77 virtual void endJob()
override ;
117 float genPt[500], genPhi[500], genEta[500];
118 float isoPt[500], isoPhi[500], isoEta[500];
119 float pixPt[500], pixPhi[500], pixEta[500];
184 float numVH,
numVS, numValidTrkHits, numValidTrkStrips;
216 tok_track_ = consumes<reco::IsolatedPixelTrackCandidateCollection>(iConfig.
getParameter<
edm::InputTag>(
"HcalIsolTrackInput"));
219 associationConeSize_=iConfig.
getParameter<
double>(
"associationConeSize");
226 calibrationConeSize_=iConfig.
getParameter<
double>(
"calibrationConeSize");
228 MinNTrackHitsBarrel = iConfig.
getParameter<
int>(
"MinNTrackHitsBarrel");
229 MinNTECHitsEndcap = iConfig.
getParameter<
int>(
"MinNTECHitsEndcap");
230 energyECALmip = iConfig.
getParameter<
double>(
"energyECALmip");
231 energyMinIso = iConfig.
getParameter<
double>(
"energyMinIso");
232 energyMaxIso = iConfig.
getParameter<
double>(
"energyMaxIso");
237 parameters_.loadParameters( parameters, iC );
238 trackAssociator_.useDefaultPropagator();
264 respRecalib = recalibCorrs.
product();
266 LogInfo(
"CalibConstants")<<
" Loaded: OK ";
269 LogWarning(
"CalibConstants")<<
" Not Found!! ";
301 parameters_.useEcal =
true;
302 parameters_.useHcal =
true;
303 parameters_.useCalo =
false;
304 parameters_.useMuon =
false;
310 if (isoPixelTracks->size()==0)
return;
313 for (reco::TrackCollection::const_iterator trit=isoProdTracks->begin(); trit!=isoProdTracks->end(); trit++)
316 reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched=isoPixelTracks->begin();
321 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin(); it!=isoPixelTracks->end(); it++)
325 if (
abs((trit->pt() - it->pt())/it->pt()) < 0.005 &&
abs(trit->eta() - it->eta()) < 0.01)
334 if (!matched)
continue;
335 if(isoMatched->maxPtPxl() > maxPNear)
continue;
337 ptNear = isoMatched->maxPtPxl();
342 if (trit->hitPattern().numberOfValidHits()<MinNTrackHitsBarrel)
continue;
343 if (fabs(trit->eta())>1.47&&trit->hitPattern().numberOfValidStripTECHits()<MinNTECHitsEndcap)
continue;
348 numVH = trit->hitPattern().numberOfValidHits();
349 numVS = trit->hitPattern().numberOfValidStripTECHits();
353 trackE =
sqrt(trit->px()*trit->px()+trit->py()*trit->py()+trit->pz()*trit->pz()+0.14*0.14);
358 emEnergy = isoMatched->energyIn();
363 TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup,trackAssociator_.getFreeTrajectoryState(iSetup, *trit), parameters_);
379 if (xTrkEcal==0 && yTrkEcal==0&& zTrkEcal==0) {
cout<<
"zero point at Ecal"<<endl;
continue;}
380 if (xTrkHcal==0 && yTrkHcal==0&& zTrkHcal==0) {
cout<<
"zero point at Hcal"<<endl;
continue;}
390 GlobalPoint gPointEcal(xTrkEcal,yTrkEcal,zTrkEcal);
391 GlobalPoint gPointHcal(xTrkHcal,yTrkHcal,zTrkHcal);
395 const HcalDetId tempId = gHcal->getClosestCell(gPointHcal);
396 ietatrue = tempId.
ieta();
397 iphitrue = tempId.
iphi();
405 std::vector<DetId> usedHits;
422 bool hitIsUsed=
false;
423 for (uint32_t
i=0;
i<usedHits.size();
i++)
425 if (usedHits[
i]==hhit->id()) hitIsUsed=
true;
427 if (hitIsUsed)
continue;
428 usedHits.push_back(hhit->id());
439 int iphihitm = (hhit->id()).iphi();
440 int ietahitm = (hhit->id()).ieta();
441 int depthhit = (hhit->id()).
depth();
442 float enehit = hhit->energy() * recal;
444 if (depthhit!=1)
continue;
457 if(distAtHcal < associationConeSize_)
462 int iphihitm2 = (hhit2->id()).iphi();
463 int ietahitm2 = (hhit2->id()).ieta();
464 int depthhit2 = (hhit2->id()).
depth();
465 float enehit2 = hhit2->energy() * recal;
467 if (iphihitm==iphihitm2 && ietahitm==ietahitm2 && depthhit!=depthhit2) enehit = enehit+enehit2;
479 MaxHit.
ietahitm = (hhit->id()).ieta();
480 MaxHit.
iphihitm = (hhit->id()).iphi();
481 MaxHit.
dr = distAtHcal;
498 Bool_t passCuts = kFALSE;
499 if(trackE > energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. &&
abs(MaxHit.
ietahitm)<29) passCuts = kTRUE;
523 bool hitIsUsed=
false;
524 for (uint32_t
i=0;
i<usedHits.size();
i++)
526 if (usedHits[
i]==hhit->id()) hitIsUsed=
true;
528 if (hitIsUsed)
continue;
529 usedHits.push_back(hhit->id());
532 if(MaxHit.
ietahitm*(hhit->id()).ieta()>0)
534 DIETA = MaxHit.
ietahitm - (hhit->id()).ieta();
536 if(MaxHit.
ietahitm*(hhit->id()).ieta()<0)
538 DIETA = MaxHit.
ietahitm - (hhit->id()).ieta();
539 DIETA = DIETA>0 ? DIETA-1 : DIETA+1;
542 int DIPHI =
abs(MaxHit.
iphihitm - (hhit->id()).iphi());
543 DIPHI = DIPHI>36 ? 72-DIPHI : DIPHI;
555 if(
abs(DIETA)<=numbercell && (
abs(DIPHI)<=numbercell || (
abs(MaxHit.
ietahitm)>=20 &&
abs(DIPHI)<=numbercell+1)) )
557 const GlobalPoint pos2 = geo->getPosition(hhit->detid());
559 if(passCuts && hhit->energy()>0)
565 factor = respRecalib -> getValues(hhit->id())->
getValue();
571 if (hhit->id().ieta() == MaxHit.
ietahitm && hhit->id().iphi() == MaxHit.
iphihitm) CentHitFactor=factor;
573 if (hhit->id().ieta() == MaxHit.
ietahitm && hhit->id().iphi() == MaxHit.
iphihitm) iTime = hhit->time();
575 if(AxB_!=
"3x3" && AxB_!=
"5x5" && AxB_!=
"Cone")
LogWarning(
" AxB ")<<
" Not supported: "<< AxB_;
581 e5x5Before += hhit->energy();
582 e5x5After += hhit->energy()*factor;
589 e3x3Before += hhit->energy();
590 e3x3After += hhit->energy()*factor;
599 if (
abs(MaxHit.
ietahitm)==21 &&
abs((hhit->id()).ieta())<=20 &&
abs(DIPHI)>3)
continue;
601 HTime[numHits]= hhit->time();
604 eClustBefore += hhit->energy();
605 eClustAfter += hhit->energy()*factor;
607 if ((hhit->id().depth() == 1) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29))
609 eBeforeDepth1 += hhit->energy();
610 eAfterDepth1 += hhit->energy()*factor;
612 else if((hhit->id().depth() == 2) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29))
614 eBeforeDepth2 += hhit->energy();
615 eAfterDepth2 += hhit->energy()*factor;
626 if (
abs(MaxHit.
ietahitm)==21 &&
abs((hhit->id()).ieta())<=20 &&
abs(DIPHI)>2)
continue;
628 HTime[numHits]= hhit->time();
631 eClustBefore += hhit->energy();
632 eClustAfter += hhit->energy() * factor;
634 if ((hhit->id().depth() == 1) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29))
636 eBeforeDepth1 += hhit->energy();
637 eAfterDepth1 += hhit->energy() * factor;
639 else if((hhit->id().depth() == 2) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29))
641 eBeforeDepth2 += hhit->energy();
642 eAfterDepth2 += hhit->energy() * factor;
651 HTime[numHits]= hhit->time();
654 eClustBefore += hhit->energy();
655 eClustAfter += hhit->energy() * factor;
657 if ((hhit->id().depth() == 1) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29))
659 eBeforeDepth1 += hhit->energy();
660 eAfterDepth1 += hhit->energy() * factor;
662 else if((hhit->id().depth() == 2) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29))
664 eBeforeDepth2 += hhit->energy();
665 eAfterDepth2 += hhit->energy() * factor;
683 diphi_M_P = diphi_M_P>36 ? 72-diphi_M_P : diphi_M_P;
689 eventNumber = iEvent.
id().
event();
693 eCentHitAfter = MaxHit.
hitenergy*CentHitFactor;
695 numValidTrkHits = numVH;
696 numValidTrkStrips = numVS;
709 iDr =
sqrt(diphi_M_P*diphi_M_P+dieta_M_P*dieta_M_P);
726 if(takeGenTracks_ && iEvent.
id().
event()%10==1)
729 iso = isoProdTracks->size();
730 pix = isoPixelTracks->size();
744 Int_t gencount=0, isocount=0, pixcount=0;
747 genPt[gencount] = gentr->pt();
748 genPhi[gencount] = gentr->phi();
749 genEta[gencount] = gentr->eta();
753 for (reco::TrackCollection::const_iterator isotr=isoProdTracks->begin(); isotr!=isoProdTracks->end(); isotr++)
755 isoPt[isocount] = isotr->pt();
756 isoPhi[isocount] = isotr->phi();
757 isoEta[isocount] = isotr->eta();
761 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator pixtr=isoPixelTracks->begin(); pixtr!=isoPixelTracks->end(); pixtr++)
763 pixPt[pixcount] = pixtr->pt();
764 pixPhi[pixcount] = pixtr->phi();
765 pixEta[pixcount] = pixtr->eta();
798 nTracks = fs->make<TH1F>(
"nTracks",
"general;number of general tracks",11,-0.5,10.5);
801 tTree = fs->make<TTree>(
"tTree",
"Tree for gen info");
803 fTree = fs->make<TTree>(
"fTree",
"Tree for IsoTrack Calibration");
805 fTree->Branch(
"eventNumber", &eventNumber,
"eventNumber/I");
806 fTree->Branch(
"runNumber", &
runNumber,
"runNumber/I");
808 fTree->Branch(
"eClustBefore", &eClustBefore,
"eClustBefore/F");
809 fTree->Branch(
"eClustAfter", &eClustAfter,
"eClustAfter/F");
810 fTree->Branch(
"eTrack", &eTrack,
"eTrack/F");
811 fTree->Branch(
"etaTrack", &etaTrack,
"etaTrack/F");
812 fTree->Branch(
"phiTrack", &phiTrack,
"phiTrack/F");
814 fTree->Branch(
"numHits", &numHits,
"numHits/I");
815 fTree->Branch(
"eECAL", &eECAL,
"eECAL/F");
816 fTree->Branch(
"PtNearBy", &PtNearBy,
"PtNearBy/F");
817 fTree->Branch(
"numValidTrkHits", &numValidTrkHits,
"numValidTrkHits/F");
818 fTree->Branch(
"numValidTrkStrips", &numValidTrkStrips,
"numValidTrkStrips/F");
820 fTree->Branch(
"eBeforeDepth1", &eBeforeDepth1,
"eBeforeDepth1/F");
821 fTree->Branch(
"eBeforeDepth2", &eBeforeDepth2,
"eBeforeDepth2/F");
822 fTree->Branch(
"eAfterDepth1", &eAfterDepth1,
"eAfterDepth1/F");
823 fTree->Branch(
"eAfterDepth2", &eAfterDepth2,
"eAfterDepth2/F");
825 fTree->Branch(
"e3x3Before", &e3x3Before,
"e3x3Before/F");
826 fTree->Branch(
"e3x3After", &e3x3After,
"e3x3After/F");
827 fTree->Branch(
"e5x5Before", &e5x5Before,
"e5x5Before/F");
828 fTree->Branch(
"e5x5After", &e5x5After,
"e5x5After/F");
830 fTree->Branch(
"eCentHitAfter", &eCentHitAfter,
"eCentHitAfter/F");
831 fTree->Branch(
"eCentHitBefore", &eCentHitBefore,
"eCentHitBefore/F");
832 fTree->Branch(
"iEta", &iEta,
"iEta/I");
833 fTree->Branch(
"iPhi", &iPhi,
"iPhi/I");
836 fTree->Branch(
"iEtaTr", &iEtaTr,
"iEtaTr/I");
837 fTree->Branch(
"iPhiTr", &iPhiTr,
"iPhiTr/I");
838 fTree->Branch(
"dietatr", &dietatr,
"dietatr/I");
839 fTree->Branch(
"diphitr", &diphitr,
"diphitr/I");
840 fTree->Branch(
"iDr", &iDr,
"iDr/F");
841 fTree->Branch(
"delR", &delR,
"delR/F");
843 fTree->Branch(
"iTime", &iTime,
"iTime/F");
844 fTree->Branch(
"HTime", HTime,
"HTime[numHits]/F");
846 fTree->Branch(
"xTrkEcal", &xTrkEcal,
"xTrkEcal/F");
847 fTree->Branch(
"yTrkEcal", &yTrkEcal,
"yTrkEcal/F");
848 fTree->Branch(
"zTrkEcal", &zTrkEcal,
"zTrkEcal/F");
849 fTree->Branch(
"xTrkHcal", &xTrkHcal,
"xTrkHcal/F");
850 fTree->Branch(
"yTrkHcal", &yTrkHcal,
"yTrkHcal/F");
851 fTree->Branch(
"zTrkHcal", &zTrkHcal,
"zTrkHcal/F");
854 tTree->Branch(
"gen", &
gen,
"gen/I");
855 tTree->Branch(
"iso", &iso,
"iso/I");
856 tTree->Branch(
"pix", &pix,
"pix/I");
857 tTree->Branch(
"genPt", genPt,
"genPt[gen]/F");
858 tTree->Branch(
"genPhi", genPhi,
"genPhi[gen]/F");
859 tTree->Branch(
"genEta", genEta,
"genEta[gen]/F");
861 tTree->Branch(
"isoPt", isoPt,
"isoPt[iso]/F");
862 tTree->Branch(
"isoPhi", isoPhi,
"isoPhi[iso]/F");
863 tTree->Branch(
"isoEta", isoEta,
"isoEta[iso]/F");
865 tTree->Branch(
"pixPt", pixPt,
"pixPt[pix]/F");
866 tTree->Branch(
"pixPhi", pixPhi,
"pixPhi[pix]/F");
867 tTree->Branch(
"pixEta", pixEta,
"pixEta[pix]/F");
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
const unsigned int nTracks(const reco::Vertex &sv)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
std::vector< HBHERecHit >::const_iterator const_iterator
TrackAssociatorParameters parameters_
math::XYZPoint trkGlobPosAtHcal
edm::EDGetTokenT< reco::IsolatedPixelTrackCandidateCollection > tok_track_
double calibrationConeSize_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual void beginJob() override
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
TrackDetectorAssociator trackAssociator_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
const HcalRespCorrs * respRecalib
ValidIsoTrkCalib(const edm::ParameterSet &)
std::vector< edm::InputTag > genecalLabel_
int iphi() const
get the cell iphi
edm::Service< TFileService > fs
T const * product() const
edm::EDGetTokenT< HORecHitCollection > tok_ho_
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint)
double associationConeSize_
edm::EDGetTokenT< reco::TrackCollection > tok_track1_
virtual void endJob() override