Skip to content

Commit

Permalink
Merge pull request cms-sw#200 from jshlee/trackerGEM-GEMGeo
Browse files Browse the repository at this point in the history
Tracker gem gem geo
  • Loading branch information
jshlee committed Apr 27, 2016
2 parents d0f79ca + d4a2166 commit 7f5227d
Show file tree
Hide file tree
Showing 64 changed files with 3,143 additions and 301 deletions.
Expand Up @@ -2,7 +2,7 @@

# Ideal geometry, needed for transient ECAL alignement
from Configuration.Geometry.GeometryExtended2015MuonGEMDev_cff import *
from Configuration.Geometry.GeometryReco_cff import *
from Configuration.Geometry.GeometryRecoDB_cff import *

from Geometry.GEMGeometryBuilder.gemGeometry_cfi import *
from Geometry.GEMGeometryBuilder.me0Geometry_cfi import *
Expand Down
Expand Up @@ -5,7 +5,11 @@
#
# Ideal geometry, needed for simulation
from Geometry.CMSCommonData.cmsExtendedGeometry2015MuonGEMDevXML_cfi import *
from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *
from Geometry.HcalCommonData.hcalParameters_cfi import *
#from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *
#from Geometry.HcalCommonData.hcalParameters_cfi import *
#from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import *

from Geometry.MuonNumbering.muonNumberingInitialization_cfi import *
from Geometry.TrackerNumberingBuilder.trackerNumberingGeometryDB_cfi import *
from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import *

119 changes: 119 additions & 0 deletions DataFormats/GEMRecHit/interface/GEMSegment.h
@@ -0,0 +1,119 @@
#ifndef GEMRecHit_GEMSegment_h
#define GEMRecHit_GEMSegment_h

/** \class GEMSegment derived by the CSC segment
* Describes a reconstructed track segment in the 2+ layers of a GEM chamber.
* This is 4-dimensional since it has an origin (x,y) and a direction (x,y)
* in the local coordinate system of the chamber.
*
* \author Piet Verwilligen
*/

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

#include <iosfwd>

class GEMDetId;

class GEMSegment GCC11_FINAL : public RecSegment {

public:

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

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

GEMSegment(const std::vector<const GEMRecHit*>& proto_segment, LocalPoint origin,
LocalVector direction, AlgebraicSymMatrix errors, double chi2, float bx);

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

/// Destructor
virtual ~GEMSegment();

//--- Base class interface
GEMSegment* clone() const { return new GEMSegment(*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<GEMRecHit>& specificRecHits() const { return theGEMRecHits; }

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

GEMDetId gemDetId() const {
DetId detid = geographicalId();
GEMDetId rollid = GEMDetId(detid);
GEMDetId chamid = rollid.superChamberId();
return chamid;
}

/*
GEMDetId gemDetId() const {
// this geographical id comes from the RecSegment.
// in .cc we have defined to choose always ST3 for GE2/1
// and always choose Layer 1 in general
DetId detid = geographicalId();
GEMDetId rollid = GEMDetId(detid);
GEMDetId chamid = rollid.chamberId();
// for GE1/1 this chamber id is fine
// for GE2/1 the station can be 2 or 3 and we want to fix it to 3
if(chamid.station()==1) return chamid;
else if(chamid.station()==2) {
// GEMDetId:: Re Ri St La Ch Ro
return GEMDetId(chamid.region(),1,3,1,chamid.chamber(),0);
}
else if(chamid.station()==3) return chamid;
else return chamid;
}
*/

float time() const { return theTimeValue; }
float timeErr() const { return theTimeUncrt; }
float BunchX() const { return theBX; }
void print() const;

private:

std::vector<GEMRecHit> theGEMRecHits;
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
float theBX; // the bunch crossing
};

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

#endif
23 changes: 23 additions & 0 deletions DataFormats/GEMRecHit/interface/GEMSegmentCollection.h
@@ -0,0 +1,23 @@
#ifndef DataFormats_GEMSegmentCollection_H
#define DataFormats_GEMSegmentCollection_H

/** \class GEMSegmentCollection
*
* The collection of GEMSegment's. See \ref CSCSegmentCollection.h for details from which is derived.
*
* \author Piet Verwilligen
*/

#include <DataFormats/MuonDetId/interface/GEMDetId.h>
#include <DataFormats/GEMRecHit/interface/GEMSegment.h>

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

typedef edm::RangeMap <GEMDetId, edm::OwnVector<GEMSegment> > GEMSegmentCollection;

#include <DataFormats/Common/interface/Ref.h>
typedef edm::Ref<GEMSegmentCollection> GEMSegmentRef;

#endif
147 changes: 147 additions & 0 deletions DataFormats/GEMRecHit/src/GEMSegment.cc
@@ -0,0 +1,147 @@
/** \file GEMegment.cc
*
* \author Piet Verwilligen
*/
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <DataFormats/GEMRecHit/interface/GEMSegment.h>
#include <iostream>

namespace {
// create reference GEM Chamber ID for segment
inline
DetId buildDetId(GEMDetId id) {
// GE1/1 => station 1
// GE2/1 => station 2 & 3 => combine Short & Long to mimick future technology that can have 4+ layers
int station, layer;
if (id.station()==1) station = 1;
else if (id.station()==2 || id.station()==3) station = 3;
else station = 0;
layer = 0;
return GEMDetId(id.region(),id.ring(),station,layer,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);
}
};


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

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

GEMSegment::GEMSegment(const std::vector<const GEMRecHit*>& proto_segment, LocalPoint origin,
LocalVector direction, AlgebraicSymMatrix errors, double chi2, double time, double timeErr) :
RecSegment(buildDetId(proto_segment.front()->gemId())),
theOrigin(origin),
theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){
theTimeValue = time;
theTimeUncrt = timeErr;
theBX = -10.0;
for(unsigned int i=0; i<proto_segment.size(); ++i)
theGEMRecHits.push_back(*proto_segment[i]);
}

GEMSegment::~GEMSegment() {}

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

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

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

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

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


AlgebraicVector GEMSegment::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 GEMSegment::projectionMatrix() const {
static const ProjectionMatrixDiag theProjectionMatrix;
return (theProjectionMatrix.getMatrix());
}

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

}

