56 useDefaultPropagator_ =
false;
61 if (defProp_)
delete defProp_;
69 if (className ==
"EBRecHitCollection")
71 EBRecHitCollectionLabels.clear();
72 EBRecHitCollectionLabels.push_back(moduleLabel);
73 EBRecHitCollectionLabels.push_back(productInstanceLabel);
75 if (className ==
"EERecHitCollection")
77 EERecHitCollectionLabels.clear();
78 EERecHitCollectionLabels.push_back(moduleLabel);
79 EERecHitCollectionLabels.push_back(productInstanceLabel);
81 if (className ==
"HBHERecHitCollection")
83 HBHERecHitCollectionLabels.clear();
84 HBHERecHitCollectionLabels.push_back(moduleLabel);
85 HBHERecHitCollectionLabels.push_back(productInstanceLabel);
87 if (className ==
"CaloTowerCollection")
89 CaloTowerCollectionLabels.clear();
90 CaloTowerCollectionLabels.push_back(moduleLabel);
91 CaloTowerCollectionLabels.push_back(productInstanceLabel);
100 caloDetIdAssociator_.setPropagator(ivProp_);
101 ecalDetIdAssociator_.setPropagator(ivProp_);
102 hcalDetIdAssociator_.setPropagator(ivProp_);
108 useDefaultPropagator_ =
true;
117 if (!theCaloGeometry_.isValid())
118 throw cms::Exception(
"FatalError") <<
"Unable to find IdealGeometryRecord in event!\n";
120 if (useDefaultPropagator_ && ! defProp_ ) {
130 setPropagator(defProp_);
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);
229 ecalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
232 std::vector<GlobalPoint> ecalPoints;
237 std::vector<GlobalPoint> ecalTrajectory = ecalDetIdAssociator_.getTrajectory(trajectoryPoint, ecalPoints);
240 if(ecalTrajectory.empty()) {
241 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to ECAL; moving on\n";
256 iEvent.
getByLabel (EBRecHitCollectionLabels[0], EBRecHitCollectionLabels[1], EBRecHits);
258 if (EERecHitCollectionLabels[1]!=EBRecHitCollectionLabels[1]) iEvent.
getByLabel (EERecHitCollectionLabels[0], EERecHitCollectionLabels[1], EERecHits);
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);
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())
271 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
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()) {
279 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
281 if (EERecHitCollectionLabels[1]==EBRecHitCollectionLabels[1])
return;
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())
287 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
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()) {
295 LogTrace(
"HTrackAssociator::fillEcal") <<
"EcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
308 caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
311 std::vector<GlobalPoint> hcalPoints;
319 std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
322 if(hcalTrajectory.empty()) {
323 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to ECAL; moving on\n";
326 std::cout<<
" HTrackAssociator::fillCaloTowers::Failed to propagate a track to ECAL "<<std::endl;
334 if(hcalTrajectory.size()<4) {
335 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to HCAL; moving on\n";
346 if (CaloTowerCollectionLabels.empty())
347 throw cms::Exception(
"FatalError") <<
"Module lable is not set for CaloTowers.\n";
349 iEvent.
getByLabel (CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
350 if (!caloTowers.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find CaloTowers in event!\n";
354 std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
356 std::set<DetId> caloTowerIdsInACone;
357 std::set<DetId> crossedCaloTowerIds;
358 std::set<DetId> caloTowerIdsInBox;
359 caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInRegion, hcalTrajectory, dR);
361 crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
363 caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
383 for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
387 if(tower != (*caloTowers).end())
390 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
393 for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
397 if(tower != (*caloTowers).end()) {
401 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
404 for(std::set<DetId>::const_iterator itr=caloTowerIdsInBox.begin(); itr!=caloTowerIdsInBox.end();itr++)
408 if(tower != (*caloTowers).end()) {
412 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
415 for(std::set<DetId>::const_iterator itr=caloTowerIdsInRegion.begin(); itr!=caloTowerIdsInRegion.end();itr++)
419 if(tower != (*caloTowers).end()) {
423 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
435 hcalDetIdAssociator_.setGeometry(&*theCaloGeometry_);
438 std::vector<GlobalPoint> hcalPoints;
443 std::vector<GlobalPoint> hcalTrajectory = hcalDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
446 if(hcalTrajectory.empty()) {
447 LogTrace(
"HTrackAssociator::fillHcal") <<
"Failed to propagate a track to HCAL; moving on\n";
461 iEvent.
getByLabel (HBHERecHitCollectionLabels[0], HBHERecHitCollectionLabels[1], HBHERecHits);
462 if (!HBHERecHits.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find HBHERecHitCollection in event!\n";
466 std::set<DetId> hcalIdsInRegion = hcalDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
468 std::set<DetId> hcalIdsInACone;
469 std::set<DetId> crossedHcalIds;
470 std::set<DetId> hcalIdsInBox;
471 hcalIdsInACone = hcalDetIdAssociator_.getDetIdsInACone(hcalIdsInRegion, hcalTrajectory, dR);
473 crossedHcalIds = hcalDetIdAssociator_.getMaxEDetId(hcalIdsInRegion, HBHERecHits);
475 hcalIdsInBox = hcalDetIdAssociator_.getDetIdsInACone(crossedHcalIds, hcalTrajectory, -1.);
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())
483 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
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())
490 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
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())
497 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
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())
504 LogTrace(
"HTrackAssociator::fillHcal") <<
"HcalRecHit is not found for DetId: " << itr->rawId() <<
"\n";
517 caloDetIdAssociator_.setGeometry(&*theCaloGeometry_);
520 std::vector<GlobalPoint> hcalPoints;
525 std::vector<GlobalPoint> hcalTrajectory = caloDetIdAssociator_.getTrajectory(trajectoryPoint, hcalPoints);
528 if(hcalTrajectory.empty()) {
529 LogTrace(
"HTrackAssociator::fillEcal") <<
"Failed to propagate a track to HCAL; moving on\n";
531 std::cout<<
" HTrackAssociator::fillCaloTowers::Failed to propagate a track to HCAL "<<std::endl;
542 if (CaloTowerCollectionLabels.empty())
543 throw cms::Exception(
"FatalError") <<
"Module lable is not set for CaloTowers.\n";
545 iEvent.
getByLabel (CaloTowerCollectionLabels[0], CaloTowerCollectionLabels[1], caloTowers);
546 if (!caloTowers.
isValid())
throw cms::Exception(
"FatalError") <<
"Unable to find CaloTowers in event!\n";
550 std::set<DetId> caloTowerIdsInBigRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR+1);
551 std::set<DetId> caloTowerIdsInRegion = caloDetIdAssociator_.getDetIdsCloseToAPoint(hcalTrajectory[0],idR);
553 std::set<DetId> caloTowerIdsInACone;
554 std::set<DetId> crossedCaloTowerIds;
555 std::set<DetId> caloTowerIdsInBox;
556 caloTowerIdsInACone = caloDetIdAssociator_.getDetIdsInACone(caloTowerIdsInBigRegion, hcalTrajectory, dR);
558 crossedCaloTowerIds = caloDetIdAssociator_.getMaxEDetId(caloTowerIdsInRegion, caloTowers);
560 caloTowerIdsInBox = caloDetIdAssociator_.getDetIdsInACone(crossedCaloTowerIds, hcalTrajectory, -1.);
563 for(std::set<DetId>::const_iterator itr=crossedCaloTowerIds.begin(); itr!=crossedCaloTowerIds.end();itr++)
567 if(tower != (*caloTowers).end())
570 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
573 for(std::set<DetId>::const_iterator itr=caloTowerIdsInACone.begin(); itr!=caloTowerIdsInACone.end();itr++)
577 if(tower != (*caloTowers).end())
580 LogTrace(
"HTrackAssociator::fillEcal") <<
"CaloTower is not found for DetId: " <<
id.rawId() <<
"\n";
596 int charge = track.
type( )> 0 ? -1 : 1;
std::vector< CaloTower > crossedTowers
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
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)
const Vector & momentum() const
track momentum vector
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
std::vector< EcalRecHit > coneEcalRecHits
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
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
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)