CMS 3D CMS Logo

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

#include <TrackAssociator.h>

Classes

class  HAssociatorParameters
 

Public Member Functions

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 More...
 
HTrackDetMatchInfo associate (const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
 
std::vector< EcalRecHitassociateEcal (const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
 
std::vector< CaloTowerassociateHcal (const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
 
double getEcalEnergy (const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
 
FreeTrajectoryState getFreeTrajectoryState (const edm::EventSetup &, const reco::Track &)
 get FreeTrajectoryState from different track representations More...
 
FreeTrajectoryState getFreeTrajectoryState (const edm::EventSetup &, const SimTrack &, const SimVertex &)
 
double getHcalEnergy (const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
 
 HTrackAssociator ()
 
void setPropagator (Propagator *)
 use a user configured propagator More...
 
void useDefaultPropagator ()
 use the default propagator More...
 
 ~HTrackAssociator ()
 

Private Member Functions

void fillCaloTowers (const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
 
void fillEcal (const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
 
void fillHcal (const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
 
void fillHcalTowers (const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
 
math::XYZPoint getPoint (const GlobalPoint &point)
 
math::XYZPoint getPoint (const LocalPoint &point)
 
math::XYZVector getVector (const GlobalVector &vec)
 
math::XYZVector getVector (const LocalVector &vec)
 
void init (const edm::EventSetup &)
 

Private Attributes

HCaloDetIdAssociator caloDetIdAssociator_
 
std::vector< std::string > CaloTowerCollectionLabels
 CaloTowers. More...
 
std::vector< std::vector< std::set< uint32_t > > > * caloTowerMap_
 
int debug_
 
PropagatordefProp_
 
std::vector< std::string > EBRecHitCollectionLabels
 
HEcalDetIdAssociator ecalDetIdAssociator_
 
std::vector< std::string > EERecHitCollectionLabels
 
std::vector< std::string > HBHERecHitCollectionLabels
 HCAL. More...
 
HHcalDetIdAssociator hcalDetIdAssociator_
 
PropagatorivProp_
 
edm::ESHandle< CaloGeometrytheCaloGeometry_
 
bool useDefaultPropagator_
 

Detailed Description

Definition at line 46 of file TrackAssociator.h.

Constructor & Destructor Documentation

◆ HTrackAssociator()

HTrackAssociator::HTrackAssociator ( )

Definition at line 44 of file TrackAssociator.cc.

44  {
45  ivProp_ = nullptr;
46  defProp_ = nullptr;
47  debug_ = 0;
48  caloTowerMap_ = nullptr;
49  useDefaultPropagator_ = false;
50 }

◆ ~HTrackAssociator()

HTrackAssociator::~HTrackAssociator ( )

Definition at line 52 of file TrackAssociator.cc.

52  {
53  if (defProp_)
54  delete defProp_;
55 }

Member Function Documentation

◆ addDataLabels()

void HTrackAssociator::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 at line 58 of file TrackAssociator.cc.

60  {
61  if (className == "EBRecHitCollection") {
64  EBRecHitCollectionLabels.push_back(productInstanceLabel);
65  }
66  if (className == "EERecHitCollection") {
69  EERecHitCollectionLabels.push_back(productInstanceLabel);
70  }
71  if (className == "HBHERecHitCollection") {
74  HBHERecHitCollectionLabels.push_back(productInstanceLabel);
75  }
76  if (className == "CaloTowerCollection") {
79  CaloTowerCollectionLabels.push_back(productInstanceLabel);
80  }
81 }

References className(), and HerwigMaxPtPartonFilter_cfi::moduleLabel.

◆ associate()

HTrackDetMatchInfo HTrackAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const FreeTrajectoryState trackOrigin,
const HAssociatorParameters parameters 
)

propagate a track across the whole detector and find associated objects. Association is done in two modes 1) an object is associated to a track only if crossed by track 2) an object is associated to a track if it is withing an eta-phi cone of some radius with respect to a track. (the cone origin is at (0,0,0))

Definition at line 116 of file TrackAssociator.cc.

119  {
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 }

References HLT_2018_cff::fillCaloTowers, iEvent, info(), and init.

Referenced by SequenceTypes._ModuleSequenceType::remove(), and SequenceTypes._ModuleSequenceType::replace().

◆ associateEcal()

std::vector< EcalRecHit > HTrackAssociator::associateEcal ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const FreeTrajectoryState trackOrigin,
const double  dR = -1 
)

associate ECAL only and return RecHits negative dR means only crossed elements

Definition at line 138 of file TrackAssociator.cc.

141  {
142  HAssociatorParameters parameters;
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 }

References HGC3DClusterGenMatchSelector_cfi::dR, iEvent, and info().

◆ associateHcal()

std::vector< CaloTower > HTrackAssociator::associateHcal ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const FreeTrajectoryState trackOrigin,
const double  dR = -1 
)

associate ECAL only and return RecHits negative dR means only crossed elements

Definition at line 168 of file TrackAssociator.cc.

171  {
172  HAssociatorParameters parameters;
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 }

References HGC3DClusterGenMatchSelector_cfi::dR, iEvent, and info().

◆ fillCaloTowers()

void HTrackAssociator::fillCaloTowers ( const edm::Event iEvent,
const edm::EventSetup iSetup,
HTrackDetMatchInfo info,
const FreeTrajectoryState trajectoryPoint,
const int  idR,
const double  dR 
)
private

Definition at line 275 of file TrackAssociator.cc.

280  {
281  // ECAL hits are not used for the CaloTower identification
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
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 }

References eleHcalExtractorBlocks_cff::caloTowers, gather_cfg::cout, HGC3DClusterGenMatchSelector_cfi::dR, triggerObjects_cff::id, iEvent, info(), LogTrace, and hgcalTowerProducer_cfi::tower.

◆ fillEcal()

void HTrackAssociator::fillEcal ( const edm::Event iEvent,
const edm::EventSetup iSetup,
HTrackDetMatchInfo info,
const FreeTrajectoryState trajectoryPoint,
const int  idR,
const double  dR 
)
private

Definition at line 198 of file TrackAssociator.cc.

203  {
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
232  // if (!EBRecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in event!\n";
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  }
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 }

References HGC3DClusterGenMatchSelector_cfi::dR, filterRecHits_cfi::EBRecHits, filterRecHits_cfi::EERecHits, iEvent, info(), and LogTrace.

◆ fillHcal()

void HTrackAssociator::fillHcal ( const edm::Event iEvent,
const edm::EventSetup iSetup,
HTrackDetMatchInfo info,
const FreeTrajectoryState trajectoryPoint,
const int  idR,
const double  dR 
)
private

Definition at line 396 of file TrackAssociator.cc.

401  {
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
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 }

References HGC3DClusterGenMatchSelector_cfi::dR, egHLT::errCodes::HBHERecHits, iEvent, info(), and LogTrace.

◆ fillHcalTowers()

void HTrackAssociator::fillHcalTowers ( const edm::Event iEvent,
const edm::EventSetup iSetup,
HTrackDetMatchInfo info,
const FreeTrajectoryState trajectoryPoint,
const int  idR,
const double  dR 
)
private

Definition at line 477 of file TrackAssociator.cc.

482  {
483  // ECAL hits are not used for the CaloTower identification
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
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 }

References eleHcalExtractorBlocks_cff::caloTowers, gather_cfg::cout, HGC3DClusterGenMatchSelector_cfi::dR, triggerObjects_cff::id, iEvent, info(), LogTrace, and hgcalTowerProducer_cfi::tower.

◆ getEcalEnergy()

double HTrackAssociator::getEcalEnergy ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const FreeTrajectoryState trackOrigin,
const double  dR = -1 
)

associate ECAL only and return energy negative dR means only crossed elements

Definition at line 153 of file TrackAssociator.cc.

156  {
157  HAssociatorParameters parameters;
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 }

References HGC3DClusterGenMatchSelector_cfi::dR, iEvent, and info().

◆ getFreeTrajectoryState() [1/2]

FreeTrajectoryState HTrackAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const reco::Track track 
)

get FreeTrajectoryState from different track representations

Definition at line 570 of file TrackAssociator.cc.

570  {
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 }

References Calorimetry_cff::bField, MillePedeFileConverter_cfg::e, reco::get(), edm::EventSetup::get(), point, and HLT_2018_cff::track.

◆ getFreeTrajectoryState() [2/2]

FreeTrajectoryState HTrackAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const SimTrack track,
const SimVertex vertex 
)

