78 virtual void endJob() ;
116 float genPt[500], genPhi[500], genEta[500];
117 float isoPt[500], isoPhi[500], isoEta[500];
118 float pixPt[500], pixPhi[500], pixEta[500];
183 float numVH,
numVS, numValidTrkHits, numValidTrkStrips;
218 associationConeSize_=iConfig.
getParameter<
double>(
"associationConeSize");
225 calibrationConeSize_=iConfig.
getParameter<
double>(
"calibrationConeSize");
227 MinNTrackHitsBarrel = iConfig.
getParameter<
int>(
"MinNTrackHitsBarrel");
228 MinNTECHitsEndcap = iConfig.
getParameter<
int>(
"MinNTECHitsEndcap");
229 energyECALmip = iConfig.
getParameter<
double>(
"energyECALmip");
230 energyMinIso = iConfig.
getParameter<
double>(
"energyMinIso");
231 energyMaxIso = iConfig.
getParameter<
double>(
"energyMaxIso");
235 parameters_.loadParameters( parameters );
236 trackAssociator_.useDefaultPropagator();
262 respRecalib = recalibCorrs.
product();
264 LogInfo(
"CalibConstants")<<
" Loaded: OK ";
267 LogWarning(
"CalibConstants")<<
" Not Found!! ";
274 iEvent.
getByLabel(trackLabel1_,isoProdTracks);
279 iEvent.
getByLabel(trackLabel_,isoPixelTracks);
299 parameters_.useEcal =
true;
300 parameters_.useHcal =
true;
301 parameters_.useCalo =
false;
302 parameters_.useMuon =
false;
308 if (isoPixelTracks->size()==0)
return;
311 for (reco::TrackCollection::const_iterator trit=isoProdTracks->begin(); trit!=isoProdTracks->end(); trit++)
314 reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched=isoPixelTracks->begin();
319 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin(); it!=isoPixelTracks->end(); it++)
323 if (
abs((trit->pt() - it->pt())/it->pt()) < 0.005 &&
abs(trit->eta() - it->eta()) < 0.01)
332 if (!matched)
continue;
333 if(isoMatched->maxPtPxl() > maxPNear)
continue;
335 ptNear = isoMatched->maxPtPxl();
340 if (trit->hitPattern().numberOfValidHits()<MinNTrackHitsBarrel)
continue;
341 if (fabs(trit->eta())>1.47&&trit->hitPattern().numberOfValidStripTECHits()<MinNTECHitsEndcap)
continue;
346 numVH = trit->hitPattern().numberOfValidHits();
347 numVS = trit->hitPattern().numberOfValidStripTECHits();
351 trackE =
sqrt(trit->px()*trit->px()+trit->py()*trit->py()+trit->pz()*trit->pz()+0.14*0.14);
352 trackPt = trit->pt();
356 emEnergy = isoMatched->energyIn();
361 TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup,trackAssociator_.getFreeTrajectoryState(iSetup, *trit), parameters_);
377 if (xTrkEcal==0 && yTrkEcal==0&& zTrkEcal==0) {
cout<<
"zero point at Ecal"<<endl;
continue;}
378 if (xTrkHcal==0 && yTrkHcal==0&& zTrkHcal==0) {
cout<<
"zero point at Hcal"<<endl;
continue;}
388 GlobalPoint gPointEcal(xTrkEcal,yTrkEcal,zTrkEcal);
389 GlobalPoint gPointHcal(xTrkHcal,yTrkHcal,zTrkHcal);
393 const HcalDetId tempId = gHcal->getClosestCell(gPointHcal);
394 ietatrue = tempId.
ieta();
395 iphitrue = tempId.
iphi();
403 std::vector<int> usedHits;
420 bool hitIsUsed=
false;
421 int hitHashedIndex=hhit->id().hashed_index();
422 for (uint32_t
i=0;
i<usedHits.size();
i++)
424 if (usedHits[
i]==hitHashedIndex) hitIsUsed=
true;
426 if (hitIsUsed)
continue;
427 usedHits.push_back(hitHashedIndex);
438 int iphihitm = (hhit->id()).iphi();
439 int ietahitm = (hhit->id()).ieta();
440 int depthhit = (hhit->id()).depth();
441 float enehit = hhit->energy() * recal;
443 if (depthhit!=1)
continue;
456 if(distAtHcal < associationConeSize_)
461 int iphihitm2 = (hhit2->id()).iphi();
462 int ietahitm2 = (hhit2->id()).ieta();
463 int depthhit2 = (hhit2->id()).depth();
464 float enehit2 = hhit2->energy() * recal;
466 if (iphihitm==iphihitm2 && ietahitm==ietahitm2 && depthhit!=depthhit2) enehit = enehit+enehit2;
478 MaxHit.
ietahitm = (hhit->id()).ieta();
479 MaxHit.
iphihitm = (hhit->id()).iphi();
480 MaxHit.
dr = distAtHcal;
497 Bool_t passCuts = kFALSE;
498 if(trackE > energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. &&
abs(MaxHit.
ietahitm)<29) passCuts = kTRUE;
522 bool hitIsUsed=
false;
523 int hitHashedIndex=hhit->id().hashed_index();
524 for (uint32_t
i=0;
i<usedHits.size();
i++)
526 if (usedHits[
i]==hitHashedIndex) hitIsUsed=
true;
528 if (hitIsUsed)
continue;
529 usedHits.push_back(hitHashedIndex);
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");
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
std::vector< T >::const_iterator const_iterator
TrackAssociatorParameters parameters_
math::XYZPoint trkGlobPosAtHcal
double calibrationConeSize_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int ieta() const
get the cell ieta
TrackDetectorAssociator trackAssociator_
const HcalRespCorrs * respRecalib
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
ValidIsoTrkCalib(const edm::ParameterSet &)
std::vector< edm::InputTag > genecalLabel_
int iphi() const
get the cell iphi
edm::Service< TFileService > fs
T const * product() const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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_