CMS 3D CMS Logo

CalibratableTest.h
Go to the documentation of this file.
1 #ifndef CALIBRATABLETEST_H_
2 #define CALIBRATABLETEST_H_
3 
4 // system include files
5 #include <memory>
6 #include <vector>
7 // user include files
15 
17 
23 
24 #include <TTree.h>
25 
26 
58 public:
59  explicit CalibratableTest(const edm::ParameterSet&);
60  ~CalibratableTest() override;
61 
62  /*
63  * Returns the collection in the event matching the Handle.
64  */
65  template<class T> void getCollection(edm::Handle<T>& c,
66  const edm::InputTag& tag, const edm::Event& event) const;
67 
68 private:
69  /*
70  * The usual EDAnalyzer methods
71  */
72  void beginJob() override;
73  void analyze(const edm::Event&, const edm::EventSetup&) override;
74  void endJob() override;
75 
76  /*
77  * Called for each particle in the event to fill the tree and
78  * reset calib_.
79  */
80  virtual void fillTreeAndReset();
81 
82  /*
83  * Finds the main pions generated by FastSim
84  */
85  std::vector<unsigned> findPrimarySimParticles(
86  const std::vector<reco::PFSimParticle>& sims);
87 
88  /*
89  * Finds PFCandidates within some deltaR of the supplied sim particle.
90  */
91  std::vector<unsigned> findCandidatesInDeltaR(const reco::PFSimParticle& pft,
92  const std::vector<reco::PFCandidate>& cands, const double& deltaR);
93 
94  /*
95  * Fills calib_ with PFCandidate information.
96  */
98 
99  /*
100  * Computes delta R between two objects.
101  */
102  double deltaR(const double& eta1, const double& eta2, const double& phi1,
103  const double& phi2);
104 
105  //Calibratable tree
106  TTree* tree_;
107 
108  //This analyzer produces a file with a tree so we need,
110 
111  //Debug?
112  int debug_;
113 
114  //True if this event was generally successful:
115  //if no sim particles are found, this will be false
117  //True if this particle should be written to the tree
118  //If no PFCandidates are found within a delta R cone of the sim particle,
119  //this will be false.
121 
122  //The Calibratable object
124 
125  //Increment nWrites_ for every record written to the tree
126  //Incremement nFails_ for every event/particle not written to the tree (thisEventPasses_ == false)
129 
130  //Size of cone around sim particle to look for PFCandidates
132 
133  //Collection input tags
138 
139  //collections
144 
145 };
146 
148  const edm::InputTag& tag, const edm::Event& event) const {
149 
150  try {
151  event.getByLabel(tag, c);
152  if(!c.isValid()) {
153  std::cout << "Warning! Collection for label " << tag << " is not valid!" << std::endl;
154  }
155  }
156  catch (cms::Exception& err) {
157  std::cout << "Couldn't get collection\n";
158  //std::ostringstream s;
159  //LogError("Error getting collection!") << s;
160  }
161 }
162 
163 #endif /*CALIBRATABLETEST_H_*/
edm::InputTag inputTagClustersHcal_
edm::Service< TFileService > fileservice_
Wraps essential single particle calibration data ready for export to a Root file. ...
Definition: Calibratable.h:122
~CalibratableTest() override
std::vector< unsigned > findPrimarySimParticles(const std::vector< reco::PFSimParticle > &sims)
virtual void fillTreeAndReset()
CalibratableTest(const edm::ParameterSet &)
edm::Handle< reco::PFCandidateCollection > * pfCandidates_
double deltaR(const double &eta1, const double &eta2, const double &phi1, const double &phi2)
void extractCandidate(const reco::PFCandidate &cand)
pftools::Calibratable * calib_
void beginJob() override
edm::Handle< reco::PFSimParticleCollection > * simParticles_
edm::Handle< reco::PFClusterCollection > * clustersEcal_
EDAnalyzer to exercise and demonstrate usage of Calibratable tree.
void getCollection(edm::Handle< T > &c, const edm::InputTag &tag, const edm::Event &event) const
edm::InputTag inputTagCandidates_
std::vector< unsigned > findCandidatesInDeltaR(const reco::PFSimParticle &pft, const std::vector< reco::PFCandidate > &cands, const double &deltaR)
bool isValid() const
Definition: HandleBase.h:74
true particle for particle flow
Definition: PFSimParticle.h:19
void endJob() override
edm::InputTag inputTagSimParticles_
edm::Handle< reco::PFClusterCollection > * clustersHcal_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::InputTag inputTagClustersEcal_
Definition: event.py:1