Definition at line 550 of file TrackAssociator.cc.

552  {
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 }

References Calorimetry_cff::bField, ALCARECOTkAlJpsiMuMu_cff::charge, MillePedeFileConverter_cfg::e, reco::get(), edm::EventSetup::get(), point, HLT_2018_cff::track, and bphysicsOniaDQM_cfi::vertex.

◆ getHcalEnergy()

double HTrackAssociator::getHcalEnergy ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const FreeTrajectoryState trackOrigin,
const double  dR = -1 
)

associate ECAL only and return energy negative dR means only crossed elements

Definition at line 183 of file TrackAssociator.cc.

186  {
187  HAssociatorParameters parameters;
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 }

References HGC3DClusterGenMatchSelector_cfi::dR, iEvent, and info().

◆ getPoint() [1/2]

math::XYZPoint HTrackAssociator::getPoint ( const GlobalPoint point)
inlineprivate

Definition at line 162 of file TrackAssociator.h.

162 { return math::XYZPoint(point.x(), point.y(), point.z()); }

References point.

◆ getPoint() [2/2]

math::XYZPoint HTrackAssociator::getPoint ( const LocalPoint point)
inlineprivate

Definition at line 164 of file TrackAssociator.h.

164 { return math::XYZPoint(point.x(), point.y(), point.z()); }

