CMS 3D CMS Logo

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

#include <PythiaFilterIsolatedTrack.h>

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

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 PythiaFilterIsolatedTrack (const edm::ParameterSet &)
 
 ~PythiaFilterIsolatedTrack ()
 
- 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 ()
 

Static Public Member Functions

static double getDistInCM (double eta1, double phi1, double eta2, double phi2)
 
static std::pair< double, double > GetEtaPhiAtEcal (double etaIP, double phiIP, double pT, int charge, double vtxZ)
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Attributes

double IsolCone_
 
double MaxSeedEta_
 
double MinIsolTrackMom_
 
double MinSeedMom_
 
double PixelEfficiency_
 
edm::Service
< edm::RandomNumberGenerator
rng_
 
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
 
- 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

PythiaFilterGammaJet filter implements generator-level preselections for ChargedHadron+jet like events to be used in jet energy calibration. Ported from fortran code written by V.Konoplianikov.

Author
O.Kodolova, SINP

Cleaned up code, and added pixel efficiency functionality

Author
J.P. Chou, Brown University

Definition at line 36 of file PythiaFilterIsolatedTrack.h.

Constructor & Destructor Documentation

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

Definition at line 82 of file PythiaFilterIsolatedTrack.cc.

References Exception, edm::Service< T >::isAvailable(), and rng_.

82  :
83  token_(consumes<edm::HepMCProduct>(iConfig.getUntrackedParameter("ModuleLabel",edm::InputTag("generator","unsmeared")))),
84  MaxSeedEta_(iConfig.getUntrackedParameter<double>("MaxSeedEta", 2.3)),
85  MinSeedMom_(iConfig.getUntrackedParameter<double>("MinSeedMom", 20.)),
86  MinIsolTrackMom_(iConfig.getUntrackedParameter<double>("MinIsolTrackMom",2.0)),
87  IsolCone_(iConfig.getUntrackedParameter<double>("IsolCone", 40.0)),
88  PixelEfficiency_(iConfig.getUntrackedParameter<double>("PixelEfficiency", 0.8))
89 {
90 
91  // check if the random number generator service was configured
92  if(!rng_.isAvailable()) {
93  throw cms::Exception("Configuration") << "PythiaFilterIsolatedTrack requires the RandomNumberGeneratorService\n";
94  }
95 }
T getUntrackedParameter(std::string const &, T const &) const
bool isAvailable() const
Definition: Service.h:46
edm::EDGetTokenT< edm::HepMCProduct > token_
edm::Service< edm::RandomNumberGenerator > rng_
PythiaFilterIsolatedTrack::~PythiaFilterIsolatedTrack ( )

Definition at line 98 of file PythiaFilterIsolatedTrack.cc.

99 {
100 }

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 104 of file PythiaFilterIsolatedTrack.cc.

References funct::abs(), MBUEandQCDValidation_cff::chargedParticles, GenParticle::GenParticle, edm::Event::getByToken(), edm::EventSetup::getData(), getDistInCM(), edm::RandomNumberGenerator::getEngine(), GetEtaPhiAtEcal(), IsolCone_, MaxSeedEta_, MinIsolTrackMom_, MinSeedMom_, AlCaHLTBitMon_ParallelJobs::p, p1, p2, PixelEfficiency_, rng_, ntuplemaker::status, edm::Event::streamID(), and token_.

