CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BPhysicsValidation.cc
Go to the documentation of this file.
1 //
3 // class Validation: Class to fill dqm monitor elements from existing EDM file
4 //
6 
8 
10 
11 #include "CLHEP/Units/defs.h"
12 #include "CLHEP/Units/PhysicalConstants.h"
13 
14 using namespace edm;
15 
17  genparticleCollection_(iPSet.getParameter<edm::InputTag>("genparticleCollection")),
18  // do not include weights right now to allow for running on aod
19  name(iPSet.getParameter< std::string>("name")),
20  particle(name,iPSet)
21 {
22  genparticleCollectionToken_=consumes<reco::GenParticleCollection>(genparticleCollection_);
23  std::vector<std::string> daughterNames = iPSet.getParameter< std::vector<std::string> >("daughters");
24  for (unsigned int i=0; i<daughterNames.size();i++){
25  std::string curSet = daughterNames[i];
26  daughters.push_back(ParticleMonitor(name+curSet,iPSet.getUntrackedParameter< ParameterSet >(curSet)));
27  }
28 }
29 
31 
33 
36  for(unsigned int j=0;j<daughters.size();j++){std::cout << j << std::endl; daughters[j].Configure(i);}
37 }
38 
41  iEvent.getByToken(genparticleCollectionToken_, genParticles );
42  for (reco::GenParticleCollection::const_iterator iter = genParticles->begin(); iter != genParticles->end(); ++iter) {
43  if(abs(iter->pdgId())==abs(particle.PDGID())){
44  particle.Fill(&(*iter), 1.0);
45  FillDaughters(&(*iter));
46  }
47  }
48 }
49 
51  int mpdgid=p->pdgId();
52  for(unsigned int i = 0; i <p->numberOfDaughters(); i++){
53  const reco::GenParticle *dau=static_cast<const reco::GenParticle*>(p->daughter(i));
54  int pdgid = dau->pdgId();
55  for(unsigned int i=0;i<daughters.size();i++){
56  if(abs(mpdgid)!=abs(daughters[i].PDGID()) && daughters[i].PDGID()==pdgid)daughters[i].Fill(dau,1.0);
57  // note: use abs when comparing to mother to avoid mixing
58  }
59  FillDaughters(dau);
60  }
61 }
62 
63 
void Configure(DQMStore::IBooker &i)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
BPhysicsValidation(const edm::ParameterSet &)
edm::EDGetTokenT< reco::GenParticleCollection > genparticleCollectionToken_
int iEvent
Definition: GenABIO.cc:230
ParticleMonitor particle
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
edm::InputTag genparticleCollection_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
virtual void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
void FillDaughters(const reco::GenParticle *p)
void Fill(const reco::GenParticle *p, double weight)
tuple cout
Definition: gather_cfg.py:121
std::vector< ParticleMonitor > daughters
Definition: Run.h:41
virtual void analyze(edm::Event const &, edm::EventSetup const &) override