CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MCSingleParticleYPt Class Reference

#include <MCSingleParticleYPt.h>

Inheritance diagram for MCSingleParticleYPt:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 
 MCSingleParticleYPt (const edm::ParameterSet &)
 
 ~MCSingleParticleYPt () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () 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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
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)
 
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

Definition at line 39 of file MCSingleParticleYPt.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file MCSingleParticleYPt.cc.

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

11  :
12 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared")))
13 {
14  fVerbose = iConfig.getUntrackedParameter("verbose",0);
15  fchekantiparticle = iConfig.getUntrackedParameter("CheckAntiparticle",true);
16  //here do whatever other initialization is needed
17  vector<int> defpid ;
18  defpid.push_back(0) ;
19  particleID = iConfig.getUntrackedParameter< vector<int> >("ParticleID",defpid);
20  vector<double> defptmin ;
21  defptmin.push_back(0.);
22  ptMin = iConfig.getUntrackedParameter< vector<double> >("MinPt", defptmin);
23  vector<double> defrapmin ;
24  defrapmin.push_back(-10.);
25  rapMin = iConfig.getUntrackedParameter< vector<double> >("MinY", defrapmin);
26  vector<double> defrapmax ;
27  defrapmax.push_back(10.);
28  rapMax = iConfig.getUntrackedParameter< vector<double> >("MaxY", defrapmax);
29  vector<int> defstat ;
30  defstat.push_back(0);
31  status = iConfig.getUntrackedParameter< vector<int> >("Status", defstat);
32 
33  // check for same size
34  if ( (ptMin.size() > 1 && particleID.size() != ptMin.size())
35  || (rapMin.size() > 1 && particleID.size() != rapMin.size())
36  || (rapMax.size() > 1 && particleID.size() != rapMax.size())
37  || (status.size() > 1 && particleID.size() != status.size()) ) {
38  edm::LogWarning("MCSingleParticleYPt") << "WARNING: MCSingleParticleYPt : size of vector cuts do not match!!" << endl;
39  }
40 
41  // if ptMin size smaller than particleID , fill up further with defaults
42  if (particleID.size() > ptMin.size() ){
43  vector<double> defptmin2 ;
44  for (unsigned int i = 0; i < particleID.size(); i++){ defptmin2.push_back(0.);}
45  ptMin = defptmin2;
46  }
47  // if etaMin size smaller than particleID , fill up further with defaults
48  if (particleID.size() > rapMin.size() ){
49  vector<double> defrapmin2 ;
50  for (unsigned int i = 0; i < particleID.size(); i++){ defrapmin2.push_back(-10.);}
51  rapMin = defrapmin2;
52  }
53  // if etaMax size smaller than particleID , fill up further with defaults
54  if (particleID.size() > rapMax.size() ){
55  vector<double> defrapmax2 ;
56  for (unsigned int i = 0; i < particleID.size(); i++){ defrapmax2.push_back(10.);}
57  rapMax = defrapmax2;
58  }
59  // if status size smaller than particleID , fill up further with defaults
60  if (particleID.size() > status.size() ){
61  vector<int> defstat2 ;
62  for (unsigned int i = 0; i < particleID.size(); i++){ defstat2.push_back(0);}
63  status = defstat2;
64  }
65 
66  if (fVerbose > 0) {
67  edm::LogInfo("MCSingleParticleYPt") << "----------------------------------------------------------------------" << std::endl;
68  edm::LogInfo("MCSingleParticleYPt") << "----- MCSingleParticleYPt" << std::endl;
69  for (unsigned int i=0; i<particleID.size(); ++i) {
70  edm::LogInfo("MCSingleParticleYPt") << " ID: " << particleID[i] << " pT > " << ptMin[i] << ", " << rapMin[i] << " < y < " << rapMax[i] << ", status = " << status[i] << std::endl;
71  }
72  if (fchekantiparticle) edm::LogInfo("MCSingleParticleYPt") << " anti-particles will be tested as well." << std::endl;
73  edm::LogInfo("MCSingleParticleYPt") << "----------------------------------------------------------------------" << std::endl;
74  }
75 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > particleID
std::vector< int > status
std::vector< double > rapMax
std::vector< double > ptMin
edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > rapMin
MCSingleParticleYPt::~MCSingleParticleYPt ( )
override

Definition at line 78 of file MCSingleParticleYPt.cc.

79 {
80  // do anything here that needs to be done at desctruction time
81  // (e.g. close files, deallocate resources etc.)
82 }

Member Function Documentation

bool MCSingleParticleYPt::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 86 of file MCSingleParticleYPt.cc.

References fchekantiparticle, fVerbose, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), mps_fire::i, cmsBatch::log, AlCaHLTBitMon_ParallelJobs::p, particleID, ptMin, rapidity, rapMax, rapMin, status, and token_.

