CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PFTester Class Reference

#include <PFTester.h>

Inheritance diagram for PFTester:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
 PFTester (const edm::ParameterSet &)
 
 ~PFTester () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

DQMStoredbe_
 
edm::EDGetTokenT< reco::PFCandidateCollectioninputPFlowLabel_tok_
 
std::map< std::string, MonitorElement * > me
 
std::string outputFile_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 18 of file PFTester.h.

Member Typedef Documentation

Definition at line 20 of file PFTester.h.

Definition at line 21 of file PFTester.h.

Constructor & Destructor Documentation

PFTester::PFTester ( const edm::ParameterSet iConfig)
explicit

Definition at line 39 of file PFTester.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

39  {
40  inputPFlowLabel_tok_ = consumes<reco::PFCandidateCollection>(iConfig.getParameter<std::string>("InputPFlowLabel"));
41  outputFile_ = iConfig.getUntrackedParameter<std::string>("OutputFile");
42 
43  if (!outputFile_.empty())
44  edm::LogInfo("OutputInfo") << " ParticleFLow Task histograms will be saved to '" << outputFile_.c_str() << "'";
45  else
46  edm::LogInfo("OutputInfo") << " ParticleFlow Task histograms will NOT be saved";
47 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::PFCandidateCollection > inputPFlowLabel_tok_
Definition: PFTester.h:37
std::string outputFile_
Definition: PFTester.h:36
PFTester::~PFTester ( )
override

Definition at line 49 of file PFTester.cc.

49 {}

Member Function Documentation

void PFTester::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 85 of file PFTester.cc.

References reco::LeafCandidate::charge(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), edm::Event::getByToken(), hlt_dqm_clientPB-live_cfg::me, reco::PFCandidate::particleId(), reco::LeafCandidate::pdgId(), packedPFCandidateRefMixer_cfi::pf, reco::LeafCandidate::phi(), and edm::Handle< T >::product().

85  {
86  // Data to Retrieve from the Event
87  const PFCandidateCollection *pflow_candidates;
88 
89  // ==========================================================
90  // Retrieve!
91  // ==========================================================
92 
93  {
94  // Get Particle Flow Candidates
96  iEvent.getByToken(inputPFlowLabel_tok_, pflow_hnd);
97  pflow_candidates = pflow_hnd.product();
98  }
99 
100  if (!pflow_candidates) {
101  edm::LogInfo("OutputInfo") << " failed to retrieve data required by ParticleFlow Task";
102  edm::LogInfo("OutputInfo") << " ParticleFlow Task cannot continue...!";
103  return;
104  }
105 
106  // ==========================================================
107  // Analyze!
108  // ==========================================================
109 
110  // Loop Over Particle Flow Candidates
111  PFCandidateCollection::const_iterator pf;
112  for (pf = pflow_candidates->begin(); pf != pflow_candidates->end(); pf++) {
113  const PFCandidate *particle = &(*pf);
114 
115  // Fill Histograms for Candidate Methods
116  me["CandidateEt"]->Fill(particle->et());
117  me["CandidateEta"]->Fill(particle->eta());
118  me["CandidatePhi"]->Fill(particle->phi());
119  me["CandidateCharge"]->Fill(particle->charge());
120  me["CandidatePdgId"]->Fill(particle->pdgId());
121 
122  // Fill Histograms for PFCandidate Specific Methods
123  me["PFCandidateType"]->Fill(particle->particleId());
124  // particle->elementsInBlocks();
125 
126  // Get the PFBlock and Elements
127  // JW: Returns vector of blocks now ,TO BE FIXED ----
128  /*PFBlock block = *(particle->block());
129  OwnVector<PFBlockElement> elements = block.elements();
130  int numElements = elements.size();
131  int numTrackElements = 0;
132  int numPS1Elements = 0;
133  int numPS2Elements = 0;
134  int numECALElements = 0;
135  int numHCALElements = 0;
136  int numMuonElements = 0;
137 
138  // Loop over Elements in Block
139  OwnVector<PFBlockElement>::const_iterator element;
140  for (element = elements.begin(); element != elements.end(); element++) {
141 
142  int element_type = element->type();
143  // Element is a Tracker Track
144  if (element_type == PFBlockElement::TRACK) {
145 
146  // Get General Information about the Track
147  PFRecTrack track = *(element->trackRefPF());
148  me["TrackCharge"]->Fill(track.charge());
149  me["TrackNumPoints"]->Fill(track.nTrajectoryPoints());
150  me["TrackNumMeasurements"]->Fill(track.nTrajectoryMeasurements());
151 
152  // Loop Over Points in the Track
153  vector<PFTrajectoryPoint> points = track.trajectoryPoints();
154  vector<PFTrajectoryPoint>::iterator point;
155  for (point = points.begin(); point != points.end(); point++) {
156  int point_layer = point->layer();
157  double x = point->positionXYZ().x();
158  double y = point->positionXYZ().y();
159  double z = point->positionXYZ().z();
160  //switch (point_layer) {
161  //case PFTrajectoryPoint::ClosestApproach:
162  // Fill the Track's D0
163  if (point_layer == PFTrajectoryPoint::ClosestApproach) {
164  me["TrackImpactParameter"]->Fill(sqrt(x*x + y*y + z*z));
165  }
166  }
167  numTrackElements++;
168  }
169 
170  // Element is an ECAL Cluster
171  else if (element_type == PFBlockElement::ECAL) {
172  numECALElements++;
173  }
174  // Element is a HCAL Cluster
175  else if (element_type == PFBlockElement::HCAL) {
176  numHCALElements++;
177  }
178  // Element is a Muon Track
179  else if (element_type == PFBlockElement::MUON) {
180  numMuonElements++;
181  }
182  // Fill the Respective Elements Sizes
183  me["NumElements"]->Fill(numElements);
184  me["NumTrackElements"]->Fill(numTrackElements);
185  me["NumPS1Elements"]->Fill(numPS1Elements);
186  me["NumPS2Elements"]->Fill(numPS2Elements);
187  me["NumECALElements"]->Fill(numECALElements);
188  me["NumHCALElements"]->Fill(numHCALElements);
189  me["NumMuonElements"]->Fill(numMuonElements);
190  } ---------------------------------------------- */
191  }
192 }
int pdgId() const final
PDG identifier.
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
int charge() const final
electric charge
std::map< std::string, MonitorElement * > me
Definition: PFTester.h:33
double et() const final
transverse energy
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
T const * product() const
Definition: Handle.h:69
edm::EDGetTokenT< reco::PFCandidateCollection > inputPFlowLabel_tok_
Definition: PFTester.h:37
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
virtual ParticleType particleId() const
Definition: PFCandidate.h:366
double phi() const final
momentum azimuthal angle
void PFTester::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file PFTester.cc.

References dqm::dqmstoreimpl::DQMStore::book1D(), dbe_, M_PI, hlt_dqm_clientPB-live_cfg::me, Utilities::operator, and dqm::dqmstoreimpl::DQMStore::setCurrentFolder().

51  {
52  // get ahold of back-end interface
54 
55  if (dbe_) {
56  dbe_->setCurrentFolder("PFTask/PFCandidates");
57 
58  me["CandidateEt"] = dbe_->book1D("CandidateEt", "CandidateEt", 1000, 0, 1000);
59  me["CandidateEta"] = dbe_->book1D("CandidateEta", "CandidateEta", 200, -5, 5);
60  me["CandidatePhi"] = dbe_->book1D("CandidatePhi", "CandidatePhi", 200, -M_PI, M_PI);
61  me["CandidateCharge"] = dbe_->book1D("CandidateCharge", "CandidateCharge", 5, -2, 2);
62  me["PFCandidateType"] = dbe_->book1D("PFCandidateType", "PFCandidateType", 10, 0, 10);
63 
64  dbe_->setCurrentFolder("PFTask/PFBlocks");
65 
66  me["NumElements"] = dbe_->book1D("NumElements", "NumElements", 25, 0, 25);
67  me["NumTrackElements"] = dbe_->book1D("NumTrackElements", "NumTrackElements", 5, 0, 5);
68  me["NumPS1Elements"] = dbe_->book1D("NumPS1Elements", "NumPS1Elements", 5, 0, 5);
69  me["NumPS2Elements"] = dbe_->book1D("NumPS2Elements", "NumPS2Elements", 5, 0, 5);
70  me["NumECALElements"] = dbe_->book1D("NumECALElements", "NumECALElements", 5, 0, 5);
71  me["NumHCALElements"] = dbe_->book1D("NumHCALElements", "NumHCALElements", 5, 0, 5);
72  me["NumMuonElements"] = dbe_->book1D("NumMuonElements", "NumMuonElements", 5, 0, 5);
73 
74  dbe_->setCurrentFolder("PFTask/PFTracks");
75 
76  me["TrackCharge"] = dbe_->book1D("TrackCharge", "TrackCharge", 5, -2, 2);
77  me["TrackNumPoints"] = dbe_->book1D("TrackNumPoints", "TrackNumPoints", 100, 0, 100);
78  me["TrackNumMeasurements"] = dbe_->book1D("TrackNumMeasurements", "TrackNumMeasurements", 100, 0, 100);
79  me["TrackImpactParameter"] = dbe_->book1D("TrackImpactParameter", "TrackImpactParameter", 1000, 0, 1);
80 
81  dbe_->setCurrentFolder("PFTask/PFClusters");
82  }
83 }
std::map< std::string, MonitorElement * > me
Definition: PFTester.h:33
#define M_PI
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Definition: DQMStore.cc:1121
DQMStore * dbe_
Definition: PFTester.h:32
void PFTester::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 194 of file PFTester.cc.

References dbe_, and dqm::dqmstoreimpl::DQMStore::save().

194  {
195  // Store the DAQ Histograms
196  if (!outputFile_.empty() && dbe_)
198 }
std::string outputFile_
Definition: PFTester.h:36
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2244
DQMStore * dbe_
Definition: PFTester.h:32

Member Data Documentation

DQMStore* PFTester::dbe_
private

Definition at line 32 of file PFTester.h.

edm::EDGetTokenT<reco::PFCandidateCollection> PFTester::inputPFlowLabel_tok_
private

Definition at line 37 of file PFTester.h.

std::map<std::string, MonitorElement *> PFTester::me
private

Definition at line 33 of file PFTester.h.

std::string PFTester::outputFile_
private

Definition at line 36 of file PFTester.h.