CMS 3D CMS Logo

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

#include <MCSmartSingleParticleFilter.h>

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

Public Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 
 MCSmartSingleParticleFilter (const edm::ParameterSet &)
 
 ~MCSmartSingleParticleFilter () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (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::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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double betaBoost
 
std::vector< double > decayRadiusMax
 
std::vector< double > decayRadiusMin
 
std::vector< double > decayZMax
 
std::vector< double > decayZMin
 
std::vector< double > etaMax
 
std::vector< double > etaMin
 
std::vector< int > particleID
 
std::vector< double > pMin
 
std::vector< double > ptMin
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 MCSmartSingleParticleFilter.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file MCSmartSingleParticleFilter.cc.

References funct::abs(), betaBoost, gather_cfg::cout, decayRadiusMax, decayRadiusMin, decayZMax, decayZMin, etaMax, etaMin, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, particleID, pMin, ptMin, and status.

12  :
13 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
14 betaBoost(iConfig.getUntrackedParameter("BetaBoost",0.))
15 {
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> defpmin ;
21  defpmin.push_back(0.);
22  pMin = iConfig.getUntrackedParameter< vector<double> >("MinP", defpmin);
23 
24  vector<double> defptmin ;
25  defptmin.push_back(0.);
26  ptMin = iConfig.getUntrackedParameter< vector<double> >("MinPt", defptmin);
27 
28  vector<double> defetamin ;
29  defetamin.push_back(-10.);
30  etaMin = iConfig.getUntrackedParameter< vector<double> >("MinEta", defetamin);
31  vector<double> defetamax ;
32  defetamax.push_back(10.);
33  etaMax = iConfig.getUntrackedParameter< vector<double> >("MaxEta", defetamax);
34  vector<int> defstat ;
35  defstat.push_back(0);
36  status = iConfig.getUntrackedParameter< vector<int> >("Status", defstat);
37 
38  vector<double> defDecayRadiusmin;
39  defDecayRadiusmin.push_back(-1.);
40  decayRadiusMin = iConfig.getUntrackedParameter< vector<double> >("MinDecayRadius", defDecayRadiusmin);
41 
42  vector<double> defDecayRadiusmax;
43  defDecayRadiusmax.push_back(1.e5);
44  decayRadiusMax = iConfig.getUntrackedParameter< vector<double> >("MaxDecayRadius", defDecayRadiusmax);
45 
46  vector<double> defDecayZmin;
47  defDecayZmin.push_back(-1.e5);
48  decayZMin = iConfig.getUntrackedParameter< vector<double> >("MinDecayZ", defDecayZmin);
49 
50  vector<double> defDecayZmax;
51  defDecayZmax.push_back(1.e5);
52  decayZMax = iConfig.getUntrackedParameter< vector<double> >("MaxDecayZ", defDecayZmax);
53 
54  // check for same size
55  if ( (pMin.size() > 1 && particleID.size() != pMin.size())
56  || (ptMin.size() > 1 && particleID.size() != ptMin.size())
57  || (etaMin.size() > 1 && particleID.size() != etaMin.size())
58  || (etaMax.size() > 1 && particleID.size() != etaMax.size())
59  || (status.size() > 1 && particleID.size() != status.size())
60  || (decayRadiusMin.size() > 1 && particleID.size() != decayRadiusMin.size())
61  || (decayRadiusMax.size() > 1 && particleID.size() != decayRadiusMax.size())
62  || (decayZMin.size() > 1 && particleID.size() != decayZMin.size())
63  || (decayZMax.size() > 1 && particleID.size() != decayZMax.size()) ) {
64  cout << "WARNING: MCPROCESSFILTER : size of MinPthat and/or MaxPthat not matching with ProcessID size!!" << endl;
65  }
66 
67  // if pMin size smaller than particleID , fill up further with defaults
68  if (particleID.size() > pMin.size() ){
69  for (unsigned int i = pMin.size(); i < particleID.size(); i++){ pMin.push_back(0.);}
70  }
71  // if ptMin size smaller than particleID , fill up further with defaults
72  if (particleID.size() > ptMin.size() ){
73  for (unsigned int i = ptMin.size(); i < particleID.size(); i++){ ptMin.push_back(0.);}
74  }
75  // if etaMin size smaller than particleID , fill up further with defaults
76  if (particleID.size() > etaMin.size() ){
77  for (unsigned int i = etaMin.size(); i < particleID.size(); i++){ etaMin.push_back(-10.);}
78  }
79  // if etaMax size smaller than particleID , fill up further with defaults
80  if (particleID.size() > etaMax.size() ){
81  for (unsigned int i = etaMax.size(); i < particleID.size(); i++){ etaMax.push_back(10.);}
82  }
83  // if status size smaller than particleID , fill up further with defaults
84  if (particleID.size() > status.size() ){
85  for (unsigned int i = status.size(); i < particleID.size(); i++){ status.push_back(0);}
86  }
87 
88  // if decayRadiusMin size smaller than particleID , fill up further with defaults
89  if (particleID.size() > decayRadiusMin.size() ){
90  for (unsigned int i = decayRadiusMin.size(); i < particleID.size(); i++){ decayRadiusMin.push_back(-10.);}
91  }
92  // if decayRadiusMax size smaller than particleID , fill up further with defaults
93  if (particleID.size() > decayRadiusMax.size() ){
94  for (unsigned int i = decayRadiusMax.size(); i < particleID.size(); i++){ decayRadiusMax.push_back(1.e5);}
95  }
96 
97  // if decayZMin size smaller than particleID , fill up further with defaults
98  if (particleID.size() > decayZMin.size() ){
99  for (unsigned int i = decayZMin.size(); i < particleID.size(); i++){ decayZMin.push_back(-1.e5);}
100  }
101  // if decayZMax size smaller than particleID , fill up further with defaults
102  if (particleID.size() > decayZMax.size() ){
103  for (unsigned int i = decayZMax.size(); i < particleID.size(); i++){ decayZMax.push_back(1.e5);}
104  }
105 
106  // check if beta is smaller than 1
107  if (std::abs(betaBoost) >= 1 ){
108  edm::LogError("MCSmartSingleParticleFilter") << "Input beta boost is >= 1 !";
109  }
110 
111 }
T getUntrackedParameter(std::string const &, T const &) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< edm::HepMCProduct > token_
MCSmartSingleParticleFilter::~MCSmartSingleParticleFilter ( )
override

Definition at line 114 of file MCSmartSingleParticleFilter.cc.

115 {
116 
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 
120 }

Member Function Documentation

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

Definition at line 124 of file MCSmartSingleParticleFilter.cc.

References cms::dd::accepted(), betaBoost, decayRadiusMax, decayRadiusMin, decayZMax, decayZMin, etaMax, etaMin, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, particleID, pMin, ptMin, mathSSE::sqrt(), status, token_, and MCFilterZboostHelper::zboost().

125 {
126  using namespace edm;
127  bool accepted = false;
129  iEvent.getByToken(token_, evt);
130 
131  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
132 
133 
134  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
135  p != myGenEvent->particles_end(); ++p ) {
136 
137 
138  for (unsigned int i = 0; i < particleID.size(); i++){
139  if (particleID[i] == (*p)->pdg_id() || particleID[i] == 0) {
140 
141  if ( (*p)->momentum().perp() > ptMin[i]
142  && ((*p)->status() == status[i] || status[i] == 0)) {
143 
144  HepMC::FourVector mom = MCFilterZboostHelper::zboost((*p)->momentum(),betaBoost);
145  if ( mom.rho() > pMin[i]
146  && mom.eta() > etaMin[i] && mom.eta() < etaMax[i]) {
147 
148  if (!((*p)->production_vertex())) continue;
149 
150  double decx = (*p)->production_vertex()->position().x();
151  double decy = (*p)->production_vertex()->position().y();
152  double decrad = sqrt(decx*decx+decy*decy);
153  if (decrad<decayRadiusMin[i] ) continue;
154  if (decrad>decayRadiusMax[i] ) continue;
155 
156  double decz = (*p)->production_vertex()->position().z();
157  if (decz<decayZMin[i] ) continue;
158  if (decz>decayZMax[i] ) continue;
159 
160  accepted = true;
161  }
162 
163  }
164 
165  }
166  }
167 
168 
169  }
170 
171  if (accepted){ return true; } else {return false;}
172 
173 }
HepMC::FourVector zboost(const HepMC::FourVector &, double)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
T sqrt(T t)
Definition: SSEVec.h:18
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
edm::EDGetTokenT< edm::HepMCProduct > token_
bool accepted(std::vector< std::string_view > const &, std::string_view)
HLT enums.

Member Data Documentation

double MCSmartSingleParticleFilter::betaBoost
private

Definition at line 62 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayRadiusMax
private

Definition at line 59 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayRadiusMin
private

Definition at line 58 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayZMax
private

Definition at line 61 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::decayZMin
private

Definition at line 60 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::etaMax
private

Definition at line 56 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::etaMin
private

Definition at line 55 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

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

Definition at line 52 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

std::vector<double> MCSmartSingleParticleFilter::pMin
private

Definition at line 53 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

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

Definition at line 54 of file MCSmartSingleParticleFilter.h.

Referenced by filter(), and MCSmartSingleParticleFilter().

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

Definition at line 51 of file MCSmartSingleParticleFilter.h.

Referenced by filter().