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 47 of file TrackAssociator.h.

Constructor & Destructor Documentation

HTrackAssociator::HTrackAssociator ( )

Definition at line 50 of file TrackAssociator.cc.

51 {
52  ivProp_ = nullptr;
53  defProp_ = nullptr;
54  debug_ = 0;
55  caloTowerMap_ = nullptr;
56  useDefaultPropagator_ = false;
57 }
Propagator * defProp_
std::vector< std::vector< std::set< uint32_t > > > * caloTowerMap_
Propagator * ivProp_
HTrackAssociator::~HTrackAssociator ( )

Definition at line 59 of file TrackAssociator.cc.

60 {
61  if (defProp_) delete defProp_;
62 }
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 65 of file TrackAssociator.cc.

68 {
69  if (className == "EBRecHitCollection")
70  {
72  EBRecHitCollectionLabels.push_back(moduleLabel);
73  EBRecHitCollectionLabels.push_back(productInstanceLabel);
74  }
75  if (className == "EERecHitCollection")
76  {
78  EERecHitCollectionLabels.push_back(moduleLabel);
79  EERecHitCollectionLabels.push_back(productInstanceLabel);
80  }
81  if (className == "HBHERecHitCollection")
82  {
84  HBHERecHitCollectionLabels.push_back(moduleLabel);
85  HBHERecHitCollectionLabels.push_back(productInstanceLabel);
86  }
87  if (className == "CaloTowerCollection")
88  {
90  CaloTowerCollectionLabels.push_back(moduleLabel);
91  CaloTowerCollectionLabels.push_back(productInstanceLabel);
92  }
93 }
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:30
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 137 of file TrackAssociator.cc.

References HTrackAssociator::HAssociatorParameters::dRCalo, HTrackAssociator::HAssociatorParameters::dREcal, HTrackAssociator::HAssociatorParameters::dRHcal, 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().

141 {
143  using namespace edm;
144 
145  init( iSetup );
146 
147  const FreeTrajectoryState& currentPosition(trackOrigin);
148 
149  if (parameters.useEcal) fillEcal( iEvent, iSetup, info, currentPosition,parameters.idREcal, parameters.dREcal);
150  if (parameters.useHcal) fillHcal( iEvent, iSetup, info, currentPosition,parameters.idRHcal,parameters.dRHcal);
151  if (parameters.useCalo) fillCaloTowers( iEvent, iSetup, info, currentPosition,parameters.idRCalo,parameters.dRCalo);
152 
153  return info;
154 }
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 157 of file TrackAssociator.cc.

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

161 {
162  HAssociatorParameters parameters;
163  parameters.useHcal = false;
164  parameters.dREcal = dR;
165  HTrackDetMatchInfo info( associate(iEvent, iSetup, trackOrigin, parameters ));
166  if (dR>0)
167  return info.coneEcalRecHits;
168  else
169  return info.crossedEcalRecHits;
170 }
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 189 of file TrackAssociator.cc.

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

193 {
194  HAssociatorParameters parameters;
195  parameters.useEcal = false;
196  parameters.dRHcal = dR;
197  HTrackDetMatchInfo info( associate(iEvent, iSetup, trackOrigin, parameters ));
198  if (dR>0)
199  return info.coneTowers;
200  else
201  return info.crossedTowers;
202 
203 }
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 300 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, HTrackDetMatchInfo::trkGlobPosAtEcal, and HTrackDetMatchInfo::trkGlobPosAtHcal.

