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 ( )

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 }
Propagator * defProp_
std::vector< std::vector< std::set< uint32_t > > > * caloTowerMap_
Propagator * ivProp_
HTrackAssociator::~HTrackAssociator ( )

Definition at line 52 of file TrackAssociator.cc.

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

Member Function Documentation

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 }
std::vector< std::string > EERecHitCollectionLabels
std::vector< std::string > CaloTowerCollectionLabels
CaloTowers.
std::vector< std::string > EBRecHitCollectionLabels
std::vector< std::string > HBHERecHitCollectionLabels
HCAL.
std::string className(const T &t)
Definition: ClassName.h:31
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.

References HTrackAssociator::HAssociatorParameters::dRCalo, HTrackAssociator::HAssociatorParameters::dREcal, HTrackAssociator::HAssociatorParameters::dRHcal, HLT_2018_cff::fillCaloTowers, HTrackAssociator::HAssociatorParameters::idRCalo, HTrackAssociator::HAssociatorParameters::idREcal, HTrackAssociator::HAssociatorParameters::idRHcal, info(), init, HTrackAssociator::HAssociatorParameters::useCalo, HTrackAssociator::HAssociatorParameters::useEcal, and HTrackAssociator::HAssociatorParameters::useHcal.

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

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 }
static const TGPicture * info(bool iBackgroundIsBlack)
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)
HLT enums.
void fillCaloTowers(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
void init(const edm::EventSetup &)
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.

References HTrackDetMatchInfo::coneEcalRecHits, HTrackDetMatchInfo::crossedEcalRecHits, HGC3DClusterGenMatchSelector_cfi::dR, HTrackAssociator::HAssociatorParameters::dREcal, info(), and HTrackAssociator::HAssociatorParameters::useHcal.

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 }
static const TGPicture * info(bool iBackgroundIsBlack)
HTrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
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.

References HTrackDetMatchInfo::coneTowers, HTrackDetMatchInfo::crossedTowers, HGC3DClusterGenMatchSelector_cfi::dR, HTrackAssociator::HAssociatorParameters::dRHcal, info(), and HTrackAssociator::HAssociatorParameters::useEcal.

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 }
static const TGPicture * info(bool iBackgroundIsBlack)
HTrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
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.

References HTrackDetMatchInfo::boxTowers, eleHcalExtractorBlocks_cff::caloTowers, HTrackDetMatchInfo::coneTowers, gather_cfg::cout, HTrackDetMatchInfo::crossedTowers, edm::Event::getByLabel(), triggerObjects_cff::id, HTrackDetMatchInfo::isGoodCalo, HTrackDetMatchInfo::isGoodEcal, HTrackDetMatchInfo::isGoodHcal, edm::HandleBase::isValid(), LogTrace, HTrackDetMatchInfo::regionTowers, hgcalTowerProducer_cfi::tower, HTrackDetMatchInfo::trkGlobPosAtEcal, and HTrackDetMatchInfo::trkGlobPosAtHcal.

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 }
std::vector< CaloTower > crossedTowers
virtual std::vector< GlobalPoint > getTrajectory(const FreeTrajectoryState &, const std::vector< GlobalPoint > &)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
edm::ESHandle< CaloGeometry > theCaloGeometry_
std::vector< std::string > CaloTowerCollectionLabels
CaloTowers.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< CaloTower >::const_iterator const_iterator
std::vector< CaloTower > boxTowers
math::XYZPoint trkGlobPosAtHcal
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double)
bool isValid() const
Definition: HandleBase.h:70
virtual std::set< DetId > getMaxEDetId(const std::set< DetId > &, edm::Handle< CaloTowerCollection > caloTowers)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
HCaloDetIdAssociator caloDetIdAssociator_
#define LogTrace(id)
Definition: DetId.h:17
std::vector< CaloTower > regionTowers
std::vector< CaloTower > coneTowers
math::XYZPoint trkGlobPosAtEcal
virtual void setGeometry(const CaloGeometry *ptr)
math::XYZPoint getPoint(const GlobalPoint &point)
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.

References HTrackDetMatchInfo::coneEcalRecHits, HTrackDetMatchInfo::crossedEcalRecHits, filterRecHits_cfi::EBRecHits, filterRecHits_cfi::EERecHits, edm::Event::getByLabel(), HTrackDetMatchInfo::isGoodEcal, LogTrace, and HTrackDetMatchInfo::trkGlobPosAtEcal.

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 }
virtual std::vector< GlobalPoint > getTrajectory(const FreeTrajectoryState &, const std::vector< GlobalPoint > &)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
edm::ESHandle< CaloGeometry > theCaloGeometry_
std::vector< std::string > EERecHitCollectionLabels
std::vector< EcalRecHit > crossedEcalRecHits
std::vector< std::string > EBRecHitCollectionLabels
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< EcalRecHit > coneEcalRecHits
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double)
virtual std::set< DetId > getCrossedDetIds(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory)
HEcalDetIdAssociator ecalDetIdAssociator_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
#define LogTrace(id)
math::XYZPoint trkGlobPosAtEcal
virtual void setGeometry(const CaloGeometry *ptr)
math::XYZPoint getPoint(const GlobalPoint &point)
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.