std::ostream& operator<<(std::ostream& os, const GEMSegment& seg) {
os << "GEMSegment: 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()<<
" bx = "<< seg.BunchX() <<
" time = "<< seg.time() << " +/- " << seg.timeErr() << " ns";

return os;
}

15 changes: 11 additions & 4 deletions DataFormats/GEMRecHit/src/classes.h
Expand Up @@ -4,16 +4,18 @@
#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMCSCSegment.h"
#include "DataFormats/GEMRecHit/interface/GEMCSCSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMSegment.h"
#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0Segment.h"
#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
#include "DataFormats/Common/interface/Wrapper.h"

namespace DataFormats_GEMRecHit {
struct dictionary {
std::pair<unsigned int, unsigned int> dummyrpc1;
std::pair<unsigned long, unsigned long> dummyrpc2;
std::map<GEMDetId, std::pair<unsigned int, unsigned int> > dummyrpcdetid1;
std::map<GEMDetId, std::pair<unsigned long, unsigned long> > dummyrpcdetid2;
std::pair<unsigned int, unsigned int> dummygem1;
std::pair<unsigned long, unsigned long> dummygem2;
std::map<GEMDetId, std::pair<unsigned int, unsigned int> > dummygemdetid1;
std::map<GEMDetId, std::pair<unsigned long, unsigned long> > dummygemdetid2;
std::map<ME0DetId, std::pair<unsigned int, unsigned int> > dummyme0detid1;
std::map<ME0DetId, std::pair<unsigned long, unsigned long> > dummyme0detid2;

Expand All @@ -36,6 +38,11 @@ namespace DataFormats_GEMRecHit {
ME0SegmentCollection seg;
edm::Wrapper<ME0SegmentCollection> dwc1;
ME0SegmentRef ref;

GEMSegment gems;
GEMSegmentCollection gemseg;
edm::Wrapper<GEMSegmentCollection> gemdwc1;
GEMCSCSegmentRef gemref;
};
}

9 changes: 9 additions & 0 deletions DataFormats/GEMRecHit/src/classes_def.xml
Expand Up @@ -36,6 +36,15 @@
<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="GEMSegment" ClassVersion="-1">
<version ClassVersion="-1" checksum="1513163288"/>
</class>
<class name="std::vector<GEMSegment*>" splitLevel="0"/>
<class name="edm::OwnVector<GEMSegment,edm::ClonePolicy<GEMSegment> >" splitLevel="0"/>
<class name="edm::RangeMap<GEMDetId,edm::OwnVector<GEMSegment,edm::ClonePolicy<GEMSegment> >,edm::ClonePolicy<GEMSegment> >" splitLevel="0"/>
<class name="edm::Wrapper<edm::RangeMap<GEMDetId,edm::OwnVector<GEMSegment,edm::ClonePolicy<GEMSegment> >,edm::ClonePolicy<GEMSegment> > >" splitLevel="0"/>
<class name="GEMSegmentRef" splitLevel="0"/>

<class name="ME0Segment" ClassVersion="12">
<version ClassVersion="12" checksum="759556370"/>
<version ClassVersion="11" checksum="513208975"/>
Expand Down

0 comments on commit 7f5227d

Please sign in to comment.