81 void fillTrack(
int,
double,
double,
double,
double);
83 void fillEnergy(
int,
int,
double,
double,
double,
double,
double);
139 usesResource(
"TFileService");
187 << trigNames_.size() <<
" triggers:";
188 for (
unsigned int k=0;
k<trigNames_.size(); ++
k)
190 edm::LogInfo(
"IsoTrack") <<
"TrackQuality " << theTrackQuality_ <<
" Minpt " 205 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};
206 int etaBins[
nEtaBin+1] = {1, 7, 13, 17, 23};
207 int pvBins[
nPVBin+1] = {1, 2, 3, 5, 100};
230 edm::LogInfo(
"IsoTrack") <<
"Event starts====================================";
231 int RunNo = iEvent.
id().
run();
232 int EvtNo = iEvent.
id().
event();
236 std::string newNames[5]={
"HLT",
"PixelTracks_Multiplicity",
"HLT_Physics_",
"HLT_JetE",
"HLT_ZeroBias"};
238 for (
int i=0;
i<5; ++
i) newAccept[
i] = 0;
246 edm::LogInfo(
"IsoTrack") <<
"RunNo " << RunNo <<
" EvtNo " << EvtNo
247 <<
" Lumi " << Lumi <<
" Bunch " << Bunch
248 <<
" mybxlumi " << mybxlumi;
255 if (!triggerEventHandle.
isValid()) {
259 triggerEvent = *(triggerEventHandle.
product());
265 if (triggerResults.
isValid()) {
270 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
271 for (
unsigned int iHLT=0; iHLT<triggerResults->
size(); iHLT++) {
285 if (ipos <= h_HLTAccept->GetNbinsX())
286 h_HLTAccept->GetXaxis()->SetBinLabel(ipos,newtriggerName.c_str());
289 edm::LogInfo(
"IsoTrack") <<
"Wrong trigger " << RunNo <<
" Event " 290 << EvtNo <<
" Hlt " << iHLT;
303 if (newtriggerName.find(
trigNames_[
i])!=std::string::npos) {
312 for (
int i=0;
i<5; ++
i) {
313 if (newtriggerName.find(newNames[
i])!=std::string::npos) {
316 <<
" : " << newtriggerName;
317 if (hlt > 0) newAccept[
i] = 1;
322 int iflg(0), indx(1);
323 for (
int i=0;
i<5; ++
i) {
324 iflg += (indx*newAccept[
i]); indx *= 2;
357 int ntrk(0), ngoodPV(0), nPV(-1);
358 int nvtxs = (
int)(recVtxs->size());
359 for (
int ind=0; ind<nvtxs; ind++) {
360 if (!((*recVtxs)[ind].isFake()) && (*recVtxs)[ind].ndof() > 4) ngoodPV++;
374 edm::LogInfo(
"IsoTrack") <<
"Number of vertices: " << nvtxs
375 <<
" Good " << ngoodPV <<
" Bin " << nPV
378 h_goodPV->Fill(ngoodPV,tr_eventWeight);
382 int npbin =
h_goodPV->FindBin(ngoodPV);
383 if (npbin > 0 && npbin <= (
int)(
puWeights_.size()))
394 double pt1 =
p.momentum().Rho();
395 double p1 =
p.momentum().R();
396 double eta1 =
p.momentum().Eta();
397 double phi1 =
p.momentum().Phi();
404 reco::TrackCollection::const_iterator trkItr;
405 for (trkItr=trkCollection->begin(); trkItr != trkCollection->end(); ++trkItr,++ntrk) {
407 double pt1 = pTrack->
pt();
408 double p1 = pTrack->
p();
409 double eta1 = pTrack->
momentum().eta();
410 double phi1 = pTrack->
momentum().phi();
413 if (quality)
fillTrack(1, pt1,p1,eta1,phi1);
415 h_ntrk[0]->Fill(ntrk,tr_eventWeight);
417 std::vector<spr::propagatedTrackID> trkCaloDets;
419 std::vector<spr::propagatedTrackID>::const_iterator trkDetItr;
420 for (trkDetItr = trkCaloDets.begin(),ntrk=0; trkDetItr != trkCaloDets.end(); trkDetItr++,ntrk++) {
421 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
422 double pt1 = pTrack->
pt();
423 double p1 = pTrack->
p();
424 double eta1 = pTrack->
momentum().eta();
425 double phi1 = pTrack->
momentum().phi();
427 edm::LogInfo(
"IsoTrack") <<
"track: p " << p1 <<
" pt " << pt1
428 <<
" eta " << eta1 <<
" phi " << phi1
429 <<
" okEcal " << trkDetItr->okECAL;
443 std::pair<double, bool> e7x7P, e11x11P, e15x15P;
444 const DetId isoCell = trkDetItr->detIdECAL;
445 e7x7P =
spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.
product(),3,3, 0.030, 0.150,
tMinE_,
tMaxE_, ((
verbosity_/10000)%10 > 0));
446 e11x11P =
spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.
product(),5,5, 0.030, 0.150,
tMinE_,
tMaxE_, ((
verbosity_/10000)%10 > 0));
447 e15x15P =
spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.
product(),7,7, 0.030, 0.150,
tMinE_,
tMaxE_, ((
verbosity_/10000)%10 > 0));
451 double h3x3(0), h5x5(0), h7x7(0);
454 edm::LogInfo(
"IsoTrack") <<
"Accepted Tracks reaching Ecal maxNearP31x31 " 455 << maxNearP31x31 <<
" e11x11P " 456 << e11x11P.first <<
" e15x15P " 457 << e15x15P.first <<
" okHCAL " 458 << trkDetItr->okHCAL;
460 int trackID =
trackPID(pTrack,genParticles);
461 if (trkDetItr->okHCAL) {
464 const DetId ClosestCell(trkDetItr->detIdHCAL);
465 ieta = ((
HcalDetId)(ClosestCell)).ietaAbs();
466 h3x3 =
spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,1,1,
false,
true, 0.7, 0.8, -100.0, -100.0,
tMinH_,
tMaxH_, ((
verbosity_/10000)%10 > 0));
467 h5x5 =
spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,2,2,
false,
true, 0.7, 0.8, -100.0, -100.0,
tMinH_,
tMaxH_, ((
verbosity_/10000)%10 > 0) );
468 h7x7 =
spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,3,3,
false,
true, 0.7, 0.8, -100.0, -100.0,
tMinH_,
tMaxH_, ((
verbosity_/10000)%10 > 0) );
471 edm::LogInfo(
"IsoTrack") <<
"Tracks Reaching Hcal maxNearHcalP7x7/h5x5/h7x7 " 472 << maxNearHcalP7x7 <<
"/" << h5x5 <<
"/" << h7x7;
491 if (maxNearP31x31 < 0) {
493 fillEnergy(0,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
494 if (maxNearHcalP7x7 < 0) {
496 fillEnergy(1,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
497 if ((e11x11P.second) && (e15x15P.second) &&
498 (e15x15P.first-e11x11P.first)<2.0) {
500 fillEnergy(2,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
501 if (h7x7-h5x5 < 2.0) {
503 fillEnergy(3,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
506 fillEnergy(nPV+4,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
509 fillTrack(nPVBin+trackID+7, pt1,p1,eta1,phi1);
510 fillEnergy(nPVBin+trackID+3,ieta,p1,e7x7P.first,h3x3,e11x11P.first,h5x5);
519 h_ntrk[1]->Fill(ntrk,tr_eventWeight);
527 h_nHLT =
fs_->
make<TH1I>(
"h_nHLT" ,
"size of trigger Names", 1000, 0, 1000);
528 h_HLTAccept =
fs_->
make<TH1I>(
"h_HLTAccept",
"HLT Accepts for all runs", 500, 0, 500);
529 for (
int i=1;
i<=500; ++
i) h_HLTAccept->GetXaxis()->SetBinLabel(
i,
" ");
530 h_nHLTvsRN =
fs_->
make<TH2I>(
"h_nHLTvsRN" ,
"size of trigger Names vs RunNo", 2168, 190949, 193116, 100, 400, 500);
531 h_HLTCorr =
fs_->
make<TH1I>(
"h_HLTCorr",
"Correlation among different paths", 100, 0, 100);
532 h_numberPV =
fs_->
make<TH1I>(
"h_numberPV",
"Number of Primary Vertex", 100, 0, 100);
533 h_goodPV =
fs_->
make<TH1I>(
"h_goodPV",
"Number of good Primary Vertex", 100, 0, 100);
534 h_goodRun =
fs_->
make<TH1I>(
"h_goodRun",
"Number of accepted events for Run", 4000, 190000, 1940000);
535 char hname[50], htit[200];
536 std::string CollectionNames[2] = {
"Reco",
"Propagated"};
537 for (
unsigned int i=0;
i<2;
i++) {
538 sprintf(hname,
"h_nTrk_%s", CollectionNames[
i].c_str());
539 sprintf(htit,
"Number of %s tracks", CollectionNames[
i].c_str());
542 std::string TrkNames[8] = {
"All",
"Quality",
"NoIso",
"okEcal",
"EcalCharIso",
"HcalCharIso",
"EcalNeutIso",
"HcalNeutIso"};
543 std::string particle[4] = {
"Electron",
"Pion",
"Kaon",
"Proton"};
544 for (
unsigned int i=0;
i<=
nGen;
i++) {
546 sprintf(hname,
"h_pt_%s", TrkNames[
i].c_str());
547 sprintf(htit,
"p_{T} of %s tracks", TrkNames[
i].c_str());
549 sprintf(hname,
"h_pt_%s_%d", TrkNames[7].c_str(),
i-8);
550 sprintf(htit,
"p_{T} of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
551 }
else if (
i ==
nGen) {
552 sprintf(hname,
"h_pt_%s_1", TrkNames[0].c_str());
553 sprintf(htit,
"p_{T} of %s Generator tracks", TrkNames[0].c_str());
555 sprintf(hname,
"h_pt_%s_%s", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
556 sprintf(htit,
"p_{T} of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
562 sprintf(hname,
"h_p_%s", TrkNames[
i].c_str());
563 sprintf(htit,
"Momentum of %s tracks", TrkNames[
i].c_str());
565 sprintf(hname,
"h_p_%s_%d", TrkNames[7].c_str(),
i-8);
566 sprintf(htit,
"Momentum of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
567 }
else if (
i ==
nGen) {
568 sprintf(hname,
"h_p_%s_1", TrkNames[0].c_str());
569 sprintf(htit,
"Momentum of %s Generator tracks", TrkNames[0].c_str());
571 sprintf(hname,
"h_p_%s_%s", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
572 sprintf(htit,
"Momentum of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
574 h_p[
i] =
fs_->
make<TH1D>(hname, htit, 400, 0, 200.0);
578 sprintf(hname,
"h_eta_%s", TrkNames[
i].c_str());
579 sprintf(htit,
"Eta of %s tracks", TrkNames[
i].c_str());
581 sprintf(hname,
"h_eta_%s_%d", TrkNames[7].c_str(),
i-8);
582 sprintf(htit,
"Eta of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
583 }
else if (
i ==
nGen) {
584 sprintf(hname,
"h_eta_%s_1", TrkNames[0].c_str());
585 sprintf(htit,
"Eta of %s Generator tracks", TrkNames[0].c_str());
587 sprintf(hname,
"h_eta_%s_%s", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
588 sprintf(htit,
"Eta of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
594 sprintf(hname,
"h_phi_%s", TrkNames[
i].c_str());
595 sprintf(htit,
"Phi of %s tracks", TrkNames[
i].c_str());
597 sprintf(hname,
"h_phi_%s_%d", TrkNames[7].c_str(),
i-8);
598 sprintf(htit,
"Phi of %s tracks (PV=%d:%d)", TrkNames[7].c_str(),
pvBin[
i-8],
pvBin[
i-7]-1);
599 }
else if (
i ==
nGen) {
600 sprintf(hname,
"h_phi_%s_1", TrkNames[0].c_str());
601 sprintf(htit,
"Phi of %s Generator tracks", TrkNames[0].c_str());
603 sprintf(hname,
"h_phi_%s_%s", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
604 sprintf(htit,
"Phi of %s tracks (%s)", TrkNames[7].c_str(), particle[
i-8-
nPVBin].c_str());
610 for (
unsigned int i=0;
i<2;
i++) {
611 sprintf(hname,
"h_maxNearP_%s", IsolationNames[
i].c_str());
612 sprintf(htit,
"Energy in ChargeIso region for %s", IsolationNames[
i].c_str());
616 sprintf(hname,
"h_ene1_%s", IsolationNames[
i].c_str());
617 sprintf(htit,
"Energy in smaller cone for %s", IsolationNames[
i].c_str());
621 sprintf(hname,
"h_ene2_%s", IsolationNames[
i].c_str());
622 sprintf(htit,
"Energy in bigger cone for %s", IsolationNames[
i].c_str());
626 sprintf(hname,
"h_ediff_%s", IsolationNames[
i].c_str());
627 sprintf(htit,
"Energy in NeutralIso region for %s", IsolationNames[
i].c_str());
631 std::string energyNames[6]={
"E_{7x7}",
"H_{3x3}",
"(E_{7x7}+H_{3x3})",
632 "E_{11x11}",
"H_{5x5}",
"{E_{11x11}+H_{5x5})"};
634 for (
int ip=0; ip<
nPBin; ++ip) {
635 for (
int ie=0; ie<
nEtaBin; ++ie) {
636 for (
int j=0; j<6; ++j) {
637 sprintf(hname,
"h_energy_%d_%d_%d_%d",
i, ip, ie, j);
639 sprintf(htit,
"%s/p (p=%4.1f:%4.1f; i#eta=%d:%d) for tracks with %s",
641 (
etaBin[ie+1]-1), TrkNames[
i+4].c_str());
642 }
else if (
i < 4+nPVBin) {
643 sprintf(htit,
"%s/p (p=%4.1f:%4.1f, i#eta=%d:%d, PV=%d:%d) for tracks with %s",
646 TrkNames[7].c_str());
648 sprintf(htit,
"%s/p (p=%4.1f:%4.1f, i#eta=%d:%d %s) for tracks with %s",
650 (
etaBin[ie+1]-1), particle[
i-4-nPVBin].c_str(),
651 TrkNames[7].c_str());
689 char hname[100], htit[400];
692 sprintf(hname,
"h_HLTAccepts_%i", iRun.
run());
693 sprintf(htit,
"HLT Accepts for Run No %i", iRun.
run());
694 TH1I *hnew =
fs_->
make<TH1I>(hname, htit, 500, 0, 500);
695 for (
int i=1;
i<=500; ++
i) hnew->GetXaxis()->SetBinLabel(
i,
" ");
738 double enHcal1,
double enEcal2,
double enHcal2) {
741 if (p >=
pBin[
i] && p <
pBin[
i+1]) { ip =
i;
break; }
746 if (ip >= 0 && ie >= 0 && enEcal1 > 0.02 && enHcal1 > 0.1) {
758 int length = str.length();
759 for (
int i=0;
i<length-2;
i++){
760 if (str[
i]==
'_' && str[
i+1]==
'v' && isdigit(str.at(
i+2))) {
762 truncated_str = str.substr(0,z);
765 return(truncated_str);
772 reco::GenParticleCollection::const_iterator
p;
774 for (p=genParticles->begin(),indx=0; p!=genParticles->end(); ++
p,++indx) {
776 int idx = (pdgId == 11) ? 1 :
777 ((pdgId == 211) ? 2 : ((pdgId == 321) ? 3 : ((pdgId == 2212) ? 4 : 0)));
779 double dEta = pTrack->
eta() - p->momentum().Eta();
780 double phi1 = pTrack->
phi();
781 double phi2 = p->momentum().Phi();
782 if (phi1 < 0) phi1 += 2.0*
M_PI;
783 if (phi2 < 0) phi2 += 2.0*
M_PI;
784 double dPhi = phi1-phi2;
786 else if (dPhi < -
M_PI) dPhi += 2.*
M_PI;
787 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
789 mindR =
dR;
id =
idx;
void fillEnergy(int, int, double, double, double, double, double)
double p() const
momentum vector magnitude
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
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
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)
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
bool accept() const
Has at least one path accepted the event?
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_
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)
std::vector< double > puWeights_
std::vector< double > tr_MaxNearHcalP7x7
std::string truncate_str(const std::string &)
unsigned int size() const
Get number of paths stored.
double pt() const
track transverse momentum
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
edm::EDGetTokenT< LumiDetails > tok_lumi
bool quality(const TrackQuality) const
Track quality.
std::vector< double > tr_H7x7
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
T const * product() const
std::vector< bool > tr_SE15x15P
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
std::vector< double > tr_H5x5
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)