References point.

◆ getVector() [1/2]

math::XYZVector HTrackAssociator::getVector ( const GlobalVector vec)
inlineprivate

◆ getVector() [2/2]

math::XYZVector HTrackAssociator::getVector ( const LocalVector vec)
inlineprivate

◆ init()

void HTrackAssociator::init ( const edm::EventSetup iSetup)
private

Definition at line 95 of file TrackAssociator.cc.

95  {
96  // access the calorimeter geometry
99  throw cms::Exception("FatalError") << "Unable to find IdealGeometryRecord in event!\n";
100 
102  // setup propagator
105 
107  prop->setMaterialMode(false);
108  prop->applyRadX0Correction(true);
109  // prop->setDebug(true); // tmp
110  defProp_ = prop;
112  }
113 }

References anyDirection, SteppingHelixPropagator::applyRadX0Correction(), Calorimetry_cff::bField, reco::get(), edm::EventSetup::get(), SteppingHelixPropagator::setMaterialMode(), and SteppingHelixPropagator_cfi::SteppingHelixPropagator.

◆ setPropagator()

void HTrackAssociator::setPropagator ( Propagator ptr)

use a user configured propagator

Definition at line 84 of file TrackAssociator.cc.

◆ useDefaultPropagator()

void HTrackAssociator::useDefaultPropagator ( )

use the default propagator

Definition at line 92 of file TrackAssociator.cc.

92 { useDefaultPropagator_ = true; }

Member Data Documentation

◆ caloDetIdAssociator_

HCaloDetIdAssociator HTrackAssociator::caloDetIdAssociator_
private

Definition at line 178 of file TrackAssociator.h.

◆ CaloTowerCollectionLabels

std::vector<std::string> HTrackAssociator::CaloTowerCollectionLabels
private

CaloTowers.

Definition at line 189 of file TrackAssociator.h.

◆ caloTowerMap_

std::vector<std::vector<std::set<uint32_t> > >* HTrackAssociator::caloTowerMap_
private

Definition at line 174 of file TrackAssociator.h.

◆ debug_

int HTrackAssociator::debug_
private

Definition at line 173 of file TrackAssociator.h.

◆ defProp_

Propagator* HTrackAssociator::defProp_
private

Definition at line 171 of file TrackAssociator.h.

◆ EBRecHitCollectionLabels

std::vector<std::string> HTrackAssociator::EBRecHitCollectionLabels
private

Labels of the detector EDProducts (empty by default) ECAL

Definition at line 184 of file TrackAssociator.h.

◆ ecalDetIdAssociator_

HEcalDetIdAssociator HTrackAssociator::ecalDetIdAssociator_
private

Definition at line 176 of file TrackAssociator.h.

◆ EERecHitCollectionLabels

std::vector<std::string> HTrackAssociator::EERecHitCollectionLabels
private

Definition at line 185 of file TrackAssociator.h.

◆ HBHERecHitCollectionLabels

std::vector<std::string> HTrackAssociator::HBHERecHitCollectionLabels
private

HCAL.

Definition at line 187 of file TrackAssociator.h.

◆ hcalDetIdAssociator_

HHcalDetIdAssociator HTrackAssociator::hcalDetIdAssociator_
private

Definition at line 177 of file TrackAssociator.h.

◆ ivProp_

Propagator* HTrackAssociator::ivProp_
private

Definition at line 170 of file TrackAssociator.h.

◆ theCaloGeometry_

edm::ESHandle<CaloGeometry> HTrackAssociator::theCaloGeometry_
private

Definition at line 180 of file TrackAssociator.h.

◆ useDefaultPropagator_

bool HTrackAssociator::useDefaultPropagator_
private

Definition at line 172 of file TrackAssociator.h.

