87 std::cout <<
"Parameters read from config file \n"
89 <<
"\t theTrackQuality " << theTrackQuality
118 if (
verbosity%10 > 0)
std::cout <<
"Event starts====================================" << std::endl;
119 int RunNo = iEvent.
id().
run();
120 int EvtNo = iEvent.
id().
event();
134 iEvent.
getByLabel(
"generalTracks", trkCollection);
135 reco::TrackCollection::const_iterator trkItr;
144 std::cout <<
"RunNo " << RunNo <<
" EvtNo " << EvtNo <<
" Lumi " << Lumi
145 <<
" Bunch " << Bunch <<
" mybxlumi " << mybxlumi << std::endl;
147 edm::InputTag triggerEvent_ (
"hltTriggerSummaryAOD",
"",
"HLT");
150 iEvent.
getByLabel(triggerEvent_,triggerEventHandle);
151 if (!triggerEventHandle.
isValid())
152 std::cout <<
"Error! Can't get the product "<< triggerEvent_.
label() << std::endl;
154 triggerEvent = *(triggerEventHandle.
product());
158 edm::InputTag theTriggerResultsLabel (
"TriggerResults",
"",
"HLT");
160 iEvent.
getByLabel( theTriggerResultsLabel, triggerResults);
162 sprintf(TrigName,
"HLT_IsoTrack%s",
Det.c_str());
163 if (triggerResults.
isValid()) {
164 std::vector<std::string> modules;
165 h_nHLT->Fill(triggerResults->size());
168 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
169 int hlt(-1), preL1(-1), preHLT(-1), prescale(-1);
170 for (
unsigned int i=0;
i<triggerResults->size();
i++) {
173 if (triggerNames_[i].
find(TrigName)!=std::string::npos) {
175 hlt = triggerResults->accept(i);
178 prescale = preL1*preHLT;
180 std::cout << triggerNames_[
i] <<
" accept " << hlt <<
" preL1 "
181 << preL1 <<
" preHLT " << preHLT << std::endl;
183 std::vector<math::XYZTLorentzVector> vec[3];
187 TrigList.insert(std::pair<unsigned int, unsigned int>(RunNo,1));
191 for (
unsigned int ifilter=0; ifilter<triggerEvent.
sizeFilters(); ++ifilter) {
192 std::vector<int>
Keys;
195 for (
unsigned int imodule=0; imodule<moduleLabels.size(); imodule++) {
196 if (label.find(moduleLabels[imodule]) != std::string::npos) {
198 for (
unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.
filterKeys(ifilter).size(); ++ifiltrKey) {
199 Keys.push_back(triggerEvent.
filterKeys(ifilter)[ifiltrKey]);
202 if(label.find(
"L2Filter") != std::string::npos) {
203 vec[1].push_back(v4);
204 }
else if (label.find(
"L3Filter") != std::string::npos) {
205 vec[2].push_back(v4);
207 vec[0].push_back(v4);
211 std::cout <<
"key " << ifiltrKey <<
" : pt " << TO.
pt() <<
" eta " << TO.
eta() <<
" phi " << TO.
phi() <<
" mass " << TO.
mass() <<
" Id " << TO.
id() << std::endl;
219 for (
int j=0;
j<3;
j++) {
220 for (
unsigned int k=0;
k<vec[
j].size();
k++) {
221 if (
verbosity%10 > 0)
std::cout <<
"vec[" <<
j <<
"][" <<
k <<
"] pt " << vec[
j][
k].pt() <<
" eta " << vec[
j][
k].eta() <<
" phi " << vec[
j][
k].phi() << std::endl;
226 double deta, dphi, dr;
228 for (
int lvl=1; lvl<3; lvl++) {
229 for (
unsigned int i=0; i<vec[lvl].size(); i++) {
230 deta =
dEta(vec[0][0],vec[lvl][i]);
231 dphi =
dPhi(vec[0][0],vec[lvl][i]);
232 dr =
dR(vec[0][0],vec[lvl][i]);
233 if (
verbosity%10 > 0)
std::cout <<
"lvl " <<lvl <<
" i " << i <<
" deta " << deta <<
" dphi " << dphi <<
" dR " << dr << std::endl;
242 for (
unsigned int k=0;
k<vec[2].size(); ++
k) {
245 if (
verbosity%10 > 0)
std::cout <<
"L3obj: pt " << vec[2][
i].pt() <<
" eta " << vec[2][
i].eta() <<
" phi " << vec[2][
i].phi() << std::endl;
246 for (
unsigned int j=0;
j<vec[1].size();
j++) {
247 dr =
dR(vec[2][
k],vec[1][
j]);
266 if (
verbosity%10 > 0)
std::cout <<
"vec[2][k].eta() " << vec[2][
k].eta() <<
" vec[k][0].phi " << vec[2][
k].phi() << std::endl;
267 reco::TrackCollection::const_iterator goodTk = trkCollection->end();
269 double mindP = 9999.9;
270 for (trkItr=trkCollection->begin();
271 trkItr!=trkCollection->end(); trkItr++) {
273 trkItr->pz(), trkItr->p());
283 std::cout <<
"track: pt " << v4.pt() <<
" eta " << v4.eta()
284 <<
" phi " << v4.phi() <<
" DR " << deltaR
288 if (mindR < 0.03 && mindP > 0.1) {
289 for (trkItr=trkCollection->begin();
290 trkItr!=trkCollection->end(); trkItr++) {
292 trkItr->pz(), trkItr->p());
295 if (dp<mindP && deltaR<0.03) {
315 iEvent.
getByLabel(
"offlinePrimaryVertices",recVtxs);
318 iEvent.
getByLabel(
"offlineBeamSpot", beamSpotH);
320 if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
321 leadPV =
math::XYZPoint( (*recVtxs)[0].
x(),(*recVtxs)[0].
y(), (*recVtxs)[0].
z() );
322 }
else if (beamSpotH.
isValid()) {
323 leadPV = beamSpotH->position();
326 std::cout <<
"Primary Vertex " << leadPV;
328 << beamSpotH->position();
332 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
334 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
338 iEvent.
getByLabel(
"ecalRecHit",
"EcalRecHitsEB",barrelRecHitsHandle);
339 iEvent.
getByLabel(
"ecalRecHit",
"EcalRecHitsEE",endcapRecHitsHandle);
341 unsigned int nTracks=0, ngoodTk=0, nselTk=0;
343 for (trkDetItr = trkCaloDirections.begin(); trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++){
344 bool l3Track = (trkDetItr->trkItr == goodTk);
345 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
347 pTrack->
pz(), pTrack->
p());
349 double eMipDR=9999., e_inCone=0, conehmaxNearP=0, mindR=999.9;
350 if (trkDetItr->okHCAL) {
354 for (
unsigned k=0; k<vec[0].size(); ++
k) {
356 if (deltaR<mindR) mindR =
deltaR;
358 if (selectTk && trkDetItr->okECAL && trkDetItr->okHCAL) {
360 int nRH_eMipDR=0, nNearTRKs=0;
362 trkDetItr->pointHCAL, trkDetItr->pointECAL,
363 a_neutR1, trkDetItr->directionECAL, nRH_eMipDR);
365 trkDetItr->pointHCAL, trkDetItr->pointECAL,
366 a_neutR2, trkDetItr->directionECAL, nRH_eMipDR);
367 eMipDR =
spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
368 trkDetItr->pointHCAL, trkDetItr->pointECAL,
369 a_mipR, trkDetItr->directionECAL, nRH_eMipDR);
372 if (eMipDR<1.0) nselTk++;
378 fillCuts(0, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>
dr_L1));
391 fillCuts(1, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>
dr_L1));
420 std::cout<<
"New trigger menu found !!!" << std::endl;
422 for (
unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
424 std::cout << triggerNames_[itrig] <<
" " << triggerindx <<
" ";
425 if (triggerindx >=
n)
426 std::cout <<
"does not exist in the current menu" << std::endl;
437 char hname[100], htit[100];
439 "Reco",
"RecoMatch",
"RecoNoMatch",
440 "L2Match",
"L2NoMatch",
"L3Match",
"L3NoMatch",
441 "HLTTrk",
"HLTGoodTrk",
"HLTIsoTrk",
"HLTMip",
"HLTSelect",
442 "nonHLTTrk",
"nonHLTGoodTrk",
"nonHLTIsoTrk",
"nonHLTMip",
"nonHLTSelect"};
443 std::string pairs[6] = {
"L2L3",
"L2L3Match",
"L2L3NoMatch",
"L3Reco",
"L3RecoMatch",
"L3RecoNoMatch"};
447 h_nHLT =
fs->
make<TH1I>(
"h_nHLT" ,
"size of rigger Names", 1000, 1, 1000);
448 h_HLT =
fs->
make<TH1I>(
"h_HLT" ,
"HLT accept", 3, -1, 2);
449 h_PreL1 =
fs->
make<TH1I>(
"h_PreL1",
"L1 Prescale", 500, 0, 500);
451 h_Pre =
fs->
make<TH1I>(
"h_Pre",
"Prescale", 3000, 0, 3000);
452 h_nL3Objs =
fs->
make<TH1I>(
"h_nL3Objs",
"Number of L3 objects", 10, 0, 10);
454 h_PreL1wt =
fs->
make<TH1D>(
"h_PreL1wt",
"Weighted L1 Prescale", 500, 0, 500);
455 h_PreHLTwt =
fs->
make<TH1D>(
"h_PreHLTwt",
"Weighted HLT Prescale", 500, 0, 100);
458 for(
int ipair=0; ipair<6; ipair++) {
459 sprintf(hname,
"h_dEta%s", pairs[ipair].c_str());
460 sprintf(htit,
"dEta for %s", pairs[ipair].c_str());
461 h_dEta[ipair] =
fs->
make<TH1D>(hname, htit, 200, -10.0, 10.0);
462 h_dEta[ipair]->GetXaxis()->SetTitle(
"d#eta");
464 sprintf(hname,
"h_dPhi%s", pairs[ipair].c_str());
465 sprintf(htit,
"dPhi for %s", pairs[ipair].c_str());
466 h_dPhi[ipair] =
fs->
make<TH1D>(hname, htit, 140, -7.0, 7.0);
467 h_dPhi[ipair]->GetXaxis()->SetTitle(
"d#phi");
469 sprintf(hname,
"h_dPt%s", pairs[ipair].c_str());
470 sprintf(htit,
"dPt for %s objects", pairs[ipair].c_str());
471 h_dPt[ipair] =
fs->
make<TH1D>(hname, htit, 400, -200.0, 200.0);
472 h_dPt[ipair]->GetXaxis()->SetTitle(
"dp_{T} (GeV)");
474 sprintf(hname,
"h_dP%s", pairs[ipair].c_str());
475 sprintf(htit,
"dP for %s objects", pairs[ipair].c_str());
476 h_dP[ipair] =
fs->
make<TH1D>(hname, htit, 400, -200.0, 200.0);
477 h_dP[ipair]->GetXaxis()->SetTitle(
"dP (GeV)");
479 sprintf(hname,
"h_dinvPt%s", pairs[ipair].c_str());
480 sprintf(htit,
"dinvPt for %s objects", pairs[ipair].c_str());
482 h_dinvPt[ipair]->GetXaxis()->SetTitle(
"d(1/p_{T})");
484 sprintf(hname,
"h_mindR%s", pairs[ipair].c_str());
485 sprintf(htit,
"mindR for %s objects", pairs[ipair].c_str());
487 h_mindR[ipair]->GetXaxis()->SetTitle(
"dR");
490 for(
int ilevel=0; ilevel<20; ilevel++) {
491 sprintf(hname,
"h_p%s", levels[ilevel].c_str());
492 sprintf(htit,
"p for %s objects", levels[ilevel].c_str());
493 h_p[ilevel] =
fs->
make<TH1D>(hname, htit, 100, 0.0, 500.0);
494 h_p[ilevel]->GetXaxis()->SetTitle(
"p (GeV)");
496 sprintf(hname,
"h_pt%s", levels[ilevel].c_str());
497 sprintf(htit,
"pt for %s objects", levels[ilevel].c_str());
498 h_pt[ilevel] =
fs->
make<TH1D>(hname, htit, 100, 0.0, 500.0);
499 h_pt[ilevel]->GetXaxis()->SetTitle(
"p_{T} (GeV)");
501 sprintf(hname,
"h_eta%s", levels[ilevel].c_str());
502 sprintf(htit,
"eta for %s objects", levels[ilevel].c_str());
503 h_eta[ilevel] =
fs->
make<TH1D>(hname, htit, 100, -5.0, 5.0);
504 h_eta[ilevel]->GetXaxis()->SetTitle(
"#eta");
506 sprintf(hname,
"h_phi%s", levels[ilevel].c_str());
507 sprintf(htit,
"phi for %s objects", levels[ilevel].c_str());
508 h_phi[ilevel] =
fs->
make<TH1D>(hname, htit, 70, -3.5, 3.50);
509 h_phi[ilevel]->GetXaxis()->SetTitle(
"#phi");
511 for(
int lvl=0; lvl<2; lvl++) {
512 sprintf(hname,
"h_dEtaL1%s", levels[lvl+1].c_str());
513 sprintf(htit,
"dEta for L1 and %s objects", levels[lvl+1].c_str());
516 sprintf(hname,
"h_dPhiL1%s", levels[lvl+1].c_str());
517 sprintf(htit,
"dPhi for L1 and %s objects", levels[lvl+1].c_str());
520 sprintf(hname,
"h_dRL1%s", levels[lvl+1].c_str());
521 sprintf(htit,
"dR for L1 and %s objects", levels[lvl+1].c_str());
522 h_dRL1[lvl] =
fs->
make<TH1D>(hname, htit, 100, 0.0, 10.0);
525 for(
int icut=0; icut<2; icut++) {
526 sprintf(hname,
"h_eMip%s", cuts[icut].c_str());
527 sprintf(htit,
"eMip for %s tracks", cuts[icut].c_str());
528 h_eMip[icut] =
fs->
make<TH1D>(hname, htit, 200, 0.0, 10.0);
529 h_eMip[icut]->GetXaxis()->SetTitle(
"E_{Mip} (GeV)");
531 sprintf(hname,
"h_eMaxNearP%s", cuts[icut].c_str());
532 sprintf(htit,
"eMaxNearP for %s tracks", cuts[icut].c_str());
534 h_eMaxNearP[icut]->GetXaxis()->SetTitle(
"E_{MaxNearP} (GeV)");
536 sprintf(hname,
"h_eNeutIso%s", cuts[icut].c_str());
537 sprintf(htit,
"eNeutIso for %s ", cuts[icut].c_str());
539 h_eNeutIso[icut]->GetXaxis()->SetTitle(
"E_{NeutIso} (GeV)");
541 for (
int kcut=0; kcut<2; ++kcut) {
542 sprintf(hname,
"h_etaCalibTracks%s%d", cuts[icut].c_str(), kcut);
543 sprintf(htit,
"etaCalibTracks for %s (%s)", cuts[icut].c_str(), cuts2[kcut].c_str());
547 sprintf(hname,
"h_etaMipTracks%s%d", cuts[icut].c_str(), kcut);
548 sprintf(htit,
"etaMipTracks for %s (%s)", cuts[icut].c_str(), cuts2[kcut].c_str());
556 unsigned int preL1, preHLT;
557 std::map<unsigned int, unsigned int>::iterator itr;
558 std::map<unsigned int, const std::pair<int, int>>::iterator itrPre;
559 std::cout <<
"RunNo vs HLT accepts for " <<
Det << std::endl;
567 preL1 = (itrPre->second).
first;
568 preHLT = (itrPre->second).
second;
569 std::cout << itr->first <<
" " << itr->second <<
" " << itrPre->first <<
" " << preL1 <<
" " << preHLT << std::endl;
570 g_Accepts->Fill(itr->first, itr->second);
571 g_PreL1->Fill(itr->first, preL1);
572 g_PreHLT->Fill(itr->first, preHLT);
573 g_Pre->Fill(itr->first, preL1*preHLT);
600 h_p[indx]->Fill(vec.r());
601 h_pt[indx]->Fill(vec.pt());
602 h_eta[indx]->Fill(vec.eta());
603 h_phi[indx]->Fill(vec.phi());
608 double dr =
dR(vec1,vec2);
609 double deta =
dEta(vec1, vec2);
610 double dphi =
dPhi(vec1, vec2);
611 double dpt =
dPt(vec1, vec2);
612 double dp =
dP(vec1, vec2);
613 double dinvpt =
dinvPt(vec1, vec2);
614 h_dEta[indx] ->Fill(deta);
615 h_dPhi[indx] ->Fill(dphi);
616 h_dPt[indx] ->Fill(dpt);
617 h_dP[indx] ->Fill(dp);
620 if (debug)
std::cout <<
"mindR for index " << indx <<
" is " << dr <<
" deta " << deta
621 <<
" dphi " << dphi <<
" dpt " << dpt <<
" dinvpt " << dinvpt <<std::endl;
625 h_eMip[indx] ->Fill(eMipDR);
628 if (conehmaxNearP <
cutCharge && eMipDR <
cutMip && vec.r()<60 && vec.r()>40) {
639 return (vec1.eta()-vec2.eta());
644 double phi1 = vec1.phi();
645 if (phi1 < 0) phi1 += 2.0*
M_PI;
646 double phi2 = vec2.phi();
647 if (phi2 < 0) phi2 += 2.0*
M_PI;
648 double dphi = phi1-phi2;
650 else if (dphi < -
M_PI) dphi += 2.*
M_PI;
655 double deta =
dEta(vec1,vec2);
656 double dphi =
dPhi(vec1,vec2);
661 return (vec1.pt()-vec2.pt());
665 return (
std::abs(vec1.r()-vec2.r()));
669 return ((1/vec1.pt())-(1/vec2.pt()));
unsigned int size() const
number of trigger paths in trigger table
double p() const
momentum vector magnitude
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
std::string theTrackQuality
const Keys & filterKeys(trigger::size_type index) const
int bunchCrossing() const
edm::LuminosityBlockNumber_t luminosityBlock() const
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
double px() const
x coordinate of momentum vector
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
double dP(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Strings const & triggerNames() const
TH1D * h_etaMipTracks[2][2]
HLTConfigProvider hltConfig_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
Single trigger physics object (e.g., an isolated muon)
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
TH1D * h_etaCalibTracks[2][2]
double dinvPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
void fillHist(int, math::XYZTLorentzVector &)
void addDefault(ParameterSetDescription const &psetDescription)
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
const TriggerObjectCollection & getObjects() const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::vector< double > vec1
int ieta() const
get the cell ieta
virtual void analyze(const edm::Event &, const edm::EventSetup &)
LuminosityBlock const & getLuminosityBlock() const
IsoTrig(const edm::ParameterSet &)
std::map< unsigned int, const std::pair< int, int > > TrigPreList
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double dPhi(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
double dR(double eta1, double eta2, double phi1, double phi2)
double pz() const
z coordinate of momentum vector
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
const edm::InputTag filterTag(trigger::size_type index) const
static TrackQuality qualityByName(const std::string &name)
virtual void endRun(edm::Run const &, edm::EventSetup const &)
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< size_type > Keys
double dEta(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
T const * product() const
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger) const
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
spr::trackSelectionParameters selectionParameters
std::map< unsigned int, unsigned int > TrigList
double eCone_ecal(const CaloGeometry *geo, edm::Handle< T > &barrelhits, edm::Handle< T > &endcaphits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500)
reco::TrackBase::TrackQuality minQuality
void fillDifferences(int, math::XYZTLorentzVector &, math::XYZTLorentzVector &, bool)
T * make() const
make new ROOT object
double dPt(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
edm::Service< TFileService > fs
tuple size
Write out results.
void fillCuts(int, double, double, double, math::XYZTLorentzVector &, int, bool)
double py() const
y coordinate of momentum vector
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
virtual void beginRun(edm::Run const &, edm::EventSetup const &)