CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MCSingleParticleYPt Class Reference
Inheritance diagram for MCSingleParticleYPt:
edm::global::EDFilter<> edm::global::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 MCSingleParticleYPt (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const bool fchekantiparticle
 
const int fVerbose
 
std::vector< int > particleID
 
std::vector< double > ptMin
 
std::vector< double > rapMax
 
std::vector< double > rapMin
 
std::vector< int > status
 
const edm::EDGetTokenT< edm::HepMCProducttoken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDFilterBase
typedef EDFilterBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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 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

Definition at line 36 of file MCSingleParticleYPt.cc.

Constructor & Destructor Documentation

◆ MCSingleParticleYPt()

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

Definition at line 56 of file MCSingleParticleYPt.cc.

References fchekantiparticle, fVerbose, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, particleID, ptMin, rapMax, rapMin, and status.

57  : token_(consumes<edm::HepMCProduct>(
58  edm::InputTag(iConfig.getUntrackedParameter("moduleLabel", std::string("generator")), "unsmeared"))),
59  fVerbose(iConfig.getUntrackedParameter("verbose", 0)),
60  fchekantiparticle(iConfig.getUntrackedParameter("CheckAntiparticle", true)) {
61  vector<int> defpid;
62  defpid.push_back(0);
63  particleID = iConfig.getUntrackedParameter<vector<int> >("ParticleID", defpid);
64  vector<double> defptmin;
65  defptmin.push_back(0.);
66  ptMin = iConfig.getUntrackedParameter<vector<double> >("MinPt", defptmin);
67  vector<double> defrapmin;
68  defrapmin.push_back(-10.);
69  rapMin = iConfig.getUntrackedParameter<vector<double> >("MinY", defrapmin);
70  vector<double> defrapmax;
71  defrapmax.push_back(10.);
72  rapMax = iConfig.getUntrackedParameter<vector<double> >("MaxY", defrapmax);
73  vector<int> defstat;
74  defstat.push_back(0);
75  status = iConfig.getUntrackedParameter<vector<int> >("Status", defstat);
76 
77  // check for same size
78  if ((ptMin.size() > 1 && particleID.size() != ptMin.size()) ||
79  (rapMin.size() > 1 && particleID.size() != rapMin.size()) ||
80  (rapMax.size() > 1 && particleID.size() != rapMax.size()) ||
81  (status.size() > 1 && particleID.size() != status.size())) {
82  edm::LogWarning("MCSingleParticleYPt")
83  << "WARNING: MCSingleParticleYPt : size of vector cuts do not match!!" << endl;
84  }
85 
86  // if ptMin size smaller than particleID , fill up further with defaults
87  if (particleID.size() > ptMin.size()) {
88  vector<double> defptmin2;
89  for (unsigned int i = 0; i < particleID.size(); i++) {
90  defptmin2.push_back(0.);
91  }
92  ptMin = defptmin2;
93  }
94  // if etaMin size smaller than particleID , fill up further with defaults
95  if (particleID.size() > rapMin.size()) {
96  vector<double> defrapmin2;
97  for (unsigned int i = 0; i < particleID.size(); i++) {
98  defrapmin2.push_back(-10.);
99  }
100  rapMin = defrapmin2;
101  }
102  // if etaMax size smaller than particleID , fill up further with defaults
103  if (particleID.size() > rapMax.size()) {
104  vector<double> defrapmax2;
105  for (unsigned int i = 0; i < particleID.size(); i++) {
106  defrapmax2.push_back(10.);
107  }
108  rapMax = defrapmax2;
109  }
110  // if status size smaller than particleID , fill up further with defaults
111  if (particleID.size() > status.size()) {
112  vector<int> defstat2;
113  for (unsigned int i = 0; i < particleID.size(); i++) {
114  defstat2.push_back(0);
115  }
116  status = defstat2;
117  }
118 
119  if (fVerbose > 0) {
120  edm::LogInfo("MCSingleParticleYPt") << "----------------------------------------------------------------------"
121  << std::endl;
122  edm::LogInfo("MCSingleParticleYPt") << "----- MCSingleParticleYPt" << std::endl;
123  for (unsigned int i = 0; i < particleID.size(); ++i) {
124  edm::LogInfo("MCSingleParticleYPt") << " ID: " << particleID[i] << " pT > " << ptMin[i] << ", " << rapMin[i]
125  << " < y < " << rapMax[i] << ", status = " << status[i] << std::endl;
126  }
127  if (fchekantiparticle)
128  edm::LogInfo("MCSingleParticleYPt") << " anti-particles will be tested as well." << std::endl;
129  edm::LogInfo("MCSingleParticleYPt") << "----------------------------------------------------------------------"
130  << std::endl;
131  }
132 }
std::vector< int > particleID
std::vector< int > status
std::vector< double > rapMax
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > ptMin
Log< level::Info, false > LogInfo
const edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > rapMin
Log< level::Warning, false > LogWarning

Member Function Documentation

◆ filter()

bool MCSingleParticleYPt::filter ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup  
) const
overridevirtual

