00001 //-------------------------------------------------------------------------- 00002 // Environment: 00003 // This software was developed for the BESIII collaboration. If you 00004 // use all or part of it, please give an appropriate acknowledgement. 00005 // 00006 // Copyright Information: 00007 // Copyright (C) 2005 IHEP 00008 // 00009 //------------------------------------------------------------------------ 00010 00011 #ifndef EMCSELBHAEVENT_H 00012 #define EMCSELBHAEVENT_H 00013 00014 //------------- 00015 // C Headers -- 00016 //------------- 00017 #include <ctime> 00018 00019 #include <cstring> 00020 #include<list> 00021 00022 #include "GaudiKernel/Algorithm.h" 00023 #include "GaudiKernel/Property.h" 00024 00025 //Ntuple 00026 #include "GaudiKernel/NTuple.h" 00027 #include "EmcGeneralClass/EmcStructure.h" 00028 #include "EmcBhaCalib/EmcShower.h" 00029 #include "EmcBhaCalib/EmcShDigi.h" 00030 #include "EmcBhaCalib/EmcBhabhaEvent.h" 00031 #include "EmcBhaCalib/EmcBhabha.h" 00032 #include "EmcBhaCalib/EmcBhaCalibData.h" 00033 #include "EmcBhaCalib/BhabhaType.h" 00034 //#include "EmcBhaCalib/ReadBeamInfFromDb.h" 00035 00036 #include "EmcCalibConstSvc/IEmcCalibConstSvc.h" 00037 #include "EmcCalibConstSvc/EmcCalibConstSvc.h" 00038 00039 #include "BeamEnergySvc/IBeamEnergySvc.h" 00040 #include "BeamEnergySvc/BeamEnergySvc.h" 00041 00042 using namespace std; 00043 00044 class IEmcRecGeoSvc; 00045 class IBeamEnergySvc; 00046 // --------------------- 00047 // -- Class Interface -- 00048 // --------------------- 00049 // 00050 // package EmcSelBhaEvent - Select Bhabha events(MCdata) for Emc-digi Calibration 00051 // 00052 // @author Chunxiu Liu (originator/contributor etc.); 00053 // 00054 00055 class EmcSelBhaEvent:public Algorithm { 00056 00057 public: 00058 00059 //selected type 00060 enum {m_oneProng=1, m_twoProng=2}; 00061 00062 EmcSelBhaEvent(const std::string& name, ISvcLocator* pSvcLocator); 00063 00064 00065 //-------------- 00066 // Destructor 00067 //-------------- 00068 ~EmcSelBhaEvent(); 00069 00070 StatusCode initialize(); 00071 StatusCode execute(); 00072 StatusCode finalize(); 00073 00074 //----------------- 00075 bool passed() { return m_passed;} 00076 void setPassed( bool passed) { m_passed = passed;} 00077 00078 int selectedType() const 00079 { 00080 return m_selectedType; 00081 } 00082 00083 int selectedTrkID1() const 00084 { 00085 return m_selectedTrkID1; 00086 } 00087 00088 int selectedTrkID2() const 00089 { 00090 return m_selectedTrkID2; 00091 } 00092 00093 //----------------- 00094 // matrix to convert theta,phi <-> index 00095 int index(int theta, int phi) const { 00096 int val = ((m_index)[theta][phi]); 00097 return (val); } 00098 00099 // init Emc geometry (convertion matrix theta,phi <-> index) 00100 void initGeom(); 00101 00102 //-------------- 00103 StatusCode SelectBhabha(); 00104 00105 StatusCode SelectFillBhabha(); 00106 00107 void FillBhabha(); 00108 00109 //collect Bhabha event and fill matrix and vector of system of linear equations 00110 void CollectBhabha(); 00111 00112 //output matrix and vector to files 00113 void OutputMV(); 00114 00115 double findPhiDiff( double phi1, double phi2); 00116 00117 00118 //read correction function f(theta) itheta=0:55 00119 void readCorFun(); 00120 00121 //read Esigma function sigma(theta) itheta=0:55 00122 void readEsigma(); 00123 00124 // energy deposition function 56(0:55) for shower selection of Bhabha calibration 00125 void readDepEneFun(); 00126 00127 // energy resolution function 56(0:55) for shower selection of Bhabha calibration 00128 void readSigmaExp(); 00129 00130 void readRawPeakIxtal(); 00131 00132 00133 double Angle2ClosestShower( int ShowerID ); 00134 00135 private : 00136 00137 // Declare r0, z0 cut for charged tracks 00138 double m_vr0cut; 00139 double m_vz0cut; 00140 00141 double m_lowEnergyShowerCut; 00142 double m_highEnergyShowerCut; 00143 double m_matchThetaCut ; 00144 double m_matchPhiCut ; 00145 00146 double m_highMomentumCut; 00147 double m_EoPMaxCut; 00148 double m_EoPMinCut; 00149 double m_minAngShEnergyCut; 00150 double m_minAngCut; 00151 double m_acolliCut; 00152 double m_eNormCut; 00153 double m_pNormCut; 00154 double m_oneProngMomentumCut; 00155 00157 int m_selectedType; 00158 int m_selectedTrkID1; 00159 int m_selectedTrkID2; 00160 00161 int m_Nothing; 00162 int m_oneProngsSelected; 00163 int m_twoProngsMatchedSelected; 00164 int m_twoProngsOneMatchedSelected; 00165 00166 // calculate the expected energy of a Bhabha depending on theta 00167 double expectedEnergy( long int ixtal ); //not been used now 00168 00169 //Correction funtion 56(0:55) parameter 00170 double m_corFun[56]; 00171 00172 //Esigma 56(0:55) as function of Itheta 00173 double m_eSigma[56]; 00174 00175 // energy deposition function 56(0:55) for shower selection of Bhabha calibration 00176 double m_eDepEne[56]; 00177 00178 double m_eRawMean[6240]; 00179 double m_eRawRMS[6240]; 00180 00181 double m_eRawPeak[6240]; 00182 double m_eMcPeak[6240]; 00183 00184 double m_eDepMean[6240]; 00185 double m_eDepPeak[6240]; 00186 double m_eDepSigma[6240]; 00187 //energy resolution 00188 double m_eSigmaExp[56]; 00189 //cut off digis further away from the maxima digi 00190 // of a shower in theta and phi 00191 00192 int m_digiRangeCut; //be not used now for MCdata 00193 00194 //low energy shower cut 00195 double m_ShEneThreshCut; 00196 00197 // high energy shower cut 00198 double m_ShEneLeptonCut; 00199 00200 // cut on minimum number of crystals of a shower in the event 00201 int m_minNrXtalsShowerCut; //be not used now for MCdata 00202 00203 // cut on maximum number of crystals of a shower in the event 00204 int m_maxNrXtalsShowerCut; //be not used now for MCdata 00205 00206 // cut on minimum difference of the two showers in phi 00207 double m_phiDiffMinCut; //be not used now for MCdata 00208 00209 // cut on maximum difference of the two showers in phi 00210 double m_phiDiffMaxCut; //be not used now for MCdata 00211 00212 // cut on number of showers above low energy threshold less this 00213 int m_nrShThreshCut; //be not used now for MCdata 00214 00215 // cut on ratio measured to expected energy of the event 00216 //double m_eNormCut; //be not used now for MCdata 00217 00218 // cut on minimum difference of the two showers in theta 00219 double m_thetaDiffCut; //be not used now for MCdata 00220 00221 double m_LATCut; //be not used now for MCdata 00222 00223 // no shower closer than this angle 00224 //double m_minAngCut; //be not used now for MCdata 00225 00226 //number of events passed 00227 long int m_events; 00228 00229 //number of events selected 00230 long int m_taken; 00231 00232 //number of events with OneProng 00233 00234 long int m_OneProng; 00235 //number of events with TwoProngMatched 00236 long int m_TwoProngMatched; 00237 //number of events with TwoProngOneMatched 00238 long int m_TwoProngOneMatched; 00239 00240 //number of events rejected 00241 long int m_rejected; 00242 00243 //number of showers accepted 00244 long m_showersAccepted; 00245 00246 // int m_oneProngsSelelected; //be not used now for MCdata 00247 //int m_twoProngsSelected; //be not used now for MCdata 00248 00249 00250 list<EmcShower> m_showerList; 00251 00252 //------------- 00253 // fill Matrix of system of linear equations 00254 void fillMatrix(); 00255 00256 //write the matrix and vector also to file ? 00257 bool m_writeMVToFile; 00258 //file name extensions 00259 std::string m_fileExt; 00260 00261 //file directory 00262 std::string m_fileDir; 00263 00264 //input file directory 00265 std::string m_inputFileDir; 00266 00267 //Selection method with "Ithe" and "Ixtal" 00268 std::string m_selMethod; 00269 00270 //calibration data: matrix M, vector R and other stuff 00271 EmcBhaCalibData* myCalibData; 00272 //the Bhabha event that is filled with the two showers 00273 EmcBhabhaEvent* myBhaEvt; 00274 00275 int m_nXtals; 00276 00277 //SigmaCut : selecting Bhabha events for digi-calibration 00278 double m_sigmaCut; 00279 //beam energy GeV 00280 double m_beamEnergy; 00281 00282 00283 bool m_ReadBeamEFromDB; 00284 bool m_elecSaturation; 00285 IBeamEnergySvc *m_BeamEnergySvc; 00286 // ReadBeamInfFromDb m_readDb; 00287 int m_irun; 00288 00289 //message output in the tool classes 00290 int m_MsgFlag; 00291 00292 // matrix to convert theta,phi <-> index 00293 int **m_index; 00294 int m_measure[6240]; 00295 bool m_passed; 00296 double m_inputConst[6240]; 00297 int m_event; 00298 int m_run; 00299 IEmcRecGeoSvc* m_iGeoSvc; 00300 00301 //IEmcCalibConstSvc* m_emcCalibConstSvc; 00302 00303 }; 00304 00305 00306 #endif // EMCSELBHAEVENT_H 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325