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
PythiaFilterGammaJetWithOutBg Class Reference

#include <PythiaFilterGammaJetWithOutBg.h>

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

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 PythiaFilterGammaJetWithOutBg (const edm::ParameterSet &)
 
 ~PythiaFilterGammaJetWithOutBg ()
 
- 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 cone
 
double deltaEB
 
double deltaEE
 
double detaMax
 
double dphiMin
 
double ebEtaMax
 
double etaMax
 
double etaPhotonCut2
 
int maxnumberofeventsinrun
 
double ptMax
 
double ptMin
 
double ptSeed
 
int theNumberOfSelected
 
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

Definition at line 30 of file PythiaFilterGammaJetWithOutBg.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file PythiaFilterGammaJetWithOutBg.cc.

References deltaEB, deltaEE, and theNumberOfSelected.

40  :
41 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
42 etaMax(iConfig.getUntrackedParameter<double>("MaxPhotonEta", 2.8)),
43 ptSeed(iConfig.getUntrackedParameter<double>("PhotonSeedPt", 5.)),
44 ptMin(iConfig.getUntrackedParameter<double>("MinPhotonPt")),
45 ptMax(iConfig.getUntrackedParameter<double>("MaxPhotonPt")),
46 dphiMin(iConfig.getUntrackedParameter<double>("MinDeltaPhi", -1)/180*M_PI),
47 detaMax(iConfig.getUntrackedParameter<double>("MaxDeltaEta", 10.)),
48 etaPhotonCut2(iConfig.getUntrackedParameter<double>("MinPhotonEtaForwardJet", 1.3)),
49 cone(0.5),ebEtaMax(1.479),
50 maxnumberofeventsinrun(iConfig.getUntrackedParameter<int>("MaxEvents",10)){
51 
52  deltaEB=0.01745/2 *5; // delta_eta, delta_phi
53  deltaEE=2.93/317/2 *5; // delta_x/z, delta_y/z
55 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > token_
#define M_PI
PythiaFilterGammaJetWithOutBg::~PythiaFilterGammaJetWithOutBg ( )

Definition at line 58 of file PythiaFilterGammaJetWithOutBg.cc.

58 {}

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 62 of file PythiaFilterGammaJetWithOutBg.cc.

References funct::abs(), cone, gather_cfg::cout, deltaEB, deltaEE, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::deltaR2(), detaMax, ebEtaMax, HLT_25ns14e33_v1_cff::etaJet, etaMax, etaPhotonCut2, GenParticle::GenParticle, edm::Event::getByToken(), edm::EventSetup::getData(), i, AlCaHLTBitMon_ParallelJobs::p, sysUtil::pid, EnergyCorrector::pt, ptMax, ptSeed, theNumberOfSelected, and token_.

62  {
63 
64 // <<<<<<< PythiaFilterGammaJetWithOutBg.cc
65 // if(theNumberOfSelected>=maxnumberofeventsinrun) {
66 // throw cms::Exception("endJob")<<"we have reached the maximum number of events ";
67 // }
68 // =======
69 // >>>>>>> 1.4
70 
71  bool accepted = false;
73  iEvent.getByToken(token_, evt);
74 
75  std::list<const HepMC::GenParticle *> seeds;
76  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
77 
78  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
79 
80  if ( (*p)->pdg_id()==22 && (*p)->status()==1
81  && (*p)->momentum().perp() > ptSeed
82  && std::abs((*p)->momentum().eta()) < etaMax ) seeds.push_back(*p);
83 
84  }
85 
86  seeds.sort(ParticlePtGreater());
87 
88 // std::cout<<" Number of seeds "<<seeds.size()<<" ProccessID "<<myGenEvent->signal_process_id()<<std::endl;
89 // std::cout<<" ParticleId 7= "<<myGenEvent->particle(7)->pdg_id()
90 // <<" pT "<<myGenEvent->particle(7)->momentum().perp()
91 // <<" Eta "<<myGenEvent->particle(7)->momentum().eta()
92 // <<" Phi "<<myGenEvent->particle(7)->momentum().phi()<<std::endl;
93 // std::cout<<" ParticleId 8= "<<myGenEvent->particle(8)->pdg_id()<<" pT "<<myGenEvent->particle(8)->momentum().perp()<<" Eta "<<myGenEvent->particle(8)->momentum().eta()<<" Phi "<<myGenEvent->particle(8)->momentum().phi()<<std::endl;
94 
95  for(std::list<const HepMC::GenParticle *>::const_iterator is=
96  seeds.begin(); is!=seeds.end(); is++){
97 
98  double etaPhoton=(*is)->momentum().eta();
99  double phiPhoton=(*is)->momentum().phi();
100 
101  /*
102  double dphi7=std::abs(deltaPhi(phiPhoton,
103  myGenEvent->particle(7)->momentum().phi()));
104  double dphi=std::abs(deltaPhi(phiPhoton,
105  myGenEvent->particle(8)->momentum().phi()));
106  */
107 
108  HepMC::GenEvent::particle_const_iterator ppp = myGenEvent->particles_begin();
109  for(int i=0;i<6;++i) ppp++;
110  HepMC::GenParticle* particle7 = (*ppp);
111  ppp++;
112  HepMC::GenParticle* particle8 = (*ppp);
113 
114  double dphi7=std::abs(deltaPhi(phiPhoton,
115  particle7->momentum().phi()));
116  double dphi=std::abs(deltaPhi(phiPhoton,
117  particle8->momentum().phi()));
118 
119  int jetline=8;
120  if(dphi7>dphi) {
121  dphi=dphi7;
122  jetline=7;
123  }
124 
125 // std::cout<<" Dphi "<<dphi<<" "<<dphiMin<<std::endl;
126 // if(dphi<dphiMin) {
127 // std::cout<<"Reject dphi"<<std::endl;
128 // continue;
129 // }
130 
131 // double etaJet= myGenEvent->particle(jetline)->momentum().eta();
132  double etaJet = 0.0;
133  if(jetline==8) etaJet = particle8->momentum().eta();
134  else etaJet = particle7->momentum().eta();
135 
136  double eta1=etaJet-detaMax;
137  double eta2=etaJet+detaMax;
138  if (eta1>etaPhotonCut2) eta1=etaPhotonCut2;
139  if (eta2<-etaPhotonCut2) eta2=-etaPhotonCut2;
140 
141 // std::cout<<" Etaphoton "<<etaPhoton<<" "<<eta1<<" "<<eta2<<std::endl;
142 
143  if (etaPhoton<eta1 ||etaPhoton>eta2) {
144 // std::cout<<"Reject eta"<<std::endl;
145  continue;
146  }
147  bool inEB(0);
148  double tgx(0);
149  double tgy(0);
150  if( std::abs(etaPhoton)<ebEtaMax) inEB=1;
151  else{
152  tgx=(*is)->momentum().px()/(*is)->momentum().pz();
153  tgy=(*is)->momentum().py()/(*is)->momentum().pz();
154  }
155 
156  double etPhoton=0;
157  double etPhotonCharged=0;
158  double etCone=0;
159  double etConeCharged=0;
160  double ptMaxHadron=0;
161 
162 
163  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
164 
165  if ( (*p)->status()!=1 ) continue;
166  int pid= (*p)->pdg_id();
167  int apid= std::abs(pid);
168  if (apid>11 && apid<21) continue; //get rid of muons and neutrinos
169  double eta=(*p)->momentum().eta();
170  double phi=(*p)->momentum().phi();
171  if (deltaR2(etaPhoton, phiPhoton, eta, phi)>cone*cone) continue;
172  double pt=(*p)->momentum().perp();
173 
174 // double charge=(*p)->particledata().charge();
175 // int charge3=(*p)->particleID().threeCharge();
176 
177  //***
179  iSetup.getData( pdt );
180  int charge3 = ((pdt->particle((*p)->pdg_id()))->ID().threeCharge());
181  //***
182 
183  etCone+=pt;
184  if(charge3 && pt<2) etConeCharged+=pt;
185 
186  //select particles matching a crystal array centered on photon
187  if(inEB) {
188  if( std::abs(eta-etaPhoton)> deltaEB ||
189  std::abs(deltaPhi(phi,phiPhoton)) > deltaEB) continue;
190  }
191  else if( std::abs((*p)->momentum().px()/(*p)->momentum().pz() - tgx)
192  > deltaEE ||
193  std::abs((*p)->momentum().py()/(*p)->momentum().pz() - tgy)
194  > deltaEE) continue;
195 
196  etPhoton+=pt;
197  if(charge3 && pt<2) etPhotonCharged+=pt;
198  if(apid>100 && apid!=310 && pt>ptMaxHadron) ptMaxHadron=pt;
199 
200  }
201 // std::cout<<" etPhoton "<<etPhoton<<" "<<ptMin<<" "<<ptMax<<std::endl;
202  if(etPhoton<ptMin ||etPhoton>ptMax) {
203 // std::cout<<" Reject etPhoton "<<std::endl;
204  continue;
205  }
206  //isolation cuts
207 
208 // double isocut1 = 5+etPhoton/20-etPhoton*etPhoton/1e4;
209 // double isocut2 = 3+etPhoton/20-etPhoton*etPhoton*etPhoton/1e6;
210 // double isocut3 = 4.5+etPhoton/40;
211 // if (etPhoton>165.)
212 // {
213 // isocut1 = 5.+165./20.-165.*165./1e4;
214 // isocut2 = 3.+165./20.-165.*165.*165./1e6;
215 // isocut3 = 4.5+165./40.;
216 // }
217 // std::cout<<" etCone "<<etCone<<" "<<etPhoton<<" "<<etCone-etPhoton<<" "<<isocut1<<std::endl;
218 // std::cout<<"Second cut on iso "<<etCone-etPhoton-(etConeCharged-etPhotonCharged)<<" cut value "<<isocut2<<" etPhoton "<<etPhoton<<std::endl;
219 // std::cout<<" PtHadron "<<ptMaxHadron<<" "<<4.5+etPhoton/40<<std::endl;
220 // if(etCone-etPhoton> 5+etPhoton/20-etPhoton*etPhoton/1e4) continue;
221 // std::cout<<" Accept 1"<<std::endl;
222 // if(etCone-etPhoton-(etConeCharged-etPhotonCharged) >
223 // isocut2) continue;
224 // std::cout<<" Accept 2"<<std::endl;
225 // if(ptMaxHadron > isocut3) continue;
226 // std::cout<<"Accept event "<<std::endl;
227 
228  accepted=true;
229  break;
230 
231  } //loop over seeds
232 
233 
234  if (accepted) {
236  std::cout<<" Event preselected "<<theNumberOfSelected<<" Proccess ID "<<myGenEvent->signal_process_id()<<std::endl;
237  return true;
238  }
239  else return false;
240 
241 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::HepMCProduct > token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void getData(T &iHolder) const
Definition: EventSetup.h:79
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
tuple pid
Definition: sysUtil.py:22
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

