Skip to content

Commit

Permalink
Merge pull request #9083 from pietverwilligen/GEMCSCSegment_75X_PR_v3
Browse files Browse the repository at this point in the history
Gemcsc segment 75X
  • Loading branch information
cmsbuild committed Jun 10, 2015
2 parents 13f1a1c + a047130 commit e47b70f
Show file tree
Hide file tree
Showing 26 changed files with 4,169 additions and 20 deletions.
4 changes: 3 additions & 1 deletion DataFormats/GEMRecHit/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/GeometryVector"/>
<use name="DataFormats/MuonDetId"/>
<use name="DataFormats/TrackingRecHit"/>

<use name="DataFormats/GeometryVector"/>
<use name="DataFormats/CSCRecHit"/>
<use name="rootrflx"/>

<export>
Expand Down
98 changes: 98 additions & 0 deletions DataFormats/GEMRecHit/interface/GEMCSCSegment.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#ifndef GEMRecHit_GEMCSCSegment_h
#define GEMRecHit_GEMCSCSegment_h

/** \class GEMCSCSegment
*
* Based on CSCSegment class
* Describes a reconstructed track segment in the GEM + CSC chambers.
* This is 4-dimensional since it has an origin (x,y) and a direction (x,y)
* in the local coordinate system of the (csc) chamber.
*
* \author R. Radogna
*/

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

#include <DataFormats/GEMRecHit/interface/GEMRecHitCollection.h>
#include <DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h>
#include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>

#include <FWCore/MessageLogger/interface/MessageLogger.h>

#include <iosfwd>

class CSCDetId;

class GEMCSCSegment GCC11_FINAL : public RecSegment {

public:

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

/// Constructor
GEMCSCSegment(const CSCSegment* csc_segment, const std::vector<const GEMRecHit*> gem_rhs, LocalPoint origin, LocalVector direction, AlgebraicSymMatrix errors, double chi2);

/// Destructor
virtual ~GEMCSCSegment();

//--- Base class interface
GEMCSCSegment* clone() const { return new GEMCSCSegment(*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;

double chi2() const { return theChi2; };

virtual int dimension() const { return 4; }

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

int nRecHits() const
{
return (theGEMRecHits.size() + theCSCSegment.specificRecHits().size());
edm::LogVerbatim("GEMCSCSegment")<< "[GEMCSCSegment :: nRecHits] CSC RecHits: " <<theCSCSegment.specificRecHits().size()
<< " + GEM RecHits: " << theGEMRecHits.size() << " = " <<(theGEMRecHits.size() + theCSCSegment.specificRecHits().size());
}


//--- Return the constituents in different ways
const CSCSegment cscSegment() const { return theCSCSegment; }
const std::vector<GEMRecHit>& gemRecHits() const { return theGEMRecHits; }
const std::vector<CSCRecHit2D>& cscRecHits() const { return theCSCSegment.specificRecHits(); }
virtual std::vector<const TrackingRecHit*> recHits() const;
virtual std::vector<TrackingRecHit*> recHits();

CSCDetId cscDetId() const { return geographicalId(); }

void print() const;

private:
std::vector<GEMRecHit> theGEMRecHits; // store GEM Rechits
CSCSegment theCSCSegment; // store CSC RecHits and store CSC Segment
// eventually we have to disentangle if later on we decide
// not to have a one-to-one relationship anymore
// i.e. if we allow the GEMCSC segment to modify the
// (selection of the rechits of the) CSC segment
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;

};

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

#endif
27 changes: 27 additions & 0 deletions DataFormats/GEMRecHit/interface/GEMCSCSegmentCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef DataFormats_GEMCSCSegmentCollection_H
#define DataFormats_GEMCSCSegmentCollection_H

/** \class GEMCSCSegmentCollection
*
* The collection of GEMCSCSegment's. See \ref GEMCSCSegmentCollection.h for details.
*
* $Date: $
* \author Raffaella Radogna
*/

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

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


typedef edm::RangeMap <CSCDetId, edm::OwnVector<GEMCSCSegment> > GEMCSCSegmentCollection;

#include <DataFormats/Common/interface/Ref.h>
typedef edm::Ref<GEMCSCSegmentCollection> GEMCSCSegmentRef;


#endif
127 changes: 127 additions & 0 deletions DataFormats/GEMRecHit/src/GEMCSCSegment.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/** \file GEMCSCSegment.cc
*
* Based on CSCSegment class
* \author Raffaella Radogna
*/

#include <DataFormats/GEMRecHit/interface/GEMCSCSegment.h>
#include <iostream>


namespace {
// Get CSCDetId from one of the rechits, but then remove the layer part so it's a _chamber_ id
inline
DetId buildDetId(CSCDetId id) {
return CSCDetId (id.endcap(),id.station(),id.ring(),id.chamber(),0);
}
}


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);
}
};




GEMCSCSegment::GEMCSCSegment(const CSCSegment* csc_segment, const std::vector<const GEMRecHit*> gem_rhs, LocalPoint origin, LocalVector direction, AlgebraicSymMatrix errors, double chi2) :

RecSegment(buildDetId(csc_segment->cscDetId())),
theOrigin(origin),
theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2) {

for(unsigned int i=0; i<gem_rhs.size(); ++i) {
theGEMRecHits.push_back((*gem_rhs[i]));
}
theCSCSegment = *csc_segment;
// LogDebug
edm::LogVerbatim("GEMCSCSegment")<< "[GEMCSCSegment :: ctor] CSCDetId: " << csc_segment->cscDetId() << " CSC RecHits: " <<csc_segment->specificRecHits().size()
<< " GEM RecHits: " << gem_rhs.size()<<"\n" // << " Fit chi2: "<<chi2<<" Position: "<<origin<<" Direction: "<<direction
<< " CSC Segment Details: \n"<<*csc_segment<<"\n"
<< " GEMCSC Segment Details: \n"<<*this<<"\n"
<< "[GEMCSCSegment :: ctor] ------------------------------------------------------------";
}


