CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GEMSegmentBuilder Class Reference

#include <GEMSegmentBuilder.h>

Public Member Functions

void build (const GEMRecHitCollection *rechits, GEMSegmentCollection &oc)
 
 GEMSegmentBuilder (const edm::ParameterSet &)
 
void setGeometry (const GEMGeometry *g)
 
 ~GEMSegmentBuilder ()
 Destructor. More...
 

Private Attributes

std::unique_ptr< GEMSegmentAlgorithmBasealgo
 
std::string algoName
 
const GEMGeometrygeom_
 
edm::ParameterSet segAlgoPSet
 

Detailed Description

CSCSegmentBuilder Algorithm to build GEMSegment's from GEMRecHit collection by implementing a 'build' function required by GEMSegmentProducer.

Implementation notes:
Configured via the Producer's ParameterSet.
Presume this might become an abstract base class one day.

Author
Piet Verwilligen

Definition at line 23 of file GEMSegmentBuilder.h.

Constructor & Destructor Documentation

GEMSegmentBuilder::GEMSegmentBuilder ( const edm::ParameterSet ps)
explicit

Configure the algorithm via ctor. Receives ParameterSet percolated down from EDProducer which owns this Builder.

Definition at line 12 of file GEMSegmentBuilder.cc.

References algo, algoName, reco::get(), edm::ParameterSet::getParameter(), segAlgoPSet, and AlCaHLTBitMon_QueryRunRegistry::string.

12  : geom_(nullptr) {
13 
14  // Algo name
15  algoName = ps.getParameter<std::string>("algo_name");
16 
17  edm::LogVerbatim("GEMSegmentBuilder")<< "GEMSegmentBuilder algorithm name: " << algoName;
18 
19  // SegAlgo parameter set
20  segAlgoPSet = ps.getParameter<edm::ParameterSet>("algo_pset");
21 
22  // Ask factory to build this algorithm, giving it appropriate ParameterSet
23  algo = std::unique_ptr<GEMSegmentAlgorithmBase>(GEMSegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet));
24 
25 }
T getParameter(std::string const &) const
const GEMGeometry * geom_
std::unique_ptr< GEMSegmentAlgorithmBase > algo
edm::ParameterSet segAlgoPSet
T get(const Candidate &c)
Definition: component.h:55
GEMSegmentBuilder::~GEMSegmentBuilder ( )

Destructor.

Definition at line 26 of file GEMSegmentBuilder.cc.

26 {}

Member Function Documentation

void GEMSegmentBuilder::build ( const GEMRecHitCollection rechits,
GEMSegmentCollection oc 
)

Find rechits in each ensemble of 6 GEM layers, build GEMSegment's , and fill into output collection.

Definition at line 28 of file GEMSegmentBuilder.cc.

References algo, relativeConstraints::chamber, GEMGeometry::etaPartition(), gemRecHits_cfi::gemRecHits, geom_, triggerObjects_cff::id, GEMSuperChamber::id(), LogTrace, and GEMGeometry::superChamber().

