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 Member Functions | Private Attributes
CalibratableTest Class Reference

EDAnalyzer to exercise and demonstrate usage of Calibratable tree. More...

#include <CalibratableTest.h>

Inheritance diagram for CalibratableTest:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 CalibratableTest (const edm::ParameterSet &)
 
template<class T >
void getCollection (edm::Handle< T > &c, const edm::InputTag &tag, const edm::Event &event) const
 
 ~CalibratableTest ()
 
- 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 Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
double deltaR (const double &eta1, const double &eta2, const double &phi1, const double &phi2)
 
virtual void endJob ()
 
void extractCandidate (const reco::PFCandidate &cand)
 
virtual void fillTreeAndReset ()
 
std::vector< unsigned > findCandidatesInDeltaR (const reco::PFSimParticle &pft, const std::vector< reco::PFCandidate > &cands, const double &deltaR)
 
std::vector< unsigned > findPrimarySimParticles (const std::vector< reco::PFSimParticle > &sims)
 

Private Attributes

pftools::Calibratablecalib_
 
edm::Handle
< reco::PFClusterCollection > * 
clustersEcal_
 
edm::Handle
< reco::PFClusterCollection > * 
clustersHcal_
 
int debug_
 
double deltaRCandToSim_
 
edm::Service< TFileServicefileservice_
 
edm::InputTag inputTagCandidates_
 
edm::InputTag inputTagClustersEcal_
 
edm::InputTag inputTagClustersHcal_
 
edm::InputTag inputTagSimParticles_
 
unsigned nEventFails_
 
unsigned nEventWrites_
 
unsigned nParticleFails_
 
unsigned nParticleWrites_
 
edm::Handle
< reco::PFCandidateCollection > * 
pfCandidates_
 
edm::Handle
< reco::PFSimParticleCollection > * 
simParticles_
 
bool thisEventPasses_
 
bool thisParticlePasses_
 
TTree * tree_
 

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

EDAnalyzer to exercise and demonstrate usage of Calibratable tree.

Author
Jamie Ballin, Imperial College London
Date
November 2008

OBJECTIVE: this analyzer will create a tree of PFClusterTools/Calibratable instances. Each entry of the tree represents particle flow information relating to one pion in a multi-pion event. The use of monte carlo is assumed as sim particle information is extracted too.

USAGE: This is an analyzer, not a producer: the tree it produces is stored in a seperate ROOT file using the CMSSW TFileService.

Consult test/CalibratableTest_FastSim.py for a sample CMSSW configuration. Run the example from that directory with, cmsRun CalibratableTest_FastSim.py This will produce a file with a tree inside. Browse the contents in bare root with a TBrowser.

NOTE: This analyzer does not exercise the complete functionality of the Calibratable class. For instance, tracks and rechits are not stored. Contact me (the author) for more details, and for an analyzer that we use to extract particle information to calibrate the particle flow algorithm. A MUCH more involved example from my private analysis is to be found in, UserCode/JamieBallin/interface/DipionDelegate.h

General details about the usage of Calibratable may be found at, https://twiki.cern.ch/twiki/bin/view/CMS/PFClusterToolsPackage

Definition at line 57 of file CalibratableTest.h.

Constructor & Destructor Documentation

CalibratableTest::CalibratableTest ( const edm::ParameterSet parameters)
explicit

Definition at line 24 of file CalibratableTest.cc.

References calib_, gather_cfg::cout, debug_, deltaRCandToSim_, fileservice_, edm::ParameterSet::getParameter(), inputTagCandidates_, inputTagClustersEcal_, inputTagClustersHcal_, inputTagSimParticles_, TFileService::make(), and tree_.