GEMCSCSegment::~GEMCSCSegment() {}


std::vector<const TrackingRecHit*> GEMCSCSegment::recHits() const{

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

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

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


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


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


AlgebraicVector GEMCSCSegment::parameters() const {
// For consistency with DT, 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 GEMCSCSegment::projectionMatrix() const {
static const ProjectionMatrixDiag theProjectionMatrix;
return (theProjectionMatrix.getMatrix());
}




std::ostream& operator<<(std::ostream& os, const GEMCSCSegment& seg) {
os << "GEMCSCSegment: 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.0) <<
" #rechits = " << seg.nRecHits();
return os;
}


8 changes: 7 additions & 1 deletion DataFormats/GEMRecHit/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0RecHit.h"
#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMCSCSegment.h"
#include "DataFormats/GEMRecHit/interface/GEMCSCSegmentCollection.h"
#include "DataFormats/Common/interface/Wrapper.h"

namespace {
namespace DataFormats_GEMRecHit {
struct dictionary {
std::pair<unsigned int, unsigned int> dummyrpc1;
std::pair<unsigned long, unsigned long> dummyrpc2;
Expand All @@ -23,6 +25,10 @@ namespace {
ME0RecHitCollection mc;
edm::Wrapper<ME0RecHitCollection> mw;

GEMCSCSegment gs;
GEMCSCSegmentCollection gseg;
edm::Wrapper<GEMCSCSegmentCollection> gdwc1;
GEMCSCSegmentRef gref;
};
}

24 changes: 17 additions & 7 deletions DataFormats/GEMRecHit/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<lcgdict>
<selection>

<class name="GEMRecHit" splitLevel="0" ClassVersion="11">
<version ClassVersion="11" checksum="3146992425"/>
<version ClassVersion="10" checksum="3680872192"/>
Expand All @@ -13,8 +14,8 @@
<class name="edm::Wrapper<edm::RangeMap<GEMDetId, edm::OwnVector<GEMRecHit, edm::ClonePolicy<GEMRecHit> >, edm::ClonePolicy<GEMRecHit> > >" splitLevel="0"/>

<class name="ME0RecHit" splitLevel="0" ClassVersion="11">
<version ClassVersion="11" checksum="3948270793"/>
<version ClassVersion="10" checksum="2817146898"/>
<version ClassVersion="11" checksum="3948270793"/>
<version ClassVersion="10" checksum="2817146898"/>
</class>
<class name="std::vector<ME0RecHit>" splitLevel="0"/>
<class name="std::vector<ME0RecHit*>" splitLevel="0"/>
Expand All @@ -24,18 +25,27 @@
<class name="edm::RangeMap<ME0DetId, edm::OwnVector<ME0RecHit, edm::ClonePolicy<ME0RecHit> >, edm::ClonePolicy<ME0RecHit> >" splitLevel="0"/>
<class name="edm::Wrapper<edm::RangeMap<ME0DetId, edm::OwnVector<ME0RecHit, edm::ClonePolicy<ME0RecHit> >, edm::ClonePolicy<ME0RecHit> > >" splitLevel="0"/>

</selection>

<class name="GEMCSCSegment" splitLevel="0" ClassVersion="12">
<version ClassVersion="12" checksum="3885697532"/>
<version ClassVersion="11" checksum="2470665576"/>
<version ClassVersion="10" checksum="2470665576"/>
</class>
<class name="std::vector<GEMCSCSegment*>" splitLevel="0"/>
<class name="edm::OwnVector<GEMCSCSegment,edm::ClonePolicy<GEMCSCSegment> >" splitLevel="0"/>
<class name="edm::RangeMap<CSCDetId,edm::OwnVector<GEMCSCSegment,edm::ClonePolicy<GEMCSCSegment> >,edm::ClonePolicy<GEMCSCSegment> >" splitLevel="0"/>
<class name="edm::Wrapper<edm::RangeMap<CSCDetId,edm::OwnVector<GEMCSCSegment,edm::ClonePolicy<GEMCSCSegment> >,edm::ClonePolicy<GEMCSCSegment> > >" splitLevel="0"/>
<class name="GEMCSCSegmentRef" splitLevel="0"/>

</selection>
<exclusion>
<class name="edm::OwnVector<GEMRecHit, edm::ClonePolicy<GEMRecHit> >">
<method name="sort" splitLevel="0"/>
</class>

<class name="edm::OwnVector<ME0RecHit, edm::ClonePolicy<ME0RecHit> >">
<method name="sort" splitLevel="0"/>
</class>


<class name="edm::OwnVector<GEMCSCSegment, edm::ClonePolicy<GEMCSCSegment> >">
<method name="sort" splitLevel="0"/>
</class>
</exclusion>
</lcgdict>
23 changes: 23 additions & 0 deletions RecoLocalMuon/GEMCSCSegment/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/Utilities"/>

<use name="CommonTools/Statistics"/>

<use name="DataFormats/CSCRecHit"/>
<use name="DataFormats/GEMRecHit"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/GeometryVector"/>
<use name="DataFormats/MuonDetId"/>

<use name="Geometry/CSCGeometry"/>
<use name="Geometry/GEMGeometry"/>
<use name="Geometry/Records"/>

<use name="rootcore"/>
<use name="rootgraphics"/>
<use name="Root"/>

<flags EDM_PLUGIN="1"/>

0 comments on commit e47b70f

Please sign in to comment.