CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenSpecificAlgo.cc
Go to the documentation of this file.
6 #include "TMath.h"
7 using namespace reco;
8 using namespace std;
9 
10 //-------------------------------------------------------------------------
11 // This algorithm adds calorimeter specific global event information to
12 // the MET object which may be useful/needed for MET Data Quality Monitoring
13 // and MET cleaning. This list is not exhaustive and additional
14 // information will be added in the future.
15 //-------------------------------------
16 //reco::GenMET GenSpecificAlgo::addInfo(const CandidateCollection *particles, CommonMETData met)
17 reco::GenMET GenSpecificAlgo::addInfo(edm::Handle<edm::View<Candidate> > particles, CommonMETData *met, double globalThreshold, bool onlyFiducial, bool usePt)
18 {
19 
20  double sum_et = 0.0;
21  double sum_ex = 0.0;
22  double sum_ey = 0.0;
23  double sum_ez = 0.0;
24 
25  // Instantiate the container to hold the calorimeter specific information
27 
28  // Initialise the container
29  specific.NeutralEMEtFraction = 0.0;
30  specific.NeutralHadEtFraction = 0.0;
31  specific.ChargedEMEtFraction = 0.0;
32  specific.ChargedHadEtFraction = 0.0;
33  specific.MuonEtFraction = 0.0;
34  specific.InvisibleEtFraction = 0.0;
35 
36  // tally Et contribution from undecayed genparticles that don't fall into the following classifications (for normalization purposes)
37  double Et_unclassified = 0.;
38 
39  for( edm::View<reco::Candidate>::const_iterator iParticle = (particles.product())->begin() ; iParticle != (particles.product())->end() ; iParticle++ )
40  {
41 
42 
43  // if "onlyFiducial" is true take only particles within fudical volume AND use pT instead of et if "usePt" is true
44  if(!onlyFiducial || (onlyFiducial && TMath::Abs(iParticle->eta()) < 5.0)) //
45  {
46  if(!usePt)
47  {
48  if( iParticle->et() > globalThreshold )
49  {
50  double phi = iParticle->phi();
51  double theta = iParticle->theta();
52  double e = iParticle->energy();
53  double et = e*sin(theta);
54  sum_ez += e*cos(theta);
55  sum_et += et;
56  sum_ex += et*cos(phi);
57  sum_ey += et*sin(phi);
58  }
59  }
60 
61  if(usePt)
62  {
63  if( iParticle->pt() > globalThreshold )
64  {
65  double phi = iParticle->phi();
66  double et = iParticle->pt(); // change et-->pt
67  sum_ez += iParticle->pz(); // change ez-->pz
68  sum_et += et;
69  sum_ex += et*cos(phi);
70  sum_ey += et*sin(phi);
71  }
72  }
73  }
74 
75 
76 
77  int pdgId = TMath::Abs( iParticle->pdgId() ) ;
78 
79  switch (pdgId) {
80 
81  case 22 : // photon
82  if(usePt){
83  specific.NeutralEMEtFraction += iParticle->pt();
84  }else{
85  specific.NeutralEMEtFraction += iParticle->et();
86  }
87  break;
88  case 11 : // e
89  if(usePt){
90  specific.ChargedEMEtFraction += iParticle->pt();
91  }else{
92  specific.ChargedEMEtFraction += iParticle->et();
93  }
94  break;
95  case 130 : // K_long
96  case 310 : // K_short
97  case 3122: // Lambda
98  case 2112: // n
99  case 3222: // Neutral Cascade
100  if(usePt){
101  specific.NeutralHadEtFraction += iParticle->pt();
102  }else{
103  specific.NeutralHadEtFraction += iParticle->et();
104  }
105  break;
106  case 211 : // pi
107  case 321 : // K+/K-
108  case 2212: // p
109  case 3312: // Cascade -
110  case 3112: // Sigma -
111  case 3322: // Sigma +
112  case 3334: // Omega -
113  if(usePt){
114  specific.ChargedHadEtFraction += iParticle->pt();
115  }else{
116  specific.ChargedHadEtFraction += iParticle->et();
117  }
118  break;
119  case 13 : //muon
120  if(usePt){
121  specific.MuonEtFraction += iParticle->pt();
122  }else{
123  specific.MuonEtFraction += iParticle->et();
124  }
125  break;
126  case 12 : // e_nu
127  case 14 : // mu_nu
128  case 16 : // tau_nu
129  case 1000022 : // Neutral ~Chi_0
130  case 1000012 : // LH ~e_nu
131  case 1000014 : // LH ~mu_nu
132  case 1000016 : // LH ~tau_nu
133  case 2000012 : // RH ~e_nu
134  case 2000014 : // RH ~mu_nu
135  case 2000016 : // RH ~tau_nu
136  case 39 : // G
137  case 1000039 : // ~G
138  case 5100039 : // KK G
139  case 4000012 : // excited e_nu
140  case 4000014 : // excited mu_nu
141  case 4000016 : // excited tau_nu
142  case 9900012 : // Maj e_nu
143  case 9900014 : // Maj mu_nu
144  case 9900016 : // Maj tau_nu
145  if(usePt){
146  specific.InvisibleEtFraction += iParticle->pt();
147  }else {
148  specific.InvisibleEtFraction += iParticle->et();
149  }
150  break;
151  default :
152  if(usePt){
153  Et_unclassified += iParticle->pt();
154  }else{
155  Et_unclassified += iParticle->et();
156  }
157  // cout << "PdgId : "<< iParticle->pdgId() << " " << iParticle->status() << " does not fall into a category " << endl;
158 
159 
160  }
161  }
162 
163  met->mex = -sum_ex;
164  met->mey = -sum_ey;
165  met->mez = -sum_ez;
166  met->met = sqrt( sum_ex*sum_ex + sum_ey*sum_ey );
167  // cout << "MET = " << met->met << endl;
168  met->sumet = sum_et;
169  met->phi = atan2( -sum_ey, -sum_ex );
170 
171  double Et_Total = specific.NeutralEMEtFraction + specific.NeutralHadEtFraction + specific.ChargedEMEtFraction +
172  specific.ChargedHadEtFraction + specific.MuonEtFraction + specific.InvisibleEtFraction + Et_unclassified;
173 
174  //Normalize
175  if( Et_Total )
176  {
177  specific.NeutralEMEtFraction /= Et_Total;
178  specific.NeutralHadEtFraction /= Et_Total;
179  specific.ChargedEMEtFraction /= Et_Total;
180  specific.ChargedHadEtFraction /= Et_Total;
181  specific.MuonEtFraction /= Et_Total;
182  specific.InvisibleEtFraction /= Et_Total;
183  }
184 
185  // Instantiate containers for the MET candidate and initialise them with
186  // the MET information in "met" (of type CommonMETData)
187  const LorentzVector p4( met->mex, met->mey, met->mez, met->met );
188  const Point vtx( 0.0, 0.0, 0.0 );
189  // Create and return an object of type GenMET, which is a MET object with
190  // the extra calorimeter specfic information added
191  GenMET specificmet( specific, met->sumet, p4, vtx );
192  return specificmet;
193 }
194 //-------------------------------------------------------------------------
dictionary specific
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
math::XYZPoint Point
Geom::Theta< T > theta() const
reco::GenMET addInfo(edm::Handle< edm::View< reco::Candidate > > particles, CommonMETData *met, double globalThreshold, bool onlyFiducial=false, bool usePt=false)
Make GenMET. Assumes MET is made from MCCandidates.
T sqrt(T t)
Definition: SSEVec.h:46
double p4[4]
Definition: TauolaWrapper.h:92
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
MET made from CaloTowers.
Structure containing data common to all types of MET.
Definition: CommonMETData.h:22
#define end
Definition: vmac.h:38
#define begin
Definition: vmac.h:31
math::XYZTLorentzVector LorentzVector
Definition: DDAxes.h:10