CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TxCalculator.cc
Go to the documentation of this file.
1 // ROOT includes
2 #include <Math/VectorUtil.h>
3 
6 
9 
14 
17 
18 #include "CLHEP/Random/RandomEngine.h"
19 
20 using namespace edm;
21 using namespace reco;
22 using namespace std;
23 using namespace ROOT::Math::VectorUtil;
24 
25 
27 {
28  iEvent.getByLabel(trackLabel, recCollection);
30  if ( ! rng.isAvailable()) {
31  throw cms::Exception("Configuration")
32  << "XXXXXXX requires the RandomNumberGeneratorService\n"
33  "which is not present in the configuration file. You must add the service\n"
34  "in the configuration file or remove the modules that require it.";
35  }
36  theDice = &rng->getEngine(iEvent.streamID());
37 }
38 
39 
40 double TxCalculator::getJurassicArea( double r1, double r2, double width) {
41 
42  float theta1 = asin( width / r1);
43  float theta2 = asin( width / r2);
44  float theA = sqrt ( r1*r1 + r2*r2 - 2 * r1 * r2 * cos ( theta1 - theta2) );
45  float area1 = 0.5 * r1*r1 * ( 3.141592 - 2 * theta1 ) ;
46  float area2 = 0.5 * r2*r2 * ( 3.141592 - 2 * theta2 ) ;
47  float area3 = width * theA;
48  float finalArea = 2 * ( area1 - area2 - area3);
49  return finalArea;
50 }
51 
52 
53 double TxCalculator::getMPT( double ptCut , double etaCut )
54 {
55  using namespace edm;
56  using namespace reco;
57 
58  double sumpx(0), sumpy(0);
59 
60  for(reco::TrackCollection::const_iterator
61  recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
62  {
63  double pt = recTrack->pt();
64  double eta = recTrack->eta();
65 
66  if(pt < ptCut )
67  continue;
68  if ( fabs( eta) > etaCut )
69  continue;
70 
71  double pxTemp = recTrack->px();
72  double pyTemp = recTrack->py();
73 
74  sumpx = sumpx + pxTemp;
75  sumpy = sumpy + pyTemp;
76  // cout << " pt = " << recTrack->pt() << " and px = " << pxTemp << " and py = " << pyTemp << endl;
77  }
78  // cout << " square = " << sumpx*sumpx + sumpy*sumpy << endl;
79  double theMPT = sqrt(sumpx*sumpx + sumpy*sumpy) ;
80  // cout << " mpt = "<< theMPT << endl;
81 
82  return theMPT;
83 }
84 
85 
86 double TxCalculator::getTx(const reco::Photon& cluster, double x, double threshold, double innerDR, double effRatio)
87 {
88 
89  using namespace edm;
90  using namespace reco;
91 
92 
93 
94  double SClusterEta = cluster.eta();
95  double SClusterPhi = cluster.phi();
96  double TotalPt = 0;
97 
98  for(reco::TrackCollection::const_iterator
99  recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
100  {
101  double diceNum = theDice->flat();
102  if ( (effRatio < 1 ) && ( diceNum > effRatio))
103  continue;
104 
105  double pt = recTrack->pt();
106  double eta2 = recTrack->eta();
107  double phi2 = recTrack->phi();
108 
109  if(dRDistance(SClusterEta,SClusterPhi,eta2,phi2) >= 0.1 * x)
110  continue;
111  if(dRDistance(SClusterEta,SClusterPhi,eta2,phi2) < innerDR)
112  continue;
113  if(pt > threshold)
114  TotalPt = TotalPt + pt;
115  }
116 
117  return TotalPt;
118 }
119 
120 
121 
122 
123 
124 double TxCalculator::getCTx(const reco::Photon& cluster, double x, double threshold, double innerDR,double effRatio)
125 {
126  using namespace edm;
127  using namespace reco;
128 
129  double SClusterEta = cluster.eta();
130  double SClusterPhi = cluster.phi();
131  double TotalPt = 0;
132 
133  TotalPt = 0;
134 
135  for(reco::TrackCollection::const_iterator
136  recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
137  {
138  double diceNum = theDice->flat();
139  if ( (effRatio < 1 ) && ( diceNum > effRatio))
140  continue;
141 
142 
143  double pt = recTrack->pt();
144  double eta2 = recTrack->eta();
145  double phi2 = recTrack->phi();
146  double dEta = fabs(eta2-SClusterEta);
147 
148  if(dEta >= 0.1 * x)
149  continue;
150  if(dRDistance(SClusterEta,SClusterPhi,eta2,phi2) < innerDR)
151  continue;
152 
153  if(pt > threshold)
154  TotalPt = TotalPt + pt;
155  }
156 
157  double Tx = getTx(cluster,x,threshold,innerDR,effRatio);
158  double CTx = Tx - TotalPt / 40.0 * x;
159 
160  return CTx;
161 }
162 
163 
164 
165 double TxCalculator::getJt(const reco::Photon& cluster, double r1, double r2, double jWidth, double threshold)
166 {
167 
168  using namespace edm;
169  using namespace reco;
170 
171 
172  double SClusterEta = cluster.eta();
173  double SClusterPhi = cluster.phi();
174  double TotalPt = 0;
175 
176  for(reco::TrackCollection::const_iterator
177  recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
178  {
179  double pt = recTrack->pt();
180  double eta = recTrack->eta();
181  double phi = recTrack->phi();
182  double dEta = fabs(eta-SClusterEta);
183  double dPhi = phi-SClusterPhi;
184  if ( dPhi < -PI ) dPhi = dPhi + 2*PI ;
185  if ( dPhi > PI ) dPhi = dPhi - 2*PI ;
186  if ( fabs(dPhi) >PI ) cout << " error!!! dphi > 2pi : " << dPhi << endl;
187  double dR = sqrt(dEta*dEta+dPhi*dPhi);
188  // Jurassic Cone /////
189  if ( dR > r1 ) continue;
190  if ( dR < r2 ) continue;
191  if ( fabs(dEta) < jWidth) continue;
192  // stupid bug if ( fabs(dPhi) > jWidth) continue;
194 
195  if(pt > threshold)
196  TotalPt = TotalPt + pt;
197  }
198 
199  return TotalPt;
200 }
201 
202 
203 double TxCalculator::getJct(const reco::Photon& cluster, double r1, double r2, double jWidth, double threshold)
204 {
205 
206  using namespace edm;
207  using namespace reco;
208 
209 
210  double SClusterEta = cluster.eta();
211  double SClusterPhi = cluster.phi();
212  double TotalPt = 0;
213 
214  for(reco::TrackCollection::const_iterator
215  recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
216  {
217  double pt = recTrack->pt();
218  double eta = recTrack->eta();
219  double phi = recTrack->phi();
220  double dEta = fabs(eta-SClusterEta);
221  double dPhi = phi-SClusterPhi;
222  if ( dPhi < -PI ) dPhi = dPhi + 2*PI ;
223  if ( dPhi > PI ) dPhi = dPhi - 2*PI ;
224  if ( fabs(dPhi) >PI ) cout << " error!!! dphi > 2pi : " << dPhi << endl;
225  // double dR = sqrt(dEta*dEta+dPhi*dPhi);
226 
227 
229  if ( fabs(dEta) > r1 ) continue;
230  if ( fabs(dPhi) <r1 ) continue;
232 
233  if(pt > threshold)
234  TotalPt = TotalPt + pt;
235  }
236 
237  double areaStrip = 4*PI*r1 - 4*r1*r1;
238  double areaJura = getJurassicArea(r1,r2, jWidth) ;
239  double theCJ = getJt(cluster,r1, r2, jWidth, threshold);
240 
241  double theCCJ = theCJ - TotalPt * areaJura / areaStrip ;
242  return theCCJ;
243 
244 }
245 
double getMPT(double ptCut=0, double etaCut=1000)
Definition: TxCalculator.cc:53
#define PI
double getJt(const reco::Photon &cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
T eta() const
double getJurassicArea(double r1, double r2, double width)
Definition: TxCalculator.cc:40
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
int iEvent
Definition: GenABIO.cc:230
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool isAvailable() const
Definition: Service.h:46
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double getTx(const reco::Photon &clus, double i, double threshold, double innerDR=0, double effRatio=2)
Definition: TxCalculator.cc:86
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
double getJct(const reco::Photon &cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
StreamID streamID() const
Definition: Event.h:72
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
TxCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::InputTag &trackLabel)
Definition: TxCalculator.cc:26
double getCTx(const reco::Photon &clus, double i, double threshold, double innerDR=0, double effRatio=2)
Definition: DDAxes.h:10