81 void fillTrack(
int,
double,
double,
double,
double);
83 void fillEnergy(
int,
int,
double,
double,
double,
double,
double);
186 << trigNames_.size() <<
" triggers:";
187 for (
unsigned int k=0;
k<trigNames_.size(); ++
k)
189 edm::LogInfo(
"IsoTrack") <<
"TrackQuality " << theTrackQuality_ <<
" Minpt "
204 double pBins[
nPBin+1] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,9.0,11.0,15.0,20.0};
205 int etaBins[
nEtaBin+1] = {1, 7, 13, 17, 23};
206 int pvBins[
nPVBin+1] = {1, 2, 3, 5, 100};
229 edm::LogInfo(
"IsoTrack") <<
"Event starts====================================";
230 int RunNo = iEvent.
id().
run();
231 int EvtNo = iEvent.
id().
event();
235 std::string newNames[5]={
"HLT",
"PixelTracks_Multiplicity",
"HLT_Physics_",
"HLT_JetE",
"HLT_ZeroBias"};
237 for (
int i=0;
i<5; ++
i) newAccept[
i] = 0;
245 edm::LogInfo(
"IsoTrack") <<
"RunNo " << RunNo <<
" EvtNo " << EvtNo
246 <<
" Lumi " << Lumi <<
" Bunch " << Bunch
247 <<
" mybxlumi " << mybxlumi;
254 if (!triggerEventHandle.
isValid()) {
258 triggerEvent = *(triggerEventHandle.
product());
264 if (triggerResults.
isValid()) {
265 h_nHLT->Fill(triggerResults->size());
266 h_nHLTvsRN->Fill(RunNo, triggerResults->size());
269 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
270 for (
unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
284 if (ipos <= h_HLTAccept->GetNbinsX())
285 h_HLTAccept->GetXaxis()->SetBinLabel(ipos,newtriggerName.c_str());
288 edm::LogInfo(
"IsoTrack") <<
"Wrong trigger " << RunNo <<
" Event "
289 << EvtNo <<
" Hlt " << iHLT;
293 int hlt = triggerResults->accept(iHLT);
302 if (newtriggerName.find(
trigNames_[
i].c_str())!=std::string::npos) {
311 for (
int i=0;
i<5; ++
i) {
312 if (newtriggerName.find(newNames[
i].c_str())!=std::string::npos) {
315 <<
" : " << newtriggerName;
316 if (hlt > 0) newAccept[
i] = 1;
321 int iflg(0), indx(1);
322 for (
int i=0;
i<5; ++
i) {
323 iflg += (indx*newAccept[
i]); indx *= 2;
356 int ntrk(0), ngoodPV(0), nPV(-1);
357 int nvtxs = (int)(recVtxs->size());
358 for (
int ind=0; ind<nvtxs; ind++) {
359 if (!((*recVtxs)[ind].isFake()) && (*recVtxs)[ind].ndof() > 4) ngoodPV++;
373 edm::LogInfo(
"IsoTrack") <<
"Number of vertices: " << nvtxs
374 <<
" Good " << ngoodPV <<
" Bin " << nPV
377 h_goodPV->Fill(ngoodPV,tr_eventWeight);
381 int npbin =
h_goodPV->FindBin(ngoodPV);
382 if (npbin > 0 && npbin <= (
int)(
puWeights_.size()))
394 reco::TrackCollection::const_iterator trkItr;
395 for (trkItr=trkCollection->begin(); trkItr != trkCollection->end(); ++trkItr,++ntrk) {
397 double pt1 = pTrack->
pt();
398 double p1 = pTrack->
p();
399 double eta1 = pTrack->
momentum().eta();
400 double phi1 = pTrack->
momentum().phi();
403 if (quality)
fillTrack(1, pt1,p1,eta1,phi1);
405 h_ntrk[0]->Fill(ntrk,tr_eventWeight);
407 std::vector<spr::propagatedTrackID> trkCaloDets;
409 std::vector<spr::propagatedTrackID>::const_iterator trkDetItr;
410 for (trkDetItr = trkCaloDets.begin(),ntrk=0; trkDetItr != trkCaloDets.end(); trkDetItr++,ntrk++) {
411 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
412 double pt1 = pTrack->
pt();
413 double p1 = pTrack->
p();
414 double eta1 = pTrack->
momentum().eta();
415 double phi1 = pTrack->
momentum().phi();
417 edm::LogInfo(
"IsoTrack") <<
"track: p " << p1 <<
" pt " << pt1
418 <<
" eta " << eta1 <<
" phi " << phi1
419 <<
" okEcal " << trkDetItr->okECAL;
433 std::pair<double, bool> e7x7P, e11x11P, e15x15P;
434 const DetId isoCell = trkDetItr->detIdECAL;
435 e7x7P =
spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.
product(),3,3, 0.030, 0.150,
tMinE_,
tMaxE_, ((
verbosity_/10000)%10 > 0));
436 e11x11P =
spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.
product(),5,5, 0.030, 0.150,
tMinE_,
tMaxE_, ((
verbosity_/10000)%10 > 0));
437 e15x15P =
spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.
product(),7,7, 0.030, 0.150,
tMinE_,
tMaxE_, ((
verbosity_/10000)%10 > 0));
441 double h3x3(0), h5x5(0), h7x7(0);
444 edm::LogInfo(
"IsoTrack") <<
"Accepted Tracks reaching Ecal maxNearP31x31 "
445 << maxNearP31x31 <<
" e11x11P "
446 << e11x11P.first <<
" e15x15P "
447 << e15x15P.first <<
" okHCAL "
448 << trkDetItr->okHCAL;
450 int trackID =
trackPID(pTrack,genParticles);
451 if (trkDetItr->okHCAL) {
454 const DetId ClosestCell(trkDetItr->detIdHCAL);
455 ieta = ((
HcalDetId)(ClosestCell)).ietaAbs();
456 h3x3 =
spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,1,1,
false,
true, 0.7, 0.8, -100.0, -100.0,
tMinH_,
tMaxH_, ((
verbosity_/10000)%10 > 0));
457 h5x5 =
spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,2,2,
false,
true, 0.7, 0.8, -100.0, -100.0,
tMinH_,
tMaxH_, ((
verbosity_/10000)%10 > 0) );
458 h7x7 =
spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,3,3,
false,
true, 0.7, 0.8, -100.0, -100.0,
tMinH_,
tMaxH_, ((
verbosity_/10000)%10 > 0) );
461 edm::LogInfo(
"IsoTrack") <<
"Tracks Reaching Hcal maxNearHcalP7x7/h5x5/h7x7 "
462 << maxNearHcalP7x7 <<
"/" << h5x5 <<
"/" << h7x7;
481 if (maxNearP31x31 < 0) {
483 fillEnergy(0,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
484 if (maxNearHcalP7x7 < 0) {
486 fillEnergy(1,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
487 if ((e11x11P.second) && (e15x15P.second) &&
488 (e15x15P.first-e11x11P.first)<2.0) {
490 fillEnergy(2,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
491 if (h7x7-h5x5 < 2.0) {
493 fillEnergy(3,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
496 fillEnergy(nPV+4,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
499 fillTrack(nPVBin+trackID+7, pt1,p1,eta1,phi1);
500 fillEnergy(nPVBin+trackID+3,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
509 h_ntrk[1]->Fill(ntrk,tr_eventWeight);
517 h_nHLT =
fs_->
make<TH1I>(
"h_nHLT" ,
"size of trigger Names", 1000, 0, 1000);
518 h_HLTAccept =
fs_->
make<TH1I>(
"h_HLTAccept",
"HLT Accepts for all runs", 500, 0, 500);
519 for (
int i=1;
i<=500; ++
i) h_HLTAccept->GetXaxis()->SetBinLabel(
i,
" ");
520 h_nHLTvsRN =
fs_->
make<TH2I>(
"h_nHLTvsRN" ,
"size of trigger Names vs RunNo", 2168, 190949, 193116, 100, 400, 500);
521 h_HLTCorr =
fs_->
make<TH1I>(
"h_HLTCorr",
"Correlation among different paths", 100, 0, 100);
522 h_numberPV =
fs_->
make<TH1I>(
"h_numberPV",
"Number of Primary Vertex", 100, 0, 100);
523 h_goodPV =
fs_->
make<TH1I>(
"h_goodPV",
"Number of good Primary Vertex", 100, 0, 100);
524 h_goodRun =
fs_->
make<TH1I>(
"h_goodRun",
"Number of accepted events for Run", 4000, 190000, 1940000);
525 char hname[50], htit[200];
526 std::string CollectionNames[2] = {
"Reco",
"Propagated"};
527 for (
unsigned int i=0;
i<2;
i++) {
528 sprintf(hname,
"h_nTrk_%s", CollectionNames[
i].c_str());
529 sprintf(htit,
"Number of %s tracks", CollectionNames[
i].c_str());
532 std::string TrkNames[8] = {
"All",
"Quality",
"NoIso",
"okEcal",
"EcalCharIso",
"HcalCharIso",
"EcalNeutIso",
"HcalNeutIso"};
533 std::string particle[4] = {
"Electron",
"Pion",
"Kaon",
"Proton"};
534 for (
unsigned int i=0;
i<8+
nPVBin+4;
i++) {
536 sprintf(hname,
"h_pt_%s", TrkNames[
i].c_str());
537 sprintf(htit,
"p_{T} of %s tracks", TrkNames[
i].c_str());
538 }
else if (
i < 8+nPVBin) {
539 sprintf(hname,
"h_pt_%s_%d", TrkNames[7].c_str(),
i-8);
540 sprintf(htit,
"p_{T} of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
542 sprintf(hname,
"h_pt_%s_%s", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
543 sprintf(htit,
"p_{T} of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
549 sprintf(hname,
"h_p_%s", TrkNames[
i].c_str());
550 sprintf(htit,
"Momentum of %s tracks", TrkNames[
i].c_str());
551 }
else if (
i < 8+nPVBin) {
552 sprintf(hname,
"h_p_%s_%d", TrkNames[7].c_str(),
i-8);
553 sprintf(htit,
"Momentum of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
555 sprintf(hname,
"h_p_%s_%s", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
556 sprintf(htit,
"Momentum of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
558 h_p[
i] =
fs_->
make<TH1D>(hname, htit, 400, 0, 200.0);
562 sprintf(hname,
"h_eta_%s", TrkNames[
i].c_str());
563 sprintf(htit,
"Eta of %s tracks", TrkNames[
i].c_str());
564 }
else if (
i < 8+nPVBin) {
565 sprintf(hname,
"h_eta_%s_%d", TrkNames[7].c_str(),
i-8);
566 sprintf(htit,
"Eta of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
568 sprintf(hname,
"h_eta_%s_%s", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
569 sprintf(htit,
"Eta of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
575 sprintf(hname,
"h_phi_%s", TrkNames[
i].c_str());
576 sprintf(htit,
"Phi of %s tracks", TrkNames[
i].c_str());
577 }
else if (
i < 8+nPVBin) {
578 sprintf(hname,
"h_phi_%s_%d", TrkNames[7].c_str(),
i-8);
579 sprintf(htit,
"Phi of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
581 sprintf(hname,
"h_phi_%s_%s", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
582 sprintf(htit,
"Phi of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-nPVBin].c_str());
588 for (
unsigned int i=0;
i<2;
i++) {
589 sprintf(hname,
"h_maxNearP_%s", IsolationNames[
i].c_str());
590 sprintf(htit,
"Energy in ChargeIso region for %s", IsolationNames[
i].c_str());
594 sprintf(hname,
"h_ene1_%s", IsolationNames[
i].c_str());
595 sprintf(htit,
"Energy in smaller cone for %s", IsolationNames[
i].c_str());
599 sprintf(hname,
"h_ene2_%s", IsolationNames[
i].c_str());
600 sprintf(htit,
"Energy in bigger cone for %s", IsolationNames[
i].c_str());
604 sprintf(hname,
"h_ediff_%s", IsolationNames[
i].c_str());
605 sprintf(htit,
"Energy in NeutralIso region for %s", IsolationNames[
i].c_str());
609 std::string energyNames[6]={
"E_{7x7}",
"H_{3x3}",
"(E_{7x7}+H_{3x3})",
610 "E_{11x11}",
"H_{5x5}",
"{E_{11x11}+H_{5x5})"};
611 for (
int i=0;
i<4+nPVBin+4; ++
i) {
612 for (
int ip=0; ip<
nPBin; ++ip) {
613 for (
int ie=0; ie<
nEtaBin; ++ie) {
614 for (
int j=0;
j<6; ++
j) {
615 sprintf(hname,
"h_energy_%d_%d_%d_%d",
i, ip, ie,
j);
617 sprintf(htit,
"%s/p (p=%4.1f:%4.1f; i#eta=%d:%d) for tracks with %s",
619 (
etaBin[ie+1]-1), TrkNames[
i+4].c_str());
620 }
else if (
i < 4+nPVBin) {
621 sprintf(htit,
"%s/p (p=%4.1f:%4.1f, i#eta=%d:%d, PV=%d:%d) for tracks with %s",
624 TrkNames[7].c_str());
626 sprintf(htit,
"%s/p (p=%4.1f:%4.1f, i#eta=%d:%d %s) for tracks with %s",
628 (
etaBin[ie+1]-1), particle[
i-4-nPVBin].c_str(),
629 TrkNames[7].c_str());
667 char hname[100], htit[400];
670 sprintf(hname,
"h_HLTAccepts_%i", iRun.
run());
671 sprintf(htit,
"HLT Accepts for Run No %i", iRun.
run());
672 TH1I *hnew =
fs_->
make<TH1I>(hname, htit, 500, 0, 500);
673 for (
int i=1;
i<=500; ++
i) hnew->GetXaxis()->SetBinLabel(
i,
" ");
716 double enHcal1,
double enEcal2,
double enHcal2) {
719 if (p >=
pBin[
i] && p <
pBin[
i+1]) { ip =
i;
break; }
724 if (ip >= 0 && ie >= 0 && enEcal1 > 0.02 && enHcal1 > 0.1) {
736 int length = str.length();
737 for (
int i=0;
i<length-2;
i++){
738 if (str[
i]==
'_' && str[
i+1]==
'v' && isdigit(str.at(
i+2))) {
740 truncated_str = str.substr(0,z);
743 return(truncated_str);
750 reco::GenParticleCollection::const_iterator
p;
752 for (p=genParticles->begin(),indx=0; p!=genParticles->end(); ++
p,++indx) {
754 int idx = (pdgId == 11) ? 1 :
755 ((pdgId == 211) ? 2 : ((pdgId == 321) ? 3 : ((pdgId == 2212) ? 4 : 0)));
757 double dEta = pTrack->
eta() - p->momentum().Eta();
758 double phi1 = pTrack->
phi();
759 double phi2 = p->momentum().Phi();
760 if (phi1 < 0) phi1 += 2.0*
M_PI;
761 if (phi2 < 0) phi2 += 2.0*
M_PI;
762 double dPhi = phi1-phi2;
764 else if (dPhi < -
M_PI) dPhi += 2.*
M_PI;
765 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
767 mindR =
dR;
id = idx;
void fillEnergy(int, int, double, double, double, double, double)
double p() const
momentum vector magnitude
T getParameter(std::string const &) const
EventNumber_t event() const
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > tr_TrkPt
std::vector< double > tr_H3x3
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
edm::InputTag triggerEvent_
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
The single EDProduct to be saved for each event (AOD case)
std::vector< double > tr_MaxNearP31X31
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
TH1D * h_energy[nPVBin+8][nPBin][nEtaBin][6]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
std::vector< TH1I * > h_HLTAccepts
std::vector< std::string > tr_TrigName
std::vector< bool > tr_SE7x7P
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
edm::EDGetTokenT< reco::GenParticleCollection > tok_parts_
double eHCALmatrix(const HcalTopology *topology, const DetId &det, edm::Handle< T > &hits, int ieta, int iphi, bool includeHO=false, bool algoNew=true, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool useRaw=false, bool debug=false)
int bunchCrossing() const
edm::LuminosityBlockNumber_t luminosityBlock() const
double phi() const
azimuthal angle of momentum vector
T * make(const Args &...args) const
make new ROOT object
const Vector & momentum() const
track momentum vector
std::vector< std::string > HLTNames_
Strings const & triggerNames() const
std::vector< std::string > trigNames_
std::vector< double > tr_TrkEta
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
virtual void beginJob() override
void fillIsolation(int, double, double, double)
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
double chargeIsolationEcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, bool debug=false)
double eta() const
pseudorapidity of momentum vector
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< int > tr_iEta
spr::trackSelectionParameters selectionParameters_
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
void fillTrack(int, double, double, double, double)
double dPhi(double phi1, double phi2)
std::vector< double > puWeights_
std::vector< double > tr_MaxNearHcalP7x7
std::string truncate_str(const std::string &)
double pt() const
track transverse momentum
usesResource(TFileService::kSharedResource)
Abs< T >::type abs(const T &t)
HLTConfigProvider hltConfig_
std::vector< bool > tr_SE11x11P
static std::string const triggerResults
std::vector< double > tr_FE11x11P
static TrackQuality qualityByName(const std::string &name)
edm::InputTag theTriggerResultsLabel_
edm::Service< TFileService > fs_
T const * product() const
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< int > tr_TrkID
int trackPID(const reco::Track *, const edm::Handle< reco::GenParticleCollection > &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
T const * product() const
edm::EDGetTokenT< LumiDetails > tok_lumi
bool quality(const TrackQuality) const
Track quality.
Geom::Phi< T > phi() const
std::vector< double > tr_H7x7
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< double > tr_FE15x15P
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes
std::string theTrackQuality_
reco::TrackBase::TrackQuality minQuality
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
StudyHLT(const edm::ParameterSet &)
std::vector< double > tr_FE7x7P
std::vector< double > tr_TrkPhi
double chargeIsolationHcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const HcalTopology *topology, int ieta, int iphi, bool debug=false)
std::vector< double > tr_TrkP
std::vector< bool > tr_SE15x15P
std::vector< double > tr_H5x5
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
double eECALmatrix(const DetId &detId, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)