38 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: ctor] algorithm name: " << algoName;
51 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: dstor] deleted the algorithm";
57 for (TrackingGeometry::DetContainer::const_iterator it=gemGeo->
dets().begin();it<gemGeo->
dets().end();it++)
62 std::vector< const GEMEtaPartition*> rolls = (ch->
etaPartitions());
63 for(std::vector<const GEMEtaPartition*>::const_iterator
r = rolls.begin();
r != rolls.end(); ++
r)
71 int gemchamber = gemId.
chamber();
72 int layer = gemId.
layer();
75 int cscchamber = gemchamber;
78 std::set<GEMDetId> myrolls;
80 myrolls.insert(gemId);
92 std::set<GEMDetId> map_secnd = mapit->second;
93 std::stringstream GEMRollsstream;
94 for(std::set<GEMDetId>::iterator setit=map_secnd.begin(); setit!=map_secnd.end(); ++setit)
96 GEMRollsstream<<
"[ GEM Id: "<<setit->rawId()<<
" ("<<*setit<<
")"<<
"],"<<std::endl;
99 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: LinkGEMRollsToCSCChamberIndex] CSC Station Index :: ["
101 <<
"] has following GEM rolls: ["<<GEMRollsstr<<
"]"<<std::endl;
108 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Total number of GEM rechits in this event: " << recHits->size()
109 <<
" Total number of CSC segments in this event: " << cscsegments->size();
126 std::map<uint32_t, std::vector<GEMRecHit*> > gemRecHitCollection;
127 std::map<uint32_t, std::vector<const CSCSegment*> > cscSegColl_GEM11;
128 std::map<uint32_t, std::vector<const CSCSegment*> > cscSegColl_noGEM;
136 CSCDetId CSCId = segmIt->cscDetId();
148 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Found ME1/1 Segment in "<<CSCId.
rawId()<<
" = "<<CSCId<<std::endl;
156 std::vector<const CSCSegment* > cscsegmentvector = cscSegColl_GEM11[CSCId.
rawId()];
157 cscsegmentvector.push_back(segmIt->clone());
158 cscSegColl_GEM11[CSCId.
rawId()]=cscsegmentvector;
162 std::vector<GEMDetId> rollsForThisCSCvector;
164 int cscRegion = CSCId.
endcap();
165 int cscStation = CSCId.
station();
166 int cscChamber = CSCId.
chamber();
167 int gemRegion = 1;
if(cscRegion==2) gemRegion= -1;
169 int gemStation = cscStation;
171 int gem1stChamber = cscChamber;
178 std::vector<CSCStationIndex> indexvector;
181 indexvector.push_back(index11); indexvector.push_back(index12);
188 for(std::vector<CSCStationIndex>::iterator cscIndexIt=indexvector.begin(); cscIndexIt!=indexvector.end(); ++cscIndexIt)
190 std::set<GEMDetId> rollsForThisCSC =
rollstoreCSC[*cscIndexIt];
191 for (std::set<GEMDetId>::iterator gemRollIt = rollsForThisCSC.begin(); gemRollIt != rollsForThisCSC.end(); ++gemRollIt)
193 rollsForThisCSCvector.push_back(*gemRollIt);
200 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Start Loop over GEM Rechits :: size = "<<recHits->size()
201 <<
" and number of Rolls for this CSC :: "<<rollsForThisCSCvector.size()<<std::endl;
204 GEMDetId gemIdfromHit = hitIt->gemId();
207 for (std::vector<GEMDetId>::iterator gemRollIt = rollsForThisCSCvector.begin(); gemRollIt != rollsForThisCSCvector.end(); ++gemRollIt)
211 if(gemIdfromHit == gemIdfromCSC.
rawId())
217 std::vector<GEMRecHit* > gemrechitvector = gemRecHitCollection[CSCId.
rawId()];
219 bool hitfound =
false;
220 for(std::vector<GEMRecHit*>::const_iterator it=gemrechitvector.begin(); it!=gemrechitvector.end(); ++it)
222 if(hitIt->gemId()==(*it)->gemId() && hitIt->localPosition()==(*it)->localPosition()) hitfound=
true;
224 if(!hitfound) gemrechitvector.push_back(hitIt->clone());
225 gemRecHitCollection[CSCId.
rawId()]=gemrechitvector;
226 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] GEM Rechit in "<<hitIt->gemId()<<
"["<<hitIt->gemId().rawId()
227 <<
"] added to CSC segment found in "<<CSCId<<
" ["<<CSCId.
rawId()<<
"]"<<std::endl;
239 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Found non-ME1/1 Segment in "<<CSCId.
rawId()<<
" = "<<CSCId<<std::endl;
245 std::vector<const CSCSegment* > cscsegmentvector_noGEM = cscSegColl_noGEM[CSCId.
rawId()];
246 cscsegmentvector_noGEM.push_back(segmIt->clone());
247 cscSegColl_noGEM[CSCId.
rawId()]=cscsegmentvector_noGEM;
278 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Run over the gemRecHitCollection (size = "<<gemRecHitCollection.size()<<
") and build GEMCSC Segments";
279 for(
auto gemHitIt=gemRecHitCollection.begin(); gemHitIt != gemRecHitCollection.end(); ++gemHitIt)
285 std::vector<const CSCSegment*>
cscSegments = cscSegColl_GEM11[cscId.
rawId()];
288 std::map<uint32_t, const CSCLayer* > cscLayers;
289 std::map<uint32_t, const GEMEtaPartition* > gemEtaPartitions;
293 for(std::vector<const CSCLayer*>::const_iterator layIt = cscLayerVector.begin(); layIt != cscLayerVector.end(); ++layIt)
299 for(
auto rechit = gemHitIt->second.begin(); rechit != gemHitIt->second.end(); ++rechit)
301 GEMDetId gemid = (*rechit)->gemId();
302 gemRecHits.push_back(*rechit);
307 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] ask SegmentAlgo to be run :: CSC DetId "<<cscId.
rawId()<<
" = "<<cscId
308 <<
" with "<<cscSegments.size()<<
" CSC segments and "<<gemRecHits.size()<<
" GEM rechits";
311 std::vector<GEMCSCSegment> segmentvector =
algo->
run(cscLayers, gemEtaPartitions, cscSegments, gemRecHits);
314 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] SegmentAlgo ran, now trying to add the segments from the returned GEMCSCSegment vector (with size = "
315 <<segmentvector.size()<<
") to the master collection";
316 std::stringstream segmentvectorss; segmentvectorss<<
"[GEMCSCSegmentBuilder :: build] :: GEMCSC segmentvector :: elements ["<<std::endl;
317 for(std::vector<GEMCSCSegment>::const_iterator segIt = segmentvector.begin(); segIt != segmentvector.end(); ++segIt)
319 segmentvectorss<<
"[GEMCSC Segment details: \n"<<*segIt<<
"],"<<std::endl;
321 segmentvectorss<<
"]";
322 std::string segmentvectorstr = segmentvectorss.str();
328 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> GEMCSC Segments created, now try to add to the collection :: CSC DetId: "<<cscId.
rawId()<<
" = "<<cscId
329 <<
" added "<<segmentvector.size()<<
" GEMCSC Segments";
330 oc.put(cscId, segmentvector.begin(), segmentvector.end());
331 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> GEMCSC Segments added to the collection";
341 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Run over the CSC Segment collection without GEM (size = "<<cscSegColl_noGEM.size()
342 <<
" CSC chambers with segments) and wrap GEMCSC Segments";
343 for(
auto cscSegIt=cscSegColl_noGEM.begin(); cscSegIt != cscSegColl_noGEM.end(); ++cscSegIt)
348 std::vector<const GEMRecHit*> gemRecHits_noGEM;
349 std::vector<const CSCSegment*> cscSegments_noGEM = cscSegColl_noGEM[cscSegIt->first];
350 std::vector<GEMCSCSegment> segmentvector;
352 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> Run over the CSC Segment vector without GEM (size = "<<cscSegments_noGEM.size()
353 <<
" CSC segments) and wrap GEMCSC Segments";
354 for (std::vector<const CSCSegment*>::iterator it=cscSegments_noGEM.begin(); it!=cscSegments_noGEM.end(); ++it)
357 GEMCSCSegment tmp(*it, gemRecHits_noGEM, (*it)->localPosition(), (*it)->localDirection(), (*it)->parametersError(), (*it)->chi2());
358 segmentvector.push_back(
tmp);
362 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> CSC Segments wrapped, now try to add to the collection :: CSC DetId: "<<cscId.
rawId()<<
" = "<<cscId
363 <<
" added "<<segmentvector.size()<<
" GEMCSC Segments";
364 oc.put(cscId, segmentvector.begin(), segmentvector.end());
365 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> CSC Segments added to the collection";
368 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] job done !!!";
T getParameter(std::string const &) const
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
void LinkGEMRollsToCSCChamberIndex(const GEMGeometry *gemgeom, const CSCGeometry *cscgeom)
const CSCGeometry * cscgeom_
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
virtual const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
uint32_t rawId() const
get the raw id
GEMCSCSegmentBuilder(const edm::ParameterSet &)
int layer() const
Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 2 is the o...
int station() const
Station id : the station is the pair of chambers at same disk.
std::map< CSCStationIndex, std::set< GEMDetId > > rollstoreCSC
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return the eta partitions.
void build(const GEMRecHitCollection *rechits, const CSCSegmentCollection *cscsegments, GEMCSCSegmentCollection &oc)
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
virtual std::vector< GEMCSCSegment > run(const std::map< uint32_t, const CSCLayer * > &csclayermap, const std::map< uint32_t, const GEMEtaPartition * > &gemrollmap, const std::vector< const CSCSegment * > &cscsegments, const std::vector< const GEMRecHit * > &gemrechits)=0
Run the algorithm = build segments.
GEMCSCSegmentAlgorithm * algo
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
const GEMGeometry * gemgeom_
std::vector< std::vector< double > > tmp
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
void setGeometry(const GEMGeometry *gemgeom, const CSCGeometry *cscgeom)
T get(const Candidate &c)