10 #include "TDirectory.h"
12 #include "TLorentzVector.h"
13 #include "TInterpreter.h"
124 changed(
false), nRun(0) {
167 edm::LogInfo(
"IsoTrack") <<
"Parameters read from config file \n"
169 <<
"\t theTrackQuality " << theTrackQuality
179 <<
"\t a_coneR " << a_coneR
182 <<
"\t qcdMC " <<
qcdMC;
183 edm::LogInfo(
"IsoTrack") << trigNames.size() <<
" triggers to be studied:";
184 for (
unsigned int k=0;
k<trigNames.size(); ++
k)
185 edm::LogInfo(
"IsoTrack") <<
"Trigger[" <<
k <<
"] : " << trigNames[
k];
222 reco::TrackCollection::const_iterator trkItr;
236 if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
237 leadPV =
math::XYZPoint( (*recVtxs)[0].
x(),(*recVtxs)[0].
y(), (*recVtxs)[0].
z() );
238 }
else if (beamSpotH.
isValid()) {
239 leadPV = beamSpotH->position();
242 edm::LogInfo(
"IsoTrack") <<
"Primary Vertex " << leadPV;
244 << beamSpotH->position();
258 if (!triggerEventHandle.
isValid()) {
262 triggerEvent = *(triggerEventHandle.
product());
268 if (triggerResults.isValid()) {
269 std::vector<std::string>
modules;
271 const std::vector<std::string> & triggerNames_ = triggerNames.
triggerNames();
272 for (
unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
274 int hlt = triggerResults->accept(iHLT);
276 if (triggerNames_[iHLT].
find(
trigNames[
i].c_str())!=std::string::npos) {
277 if (hlt > 0) ok =
true;
279 edm::LogInfo(
"IsoTrack") <<
"This is the trigger we are looking for "
280 << triggerNames_[iHLT] <<
" Flag "
288 std::vector<math::XYZTLorentzVector> vec[3];
290 for (
unsigned int ifilter=0; ifilter<triggerEvent.
sizeFilters();
292 std::vector<int>
Keys;
295 for (
unsigned int imodule=0; imodule<moduleLabels.size();
297 if (label.find(moduleLabels[imodule]) != std::string::npos) {
300 for (
unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.
filterKeys(ifilter).size(); ++ifiltrKey) {
301 Keys.push_back(triggerEvent.
filterKeys(ifilter)[ifiltrKey]);
305 if (label.find(
"hltL1s") != std::string::npos) {
306 vec[0].push_back(v4);
307 }
else if (label.find(
"PFJet") != std::string::npos) {
308 vec[2].push_back(v4);
310 vec[1].push_back(v4);
313 if (label.find(
"L2Filter") != std::string::npos) {
314 vec[1].push_back(v4);
315 }
else if (label.find(
"Filter") != std::string::npos) {
316 vec[2].push_back(v4);
318 vec[0].push_back(v4);
322 edm::LogInfo(
"IsoTrack") <<
"key " << ifiltrKey <<
" : pt "
323 << TO.
pt() <<
" eta " << TO.
eta()
324 <<
" phi " << TO.
phi() <<
" mass "
325 << TO.
mass() <<
" Id " << TO.
id();
330 <<
":" << vec[1].size() <<
":"
337 double deta, dphi, dr;
341 for (
int lvl=1; lvl<3; lvl++) {
342 for (
unsigned int i=0;
i<vec[lvl].size();
i++) {
343 deta =
dEta(vec[0][0],vec[lvl][
i]);
344 dphi =
dPhi(vec[0][0],vec[lvl][i]);
345 dr =
dR(vec[0][0],vec[lvl][i]);
348 <<
" deta " << deta <<
" dphi "
349 << dphi <<
" dR " << dr;
352 mindRvec1 = vec[lvl][
i];
365 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
367 trkCaloDirections, ((
verbosity/100)%10>2));
369 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
370 unsigned int nTracks(0), nselTracks(0);
371 for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
372 trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
373 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
375 pTrack->
pz(), pTrack->
p());
378 <<
" (pt/eta/phi/p) :" << pTrack->
pt()
379 <<
"/" << pTrack->
eta() <<
"/"
380 << pTrack->
phi() <<
"/" << pTrack->
p();
384 for (
unsigned int k=0;
k<vec[2].size(); ++
k) {
385 dr =
dR(vec[2][
k],v4);
388 mindRvec2 = vec[2][
k];
393 edm::LogInfo(
"IsoTrack") <<
"Closest L3 object at mindr :"
401 oneCutParameters.
maxDzPV = 100;
407 oneCutParameters.
maxDzPV = 100;
414 if (trkDetItr->okHCAL) {
420 << qltyFlag <<
"|" << trkDetItr->okECAL
421 <<
"/" << trkDetItr->okHCAL;
422 if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) {
424 int nRH_eMipDR(0), nNearTRKs(0), nRecHits(-999);
427 trkDetItr->pointHCAL,
428 trkDetItr->pointECAL,
429 a_mipR, trkDetItr->directionECAL,
432 std::vector<DetId> ids;
435 trkDetItr->directionHCAL,nRecHits,
437 for (
unsigned int k=0;
k<ids.size(); ++
k) {
446 <<
" (pt/eta/phi/p) :" << pTrack->
pt()
447 <<
"/" << pTrack->
eta() <<
"/"
448 << pTrack->
phi() <<
"/" <<
t_p <<
"\n"
451 <<
" eHcal" <<
t_eHcal <<
" ieta "
467 edm::LogInfo(
"IsoTrack") <<
"New trigger menu found !!!";
469 for (
unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
471 if (triggerindx >=
n)
473 << triggerindx <<
" does not exist";
476 << triggerindx <<
" exists";
486 tree =
fs->
make<TTree>(
"CalibTree",
"CalibTree");
488 tree->Branch(
"t_Run", &
t_Run,
"t_Run/I");
498 tree->Branch(
"t_p", &
t_p,
"t_p/D");
508 t_DetIds =
new std::vector<unsigned int>();
511 tree->Branch(
"t_DetIds",
"std::vector<unsigned int>", &
t_DetIds);
512 tree->Branch(
"t_HitEnergies",
"std::vector<double>", &t_HitEnergies);
522 <<
" hltconfig.init "
546 return (vec1.eta()-vec2.eta());
554 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
edm::InputTag triggerEvent_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
double dPhi(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
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
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
int bunchCrossing() const
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
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
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
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_
double deltaPhi(double phi1, double phi2)
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)
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
T const * product() const
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt
spr::trackSelectionParameters selectionParameters
reco::TrackBase::TrackQuality minQuality
volatile std::atomic< bool > shutdown_flag false
double dEta(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
std::vector< unsigned int > * t_DetIds
HLTConfigProvider hltConfig_
double py() const
y coordinate of momentum vector
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_