References HTrackDetMatchInfo::boxHcalRecHits, HTrackDetMatchInfo::coneHcalRecHits, HTrackDetMatchInfo::crossedHcalRecHits, edm::Event::getByLabel(), egHLT::errCodes::HBHERecHits, HTrackDetMatchInfo::isGoodHcal, edm::HandleBase::isValid(), LogTrace, HTrackDetMatchInfo::regionHcalRecHits, and HTrackDetMatchInfo::trkGlobPosAtHcal.

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 }
virtual std::vector< GlobalPoint > getTrajectory(const FreeTrajectoryState &, const std::vector< GlobalPoint > &)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
edm::ESHandle< CaloGeometry > theCaloGeometry_
std::vector< HBHERecHit > coneHcalRecHits
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< HBHERecHit > regionHcalRecHits
std::vector< std::string > HBHERecHitCollectionLabels
HCAL.
math::XYZPoint trkGlobPosAtHcal
std::vector< HBHERecHit > boxHcalRecHits
std::vector< HBHERecHit > crossedHcalRecHits
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double)
bool isValid() const
Definition: HandleBase.h:70
virtual std::set< DetId > getMaxEDetId(const std::set< DetId > &, edm::Handle< CaloTowerCollection > caloTowers)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
#define LogTrace(id)
virtual void setGeometry(const CaloGeometry *ptr)
HHcalDetIdAssociator hcalDetIdAssociator_
math::XYZPoint getPoint(const GlobalPoint &point)
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.

References eleHcalExtractorBlocks_cff::caloTowers, HTrackDetMatchInfo::coneTowers, gather_cfg::cout, HTrackDetMatchInfo::crossedTowers, edm::Event::getByLabel(), triggerObjects_cff::id, HTrackDetMatchInfo::isGoodCalo, edm::HandleBase::isValid(), LogTrace, hgcalTowerProducer_cfi::tower, and HTrackDetMatchInfo::trkGlobPosAtHcal.

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 }
std::vector< CaloTower > crossedTowers
virtual std::vector< GlobalPoint > getTrajectory(const FreeTrajectoryState &, const std::vector< GlobalPoint > &)
virtual std::set< DetId > getDetIdsCloseToAPoint(const GlobalPoint &, const int idR=0)
edm::ESHandle< CaloGeometry > theCaloGeometry_
std::vector< std::string > CaloTowerCollectionLabels
CaloTowers.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< CaloTower >::const_iterator const_iterator
math::XYZPoint trkGlobPosAtHcal
virtual std::set< DetId > getDetIdsInACone(const std::set< DetId > &, const std::vector< GlobalPoint > &trajectory, const double)
bool isValid() const
Definition: HandleBase.h:70
virtual std::set< DetId > getMaxEDetId(const std::set< DetId > &, edm::Handle< CaloTowerCollection > caloTowers)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
HCaloDetIdAssociator caloDetIdAssociator_
#define LogTrace(id)
Definition: DetId.h:17
std::vector< CaloTower > coneTowers
virtual void setGeometry(const CaloGeometry *ptr)
math::XYZPoint getPoint(const GlobalPoint &point)
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.

References HGC3DClusterGenMatchSelector_cfi::dR, HTrackAssociator::HAssociatorParameters::dREcal, HTrackDetMatchInfo::ecalConeEnergyFromRecHits(), HTrackDetMatchInfo::ecalEnergyFromRecHits(), info(), and HTrackAssociator::HAssociatorParameters::useHcal.

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 }
static const TGPicture * info(bool iBackgroundIsBlack)
double ecalConeEnergyFromRecHits()
HTrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
double ecalEnergyFromRecHits()
ECAL energy.
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.

References Calorimetry_cff::bField, reco::TrackBase::charge(), MillePedeFileConverter_cfg::e, edm::EventSetup::get(), reco::TrackBase::momentum(), point, and reco::TrackBase::vertex().

570  {
572  iSetup.get<IdealMagneticFieldRecord>().get(bField);
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 }
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:629
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:641
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
T get() const
Definition: EventSetup.h:73
int charge() const
track electric charge
Definition: TrackBase.h:575
*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
FreeTrajectoryState HTrackAssociator::getFreeTrajectoryState ( const edm::EventSetup iSetup,
const SimTrack track,
const SimVertex vertex 
)

