00001 00002 #ifndef NOISEALG_H 00003 #define NOISEALG_H 00004 00005 //#include "HecRunHeader2001v0.h" 00006 #include "Headers.h" 00007 //#include "HecEvent.h" 00008 #include "Event.h" 00009 #include "Geometry.h" 00010 #include "SystemAlg.h" 00011 #include "TBID.h" 00012 #include "CalibrationAlg.h" 00013 00014 #include "TH1.h" 00015 #include "TF1.h" 00016 00017 #include <string> 00018 #include <map> 00019 00020 using std::string; 00021 using std::map; 00022 00023 /*! -Class: NoiseAlg 00024 - Author: Michel Lefebvre 00025 - Date: 21/7/2003 00026 - Description: NoiseAlg is a systemAlg that deal with digital filtering channel noise (nA) 00027 1- Compute an estimate of the noise (nA) of each channel given a run number and store 00028 the results in a file (one per detector); 00029 or 00030 2- Read noise file(s) for user access to noise (nA) values. 00031 */ 00032 class NoiseAlg : public SystemAlg { 00033 public: 00034 00035 /** The user should never need to use this contructor 00036 * @param event A pointer in the event. Information contained in the event 00037 * gets refreshed before the execute method is run 00038 * @param hecGeom Pointer to the singleton Geometry object 00039 * @param runHeader Pointer to the singleton HecRunHeader object 00040 */ 00041 00042 NoiseAlg(Event* event, Geometry* hecGeom, Headers* runHeader); 00043 00044 ~NoiseAlg(); 00045 00046 //! Gets run once at the begining of the event Loop 00047 bool initialize(); 00048 00049 //! Gets run for every event 00050 bool execute(); 00051 00052 //! Gets run after all events have been executed 00053 bool finalize(); 00054 00055 //################################ 00056 // hec public methods 00057 00058 /** Enable the computation of noise for the hec 00059 * @param calibFileName Name of calibration coefficient file 00060 */ 00061 void hecEnable(string calibFileName); 00062 00063 /** Set the print level for noise computation for the hec 00064 * 0 minimum 00065 * 1 print noise results (default) 00066 * 2 above and print the mean sigma/pedrms values 00067 * 3 above and print +/- 2 sigma fit results 00068 * 4 above and print first gaussian fit result 00069 * @param level Print level 00070 */ 00071 void hecPrintLevel(int level){m_hecPrintLevel = level;}; 00072 00073 /** Set the hec noise result file name 00074 * @param noiseFileName the name of the noise file 00075 */ 00076 void hecNoiseFileName(string noiseFileName){m_hecNoiseFileName = noiseFileName;}; 00077 00078 /** Get the febno keyed hec noise (nA) map 00079 * The map contains entries for all connected channels 00080 * if the noise could not be obtained for a channel, the map contains 0. 00081 */ 00082 map<int, float> hecNoiseMap(){return m_hecNoiseMap;}; 00083 00084 /** Get the hec noise (nA) 00085 * If the noise could not be obtained, 0 is returned. 00086 * @param febno channel febno 00087 */ 00088 float hecNoise(int febno); 00089 00090 /** Get the febno keyed hec noise error estimate (nA) map 00091 * The map contains entries for all connected channels 00092 * if the noise could not be obtained for a channel, the map contains 0. 00093 */ 00094 map<int, float> hecNoiseErrorMap(){return m_hecNoiseErrorMap;}; 00095 00096 /** Get the hec noise error estimate (nA) 00097 * If the noise could not be obtained, 0 is returned. 00098 * @param febno channel febno 00099 */ 00100 float hecNoiseError(int febno); 00101 00102 /** Get the febno keyed hec noise status word map 00103 * The map contains entries for all connected channels 00104 * status == 0 the noise was obtained directly from the channel 00105 * status != 0 the noise was obtained from the ped rms of the channel 00106 * and the noise/pedrms of other channels 00107 */ 00108 map<int, int> hecNoiseStatusMap(){return m_hecNoiseStatusMap;}; 00109 00110 /** Get the hec noise status word (see hecNoiseStatusMap) 00111 * @param febno channel febno 00112 */ 00113 int hecNoiseStatus(int febno); 00114 00115 /** Read a hec noise file 00116 * If no noise file name is given, then the file is assumed to be 00117 * hec_nnnnn_noise.dat 00118 * @param noiseFileName the name of the noise file 00119 */ 00120 void hecReadNoiseFile(string noiseFileName = ""); 00121 00122 //! Print hec noise data 00123 void hecPrintNoise(); 00124 00125 00126 //################################ 00127 // emec public methods 00128 00129 /** Enable the computation of noise for the emec 00130 * @param calibFileName Name of calibration coefficient file 00131 */ 00132 void emecEnable(string calibFileName); 00133 00134 /** Set the print level for noise computation for the emec 00135 * 0 minimum 00136 * 1 print noise results (default) 00137 * 2 above and print the mean sigma/pedrms values 00138 * 3 above and print +/- 2 sigma fit results 00139 * 4 above and print first gaussian fit result 00140 * @param level Print level 00141 */ 00142 void emecPrintLevel(int level){m_emecPrintLevel = level;}; 00143 00144 /** Set the emec noise result file name 00145 * @param noiseFileName the name of the noise file 00146 */ 00147 void emecNoiseFileName(string noiseFileName){m_emecNoiseFileName = noiseFileName;}; 00148 00149 /** Get the febno keyed emec noise (nA) map 00150 * The map contains entries for all connected channels 00151 * if the noise could not be obtained for a channel, the map contains 0. 00152 */ 00153 map<int, float> emecNoiseMap(){return m_emecNoiseMap;}; 00154 00155 /** Get the emec noise (nA) 00156 * If the noise could not be obtained, 0 is returned. 00157 * @param febno channel febno 00158 */ 00159 float emecNoise(int febno); 00160 00161 /** Get the febno keyed emec noise error estimate (nA) map 00162 * The map contains entries for all connected channels 00163 * if the noise could not be obtained for a channel, the map contains 0. 00164 */ 00165 map<int, float> emecNoiseErrorMap(){return m_emecNoiseErrorMap;}; 00166 00167 /** Get the emec noise error estimate (nA) 00168 * If the noise could not be obtained, 0 is returned. 00169 * @param febno channel febno 00170 */ 00171 float emecNoiseError(int febno); 00172 00173 /** Get the febno keyed emec noise status word map 00174 * The map contains entries for all connected channels 00175 * status == 0 the noise was obtained directly from the channel 00176 * status != 0 the noise was obtained from the ped rms of the channel 00177 */ 00178 map<int, int> emecNoiseStatusMap(){return m_emecNoiseStatusMap;}; 00179 00180 /** Get the emec noise status word (see emecNoiseStatusMap) 00181 * @param febno channel febno 00182 */ 00183 int emecNoiseStatus(int febno); 00184 00185 /** Read a emec noise file 00186 * If no noise file name is given, then assume the file is 00187 * emec?_nnnnn_noise.dat where ? is given by the input data file name 00188 * @param noiseFileName the name of the noise file 00189 */ 00190 void emecReadNoiseFile(string noiseFileName = ""); 00191 00192 //! Print emec noise data 00193 void emecPrintNoise(); 00194 00195 00196 // all the following variables will be made private eventually 00197 // only for experts! 00198 00199 //################################ 00200 // hec public variables 00201 00202 // febno keyed maps for all connected channels 00203 map<int, TH1F*> m_hecHMap; // map of histograms 00204 map<int, float> m_hecHistoMeanMap; // map of histogram signal means 00205 map<int, float> m_hecHistoRMSMap; // map of histogram signal rms 00206 map<int, float> m_hecHistoNMap; // map of histogram number of entries in bins 00207 // febno keyed mean sigma/peds maps for all connected channels 00208 // all entried for a given ieta are the same 00209 map<int, float> m_hecMeanRatioMap; 00210 map<int, float> m_hecMeanRatioErrorMap; 00211 // febno keyed maps for good channels (retained for noise fit) 00212 map<int, float> m_hecFitMeanMap; // map of fitted means 00213 map<int, float> m_hecFitMeanErrorMap; 00214 map<int, float> m_hecFitSigmaMap; // map of fitted sigmas 00215 map<int, float> m_hecFitSigmaErrorMap; 00216 map<int, float> m_hecFitProbMap; // map of fit probabilities 00217 // febno keyed maps for good channels and PedRMSnA > 0 00218 map<int, float> m_hecFitSigmaOverPedRMSMap; // map of sigma/ped rms 00219 map<int, float> m_hecFitSigmaOverPedRMSErrorMap; // map of sigma/ped rms 00220 00221 //################################ 00222 // emec public variables 00223 00224 // febno keyed maps for all connected channels 00225 map<int, TH1F*> m_emecHMap; // map of histograms 00226 map<int, float> m_emecHistoMeanMap; // map of histogram signal means 00227 map<int, float> m_emecHistoRMSMap; // map of histogram signal rms 00228 map<int, float> m_emecHistoNMap; // map of histogram number of entries in bins 00229 // febno keyed mean sigma/peds maps for all connected channels 00230 // all entried for a given ieta are the same 00231 map<int, float> m_emecMeanRatioMap; 00232 map<int, float> m_emecMeanRatioErrorMap; 00233 // febno keyed maps for good channels (retained for noise fit) 00234 map<int, float> m_emecFitMeanMap; // map of fitted means 00235 map<int, float> m_emecFitMeanErrorMap; 00236 map<int, float> m_emecFitSigmaMap; // map of fitted sigmas 00237 map<int, float> m_emecFitSigmaErrorMap; 00238 map<int, float> m_emecFitProbMap; // map of fit probabilities 00239 // febno keyed maps for good channels and PedRMSnA > 0 00240 map<int, float> m_emecFitSigmaOverPedRMSMap; // map of sigma/ped rms 00241 map<int, float> m_emecFitSigmaOverPedRMSErrorMap; // map of sigma/ped rms 00242 00243 private: 00244 00245 //################################ 00246 // hec private methods 00247 00248 // make a TBID from a febno only considering ieta and iz 00249 TBID hecMakeTBID(int febno); 00250 // write noise data file 00251 void hecWriteNoiseFile(); 00252 00253 //################################ 00254 // emec private methods 00255 00256 // make a TBID from a febno only considering ieta and iz 00257 TBID emecMakeTBID(int febno); 00258 // write noise data file 00259 void emecWriteNoiseFile(); 00260 00261 //################################ 00262 // private variables 00263 00264 Geometry* m_geo; 00265 Event* m_event; 00266 Headers* m_runHeader; 00267 // pointer to CalibrationAlg systemAlg 00268 CalibrationAlg* m_calibration; 00269 // cell signal range (nA) and number of bins for signal histograms 00270 float m_sigMin; 00271 float m_sigMax; 00272 int m_nbins; 00273 // signal cut variables 00274 float m_SigmaMeanCut; // |HistoMean-FitMean| > m_SigmaMeanCut*FitMeanError 00275 float m_MeanCut; // (nA) |HistoMean| > m_MeanCut 00276 // vector of TF1* needed for deletion in destructor 00277 vector<TF1*> m_TF1Vector; 00278 00279 //################################ 00280 // hec private variables 00281 00282 // enable flags 00283 bool m_hecEnable; 00284 // print level 00285 int m_hecPrintLevel; 00286 // noise result file name 00287 string m_hecNoiseFileName; 00288 // febno keyed noise maps for all connected channels 00289 map<int, float> m_hecNoiseMap; 00290 map<int, float> m_hecNoiseErrorMap; 00291 map<int, int> m_hecNoiseStatusMap; 00292 00293 //################################ 00294 // emec private variables 00295 00296 // enable flags 00297 bool m_emecEnable; 00298 // print level 00299 int m_emecPrintLevel; 00300 // noise result file name 00301 string m_emecNoiseFileName; 00302 // febno keyed noise maps for all connected channels 00303 map<int, float> m_emecNoiseMap; 00304 map<int, float> m_emecNoiseErrorMap; 00305 map<int, int> m_emecNoiseStatusMap; 00306 00307 }; 00308 00309 #endif