87 {
88  using namespace edm;
89  bool accepted = false;
91  iEvent.getByToken(token_, evt);
92 
93  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
94  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
95  p != myGenEvent->particles_end(); ++p ) {
96  if (fVerbose > 3) edm::LogInfo("MCSingleParticleYPt") << "Looking at particle : " << (*p)->pdg_id() << " status : " << (*p)->status() << std::endl;
97 
98  for (unsigned int i = 0; i < particleID.size(); i++) {
99  if (particleID[i] == (*p)->pdg_id() || (fchekantiparticle && (-particleID[i] == (*p)->pdg_id())) || particleID[i] == 0) {
100  // calculate rapidity just for the desired particle and make sure, this particles has enough energy
101  rapidity = ((*p)->momentum().e()-(*p)->momentum().pz()) > 0. ? 0.5*log( ((*p)->momentum().e()+(*p)->momentum().pz()) / ((*p)->momentum().e()-(*p)->momentum().pz()) ) : rapMax[i]+.1;
102  if (fVerbose > 2) edm::LogInfo("MCSingleParticleYPt") << "Testing particle : " << (*p)->pdg_id() << " pT: " << (*p)->momentum().perp() << " y: " << rapidity << " status : " << (*p)->status() << endl;
103  if ( (*p)->momentum().perp() > ptMin[i]
104  && rapidity > rapMin[i]
105  && rapidity < rapMax[i]
106  && ((*p)->status() == status[i] || status[i] == 0) ) {
107  accepted = true;
108  if (fVerbose > 1)
109  edm::LogInfo("MCSingleParticleYPt") << "Accepted particle : " << (*p)->pdg_id() << " pT: " << (*p)->momentum().perp() << " y: " << rapidity << " status : " << (*p)->status() << endl;
110  break;
111  }
112 
113  }
114  }
115  if (accepted) break;
116  }
117 
118  if (accepted) { return true; }
119  else { return false; }
120 }
std::vector< int > particleID
std::vector< int > status
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< double > rapMax
std::vector< double > ptMin
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
HLT enums.
edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > rapMin

Member Data Documentation

bool MCSingleParticleYPt::fchekantiparticle
private

Definition at line 48 of file MCSingleParticleYPt.h.

Referenced by filter(), and MCSingleParticleYPt().

int MCSingleParticleYPt::fVerbose
private

Definition at line 47 of file MCSingleParticleYPt.h.

Referenced by filter(), and MCSingleParticleYPt().

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

Definition at line 50 of file MCSingleParticleYPt.h.

Referenced by filter(), and MCSingleParticleYPt().

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

Definition at line 51 of file MCSingleParticleYPt.h.

Referenced by filter(), and MCSingleParticleYPt().

double MCSingleParticleYPt::rapidity
private

Definition at line 55 of file MCSingleParticleYPt.h.

Referenced by filter().

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

Definition at line 53 of file MCSingleParticleYPt.h.

Referenced by filter(), and MCSingleParticleYPt().

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

Definition at line 52 of file MCSingleParticleYPt.h.

Referenced by filter(), and MCSingleParticleYPt().

std::vector<int> MCSingleParticleYPt::status
private
edm::EDGetTokenT<edm::HepMCProduct> MCSingleParticleYPt::token_
private

Definition at line 49 of file MCSingleParticleYPt.h.

Referenced by filter().