39 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: ctor] algorithm name: " << ps.getParameter<
std::string>(
"algo_name");
44 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: dstor] deleted the algorithm";
50 for (TrackingGeometry::DetContainer::const_iterator it=gemGeo->
dets().begin();it<gemGeo->
dets().end();it++)
55 std::vector< const GEMEtaPartition*> rolls = (ch->
etaPartitions());
56 for(std::vector<const GEMEtaPartition*>::const_iterator
r = rolls.begin();
r != rolls.end(); ++
r)
64 int gemchamber = gemId.
chamber();
65 int layer = gemId.
layer();
68 int cscchamber = gemchamber;
71 std::set<GEMDetId> myrolls;
73 myrolls.insert(gemId);
85 std::set<GEMDetId> map_secnd = mapit->second;
86 std::stringstream GEMRollsstream;
87 for(std::set<GEMDetId>::iterator setit=map_secnd.begin(); setit!=map_secnd.end(); ++setit)
89 GEMRollsstream<<
"[ GEM Id: "<<setit->rawId()<<
" ("<<*setit<<
")"<<
"],"<<std::endl;
92 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: LinkGEMRollsToCSCChamberIndex] CSC Station Index :: [" 94 <<
"] has following GEM rolls: ["<<GEMRollsstr<<
"]"<<std::endl;
101 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Total number of GEM rechits in this event: " << recHits->size()
102 <<
" Total number of CSC segments in this event: " << cscsegments->size();
119 std::map<uint32_t, std::vector<GEMRecHit*> > gemRecHitCollection;
120 std::map<uint32_t, std::vector<const CSCSegment*> > cscSegColl_GEM11;
121 std::map<uint32_t, std::vector<const CSCSegment*> > cscSegColl_noGEM;
129 CSCDetId CSCId = segmIt->cscDetId();
141 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Found ME1/1 Segment in "<<CSCId.
rawId()<<
" = "<<CSCId<<std::endl;
149 std::vector<const CSCSegment* > cscsegmentvector = cscSegColl_GEM11[CSCId.
rawId()];
150 cscsegmentvector.push_back(segmIt->clone());
151 cscSegColl_GEM11[CSCId.
rawId()]=cscsegmentvector;
155 std::vector<GEMDetId> rollsForThisCSCvector;
157 int cscRegion = CSCId.
endcap();
158 int cscStation = CSCId.
station();
159 int cscChamber = CSCId.
chamber();
160 int gemRegion = 1;
if(cscRegion==2) gemRegion= -1;
162 int gemStation = cscStation;
164 int gem1stChamber = cscChamber;
171 std::vector<CSCStationIndex> indexvector;
174 indexvector.push_back(index11); indexvector.push_back(index12);
181 for(std::vector<CSCStationIndex>::iterator cscIndexIt=indexvector.begin(); cscIndexIt!=indexvector.end(); ++cscIndexIt)
183 std::set<GEMDetId> rollsForThisCSC =
rollstoreCSC[*cscIndexIt];
184 for (std::set<GEMDetId>::iterator gemRollIt = rollsForThisCSC.begin(); gemRollIt != rollsForThisCSC.end(); ++gemRollIt)
186 rollsForThisCSCvector.push_back(*gemRollIt);
193 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Start Loop over GEM Rechits :: size = "<<recHits->size()
194 <<
" and number of Rolls for this CSC :: "<<rollsForThisCSCvector.size()<<std::endl;
197 GEMDetId gemIdfromHit = hitIt->gemId();
200 for (std::vector<GEMDetId>::iterator gemRollIt = rollsForThisCSCvector.begin(); gemRollIt != rollsForThisCSCvector.end(); ++gemRollIt)
204 if(gemIdfromHit == gemIdfromCSC.
rawId())
210 std::vector<GEMRecHit* > gemrechitvector = gemRecHitCollection[CSCId.
rawId()];
212 bool hitfound =
false;
213 for(std::vector<GEMRecHit*>::const_iterator it=gemrechitvector.begin(); it!=gemrechitvector.end(); ++it)
215 if(hitIt->gemId()==(*it)->gemId() && hitIt->localPosition()==(*it)->localPosition()) hitfound=
true;
217 if(!hitfound) gemrechitvector.push_back(hitIt->clone());
218 gemRecHitCollection[CSCId.
rawId()]=gemrechitvector;
219 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] GEM Rechit in "<<hitIt->gemId()<<
"["<<hitIt->gemId().rawId()
220 <<
"] added to CSC segment found in "<<CSCId<<
" ["<<CSCId.
rawId()<<
"]"<<std::endl;
232 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Found non-ME1/1 Segment in "<<CSCId.
rawId()<<
" = "<<CSCId<<std::endl;
238 std::vector<const CSCSegment* > cscsegmentvector_noGEM = cscSegColl_noGEM[CSCId.
rawId()];
239 cscsegmentvector_noGEM.push_back(segmIt->clone());
240 cscSegColl_noGEM[CSCId.
rawId()]=cscsegmentvector_noGEM;
271 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Run over the gemRecHitCollection (size = "<<gemRecHitCollection.size()<<
") and build GEMCSC Segments";
272 for(
auto gemHitIt=gemRecHitCollection.begin(); gemHitIt != gemRecHitCollection.end(); ++gemHitIt)
278 std::vector<const CSCSegment*>
cscSegments = cscSegColl_GEM11[cscId.
rawId()];
281 std::map<uint32_t, const CSCLayer* > cscLayers;
282 std::map<uint32_t, const GEMEtaPartition* > gemEtaPartitions;
286 for(std::vector<const CSCLayer*>::const_iterator layIt = cscLayerVector.begin(); layIt != cscLayerVector.end(); ++layIt)
292 for(
auto rechit = gemHitIt->second.begin(); rechit != gemHitIt->second.end(); ++rechit)
294 GEMDetId gemid = (*rechit)->gemId();
295 gemRecHits.push_back(*rechit);
300 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] ask SegmentAlgo to be run :: CSC DetId "<<cscId.
rawId()<<
" = "<<cscId
301 <<
" with "<<cscSegments.size()<<
" CSC segments and "<<gemRecHits.size()<<
" GEM rechits";
304 std::vector<GEMCSCSegment> segmentvector =
algo->run(cscLayers, gemEtaPartitions, cscSegments, gemRecHits);
307 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] SegmentAlgo ran, now trying to add the segments from the returned GEMCSCSegment vector (with size = " 308 <<segmentvector.size()<<
") to the master collection";
309 std::stringstream segmentvectorss; segmentvectorss<<
"[GEMCSCSegmentBuilder :: build] :: GEMCSC segmentvector :: elements ["<<std::endl;
310 for(std::vector<GEMCSCSegment>::const_iterator segIt = segmentvector.begin(); segIt != segmentvector.end(); ++segIt)
312 segmentvectorss<<
"[GEMCSC Segment details: \n"<<*segIt<<
"],"<<std::endl;
314 segmentvectorss<<
"]";
315 std::string segmentvectorstr = segmentvectorss.str();
321 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> GEMCSC Segments created, now try to add to the collection :: CSC DetId: "<<cscId.
rawId()<<
" = "<<cscId
322 <<
" added "<<segmentvector.size()<<
" GEMCSC Segments";
323 oc.put(cscId, segmentvector.begin(), segmentvector.end());
324 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> GEMCSC Segments added to the collection";
334 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] Run over the CSC Segment collection without GEM (size = "<<cscSegColl_noGEM.size()
335 <<
" CSC chambers with segments) and wrap GEMCSC Segments";
336 for(
auto cscSegIt=cscSegColl_noGEM.begin(); cscSegIt != cscSegColl_noGEM.end(); ++cscSegIt)
341 std::vector<const GEMRecHit*> gemRecHits_noGEM;
342 std::vector<const CSCSegment*> cscSegments_noGEM = cscSegColl_noGEM[cscSegIt->first];
343 std::vector<GEMCSCSegment> segmentvector;
345 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> Run over the CSC Segment vector without GEM (size = "<<cscSegments_noGEM.size()
346 <<
" CSC segments) and wrap GEMCSC Segments";
347 for (std::vector<const CSCSegment*>::iterator it=cscSegments_noGEM.begin(); it!=cscSegments_noGEM.end(); ++it)
350 GEMCSCSegment tmp(*it, gemRecHits_noGEM, (*it)->localPosition(), (*it)->localDirection(), (*it)->parametersError(), (*it)->chi2());
351 segmentvector.push_back(
tmp);
355 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> CSC Segments wrapped, now try to add to the collection :: CSC DetId: "<<cscId.
rawId()<<
" = "<<cscId
356 <<
" added "<<segmentvector.size()<<
" GEMCSC Segments";
357 oc.put(cscId, segmentvector.begin(), segmentvector.end());
358 edm::LogVerbatim(
"GEMCSCSegmentBuilder")<<
"[GEMCSCSegmentBuilder :: build] |--> CSC Segments added to the collection";
361 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_
constexpr uint32_t rawId() const
get the raw id
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
std::unique_ptr< GEMCSCSegmentAlgorithm > algo
C::const_iterator const_iterator
constant access iterator type
GEMCSCSegmentBuilder(const edm::ParameterSet &)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
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.
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)