test
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
L1GenTreeProducer Class Reference

#include <L1TriggerDPG/L1Ntuples/src/L1GenTreeProducer.cc>

Inheritance diagram for L1GenTreeProducer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 L1GenTreeProducer (const edm::ParameterSet &)
 
 ~L1GenTreeProducer ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 (void)
 
virtual void endJob ()
 

Private Attributes

edm::Service< TFileServicefs_
 
edm::EDGetTokenT
< reco::GenJetCollection
genJetToken_
 
edm::EDGetTokenT
< reco::GenParticleCollection
genParticleToken_
 
L1Analysis::L1AnalysisGeneratorDataFormatl1GenData_
 
unsigned maxL1Upgrade_
 
edm::EDGetTokenT< std::vector
< PileupSummaryInfo > > 
pileupInfoToken_
 
TTree * tree_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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

Description: Produce L1 Extra tree

Implementation:

Definition at line 55 of file L1GenTreeProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 88 of file L1GenTreeProducer.cc.

References fs_, genJetToken_, genParticleToken_, edm::ParameterSet::getUntrackedParameter(), l1GenData_, TFileService::make(), pileupInfoToken_, and tree_.

89 {
90 
91  genJetToken_ = consumes<reco::GenJetCollection>(iConfig.getUntrackedParameter<edm::InputTag>("genJetToken"));
92  genParticleToken_ = consumes<reco::GenParticleCollection>(iConfig.getUntrackedParameter<edm::InputTag>("genParticleToken"));
93  pileupInfoToken_ = consumes<std::vector<PileupSummaryInfo> >(iConfig.getUntrackedParameter<edm::InputTag>("pileupInfoToken"));
94 
95  // set up output
96  tree_=fs_->make<TTree>("L1GenTree", "L1GenTree");
97  tree_->Branch("Generator", "L1Analysis::L1AnalysisGeneratorDataFormat", &l1GenData_, 32000, 3);
98 
99 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::Service< TFileService > fs_
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
L1Analysis::L1AnalysisGeneratorDataFormat * l1GenData_
L1GenTreeProducer::~L1GenTreeProducer ( )

Definition at line 102 of file L1GenTreeProducer.cc.

103 {
104 
105  // do anything here that needs to be done at desctruction time
106  // (e.g. close files, deallocate resources etc.)
107 
108 }

Member Function Documentation

void L1GenTreeProducer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 117 of file L1GenTreeProducer.cc.

References funct::abs(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), Exception, genJetToken_, genParticleCandidates2GenParticles_cfi::genParticles, genParticleToken_, edm::Event::getByToken(), i, edm::HandleBase::isValid(), L1Analysis::L1AnalysisGeneratorDataFormat::jetEta, L1Analysis::L1AnalysisGeneratorDataFormat::jetPhi, L1Analysis::L1AnalysisGeneratorDataFormat::jetPt, l1GenData_, reco::CompositeRefCandidateT< D >::mother(), L1Analysis::L1AnalysisGeneratorDataFormat::nJet, L1Analysis::L1AnalysisGeneratorDataFormat::nPUPoissonMean, reco::CompositeRefCandidateT< D >::numberOfMothers(), L1Analysis::L1AnalysisGeneratorDataFormat::nVtx, AlCaHLTBitMon_ParallelJobs::p, L1Analysis::L1AnalysisGeneratorDataFormat::partE, L1Analysis::L1AnalysisGeneratorDataFormat::partEta, L1Analysis::L1AnalysisGeneratorDataFormat::partId, L1Analysis::L1AnalysisGeneratorDataFormat::partParent, L1Analysis::L1AnalysisGeneratorDataFormat::partPhi, L1Analysis::L1AnalysisGeneratorDataFormat::partPt, L1Analysis::L1AnalysisGeneratorDataFormat::partStat, SingleMuPt40Fwdv2_cfi_GEN_SIM::pdgId, reco::LeafCandidate::pdgId(), reco::LeafCandidate::phi(), pileupInfoToken_, reco::LeafCandidate::pt(), L1Analysis::L1AnalysisGeneratorDataFormat::Reset(), reco::LeafCandidate::status(), and tree_.

118 {
119 
120  l1GenData_->Reset();
121 
123  iEvent.getByToken(genJetToken_, genJets);
124 
125 
126  if (genJets.isValid()){
127 
128  reco::GenJetCollection::const_iterator jetItr = genJets->begin();
129  reco::GenJetCollection::const_iterator jetEnd = genJets->end();
130  for( ; jetItr != jetEnd ; ++jetItr) {
131  l1GenData_->jetPt.push_back( jetItr->pt() );
132  l1GenData_->jetEta.push_back( jetItr->eta() );
133  l1GenData_->jetPhi.push_back( jetItr->phi() );
134  l1GenData_->nJet++;
135  }
136 
137  } else {
138  edm::LogWarning("MissingProduct") << "Gen jets not found. Branch will not be filled" << std::endl;
139  }
140 
142  iEvent.getByToken(genParticleToken_, genParticles);
143 
144  for(size_t i = 0; i < genParticles->size(); ++ i) {
145  const reco::GenParticle & p = (*genParticles)[i];
146  int id = p.pdgId();
147  //int st = p.status();
148  if (abs(id) == 13) {
149  unsigned int nMo=p.numberOfMothers();
150  //std::cout << "id " << id << "; st " << st
151  //<< "; nMo " << nMo << std::endl;
152  for(unsigned int i=0;i<nMo;++i){
153  //int thisParentID = dynamic_cast<const reco::GenParticle*>(p.mother(i))->pdgId();
154  //std::cout << " mother ID " << thisParentID << std::endl;
155  }
156  }
157 
158  //
159  // See if the parent was interesting
160  int parentID = -10000;
161  unsigned int nMo=p.numberOfMothers();
162  for(unsigned int i=0;i<nMo;++i){
163  int thisParentID = dynamic_cast
164  <const reco::GenParticle*>(p.mother(i))->pdgId();
165  //
166  // Is this a bottom hadron?
167  int hundredsIndex = abs(thisParentID)/100;
168  int thousandsIndex = abs(thisParentID)/1000;
169  if ( ((abs(thisParentID) >= 23) &&
170  (abs(thisParentID) <= 25)) ||
171  (abs(thisParentID) == 6) ||
172  (hundredsIndex == 5) ||
173  (hundredsIndex == 4) ||
174  (thousandsIndex == 5) ||
175  (thousandsIndex == 4)
176  )
177  parentID = thisParentID;
178  }
179  if ((parentID == -10000) && (nMo > 0))
180  parentID = dynamic_cast
181  <const reco::GenParticle*>(p.mother(0))->pdgId();
182  //
183  // If the parent of this particle is interesting, store all of the info
184  if ((parentID != p.pdgId()) &&
185  ((parentID > -9999)
186  || (abs(id) == 11)
187  || (abs(id) == 13)
188  || (abs(id) == 23)
189  || (abs(id) == 24)
190  || (abs(id) == 25)
191  || (abs(id) == 4)
192  || (abs(id) == 5)
193  || (abs(id) == 6))
194  )
195  {
196  l1GenData_->partId.push_back(p.pdgId());
197  l1GenData_->partStat.push_back(p.status());
198  l1GenData_->partPt.push_back(p.pt());
199  l1GenData_->partEta.push_back(p.eta());
200  l1GenData_->partPhi.push_back(p.phi());
201  l1GenData_->partE.push_back(p.energy());
202  l1GenData_->partParent.push_back(parentID);
203  }
204  }
205 
206 
208  iEvent.getByToken(pileupInfoToken_, puInfoCollection);
209 
210  if (!puInfoCollection.isValid()) {
211  throw cms::Exception("ProductNotValid") << "pileupInfoSource not valid";
212  }
213 
214  // Loop over vector, find in-time entry, then store the relevant info
215  std::vector<PileupSummaryInfo>::const_iterator puItr = puInfoCollection->begin();
216  std::vector<PileupSummaryInfo>::const_iterator puEnd = puInfoCollection->end();
217  for( ; puItr != puEnd; ++puItr) {
218  int bx = puItr->getBunchCrossing();
219  if (bx == 0) {
220  l1GenData_->nPUPoissonMean = puItr->getTrueNumInteractions();
221  l1GenData_->nVtx = puItr->getPU_NumInteractions();
222  break;
223  }
224  }
225 
226 
227 
228  tree_->Fill();
229 
230 }
int i
Definition: DBlmapReader.cc:9
virtual double energy() const final
energy
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken_
virtual double phi() const final
momentum azimuthal angle
virtual int status() const final
status word
virtual size_t numberOfMothers() const
number of mothers
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:75
virtual int pdgId() const final
PDG identifier.
virtual double eta() const final
momentum pseudorapidity
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
L1Analysis::L1AnalysisGeneratorDataFormat * l1GenData_
virtual double pt() const final
transverse momentum
void L1GenTreeProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file L1GenTreeProducer.cc.

235 {
236 }
void L1GenTreeProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 240 of file L1GenTreeProducer.cc.

240  {
241 }

Member Data Documentation

edm::Service<TFileService> L1GenTreeProducer::fs_
private

Definition at line 71 of file L1GenTreeProducer.cc.

Referenced by L1GenTreeProducer().

edm::EDGetTokenT<reco::GenJetCollection> L1GenTreeProducer::genJetToken_
private

Definition at line 80 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

edm::EDGetTokenT<reco::GenParticleCollection> L1GenTreeProducer::genParticleToken_
private

Definition at line 81 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

L1Analysis::L1AnalysisGeneratorDataFormat* L1GenTreeProducer::l1GenData_
private

Definition at line 77 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

unsigned L1GenTreeProducer::maxL1Upgrade_
private

Definition at line 68 of file L1GenTreeProducer.cc.

edm::EDGetTokenT<std::vector<PileupSummaryInfo> > L1GenTreeProducer::pileupInfoToken_
private

Definition at line 82 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

TTree* L1GenTreeProducer::tree_
private

Definition at line 74 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().