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::nMeanPU, 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  if (false) {
145  // if (genParticles.isValid()) {
146 
147  for(size_t i = 0; i < genParticles->size(); ++ i) {
148  const reco::GenParticle & p = (*genParticles)[i];
149  int id = p.pdgId();
150  //int st = p.status();
151  if (abs(id) == 13) {
152  unsigned int nMo=p.numberOfMothers();
153  //std::cout << "id " << id << "; st " << st
154  //<< "; nMo " << nMo << std::endl;
155  for(unsigned int i=0;i<nMo;++i){
156  //int thisParentID = dynamic_cast<const reco::GenParticle*>(p.mother(i))->pdgId();
157  //std::cout << " mother ID " << thisParentID << std::endl;
158  }
159  }
160 
161  //
162  // See if the parent was interesting
163  int parentID = -10000;
164  unsigned int nMo=p.numberOfMothers();
165  for(unsigned int i=0;i<nMo;++i){
166  int thisParentID = dynamic_cast
167  <const reco::GenParticle*>(p.mother(i))->pdgId();
168  //
169  // Is this a bottom hadron?
170  int hundredsIndex = abs(thisParentID)/100;
171  int thousandsIndex = abs(thisParentID)/1000;
172  if ( ((abs(thisParentID) >= 23) &&
173  (abs(thisParentID) <= 25)) ||
174  (abs(thisParentID) == 6) ||
175  (hundredsIndex == 5) ||
176  (hundredsIndex == 4) ||
177  (thousandsIndex == 5) ||
178  (thousandsIndex == 4)
179  )
180  parentID = thisParentID;
181  }
182  if ((parentID == -10000) && (nMo > 0))
183  parentID = dynamic_cast
184  <const reco::GenParticle*>(p.mother(0))->pdgId();
185  //
186  // If the parent of this particle is interesting, store all of the info
187  if ((parentID != p.pdgId()) &&
188  ((parentID > -9999)
189  || (abs(id) == 11)
190  || (abs(id) == 13)
191  || (abs(id) == 23)
192  || (abs(id) == 24)
193  || (abs(id) == 25)
194  || (abs(id) == 4)
195  || (abs(id) == 5)
196  || (abs(id) == 6))
197  )
198  {
199  l1GenData_->partId.push_back(p.pdgId());
200  l1GenData_->partStat.push_back(p.status());
201  l1GenData_->partPt.push_back(p.pt());
202  l1GenData_->partEta.push_back(p.eta());
203  l1GenData_->partPhi.push_back(p.phi());
204  l1GenData_->partE.push_back(p.energy());
205  l1GenData_->partParent.push_back(parentID);
206  }
207  }
208 
209  }
210 
211 
213  iEvent.getByToken(pileupInfoToken_, puInfoCollection);
214 
215  if (!puInfoCollection.isValid()) {
216  throw cms::Exception("ProductNotValid") << "pileupInfoSource not valid";
217  }
218 
219  // Loop over vector, find in-time entry, then store the relevant info
220  std::vector<PileupSummaryInfo>::const_iterator puItr = puInfoCollection->begin();
221  std::vector<PileupSummaryInfo>::const_iterator puEnd = puInfoCollection->end();
222  for( ; puItr != puEnd; ++puItr) {
223  int bx = puItr->getBunchCrossing();
224  if (bx == 0) {
225  l1GenData_->nMeanPU = puItr->getTrueNumInteractions();
226  l1GenData_->nVtx = puItr->getPU_NumInteractions();
227  break;
228  }
229  }
230 
231 
232 
233  tree_->Fill();
234 
235 }
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 239 of file L1GenTreeProducer.cc.

240 {
241 }
void L1GenTreeProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 245 of file L1GenTreeProducer.cc.

245  {
246 }

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().