CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PFTester Class Reference

#include <PFTester.h>

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

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 PFTester (const edm::ParameterSet &)
 
virtual ~PFTester ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 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 19 of file PFTester.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file PFTester.cc.

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

41 {
42 
43  inputPFlowLabel_tok_ = consumes<reco::PFCandidateCollection> (iConfig.getParameter<std::string>("InputPFlowLabel") );
44  outputFile_ = iConfig.getUntrackedParameter<std::string>("OutputFile");
45 
46  if (outputFile_.size() > 0)
47  edm::LogInfo("OutputInfo") << " ParticleFLow Task histograms will be saved to '" << outputFile_.c_str() << "'";
48  else edm::LogInfo("OutputInfo") << " ParticleFlow Task histograms will NOT be saved";
49 
50 }
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 ( )
virtual

Definition at line 52 of file PFTester.cc.

52 { }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 95 of file PFTester.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file PFTester.cc.

References dbe_, M_PI, and cppFunctionSkipper::operator.

56 {
57 
58  // get ahold of back-end interface
60 
61  if (dbe_) {
62 
63  dbe_->setCurrentFolder("PFTask/PFCandidates");
64 
65  me["CandidateEt"] = dbe_->book1D("CandidateEt","CandidateEt",1000,0,1000);
66  me["CandidateEta"] = dbe_->book1D("CandidateEta","CandidateEta",200,-5,5);
67  me["CandidatePhi"] = dbe_->book1D("CandidatePhi","CandidatePhi",200,-M_PI,M_PI);
68  me["CandidateCharge"] = dbe_->book1D("CandidateCharge","CandidateCharge",5,-2,2);
69  me["PFCandidateType"] = dbe_->book1D("PFCandidateType","PFCandidateType",10,0,10);
70 
71  dbe_->setCurrentFolder("PFTask/PFBlocks");
72 
73  me["NumElements"] = dbe_->book1D("NumElements","NumElements",25,0,25);
74  me["NumTrackElements"] = dbe_->book1D("NumTrackElements","NumTrackElements",5,0,5);
75  me["NumPS1Elements"] = dbe_->book1D("NumPS1Elements","NumPS1Elements",5,0,5);
76  me["NumPS2Elements"] = dbe_->book1D("NumPS2Elements","NumPS2Elements",5,0,5);
77  me["NumECALElements"] = dbe_->book1D("NumECALElements","NumECALElements",5,0,5);
78  me["NumHCALElements"] = dbe_->book1D("NumHCALElements","NumHCALElements",5,0,5);
79  me["NumMuonElements"] = dbe_->book1D("NumMuonElements","NumMuonElements",5,0,5);
80 
81  dbe_->setCurrentFolder("PFTask/PFTracks");
82 
83  me["TrackCharge"] = dbe_->book1D("TrackCharge","TrackCharge",5,-2,2);
84  me["TrackNumPoints"] = dbe_->book1D("TrackNumPoints","TrackNumPoints",100,0,100);
85  me["TrackNumMeasurements"] = dbe_->book1D("TrackNumMeasurements","TrackNumMeasurements",100,0,100);
86  me["TrackImpactParameter"] = dbe_->book1D("TrackImpactParameter","TrackImpactParameter",1000,0,1);
87 
88  dbe_->setCurrentFolder("PFTask/PFClusters");
89 
90  }
91 
92 }
std::map< std::string, MonitorElement * > me
Definition: PFTester.h:33
#define M_PI
DQMStore * dbe_
Definition: PFTester.h:32
void PFTester::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 214 of file PFTester.cc.

References dbe_.

215 {
216 
217  // Store the DAQ Histograms
218  if (outputFile_.size() > 0 && dbe_)
219  dbe_->save(outputFile_);
220 
221 }
std::string outputFile_
Definition: PFTester.h:36
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.