60 useDefaultPropagator_ =
false;
65 if (defProp_)
delete defProp_;
70 const std::string moduleLabel,
71 const std::string productInstanceLabel)
73 if (className ==
"EBRecHitCollection")
75 EBRecHitCollectionLabels.clear();
76 EBRecHitCollectionLabels.push_back(moduleLabel);
77 EBRecHitCollectionLabels.push_back(productInstanceLabel);
79 if (className ==
"EERecHitCollection")
81 EERecHitCollectionLabels.clear();
82 EERecHitCollectionLabels.push_back(moduleLabel);
83 EERecHitCollectionLabels.push_back(productInstanceLabel);
85 if (className ==
"HBHERecHitCollection")
87 HBHERecHitCollectionLabels.clear();
88 HBHERecHitCollectionLabels.push_back(moduleLabel);
89 HBHERecHitCollectionLabels.push_back(productInstanceLabel);
91 if (className ==
"CaloTowerCollection")
93 CaloTowerCollectionLabels.clear();
94 CaloTowerCollectionLabels.push_back(moduleLabel);
95 CaloTowerCollectionLabels.push_back(productInstanceLabel);
104 caloDetIdAssociator_.setPropagator(ivProp_);
105 ecalDetIdAssociator_.setPropagator(ivProp_);
106 hcalDetIdAssociator_.setPropagator(ivProp_);
112 useDefaultPropagator_ =
true;
121 if (!theCaloGeometry_.isValid())
122 throw cms::Exception(
"FatalError") <<
"Unable to find IdealGeometryRecord in event!\n";
124 if (useDefaultPropagator_ && ! defProp_ ) {
134 setPropagator(defProp_);
154 if (parameters.
useEcal) fillEcal( iEvent, iSetup, info, currentPosition,parameters.
idREcal, parameters.
dREcal);
155 if (parameters.
useHcal) fillHcal( iEvent, iSetup, info, currentPosition,parameters.
idRHcal,parameters.
dRHcal);
156 if (parameters.
useCalo) fillCaloTowers( iEvent, iSetup, info, currentPosition,parameters.
idRCalo,parameters.
dRCalo);
235 timers.
push(
"HTrackAssociator::fillEcal");
237 ecalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
239 timers.
push(
"HTrackAssociator::fillEcal::propagation");
241 std::vector<GlobalPoint> ecalPoints;
246 std::vector<GlobalPoint> ecalTrajectory = ecalDetIdAssociator_.getTrajectory(trajectoryPoint, ecalPoints);
249 if(ecalTrajectory.empty()) {
250 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to ECAL; moving on\n";
260 timers.
pop_and_push(
"HTrackAssociator::fillEcal::access::EcalBarrel");
266 iEvent.
getByLabel (EBRecHitCollectionLabels[0], EBRecHitCollectionLabels[1], EBRecHits);
268 if (EERecHitCollectionLabels[1]!=EBRecHitCollectionLabels[1]) iEvent.
getByLabel (EERecHitCollectionLabels[0], EERecHitCollectionLabels[1], EERecHits);
271 timers.
pop_and_push(
"HTrackAssociator::fillEcal::matching");
272 std::set<DetId> ecalIdsInRegion = ecalDetIdAssociator_.getDetIdsCloseToAPoint(ecalTrajectory[0],idR);
273 std::set<DetId> ecalIdsInACone = ecalDetIdAssociator_.getDetIdsInACone(ecalIdsInRegion, ecalTrajectory, dR);
274 std::set<DetId> crossedEcalIds = ecalDetIdAssociator_.getCrossedDetIds(ecalIdsInRegion, ecalTrajectory);
277 timers.
pop_and_push(
"HTrackAssociator::fillEcal::addEcalRecHits");
278 for(std::set<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++) {
279 std::vector<EcalRecHit>::const_iterator
hit = (*EBRecHits).find(*itr);
280 if(hit != (*EBRecHits).end())
283 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
285 for(std::set<DetId>::const_iterator itr=ecalIdsInACone.begin(); itr!=ecalIdsInACone.end();itr++) {
286 std::vector<EcalRecHit>::const_iterator
hit = (*EBRecHits).find(*itr);
287 if(hit != (*EBRecHits).end()) {
291 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
293 if (EERecHitCollectionLabels[1]==EBRecHitCollectionLabels[1])
return;
294 for(std::set<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++) {
295 std::vector<EcalRecHit>::const_iterator
hit = (*EERecHits).find(*itr);
296 if(hit != (*EERecHits).end())
299 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
301 for(std::set<DetId>::const_iterator itr=ecalIdsInACone.begin(); itr!=ecalIdsInACone.end();itr++) {
302 std::vector<EcalRecHit>::const_iterator
hit = (*EERecHits).find(*itr);
303 if(hit != (*EERecHits).end()) {
307 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
321 timers.
push(
"HTrackAssociator::fillCaloTowers");
323 caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
326 timers.
push(
"HTrackAssociator::fillCaloTowers::propagation");
327 std::vector<GlobalPoint> hcalPoints;
335 std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
338 if(hcalTrajectory.empty()) {
339 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to ECAL; moving on\n";
342 std::cout<<
" HTrackAssociator::fillCaloTowers::Failed to propagate a track to ECAL "<<std::endl;
350 if(hcalTrajectory.size()<4) {
351 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to HCAL; moving on\n";
360 timers.
pop_and_push(
"HTrackAssociator::fillCaloTowers::access::CaloTowers");
363 if (CaloTowerCollectionLabels.empty())
364 throw cms::Exception(
"FatalError") <<
"Module lable is not set for CaloTowers.\n";
366 iEvent.
getByLabel (CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
367 if (!caloTowers.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find CaloTowers in event!\n";
369 timers.
push(
"HTrackAssociator::fillCaloTowers::matching");
373 std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
375 std::set<DetId> caloTowerIdsInACone;
376 std::set<DetId> crossedCaloTowerIds;
377 std::set<DetId> caloTowerIdsInBox;
378 caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInRegion, hcalTrajectory, dR);
380 crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
382 caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
402 timers.
push(
"HTrackAssociator::fillCaloTowers::addCaloTowers");
403 for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
407 if(tower != (*caloTowers).end())
410 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
413 for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
417 if(tower != (*caloTowers).end()) {
421 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
424 for(std::set<DetId>::const_iterator itr=caloTowerIdsInBox.begin(); itr!=caloTowerIdsInBox.end();itr++)
428 if(tower != (*caloTowers).end()) {
432 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
435 for(std::set<DetId>::const_iterator itr=caloTowerIdsInRegion.begin(); itr!=caloTowerIdsInRegion.end();itr++)
439 if(tower != (*caloTowers).end()) {
443 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
456 timers.
push(
"HTrackAssociator::fillHcal");
458 hcalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
461 timers.
push(
"HTrackAssociator::fillHcal::propagation");
462 std::vector<GlobalPoint> hcalPoints;
467 std::vector<GlobalPoint> hcalTrajectory = hcalDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
470 if(hcalTrajectory.empty()) {
471 LogTrace(
"HTrackAssociator::fillHcal") <<
"Failed to propagate a track to HCAL; moving on\n";
480 timers.
pop_and_push(
"HTrackAssociator::fillHcal::access::Hcal");
486 iEvent.
getByLabel (HBHERecHitCollectionLabels[0], HBHERecHitCollectionLabels[1], HBHERecHits);
487 if (!HBHERecHits.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find HBHERecHitCollection in event!\n";
489 timers.
pop_and_push(
"HTrackAssociator::fillHcal::matching");
493 std::set<DetId> hcalIdsInRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
495 std::set<DetId> hcalIdsInACone;
496 std::set<DetId> crossedHcalIds;
497 std::set<DetId> hcalIdsInBox;
498 hcalIdsInACone = hcalDetIdAssociator_.getDetIdsInACone(hcalIdsInRegion, hcalTrajectory, dR);
500 crossedHcalIds = hcalDetIdAssociator_.getMaxEDetId(hcalIdsInRegion, HBHERecHits);
502 hcalIdsInBox = hcalDetIdAssociator_.getDetIdsInACone(crossedHcalIds, hcalTrajectory, -1.);
505 timers.
pop_and_push(
"HTrackAssociator::fillHcal::addHcalRecHits");
506 for(std::set<DetId>::const_iterator itr=crossedHcalIds.begin(); itr!=crossedHcalIds.end();itr++) {
507 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
508 if(hit != (*HBHERecHits).end())
511 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
513 for(std::set<DetId>::const_iterator itr=hcalIdsInACone.begin(); itr!=hcalIdsInACone.end();itr++) {
514 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
515 if(hit != (*HBHERecHits).end())
518 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
520 for(std::set<DetId>::const_iterator itr=hcalIdsInBox.begin(); itr!=hcalIdsInBox.end();itr++) {
521 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
522 if(hit != (*HBHERecHits).end())
525 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
527 for(std::set<DetId>::const_iterator itr=hcalIdsInRegion.begin(); itr!=hcalIdsInRegion.end();itr++) {
528 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
529 if(hit != (*HBHERecHits).end())
532 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
546 timers.
push(
"HTrackAssociator::fillCaloTowers");
548 caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
551 timers.
push(
"HTrackAssociator::fillCaloTowers::propagation");
552 std::vector<GlobalPoint> hcalPoints;
557 std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
560 if(hcalTrajectory.empty()) {
561 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to HCAL; moving on\n";
563 std::cout<<
" HTrackAssociator::fillCaloTowers::Failed to propagate a track to HCAL "<<std::endl;
572 timers.
pop_and_push(
"HTrackAssociator::fillCaloTowers::access::CaloTowers");
575 if (CaloTowerCollectionLabels.empty())
576 throw cms::Exception(
"FatalError") <<
"Module lable is not set for CaloTowers.\n";
578 iEvent.
getByLabel (CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
579 if (!caloTowers.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find CaloTowers in event!\n";
581 timers.
push(
"HTrackAssociator::fillCaloTowers::matching");
584 std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
585 std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
587 std::set<DetId> caloTowerIdsInACone;
588 std::set<DetId> crossedCaloTowerIds;
589 std::set<DetId> caloTowerIdsInBox;
590 caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInBigRegion, hcalTrajectory, dR);
592 crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
594 caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
597 timers.
push(
"HTrackAssociator::fillCaloTowers::addCaloTowers");
598 for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
602 if(tower != (*caloTowers).end())
605 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
608 for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
612 if(tower != (*caloTowers).end())
615 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
std::vector< CaloTower > crossedTowers
const Vector & momentum() const
track momentum vector
FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
double getHcalEnergy(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
std::vector< HBHERecHit > coneHcalRecHits
void push(std::string name)
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
std::vector< EcalRecHit > crossedEcalRecHits
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Global3DPoint GlobalPoint
std::vector< CaloTower >::const_iterator const_iterator
std::vector< CaloTower > boxTowers
double getEcalEnergy(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
std::vector< HBHERecHit > regionHcalRecHits
void setPropagator(Propagator *)
use a user configured propagator
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
void pop_and_push(std::string name)
std::vector< EcalRecHit > coneEcalRecHits
double hcalEnergyFromRecHits()
HCAL energy.
math::XYZPoint trkGlobPosAtHcal
std::vector< HBHERecHit > boxHcalRecHits
tuple SteppingHelixPropagator
void applyRadX0Correction(bool applyRadX0Correction)
void fillEcal(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
std::vector< HBHERecHit > crossedHcalRecHits
void fillHcal(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
double ecalConeEnergyFromRecHits()
const math::XYZTLorentzVectorD & position() const
HTrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const HAssociatorParameters &)
double ecalEnergyFromRecHits()
ECAL energy.
void fillHcalTowers(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void useDefaultPropagator()
use the default propagator
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
std::vector< CaloTower > regionTowers
std::vector< CaloTower > coneTowers
int type() const
particle type (HEP PDT convension)
const math::XYZTLorentzVectorD & momentum() const
particle info...
math::XYZPoint trkGlobPosAtEcal
double hcalConeEnergyFromRecHits()
void fillCaloTowers(const edm::Event &, const edm::EventSetup &, HTrackDetMatchInfo &, const FreeTrajectoryState &, const int, const double)
void init(const edm::EventSetup &)
int charge() const
track electric charge
std::vector< EcalRecHit > associateEcal(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
std::vector< CaloTower > associateHcal(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const double dR=-1)
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
*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
std::string className(const T &t)