306 {
307  // ECAL hits are not used for the CaloTower identification
309 
310  // HCAL points (HB+HE)
311  std::vector<GlobalPoint> hcalPoints;
312  hcalPoints.push_back(GlobalPoint(135.,0,310.));
313  hcalPoints.push_back(GlobalPoint(150.,0,340.));
314  hcalPoints.push_back(GlobalPoint(170.,0,370.));
315  hcalPoints.push_back(GlobalPoint(190.,0,400.));
316  hcalPoints.push_back(GlobalPoint(240.,0,500.));
317  hcalPoints.push_back(GlobalPoint(280.,0,550.));
318 
319  std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
320 // if(hcalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate the track to HCAL\n";
321 
322  if(hcalTrajectory.empty()) {
323  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to ECAL; moving on\n";
324  info.isGoodCalo = false;
325  info.isGoodEcal = false;
326  std::cout<<" HTrackAssociator::fillCaloTowers::Failed to propagate a track to ECAL "<<std::endl;
327  return;
328  }
329 
330  info.isGoodCalo = true;
331  info.isGoodEcal = true;
332  info.trkGlobPosAtEcal = getPoint(hcalTrajectory[0]);
333 
334  if(hcalTrajectory.size()<4) {
335  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to HCAL; moving on\n";
336  info.isGoodHcal = false;
337  }
338 
339  info.isGoodHcal = true;
340 
341  info.trkGlobPosAtHcal = getPoint(hcalTrajectory[4]);
342 
343  // find crossed CaloTowers
345 
346  if (CaloTowerCollectionLabels.empty())
347  throw cms::Exception("FatalError") << "Module lable is not set for CaloTowers.\n";
348  else
350  if (!caloTowers.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
351 
352 // first get DetIds in a predefined NxN region
353 // std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
354  std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
355 
356  std::set<DetId> caloTowerIdsInACone;
357  std::set<DetId> crossedCaloTowerIds;
358  std::set<DetId> caloTowerIdsInBox;
359  caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInRegion, hcalTrajectory, dR);
360 // get DetId of the most energetic tower in that region
361  crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
362 // get DetIds of the towers surrounding the most energetic one
363  caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
364 
365 //
366 // Debug prints
367 //
368 // std::cout <<" Debug printout in CaloTowers "<<std::endl;
369 // std::cout <<" with position at outer layer:r,z,phi "<<trajectoryPoint.position().eta()<<
370 // " "<<trajectoryPoint.position().phi()<<
371 // " "<<trajectoryPoint.position().perp()<<
372 // " "<<trajectoryPoint.position().z()<<
373 // " "<<trajectoryPoint.charge()<<std::endl;
374 // std::cout <<" Trajectory point at ECAL surface:eta:phi:radius:z "<<(hcalTrajectory[0]).eta()<<
375 // " "<<(hcalTrajectory[0]).phi()<<
376 // " "<<(hcalTrajectory[0]).perp()<<
377 // " "<<(hcalTrajectory[0]).z()<<
378 // " momentum "<<trajectoryPoint.momentum().perp()<<std::endl;
379 //
380 // std::cout<<" Number of towers in the region "<<caloTowerIdsInRegion.size()<<" idR= "<<idR<<std::endl;
381 
382  // add CaloTowers
383  for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
384  {
385  DetId id(*itr);
386  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
387  if(tower != (*caloTowers).end())
388  info.crossedTowers.push_back(*tower);
389  else
390  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
391  }
392 
393  for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
394  {
395  DetId id(*itr);
396  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
397  if(tower != (*caloTowers).end()) {
398  info.coneTowers.push_back(*tower);
399  }
400  else
401  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
402  }
403 
404  for(std::set<DetId>::const_iterator itr=caloTowerIdsInBox.begin(); itr!=caloTowerIdsInBox.end();itr++)
405  {
406  DetId id(*itr);
407  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
408  if(tower != (*caloTowers).end()) {
409  info.boxTowers.push_back(*tower);
410  }
411  else
412  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
413  }
414 
415  for(std::set<DetId>::const_iterator itr=caloTowerIdsInRegion.begin(); itr!=caloTowerIdsInRegion.end();itr++)
416  {
417  DetId id(*itr);
418  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
419  if(tower != (*caloTowers).end()) {
420  info.regionTowers.push_back(*tower);
421  }
422  else
423  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
424  }
425 
426 }
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:74
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:480
HCaloDetIdAssociator caloDetIdAssociator_
#define LogTrace(id)
Definition: DetId.h:18
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 222 of file TrackAssociator.cc.

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

