CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PythiaFilterEMJet Class Reference

#include <PythiaFilterEMJet.h>

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

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 PythiaFilterEMJet (const edm::ParameterSet &)
 
 ~PythiaFilterEMJet ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

double deltaEB
 
double deltaEE
 
double ebEtaMax
 
double etaMax
 
double etaMin
 
double eTSumMax
 
double eTSumMin
 
int maxnumberofeventsinrun
 
double pTMax
 
double pTMin
 
int theNumberOfSelected
 
int theNumberOfTestedEvt
 
edm::EDGetTokenT
< edm::HepMCProduct
token_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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 &)
 
- 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

PythiaFilterEMJet filter implements generator-level preselections

Author
R.Salerno, Universita' Milano Bicocca

Definition at line 28 of file PythiaFilterEMJet.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file PythiaFilterEMJet.cc.

References gather_cfg::cout, deltaEB, deltaEE, etaMax, etaMin, eTSumMax, eTSumMin, maxnumberofeventsinrun, pTMax, pTMin, theNumberOfSelected, and theNumberOfTestedEvt.

38  :
39 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
40 etaMin(iConfig.getUntrackedParameter<double>("MinEMEta", 0)),
41 eTSumMin(iConfig.getUntrackedParameter<double>("ETSumMin", 50.)),
42 pTMin(iConfig.getUntrackedParameter<double>("MinEMpT", 5.)),
43 etaMax(iConfig.getUntrackedParameter<double>("MaxEMEta", 2.7)),
44 eTSumMax(iConfig.getUntrackedParameter<double>("ETSumMax", 100.)),
45 pTMax(iConfig.getUntrackedParameter<double>("MaxEMpT", 999999.)),
46 ebEtaMax(1.479),
47 maxnumberofeventsinrun(iConfig.getUntrackedParameter<int>("MaxEvents",3000000)){
48 
49  deltaEB=0.01745/2 *5; // delta_eta, delta_phi
50  deltaEE=2.93/317/2 *5; // delta_x/z, delta_y/z
53 
54  cout << " Max Events : " << maxnumberofeventsinrun << endl;
55  cout << " Cut Definition: " << endl;
56  cout << " MinEMEta = " << etaMin << endl;
57  cout << " ETSumMin = " << eTSumMin << endl;
58  cout << " MinEMpT = " << pTMin << endl;
59  cout << " MaxEMEta = " << etaMax << endl;
60  cout << " ETSumMax = " << eTSumMax << endl;
61  cout << " MaxEMpT = " << pTMax << endl;
62  cout << " 5x5 crystal cone around EM axis in ECAL Barrel = " << deltaEB << endl;
63  cout << " 5x5 crystal cone around EM axis in ECAL Endcap = " << deltaEE << endl;
64 
65 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > token_
tuple cout
Definition: gather_cfg.py:121
PythiaFilterEMJet::~PythiaFilterEMJet ( )

Definition at line 67 of file PythiaFilterEMJet.cc.

References gather_cfg::cout, theNumberOfSelected, and theNumberOfTestedEvt.

68 {
69 std::cout << "Total number of tested events = " << theNumberOfTestedEvt << std::endl;
70 std::cout << "Total number of accepted events = " << theNumberOfSelected << std::endl;
71 }
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

bool PythiaFilterEMJet::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 75 of file PythiaFilterEMJet.cc.

References funct::abs(), gather_cfg::cout, deltaEB, deltaEE, SiPixelRawToDigiRegional_cfi::deltaPhi, ebEtaMax, etaMax, etaMin, eTSumMin, Exception, edm::Event::getByToken(), maxnumberofeventsinrun, AlCaHLTBitMon_ParallelJobs::p, EnergyCorrector::pt, pTMax, pTMin, theNumberOfSelected, theNumberOfTestedEvt, token_, and funct::true.

75  {
76 
78  throw cms::Exception("endJob") << "we have reached the maximum number of events ";
79  }
80 
82  if(theNumberOfTestedEvt%1000 == 0) cout << "Number of tested events = " << theNumberOfTestedEvt << endl;
83 
84  bool accepted = false;
86  iEvent.getByToken(token_, evt);
87 
88  list<const HepMC::GenParticle *> EM_seeds;
89  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
90 
91  int particle_id = 1;
92 
93  //select e+/e-/gamma particles in the events
94  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
95  p != myGenEvent->particles_end();
96  ++p ) {
97 
98 
99  if ( (abs((*p)->pdg_id())==11 || (*p)->pdg_id()==22)
100  && (*p)->status()==1
101  && (*p)->momentum().perp() > pTMin
102  && (*p)->momentum().perp() < pTMax
103  && fabs((*p)->momentum().eta()) < etaMax
104  && fabs((*p)->momentum().eta()) > etaMin ) {
105  EM_seeds.push_back(*p);
106  }
107  particle_id++;
108  }
109 
110  EM_seeds.sort(ParticlePtGreater());
111 
112  double etaEMClus=0;
113  double phiEMClus=0;
114  double ptEMClus=0;
115  for(std::list<const HepMC::GenParticle *>::const_iterator is=EM_seeds.begin();
116  is!= EM_seeds.end();
117  ++is){
118  double etaEM=(*is)->momentum().eta();
119  double phiEM=(*is)->momentum().phi();
120  double ptEM=(*is)->momentum().perp();
121  //pass at the cluster the seed infos
122  etaEMClus = etaEM;
123  phiEMClus = phiEM;
124  ptEMClus = ptEM;
125 
126  //check if the EM particle is in the barrel
127  bool inEB(0);
128  double tgx(0);
129  double tgy(0);
130  if( std::abs(etaEM)<ebEtaMax ) inEB=1;
131  else{
132  tgx=(*is)->momentum().px()/(*is)->momentum().pz();
133  tgy=(*is)->momentum().py()/(*is)->momentum().pz();
134  }
135 
136 // std::vector<const HepMC::GenParticle*> takenEM ;
137 // std::vector<const HepMC::GenParticle*>::const_iterator itPart ;
138 
139  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
140  p != myGenEvent->particles_end();
141  ++p ) {
142 
143  if (((*p)->status()==1 && (*p)->pdg_id() == 22) || // gamma
144  ((*p)->status()==1 && abs((*p)->pdg_id()) == 11) ) // electron
145 // (*p)->pdg_id() == 111 || // pi0
146 // abs((*p)->pdg_id()) == 221 || // eta
147 // abs((*p)->pdg_id()) == 331 || // eta prime
148 // abs((*p)->pdg_id()) == 113 || // rho0
149 // abs((*p)->pdg_id()) == 223 ) // omega*/
150  {
151 // // check if found is daughter of one already taken
152 // bool isUsed = false ;
153 // const HepMC::GenParticle* mother = (*p)->production_vertex() ?
154 // *((*p)->production_vertex()->particles_in_const_begin()) : 0 ;
155 // const HepMC::GenParticle* motherMother = (mother != 0 && mother->production_vertex()) ?
156 // *(mother->production_vertex()->particles_in_const_begin()) : 0 ;
157 // const HepMC::GenParticle* motherMotherMother = (motherMother != 0 && motherMother->production_vertex()) ?
158 // *(motherMother->production_vertex()->particles_in_const_begin()) : 0 ;
159 // for(itPart = takenEM.begin(); itPart != takenEM.end(); ++itPart) {
160 // if ((*itPart) == mother ||
161 // (*itPart) == motherMother ||
162 // (*itPart) == motherMotherMother)
163 // {
164 // isUsed = true ;
165 // break ;
166 // }
167 // }
168 // if (!isUsed) takenEM.push_back(*p);
169 
170  double pt=(*p)->momentum().perp();
171  if (pt == ptEM) continue ; //discard the same particle of the seed
172  double eta=(*p)->momentum().eta();
173  double phi=(*p)->momentum().phi();
174 
175  if(inEB) {
176  if( std::abs(eta-etaEM)> deltaEB ||
177  std::abs(deltaPhi(phi,phiEM)) > deltaEB) continue;
178  }
179  else if( std::abs((*p)->momentum().px()/(*p)->momentum().pz() - tgx)
180  > deltaEE ||
181  std::abs((*p)->momentum().py()/(*p)->momentum().pz() - tgy)
182  > deltaEE) continue;
183  ptEMClus += pt ;
184  if(inEB)
185  {
186  etaEMClus += (eta-etaEMClus)*pt/ptEMClus ;
187  phiEMClus += deltaPhi(phi,phiEM)*pt/ptEMClus;
188  }
189  else
190  {
191  etaEMClus += ((*p)->momentum().px()/(*p)->momentum().pz() - tgx)*pt/ptEMClus ;
192  phiEMClus += ((*p)->momentum().py()/(*p)->momentum().pz() - tgy)*pt/ptEMClus;
193  }
194  }
195  }
196  if( ptEMClus > eTSumMin)
197  accepted = true ;
198  }
199 
200  if (accepted) {
202  cout << "========> Event preselected " << theNumberOfSelected
203  << " Proccess ID " << myGenEvent->signal_process_id() << endl;
204  return true;
205  }
206  else return false;
207 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< edm::HepMCProduct > token_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

