9 #include "TDirectory.h"
11 #include "TLorentzVector.h"
12 #include "TInterpreter.h"
120 changed(
false), nRun(0), nAll(0), nGood(0) {
159 tok_bs_ = consumes<reco::BeamSpot>(labelBS);
166 edm::LogInfo(
"HcalIsoTrack") <<
"Labels used " << triggerEvent_ <<
" "
167 << theTriggerResultsLabel <<
" "
168 << labelBS <<
" " << labelRecVtx_ <<
" "
169 << labelGenTrack_ <<
" "
178 edm::LogInfo(
"HcalIsoTrack") <<
"Labels used " << triggerEvent_
179 <<
"\n " << theTriggerResultsLabel
182 <<
"\n " << labelGenTrack_
188 std::vector<int> dummy(
trigNames.size(),0);
190 edm::LogInfo(
"HcalIsoTrack") <<
"Parameters read from config file \n"
192 <<
"\t theTrackQuality " << theTrackQuality
202 <<
"\t a_coneR " << a_coneR
203 <<
"\t a_charIsoR " << a_charIsoR
205 edm::LogInfo(
"HcalIsoTrack") <<
"Process " << processName <<
" L1Filter:"
206 << l1Filter <<
" L2Filter:" << l2Filter
241 reco::TrackCollection::const_iterator trkItr;
242 if (!trkCollection.
isValid()) {
256 if (recVtxs.
isValid() && recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
257 leadPV =
math::XYZPoint( (*recVtxs)[0].
x(),(*recVtxs)[0].
y(), (*recVtxs)[0].
z() );
258 }
else if (beamSpotH.
isValid()) {
259 leadPV = beamSpotH->position();
262 edm::LogInfo(
"HcalIsoTrack") <<
"Primary Vertex " << leadPV;
264 << beamSpotH->position();
269 if (!barrelRecHitsHandle.
isValid()) {
275 if (!endcapRecHitsHandle.
isValid()) {
287 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
289 trkCaloDirections,
false);
290 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
300 if (!triggerEventHandle.
isValid()) {
304 triggerEvent = *(triggerEventHandle.
product());
310 if (triggerResults.isValid()) {
311 std::vector<std::string>
modules;
313 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
314 for (
unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
316 int hlt = triggerResults->accept(iHLT);
318 if (triggerNames_[iHLT].
find(
trigNames[
i].c_str())!=std::string::npos) {
327 << triggerNames_[iHLT] <<
" Flag "
336 std::vector<math::XYZTLorentzVector> vec[3];
338 for (
unsigned int ifilter=0; ifilter<triggerEvent.
sizeFilters();
340 std::vector<int>
Keys;
343 for (
unsigned int imodule=0; imodule<moduleLabels.size();
345 if (label.find(moduleLabels[imodule]) != std::string::npos) {
349 for (
unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.
filterKeys(ifilter).size(); ++ifiltrKey) {
350 Keys.push_back(triggerEvent.
filterKeys(ifilter)[ifiltrKey]);
353 if (label.find(
l2Filter) != std::string::npos) {
354 vec[1].push_back(v4);
355 }
else if (label.find(
l3Filter) != std::string::npos) {
356 vec[2].push_back(v4);
357 }
else if (label.find(
l1Filter) != std::string::npos ||
359 vec[0].push_back(v4);
362 edm::LogInfo(
"HcalIsoTrack") <<
"key " << ifiltrKey<<
" : pt "
363 << TO.
pt() <<
" eta "<< TO.
eta()
364 <<
" phi " << TO.
phi()<<
" mass "
365 << TO.
mass() <<
" Id "<<TO.
id();
369 edm::LogInfo(
"HcalIsoTrack") <<
"sizes " << vec[0].size() <<
":"
370 << vec[1].size() <<
":" <<vec[2].size();
379 for (
int lvl=1; lvl<3; lvl++) {
380 for (
unsigned int i=0;
i<vec[lvl].size();
i++) {
381 dr =
dR(vec[0][0],vec[lvl][
i]);
383 edm::LogInfo(
"HcalIsoTrack") <<
"lvl " << lvl <<
" i " << i
388 mindRvec1 = vec[lvl][
i];
396 if (vec[2].
size()>0) {
402 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
403 unsigned int nTracks(0), nselTracks(0);
404 for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
405 trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
406 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
408 pTrack->
pz(), pTrack->
p());
410 edm::LogInfo(
"HcalIsoTrack") <<
"This track : " << nTracks
411 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
412 <<
"|" << pTrack->
eta() <<
"|"
413 << pTrack->
phi() <<
"|" <<pTrack->
p();
418 for (
unsigned int k=0;
k<vec[2].size(); ++
k) {
419 dr =
dR(vec[2][
k],v4);
422 mindRvec2 = vec[2][
k];
427 edm::LogInfo(
"HcalIsoTrack") <<
"Closest L3 object at mindr :"
435 oneCutParameters.
maxDzPV = 100;
438 bool qltyFlag =
spr::goodTrack(pTrack,leadPV,oneCutParameters,
false);
441 oneCutParameters.
maxDzPV = 100;
448 if (trkDetItr->okHCAL) {
453 edm::LogInfo(
"HcalIsoTrack") <<
"qltyFlag|okECAL|okHCAL : "
454 << qltyFlag <<
"|" << trkDetItr->okECAL
455 <<
"|" << trkDetItr->okHCAL;
457 t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL);
461 int nRH_eMipDR(0), nNearTRKs(0), nRecHits(-999);
464 trkDetItr->pointHCAL,
465 trkDetItr->pointECAL,
466 a_mipR, trkDetItr->directionECAL,
469 std::vector<DetId> ids;
472 trkDetItr->directionHCAL,nRecHits,
474 for (
unsigned int k=0;
k<ids.size(); ++
k) {
481 edm::LogInfo(
"HcalIsoTrack") <<
"This track : " << nTracks
482 <<
" (pt|eta|phi|p) :" << pTrack->
pt()
483 <<
"|" << pTrack->
eta() <<
"|"
484 << pTrack->
phi() <<
"|" <<
t_p;
487 <<
" eHcal" <<
t_eHcal <<
" ieta "
491 for (
unsigned int lll=0;lll<
t_DetIds->size();lll++) {
493 <<
" hit enery is = "
515 edm::LogInfo(
"HcalIsoTrack") <<
"New trigger menu found !!!";
518 for (
unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
520 if (triggerindx >=
n)
521 edm::LogInfo(
"HcalIsoTrack") << triggerNames_[itrig] <<
" "
522 << triggerindx <<
" does not exist in "
523 <<
"the current menu";
526 edm::LogInfo(
"HcalIsoTrack") << triggerNames_[itrig] <<
" "
527 << triggerindx <<
" exists";
537 tree =
fs->
make<TTree>(
"CalibTree",
"CalibTree");
539 tree->Branch(
"t_Run", &
t_Run,
"t_Run/I");
549 tree->Branch(
"t_p", &
t_p,
"t_p/D");
560 t_DetIds =
new std::vector<unsigned int>();
563 tree->Branch(
"t_DetIds",
"std::vector<unsigned int>", &
t_DetIds);
564 tree->Branch(
"t_HitEnergies",
"std::vector<double>", &t_HitEnergies);
565 tree->Branch(
"t_trgbits",
"std::vector<bool>", &t_trgbits);
571 <<
nAll <<
" events from " <<
nRun <<
" runs";
604 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
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
virtual void endRun(edm::Run const &, edm::EventSetup const &)
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
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)
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 > HLTNames
std::vector< int > trigKount
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
HcalIsoTrkAnalyzer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
const Keys & filterKeys(trigger::size_type index) const
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 &)
std::vector< std::string > trgnames
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)
double deltaR(const T1 &t1, const T2 &t2)
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
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.
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
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_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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)
const edm::InputTag filterTag(trigger::size_type index) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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)
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
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
T const * product() const
std::string labelGenTrack_
double dR(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
std::vector< int > trigPass
reco::TrackBase::TrackQuality minQuality
edm::InputTag theTriggerResultsLabel
std::vector< std::string > trigNames
spr::trackSelectionParameters selectionParameters
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
edm::InputTag triggerEvent_
tuple size
Write out results.
double py() const
y coordinate of momentum vector
std::string theTrackQuality