CMS 3D CMS Logo

TrackAssociator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HTrackAssociator
4 // Class: HTrackAssociator
5 //
6 /*
7 
8  Description: <one line class summary>
9 
10  Implementation:
11  <Notes on implementation>
12 */
13 //
14 // Original Author: Dmytro Kovalskyi
15 // Modified for ECAL+HCAL by: Michal Szleper
16 // Created: Fri Apr 21 10:59:41 PDT 2006
17 //
18 //
19 
21 
22 // user include files
23 
28 
29 // calorimeter info
31 
33 
35 #include <stack>
36 #include <set>
37 
38 //
39 // class declaration
40 //
41 
42 using namespace reco;
43 
45  ivProp_ = nullptr;
46  defProp_ = nullptr;
47  debug_ = 0;
48  caloTowerMap_ = nullptr;
49  useDefaultPropagator_ = false;
50 }
51 
53  if (defProp_)
54  delete defProp_;
55 }
56 
57 //-----------------------------------------------------------------------------
60  const std::string productInstanceLabel) {
61  if (className == "EBRecHitCollection") {
62  EBRecHitCollectionLabels.clear();
63  EBRecHitCollectionLabels.push_back(moduleLabel);
64  EBRecHitCollectionLabels.push_back(productInstanceLabel);
65  }
66  if (className == "EERecHitCollection") {
67  EERecHitCollectionLabels.clear();
68  EERecHitCollectionLabels.push_back(moduleLabel);
69  EERecHitCollectionLabels.push_back(productInstanceLabel);
70  }
71  if (className == "HBHERecHitCollection") {
72  HBHERecHitCollectionLabels.clear();
73  HBHERecHitCollectionLabels.push_back(moduleLabel);
74  HBHERecHitCollectionLabels.push_back(productInstanceLabel);
75  }
76  if (className == "CaloTowerCollection") {
77  CaloTowerCollectionLabels.clear();
78  CaloTowerCollectionLabels.push_back(moduleLabel);
79  CaloTowerCollectionLabels.push_back(productInstanceLabel);
80  }
81 }
82 
83 //-----------------------------------------------------------------------------
85  ivProp_ = ptr;
86  caloDetIdAssociator_.setPropagator(ivProp_);
87  ecalDetIdAssociator_.setPropagator(ivProp_);
88  hcalDetIdAssociator_.setPropagator(ivProp_);
89 }
90 
91 //-----------------------------------------------------------------------------
92 void HTrackAssociator::useDefaultPropagator() { useDefaultPropagator_ = true; }
93 
94 //-----------------------------------------------------------------------------
96  // access the calorimeter geometry
97  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry_);
98  if (!theCaloGeometry_.isValid())
99  throw cms::Exception("FatalError") << "Unable to find IdealGeometryRecord in event!\n";
100 
101  if (useDefaultPropagator_ && !defProp_) {
102  // setup propagator
105 
107  prop->setMaterialMode(false);
108  prop->applyRadX0Correction(true);
109  // prop->setDebug(true); // tmp
110  defProp_ = prop;
111  setPropagator(defProp_);
112  }
113 }
114 
115 //-----------------------------------------------------------------------------
117  const edm::EventSetup& iSetup,
118  const FreeTrajectoryState& trackOrigin,
121  using namespace edm;
122 
123  init(iSetup);
124 
125  const FreeTrajectoryState& currentPosition(trackOrigin);
126 
127  if (parameters.useEcal)
128  fillEcal(iEvent, iSetup, info, currentPosition, parameters.idREcal, parameters.dREcal);
129  if (parameters.useHcal)
130  fillHcal(iEvent, iSetup, info, currentPosition, parameters.idRHcal, parameters.dRHcal);
131  if (parameters.useCalo)
132  fillCaloTowers(iEvent, iSetup, info, currentPosition, parameters.idRCalo, parameters.dRCalo);
133 
134  return info;
135 }
136 
137 //-----------------------------------------------------------------------------
138 std::vector<EcalRecHit> HTrackAssociator::associateEcal(const edm::Event& iEvent,
139  const edm::EventSetup& iSetup,
140  const FreeTrajectoryState& trackOrigin,
141  const double dR) {
143  parameters.useHcal = false;
144  parameters.dREcal = dR;
145  HTrackDetMatchInfo info(associate(iEvent, iSetup, trackOrigin, parameters));
146  if (dR > 0)
147  return info.coneEcalRecHits;
148  else
149  return info.crossedEcalRecHits;
150 }
151 
152 //-----------------------------------------------------------------------------
154  const edm::EventSetup& iSetup,
155  const FreeTrajectoryState& trackOrigin,
156  const double dR) {
158  parameters.useHcal = false;
159  parameters.dREcal = dR;
160  HTrackDetMatchInfo info = associate(iEvent, iSetup, trackOrigin, parameters);
161  if (dR > 0)
162  return info.ecalConeEnergyFromRecHits();
163  else
164  return info.ecalEnergyFromRecHits();
165 }
166 
167 //-----------------------------------------------------------------------------
168 std::vector<CaloTower> HTrackAssociator::associateHcal(const edm::Event& iEvent,
169  const edm::EventSetup& iSetup,
170  const FreeTrajectoryState& trackOrigin,
171  const double dR) {
173  parameters.useEcal = false;
174  parameters.dRHcal = dR;
175  HTrackDetMatchInfo info(associate(iEvent, iSetup, trackOrigin, parameters));
176  if (dR > 0)
177  return info.coneTowers;
178  else
179  return info.crossedTowers;
180 }
181 
182 //-----------------------------------------------------------------------------
184  const edm::EventSetup& iSetup,
185  const FreeTrajectoryState& trackOrigin,
186  const double dR) {
188  parameters.useEcal = false;
189  parameters.dRHcal = dR;
190  HTrackDetMatchInfo info(associate(iEvent, iSetup, trackOrigin, parameters));
191  if (dR > 0)
192  return info.hcalConeEnergyFromRecHits();
193  else
194  return info.hcalEnergyFromRecHits();
195 }
196 
197 //-----------------------------------------------------------------------------
199  const edm::EventSetup& iSetup,
201  const FreeTrajectoryState& trajectoryPoint,
202  const int idR,
203  const double dR) {
204  ecalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
205 
206  // ECAL points (EB+EE)
207  std::vector<GlobalPoint> ecalPoints;
208  ecalPoints.push_back(GlobalPoint(135., 0, 310.));
209  ecalPoints.push_back(GlobalPoint(150., 0, 340.));
210  ecalPoints.push_back(GlobalPoint(170., 0, 370.));
211 
212  std::vector<GlobalPoint> ecalTrajectory = ecalDetIdAssociator_.getTrajectory(trajectoryPoint, ecalPoints);
213  // if(ecalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate a track to ECAL\n";
214 
215  if (ecalTrajectory.empty()) {
216  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to ECAL; moving on\n";
217  info.isGoodEcal = false;
218  return;
219  }
220 
221  info.isGoodEcal = true;
222 
223  info.trkGlobPosAtEcal = getPoint(ecalTrajectory[0]);
224 
225  // Find ECAL crystals
228  // if (EBRecHitCollectionLabels.empty())
229  // throw cms::Exception("FatalError") << "Module lable is not set for EBRecHitCollection.\n";
230  // else
231  iEvent.getByLabel(EBRecHitCollectionLabels[0], EBRecHitCollectionLabels[1], EBRecHits);
232  // if (!EBRecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in event!\n";
233  if (EERecHitCollectionLabels[1] != EBRecHitCollectionLabels[1])
234  iEvent.getByLabel(EERecHitCollectionLabels[0], EERecHitCollectionLabels[1], EERecHits);
235  // if (!EERecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EERecHitCollection in event!\n";
236 
237  std::set<DetId> ecalIdsInRegion = ecalDetIdAssociator_.getDetIdsCloseToAPoint(ecalTrajectory[0], idR);
238  std::set<DetId> ecalIdsInACone = ecalDetIdAssociator_.getDetIdsInACone(ecalIdsInRegion, ecalTrajectory, dR);
239  std::set<DetId> crossedEcalIds = ecalDetIdAssociator_.getCrossedDetIds(ecalIdsInRegion, ecalTrajectory);
240 
241  // add EcalRecHits
242  for (std::set<DetId>::const_iterator itr = crossedEcalIds.begin(); itr != crossedEcalIds.end(); itr++) {
243  std::vector<EcalRecHit>::const_iterator hit = (*EBRecHits).find(*itr);
244  if (hit != (*EBRecHits).end())
245  info.crossedEcalRecHits.push_back(*hit);
246  else
247  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() << "\n";
248  }
249  for (std::set<DetId>::const_iterator itr = ecalIdsInACone.begin(); itr != ecalIdsInACone.end(); itr++) {
250  std::vector<EcalRecHit>::const_iterator hit = (*EBRecHits).find(*itr);
251  if (hit != (*EBRecHits).end()) {
252  info.coneEcalRecHits.push_back(*hit);
253  } else
254  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() << "\n";
255  }
256  if (EERecHitCollectionLabels[1] == EBRecHitCollectionLabels[1])
257  return;
258  for (std::set<DetId>::const_iterator itr = crossedEcalIds.begin(); itr != crossedEcalIds.end(); itr++) {
259  std::vector<EcalRecHit>::const_iterator hit = (*EERecHits).find(*itr);
260  if (hit != (*EERecHits).end())
261  info.crossedEcalRecHits.push_back(*hit);
262  else
263  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() << "\n";
264  }
265  for (std::set<DetId>::const_iterator itr = ecalIdsInACone.begin(); itr != ecalIdsInACone.end(); itr++) {
266  std::vector<EcalRecHit>::const_iterator hit = (*EERecHits).find(*itr);
267  if (hit != (*EERecHits).end()) {
268  info.coneEcalRecHits.push_back(*hit);
269  } else
270  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() << "\n";
271  }
272 }
273 
274 //-----------------------------------------------------------------------------
276  const edm::EventSetup& iSetup,
278  const FreeTrajectoryState& trajectoryPoint,
279  const int idR,
280  const double dR) {
281  // ECAL hits are not used for the CaloTower identification
282  caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
283 
284  // HCAL points (HB+HE)
285  std::vector<GlobalPoint> hcalPoints;
286  hcalPoints.push_back(GlobalPoint(135., 0, 310.));
287  hcalPoints.push_back(GlobalPoint(150., 0, 340.));
288  hcalPoints.push_back(GlobalPoint(170., 0, 370.));
289  hcalPoints.push_back(GlobalPoint(190., 0, 400.));
290  hcalPoints.push_back(GlobalPoint(240., 0, 500.));
291  hcalPoints.push_back(GlobalPoint(280., 0, 550.));
292 
293  std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
294  // if(hcalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate the track to HCAL\n";
295 
296  if (hcalTrajectory.empty()) {
297  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to ECAL; moving on\n";
298  info.isGoodCalo = false;
299  info.isGoodEcal = false;
300  std::cout << " HTrackAssociator::fillCaloTowers::Failed to propagate a track to ECAL " << std::endl;
301  return;
302  }
303 
304  info.isGoodCalo = true;
305  info.isGoodEcal = true;
306  info.trkGlobPosAtEcal = getPoint(hcalTrajectory[0]);
307 
308  if (hcalTrajectory.size() < 4) {
309  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to HCAL; moving on\n";
310  info.isGoodHcal = false;
311  }
312 
313  info.isGoodHcal = true;
314 
315  info.trkGlobPosAtHcal = getPoint(hcalTrajectory[4]);
316 
317  // find crossed CaloTowers
319 
320  if (CaloTowerCollectionLabels.empty())
321  throw cms::Exception("FatalError") << "Module lable is not set for CaloTowers.\n";
322  else
323  iEvent.getByLabel(CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
324  if (!caloTowers.isValid())
325  throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
326 
327  // first get DetIds in a predefined NxN region
328  // std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
329  std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0], idR);
330 
331  std::set<DetId> caloTowerIdsInACone;
332  std::set<DetId> crossedCaloTowerIds;
333  std::set<DetId> caloTowerIdsInBox;
334  caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInRegion, hcalTrajectory, dR);
335  // get DetId of the most energetic tower in that region
336  crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
337  // get DetIds of the towers surrounding the most energetic one
338  caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
339 
340  //
341  // Debug prints
342  //
343  // std::cout <<" Debug printout in CaloTowers "<<std::endl;
344  // std::cout <<" with position at outer layer:r,z,phi "<<trajectoryPoint.position().eta()<<
345  // " "<<trajectoryPoint.position().phi()<<
346  // " "<<trajectoryPoint.position().perp()<<
347  // " "<<trajectoryPoint.position().z()<<
348  // " "<<trajectoryPoint.charge()<<std::endl;
349  // std::cout <<" Trajectory point at ECAL surface:eta:phi:radius:z "<<(hcalTrajectory[0]).eta()<<
350  // " "<<(hcalTrajectory[0]).phi()<<
351  // " "<<(hcalTrajectory[0]).perp()<<
352  // " "<<(hcalTrajectory[0]).z()<<
353  // " momentum "<<trajectoryPoint.momentum().perp()<<std::endl;
354  //
355  // std::cout<<" Number of towers in the region "<<caloTowerIdsInRegion.size()<<" idR= "<<idR<<std::endl;
356 
357  // add CaloTowers
358  for (std::set<DetId>::const_iterator itr = crossedCaloTowerIds.begin(); itr != crossedCaloTowerIds.end(); itr++) {
359  DetId id(*itr);
360  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
361  if (tower != (*caloTowers).end())
362  info.crossedTowers.push_back(*tower);
363  else
364  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
365  }
366 
367  for (std::set<DetId>::const_iterator itr = caloTowerIdsInACone.begin(); itr != caloTowerIdsInACone.end(); itr++) {
368  DetId id(*itr);
369  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
370  if (tower != (*caloTowers).end()) {
371  info.coneTowers.push_back(*tower);
372  } else
373  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
374  }
375 
376  for (std::set<DetId>::const_iterator itr = caloTowerIdsInBox.begin(); itr != caloTowerIdsInBox.end(); itr++) {
377  DetId id(*itr);
378  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
379  if (tower != (*caloTowers).end()) {
380  info.boxTowers.push_back(*tower);
381  } else
382  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
383  }
384 
385  for (std::set<DetId>::const_iterator itr = caloTowerIdsInRegion.begin(); itr != caloTowerIdsInRegion.end(); itr++) {
386  DetId id(*itr);
387  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
388  if (tower != (*caloTowers).end()) {
389  info.regionTowers.push_back(*tower);
390  } else
391  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
392  }
393 }
394 
395 //-----------------------------------------------------------------------------
397  const edm::EventSetup& iSetup,
399  const FreeTrajectoryState& trajectoryPoint,
400  const int idR,
401  const double dR) {
402  hcalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
403 
404  // HCAL points (HB+HE)
405  std::vector<GlobalPoint> hcalPoints;
406  hcalPoints.push_back(GlobalPoint(190., 0, 400.));
407  hcalPoints.push_back(GlobalPoint(240., 0, 500.));
408  hcalPoints.push_back(GlobalPoint(280., 0, 550.));
409 
410  std::vector<GlobalPoint> hcalTrajectory = hcalDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
411  // if(hcalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate the track to HCAL\n";
412 
413  if (hcalTrajectory.empty()) {
414  LogTrace("HTrackAssociator::fillHcal") << "Failed to propagate a track to HCAL; moving on\n";
415  info.isGoodHcal = false;
416  // std::cout<<" HTrackAssociator::fillHcal::Failed to propagate a track to HCAL "<<std::endl;
417  return;
418  }
419 
420  info.isGoodHcal = true;
421 
422  info.trkGlobPosAtHcal = getPoint(hcalTrajectory[0]);
423 
425  // if (HBHERecHitCollectionLabels.empty())
426  // throw cms::Exception("FatalError") << "Module label is not set for HBHERecHitCollection.\n";
427  // else
428  iEvent.getByLabel(HBHERecHitCollectionLabels[0], HBHERecHitCollectionLabels[1], HBHERecHits);
429  if (!HBHERecHits.isValid())
430  throw cms::Exception("FatalError") << "Unable to find HBHERecHitCollection in event!\n";
431 
432  // first get DetIds in a predefined NxN region
433  // std::set<DetId> hcalIdsInBigRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
434  std::set<DetId> hcalIdsInRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0], idR);
435 
436  std::set<DetId> hcalIdsInACone;
437  std::set<DetId> crossedHcalIds;
438  std::set<DetId> hcalIdsInBox;
439  hcalIdsInACone = hcalDetIdAssociator_.getDetIdsInACone(hcalIdsInRegion, hcalTrajectory, dR);
440  // get DetId of the most energetic tower in that region
441  crossedHcalIds = hcalDetIdAssociator_.getMaxEDetId(hcalIdsInRegion, HBHERecHits);
442  // get DetIds of the towers surrounding the most energetic one
443  hcalIdsInBox = hcalDetIdAssociator_.getDetIdsInACone(crossedHcalIds, hcalTrajectory, -1.);
444 
445  // add HcalRecHits
446  for (std::set<DetId>::const_iterator itr = crossedHcalIds.begin(); itr != crossedHcalIds.end(); itr++) {
447  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
448  if (hit != (*HBHERecHits).end())
449  info.crossedHcalRecHits.push_back(*hit);
450  else
451  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() << "\n";
452  }
453  for (std::set<DetId>::const_iterator itr = hcalIdsInACone.begin(); itr != hcalIdsInACone.end(); itr++) {
454  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
455  if (hit != (*HBHERecHits).end())
456  info.coneHcalRecHits.push_back(*hit);
457  else
458  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() << "\n";
459  }
460  for (std::set<DetId>::const_iterator itr = hcalIdsInBox.begin(); itr != hcalIdsInBox.end(); itr++) {
461  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
462  if (hit != (*HBHERecHits).end())
463  info.boxHcalRecHits.push_back(*hit);
464  else
465  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() << "\n";
466  }
467  for (std::set<DetId>::const_iterator itr = hcalIdsInRegion.begin(); itr != hcalIdsInRegion.end(); itr++) {
468  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
469  if (hit != (*HBHERecHits).end())
470  info.regionHcalRecHits.push_back(*hit);
471  else
472  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() << "\n";
473  }
474 }
475 
476 //-----------------------------------------------------------------------------
478  const edm::EventSetup& iSetup,
480  const FreeTrajectoryState& trajectoryPoint,
481  const int idR,
482  const double dR) {
483  // ECAL hits are not used for the CaloTower identification
484  caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
485 
486  // HCAL points (HB+HE)
487  std::vector<GlobalPoint> hcalPoints;
488  hcalPoints.push_back(GlobalPoint(190., 0, 400.));
489  hcalPoints.push_back(GlobalPoint(240., 0, 500.));
490  hcalPoints.push_back(GlobalPoint(280., 0, 550.));
491 
492  std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
493  // if(hcalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate the track to HCAL\n";
494 
495  if (hcalTrajectory.empty()) {
496  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to HCAL; moving on\n";
497  info.isGoodCalo = false;
498  std::cout << " HTrackAssociator::fillCaloTowers::Failed to propagate a track to HCAL " << std::endl;
499  return;
500  }
501 
502  info.isGoodCalo = true;
503 
504  info.trkGlobPosAtHcal = getPoint(hcalTrajectory[0]);
505 
506  // find crossed CaloTowers
508 
509  if (CaloTowerCollectionLabels.empty())
510  throw cms::Exception("FatalError") << "Module lable is not set for CaloTowers.\n";
511  else
512  iEvent.getByLabel(CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
513  if (!caloTowers.isValid())
514  throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
515 
516  // first get DetIds in a predefined NxN region
517  std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0], idR + 1);
518  std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0], idR);
519 
520  std::set<DetId> caloTowerIdsInACone;
521  std::set<DetId> crossedCaloTowerIds;
522  std::set<DetId> caloTowerIdsInBox;
523  caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInBigRegion, hcalTrajectory, dR);
524  // get DetId of the most energetic tower in that region
525  crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
526  // get DetIds of the towers surrounding the most energetic one
527  caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
528 
529  // add CaloTowers
530  for (std::set<DetId>::const_iterator itr = crossedCaloTowerIds.begin(); itr != crossedCaloTowerIds.end(); itr++) {
531  DetId id(*itr);
532  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
533  if (tower != (*caloTowers).end())
534  info.crossedTowers.push_back(*tower);
535  else
536  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
537  }
538 
539  for (std::set<DetId>::const_iterator itr = caloTowerIdsInACone.begin(); itr != caloTowerIdsInACone.end(); itr++) {
540  DetId id(*itr);
541  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
542  if (tower != (*caloTowers).end())
543  info.coneTowers.push_back(*tower);
544  else
545  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
546  }
547 }
548 
549 //-----------------------------------------------------------------------------
551  const SimTrack& track,
552  const SimVertex& vertex) {
555 
556  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
557  // convert mm to cm
558  GlobalPoint point(vertex.position().x() * .1, vertex.position().y() * .1, vertex.position().z() * .1);
559  int charge = track.type() > 0 ? -1 : 1;
560  GlobalTrajectoryParameters tPars(point, vector, charge, &*bField);
561 
563  covT *= 1e-6; // initialize to sigma=1e-3
564  CartesianTrajectoryError tCov(covT);
565 
566  return FreeTrajectoryState(tPars, tCov);
567 }
568 
569 //-----------------------------------------------------------------------------
573 
574  GlobalVector vector(track.momentum().x(), track.momentum().y(), track.momentum().z());
575 
576  GlobalPoint point(track.vertex().x(), track.vertex().y(), track.vertex().z());
577 
578  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
579 
580  // FIX THIS !!!
581  // need to convert from perigee to global or helix (curvilinear) frame
582  // for now just an arbitrary matrix.
584  covT *= 1e-6; // initialize to sigma=1e-3
585  CartesianTrajectoryError tCov(covT);
586 
587  return FreeTrajectoryState(tPars, tCov);
588 }
Vector3DBase
Definition: Vector3DBase.h:8
init
int init
Definition: HydjetWrapper.h:64
anyDirection
Definition: PropagationDirection.h:4
edm::SortedCollection< CaloTower >::const_iterator
std::vector< CaloTower >::const_iterator const_iterator
Definition: SortedCollection.h:80
SimVertex
Definition: SimVertex.h:5
SteppingHelixPropagator.h
HTrackAssociator::fillEcal
void fillEcal(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
Definition: TrackAssociator.cc:198
HTrackAssociator::associate
HTrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
Definition: TrackAssociator.cc:116
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
HTrackAssociator::fillHcal
void fillHcal(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
Definition: TrackAssociator.cc:396
egHLT::errCodes::HBHERecHits
Definition: EgHLTErrCodes.h:20
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:3
HTrackAssociator::fillCaloTowers
void fillCaloTowers(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
Definition: TrackAssociator.cc:275
HTrackAssociator::init
void init(const edm::EventSetup &)
Definition: TrackAssociator.cc:95
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
SteppingHelixPropagator_cfi.SteppingHelixPropagator
SteppingHelixPropagator
Definition: SteppingHelixPropagator_cfi.py:3
HTrackAssociator::fillHcalTowers
void fillHcalTowers(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
Definition: TrackAssociator.cc:477
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HTrackAssociator::useDefaultPropagator
void useDefaultPropagator()
use the default propagator
Definition: TrackAssociator.cc:92
edm::Handle
Definition: AssociativeIterator.h:50
filterRecHits_cfi.EERecHits
EERecHits
Definition: filterRecHits_cfi.py:9
EcalRecHitCollections.h
HTrackAssociator::HTrackAssociator
HTrackAssociator()
Definition: TrackAssociator.cc:44
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
AlgebraicMatrixID
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Definition: AlgebraicROOTObjects.h:72
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
SteppingHelixPropagator
Definition: SteppingHelixPropagator.h:36
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
HTrackAssociator::associateEcal
std::vector< EcalRecHit > associateEcal(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
Definition: TrackAssociator.cc:138
AlgebraicSymMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Definition: AlgebraicROOTObjects.h:24
reco::Track
Definition: Track.h:27
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
HTrackAssociator::associateHcal
std::vector< CaloTower > associateHcal(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
Definition: TrackAssociator.cc:168
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HTrackAssociator::HAssociatorParameters
Definition: TrackAssociator.h:51
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
HTrackAssociator::~HTrackAssociator
~HTrackAssociator()
Definition: TrackAssociator.cc:52
eleHcalExtractorBlocks_cff.caloTowers
caloTowers
Definition: eleHcalExtractorBlocks_cff.py:15
TrackAssociator.h
SteppingHelixPropagator::applyRadX0Correction
void applyRadX0Correction(bool applyRadX0Correction)
Definition: SteppingHelixPropagator.h:133
iEvent
int iEvent
Definition: GenABIO.cc:224
HLT_2018_cff.fillCaloTowers
fillCaloTowers
Definition: HLT_2018_cff.py:48595
HTrackAssociator::getFreeTrajectoryState
FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
Definition: TrackAssociator.cc:570
edm::EventSetup
Definition: EventSetup.h:57
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
SteppingHelixPropagator::setMaterialMode
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
Definition: SteppingHelixPropagator.h:124
reco::get
T get(const Candidate &c)
Definition: component.h:60
CaloTowerCollection.h
HTrackDetMatchInfo
Definition: TrackDetMatchInfo.h:10
CartesianTrajectoryError
Definition: CartesianTrajectoryError.h:15
HTrackAssociator::getHcalEnergy
double getHcalEnergy(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
Definition: TrackAssociator.cc:183
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
Calorimetry_cff.bField
bField
Definition: Calorimetry_cff.py:292
DetId.h
SimTrack
Definition: SimTrack.h:6
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
SuperCluster.h
HTrackAssociator::getEcalEnergy
double getEcalEnergy(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
Definition: TrackAssociator.cc:153
className
std::string className(const T &t)
Definition: ClassName.h:31
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
HTrackAssociator::setPropagator
void setPropagator(Propagator *)
use a user configured propagator
Definition: TrackAssociator.cc:84
cms::Exception
Definition: Exception.h:70
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
edm::Event
Definition: Event.h:73
HTrackAssociator::addDataLabels
void addDataLabels(const std::string className, const std::string moduleLabel, const std::string productInstanceLabel="")
specify names of EDProducts to use for different input data types
Definition: TrackAssociator.cc:58
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
filterRecHits_cfi.EBRecHits
EBRecHits
Definition: filterRecHits_cfi.py:8