Implements edm::global::EDFilterBase.

Definition at line 134 of file MCSingleParticleYPt.cc.

References fchekantiparticle, fVerbose, edm::HepMCProduct::GetEvent(), mps_fire::i, iEvent, dqm-mbProfile::log, AlCaHLTBitMon_ParallelJobs::p, particleID, ptMin, rapMax, rapMin, status, and token_.

134  {
135  bool accepted = false;
137  iEvent.getByToken(token_, evt);
138 
139  const HepMC::GenEvent* myGenEvent = evt->GetEvent();
140  for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
141  ++p) {
142  if (fVerbose > 3)
143  edm::LogInfo("MCSingleParticleYPt")
144  << "Looking at particle : " << (*p)->pdg_id() << " status : " << (*p)->status() << std::endl;
145 
146  for (unsigned int i = 0; i < particleID.size(); i++) {
147  if (particleID[i] == (*p)->pdg_id() || (fchekantiparticle && (-particleID[i] == (*p)->pdg_id())) ||
148  particleID[i] == 0) {
149  // calculate rapidity just for the desired particle and make sure, this particles has enough energy
150  double rapidity = ((*p)->momentum().e() - (*p)->momentum().pz()) > 0.
151  ? 0.5 * log(((*p)->momentum().e() + (*p)->momentum().pz()) /
152  ((*p)->momentum().e() - (*p)->momentum().pz()))
153  : rapMax[i] + .1;
154  if (fVerbose > 2)
155  edm::LogInfo("MCSingleParticleYPt")
156  << "Testing particle : " << (*p)->pdg_id() << " pT: " << (*p)->momentum().perp() << " y: " << rapidity
157  << " status : " << (*p)->status() << endl;
158  if ((*p)->momentum().perp() > ptMin[i] && rapidity > rapMin[i] && rapidity < rapMax[i] &&
159  ((*p)->status() == status[i] || status[i] == 0)) {
160  accepted = true;
161  if (fVerbose > 1)
162  edm::LogInfo("MCSingleParticleYPt")
163  << "Accepted particle : " << (*p)->pdg_id() << " pT: " << (*p)->momentum().perp() << " y: " << rapidity
164  << " status : " << (*p)->status() << endl;
165  break;
166  }
167  }
168  }
169  if (accepted)
170  break;
171  }
172  return accepted;
173 }
std::vector< int > particleID
std::vector< int > status
std::vector< double > rapMax
int iEvent
Definition: GenABIO.cc:224
std::vector< double > ptMin
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
Log< level::Info, false > LogInfo
const edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > rapMin

Member Data Documentation

◆ fchekantiparticle

const bool MCSingleParticleYPt::fchekantiparticle
private

Definition at line 45 of file MCSingleParticleYPt.cc.

Referenced by filter(), and MCSingleParticleYPt().

◆ fVerbose

const int MCSingleParticleYPt::fVerbose
private

Definition at line 44 of file MCSingleParticleYPt.cc.

Referenced by filter(), and MCSingleParticleYPt().

◆ particleID

std::vector<int> MCSingleParticleYPt::particleID
private

Definition at line 46 of file MCSingleParticleYPt.cc.

Referenced by filter(), and MCSingleParticleYPt().

◆ ptMin

std::vector<double> MCSingleParticleYPt::ptMin
private

Definition at line 47 of file MCSingleParticleYPt.cc.

Referenced by filter(), and MCSingleParticleYPt().

◆ rapMax

std::vector<double> MCSingleParticleYPt::rapMax
private

Definition at line 49 of file MCSingleParticleYPt.cc.

Referenced by filter(), and MCSingleParticleYPt().

◆ rapMin

std::vector<double> MCSingleParticleYPt::rapMin
private

Definition at line 48 of file MCSingleParticleYPt.cc.

Referenced by filter(), and MCSingleParticleYPt().

◆ status

std::vector<int> MCSingleParticleYPt::status
private

◆ token_

const edm::EDGetTokenT<edm::HepMCProduct> MCSingleParticleYPt::token_
private

Definition at line 43 of file MCSingleParticleYPt.cc.

Referenced by filter().