00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __TMarH1ElecCalibration_H
00029 #include "TMarH1ElecCalibration.h"
00030 #endif
00031
00032 #include <iostream>
00033
00034 ClassImp(TMarH1ElecCalibration)
00035
00036
00037
00038
00039
00040
00041
00042 TMarH1ElecCalibration::TMarH1ElecCalibration(Bool_t DoStackWiseCalibration,
00043 Bool_t DoZimpactWiseCalibration,
00044 Bool_t DoResolutionSmearing,
00045 Bool_t UseTrackTheta, Bool_t UseTrackPhi)
00046 {
00047
00048
00049
00050 bUseTrackTheta = UseTrackTheta;
00051 bUseTrackPhi = UseTrackPhi;
00052
00053 bDoStackWiseCalibration = DoStackWiseCalibration;
00054 bDoZimpactWiseCalibration = DoZimpactWiseCalibration;
00055 bDoForwardWheelWiseCalibration = DoZimpactWiseCalibration;
00056
00057 bDoResolutionSmearing = DoResolutionSmearing;
00058
00059 fExtrapol = new H1CalcTrackExtrapol();
00060
00061 fCalibration = 0;
00062
00063
00064 fElectronTrack = TLorentzVector(0,0,0,0);
00065 fElectronCluster = TLorentzVector(0,0,0,0);
00066 fCalibratedElectron = TLorentzVector(0,0,0,0);
00067
00068 fCharge = 0;
00069 fLinkedTrackType = 0;
00070
00071
00072 fElectronTheta = 0.0;
00073 fElectronPhi = 0.0;
00074
00075 }
00076
00077 TMarH1ElecCalibration::~TMarH1ElecCalibration()
00078 {
00079
00080
00081 if ( fExtrapol != 0 ) delete fExtrapol;
00082 }
00083
00084 const TLorentzVector& TMarH1ElecCalibration::GetElecCalibration(const TLorentzVector& UncalibratedElectron,
00085 const TLorentzVector& ElectronTrack,
00086 Int_t Charge, Float_t ZVertex,
00087 Bool_t IsMC, Int_t RunPeriod,
00088 Int_t LinkedTrackType)
00089 {
00090
00091
00092
00093 fElectronTrack = (TLorentzVector)ElectronTrack;
00094 fElectronCluster = (TLorentzVector)UncalibratedElectron;
00095 fCharge = Charge;
00096 fLinkedTrackType = LinkedTrackType;
00097
00098
00099 static TVector3 impactPositon(0.0,0.0,0.0);
00100
00101
00102
00103
00104 if (!IsMC) {
00105
00106 if (RunPeriod == 5){
00107
00108 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("9900", RunPeriod);
00109 fCalibration = Calibration;
00110 } else if (RunPeriod == 7 || RunPeriod == 6){
00111
00112 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("0304", RunPeriod);
00113 fCalibration = Calibration;
00114 } else if (RunPeriod < 5){
00115
00116 Warning("GetElecCalibration", "Run Period not supported. Taking no calibration.");
00117 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("Default");
00118 fCalibration = Calibration;
00119 } else {
00120
00121 Warning("GetElecCalibration", "No valid Run Period. Taking default CalibrationParameters 9900.");
00122 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("9900");
00123 fCalibration = Calibration;
00124 }
00125
00126 }
00127
00128 else {
00129
00130 if (RunPeriod == 5){
00131
00132 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("99MC", RunPeriod);
00133 fCalibration = Calibration;
00134 } else if (RunPeriod == 6 || RunPeriod == 7){
00135
00136 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("03MC", RunPeriod);
00137 fCalibration = Calibration;
00138 } else if (RunPeriod < 5){
00139
00140 Warning("GetElecCalibration", "Run Period not supported. Taking no calibration.");
00141 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("Default");
00142 fCalibration = Calibration;
00143 } else {
00144
00145 Warning("GetElecCalibration", "No valid Run Period. Taking default CalibrationParameters 99MC.");
00146 static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("99MC");
00147 fCalibration = Calibration;
00148 }
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158 if (bDoStackWiseCalibration) {
00159
00160
00161
00162
00163
00164
00165
00166
00167 impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00168
00169 Float_t zImpact = impactPositon.Z();
00170 Float_t extrapolPhi = impactPositon.Phi();
00171
00172
00173
00174
00175 Float_t Correction = 1.0 / fCalibration->GetOctantCalibrationFactor(extrapolPhi, zImpact);
00176 fElectronCluster *= Correction;
00177
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187 if (bDoZimpactWiseCalibration) {
00188
00189
00190
00191
00192
00193
00194
00195
00196 impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00197
00198 Float_t zImpact = impactPositon.Z();
00199
00200
00201
00202
00203 Float_t Correction = 1.0 / fCalibration->GetZimpactCalibrationFactor(zImpact);
00204 fElectronCluster *= Correction;
00205
00206 }
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 if (bDoForwardWheelWiseCalibration) {
00217
00218
00219
00220
00221
00222
00223
00224
00225 impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00226
00227 Float_t zImpact = impactPositon.Z();
00228
00229
00230
00231
00232 Float_t Correction = fCalibration->GetForwardWheelCalibrationFactor(zImpact);
00233 fElectronCluster *= Correction;
00234
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 if (bDoResolutionSmearing && IsMC) {
00249
00250
00251
00252
00253
00254
00255 impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00256
00257 Float_t zImpact = impactPositon.Z();
00258
00259
00260
00261 Float_t Correction = fCalibration->GetResolutionSmearingFactor(zImpact);
00262 fElectronCluster *= Correction;
00263
00264 }
00265
00266
00267
00268
00269
00270
00271 fCalibratedElectron = fElectronCluster;
00272 return fCalibratedElectron;
00273
00274 }
00275
00276 void TMarH1ElecCalibration::MakeVertexElectron()
00277 {
00278
00279
00280
00281
00282
00283
00284 fElectronTheta = 0.;
00285 if ( bUseTrackTheta && IsGoodTrack() ){
00286 fElectronTheta = fElectronTrack.Theta();
00287 } else {
00288 fElectronTheta = fElectronCluster.Theta();
00289 }
00290
00291
00292
00293
00294
00295 fElectronPhi = 0.;
00296 if ( bUseTrackPhi && IsGoodTrack() ){
00297 fElectronPhi = fElectronTrack.Phi();
00298 } else {
00299
00300
00301
00302 Float_t phiLAr = fElectronCluster.Phi();
00303 Float_t dPhi = fExtrapol->MakeExtrapolatedPhi(fElectronCluster.P(),
00304 fElectronTheta, phiLAr, fCharge) - phiLAr;
00305 fElectronPhi = phiLAr - dPhi;
00306
00307 }
00308
00309 }
00310
00311 const TLorentzVector& TMarH1ElecCalibration::GetElectronVector()
00312 {
00313
00314
00315 static TLorentzVector electron;
00316
00317
00318
00319
00320
00321 MakeVertexElectron();
00322
00323
00324
00325
00326 Double_t elecP = fElectronCluster.P();
00327
00328 Double_t elecPx = elecP * TMath::Sin(fElectronTheta)*TMath::Cos(fElectronPhi);
00329 Double_t elecPy = elecP * TMath::Sin(fElectronTheta)*TMath::Sin(fElectronPhi);
00330 Double_t elecPz = elecP * TMath::Cos(fElectronTheta);
00331
00332 electron.SetPxPyPzE(elecPx, elecPy, elecPz, elecP);
00333
00334 return electron;
00335 }
00336
00337 Bool_t TMarH1ElecCalibration::IsGoodTrack()
00338 {
00339
00340 return (fLinkedTrackType < 1 || fLinkedTrackType > 2 ||
00341 fElectronCluster.Theta() < (30.0*TMath::Pi()/180.0)
00342 ) ? kFALSE : kTRUE;
00343 }