12 #include "TDirectory.h"
14 #include "TLorentzVector.h"
15 #include "TInterpreter.h"
138 changed(
false), nRun(0), nAll(0), nGood(0),
139 t_trgbits(0), t_DetIds(0), t_HitEnergies(0) {
190 std::vector<int>dummy(trigNames.size(),0);
194 std::cout <<
"Parameters read from config file \n"
196 <<
"\t theTrackQuality " << theTrackQuality
206 <<
"\t a_coneR " << a_coneR
209 <<
"\t qcdMC " <<
qcdMC
211 std::cout <<
"Process " << processName <<
" L1Filter:" << l1Filter
212 <<
" L2Filter:" << l2Filter <<
" L3Filter:" << l3Filter
214 std::cout << trigNames.size() <<
" triggers to be studied";
215 for (
unsigned int k=0;
k<trigNames.size(); ++
k)
241 <<
" starts ==========" << std::endl;
259 reco::TrackCollection::const_iterator trkItr;
270 std::vector<PileupSummaryInfo>::const_iterator PVI;
271 for (PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
272 int BX = PVI->getBunchCrossing();
280 int ivtx = (int)(
vbin.size()-2);
281 for (
unsigned int iv=1; iv<
vbin.size(); ++iv) {
292 << ivtx <<
":" <<
vbin.size() << std::endl;
298 for (
unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {
300 double genJetPt = genJet.
pt();
301 double genJetEta = genJet.
eta();
304 if (genJetEta>-2.5 && genJetEta<2.5) {
317 if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
318 leadPV =
math::XYZPoint( (*recVtxs)[0].
x(),(*recVtxs)[0].
y(), (*recVtxs)[0].
z() );
319 }
else if (beamSpotH.
isValid()) {
320 leadPV = beamSpotH->position();
324 std::cout <<
"Primary Vertex " << leadPV;
326 << beamSpotH->position();
339 for (rhitItr=hbhe->begin();rhitItr!=hbhe->end();rhitItr++) {
340 double rec_energy = rhitItr->energy();
341 int rec_ieta = rhitItr->id().ieta();
342 int rec_depth = rhitItr->id().depth();
343 int rec_zside = rhitItr->id().zside();
344 double num1_1 = rec_zside*(rec_ieta+0.2*(rec_depth-1));
347 std::cout <<
"detid/rechit/ieta/zside/depth/num = " << rhitItr->id()
348 <<
"/" << rec_energy <<
"/" << rec_ieta <<
"/" << rec_zside
349 <<
"/" << rec_depth <<
"/" << num1_1 << std::endl;
358 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
360 trkCaloDirections, ((
verbosity/100)%10>2));
361 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
362 for (trkDetItr = trkCaloDirections.begin();
363 trkDetItr != trkCaloDirections.end(); trkDetItr++) {
364 if (trkDetItr->okHCAL) {
366 int tk_ieta = detId.
ieta();
367 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
368 double tk_p = pTrack->
p();
372 std::cout <<
"Fill for " << tk_ieta <<
" in " << ivtx <<
":"
373 <<
h_tketav1[ivtx][0]->GetName() << std::endl;
375 for (
unsigned int k=1;
k<
pbin.size(); ++
k) {
380 std::cout <<
"Fill for " << tk_ieta <<
":" << tk_p <<
" in " << ivtx
381 <<
":" <<
h_tketav1[ivtx][
k]->GetName() << std::endl;
396 if (!triggerEventHandle.
isValid()) {
402 triggerEvent = *(triggerEventHandle.
product());
408 if (triggerResults.isValid()) {
409 std::vector<std::string>
modules;
411 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
412 for (
unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
414 int hlt = triggerResults->accept(iHLT);
416 if (triggerNames_[iHLT].
find(
trigNames[
i].c_str())!=std::string::npos) {
425 std::cout <<
"This is the trigger we are looking for "
426 << triggerNames_[iHLT] <<
" Flag " << hlt <<
":"
435 std::vector<math::XYZTLorentzVector> vec[3];
437 for (
unsigned int ifilter=0; ifilter<triggerEvent.
sizeFilters();
439 std::vector<int>
Keys;
442 for (
unsigned int imodule=0; imodule<moduleLabels.size();
444 if (label.find(moduleLabels[imodule]) != std::string::npos) {
448 for (
unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.
filterKeys(ifilter).size(); ++ifiltrKey) {
449 Keys.push_back(triggerEvent.
filterKeys(ifilter)[ifiltrKey]);
453 if (label.find(
"hltL1s") != std::string::npos) {
454 vec[0].push_back(v4);
455 }
else if (label.find(
"PFJet") != std::string::npos) {
456 vec[2].push_back(v4);
458 vec[1].push_back(v4);
461 if (label.find(
l2Filter) != std::string::npos) {
462 vec[1].push_back(v4);
463 }
else if (label.find(
l3Filter) != std::string::npos) {
464 vec[2].push_back(v4);
465 }
else if (label.find(
l1Filter) != std::string::npos ||
467 vec[0].push_back(v4);
472 std::cout <<
"key " << ifiltrKey <<
" : pt " << TO.
pt()
473 <<
" eta " << TO.
eta() <<
" phi " << TO.
phi()
474 <<
" mass " << TO.
mass() <<
" Id " << TO.
id()
480 <<
":" << vec[1].size() <<
":"
481 << vec[2].size() << std::endl;
490 for (
int lvl=1; lvl<3; lvl++) {
491 for (
unsigned int i=0;
i<vec[lvl].size();
i++) {
492 dr =
dR(vec[0][0],vec[lvl][
i]);
495 <<
" dR " << dr << std::endl;
499 mindRvec1 = vec[lvl][
i];
507 if (vec[2].
size()>0) {
513 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
514 unsigned int nTracks(0), nselTracks(0);
515 for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
516 trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
517 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
519 pTrack->
pz(), pTrack->
p());
522 std::cout <<
"This track : " << nTracks <<
" (pt/eta/phi/p) :"
523 << pTrack->
pt() <<
"/" << pTrack->
eta() <<
"/"
524 << pTrack->
phi() <<
"/" << pTrack->
p() << std::endl;
529 for (
unsigned int k=0;
k<vec[2].size(); ++
k) {
530 dr =
dR(vec[2][
k],v4);
533 mindRvec2 = vec[2][
k];
540 << mindRvec2 <<
" and from L1 " <<
t_mindR1 <<std::endl;
547 oneCutParameters.
maxDzPV = 100;
553 oneCutParameters.
maxDzPV = 100;
560 if (trkDetItr->okHCAL) {
566 std::cout <<
"qltyFlag|okECAL|okHCAL : " << qltyFlag <<
"|"
567 << trkDetItr->okECAL <<
"/" << trkDetItr->okHCAL
570 t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL);
573 for (
unsigned int k=1;
k<
pbin.size(); ++
k) {
582 for (
unsigned int k=1;
k<
pbin.size(); ++
k) {
588 int nRH_eMipDR(0), nNearTRKs(0), nRecHits(-999);
591 trkDetItr->pointHCAL,
592 trkDetItr->pointECAL,
593 a_mipR, trkDetItr->directionECAL,
596 std::vector<DetId> ids;
599 trkDetItr->directionHCAL,nRecHits,
601 for (
unsigned int k=0;
k<ids.size(); ++
k) {
609 for (
unsigned int k=1;
k<
pbin.size(); ++
k) {
617 for (
unsigned int k=1;
k<
pbin.size(); ++
k) {
626 for (
unsigned int k=1;
k<
pbin.size(); ++
k) {
638 std::cout <<
"This track : " << nTracks <<
" (pt/eta/phi/p) :"
639 << pTrack->
pt() <<
"/" << pTrack->
eta() <<
"/"
640 << pTrack->
phi() <<
"/" <<
t_p << std::endl;
646 for (
unsigned int lll=0;lll<
t_DetIds->size();lll++) {
675 std::cout<<
"New trigger menu found !!!" << std::endl;
677 for (
unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
679 std::cout << triggerNames_[itrig] <<
" " << triggerindx <<
" ";
680 if (triggerindx >=
n)
681 std::cout <<
"does not exist in the current menu" << std::endl;
698 double prange[5] = {20,30,40,60,100};
699 for (
int k=0;
k<5; ++
k)
pbin.push_back(prange[
k]);
701 "Charge Isolation",
"MIP Cut",
"L1 Cut"};
702 double vrange[6] = {0, 10, 20, 30, 40, 1000};
703 for (
int k=0; k<6; ++
k)
vbin.push_back(vrange[k]);
705 for (
unsigned int k=0; k<
pbin.size(); ++
k) {
706 if (k == 0) sprintf (namp,
"all momentum");
707 else sprintf (namp,
"p = %4.0f:%4.0f GeV",
pbin[k-1],
pbin[k]);
708 sprintf (name,
"TrackEta0%d", k);
709 sprintf (title,
"Track #eta for tracks with %s (%s)",namp,type[0].c_str());
711 sprintf (name,
"TrackEta1%d", k);
712 sprintf (title,
"Track #eta for tracks with %s (%s)",namp,type[1].c_str());
714 sprintf (name,
"TrackEta2%d", k);
715 sprintf (title,
"Track #eta for tracks with %s (%s)",namp,type[2].c_str());
717 sprintf (name,
"TrackEta3%d", k);
718 sprintf (title,
"Track #eta for tracks with %s (%s)",namp,type[3].c_str());
720 sprintf (name,
"TrackEta4%d", k);
721 sprintf (title,
"Track #eta for tracks with %s (%s)",namp,type[4].c_str());
723 sprintf (name,
"TrackEta5%d", k);
724 sprintf (title,
"Track #eta for tracks with %s (%s)",namp,type[5].c_str());
726 for (
unsigned int l=0;
l<
vbin.size()-1; ++
l) {
727 int v1 = (int)(
vbin[
l]);
728 int v2 = (int)(
vbin[l+1]);
729 sprintf (name,
"TrackEta1%dVtx%d", k, l);
730 sprintf (title,
"Track #eta for tracks with %s (%s and PU %d:%d)",namp,type[0].c_str(),v1,v2);
732 sprintf (name,
"TrackEta2%dVtx%d", k, l);
733 sprintf (title,
"Track #eta for tracks with %s (%s and PU %d:%d)",namp,type[5].c_str(),v1,v2);
737 h_jetpt[0] =
fs->
make<TH1F>(
"Jetpt0",
"Jet p_T (All)", 500,0.,2500.);
738 h_jetpt[1] =
fs->
make<TH1F>(
"Jetpt1",
"Jet p_T (All Weighted)", 500,0.,2500.);
739 h_jetpt[2] =
fs->
make<TH1F>(
"Jetpt2",
"Jet p_T (|#eta| < 2.5)", 500,0.,2500.);
740 h_jetpt[3] =
fs->
make<TH1F>(
"Jetpt3",
"Jet p_T (|#eta| < 2.5 Weighted)", 500,0.,2500.);
741 tree =
fs->
make<TTree>(
"CalibTree",
"CalibTree");
744 tree->Branch(
"t_Run", &
t_Run,
"t_Run/I");
756 tree->Branch(
"t_p", &
t_p,
"t_p/D");
767 t_DetIds =
new std::vector<unsigned int>();
770 tree->Branch(
"t_DetIds",
"std::vector<unsigned int>", &
t_DetIds);
771 tree->Branch(
"t_HitEnergies",
"std::vector<double>", &t_HitEnergies);
772 tree->Branch(
"t_trgbits",
"std::vector<bool>", &t_trgbits);
778 <<
nAll <<
" events from " <<
nRun <<
" runs";
811 return reco::deltaR(vec1.eta(),vec1.phi(),vec2.eta(),vec2.phi());
std::vector< int > trigPass
unsigned int size() const
number of trigger paths in trigger table
double p() const
momentum vector magnitude
std::vector< bool > * t_trgbits
edm::InputTag triggerEvent_
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)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
const Keys & filterKeys(trigger::size_type index) const
std::vector< HBHERecHit >::const_iterator const_iterator
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
int bunchCrossing() const
std::vector< int > trigKount
edm::LuminosityBlockNumber_t luminosityBlock() const
std::vector< std::string > trigNames
double phi() const
azimuthal angle of momentum vector
T * make(const Args &...args) const
make new ROOT object
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
double deltaR(const T1 &t1, const T2 &t2)
double px() const
x coordinate of momentum vector
virtual void endRun(edm::Run const &, edm::EventSetup const &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::InputTag theTriggerResultsLabel
Strings const & triggerNames() const
std::vector< double > vbin
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
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)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes
double eta() const
pseudorapidity of momentum vector
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< std::string > HLTNames
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
const TriggerObjectCollection & getObjects() const
std::vector< double > vec1
double pt() const
track transverse momentum
int ieta() const
get the cell ieta
Jets made from MC generator particles.
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, bool debug=false)
edm::Service< TFileService > fs
static std::string const triggerResults
IsoTrackCalibration(const edm::ParameterSet &)
std::vector< double > * t_HitEnergies
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
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
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
const edm::InputTag filterTag(trigger::size_type index) const
static TrackQuality qualityByName(const std::string &name)
T const * product() const
double eCone_hcal(const CaloGeometry *geo, edm::Handle< T > &hits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int detOnly=-1, bool debug=false)
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > tok_pu_
std::string theTrackQuality
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< size_type > Keys
double dR(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
std::vector< double > pbin
T const * product() const
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
spr::trackSelectionParameters selectionParameters
reco::TrackBase::TrackQuality minQuality
edm::EDGetTokenT< reco::GenJetCollection > tok_jets_
volatile std::atomic< bool > shutdown_flag false
std::vector< unsigned int > * t_DetIds
HLTConfigProvider hltConfig_
tuple size
Write out results.
double py() const
y coordinate of momentum vector
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_