Skip to content

Commit

Permalink
Merge pull request #10485 from pietverwilligen/GEMSegment_76X_v1
Browse files Browse the repository at this point in the history
Gem segment 76
  • Loading branch information
davidlange6 committed Aug 26, 2015
2 parents 8ed8251 + e0ad8cd commit 2423f1a
Show file tree
Hide file tree
Showing 34 changed files with 2,310 additions and 464 deletions.
92 changes: 92 additions & 0 deletions DataFormats/GEMRecHit/interface/ME0Segment.h
@@ -0,0 +1,92 @@
#ifndef GEMRecHit_ME0Segment_h
#define GEMRecHit_ME0Segment_h

/** \class ME0Segment derived by the CSC segment
* Describes a reconstructed track segment in the 6 layers of the ME0 system.
* This is 4-dimensional since it has an origin (x,y) and a direction (x,y)
* in the local coordinate system of the chamber.
*
* $Date: 2014/02/04 12:41:32 $
* \author Marcello Maggi
*/

#include <DataFormats/TrackingRecHit/interface/RecSegment.h>
#include <DataFormats/GEMRecHit/interface/ME0RecHitCollection.h>

#include <iosfwd>

class ME0DetId;

class ME0Segment GCC11_FINAL : public RecSegment {

public:

/// Default constructor
ME0Segment() : theChi2(0.){}

/// Constructor
ME0Segment(const std::vector<const ME0RecHit*>& proto_segment, LocalPoint origin,
LocalVector direction, AlgebraicSymMatrix errors, double chi2);

ME0Segment(const std::vector<const ME0RecHit*>& proto_segment, LocalPoint origin,
LocalVector direction, AlgebraicSymMatrix errors, double chi2, double time, double timeErr);

/// Destructor
virtual ~ME0Segment();

//--- Base class interface
ME0Segment* clone() const { return new ME0Segment(*this); }

LocalPoint localPosition() const { return theOrigin; }
LocalError localPositionError() const ;

LocalVector localDirection() const { return theLocalDirection; }
LocalError localDirectionError() const ;

/// Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
AlgebraicVector parameters() const;

/// Covariance matrix of parameters()
AlgebraicSymMatrix parametersError() const { return theCovMatrix; }

/// The projection matrix relates the trajectory state parameters to the segment parameters().
virtual AlgebraicMatrix projectionMatrix() const;

virtual std::vector<const TrackingRecHit*> recHits() const;

virtual std::vector<TrackingRecHit*> recHits();

double chi2() const { return theChi2; };

virtual int dimension() const { return 4; }

virtual int degreesOfFreedom() const { return 2*nRecHits() - 4;}

//--- Extension of the interface

const std::vector<ME0RecHit>& specificRecHits() const { return theME0RecHits; }

int nRecHits() const { return theME0RecHits.size(); }

ME0DetId me0DetId() const { return geographicalId(); }

float time() const { return theTimeValue; }
float timeErr() const { return theTimeUncrt; }

void print() const;

private:

std::vector<ME0RecHit> theME0RecHits;
LocalPoint theOrigin; // in chamber frame - the GeomDet local coordinate system
LocalVector theLocalDirection; // in chamber frame - the GeomDet local coordinate system
AlgebraicSymMatrix theCovMatrix; // the covariance matrix
double theChi2; // the Chi squared of the segment fit
double theTimeValue; // the best time estimate of the segment
double theTimeUncrt; // the uncertainty on the time estimation

};

std::ostream& operator<<(std::ostream& os, const ME0Segment& seg);

#endif
24 changes: 24 additions & 0 deletions DataFormats/GEMRecHit/interface/ME0SegmentCollection.h
@@ -0,0 +1,24 @@
#ifndef DataFormats_ME0SegmentCollection_H
#define DataFormats_ME0SegmentCollection_H

/** \class ME0SegmentCollection
*
* The collection of ME0Segment's. See \ref CSCSegmentCollection.h for details from which is derived.
*
* $Date: 2014/02/04 10:08:15 $
* \author Marcello Maggi
*/

