76 void endJob()
override;
114 float genPt[500], genPhi[500], genEta[500];
115 float isoPt[500], isoPhi[500], isoEta[500];
116 float pixPt[500], pixPhi[500], pixEta[500];
179 float numVH,
numVS, numValidTrkHits, numValidTrkStrips;
211 associationConeSize_ = iConfig.
getParameter<
double>(
"associationConeSize");
217 calibrationConeSize_ = iConfig.
getParameter<
double>(
"calibrationConeSize");
219 MinNTrackHitsBarrel = iConfig.
getParameter<
int>(
"MinNTrackHitsBarrel");
220 MinNTECHitsEndcap = iConfig.
getParameter<
int>(
"MinNTECHitsEndcap");
221 energyECALmip = iConfig.
getParameter<
double>(
"energyECALmip");
222 energyMinIso = iConfig.
getParameter<
double>(
"energyMinIso");
223 energyMaxIso = iConfig.
getParameter<
double>(
"energyMaxIso");
229 trackAssociator_.useDefaultPropagator();
247 respRecalib = recalibCorrs.
product();
249 LogInfo(
"CalibConstants") <<
" Loaded: OK ";
252 LogWarning(
"CalibConstants") <<
" Not Found!! ";
259 iEvent.getByToken(tok_track1_, isoProdTracks);
263 iEvent.getByToken(tok_track_, isoPixelTracks);
283 parameters_.useEcal =
true;
284 parameters_.useHcal =
true;
285 parameters_.useCalo =
false;
286 parameters_.useMuon =
false;
292 if (isoPixelTracks->empty())
295 for (reco::TrackCollection::const_iterator trit = isoProdTracks->begin(); trit != isoProdTracks->end(); trit++) {
296 reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched = isoPixelTracks->begin();
301 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin();
302 it != isoPixelTracks->end();
306 if (
abs((trit->pt() - it->pt()) / it->pt()) < 0.005 &&
abs(trit->eta() - it->eta()) < 0.01) {
316 if (isoMatched->maxPtPxl() > maxPNear)
319 ptNear = isoMatched->maxPtPxl();
323 if (trit->hitPattern().numberOfValidHits() < MinNTrackHitsBarrel)
325 if (fabs(trit->eta()) > 1.47 && trit->hitPattern().numberOfValidStripTECHits() < MinNTECHitsEndcap)
331 numVH = trit->hitPattern().numberOfValidHits();
332 numVS = trit->hitPattern().numberOfValidStripTECHits();
334 trackE =
sqrt(trit->px() * trit->px() + trit->py() * trit->py() + trit->pz() * trit->pz() + 0.14 * 0.14);
339 emEnergy = isoMatched->energyIn();
345 trackAssociator_.associate(
iEvent, iSetup, trackAssociator_.getFreeTrajectoryState(iSetup, *trit), parameters_);
352 xTrkEcal =
info.trkGlobPosAtEcal.x();
353 yTrkEcal =
info.trkGlobPosAtEcal.y();
354 zTrkEcal =
info.trkGlobPosAtEcal.z();
356 xTrkHcal =
info.trkGlobPosAtHcal.x();
357 yTrkHcal =
info.trkGlobPosAtHcal.y();
358 zTrkHcal =
info.trkGlobPosAtHcal.z();
360 if (xTrkEcal == 0 && yTrkEcal == 0 && zTrkEcal == 0) {
361 cout <<
"zero point at Ecal" << endl;
364 if (xTrkHcal == 0 && yTrkHcal == 0 && zTrkHcal == 0) {
365 cout <<
"zero point at Hcal" << endl;
377 GlobalPoint gPointEcal(xTrkEcal, yTrkEcal, zTrkEcal);
378 GlobalPoint gPointHcal(xTrkHcal, yTrkHcal, zTrkHcal);
383 ietatrue = tempId.
ieta();
384 iphitrue = tempId.
iphi();
391 std::vector<DetId> usedHits;
405 bool hitIsUsed =
false;
406 for (uint32_t
i = 0;
i < usedHits.size();
i++) {
407 if (usedHits[
i] == hhit->id())
412 usedHits.push_back(hhit->id());
423 int iphihitm = (hhit->id()).
iphi();
424 int ietahitm = (hhit->id()).
ieta();
425 int depthhit = (hhit->id()).
depth();
426 float enehit = hhit->energy() * recal;
441 if (distAtHcal < associationConeSize_) {
443 int iphihitm2 = (hhit2->id()).
iphi();
444 int ietahitm2 = (hhit2->id()).
ieta();
445 int depthhit2 = (hhit2->id()).
depth();
446 float enehit2 = hhit2->energy() * recal;
448 if (iphihitm == iphihitm2 && ietahitm == ietahitm2 && depthhit != depthhit2)
449 enehit = enehit + enehit2;
460 MaxHit.
dr = distAtHcal;
476 Bool_t passCuts = kFALSE;
477 if (trackE > energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. &&
499 bool hitIsUsed =
false;
500 for (uint32_t
i = 0;
i < usedHits.size();
i++) {
501 if (usedHits[
i] == hhit->id())
506 usedHits.push_back(hhit->id());
514 DIETA = DIETA > 0 ? DIETA - 1 : DIETA + 1;
518 DIPHI = DIPHI > 36 ? 72 - DIPHI : DIPHI;
520 int numbercell = 100;
528 if (
abs(DIETA) <= numbercell &&
529 (
abs(DIPHI) <= numbercell || (
abs(MaxHit.
ietahitm) >= 20 &&
abs(DIPHI) <= numbercell + 1))) {
530 const GlobalPoint pos2 = geo->getPosition(hhit->detid());
532 if (passCuts && hhit->energy() > 0) {
539 if (hhit->id().ieta() == MaxHit.
ietahitm && hhit->id().iphi() == MaxHit.
iphihitm)
542 if (hhit->id().ieta() == MaxHit.
ietahitm && hhit->id().iphi() == MaxHit.
iphihitm)
543 iTime = hhit->time();
545 if (AxB_ !=
"3x3" && AxB_ !=
"5x5" && AxB_ !=
"Cone")
546 LogWarning(
" AxB ") <<
" Not supported: " << AxB_;
550 abs((hhit->id()).
ieta()) <= 20 &&
abs(DIPHI) > 2)))) {
551 e5x5Before += hhit->energy();
552 e5x5After += hhit->energy() *
factor;
558 e3x3Before += hhit->energy();
559 e3x3After += hhit->energy() *
factor;
567 HTime[numHits] = hhit->time();
570 eClustBefore += hhit->energy();
571 eClustAfter += hhit->energy() *
factor;
573 if ((hhit->id().depth() == 1) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29)) {
574 eBeforeDepth1 += hhit->energy();
575 eAfterDepth1 += hhit->energy() *
factor;
576 }
else if ((hhit->id().depth() == 2) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29)) {
577 eBeforeDepth2 += hhit->energy();
578 eAfterDepth2 += hhit->energy() *
factor;
588 HTime[numHits] = hhit->time();
591 eClustBefore += hhit->energy();
592 eClustAfter += hhit->energy() *
factor;
594 if ((hhit->id().depth() == 1) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29)) {
595 eBeforeDepth1 += hhit->energy();
596 eAfterDepth1 += hhit->energy() *
factor;
597 }
else if ((hhit->id().depth() == 2) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29)) {
598 eBeforeDepth2 += hhit->energy();
599 eAfterDepth2 += hhit->energy() *
factor;
605 HTime[numHits] = hhit->time();
608 eClustBefore += hhit->energy();
609 eClustAfter += hhit->energy() *
factor;
611 if ((hhit->id().depth() == 1) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29)) {
612 eBeforeDepth1 += hhit->energy();
613 eAfterDepth1 += hhit->energy() *
factor;
614 }
else if ((hhit->id().depth() == 2) && (
abs(hhit->id().ieta()) > 17) && (
abs(hhit->id().ieta()) < 29)) {
615 eBeforeDepth2 += hhit->energy();
616 eAfterDepth2 += hhit->energy() *
factor;
629 if (MaxHit.
ietahitm * ietatrue > 0) {
632 if (MaxHit.
ietahitm * ietatrue < 0) {
636 diphi_M_P = diphi_M_P > 36 ? 72 - diphi_M_P : diphi_M_P;
641 eventNumber =
iEvent.id().event();
645 eCentHitAfter = MaxHit.
hitenergy * CentHitFactor;
647 numValidTrkHits = numVH;
648 numValidTrkStrips = numVS;
660 iDr =
sqrt(diphi_M_P * diphi_M_P + dieta_M_P * dieta_M_P);
675 if (takeGenTracks_ &&
iEvent.id().event() % 10 == 1) {
677 iso = isoProdTracks->size();
678 pix = isoPixelTracks->size();
692 Int_t gencount = 0, isocount = 0, pixcount = 0;
694 genPt[gencount] = gentr->pt();
695 genPhi[gencount] = gentr->phi();
696 genEta[gencount] = gentr->eta();
700 for (reco::TrackCollection::const_iterator isotr = isoProdTracks->begin(); isotr != isoProdTracks->end(); isotr++) {
701 isoPt[isocount] = isotr->pt();
702 isoPhi[isocount] = isotr->phi();
703 isoEta[isocount] = isotr->eta();
707 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator pixtr = isoPixelTracks->begin();
708 pixtr != isoPixelTracks->end();
710 pixPt[pixcount] = pixtr->pt();
711 pixPhi[pixcount] = pixtr->phi();
712 pixEta[pixcount] = pixtr->eta();
740 nTracks = fs->make<TH1F>(
"nTracks",
"general;number of general tracks", 11, -0.5, 10.5);
742 tTree = fs->make<TTree>(
"tTree",
"Tree for gen info");
744 fTree = fs->make<TTree>(
"fTree",
"Tree for IsoTrack Calibration");
746 fTree->Branch(
"eventNumber", &eventNumber,
"eventNumber/I");
747 fTree->Branch(
"runNumber", &
runNumber,
"runNumber/I");
749 fTree->Branch(
"eClustBefore", &eClustBefore,
"eClustBefore/F");
750 fTree->Branch(
"eClustAfter", &eClustAfter,
"eClustAfter/F");
751 fTree->Branch(
"eTrack", &eTrack,
"eTrack/F");
752 fTree->Branch(
"etaTrack", &etaTrack,
"etaTrack/F");
753 fTree->Branch(
"phiTrack", &phiTrack,
"phiTrack/F");
755 fTree->Branch(
"numHits", &numHits,
"numHits/I");
756 fTree->Branch(
"eECAL", &eECAL,
"eECAL/F");
757 fTree->Branch(
"PtNearBy", &PtNearBy,
"PtNearBy/F");
758 fTree->Branch(
"numValidTrkHits", &numValidTrkHits,
"numValidTrkHits/F");
759 fTree->Branch(
"numValidTrkStrips", &numValidTrkStrips,
"numValidTrkStrips/F");
761 fTree->Branch(
"eBeforeDepth1", &eBeforeDepth1,
"eBeforeDepth1/F");
762 fTree->Branch(
"eBeforeDepth2", &eBeforeDepth2,
"eBeforeDepth2/F");
763 fTree->Branch(
"eAfterDepth1", &eAfterDepth1,
"eAfterDepth1/F");
764 fTree->Branch(
"eAfterDepth2", &eAfterDepth2,
"eAfterDepth2/F");
766 fTree->Branch(
"e3x3Before", &e3x3Before,
"e3x3Before/F");
767 fTree->Branch(
"e3x3After", &e3x3After,
"e3x3After/F");
768 fTree->Branch(
"e5x5Before", &e5x5Before,
"e5x5Before/F");
769 fTree->Branch(
"e5x5After", &e5x5After,
"e5x5After/F");
771 fTree->Branch(
"eCentHitAfter", &eCentHitAfter,
"eCentHitAfter/F");
772 fTree->Branch(
"eCentHitBefore", &eCentHitBefore,
"eCentHitBefore/F");
773 fTree->Branch(
"iEta", &
iEta,
"iEta/I");
774 fTree->Branch(
"iPhi", &iPhi,
"iPhi/I");
776 fTree->Branch(
"iEtaTr", &iEtaTr,
"iEtaTr/I");
777 fTree->Branch(
"iPhiTr", &iPhiTr,
"iPhiTr/I");
778 fTree->Branch(
"dietatr", &dietatr,
"dietatr/I");
779 fTree->Branch(
"diphitr", &diphitr,
"diphitr/I");
780 fTree->Branch(
"iDr", &iDr,
"iDr/F");
781 fTree->Branch(
"delR", &delR,
"delR/F");
783 fTree->Branch(
"iTime", &iTime,
"iTime/F");
784 fTree->Branch(
"HTime", HTime,
"HTime[numHits]/F");
786 fTree->Branch(
"xTrkEcal", &xTrkEcal,
"xTrkEcal/F");
787 fTree->Branch(
"yTrkEcal", &yTrkEcal,
"yTrkEcal/F");
788 fTree->Branch(
"zTrkEcal", &zTrkEcal,
"zTrkEcal/F");
789 fTree->Branch(
"xTrkHcal", &xTrkHcal,
"xTrkHcal/F");
790 fTree->Branch(
"yTrkHcal", &yTrkHcal,
"yTrkHcal/F");
791 fTree->Branch(
"zTrkHcal", &zTrkHcal,
"zTrkHcal/F");
793 if (takeGenTracks_) {
794 tTree->Branch(
"gen", &
gen,
"gen/I");
795 tTree->Branch(
"iso", &iso,
"iso/I");
796 tTree->Branch(
"pix", &pix,
"pix/I");
797 tTree->Branch(
"genPt",
genPt,
"genPt[gen]/F");
798 tTree->Branch(
"genPhi", genPhi,
"genPhi[gen]/F");
799 tTree->Branch(
"genEta", genEta,
"genEta[gen]/F");
801 tTree->Branch(
"isoPt", isoPt,
"isoPt[iso]/F");
802 tTree->Branch(
"isoPhi", isoPhi,
"isoPhi[iso]/F");
803 tTree->Branch(
"isoEta", isoEta,
"isoEta[iso]/F");
805 tTree->Branch(
"pixPt", pixPt,
"pixPt[pix]/F");
806 tTree->Branch(
"pixPhi", pixPhi,
"pixPhi[pix]/F");
807 tTree->Branch(
"pixEta", pixEta,
"pixEta[pix]/F");