24  :
26  deltaRCandToSim_(0.4) {
27 
28  std::cout << __PRETTY_FUNCTION__ << std::endl;
29 
30  /* This procedure is GENERIC to storing any dictionary enable class in a ROOT tree. */
31  tree_ = fileservice_->make<TTree>("CalibratableTest", "");
32  calib_ = new Calibratable();
33  tree_->Branch("Calibratable", "pftools::Calibratable", &calib_, 32000, 2);
34 
35  inputTagCandidates_= parameters.getParameter<InputTag>("PFCandidates");
36  inputTagSimParticles_= parameters.getParameter<InputTag>("PFSimParticles");
37  inputTagClustersEcal_= parameters.getParameter<InputTag>("PFClustersEcal");
38  inputTagClustersHcal_= parameters.getParameter<InputTag>("PFClustersHcal");
39  deltaRCandToSim_ = parameters.getParameter<double>("deltaRCandToSim");
40  debug_= parameters.getParameter<int>("debug");
41 }
T getParameter(std::string const &) const
edm::InputTag inputTagClustersHcal_
edm::Service< TFileService > fileservice_
Wraps essential single particle calibration data ready for export to a Root file. ...
Definition: Calibratable.h:122
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
pftools::Calibratable * calib_
edm::InputTag inputTagCandidates_
edm::InputTag inputTagSimParticles_
tuple cout
Definition: gather_cfg.py:121
edm::InputTag inputTagClustersEcal_
CalibratableTest::~CalibratableTest ( )

Definition at line 43 of file CalibratableTest.cc.

43  {
44 
45 }

Member Function Documentation