28  {
29 
30  edm::LogVerbatim("GEMSegmentBuilder")<< "[GEMSegmentBuilder::build] Total number of rechits in this event: " << recHits->size();
31 
32  // Let's define the ensemble of GEM devices having the same region, chambers number (phi)
33  // different eta partitions and different layers are allowed
34 
35  std::map<uint32_t, std::vector<GEMRecHit*> > ensembleRH;
36 
37  // Loop on the GEM rechit and select the different GEM Ensemble
38  for(GEMRecHitCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); ++it2) {
39  // GEM Ensemble is defined by assigning all the GEMDetIds of the same "superchamber"
40  // (i.e. region same, chamber same) to the DetId of the first layer
41 
42  // here a reference GEMDetId is created: named "id"
43  // - Ring 1 (no other rings available for GEM)
44  // - Layer 1 = reference layer (effective layermask)
45  // - Roll 0 = reference roll (effective rollmask)
46  // - Station == 1 (GE1/1) or == 2 (GE2/1)
47  // this reference id serves to link all GEMEtaPartitions
48  // and will also be used to determine the GEMSuperChamber
49  // to which the GEMSegment is assigned (done inside GEMSegAlgoXX)
50  GEMDetId id(it2->gemId().region(),1,it2->gemId().station(),0,it2->gemId().chamber(),0);
51  // save current GEMRecHit in vector associated to the reference id
52  ensembleRH[id.rawId()].push_back(it2->clone());
53  }
54 
55  // Loop on the entire map <ref id, vector of GEMRecHits>
56  for(auto enIt=ensembleRH.begin(); enIt != ensembleRH.end(); ++enIt) {
57 
58  std::vector<const GEMRecHit*> gemRecHits;
59  std::map<uint32_t,const GEMEtaPartition* > ens;
60 
61  // all detIds have been assigned to the to chamber
62  const GEMSuperChamber* chamber = geom_->superChamber(enIt->first);
63  for(auto rechit = enIt->second.begin(); rechit != enIt->second.end(); ++rechit) {
64  gemRecHits.push_back(*rechit);
65  ens[(*rechit)->gemId()]=geom_->etaPartition((*rechit)->gemId());
66  }
67 
68  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
69  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] -----------------------------------------------------------------------------";
70  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << gemRecHits.size() << " rechits in GEM Super Chamber " << chamber->id()<<" ::";
71  for (auto rh=gemRecHits.begin(); rh!=gemRecHits.end(); ++rh){
72  auto gemid = (*rh)->gemId();
73  // auto rhr = gemGeom->etaPartition(gemid);
74  auto rhLP = (*rh)->localPosition();
75  // auto rhGP = rhr->toGlobal(rhLP);
76  // no sense to print local y because local y here is in the roll reference frame
77  // in the roll reference frame the local y of a rechit is always the middle of the roll, and hence equal to 0.0
78  LogTrace("GEMSegmentBuilder") << "[RecHit :: Loc x = "<<std::showpos<<std::setw(9)<<rhLP.x() /*<<" Loc y = "<<std::showpos<<std::setw(9)<<rhLP.y()*/
79  <<" BX = "<<(*rh)->BunchX()<<" -- "<<gemid.rawId()<<" = "<<gemid<<" ]";
80  }
81  #endif
82 
83 
84  GEMSegmentAlgorithmBase::GEMEnsemble ensemble(std::pair<const GEMSuperChamber*, std::map<uint32_t,const GEMEtaPartition*> >(chamber,ens));
85 
86  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
87  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] run the segment reconstruction algorithm now";
88  #endif
89 
90  // given the superchamber select the appropriate algo... and run it
91  std::vector<GEMSegment> segv = algo->run(ensemble, gemRecHits);
92  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
93  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << segv.size() ;
94  #endif
95 
96  GEMDetId mid(enIt->first);
97 
98  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
99  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << segv.size() << " segments in GEM Super Chamber " << mid;
100  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] -----------------------------------------------------------------------------";
101  #endif
102 
103  // Add the segments to master collection
104  oc.put(mid, segv.begin(), segv.end());
105  }
106 }
const GEMGeometry * geom_
std::pair< const GEMSuperChamber *, std::map< uint32_t, const GEMEtaPartition * > > GEMEnsemble
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
#define LogTrace(id)
const GEMSuperChamber * superChamber(GEMDetId id) const
Definition: GEMGeometry.cc:91
GEMDetId id() const
Return the GEMDetId of this super chamber.
std::unique_ptr< GEMSegmentAlgorithmBase > algo
void GEMSegmentBuilder::setGeometry ( const GEMGeometry g)

Cache pointer to geometry for current event

Definition at line 108 of file GEMSegmentBuilder.cc.

References relativeConstraints::geom, and geom_.

108  {
109  geom_ = geom;
110 }
const GEMGeometry * geom_

Member Data Documentation

std::unique_ptr<GEMSegmentAlgorithmBase> GEMSegmentBuilder::algo
private

Definition at line 47 of file GEMSegmentBuilder.h.

Referenced by build(), and GEMSegmentBuilder().

std::string GEMSegmentBuilder::algoName
private

Definition at line 45 of file GEMSegmentBuilder.h.

Referenced by GEMSegmentBuilder().

const GEMGeometry* GEMSegmentBuilder::geom_
private

Definition at line 48 of file GEMSegmentBuilder.h.

Referenced by build(), and setGeometry().

edm::ParameterSet GEMSegmentBuilder::segAlgoPSet
private

Definition at line 46 of file GEMSegmentBuilder.h.

Referenced by GEMSegmentBuilder().