CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
< GenEventInfoProduct
genInfoToken_
 
edm::EDGetTokenT
< reco::GenJetCollection
genJetToken_
 
edm::EDGetTokenT
< reco::GenParticleCollection
genParticleToken_
 
std::unique_ptr
< L1Analysis::L1AnalysisGeneratorDataFormat
l1GenData_
 
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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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< B > consumes (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 () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 83 of file L1GenTreeProducer.cc.

References fs_, genInfoToken_, genJetToken_, genParticleToken_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), 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  // set up output
94  tree_ = fs_->make<TTree>("L1GenTree", "L1GenTree");
95  tree_->Branch("Generator", "L1Analysis::L1AnalysisGeneratorDataFormat", l1GenData_.get(), 32000, 3);
96 }
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::EDGetTokenT< GenEventInfoProduct > genInfoToken_
edm::Service< TFileService > fs_
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< L1Analysis::L1AnalysisGeneratorDataFormat > l1GenData_
L1GenTreeProducer::~L1GenTreeProducer ( )
override

Definition at line 98 of file L1GenTreeProducer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 108 of file L1GenTreeProducer.cc.

References funct::abs(), makePileupJSON::bx, reco::LeafCandidate::charge(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), Exception, genInfoToken_, genJetToken_, genParticleCandidates2GenParticles_cfi::genParticles, genParticleToken_, edm::Event::getByToken(), mps_fire::i, edm::HandleBase::isValid(), l1GenData_, reco::CompositeRefCandidateT< D >::mother(), nPart(), reco::CompositeRefCandidateT< D >::numberOfMothers(), AlCaHLTBitMon_ParallelJobs::p, reco::LeafCandidate::pdgId(), reco::LeafCandidate::phi(), pileupInfoToken_, reco::LeafCandidate::pt(), reco::LeafCandidate::status(), and tree_.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 203 of file L1GenTreeProducer.cc.

203 {}
void L1GenTreeProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 206 of file L1GenTreeProducer.cc.

206 {}

Member Data Documentation

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

Definition at line 68 of file L1GenTreeProducer.cc.

Referenced by L1GenTreeProducer().

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

Definition at line 80 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

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

Definition at line 77 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

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

Definition at line 78 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

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

Definition at line 74 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

unsigned L1GenTreeProducer::maxL1Upgrade_
private

Definition at line 65 of file L1GenTreeProducer.cc.

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

Definition at line 79 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().

TTree* L1GenTreeProducer::tree_
private

Definition at line 71 of file L1GenTreeProducer.cc.

Referenced by analyze(), and L1GenTreeProducer().