59 useDefaultPropagator_ =
false;
64 if (defProp_)
delete defProp_;
72 if (className ==
"EBRecHitCollection")
74 EBRecHitCollectionLabels.clear();
75 EBRecHitCollectionLabels.push_back(moduleLabel);
76 EBRecHitCollectionLabels.push_back(productInstanceLabel);
78 if (className ==
"EERecHitCollection")
80 EERecHitCollectionLabels.clear();
81 EERecHitCollectionLabels.push_back(moduleLabel);
82 EERecHitCollectionLabels.push_back(productInstanceLabel);
84 if (className ==
"HBHERecHitCollection")
86 HBHERecHitCollectionLabels.clear();
87 HBHERecHitCollectionLabels.push_back(moduleLabel);
88 HBHERecHitCollectionLabels.push_back(productInstanceLabel);
90 if (className ==
"CaloTowerCollection")
92 CaloTowerCollectionLabels.clear();
93 CaloTowerCollectionLabels.push_back(moduleLabel);
94 CaloTowerCollectionLabels.push_back(productInstanceLabel);
103 caloDetIdAssociator_.setPropagator(ivProp_);
104 ecalDetIdAssociator_.setPropagator(ivProp_);
105 hcalDetIdAssociator_.setPropagator(ivProp_);
111 useDefaultPropagator_ =
true;
120 if (!theCaloGeometry_.isValid())
121 throw cms::Exception(
"FatalError") <<
"Unable to find IdealGeometryRecord in event!\n";
123 if (useDefaultPropagator_ && ! defProp_ ) {
133 setPropagator(defProp_);
153 if (parameters.
useEcal) fillEcal( iEvent, iSetup, info, currentPosition,parameters.
idREcal, parameters.
dREcal);
154 if (parameters.
useHcal) fillHcal( iEvent, iSetup, info, currentPosition,parameters.
idRHcal,parameters.
dRHcal);
155 if (parameters.
useCalo) fillCaloTowers( iEvent, iSetup, info, currentPosition,parameters.
idRCalo,parameters.
dRCalo);
234 timers.
push(
"HTrackAssociator::fillEcal");
236 ecalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
238 timers.
push(
"HTrackAssociator::fillEcal::propagation");
240 std::vector<GlobalPoint> ecalPoints;
245 std::vector<GlobalPoint> ecalTrajectory = ecalDetIdAssociator_.getTrajectory(trajectoryPoint, ecalPoints);
248 if(ecalTrajectory.empty()) {
249 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to ECAL; moving on\n";
259 timers.
pop_and_push(
"HTrackAssociator::fillEcal::access::EcalBarrel");
265 iEvent.
getByLabel (EBRecHitCollectionLabels[0], EBRecHitCollectionLabels[1], EBRecHits);
267 if (EERecHitCollectionLabels[1]!=EBRecHitCollectionLabels[1]) iEvent.
getByLabel (EERecHitCollectionLabels[0], EERecHitCollectionLabels[1], EERecHits);
270 timers.
pop_and_push(
"HTrackAssociator::fillEcal::matching");
271 std::set<DetId> ecalIdsInRegion = ecalDetIdAssociator_.getDetIdsCloseToAPoint(ecalTrajectory[0],idR);
272 std::set<DetId> ecalIdsInACone = ecalDetIdAssociator_.getDetIdsInACone(ecalIdsInRegion, ecalTrajectory, dR);
273 std::set<DetId> crossedEcalIds = ecalDetIdAssociator_.getCrossedDetIds(ecalIdsInRegion, ecalTrajectory);
276 timers.
pop_and_push(
"HTrackAssociator::fillEcal::addEcalRecHits");
277 for(std::set<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++) {
278 std::vector<EcalRecHit>::const_iterator
hit = (*EBRecHits).find(*itr);
279 if(hit != (*EBRecHits).end())
282 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
284 for(std::set<DetId>::const_iterator itr=ecalIdsInACone.begin(); itr!=ecalIdsInACone.end();itr++) {
285 std::vector<EcalRecHit>::const_iterator
hit = (*EBRecHits).find(*itr);
286 if(hit != (*EBRecHits).end()) {
290 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
292 if (EERecHitCollectionLabels[1]==EBRecHitCollectionLabels[1])
return;
293 for(std::set<DetId>::const_iterator itr=crossedEcalIds.begin(); itr!=crossedEcalIds.end();itr++) {
294 std::vector<EcalRecHit>::const_iterator
hit = (*EERecHits).find(*itr);
295 if(hit != (*EERecHits).end())
298 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
300 for(std::set<DetId>::const_iterator itr=ecalIdsInACone.begin(); itr!=ecalIdsInACone.end();itr++) {
301 std::vector<EcalRecHit>::const_iterator
hit = (*EERecHits).find(*itr);
302 if(hit != (*EERecHits).end()) {
306 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
320 timers.
push(
"HTrackAssociator::fillCaloTowers");
322 caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
325 timers.
push(
"HTrackAssociator::fillCaloTowers::propagation");
326 std::vector<GlobalPoint> hcalPoints;
334 std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
337 if(hcalTrajectory.empty()) {
338 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to ECAL; moving on\n";
341 std::cout<<
" HTrackAssociator::fillCaloTowers::Failed to propagate a track to ECAL "<<std::endl;
349 if(hcalTrajectory.size()<4) {
350 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to HCAL; moving on\n";
359 timers.
pop_and_push(
"HTrackAssociator::fillCaloTowers::access::CaloTowers");
362 if (CaloTowerCollectionLabels.empty())
363 throw cms::Exception(
"FatalError") <<
"Module lable is not set for CaloTowers.\n";
365 iEvent.
getByLabel (CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
366 if (!caloTowers.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find CaloTowers in event!\n";
368 timers.
push(
"HTrackAssociator::fillCaloTowers::matching");
372 std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
374 std::set<DetId> caloTowerIdsInACone;
375 std::set<DetId> crossedCaloTowerIds;
376 std::set<DetId> caloTowerIdsInBox;
377 caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInRegion, hcalTrajectory, dR);
379 crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
381 caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
401 timers.
push(
"HTrackAssociator::fillCaloTowers::addCaloTowers");
402 for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
406 if(tower != (*caloTowers).end())
409 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
412 for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
416 if(tower != (*caloTowers).end()) {
420 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
423 for(std::set<DetId>::const_iterator itr=caloTowerIdsInBox.begin(); itr!=caloTowerIdsInBox.end();itr++)
427 if(tower != (*caloTowers).end()) {
431 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
434 for(std::set<DetId>::const_iterator itr=caloTowerIdsInRegion.begin(); itr!=caloTowerIdsInRegion.end();itr++)
438 if(tower != (*caloTowers).end()) {
442 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
455 timers.
push(
"HTrackAssociator::fillHcal");
457 hcalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
460 timers.
push(
"HTrackAssociator::fillHcal::propagation");
461 std::vector<GlobalPoint> hcalPoints;
466 std::vector<GlobalPoint> hcalTrajectory = hcalDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
469 if(hcalTrajectory.empty()) {
470 LogTrace(
"HTrackAssociator::fillHcal") <<
"Failed to propagate a track to HCAL; moving on\n";
479 timers.
pop_and_push(
"HTrackAssociator::fillHcal::access::Hcal");
485 iEvent.
getByLabel (HBHERecHitCollectionLabels[0], HBHERecHitCollectionLabels[1], HBHERecHits);
486 if (!HBHERecHits.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find HBHERecHitCollection in event!\n";
488 timers.
pop_and_push(
"HTrackAssociator::fillHcal::matching");
492 std::set<DetId> hcalIdsInRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
494 std::set<DetId> hcalIdsInACone;
495 std::set<DetId> crossedHcalIds;
496 std::set<DetId> hcalIdsInBox;
497 hcalIdsInACone = hcalDetIdAssociator_.getDetIdsInACone(hcalIdsInRegion, hcalTrajectory, dR);
499 crossedHcalIds = hcalDetIdAssociator_.getMaxEDetId(hcalIdsInRegion, HBHERecHits);
501 hcalIdsInBox = hcalDetIdAssociator_.getDetIdsInACone(crossedHcalIds, hcalTrajectory, -1.);
504 timers.
pop_and_push(
"HTrackAssociator::fillHcal::addHcalRecHits");
505 for(std::set<DetId>::const_iterator itr=crossedHcalIds.begin(); itr!=crossedHcalIds.end();itr++) {
506 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
507 if(hit != (*HBHERecHits).end())
510 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
512 for(std::set<DetId>::const_iterator itr=hcalIdsInACone.begin(); itr!=hcalIdsInACone.end();itr++) {
513 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
514 if(hit != (*HBHERecHits).end())
517 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
519 for(std::set<DetId>::const_iterator itr=hcalIdsInBox.begin(); itr!=hcalIdsInBox.end();itr++) {
520 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
521 if(hit != (*HBHERecHits).end())
524 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
526 for(std::set<DetId>::const_iterator itr=hcalIdsInRegion.begin(); itr!=hcalIdsInRegion.end();itr++) {
527 std::vector<HBHERecHit>::const_iterator
hit = (*HBHERecHits).find(*itr);
528 if(hit != (*HBHERecHits).end())
531 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
545 timers.
push(
"HTrackAssociator::fillCaloTowers");
547 caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
550 timers.
push(
"HTrackAssociator::fillCaloTowers::propagation");
551 std::vector<GlobalPoint> hcalPoints;
556 std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
559 if(hcalTrajectory.empty()) {
560 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to HCAL; moving on\n";
562 std::cout<<
" HTrackAssociator::fillCaloTowers::Failed to propagate a track to HCAL "<<std::endl;
571 timers.
pop_and_push(
"HTrackAssociator::fillCaloTowers::access::CaloTowers");
574 if (CaloTowerCollectionLabels.empty())
575 throw cms::Exception(
"FatalError") <<
"Module lable is not set for CaloTowers.\n";
577 iEvent.
getByLabel (CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
578 if (!caloTowers.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find CaloTowers in event!\n";
580 timers.
push(
"HTrackAssociator::fillCaloTowers::matching");
583 std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
584 std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
586 std::set<DetId> caloTowerIdsInACone;
587 std::set<DetId> crossedCaloTowerIds;
588 std::set<DetId> caloTowerIdsInBox;
589 caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInBigRegion, hcalTrajectory, dR);
591 crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
593 caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
596 timers.
push(
"HTrackAssociator::fillCaloTowers::addCaloTowers");
597 for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
601 if(tower != (*caloTowers).end())
604 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
607 for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
611 if(tower != (*caloTowers).end())
614 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
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)