228 {
230 
231  // ECAL points (EB+EE)
232  std::vector<GlobalPoint> ecalPoints;
233  ecalPoints.push_back(GlobalPoint(135.,0,310.));
234  ecalPoints.push_back(GlobalPoint(150.,0,340.));
235  ecalPoints.push_back(GlobalPoint(170.,0,370.));
236 
237  std::vector<GlobalPoint> ecalTrajectory = ecalDetIdAssociator_.getTrajectory(trajectoryPoint, ecalPoints);
238 // if(ecalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate a track to ECAL\n";
239 
240  if(ecalTrajectory.empty()) {
241  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to ECAL; moving on\n";
242  info.isGoodEcal = false;
243  return;
244  }
245 
246  info.isGoodEcal = true;
247 
248  info.trkGlobPosAtEcal = getPoint(ecalTrajectory[0]);
249 
250  // Find ECAL crystals
253 // if (EBRecHitCollectionLabels.empty())
254 // throw cms::Exception("FatalError") << "Module lable is not set for EBRecHitCollection.\n";
255 // else
257 // if (!EBRecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EBRecHitCollection in event!\n";
259 // if (!EERecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find EERecHitCollection in event!\n";
260 
261  std::set<DetId> ecalIdsInRegion = ecalDetIdAssociator_.getDetIdsCloseToAPoint(ecalTrajectory[0],idR);
262  std::set<DetId> ecalIdsInACone = ecalDetIdAssociator_.getDetIdsInACone(ecalIdsInRegion, ecalTrajectory, dR);
263  std::set<DetId> crossedEcalIds = ecalDetIdAssociator_.getCrossedDetIds(ecalIdsInRegion, ecalTrajectory);
264 
265  // add EcalRecHits
266  for(std::set<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++) {
267  std::vector<EcalRecHit>::const_iterator hit = (*EBRecHits).find(*itr);
268  if(hit != (*EBRecHits).end())
269  info.crossedEcalRecHits.push_back(*hit);
270  else
271  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
272  }
273  for(std::set<DetId>::const_iterator itr=ecalIdsInACone.begin(); itr!=ecalIdsInACone.end();itr++) {
274  std::vector<EcalRecHit>::const_iterator hit = (*EBRecHits).find(*itr);
275  if(hit != (*EBRecHits).end()) {
276  info.coneEcalRecHits.push_back(*hit);
277  }
278  else
279  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
280  }
282  for(std::set<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++) {
283  std::vector<EcalRecHit>::const_iterator hit = (*EERecHits).find(*itr);
284  if(hit != (*EERecHits).end())
285  info.crossedEcalRecHits.push_back(*hit);
286  else
287  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
288  }
289  for(std::set<DetId>::const_iterator itr=ecalIdsInACone.begin(); itr!=ecalIdsInACone.end();itr++) {
290  std::vector<EcalRecHit>::const_iterator hit = (*EERecHits).find(*itr);
291  if(hit != (*EERecHits).end()) {
292  info.coneEcalRecHits.push_back(*hit);
293  }
294  else
295  LogTrace("HTrackAssociator::fillEcal") << "EcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
296  }
297 }
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:480
#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 429 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.