double PythiaFilterGammaJetWithOutBg::cone
private

Definition at line 48 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

double PythiaFilterGammaJetWithOutBg::deltaEB
private

Definition at line 50 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter(), and PythiaFilterGammaJetWithOutBg().

double PythiaFilterGammaJetWithOutBg::deltaEE
private

Definition at line 51 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter(), and PythiaFilterGammaJetWithOutBg().

double PythiaFilterGammaJetWithOutBg::detaMax
private

Definition at line 45 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

double PythiaFilterGammaJetWithOutBg::dphiMin
private

Definition at line 44 of file PythiaFilterGammaJetWithOutBg.h.

double PythiaFilterGammaJetWithOutBg::ebEtaMax
private

Definition at line 49 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

double PythiaFilterGammaJetWithOutBg::etaMax
private

Definition at line 40 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

double PythiaFilterGammaJetWithOutBg::etaPhotonCut2
private

Definition at line 46 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

int PythiaFilterGammaJetWithOutBg::maxnumberofeventsinrun
private

Definition at line 54 of file PythiaFilterGammaJetWithOutBg.h.

double PythiaFilterGammaJetWithOutBg::ptMax
private

Definition at line 43 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

double PythiaFilterGammaJetWithOutBg::ptMin
private

Definition at line 42 of file PythiaFilterGammaJetWithOutBg.h.

double PythiaFilterGammaJetWithOutBg::ptSeed
private

Definition at line 41 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().

int PythiaFilterGammaJetWithOutBg::theNumberOfSelected
private

Definition at line 53 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter(), and PythiaFilterGammaJetWithOutBg().

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

Definition at line 39 of file PythiaFilterGammaJetWithOutBg.h.

Referenced by filter().