104  {
105 
106  CLHEP::HepRandomEngine& engine = rng_->getEngine(iEvent.streamID());
107 
109  iSetup.getData( pdt );
110 
112  iEvent.getByToken(token_, evt);
113 
114  const HepMC::GenEvent* myGenEvent = evt->GetEvent();
115 
116  // all of the stable, charged particles with momentum>MinIsolTrackMom_ and |eta|<MaxSeedEta_+0.5
117  std::vector<const HepMC::GenParticle *> chargedParticles;
118 
119  // all of the stable, charged particles with momentum>MinSeedMom_ and |eta|<MaxSeedEta_
120  std::vector<const HepMC::GenParticle *> seeds;
121 
122  // fill the vector of charged particles and seeds in the event
123  for(HepMC::GenEvent::particle_const_iterator iter=myGenEvent->particles_begin(); iter!=myGenEvent->particles_end(); ++iter) {
124  const HepMC::GenParticle *p=*iter;
125  int charge3 = pdt->particle(p->pdg_id())->ID().threeCharge();
126  int status = p->status();
127  double momentum = p->momentum().rho();
128  double abseta = fabs(p->momentum().eta());
129 
130  // only consider stable, charged particles
131  if(abs(charge3)==3 && status==1 && momentum>MinIsolTrackMom_ && abseta<MaxSeedEta_+0.5) {
132  chargedParticles.push_back(p);
133  if(momentum>MinSeedMom_ && abseta<MaxSeedEta_) {
134  seeds.push_back(p);
135  }
136  }
137  }
138 
139  // loop over all the seeds and see if any of them are isolated
140  for(std::vector<const HepMC::GenParticle *>::const_iterator it1=seeds.begin(); it1!=seeds.end(); ++it1) {
141  const HepMC::GenParticle *p1=*it1;
142 
143  std::pair<double,double> EtaPhi1=GetEtaPhiAtEcal(p1->momentum().eta(),
144  p1->momentum().phi(),
145  p1->momentum().perp(),
146  (pdt->particle(p1->pdg_id()))->ID().threeCharge()/3,
147  0.0);
148 
149  // loop over all of the other charged particles in the event, and see if any are close by
150  bool failsIso=false;
151  for(std::vector<const HepMC::GenParticle *>::const_iterator it2=chargedParticles.begin(); it2!=chargedParticles.end(); ++it2) {
152  const HepMC::GenParticle *p2=*it2;
153 
154  // don't consider the seed particle among the other charge particles
155  if(p1==p2) continue;
156 
157  std::pair<double,double> EtaPhi2=GetEtaPhiAtEcal(p2->momentum().eta(),
158  p2->momentum().phi(),
159  p2->momentum().perp(),
160  (pdt->particle(p2->pdg_id()))->ID().threeCharge()/3,
161  0.0);
162 
163  // find out how far apart the particles are
164  // if the seed fails the isolation requirement, try a different seed
165  // occasionally allow a seed to pass to isolation requirement
166  if(getDistInCM(EtaPhi1.first, EtaPhi1.second, EtaPhi2.first, EtaPhi2.second) < IsolCone_ &&
167  engine.flat() < PixelEfficiency_) {
168  failsIso=true;
169  break;
170  }
171  }
172 
173  if(!failsIso) return true;
174 
175  } //loop over seeds
176 
177  return false;
178 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
uint32_t ID
Definition: Definitions.h:26
void getData(T &iHolder) const
Definition: EventSetup.h:79
edm::EDGetTokenT< edm::HepMCProduct > token_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double p2[4]
Definition: TauolaWrapper.h:90
static double getDistInCM(double eta1, double phi1, double eta2, double phi2)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
edm::Service< edm::RandomNumberGenerator > rng_
double p1[4]
Definition: TauolaWrapper.h:89
StreamID streamID() const
Definition: Event.h:79
tuple status
Definition: ntuplemaker.py:245
static std::pair< double, double > GetEtaPhiAtEcal(double etaIP, double phiIP, double pT, int charge, double vtxZ)
double PythiaFilterIsolatedTrack::getDistInCM ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
)
static

Definition at line 66 of file PythiaFilterIsolatedTrack.cc.

