@@ -27,7 +27,8 @@ TrackerHitAssociator::TrackerHitAssociator(const edm::Event& e) :
27
27
myEvent_(e),
28
28
doPixel_( true ),
29
29
doStrip_( true ),
30
- doTrackAssoc_( false ) {
30
+ doTrackAssoc_( false ),
31
+ useCFpos_( false ) {
31
32
trackerContainers.clear ();
32
33
//
33
34
// Take by default all tracker SimHits
@@ -56,14 +57,19 @@ TrackerHitAssociator::TrackerHitAssociator(const edm::Event& e) :
56
57
}
57
58
58
59
std::auto_ptr<MixCollection<PSimHit> > allTrackerHits (new MixCollection<PSimHit>(cf_simhitvec));
59
- TrackerHits = (*allTrackerHits);
60
+ // TrackerHits = (*allTrackerHits);
60
61
61
62
// Loop on PSimHit
62
63
SimHitMap.clear ();
64
+ SimHitSubdetMap.clear ();
63
65
64
66
MixCollection<PSimHit>::iterator isim;
65
67
for (isim=allTrackerHits->begin (); isim!= allTrackerHits->end ();isim++) {
66
68
SimHitMap[(*isim).detUnitId ()].push_back ((*isim));
69
+ if (useCFpos_) {
70
+ DetId theDet ((*isim).detUnitId ());
71
+ SimHitSubdetMap[theDet.subdetId ()].push_back ((*isim));
72
+ }
67
73
}
68
74
69
75
if (doStrip_) e.getByLabel (" simSiStripDigis" , stripdigisimlink);
@@ -78,7 +84,8 @@ TrackerHitAssociator::TrackerHitAssociator(const edm::Event& e, const edm::Param
78
84
myEvent_(e),
79
85
doPixel_( conf.getParameter<bool >(" associatePixel" ) ),
80
86
doStrip_( conf.getParameter<bool >(" associateStrip" ) ),
81
- doTrackAssoc_( conf.getParameter<bool >(" associateRecoTracks" ) ){
87
+ doTrackAssoc_( conf.getParameter<bool >(" associateRecoTracks" ) ),
88
+ useCFpos_( false ) {
82
89
83
90
// if track association there is no need to acces the CrossingFrame
84
91
if (!doTrackAssoc_) {
@@ -94,20 +101,25 @@ TrackerHitAssociator::TrackerHitAssociator(const edm::Event& e, const edm::Param
94
101
cf_simhitvec.push_back (cf_simhit.product ());
95
102
}
96
103
97
- // std::cout << "SIMHITVEC SIZE = " << cf_simhitvec.size() << std::endl;
104
+ // std::cout << "SIMHITVEC SIZE = " << cf_simhitvec.size() << std::endl;
98
105
99
106
// TrackerHits = new MixCollection<PSimHit>(cf_simhitvec);
100
107
// std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(TrackerHits);
101
108
// std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
102
109
std::auto_ptr<MixCollection<PSimHit> > allTrackerHits (new MixCollection<PSimHit>(cf_simhitvec));
103
- TrackerHits = (*allTrackerHits);
110
+ // TrackerHits = (*allTrackerHits);
104
111
105
112
// Loop on PSimHit
106
113
SimHitMap.clear ();
114
+ SimHitSubdetMap.clear ();
107
115
108
116
MixCollection<PSimHit>::iterator isim;
109
117
for (isim=allTrackerHits->begin (); isim!= allTrackerHits->end ();isim++) {
110
118
SimHitMap[(*isim).detUnitId ()].push_back ((*isim));
119
+ if (useCFpos_) {
120
+ DetId theDet ((*isim).detUnitId ());
121
+ SimHitSubdetMap[theDet.subdetId ()].push_back ((*isim));
122
+ }
111
123
}
112
124
113
125
}
@@ -184,7 +196,7 @@ std::vector<PSimHit> TrackerHitAssociator::associateHit(const TrackingRecHit & t
184
196
{
185
197
if (const SiPixelRecHit * rechit = dynamic_cast <const SiPixelRecHit *>(&thit))
186
198
{
187
- // std::cout << "associate to pixelHit" << std::endl;
199
+ // std::cout << "associate to pixelHit" << std::endl;
188
200
associatePixelRecHit (rechit,simtrackid );
189
201
}
190
202
}
@@ -208,14 +220,29 @@ std::vector<PSimHit> TrackerHitAssociator::associateHit(const TrackingRecHit & t
208
220
// Save the SimHits in a vector. for the macthed hits both the rphi and stereo simhits are saved.
209
221
//
210
222
211
- if (StripHits){
223
+ // From CMSSW_6_2_0_pre8 simhitCFPos is ill-defined.
224
+ // It points relative to the PSimHit collection, but we don't know whether High- or LowTof.
225
+ // Before CMSSW_6_2_0_pre8 it pointed relative to base of the combined TrackerHits.
226
+ if (useCFpos_ && StripHits){
212
227
// USE THIS FOR STRIPS
213
- // std::cout << "NEW SIZE = " << simhitCFPos.size() << std::endl;
228
+ // std::cout << "NEW SIZE = " << simhitCFPos.size() << std::endl;
214
229
215
- for (size_t i=0 ; i<simhitCFPos.size (); i++){
216
- // std::cout << "NEW CFPOS " << simhitCFPos[i] << endl;
217
- // std::cout << "NEW LOCALPOS " << TrackerHits.getObject(simhitCFPos[i]).localPosition() << endl;
218
- result.push_back ( TrackerHits.getObject (simhitCFPos[i]));
230
+ // for(size_t i=0; i<simhitCFPos.size(); i++){
231
+ // //std::cout << "NEW CFPOS " << simhitCFPos[i] << endl;
232
+ // //std::cout << "NEW LOCALPOS " << TrackerHits.getObject(simhitCFPos[i]).localPosition() << endl;
233
+ // result.push_back( TrackerHits.getObject(simhitCFPos[i]));
234
+ // }
235
+ std::vector<PSimHit> simHit;
236
+ std::map<unsigned int , std::vector<PSimHit> >::const_iterator it = SimHitSubdetMap.find (detid.subdetId ());
237
+ simHit.clear ();
238
+ if (it!= SimHitSubdetMap.end ()){
239
+ simHit = it->second ;
240
+
241
+ // std::cout << "NEW SIZE = " << simhitCFPos.size() << std::endl;
242
+ for (size_t i=0 ; i<simhitCFPos.size (); i++){
243
+ // std::cout << "NEW CFPOS " << simhitCFPos[i] << endl;
244
+ result.push_back (simHit[simhitCFPos[i]]);
245
+ }
219
246
}
220
247
}else {
221
248
@@ -234,9 +261,10 @@ std::vector<PSimHit> TrackerHitAssociator::associateHit(const TrackingRecHit & t
234
261
235
262
for (size_t i=0 ; i<simtrackid.size ();i++){
236
263
if (simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second ){
237
- // cout << "Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
238
- // << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
264
+ // cout << "Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
265
+ // << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
239
266
result.push_back (ihit);
267
+ continue ;
240
268
}
241
269
}
242
270
}
@@ -265,6 +293,7 @@ std::vector<PSimHit> TrackerHitAssociator::associateHit(const TrackingRecHit & t
265
293
// cout << "GluedDet Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
266
294
// << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
267
295
result.push_back (ihit);
296
+ continue ;
268
297
}
269
298
}
270
299
}
@@ -395,11 +424,12 @@ void TrackerHitAssociator::associateSiStripRecHit1D(const SiStripRecHit1D * simp
395
424
associateSimpleRecHitCluster (clust,simplerechit->geographicalId (),simtrackid);
396
425
}
397
426
427
+ /*
398
428
void TrackerHitAssociator::associateSimpleRecHitCluster(const SiStripCluster* clust,
399
429
const uint32_t& detID,
400
- std::vector<SimHitIdpr>& theSimtrackid, std::vector<PSimHit>& simhit )
430
+ std::vector<SimHitIdpr>& theSimtrackid, std::vector<PSimHit>& clusterSimHits )
401
431
{
402
- // Caller needs to clear simhit before calling this function
432
+ // Caller needs to clear clusterSimHits before calling this function
403
433
404
434
//initialize vector
405
435
theSimtrackid.clear();
@@ -408,27 +438,45 @@ void TrackerHitAssociator::associateSimpleRecHitCluster(const SiStripCluster* cl
408
438
409
439
associateSimpleRecHitCluster(clust, detID, theSimtrackid);
410
440
411
- for (size_t i=0 ; i<simhitCFPos.size (); i++){
412
- simhit.push_back (TrackerHits.getObject (simhitCFPos[i]));
441
+ DetId theDet(detID);
442
+ std::vector<PSimHit> subDetSimHits;
443
+ std::map<unsigned int, std::vector<PSimHit> >::const_iterator it = SimHitSubdetMap.find(theDet.subdetId());
444
+ subDetSimHits.clear();
445
+ if (it!= SimHitSubdetMap.end()){
446
+ subDetSimHits = it->second;
447
+ for(size_t i=0; i<simhitCFPos.size(); i++){
448
+ // clusterSimHits.push_back(TrackerHits.getObject(simhitCFPos[i]));
449
+ clusterSimHits.push_back(subDetSimHits[simhitCFPos[i]]);
450
+ }
413
451
}
414
452
}
415
453
416
454
void TrackerHitAssociator::associateSimpleRecHitCluster(const SiStripCluster* clust,
417
455
const uint32_t& detID,
418
- std::vector<PSimHit>& simhit )
456
+ std::vector<PSimHit>& clusterSimHits )
419
457
{
420
- // Caller needs to clear simhit before calling this function
458
+ // Caller needs to clear clusterSimHits before calling this function
421
459
422
460
//initialize class vectors
423
461
simtrackid.clear();
424
462
simhitCFPos.clear();
425
463
426
464
associateSimpleRecHitCluster(clust, detID, simtrackid);
427
465
428
- for (size_t i=0 ; i<simhitCFPos.size (); i++){
429
- simhit.push_back (TrackerHits.getObject (simhitCFPos[i]));
466
+
467
+ DetId theDet(detID);
468
+ std::vector<PSimHit> subDetSimHits;
469
+ std::map<unsigned int, std::vector<PSimHit> >::const_iterator it = SimHitSubdetMap.find(theDet.subdetId());
470
+ subDetSimHits.clear();
471
+ if (it!= SimHitSubdetMap.end()){
472
+ subDetSimHits = it->second;
473
+ for(size_t i=0; i<simhitCFPos.size(); i++){
474
+ // clusterSimHits.push_back(TrackerHits.getObject(simhitCFPos[i]));
475
+ clusterSimHits.push_back(subDetSimHits[simhitCFPos[i]]);
476
+ }
430
477
}
431
478
}
479
+ */
432
480
433
481
void TrackerHitAssociator::associateSimpleRecHitCluster (const SiStripCluster* clust,
434
482
const uint32_t & detID,
@@ -498,17 +546,16 @@ void TrackerHitAssociator::associateSimpleRecHitCluster(const SiStripCluster* cl
498
546
idcachev.push_back (currentId);
499
547
simtrackid.push_back (currentId);
500
548
}
501
-
549
+
550
+
502
551
// create a vector that contains all the position (in the MixCollection) of the SimHits that contributed to the RecHit
503
552
// write position only once
504
553
int currentCFPos = linkiter->CFposition ()-1 ;
505
- if (find (CFposcachev.begin (),CFposcachev.end (),currentCFPos ) == CFposcachev.end ()){
506
- /*
507
- std::cout << "CHECKING CHANNEL = " << linkiter->channel() << std::endl;
508
- std::cout << "\tTrackID = " << linkiter->SimTrackId() << "\tCFPos = " << currentCFPos << std::endl;
509
- std::cout << "\tLocal Pos = " << TrackerHits.getObject(currentCFPos).localPosition()
510
- << "\tProcess = " << TrackerHits.getObject(currentCFPos).processType() << std::endl;
511
- */
554
+ if (useCFpos_ && find (CFposcachev.begin (),CFposcachev.end (),currentCFPos ) == CFposcachev.end ()){
555
+ // std::cout << "CHECKING CHANNEL = " << linkiter->channel() << std::endl;
556
+ // std::cout << "\tTrackID = " << linkiter->SimTrackId() << "\tCFPos = " << currentCFPos << std::endl;
557
+ // std::cout << "\tLocal Pos = " << TrackerHits.getObject(currentCFPos).localPosition()
558
+ // << "\tProcess = " << TrackerHits.getObject(currentCFPos).processType() << std::endl;
512
559
CFposcachev.push_back (currentCFPos);
513
560
simhitCFPos.push_back (currentCFPos);
514
561
// simhitassoc.push_back( TrackerHits.getObject(currentCFPos));
0 commit comments