Vector3DBase
Definition: Vector3DBase.h:8
HDetIdAssociator::getMaxEDetId
virtual std::set< DetId > getMaxEDetId(const std::set< DetId > &, edm::Handle< CaloTowerCollection > caloTowers)
Definition: DetIdAssociator.cc:407
HTrackAssociator::ecalDetIdAssociator_
HEcalDetIdAssociator ecalDetIdAssociator_
Definition: TrackAssociator.h:176
anyDirection
Definition: PropagationDirection.h:4
edm::SortedCollection< CaloTower >::const_iterator
std::vector< CaloTower >::const_iterator const_iterator
Definition: SortedCollection.h:80
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
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
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
HDetIdAssociator::getDetIdsInACone
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double)
Definition: DetIdAssociator.cc:345
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
HDetIdAssociator::setPropagator
virtual void setPropagator(Propagator *ptr)
Definition: DetIdAssociator.h:62
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
SteppingHelixPropagator_cfi.SteppingHelixPropagator
SteppingHelixPropagator
Definition: SteppingHelixPropagator_cfi.py:3
edm::Handle
Definition: AssociativeIterator.h:50
filterRecHits_cfi.EERecHits
EERecHits
Definition: filterRecHits_cfi.py:9
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
HTrackAssociator::hcalDetIdAssociator_
HHcalDetIdAssociator hcalDetIdAssociator_
Definition: TrackAssociator.h:177
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
AlgebraicMatrixID
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Definition: AlgebraicROOTObjects.h:72
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
SteppingHelixPropagator
Definition: SteppingHelixPropagator.h:36
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
HTrackAssociator::getPoint
math::XYZPoint getPoint(const GlobalPoint &point)
Definition: TrackAssociator.h:162
AlgebraicSymMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Definition: AlgebraicROOTObjects.h:24
edm::ESHandle< MagneticField >
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
HTrackAssociator::useDefaultPropagator_
bool useDefaultPropagator_
Definition: TrackAssociator.h:172
HTrackAssociator::CaloTowerCollectionLabels
std::vector< std::string > CaloTowerCollectionLabels
CaloTowers.
Definition: TrackAssociator.h:189
HTrackAssociator::defProp_
Propagator * defProp_
Definition: TrackAssociator.h:171
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HTrackAssociator::theCaloGeometry_
edm::ESHandle< CaloGeometry > theCaloGeometry_
Definition: TrackAssociator.h:180
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
eleHcalExtractorBlocks_cff.caloTowers
caloTowers
Definition: eleHcalExtractorBlocks_cff.py:15
HDetIdAssociator::getDetIdsCloseToAPoint
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
Definition: DetIdAssociator.cc:138
SteppingHelixPropagator::applyRadX0Correction
void applyRadX0Correction(bool applyRadX0Correction)
Definition: SteppingHelixPropagator.h:133
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
iEvent
int iEvent
Definition: GenABIO.cc:224
HTrackAssociator::EERecHitCollectionLabels
std::vector< std::string > EERecHitCollectionLabels
Definition: TrackAssociator.h:185
HTrackAssociator::EBRecHitCollectionLabels
std::vector< std::string > EBRecHitCollectionLabels
Definition: TrackAssociator.h:184
HTrackAssociator::caloTowerMap_
std::vector< std::vector< std::set< uint32_t > > > * caloTowerMap_
Definition: TrackAssociator.h:174
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
get
#define get
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
SteppingHelixPropagator::setMaterialMode
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
Definition: SteppingHelixPropagator.h:124
HDetIdAssociator::getTrajectory
virtual std::vector< GlobalPoint > getTrajectory(const FreeTrajectoryState &, const std::vector< GlobalPoint > &)
Definition: DetIdAssociator.cc:25
HTrackDetMatchInfo
Definition: TrackDetMatchInfo.h:10
HTrackAssociator::ivProp_
Propagator * ivProp_
Definition: TrackAssociator.h:170
CartesianTrajectoryError
Definition: CartesianTrajectoryError.h:15
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
Calorimetry_cff.bField
bField
Definition: Calorimetry_cff.py:292
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
HCaloDetIdAssociator::setGeometry
virtual void setGeometry(const CaloGeometry *ptr)
Definition: CaloDetIdAssociator.h:32
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
HDetIdAssociator::getCrossedDetIds
virtual std::set< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory)
Definition: DetIdAssociator.cc:394
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
HTrackAssociator::debug_
int debug_
Definition: TrackAssociator.h:173
HTrackAssociator::HBHERecHitCollectionLabels
std::vector< std::string > HBHERecHitCollectionLabels
HCAL.
Definition: TrackAssociator.h:187
HTrackAssociator::caloDetIdAssociator_
HCaloDetIdAssociator caloDetIdAssociator_
Definition: TrackAssociator.h:178
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
filterRecHits_cfi.EBRecHits
EBRecHits
Definition: filterRecHits_cfi.py:8