#include <DataFormats/MuonDetId/interface/ME0DetId.h>
#include <DataFormats/GEMRecHit/interface/ME0Segment.h>

#include <DataFormats/Common/interface/RangeMap.h>
#include <DataFormats/Common/interface/ClonePolicy.h>
#include <DataFormats/Common/interface/OwnVector.h>

typedef edm::RangeMap <ME0DetId, edm::OwnVector<ME0Segment> > ME0SegmentCollection;

#include <DataFormats/Common/interface/Ref.h>
typedef edm::Ref<ME0SegmentCollection> ME0SegmentRef;

#endif
127 changes: 127 additions & 0 deletions DataFormats/GEMRecHit/src/ME0Segment.cc
@@ -0,0 +1,127 @@
/** \file ME0egment.cc
*
* $Date: 2014/02/04 12:41:33 $
* \author Marcello Maggi
*/
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <DataFormats/GEMRecHit/interface/ME0Segment.h>
#include <iostream>

namespace {
// define a Super Layer Id from the first layer of the first rechits, and put to first layer
inline
DetId buildDetId(ME0DetId id) {
return ME0DetId(id.region(),1,id.chamber(),id.roll());
}
}

class ProjectionMatrixDiag {
// Aider class to make the return of the projection Matrix thread-safe
protected:
AlgebraicMatrix theProjectionMatrix;
public:
ProjectionMatrixDiag() : theProjectionMatrix(4,5,0) {
theProjectionMatrix[0][1] = 1;
theProjectionMatrix[1][2] = 1;
theProjectionMatrix[2][3] = 1;
theProjectionMatrix[3][4] = 1;
}
const AlgebraicMatrix &getMatrix() const {
return (theProjectionMatrix);
}
};


ME0Segment::ME0Segment(const std::vector<const ME0RecHit*>& proto_segment, LocalPoint origin,
LocalVector direction, AlgebraicSymMatrix errors, double chi2) :
RecSegment(buildDetId(proto_segment.front()->me0Id())),
theOrigin(origin),
theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){
theTimeValue = 0.0;
theTimeUncrt = 0.0;
for(unsigned int i=0; i<proto_segment.size(); ++i)
theME0RecHits.push_back(*proto_segment[i]);
}

ME0Segment::ME0Segment(const std::vector<const ME0RecHit*>& proto_segment, LocalPoint origin,
LocalVector direction, AlgebraicSymMatrix errors, double chi2, double time, double timeErr) :
RecSegment(buildDetId(proto_segment.front()->me0Id())),
theOrigin(origin),
theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){
theTimeValue = time;
theTimeUncrt = timeErr;

for(unsigned int i=0; i<proto_segment.size(); ++i)
theME0RecHits.push_back(*proto_segment[i]);
}

ME0Segment::~ME0Segment() {}

std::vector<const TrackingRecHit*> ME0Segment::recHits() const{
std::vector<const TrackingRecHit*> pointersOfRecHits;
for (std::vector<ME0RecHit>::const_iterator irh = theME0RecHits.begin(); irh!=theME0RecHits.end(); ++irh) {
pointersOfRecHits.push_back(&(*irh));
}
return pointersOfRecHits;
}

std::vector<TrackingRecHit*> ME0Segment::recHits() {

std::vector<TrackingRecHit*> pointersOfRecHits;
for (std::vector<ME0RecHit>::iterator irh = theME0RecHits.begin(); irh!=theME0RecHits.end(); ++irh) {
pointersOfRecHits.push_back(&(*irh));
}
return pointersOfRecHits;
}

LocalError ME0Segment::localPositionError() const {
return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
}

LocalError ME0Segment::localDirectionError() const {
return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
}


