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 Member Functions | Private Attributes
TxCalculator Class Reference

#include <TxCalculator.h>

Public Member Functions

double getCTx (const reco::Photon clus, double i, double threshold, double innerDR=0, double effRatio=2)
 
double getJct (const reco::Photon cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
 
double getJt (const reco::Photon cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
 
double getJurassicArea (double r1, double r2, double width)
 
double getMPT (double ptCut=0, double etaCut=1000)
 
double getTx (const reco::Photon clus, double i, double threshold, double innerDR=0, double effRatio=2)
 
 TxCalculator (const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag trackLabel)
 

Private Member Functions

double calcDphi (double phi1_, double phi2_)
 
double dRDistance (double eta1, double phi1, double eta2, double phi2)
 

Private Attributes

edm::Handle
< reco::TrackCollection
recCollection
 
CLHEP::RandFlat * theDice
 

Detailed Description

Definition at line 27 of file TxCalculator.h.

Constructor & Destructor Documentation

TxCalculator::TxCalculator ( const edm::Event iEvent,
const edm::EventSetup iSetup,
edm::InputTag  trackLabel 
)

Definition at line 24 of file TxCalculator.cc.

References edm::hlt::Exception, edm::Event::getByLabel(), edm::RandomNumberGenerator::getEngine(), and edm::Service< T >::isAvailable().

25 {
26  iEvent.getByLabel(trackLabel, recCollection);
28  if ( ! rng.isAvailable()) {
29  throw cms::Exception("Configuration")
30  << "XXXXXXX requires the RandomNumberGeneratorService\n"
31  "which is not present in the configuration file. You must add the service\n"
32  "in the configuration file or remove the modules that require it.";
33  }
34  CLHEP::HepRandomEngine& engine = rng->getEngine();
35  theDice = new CLHEP::RandFlat(engine, 0, 1);
36 
37 }
CLHEP::RandFlat * theDice
Definition: TxCalculator.h:44
edm::Handle< reco::TrackCollection > recCollection
Definition: TxCalculator.h:43
bool isAvailable() const
Definition: Service.h:47
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356

Member Function Documentation

double TxCalculator::calcDphi ( double  phi1_,
double  phi2_ 
)
inlineprivate

Definition at line 54 of file TxCalculator.h.

References PI.

Referenced by dRDistance().

55  {
56  double dphi=phi1_-phi2_;
57 
58  if (dphi>0){
59  while (dphi>2*PI) dphi-=2*PI;
60  if (dphi>PI) dphi=2*PI-dphi;
61  } else {
62  while (dphi<-2*PI) dphi+=2*PI;
63  if (dphi<-PI) dphi=-2*PI-dphi;
64  }
65  return dphi;
66  }
#define PI
double TxCalculator::dRDistance ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
)
inlineprivate

Definition at line 46 of file TxCalculator.h.

References calcDphi(), and mathSSE::sqrt().

47  {
48  double deta = eta1 - eta2;
49  double dphi = (calcDphi(phi1, phi2));
50 
51  return sqrt(deta * deta + dphi * dphi);
52  }
T sqrt(T t)
Definition: SSEVec.h:46
double calcDphi(double phi1_, double phi2_)
Definition: TxCalculator.h:54
double TxCalculator::getCTx ( const reco::Photon  clus,
double  i,
double  threshold,
double  innerDR = 0,
double  effRatio = 2 
)

Definition at line 124 of file TxCalculator.cc.

References reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), dt_dqm_sourceclient_common_cff::reco, and vdt::x.

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->fire();
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 }
CLHEP::RandFlat * theDice
Definition: TxCalculator.h:44
edm::Handle< reco::TrackCollection > recCollection
Definition: TxCalculator.h:43
double dRDistance(double eta1, double phi1, double eta2, double phi2)
Definition: TxCalculator.h:46
double getTx(const reco::Photon clus, double i, double threshold, double innerDR=0, double effRatio=2)
Definition: TxCalculator.cc:86
x
Definition: VDTMath.h:216
double TxCalculator::getJct ( const reco::Photon  cluster,
double  r1 = 0.4,
double  r2 = 0.04,
double  jWidth = 0.015,
double  threshold = 2 
)

Definition at line 203 of file TxCalculator.cc.

References gather_cfg::cout, dPhi(), reco::LeafCandidate::eta(), eta(), phi, reco::LeafCandidate::phi(), PI, diffTwoXMLs::r1, and dt_dqm_sourceclient_common_cff::reco.

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 }
#define PI
edm::Handle< reco::TrackCollection > recCollection
Definition: TxCalculator.h:43
double getJt(const reco::Photon cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
T eta() const
virtual double eta() const
momentum pseudorapidity
double getJurassicArea(double r1, double r2, double width)
Definition: TxCalculator.cc:40
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
tuple cout
Definition: gather_cfg.py:121
virtual double phi() const
momentum azimuthal angle
Definition: DDAxes.h:10
double TxCalculator::getJt ( const reco::Photon  cluster,
double  r1 = 0.4,
double  r2 = 0.04,
double  jWidth = 0.015,
double  threshold = 2 
)

Definition at line 165 of file TxCalculator.cc.

References gather_cfg::cout, dPhi(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::LeafCandidate::eta(), eta(), phi, reco::LeafCandidate::phi(), PI, dt_dqm_sourceclient_common_cff::reco, and mathSSE::sqrt().

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 }
#define PI
edm::Handle< reco::TrackCollection > recCollection
Definition: TxCalculator.h:43
T eta() const
virtual double eta() const
momentum pseudorapidity
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:46
tuple cout
Definition: gather_cfg.py:121
virtual double phi() const
momentum azimuthal angle
Definition: DDAxes.h:10
double TxCalculator::getJurassicArea ( double  r1,
double  r2,
double  width 
)

Definition at line 40 of file TxCalculator.cc.

References funct::cos(), and mathSSE::sqrt().

40  {
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 }
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double TxCalculator::getMPT ( double  ptCut = 0,
double  etaCut = 1000 
)

Definition at line 53 of file TxCalculator.cc.

References eta(), dt_dqm_sourceclient_common_cff::reco, and mathSSE::sqrt().

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 }
edm::Handle< reco::TrackCollection > recCollection
Definition: TxCalculator.h:43
T eta() const
T sqrt(T t)
Definition: SSEVec.h:46
double TxCalculator::getTx ( const reco::Photon  clus,
double  i,
double  threshold,
double  innerDR = 0,
double  effRatio = 2 
)

Definition at line 86 of file TxCalculator.cc.

References reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), and dt_dqm_sourceclient_common_cff::reco.

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->fire();
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 }
CLHEP::RandFlat * theDice
Definition: TxCalculator.h:44
edm::Handle< reco::TrackCollection > recCollection
Definition: TxCalculator.h:43
double dRDistance(double eta1, double phi1, double eta2, double phi2)
Definition: TxCalculator.h:46
x
Definition: VDTMath.h:216

Member Data Documentation

edm::Handle<reco::TrackCollection> TxCalculator::recCollection
private

Definition at line 43 of file TxCalculator.h.

CLHEP::RandFlat* TxCalculator::theDice
private

Definition at line 44 of file TxCalculator.h.