double PythiaFilterEMJet::deltaEB
private

Definition at line 45 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

double PythiaFilterEMJet::deltaEE
private

Definition at line 46 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

double PythiaFilterEMJet::ebEtaMax
private

Definition at line 44 of file PythiaFilterEMJet.h.

Referenced by filter().

double PythiaFilterEMJet::etaMax
private

Definition at line 41 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

double PythiaFilterEMJet::etaMin
private

Definition at line 38 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

double PythiaFilterEMJet::eTSumMax
private

Definition at line 42 of file PythiaFilterEMJet.h.

Referenced by PythiaFilterEMJet().

double PythiaFilterEMJet::eTSumMin
private

Definition at line 39 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

int PythiaFilterEMJet::maxnumberofeventsinrun
private

Definition at line 50 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

double PythiaFilterEMJet::pTMax
private

Definition at line 43 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

double PythiaFilterEMJet::pTMin
private

Definition at line 40 of file PythiaFilterEMJet.h.

Referenced by filter(), and PythiaFilterEMJet().

int PythiaFilterEMJet::theNumberOfSelected
private

Definition at line 49 of file PythiaFilterEMJet.h.

Referenced by filter(), PythiaFilterEMJet(), and ~PythiaFilterEMJet().

int PythiaFilterEMJet::theNumberOfTestedEvt
private

Definition at line 48 of file PythiaFilterEMJet.h.

Referenced by filter(), PythiaFilterEMJet(), and ~PythiaFilterEMJet().

edm::EDGetTokenT<edm::HepMCProduct> PythiaFilterEMJet::token_
private

Definition at line 37 of file PythiaFilterEMJet.h.

Referenced by filter().