434  {
436 
437 // HCAL points (HB+HE)
438  std::vector<GlobalPoint> hcalPoints;
439  hcalPoints.push_back(GlobalPoint(190.,0,400.));
440  hcalPoints.push_back(GlobalPoint(240.,0,500.));
441  hcalPoints.push_back(GlobalPoint(280.,0,550.));
442 
443  std::vector<GlobalPoint> hcalTrajectory = hcalDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
444 // if(hcalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate the track to HCAL\n";
445 
446  if(hcalTrajectory.empty()) {
447  LogTrace("HTrackAssociator::fillHcal") << "Failed to propagate a track to HCAL; moving on\n";
448  info.isGoodHcal = false;
449 // std::cout<<" HTrackAssociator::fillHcal::Failed to propagate a track to HCAL "<<std::endl;
450  return;
451  }
452 
453  info.isGoodHcal = true;
454 
455  info.trkGlobPosAtHcal = getPoint(hcalTrajectory[0]);
456 
458 // if (HBHERecHitCollectionLabels.empty())
459 // throw cms::Exception("FatalError") << "Module label is not set for HBHERecHitCollection.\n";
460 // else
462  if (!HBHERecHits.isValid()) throw cms::Exception("FatalError") << "Unable to find HBHERecHitCollection in event!\n";
463 
464 // first get DetIds in a predefined NxN region
465 // std::set<DetId> hcalIdsInBigRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
466  std::set<DetId> hcalIdsInRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
467 
468  std::set<DetId> hcalIdsInACone;
469  std::set<DetId> crossedHcalIds;
470  std::set<DetId> hcalIdsInBox;
471  hcalIdsInACone = hcalDetIdAssociator_.getDetIdsInACone(hcalIdsInRegion, hcalTrajectory, dR);
472 // get DetId of the most energetic tower in that region
473  crossedHcalIds = hcalDetIdAssociator_.getMaxEDetId(hcalIdsInRegion, HBHERecHits);
474 // get DetIds of the towers surrounding the most energetic one
475  hcalIdsInBox = hcalDetIdAssociator_.getDetIdsInACone(crossedHcalIds, hcalTrajectory, -1.);
476 
477 // add HcalRecHits
478  for(std::set<DetId>::const_iterator itr=crossedHcalIds.begin(); itr!=crossedHcalIds.end();itr++) {
479  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
480  if(hit != (*HBHERecHits).end())
481  info.crossedHcalRecHits.push_back(*hit);
482  else
483  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
484  }
485  for(std::set<DetId>::const_iterator itr=hcalIdsInACone.begin(); itr!=hcalIdsInACone.end();itr++) {
486  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
487  if(hit != (*HBHERecHits).end())
488  info.coneHcalRecHits.push_back(*hit);
489  else
490  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
491  }
492  for(std::set<DetId>::const_iterator itr=hcalIdsInBox.begin(); itr!=hcalIdsInBox.end();itr++) {
493  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
494  if(hit != (*HBHERecHits).end())
495  info.boxHcalRecHits.push_back(*hit);
496  else
497  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
498  }
499  for(std::set<DetId>::const_iterator itr=hcalIdsInRegion.begin(); itr!=hcalIdsInRegion.end();itr++) {
500  std::vector<HBHERecHit>::const_iterator hit = (*HBHERecHits).find(*itr);
501  if(hit != (*HBHERecHits).end())
502  info.regionHcalRecHits.push_back(*hit);
503  else
504  LogTrace("HTrackAssociator::fillHcal") << "HcalRecHit is not found for DetId: " << itr->rawId() <<"\n";
505  }
506 }
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:74
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:480
#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 509 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, and HTrackDetMatchInfo::trkGlobPosAtHcal.

