CMS 3D CMS Logo

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::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 L1GenTreeProducer (const edm::ParameterSet &)
 
 ~L1GenTreeProducer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob (void) override
 
void endJob () override
 

Private Attributes

edm::Service< TFileServicefs_
 
edm::EDGetTokenT< GenEventInfoProductgenInfoToken_
 
edm::EDGetTokenT< reco::GenJetCollectiongenJetToken_
 
edm::EDGetTokenT< reco::GenParticleCollectiongenParticleToken_
 
std::unique_ptr< L1Analysis::L1AnalysisGeneratorDataFormatl1GenData_
 
unsigned maxL1Upgrade_
 
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken_
 
TTree * tree_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Produce L1 Extra tree

Implementation:

Definition at line 54 of file L1GenTreeProducer.cc.

Constructor & Destructor Documentation

◆ L1GenTreeProducer()

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

Definition at line 83 of file L1GenTreeProducer.cc.

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

83  {
84  genJetToken_ = consumes<reco::GenJetCollection>(iConfig.getUntrackedParameter<edm::InputTag>("genJetToken"));
86  consumes<reco::GenParticleCollection>(iConfig.getUntrackedParameter<edm::InputTag>("genParticleToken"));
88  consumes<std::vector<PileupSummaryInfo>>(iConfig.getUntrackedParameter<edm::InputTag>("pileupInfoToken"));
89  genInfoToken_ = consumes<GenEventInfoProduct>(iConfig.getParameter<edm::InputTag>("genInfoToken"));
90 
91  l1GenData_ = std::make_unique<L1Analysis::L1AnalysisGeneratorDataFormat>();
92 
93  usesResource(TFileService::kSharedResource);
94  // set up output
95  tree_ = fs_->make<TTree>("L1GenTree", "L1GenTree");
96  tree_->Branch("Generator", "L1Analysis::L1AnalysisGeneratorDataFormat", l1GenData_.get(), 32000, 3);
97 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken_
edm::EDGetTokenT< GenEventInfoProduct > genInfoToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::Service< TFileService > fs_
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
std::unique_ptr< L1Analysis::L1AnalysisGeneratorDataFormat > l1GenData_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ ~L1GenTreeProducer()

L1GenTreeProducer::~L1GenTreeProducer ( )
override

Definition at line 99 of file L1GenTreeProducer.cc.

99  {
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 109 of file L1GenTreeProducer.cc.

References funct::abs(), GenEventInfoProduct::binningValues(), l1GtPatternGenerator_cfi::bx, Exception, genInfoToken_, l1tCaloJetHTTProducer_cfi::genJets, genJetToken_, AJJGenJetFilter_cfi::genParticles, genParticleToken_, GenEventInfoProduct::hasBinningValues(), mps_fire::i, iEvent, edm::HandleBase::isValid(), l1GenData_, nPart(), AlCaHLTBitMon_ParallelJobs::p, EgammaValidation_cff::pdgId, pileupInfoToken_, tree_, and GenEventInfoProduct::weight().

109  {
111  iEvent.getByToken(genInfoToken_, genInfo);
112 
113  l1GenData_->Reset();
114 
115  if (genInfo.isValid()) {
116  l1GenData_->weight = genInfo->weight();
117  l1GenData_->pthat = genInfo->hasBinningValues() ? (genInfo->binningValues())[0] : 0.0;
118  }
119 
121  iEvent.getByToken(genJetToken_, genJets);
122 
123  if (genJets.isValid()) {
124  reco::GenJetCollection::const_iterator jetItr = genJets->begin();
125  reco::GenJetCollection::const_iterator jetEnd = genJets->end();
126  for (; jetItr != jetEnd; ++jetItr) {
127  l1GenData_->jetPt.push_back(jetItr->pt());
128  l1GenData_->jetEta.push_back(jetItr->eta());
129  l1GenData_->jetPhi.push_back(jetItr->phi());
130  l1GenData_->nJet++;
131  }
132 
133  } else {
134  edm::LogWarning("MissingProduct") << "Gen jets not found. Branch will not be filled" << std::endl;
135  }
136 
139 
140  if (genParticles.isValid()) {
141  int nPart{0};
142 
143  for (size_t i = 0; i < genParticles->size(); ++i) {
144  const reco::GenParticle& p = (*genParticles)[i];
145  int id = p.pdgId();
146 
147  // See if the parent was interesting
148  int parentID = -10000;
149  unsigned int nMo = p.numberOfMothers();
150  for (unsigned int i = 0; i < nMo; ++i) {
151  int thisParentID = dynamic_cast<const reco::GenParticle*>(p.mother(i))->pdgId();
152  //
153  // Is this a bottom hadron?
154  int hundredsIndex = abs(thisParentID) / 100;
155  int thousandsIndex = abs(thisParentID) / 1000;
156  if (((abs(thisParentID) >= 23) && (abs(thisParentID) <= 25)) || (abs(thisParentID) == 6) ||
157  (hundredsIndex == 5) || (hundredsIndex == 4) || (thousandsIndex == 5) || (thousandsIndex == 4))
158  parentID = thisParentID;
159  }
160  if ((parentID == -10000) && (nMo > 0))
161  parentID = dynamic_cast<const reco::GenParticle*>(p.mother(0))->pdgId();
162  //
163  // If the parent of this particle is interesting, store all of the info
164  if ((parentID != p.pdgId()) &&
165  ((parentID > -9999) || (abs(id) == 11) || (abs(id) == 13) || (abs(id) == 23) || (abs(id) == 24) ||
166  (abs(id) == 25) || (abs(id) == 4) || (abs(id) == 5) || (abs(id) == 6))) {
167  l1GenData_->partId.push_back(p.pdgId());
168  l1GenData_->partStat.push_back(p.status());
169  l1GenData_->partPt.push_back(p.pt());
170  l1GenData_->partEta.push_back(p.eta());
171  l1GenData_->partPhi.push_back(p.phi());
172  l1GenData_->partE.push_back(p.energy());
173  l1GenData_->partParent.push_back(parentID);
174  l1GenData_->partCh.push_back(p.charge());
175  ++nPart;
176  }
177  }
178  l1GenData_->nPart = nPart;
179  }
180 
182  iEvent.getByToken(pileupInfoToken_, puInfoCollection);
183 
184  if (!puInfoCollection.isValid()) {
185  throw cms::Exception("ProductNotValid") << "pileupInfoSource not valid";
186  }
187 
188  // Loop over vector, find in-time entry, then store the relevant info
189  std::vector<PileupSummaryInfo>::const_iterator puItr = puInfoCollection->begin();
190  std::vector<PileupSummaryInfo>::const_iterator puEnd = puInfoCollection->end();
191  for (; puItr != puEnd; ++puItr) {
192  int bx = puItr->getBunchCrossing();
193  if (bx == 0) {
194  l1GenData_->nMeanPU = puItr->getTrueNumInteractions();
195  l1GenData_->nVtx = puItr->getPU_NumInteractions();
196  break;
197  }
198  }
199 
200  tree_->Fill();
201 }
const std::vector< double > & binningValues() const
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken_
edm::EDGetTokenT< GenEventInfoProduct > genInfoToken_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
std::unique_ptr< L1Analysis::L1AnalysisGeneratorDataFormat > l1GenData_
bool isValid() const
Definition: HandleBase.h:70
bool hasBinningValues() const
Log< level::Warning, false > LogWarning

◆ beginJob()

void L1GenTreeProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 204 of file L1GenTreeProducer.cc.

204 {}

◆ endJob()

void L1GenTreeProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 207 of file L1GenTreeProducer.cc.

207 {}

Member Data Documentation

◆ fs_

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

Definition at line 68 of file L1GenTreeProducer.cc.

Referenced by L1GenTreeProducer().

◆ genInfoToken_

edm::EDGetTokenT<GenEventInfoProduct> L1GenTreeProducer::genInfoToken_
private

Definition at line 80 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

◆ genJetToken_

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

Definition at line 77 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

◆ genParticleToken_

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

Definition at line 78 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

◆ l1GenData_

std::unique_ptr<L1Analysis::L1AnalysisGeneratorDataFormat> L1GenTreeProducer::l1GenData_
private

Definition at line 74 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

◆ maxL1Upgrade_

unsigned L1GenTreeProducer::maxL1Upgrade_
private

Definition at line 65 of file L1GenTreeProducer.cc.

◆ pileupInfoToken_

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

Definition at line 79 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

◆ tree_

TTree* L1GenTreeProducer::tree_
private

Definition at line 71 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().