Definition at line 550 of file TrackAssociator.cc.

References Calorimetry_cff::bField, ALCARECOTkAlJpsiMuMu_cff::charge, MillePedeFileConverter_cfg::e, edm::EventSetup::get(), CoreSimTrack::momentum(), point, CoreSimVertex::position(), and CoreSimTrack::type().

552  {
554  iSetup.get<IdealMagneticFieldRecord>().get(bField);
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 }
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
T get() const
Definition: EventSetup.h:73
*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
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.

References HGC3DClusterGenMatchSelector_cfi::dR, HTrackAssociator::HAssociatorParameters::dRHcal, HTrackDetMatchInfo::hcalConeEnergyFromRecHits(), HTrackDetMatchInfo::hcalEnergyFromRecHits(), info(), and HTrackAssociator::HAssociatorParameters::useEcal.

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 }
static const TGPicture * info(bool iBackgroundIsBlack)
HTrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
math::XYZPoint HTrackAssociator::getPoint ( const GlobalPoint point)
inlineprivate

Definition at line 162 of file TrackAssociator.h.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

162 { return math::XYZPoint(point.x(), point.y(), point.z()); }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:59
math::XYZPoint HTrackAssociator::getPoint ( const LocalPoint point)
inlineprivate

Definition at line 164 of file TrackAssociator.h.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

164 { return math::XYZPoint(point.x(), point.y(), point.z()); }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:59
math::XYZVector HTrackAssociator::getVector ( const GlobalVector vec)
inlineprivate

Definition at line 166 of file TrackAssociator.h.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

166 { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
T x() const
Definition: PV3DBase.h:59
math::XYZVector HTrackAssociator::getVector ( const LocalVector vec)
inlineprivate

Definition at line 168 of file TrackAssociator.h.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

168 { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
T x() const
Definition: PV3DBase.h:59
void HTrackAssociator::init ( const edm::EventSetup iSetup)
private

Definition at line 95 of file TrackAssociator.cc.

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

95  {
96  // access the calorimeter geometry
99  throw cms::Exception("FatalError") << "Unable to find IdealGeometryRecord in event!\n";
100 
102  // setup propagator
104  iSetup.get<IdealMagneticFieldRecord>().get(bField);
105 
107  prop->setMaterialMode(false);
108  prop->applyRadX0Correction(true);
109  // prop->setDebug(true); // tmp
110  defProp_ = prop;
112  }
113 }
edm::ESHandle< CaloGeometry > theCaloGeometry_
Propagator * defProp_
void setPropagator(Propagator *)
use a user configured propagator
void applyRadX0Correction(bool applyRadX0Correction)
T get() const
Definition: EventSetup.h:73
bool isValid() const
Definition: ESHandle.h:44
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void HTrackAssociator::setPropagator ( Propagator ptr)

use a user configured propagator

Definition at line 84 of file TrackAssociator.cc.

84  {
85  ivProp_ = ptr;
89 }
Propagator * ivProp_
HEcalDetIdAssociator ecalDetIdAssociator_
HCaloDetIdAssociator caloDetIdAssociator_
virtual void setPropagator(Propagator *ptr)
HHcalDetIdAssociator hcalDetIdAssociator_
void HTrackAssociator::useDefaultPropagator ( )

use the default propagator

Definition at line 92 of file TrackAssociator.cc.

92 { useDefaultPropagator_ = true; }

Member Data Documentation

HCaloDetIdAssociator HTrackAssociator::caloDetIdAssociator_
private

Definition at line 178 of file TrackAssociator.h.

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

CaloTowers.

Definition at line 189 of file TrackAssociator.h.

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

Definition at line 174 of file TrackAssociator.h.

int HTrackAssociator::debug_
private

Definition at line 173 of file TrackAssociator.h.

Propagator* HTrackAssociator::defProp_
private

Definition at line 171 of file TrackAssociator.h.

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

Labels of the detector EDProducts (empty by default) ECAL

Definition at line 184 of file TrackAssociator.h.

HEcalDetIdAssociator HTrackAssociator::ecalDetIdAssociator_
private

Definition at line 176 of file TrackAssociator.h.

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

Definition at line 185 of file TrackAssociator.h.

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

HCAL.

Definition at line 187 of file TrackAssociator.h.

HHcalDetIdAssociator HTrackAssociator::hcalDetIdAssociator_
private

Definition at line 177 of file TrackAssociator.h.

Propagator* HTrackAssociator::ivProp_
private

Definition at line 170 of file TrackAssociator.h.

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

Definition at line 180 of file TrackAssociator.h.

bool HTrackAssociator::useDefaultPropagator_
private

Definition at line 172 of file TrackAssociator.h.