void CalibratableTest::analyze ( const edm::Event event,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 53 of file CalibratableTest.cc.

References calib_, clustersEcal_, clustersHcal_, gather_cfg::cout, debug_, deltaRCandToSim_, extractCandidate(), fillTreeAndReset(), findCandidatesInDeltaR(), findPrimarySimParticles(), getCollection(), inputTagCandidates_, inputTagClustersEcal_, inputTagClustersHcal_, inputTagSimParticles_, reco::PFTrajectoryPoint::momentum(), nEventFails_, nEventWrites_, reco::PFTrack::nTrajectoryPoints(), pfCandidates_, reco::PFTrajectoryPoint::positionREP(), pftools::Calibratable::reset(), pftools::Calibratable::sim_energyEvent_, pftools::Calibratable::sim_eta_, pftools::Calibratable::sim_etaEcal_, pftools::Calibratable::sim_etaHcal_, pftools::Calibratable::sim_isMC_, pftools::Calibratable::sim_numEvent_, pftools::Calibratable::sim_phi_, pftools::Calibratable::sim_phiEcal_, pftools::Calibratable::sim_phiHcal_, simParticles_, thisEventPasses_, thisParticlePasses_, and reco::PFTrack::trajectoryPoint().

54  {
55  if (debug_ > 1)
56  std::cout << __PRETTY_FUNCTION__ << "\n";
57 
58  //Extract new collection references
63 
68 
69  //Reset calibratable branch
70  thisEventPasses_ = true;
71  thisParticlePasses_ = true;
72  calib_->reset();
73 
74  if (debug_ > 1)
75  std::cout << "\tStarting event..."<< std::endl;
76 
78  PFCandidateCollection candidates = **pfCandidates_;
79  PFClusterCollection clustersEcal = **clustersEcal_;
80  PFClusterCollection clustersHcal = **clustersHcal_;
81 
82  if (sims.size() == 0) {
83  std::cout << "\tNo sim particles found!" << std::endl;
84  thisEventPasses_ = false;
85  }
86 
87  //Find primary pions in the event
88  std::vector<unsigned> primarySims = findPrimarySimParticles(sims);
89  if (debug_) {
90  std::cout << "\tFound "<< primarySims.size()
91  << " primary sim particles, "<< (**pfCandidates_).size() << " pfCandidates\n";
92  }
93  for (std::vector<unsigned>::const_iterator cit = primarySims.begin(); cit
94  != primarySims.end(); ++cit) {
95  //There will be one write to the tree for each pion found.
96  if (debug_ > 1)
97  std::cout << "\t**Starting particle...**\n";
98  const PFSimParticle& sim = sims[*cit];
99  //One sim per calib =>
100  calib_->sim_numEvent_ = 1;
101  calib_->sim_isMC_ = true;
102  calib_->sim_energyEvent_ = sim.trajectoryPoint(PFTrajectoryPoint::ClosestApproach).momentum().E();
103  calib_->sim_phi_ = sim.trajectoryPoint(PFTrajectoryPoint::ClosestApproach).momentum().Phi();
104  calib_->sim_eta_ = sim.trajectoryPoint(PFTrajectoryPoint::ClosestApproach).momentum().Eta();
105 
106  if (sim.nTrajectoryPoints() > PFTrajectoryPoint::ECALEntrance) {
107  calib_->sim_etaEcal_ = sim.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Eta();
108  calib_->sim_phiEcal_ = sim.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Phi();
109  }
110  if (sim.nTrajectoryPoints() > PFTrajectoryPoint::HCALEntrance) {
111  calib_->sim_etaHcal_ = sim.trajectoryPoint(PFTrajectoryPoint::HCALEntrance).positionREP().Eta();
112  calib_->sim_phiHcal_ = sim.trajectoryPoint(PFTrajectoryPoint::HCALEntrance).positionREP().Phi();
113  }
114 
115  // Find candidates near this sim particle
116  std::vector<unsigned> matchingCands = findCandidatesInDeltaR(sim,
117  candidates, deltaRCandToSim_);
118  if (debug_ > 3)
119  std::cout << "\t\tFound candidates near sim, found "
120  << matchingCands.size()<< " of them.\n";
121  if (matchingCands.size() == 0)
122  thisParticlePasses_ = false;
123  for (std::vector<unsigned>::const_iterator mcIt = matchingCands.begin(); mcIt
124  != matchingCands.end(); ++mcIt) {
125  const PFCandidate& theCand = candidates[*mcIt];
126  extractCandidate(theCand);
127  }
128  //Finally,
130 
131  }
132 
133  delete pfCandidates_;
134  delete simParticles_;
135  delete clustersEcal_;
136  delete clustersHcal_;
137 
138  if (thisEventPasses_)
139  ++nEventWrites_;
140  else
141  ++nEventFails_;
142 
143 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
edm::InputTag inputTagClustersHcal_
std::vector< unsigned > findPrimarySimParticles(const std::vector< reco::PFSimParticle > &sims)
virtual void fillTreeAndReset()
edm::Handle< reco::PFCandidateCollection > * pfCandidates_
std::vector< PFSimParticle > PFSimParticleCollection
collection of PFSimParticle objects
void extractCandidate(const reco::PFCandidate &cand)
pftools::Calibratable * calib_
Definition: sim.h:19
edm::Handle< reco::PFSimParticleCollection > * simParticles_
edm::Handle< reco::PFClusterCollection > * clustersEcal_
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)
virtual void reset()
true particle for particle flow
Definition: PFSimParticle.h:19
edm::InputTag inputTagSimParticles_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
const reco::PFTrajectoryPoint & trajectoryPoint(unsigned index) const
Definition: PFTrack.h:102
edm::Handle< reco::PFClusterCollection > * clustersHcal_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
tuple cout
Definition: gather_cfg.py:121
unsigned int nTrajectoryPoints() const
Definition: PFTrack.h:90
edm::InputTag inputTagClustersEcal_
void CalibratableTest::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 47 of file CalibratableTest.cc.

References gather_cfg::cout, and debug_.

47  {
48  if (debug_ > 1)
49  std::cout << __PRETTY_FUNCTION__ << "\n";
50 
51 }
tuple cout
Definition: gather_cfg.py:121
double CalibratableTest::deltaR ( const double &  eta1,
const double &  eta2,
const double &  phi1,
const double &  phi2 
)
private

Definition at line 301 of file CalibratableTest.cc.

References HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, M_PI, funct::pow(), and mathSSE::sqrt().

Referenced by findCandidatesInDeltaR().

302  {
303  double deltaEta = fabs(eta1 - eta2);
304  double deltaPhi = fabs(phi1 - phi2);
305  if (deltaPhi > M_PI) {
306  deltaPhi = 2 * M_PI- deltaPhi;
307  }
308  return sqrt(pow(deltaEta, 2) + pow(deltaPhi, 2));
309 }
T sqrt(T t)
Definition: SSEVec.h:48
#define M_PI
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void CalibratableTest::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 287 of file CalibratableTest.cc.

References gather_cfg::cout, debug_, nEventFails_, nEventWrites_, nParticleFails_, and nParticleWrites_.

287  {
288 
289  if (debug_> 0) {
290  std::cout << __PRETTY_FUNCTION__ << std::endl;
291 
292  std::cout << "\tnParticleWrites: "<< nParticleWrites_
293  << ", nParticleFails: "<< nParticleFails_ << "\n";
294  std::cout << "\tnEventWrites: "<< nEventWrites_ << ", nEventFails: "
295  << nEventFails_ << "\n";
296  std::cout << "Leaving "<< __PRETTY_FUNCTION__ << "\n";
297  }
298 
299 }
tuple cout
Definition: gather_cfg.py:121
void CalibratableTest::extractCandidate ( const reco::PFCandidate cand)
private

Definition at line 167 of file CalibratableTest.cc.

References createPayload::block, calib_, pftools::Calibratable::cands_, pftools::Calibratable::cluster_ecal_, pftools::Calibratable::cluster_hcal_, gather_cfg::cout, debug_, ECAL, reco::PFBlock::elements(), asciidump::elements, reco::PFCluster::energy(), pftools::CandidateWrapper::energy_, pftools::CandidateWrapper::energyEcal_, pftools::CandidateWrapper::energyHcal_, pftools::CandidateWrapper::eta_, HCAL, reco::PFCluster::layer(), pftools::CandidateWrapper::phi_, reco::PFCluster::positionREP(), and pftools::CandidateWrapper::type_.

Referenced by analyze().

167  {
168  if (debug_ > 3)
169  std::cout << "\tCandidate: "<< cand << "\n";
170 
171  //There may be several PFCandiates per sim particle. So we create a mini-class
172  //to represent each one. CandidateWrapper is defined in Calibratable.
173  //It's very easy to use, as we shall see...
174  CandidateWrapper cw;
175  cw.energy_ = cand.energy();
176  cw.eta_ = cand.eta();
177  cw.phi_ = cand.phi();
178  cw.type_ = cand.particleId();
179  cw.energyEcal_ = cand.ecalEnergy();
180  cw.energyHcal_ = cand.hcalEnergy();
181  if (debug_ > 4)
182  std::cout << "\t\tECAL energy = " << cand.ecalEnergy()
183  << ", HCAL energy = " << cand.hcalEnergy() << "\n";
184 
185  //Now, extract block elements from the pfCandidate:
186  PFCandidate::ElementsInBlocks eleInBlocks = cand.elementsInBlocks();
187  if (debug_ > 3)
188  std::cout << "\tLooping over elements in blocks, "
189  << eleInBlocks.size() << " of them."<< std::endl;
190  for (PFCandidate::ElementsInBlocks::iterator bit = eleInBlocks.begin(); bit
191  != eleInBlocks.end(); ++bit) {
192 
193  /*
194  * Find PFClusters associated with this candidate.
195  */
196 
197  //Extract block reference
198  PFBlockRef blockRef((*bit).first);
199  //Extract index
200  unsigned indexInBlock((*bit).second);
201  //Dereference the block (what a palava!)
202  const PFBlock& block = *blockRef;
203  //And finally get a handle on the elements
205  //get references to the candidate's track, ecal clusters and hcal clusters
206  switch (elements[indexInBlock].type()) {
207  case PFBlockElement::ECAL: {
208  reco::PFClusterRef clusterRef = elements[indexInBlock].clusterRef();
209  const PFCluster theRealCluster = *clusterRef;
210  CalibratableElement d(theRealCluster.energy(),
211  theRealCluster.positionREP().eta(), theRealCluster.positionREP().phi(), theRealCluster.layer() );
212  calib_->cluster_ecal_.push_back(d);
213  if (debug_ > 4)
214  std::cout << "\t\tECAL cluster: "<< theRealCluster << "\n";
215 
216  break;
217  }
218 
219  case PFBlockElement::HCAL: {
220  reco::PFClusterRef clusterRef = elements[indexInBlock].clusterRef();
221  const PFCluster theRealCluster = *clusterRef;
222  CalibratableElement d(theRealCluster.energy(),
223  theRealCluster.positionREP().eta(), theRealCluster.positionREP().phi(), theRealCluster.layer() );
224  calib_->cluster_hcal_.push_back(d);
225  if (debug_ > 4)
226  std::cout << "\t\tHCAL cluster: "<< theRealCluster << "\n";
227 
228  break;
229  }
230 
231  default:
232  if (debug_ > 3)
233  std::cout << "\t\tOther block type: "
234  << elements[indexInBlock].type() << "\n";
235  break;
236  }
237 
238  }
239  //For each candidate found,
240  calib_->cands_.push_back(cw);
241 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:86
type
Definition: HCALResponse.h:21
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
Small wrapper class for storing individual rechit and cluster information.
Definition: Calibratable.h:24
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
pftools::Calibratable * calib_
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:381
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:90
std::vector< CandidateWrapper > cands_
Definition: Calibratable.h:196
double energy() const
cluster energy
Definition: PFCluster.h:79
std::vector< CalibratableElement > cluster_ecal_
Definition: Calibratable.h:184
std::vector< CalibratableElement > cluster_hcal_
Definition: Calibratable.h:184
tuple cout
Definition: gather_cfg.py:121
Small wrapper class to store information associated with PFCandidates.
Definition: Calibratable.h:66
Block of elements.
Definition: PFBlock.h:30
void CalibratableTest::fillTreeAndReset ( )
privatevirtual

Definition at line 270 of file CalibratableTest.cc.

References calib_, gather_cfg::cout, debug_, nParticleFails_, nParticleWrites_, pftools::Calibratable::recompute(), pftools::Calibratable::reset(), thisEventPasses_, thisParticlePasses_, and tree_.

Referenced by analyze().

270  {
273  calib_->recompute();
274  if (debug_> 4) {
275  //print a summary
276  std::cout << *calib_;
277  }
278  tree_->Fill();
279  } else {
280  ++nParticleFails_;
281  }
282  if (debug_ > 1)
283  std::cout << "\t**Finished particle.**\n";
284  calib_->reset();
285 }
pftools::Calibratable * calib_
virtual void reset()
virtual void recompute()
Definition: Calibratable.cc:45
tuple cout
Definition: gather_cfg.py:121
std::vector< unsigned > CalibratableTest::findCandidatesInDeltaR ( const reco::PFSimParticle pft,
const std::vector< reco::PFCandidate > &  cands,
const double &  deltaR 
)
private

Definition at line 243 of file CalibratableTest.cc.

References deltaR(), reco::LeafCandidate::eta(), cmsHarvester::index, reco::LeafCandidate::phi(), reco::PFTrajectoryPoint::positionREP(), and reco::PFTrack::trajectoryPoint().

Referenced by analyze().

245  {
246 
247  unsigned index(0);
248  std::vector<unsigned> answers;
249 
250  double trEta = pft.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Eta();
251  double trPhi = pft.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Phi();
252 
253  for (std::vector<PFCandidate>::const_iterator cit = cands.begin(); cit
254  != cands.end(); ++cit) {
255 
256  PFCandidate cand = *cit;
257  double cEta = cand.eta();
258  double cPhi = cand.phi();
259 
260  if (deltaR(cEta, trEta, cPhi, trPhi) < deltaRCut) {
261  //accept
262  answers.push_back(index);
263  }
264 
265  ++index;
266  }
267  return answers;
268 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
virtual float phi() const
momentum azimuthal angle
double deltaR(const double &eta1, const double &eta2, const double &phi1, const double &phi2)
virtual float eta() const
momentum pseudorapidity
const reco::PFTrajectoryPoint & trajectoryPoint(unsigned index) const
Definition: PFTrack.h:102
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::vector< unsigned > CalibratableTest::findPrimarySimParticles ( const std::vector< reco::PFSimParticle > &  sims)
private

Definition at line 145 of file CalibratableTest.cc.

References funct::abs(), reco::PFSimParticle::daughterIds(), cmsHarvester::index, reco::PFSimParticle::motherId(), and reco::PFSimParticle::pdgCode().

Referenced by analyze().

146  {
147  std::vector<unsigned> answers;
148  unsigned index(0);
149  for (std::vector<PFSimParticle>::const_iterator cit = sims.begin(); cit
150  != sims.end(); ++cit) {
151  PFSimParticle theSim = *cit;
152  //TODO: what about rejected events?
153  if (theSim.motherId() >= 0)
154  continue;
155  int particleId = abs(theSim.pdgCode());
156  if (particleId != 211)
157  continue;
158  //TODO: ...particularly interacting pions?
159  if (theSim.daughterIds().size() > 0)
160  continue;
161  answers.push_back(index);
162  ++index;
163  }
164  return answers;
165 }
const std::vector< int > & daughterIds() const
Definition: PFSimParticle.h:44
int pdgCode() const
Definition: PFSimParticle.h:35
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
true particle for particle flow
Definition: PFSimParticle.h:19
int motherId() const
Definition: PFSimParticle.h:41
template<class T >
void CalibratableTest::getCollection ( edm::Handle< T > &  c,
const edm::InputTag tag,
const edm::Event event 
) const

Definition at line 147 of file CalibratableTest.h.

References gather_cfg::cout, and edm::HandleBase::isValid().

Referenced by analyze().

148  {
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 }
bool isValid() const
Definition: HandleBase.h:76
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

pftools::Calibratable* CalibratableTest::calib_
private

Definition at line 123 of file CalibratableTest.h.

Referenced by analyze(), CalibratableTest(), extractCandidate(), and fillTreeAndReset().

edm::Handle<reco::PFClusterCollection>* CalibratableTest::clustersEcal_
private

Definition at line 142 of file CalibratableTest.h.

Referenced by analyze().

edm::Handle<reco::PFClusterCollection>* CalibratableTest::clustersHcal_
private

Definition at line 143 of file CalibratableTest.h.

Referenced by analyze().

int CalibratableTest::debug_
private
double CalibratableTest::deltaRCandToSim_
private

Definition at line 131 of file CalibratableTest.h.

Referenced by analyze(), and CalibratableTest().

edm::Service<TFileService> CalibratableTest::fileservice_
private

Definition at line 109 of file CalibratableTest.h.

Referenced by CalibratableTest().

edm::InputTag CalibratableTest::inputTagCandidates_
private

Definition at line 134 of file CalibratableTest.h.

Referenced by analyze(), and CalibratableTest().

edm::InputTag CalibratableTest::inputTagClustersEcal_
private

Definition at line 136 of file CalibratableTest.h.

Referenced by analyze(), and CalibratableTest().

edm::InputTag CalibratableTest::inputTagClustersHcal_
private

Definition at line 137 of file CalibratableTest.h.

Referenced by analyze(), and CalibratableTest().

edm::InputTag CalibratableTest::inputTagSimParticles_
private

Definition at line 135 of file CalibratableTest.h.

Referenced by analyze(), and CalibratableTest().

unsigned CalibratableTest::nEventFails_
private

Definition at line 128 of file CalibratableTest.h.

Referenced by analyze(), and endJob().

unsigned CalibratableTest::nEventWrites_
private

Definition at line 128 of file CalibratableTest.h.

Referenced by analyze(), and endJob().

unsigned CalibratableTest::nParticleFails_
private

Definition at line 127 of file CalibratableTest.h.

Referenced by endJob(), and fillTreeAndReset().

unsigned CalibratableTest::nParticleWrites_
private

Definition at line 127 of file CalibratableTest.h.

Referenced by endJob(), and fillTreeAndReset().

edm::Handle<reco::PFCandidateCollection>* CalibratableTest::pfCandidates_
private

Definition at line 140 of file CalibratableTest.h.

Referenced by analyze().

edm::Handle<reco::PFSimParticleCollection>* CalibratableTest::simParticles_
private

Definition at line 141 of file CalibratableTest.h.

Referenced by analyze().

bool CalibratableTest::thisEventPasses_
private

Definition at line 116 of file CalibratableTest.h.

Referenced by analyze(), and fillTreeAndReset().

bool CalibratableTest::thisParticlePasses_
private

Definition at line 120 of file CalibratableTest.h.

Referenced by analyze(), and fillTreeAndReset().

TTree* CalibratableTest::tree_
private

Definition at line 106 of file CalibratableTest.h.

Referenced by CalibratableTest(), and fillTreeAndReset().