Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TMarH1ElecCalibration.C

Go to the documentation of this file.
00001 /***************************************************************************
00002                           TMarH1ElecCalibration.C  -  description
00003     begin                : Fri Jul 15 2003
00004     last update          : $Date: 2005/03/11 08:52:42 $ (UTC)
00005     by                   : $Author: sauvan $
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009                                    based on
00010 
00011                           H1JetCalibration.C  -  description
00012                              -------------------
00013     begin                : Fri Jun 14 2002
00014     copyright            : (C) 2002 by Nicole Werner
00015     email                : nwerner@mail.desy.de
00016 
00017  ***************************************************************************/
00018 
00019 /***************************************************************************
00020 *                                                                         *
00021 *   This program is free software; you can redistribute it and/or modify  *
00022 *   it under the terms of the GNU General Public License as published by  *
00023 *   the Free Software Foundation; either version 2 of the License, or     *
00024 *   (at your option) any later version.                                   *
00025 *                                                                         *
00026 ***************************************************************************/
00027 
00028 #ifndef __TMarH1ElecCalibration_H
00029 #include "TMarH1ElecCalibration.h"
00030 #endif
00031 
00032 #include <iostream>
00033 
00034 ClassImp(TMarH1ElecCalibration)
00035   //------------------------------------------------------
00036   // This class is for application of electron energy calibration coefficients
00037   //
00038   // More details to come
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   // Constructor
00048   // Takes decisions on whether to use cluster/track theta & phi in constructor
00049 
00050   bUseTrackTheta = UseTrackTheta;
00051   bUseTrackPhi = UseTrackPhi;
00052 
00053   bDoStackWiseCalibration = DoStackWiseCalibration;
00054   bDoZimpactWiseCalibration = DoZimpactWiseCalibration;
00055   bDoForwardWheelWiseCalibration = DoZimpactWiseCalibration;  // FIXME
00056   //  bDoForwardWheelWiseCalibration = false;  // FIXME
00057   bDoResolutionSmearing = DoResolutionSmearing;
00058 
00059   fExtrapol = new H1CalcTrackExtrapol();
00060 
00061   fCalibration = 0;
00062 
00063   // data members to store electron information passed into this class
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   // data members to store electron information determined by this class
00072   fElectronTheta = 0.0;
00073   fElectronPhi = 0.0;
00074 
00075 }
00076 
00077 TMarH1ElecCalibration::~TMarH1ElecCalibration()
00078 {
00079   // Destructor
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   // Get calibrated electron object with user steered calibration constants
00091 
00092   // set data members
00093   fElectronTrack = (TLorentzVector)ElectronTrack;
00094   fElectronCluster = (TLorentzVector)UncalibratedElectron;
00095   fCharge = Charge;
00096   fLinkedTrackType = LinkedTrackType;
00097   
00098   // static local variables, i.e. wannabe data members
00099   static TVector3 impactPositon(0.0,0.0,0.0);
00100 
00101   // Get calibration parameters for different run periods...
00102 
00103   // ... for data
00104   if (!IsMC) {
00105 
00106     if (RunPeriod == 5){
00107       // Do 9900
00108       static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("9900", RunPeriod);
00109       fCalibration = Calibration;
00110     } else if (RunPeriod == 7 || RunPeriod == 6){ // good for 0203 or 0304?
00111       // Do 0304
00112       static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("0304", RunPeriod);
00113       fCalibration = Calibration;
00114     } else if (RunPeriod < 5){
00115       // 94-99 not supported
00116       Warning("GetElecCalibration", "Run Period not supported. Taking no calibration.");
00117       static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("Default");
00118       fCalibration = Calibration;
00119     } else {
00120       // Unknown Run Period
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   // ...for monte carlo
00128   else {
00129     
00130     if (RunPeriod == 5){
00131       // Do 99MC
00132       static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("99MC", RunPeriod);
00133       fCalibration = Calibration;
00134     } else if (RunPeriod == 6 || RunPeriod == 7){  // compare 03MC with 0304 only?
00135       // use 03MC monte carlo
00136       static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("03MC", RunPeriod);
00137       fCalibration = Calibration;
00138    } else if (RunPeriod < 5){
00139       // 94-99 not supported
00140       Warning("GetElecCalibration", "Run Period not supported. Taking no calibration.");
00141       static TMarH1LarCalParameters* Calibration = new TMarH1LarCalParameters("Default");
00142       fCalibration = Calibration;
00143     } else {
00144       // Unknown Run Period
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     // Wheel-Octant based calibration
00161     
00162 
00163     //
00164     //    Calculate Zimpact, PhiImpact
00165     //
00166 
00167     impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00168 
00169     Float_t zImpact = impactPositon.Z();
00170     Float_t extrapolPhi = impactPositon.Phi();
00171     
00172 
00173     // Apply correction
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     // Zimpact based calibration
00190 
00191 
00192     //
00193     //    Calculate Zimpact
00194     //
00195 
00196     impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00197 
00198     Float_t zImpact = impactPositon.Z();
00199 
00200 
00201     // Apply correction
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     // calibration of forward wheels
00219     
00220 
00221     //
00222     //    Calculate Zimpact
00223     //
00224     
00225     impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00226 
00227     Float_t zImpact = impactPositon.Z();
00228 
00229 
00230     // Apply correction
00231     
00232     Float_t Correction = fCalibration->GetForwardWheelCalibrationFactor(zImpact);
00233     fElectronCluster *= Correction;
00234 
00235   }
00236 
00237 
00238   //
00239   // **********************************************************************
00240   // **********************************************************************
00241   //
00242   
00243 
00244   //
00245   // Smear by difference in resolutions
00246   //
00247   
00248   if (bDoResolutionSmearing  && IsMC) {
00249 
00250 
00251     //
00252     //    Calculate Zimpact
00253     //
00254 
00255     impactPositon = fExtrapol->MakeImpactPosition(GetElectronVector(), fCharge);
00256 
00257     Float_t zImpact = impactPositon.Z();
00258 
00259   
00260     // Apply smearing    
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   // Determines the electron theta and phi at the vertex, 
00279   // according to user steering and track quality.
00280 
00281   // What about charge?  Unconditionally accepting (verified) track charge.
00282 
00283   // Theta
00284   fElectronTheta = 0.;
00285   if ( bUseTrackTheta && IsGoodTrack() ){  // do not use theta from bad tracks
00286     fElectronTheta = fElectronTrack.Theta();
00287   } else {
00288     fElectronTheta = fElectronCluster.Theta();
00289   }
00290   
00291   // 
00292   // Electron Phi at the event vertex
00293   //
00294 
00295   fElectronPhi = 0.;
00296   if ( bUseTrackPhi && IsGoodTrack() ){  // do not use phi from bad tracks
00297     fElectronPhi = fElectronTrack.Phi();
00298   } else {
00299     // back-extrapolate phi from cluster center back to vertex
00300     // WARNING this may lead to inconsistency as forward-extrapolate with H1HelixExtrapolation
00301 
00302     Float_t phiLAr = fElectronCluster.Phi();
00303     Float_t dPhi   = fExtrapol->MakeExtrapolatedPhi(fElectronCluster.P(),
00304                                                     fElectronTheta, phiLAr, fCharge) - phiLAr;
00305     fElectronPhi   = phiLAr - dPhi; // minus sign because of back-extrapolation
00306     
00307   }
00308   
00309 }
00310 
00311 const TLorentzVector& TMarH1ElecCalibration::GetElectronVector()
00312 {
00313   // accessor for the electron TLorentzVector at the vertex
00314   
00315   static TLorentzVector electron;
00316   
00317   //
00318   // Determine theta and phi of electron four-vector (at vertex)
00319   //
00320 
00321   MakeVertexElectron();
00322 
00323 
00324   // Now construct the four-vector
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);  // tiny mass inconsistency
00333   
00334   return electron;
00335 }
00336 
00337 Bool_t TMarH1ElecCalibration::IsGoodTrack()
00338 {
00339   // evaluates quality of linked track
00340   return (fLinkedTrackType < 1 || fLinkedTrackType > 2  || 
00341           fElectronCluster.Theta() < (30.0*TMath::Pi()/180.0) 
00342           ) ? kFALSE : kTRUE;
00343 }

Generated on Thu Jul 28 11:48:52 2005 for SFHMarana by doxygen 1.3.2