AlgebraicVector ME0Segment::parameters() const {
// For consistency with DT and CSC and what we require for the TrackingRecHit interface,
// the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)

AlgebraicVector result(4);

if(theLocalDirection.z() != 0)
{
result[0] = theLocalDirection.x()/theLocalDirection.z();
result[1] = theLocalDirection.y()/theLocalDirection.z();
}
result[2] = theOrigin.x();
result[3] = theOrigin.y();

return result;
}

AlgebraicMatrix ME0Segment::projectionMatrix() const {
static const ProjectionMatrixDiag theProjectionMatrix;
return (theProjectionMatrix.getMatrix());
}

//
void ME0Segment::print() const {
LogDebug("ME0Segment") << *this;

}

std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) {
os << "ME0Segment: local pos = " << seg.localPosition() <<
" posErr = (" << sqrt(seg.localPositionError().xx())<<","<<sqrt(seg.localPositionError().yy())<<
"0,)\n"<<
" dir = " << seg.localDirection() <<
" dirErr = (" << sqrt(seg.localDirectionError().xx())<<","<<sqrt(seg.localDirectionError().yy())<<
"0,)\n"<<
" chi2/ndf = " << ((seg.degreesOfFreedom() != 0.) ? seg.chi2()/double(seg.degreesOfFreedom()) :0 ) <<
" #rechits = " << seg.specificRecHits().size()<<
" time = "<< seg.time() << " +/- " << seg.timeErr() << " ns ";

return os;
}

7 changes: 7 additions & 0 deletions DataFormats/GEMRecHit/src/classes.h
Expand Up @@ -4,6 +4,8 @@
#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMCSCSegment.h"
#include "DataFormats/GEMRecHit/interface/GEMCSCSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0Segment.h"
#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
#include "DataFormats/Common/interface/Wrapper.h"

namespace DataFormats_GEMRecHit {
Expand All @@ -29,6 +31,11 @@ namespace DataFormats_GEMRecHit {
GEMCSCSegmentCollection gseg;
edm::Wrapper<GEMCSCSegmentCollection> gdwc1;
GEMCSCSegmentRef gref;

ME0Segment ms;
ME0SegmentCollection seg;
edm::Wrapper<ME0SegmentCollection> dwc1;
ME0SegmentRef ref;
};
}

14 changes: 14 additions & 0 deletions DataFormats/GEMRecHit/src/classes_def.xml
Expand Up @@ -36,6 +36,17 @@
<class name="edm::Wrapper<edm::RangeMap<CSCDetId,edm::OwnVector<GEMCSCSegment,edm::ClonePolicy<GEMCSCSegment> >,edm::ClonePolicy<GEMCSCSegment> > >" splitLevel="0"/>
<class name="GEMCSCSegmentRef" splitLevel="0"/>

<class name="ME0Segment" ClassVersion="12">
<version ClassVersion="12" checksum="759556370"/>
<version ClassVersion="11" checksum="513208975"/>
<version ClassVersion="10" checksum="2562385753"/>
</class>
<class name="std::vector<ME0Segment*>" splitLevel="0"/>
<class name="edm::OwnVector<ME0Segment,edm::ClonePolicy<ME0Segment> >" splitLevel="0"/>
<class name="edm::RangeMap<ME0DetId,edm::OwnVector<ME0Segment,edm::ClonePolicy<ME0Segment> >,edm::ClonePolicy<ME0Segment> >" splitLevel="0"/>
<class name="edm::Wrapper<edm::RangeMap<ME0DetId,edm::OwnVector<ME0Segment,edm::ClonePolicy<ME0Segment> >,edm::ClonePolicy<ME0Segment> > >" splitLevel="0"/>
<class name="ME0SegmentRef" splitLevel="0"/>

</selection>
<exclusion>
<class name="edm::OwnVector<GEMRecHit, edm::ClonePolicy<GEMRecHit> >">
Expand All @@ -47,5 +58,8 @@
<class name="edm::OwnVector<GEMCSCSegment, edm::ClonePolicy<GEMCSCSegment> >">
<method name="sort" splitLevel="0"/>
</class>
<class name="edm::OwnVector<ME0Segment, edm::ClonePolicy<ME0Segment> >">
<method name="sort" splitLevel="0"/>
</class>
</exclusion>
</lcgdict>
37 changes: 23 additions & 14 deletions DataFormats/MuonDetId/interface/ME0DetId.h
Expand Up @@ -47,39 +47,47 @@ class ME0DetId :public DetId {
return int((id_>>RegionStartBit_) & RegionMask_) + minRegionId;
}

/// Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 6 is the outer chamber
int layer() const{
return int((id_>>LayerStartBit_) & LayerMask_) + minLayerId;
}

/// Chamber id: it identifies a chamber in a ring it goes from 1 to 36
int chamber() const{
return int((id_>>ChamberStartBit_) & ChamberMask_) + minChamberId;
}

/// Roll id (also known as eta partition): each chamber is divided along the strip direction in
/// several parts (rolls) ME0 up to 10
/// Layer id: each chamber has six layers of chambers: layer 1 is the inner layer and layer 6 is the outer layer
int layer() const{
return int((id_>>LayerStartBit_) & LayerMask_) + minLayerId;
}

/// Roll id (also known as eta partition): each chamber is divided along the strip direction in
/// several parts (rolls) ME0 up to 10
int roll() const{
return int((id_>>RollStartBit_) & RollMask_) + minRollId; // value 0 is used as wild card
}


/// Return the corresponding ChamberId
/// Return the corresponding ChamberId (mask layers)
ME0DetId chamberId() const {
return ME0DetId(id_ & chamberIdMask_);
return ME0DetId(id_ & chamberIdMask_ & layerIdMask_);
}
/// Return the corresponding LayerId (mask eta partition)
ME0DetId layerId() const {
return ME0DetId(id_ & layerIdMask_);
}

/// For future modifications (implement more layers)
int nlayers() const{
return int(maxLayerId);
}

static const int minRegionId= -1;
static const int maxRegionId= 1;

static const int minChamberId= 0;
static const int maxChamberId= 36;
static const int maxChamberId= 36; // ME0 ring consists of 36 chambers spanning 10 degrees

static const int minLayerId= 0;
static const int maxLayerId= 31;
static const int maxLayerId= 6; // ME0 chamber consists of 6 layers for now, change here when changing ME0 Geometry

static const int minRollId= 0;
static const int maxRollId= 31;
static const int maxRollId= 1; // ME0 layer consits of 1 etapartition for now, change here when changing ME0 Geometry

private:
static const int RegionNumBits_ = 2;
Expand All @@ -98,7 +106,8 @@ class ME0DetId :public DetId {
static const int RollStartBit_ = LayerStartBit_+LayerNumBits_;
static const unsigned int RollMask_ = 0X1F;

static const uint32_t chamberIdMask_ = ~(RollMask_<<RollStartBit_);
static const uint32_t chamberIdMask_ = ~( (LayerMask_<<LayerStartBit_) | (RollMask_<<RollStartBit_));
static const uint32_t layerIdMask_ = ~(RollMask_<<RollStartBit_);

private:
void init(int region,
Expand Down
11 changes: 8 additions & 3 deletions DataFormats/MuonDetId/test/testME0DetId.cc
Expand Up @@ -112,15 +112,20 @@ void testME0DetId::testFail(){


void testME0DetId::testMemberOperators(){
ME0DetId unit1(1,5,3,5);
ME0DetId unit1(1,5,3,1);
ME0DetId unit2=unit1;

CPPUNIT_ASSERT(unit2==unit1);

ME0DetId chamber = unit1.chamberId();
ME0DetId layer = unit1.layerId();
ME0DetId unit3(1,5,3,0);

CPPUNIT_ASSERT(chamber==unit3);
CPPUNIT_ASSERT(layer==unit3);

ME0DetId chamber = unit1.chamberId();
ME0DetId unit4(1,0,3,0);

CPPUNIT_ASSERT(chamber==unit4);


}

0 comments on commit 2423f1a

Please sign in to comment.