References funct::cos(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, mathSSE::sqrt(), and z.

Referenced by filter().

67 {
68  double dR, Rec;
69  if (fabs(eta1)<1.479) Rec=129;
70  else Rec=317;
71  double ce1=cosh(eta1);
72  double ce2=cosh(eta2);
73  double te1=tanh(eta1);
74  double te2=tanh(eta2);
75 
76  double z=cos(phi1-phi2)/ce1/ce2+te1*te2;
77  if(z!=0) dR=fabs(Rec*ce1*sqrt(1./z/z-1.));
78  else dR=999999.;
79  return dR;
80 }
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::pair< double, double > PythiaFilterIsolatedTrack::GetEtaPhiAtEcal ( double  etaIP,
double  phiIP,
double  pT,
int  charge,
double  vtxZ 
)
static

Definition at line 17 of file PythiaFilterIsolatedTrack.cc.

References alpha, RecoTauCleanerPlugins::charge, SiPixelRawToDigiRegional_cfi::deltaPhi, create_public_lumi_plots::exp, cmsBatch::log, funct::sin(), funct::tan(), theta(), and z.

Referenced by filter().

18 {
19  double deltaPhi;
20  double etaEC=100;
21  double phiEC=100;
22  double Rcurv=pT*33.3*100/38; //r(m)=pT(GeV)*33.3/B(kG)
23  double ecDist=317; //distance to ECAL andcap from IP (cm), 317 - ecal (not preshower), preshower -300
24  double ecRad=129; //radius of ECAL barrel (cm)
25  double theta=2*atan(exp(-etaIP));
26  double zNew;
27  if (theta>0.5*acos(-1)) theta=acos(-1)-theta;
28  if (fabs(etaIP)<1.479) {
29  deltaPhi=-charge*asin(0.5*ecRad/Rcurv);
30  double alpha1=2*asin(0.5*ecRad/Rcurv);
31  double z=ecRad/tan(theta);
32  if (etaIP>0) zNew=z*(Rcurv*alpha1)/ecRad+vtxZ; //new z-coordinate of track
33  else zNew=-z*(Rcurv*alpha1)/ecRad+vtxZ; //new z-coordinate of track
34  double zAbs=fabs(zNew);
35  if (zAbs<ecDist) {
36  etaEC=-log(tan(0.5*atan(ecRad/zAbs)));
37  deltaPhi=-charge*asin(0.5*ecRad/Rcurv);
38  }
39  if (zAbs>ecDist) {
40  zAbs=(fabs(etaIP)/etaIP)*ecDist;
41  double Zflight=fabs(zAbs-vtxZ);
42  double alpha=(Zflight*ecRad)/(z*Rcurv);
43  double Rec=2*Rcurv*sin(alpha/2);
44  deltaPhi=-charge*alpha/2;
45  etaEC=-log(tan(0.5*atan(Rec/ecDist)));
46  }
47  } else {
48  zNew=(fabs(etaIP)/etaIP)*ecDist;
49  double Zflight=fabs(zNew-vtxZ);
50  double Rvirt=fabs(Zflight*tan(theta));
51  double Rec=2*Rcurv*sin(Rvirt/(2*Rcurv));
52  deltaPhi=-(charge)*(Rvirt/(2*Rcurv));
53  etaEC=-log(tan(0.5*atan(Rec/ecDist)));
54  }
55 
56  if (zNew<0) etaEC=-etaEC;
57  phiEC=phiIP+deltaPhi;
58 
59  if (phiEC<-acos(-1)) phiEC=2*acos(-1)+phiEC;
60  if (phiEC>acos(-1)) phiEC=-2*acos(-1)+phiEC;
61 
62  std::pair<double,double> retVal(etaEC,phiEC);
63  return retVal;
64 }
float alpha
Definition: AMPTWrapper.h:95
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
tuple log
Definition: cmsBatch.py:341

Member Data Documentation

double PythiaFilterIsolatedTrack::IsolCone_
private

Definition at line 55 of file PythiaFilterIsolatedTrack.h.

Referenced by filter().

double PythiaFilterIsolatedTrack::MaxSeedEta_
private

Definition at line 52 of file PythiaFilterIsolatedTrack.h.

Referenced by filter().

double PythiaFilterIsolatedTrack::MinIsolTrackMom_
private

Definition at line 54 of file PythiaFilterIsolatedTrack.h.

Referenced by filter().

double PythiaFilterIsolatedTrack::MinSeedMom_
private

Definition at line 53 of file PythiaFilterIsolatedTrack.h.

Referenced by filter().

double PythiaFilterIsolatedTrack::PixelEfficiency_
private

Definition at line 56 of file PythiaFilterIsolatedTrack.h.

Referenced by filter().

edm::Service<edm::RandomNumberGenerator> PythiaFilterIsolatedTrack::rng_
private

Definition at line 59 of file PythiaFilterIsolatedTrack.h.

Referenced by filter(), and PythiaFilterIsolatedTrack().

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

Definition at line 51 of file PythiaFilterIsolatedTrack.h.

Referenced by filter().