515 {
516  // ECAL hits are not used for the CaloTower identification
518 
519  // HCAL points (HB+HE)
520  std::vector<GlobalPoint> hcalPoints;
521  hcalPoints.push_back(GlobalPoint(190.,0,400.));
522  hcalPoints.push_back(GlobalPoint(240.,0,500.));
523  hcalPoints.push_back(GlobalPoint(280.,0,550.));
524 
525  std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
526 // if(hcalTrajectory.empty()) throw cms::Exception("FatalError") << "Failed to propagate the track to HCAL\n";
527 
528  if(hcalTrajectory.empty()) {
529  LogTrace("HTrackAssociator::fillEcal") << "Failed to propagate a track to HCAL; moving on\n";
530  info.isGoodCalo = false;
531  std::cout<<" HTrackAssociator::fillCaloTowers::Failed to propagate a track to HCAL "<<std::endl;
532  return;
533  }
534 
535  info.isGoodCalo = true;
536 
537  info.trkGlobPosAtHcal = getPoint(hcalTrajectory[0]);
538 
539  // find crossed CaloTowers
541 
542  if (CaloTowerCollectionLabels.empty())
543  throw cms::Exception("FatalError") << "Module lable is not set for CaloTowers.\n";
544  else
546  if (!caloTowers.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloTowers in event!\n";
547 
548 
549 // first get DetIds in a predefined NxN region
550  std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
551  std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
552 
553  std::set<DetId> caloTowerIdsInACone;
554  std::set<DetId> crossedCaloTowerIds;
555  std::set<DetId> caloTowerIdsInBox;
556  caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInBigRegion, hcalTrajectory, dR);
557 // get DetId of the most energetic tower in that region
558  crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
559 // get DetIds of the towers surrounding the most energetic one
560  caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
561 
562  // add CaloTowers
563  for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
564  {
565  DetId id(*itr);
566  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
567  if(tower != (*caloTowers).end())
568  info.crossedTowers.push_back(*tower);
569  else
570  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
571  }
572 
573  for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
574  {
575  DetId id(*itr);
576  CaloTowerCollection::const_iterator tower = (*caloTowers).find(id);
577  if(tower != (*caloTowers).end())
578  info.coneTowers.push_back(*tower);
579  else
580  LogTrace("HTrackAssociator::fillEcal") << "CaloTower is not found for DetId: " << id.rawId() << "\n";
581  }
582 
583 }
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:74
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:480
HCaloDetIdAssociator caloDetIdAssociator_
#define LogTrace(id)
Definition: DetId.h:18
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 173 of file TrackAssociator.cc.

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

177 {
178  HAssociatorParameters parameters;
179  parameters.useHcal = false;
180  parameters.dREcal = dR;
181  HTrackDetMatchInfo info = associate(iEvent, iSetup, trackOrigin, parameters );
182  if(dR>0)
183  return info.ecalConeEnergyFromRecHits();
184  else
185  return info.ecalEnergyFromRecHits();
186 }
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 606 of file TrackAssociator.cc.

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

608 {
610  iSetup.get<IdealMagneticFieldRecord>().get(bField);
611 
612  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
613 
614  GlobalPoint point( track.vertex().x(), track.vertex().y(), track.vertex().z() );
615 
616  GlobalTrajectoryParameters tPars(point, vector, track.charge(), &*bField);
617 
618  // FIX THIS !!!
619  // need to convert from perigee to global or helix (curvilinear) frame
620  // for now just an arbitrary matrix.
621  AlgebraicSymMatrix66 covT= AlgebraicMatrixID(); covT *= 1e-6; // initialize to sigma=1e-3
622  CartesianTrajectoryError tCov(covT);
623 
624  return FreeTrajectoryState(tPars, tCov);
625 }
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:714
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:738
T get() const
Definition: EventSetup.h:71
int charge() const
track electric charge
Definition: TrackBase.h:606
*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 586 of file TrackAssociator.cc.

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

589 {
591  iSetup.get<IdealMagneticFieldRecord>().get(bField);
592 
593  GlobalVector vector( track.momentum().x(), track.momentum().y(), track.momentum().z() );
594  // convert mm to cm
595  GlobalPoint point( vertex.position().x()*.1, vertex.position().y()*.1, vertex.position().z()*.1 );
596  int charge = track.type( )> 0 ? -1 : 1;
597  GlobalTrajectoryParameters tPars(point, vector, charge, &*bField);
598 
599  AlgebraicSymMatrix66 covT= AlgebraicMatrixID(); covT *= 1e-6; // initialize to sigma=1e-3
600  CartesianTrajectoryError tCov(covT);
601 
602  return FreeTrajectoryState(tPars, tCov);
603 }
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
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:71
*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 206 of file TrackAssociator.cc.

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

210 {
211  HAssociatorParameters parameters;
212  parameters.useEcal = false;
213  parameters.dRHcal = dR;
214  HTrackDetMatchInfo info( associate(iEvent, iSetup, trackOrigin, parameters ));
215  if (dR>0)
216  return info.hcalConeEnergyFromRecHits();
217  else
218  return info.hcalEnergyFromRecHits();
219 }
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 173 of file TrackAssociator.h.

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

