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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 18 of file PFTester.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 20 of file PFTester.h.

◆ MonitorElement

Definition at line 21 of file PFTester.h.

Constructor & Destructor Documentation

◆ PFTester()

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

Definition at line 39 of file PFTester.cc.

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 }

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

◆ ~PFTester()

PFTester::~PFTester ( )
override

Definition at line 49 of file PFTester.cc.

49 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 85 of file PFTester.cc.

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 }

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

◆ beginJob()

void PFTester::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file PFTester.cc.

51  {
52  // get ahold of back-end interface
53  dbe_ = edm::Service<DQMStore>().operator->();
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 }

References dqm::implementation::IBooker::book1D(), dbe_, M_PI, hlt_dqm_clientPB-live_cfg::me, and dqm::implementation::DQMStore::setCurrentFolder().

◆ endJob()

void PFTester::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 194 of file PFTester.cc.

194  {
195  // Store the DAQ Histograms
196  if (!outputFile_.empty() && dbe_)
198 }

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

Member Data Documentation

◆ dbe_

DQMStore* PFTester::dbe_
private

Definition at line 32 of file PFTester.h.

◆ inputPFlowLabel_tok_

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

Definition at line 37 of file PFTester.h.

◆ me

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

Definition at line 33 of file PFTester.h.

◆ outputFile_

std::string PFTester::outputFile_
private

Definition at line 36 of file PFTester.h.

edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:761
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFTester::outputFile_
std::string outputFile_
Definition: PFTester.h:36
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
reco::PFCandidate::particleId
virtual ParticleType particleId() const
Definition: PFCandidate.h:367
PFTester::inputPFlowLabel_tok_
edm::EDGetTokenT< reco::PFCandidateCollection > inputPFlowLabel_tok_
Definition: PFTester.h:37
reco::LeafCandidate::pdgId
int pdgId() const final
PDG identifier.
Definition: LeafCandidate.h:176
PFTester::me
std::map< std::string, MonitorElement * > me
Definition: PFTester.h:33
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
reco::LeafCandidate::charge
int charge() const final
electric charge
Definition: LeafCandidate.h:106
reco::LeafCandidate::et
double et() const final
transverse energy
Definition: LeafCandidate.h:127
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
PFTester::dbe_
DQMStore * dbe_
Definition: PFTester.h:32
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
edm::Log
Definition: MessageLogger.h:70
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98