12 #include "TDirectory.h"
14 #include "TLorentzVector.h"
15 #include "TInterpreter.h"
84 int fillTree(std::vector< math::XYZTLorentzVector>& vecL1,
85 std::vector< math::XYZTLorentzVector>& vecL3,
87 std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
133 usesResource(
"TFileService");
136 const double isolationRadius(28.9);
180 tok_bs_ = consumes<reco::BeamSpot>(labelBS);
187 edm::LogInfo(
"HcalIsoTrack") <<
"Labels used " << triggerEvent_ <<
" "
188 << theTriggerResultsLabel_ <<
" "
189 << labelBS <<
" " << labelRecVtx_ <<
" "
190 << labelGenTrack_ <<
" "
199 edm::LogInfo(
"HcalIsoTrack") <<
"Labels used " << triggerEvent_
200 <<
"\n " << theTriggerResultsLabel_
203 <<
"\n " << labelGenTrack_
209 edm::LogInfo(
"HcalIsoTrack") <<
"Parameters read from config file \n"
211 <<
"\t theTrackQuality " << theTrackQuality_
221 <<
"\t a_coneR " << a_coneR_
222 <<
"\t a_charIsoR " << a_charIsoR_
224 <<
"\t hcalScale_ " << hcalScale_
225 <<
"\t useRaw_ " << useRaw_
226 <<
"\t ignoreTrigger_ " << ignoreTrigger_
228 edm::LogInfo(
"HcalIsoTrack") <<
"Process " << processName_ <<
" L1Filter:"
229 << l1Filter_ <<
" L2Filter:" << l2Filter_
263 reco::TrackCollection::const_iterator trkItr;
264 if (!trkCollection.
isValid()) {
279 if (recVtxs.
isValid() && recVtxs->size()>0) {
280 for (
unsigned int k=0;
k<recVtxs->size(); ++
k) {
281 if (!((*recVtxs)[
k].isFake()) && ((*recVtxs)[
k].ndof() > 4)) {
288 leadPV = beamSpotH->position();
291 edm::LogInfo(
"HcalIsoTrack") <<
"Primary Vertex " << leadPV <<
" out of "
294 edm::LogInfo(
"HcalIsoTrack") <<
" Beam Spot " << beamSpotH->position();
300 if (!barrelRecHitsHandle.
isValid()) {
306 if (!endcapRecHitsHandle.
isValid()) {
318 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
320 trkCaloDirections,
false);
321 std::vector<math::XYZTLorentzVector> vecL1, vecL3;
327 <<
" out of " <<
t_Tracks <<
" with Trigger "
334 if (ignoreTrigger_) {
338 barrelRecHitsHandle, endcapRecHitsHandle, hbhe);
343 if (!triggerEventHandle.
isValid()) {
347 triggerEvent = *(triggerEventHandle.
product());
353 if (triggerResults.isValid()) {
354 std::vector<std::string>
modules;
356 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
358 for (
unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
360 int hlt = triggerResults->accept(iHLT);
363 if (triggerNames_[iHLT].
find(
trigNames_[
i].c_str())!=std::string::npos) {
365 if (hlt > 0) ok =
true;
368 << triggerNames_[iHLT] <<
" Flag "
380 std::vector<math::XYZTLorentzVector> vecL2;
381 vecL1.clear(); vecL3.clear();
383 for (
unsigned int ifilter=0; ifilter<triggerEvent.
sizeFilters();
385 std::vector<int>
Keys;
388 for (
unsigned int imodule=0; imodule<moduleLabels.size(); imodule++) {
389 if (label.find(moduleLabels[imodule]) != std::string::npos) {
393 for (
unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.
filterKeys(ifilter).size(); ++ifiltrKey) {
394 Keys.push_back(triggerEvent.
filterKeys(ifilter)[ifiltrKey]);
397 if (label.find(
l2Filter_) != std::string::npos) {
399 }
else if (label.find(
l3Filter_) != std::string::npos) {
405 edm::LogInfo(
"HcalIsoTrack") <<
"key " <<ifiltrKey<<
" : pt "
406 << TO.
pt() <<
" eta "<<TO.
eta()
407 <<
" phi " <<TO.
phi()<<
" mass "
408 << TO.
mass() <<
" Id "<<TO.
id();
412 edm::LogInfo(
"HcalIsoTrack") <<
"sizes " << vecL1.size() <<
":"
413 << vecL2.size() <<
":" <<vecL3.size();
421 for (
unsigned int i=0;
i<vecL2.size();
i++) {
422 double dr =
dR(vecL1[0],vecL2[
i]);
424 edm::LogInfo(
"HcalIsoTrack") <<
"lvl2[" << i <<
"] dR " << dr;
428 mindRvec1 = vecL2[
i];
432 edm::LogInfo(
"HcalIsoTrack") <<
"L2 object closest to L1 "
433 << mindRvec1 <<
" at Dr " << mindR1;
436 if (vecL1.size()>0) {
443 if (vecL3.size()>0) {
452 ntksave =
fillTree(vecL1, vecL3, leadPV, trkCaloDirections, geo,
453 barrelRecHitsHandle,endcapRecHitsHandle, hbhe);
467 tree =
fs->
make<TTree>(
"CalibTree",
"CalibTree");
469 tree->Branch(
"t_Run", &
t_Run,
"t_Run/I");
481 tree->Branch(
"t_p", &
t_p,
"t_p/D");
492 t_DetIds =
new std::vector<unsigned int>();
495 tree->Branch(
"t_DetIds",
"std::vector<unsigned int>", &
t_DetIds);
496 tree->Branch(
"t_HitEnergies",
"std::vector<double>", &t_HitEnergies);
497 tree->Branch(
"t_trgbits",
"std::vector<bool>", &t_trgbits);
499 tree2 =
fs->
make<TTree>(
"EventInfo",
"Event Information");
507 tree2->Branch(
"t_ietaGood",
"std::vector<int>", &t_ietaGood);
517 << flag <<
" change flag " << changed_;
523 edm::LogInfo(
"HcalIsoTrack") <<
"New trigger menu found !!!";
526 for (
unsigned itrig=0; itrig<
trigNames_.size(); itrig++) {
528 if (triggerindx >=
n) {
530 << triggerindx <<
" does not exist in "
531 <<
"the current menu";
535 << triggerindx <<
" exists";
562 std::vector< math::XYZTLorentzVector>& vecL3,
564 std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
572 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
573 unsigned int nTracks(0), nselTracks(0);
574 for (trkDetItr = trkCaloDirections.begin(),
nTracks=0;
575 trkDetItr != trkCaloDirections.end(); trkDetItr++,
nTracks++) {
576 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
578 pTrack->
pz(), pTrack->
p());
581 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
582 <<
"|" << pTrack->
eta() <<
"|"
583 << pTrack->
phi() <<
"|" <<pTrack->
p();
586 for (
unsigned int k=0;
k<vecL3.size(); ++
k) {
587 double dr =
dR(vecL3[
k],v4);
592 t_mindR1 = (vecL1.size() > 0) ?
dR(vecL1[0],v4) : 999;
594 edm::LogInfo(
"HcalIsoTrack") <<
"Closest L3 object at dr :"
602 oneCutParameters.
maxDzPV = 100;
605 bool qltyFlag =
spr::goodTrack(pTrack,leadPV,oneCutParameters,
false);
608 oneCutParameters.
maxDzPV = 100;
616 if (trkDetItr->okHCAL) {
622 edm::LogInfo(
"HcalIsoTrack") <<
"qltyFlag|okECAL|okHCAL : "
623 << qltyFlag <<
"|" << trkDetItr->okECAL
624 <<
"|" << trkDetItr->okHCAL;
626 t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL);
629 int nRH_eMipDR(0), nNearTRKs(0), nRecHits(-999);
631 endcapRecHitsHandle, trkDetItr->pointHCAL,
633 trkDetItr->directionECAL, nRH_eMipDR);
635 std::vector<DetId> ids;
638 trkDetItr->directionHCAL,nRecHits,
641 for (
unsigned int k=0;
k<ids.size(); ++
k) {
648 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
649 <<
"|" << pTrack->
eta() <<
"|"
650 << pTrack->
phi() <<
"|" <<
t_p;
653 <<
" eHcal" <<
t_eHcal <<
" ieta "
657 for (
unsigned int lll=0;lll<
t_DetIds->size();lll++) {
659 <<
" hit enery is = "
681 return reco::deltaR(vec1.eta(),vec1.phi(),vec2.eta(),vec2.phi());
unsigned int size() const
number of trigger paths in trigger table
double p() const
momentum vector magnitude
spr::trackSelectionParameters selectionParameter_
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
const unsigned int nTracks(const reco::Vertex &sv)
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
std::vector< std::string > trigNames_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
std::vector< int > * t_ietaAll
const Keys & filterKeys(trigger::size_type index) const
edm::InputTag theTriggerResultsLabel_
int bunchCrossing() const
edm::LuminosityBlockNumber_t luminosityBlock() const
double phi() const
azimuthal angle of momentum vector
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
T * make(const Args &...args) const
make new ROOT object
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< double > * t_HitEnergies
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
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)
Strings const & triggerNames() const
std::vector< unsigned int > * t_DetIds
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
std::vector< double > pbin
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
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< trigger::TriggerEvent > tok_trigEvt_
double eta() const
pseudorapidity of momentum vector
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
edm::Service< TFileService > fs
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
Abs< T >::type abs(const T &t)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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)
static std::string const triggerResults
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
HLTConfigProvider hltConfig_
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< bool > * t_trgbits
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
std::string theTrackQuality_
const edm::InputTag filterTag(trigger::size_type index) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static TrackQuality qualityByName(const std::string &name)
double slopeRestrictionPt_
T const * product() const
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
T const * product() const
std::string labelGenTrack_
double dR(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
HcalIsoTrkAnalyzer(edm::ParameterSet const &)
int fillTree(std::vector< math::XYZTLorentzVector > &vecL1, std::vector< math::XYZTLorentzVector > &vecL3, math::XYZPoint &leadPV, std::vector< spr::propagatedTrackDirection > &trkCaloDirections, const CaloGeometry *geo, edm::Handle< EcalRecHitCollection > &barrelRecHitsHandle, edm::Handle< EcalRecHitCollection > &endcapRecHitsHandle, edm::Handle< HBHERecHitCollection > &hbhe)
reco::TrackBase::TrackQuality minQuality
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< int > * t_ietaGood
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
edm::InputTag triggerEvent_
double py() const
y coordinate of momentum vector
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 useRaw=false, bool debug=false)