174  {
175  return math::XYZPoint(point.x(),point.y(),point.z());
176  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:62
math::XYZPoint HTrackAssociator::getPoint ( const LocalPoint point)
inlineprivate

Definition at line 178 of file TrackAssociator.h.

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

179  {
180  return math::XYZPoint(point.x(),point.y(),point.z());
181  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:62
math::XYZVector HTrackAssociator::getVector ( const GlobalVector vec)
inlineprivate

Definition at line 183 of file TrackAssociator.h.

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

184  {
185  return math::XYZVector(vec.x(),vec.y(),vec.z());
186  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T x() const
Definition: PV3DBase.h:62
math::XYZVector HTrackAssociator::getVector ( const LocalVector vec)
inlineprivate

Definition at line 188 of file TrackAssociator.h.

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

189  {
190  return math::XYZVector(vec.x(),vec.y(),vec.z());
191  }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T x() const
Definition: PV3DBase.h:62
void HTrackAssociator::init ( const edm::EventSetup iSetup)
private

Definition at line 113 of file TrackAssociator.cc.

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

114 {
115  // access the calorimeter geometry
116  iSetup.get<CaloGeometryRecord>().get(theCaloGeometry_);
117  if (!theCaloGeometry_.isValid())
118  throw cms::Exception("FatalError") << "Unable to find IdealGeometryRecord in event!\n";
119 
120  if (useDefaultPropagator_ && ! defProp_ ) {
121  // setup propagator
123  iSetup.get<IdealMagneticFieldRecord>().get(bField);
124 
126  prop->setMaterialMode(false);
127  prop->applyRadX0Correction(true);
128  // prop->setDebug(true); // tmp
129  defProp_ = prop;
131  }
132 
133 
134 }
edm::ESHandle< CaloGeometry > theCaloGeometry_
Propagator * defProp_
void setPropagator(Propagator *)
use a user configured propagator
void applyRadX0Correction(bool applyRadX0Correction)
T get() const
Definition: EventSetup.h:71
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 97 of file TrackAssociator.cc.

98 {
99  ivProp_ = ptr;
103 }
Propagator * ivProp_
HEcalDetIdAssociator ecalDetIdAssociator_
HCaloDetIdAssociator caloDetIdAssociator_
virtual void setPropagator(Propagator *ptr)
HHcalDetIdAssociator hcalDetIdAssociator_
void HTrackAssociator::useDefaultPropagator ( )

use the default propagator

Definition at line 106 of file TrackAssociator.cc.

107 {
108  useDefaultPropagator_ = true;
109 }

Member Data Documentation

HCaloDetIdAssociator HTrackAssociator::caloDetIdAssociator_
private

Definition at line 201 of file TrackAssociator.h.

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

CaloTowers.

Definition at line 212 of file TrackAssociator.h.

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

Definition at line 197 of file TrackAssociator.h.

int HTrackAssociator::debug_
private

Definition at line 196 of file TrackAssociator.h.

Propagator* HTrackAssociator::defProp_
private

Definition at line 194 of file TrackAssociator.h.

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

Labels of the detector EDProducts (empty by default) ECAL

Definition at line 207 of file TrackAssociator.h.

HEcalDetIdAssociator HTrackAssociator::ecalDetIdAssociator_
private

Definition at line 199 of file TrackAssociator.h.

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

Definition at line 208 of file TrackAssociator.h.

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

HCAL.

Definition at line 210 of file TrackAssociator.h.

HHcalDetIdAssociator HTrackAssociator::hcalDetIdAssociator_
private

Definition at line 200 of file TrackAssociator.h.

Propagator* HTrackAssociator::ivProp_
private

Definition at line 193 of file TrackAssociator.h.

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

Definition at line 203 of file TrackAssociator.h.

bool HTrackAssociator::useDefaultPropagator_
private

Definition at line 195 of file TrackAssociator.h.