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 #ifndef _ROLLINGGAIN_H_
00026 #define _ROLLINGGAIN_H_
00027
00028 #include "GaudiAlg/GaudiAlgorithm.h"
00029 #include "Conventions/Detectors.h"
00030 #include "Event/ReadoutHeader.h"
00031 #include "Event/CalibReadoutHeader.h"
00032 #include "DataSvc/ICableSvc.h"
00033 #include "DataSvc/IRunDataSvc.h"
00034 #include "TH1F.h"
00035 #include "TF1.h"
00036 #include "TFile.h"
00037 #include "TTree.h"
00038 #include <map>
00039
00040 using namespace std;
00041 using namespace DayaBay;
00042
00043 class RollingGain : public GaudiAlgorithm
00044 {
00045
00046 public:
00047
00048 RollingGain(const std::string& name, ISvcLocator* pSvcLocator);
00049 virtual ~RollingGain();
00050
00051 virtual StatusCode initialize();
00052 virtual StatusCode execute();
00053 virtual StatusCode finalize();
00054
00055 static double poisson(double u, int n);
00056 static double gn(double x,double n, double q0, double sigma0,
00057 double q1, double sigma1);
00058 static double NIMmodel(double* xpar,double* par);
00059 static double Pedestal(double* xpar,double* par);
00060 void Fit();
00061
00062 int InitPmtProp(const ServiceMode& svc);
00063 int ResetPmtProp();
00064
00065 private:
00067 ICableSvc* m_cableSvc;
00068 IRunDataSvc* m_runDataSvc;
00069
00070 TF1* f1;
00071 TF1* f2;
00072 TFile* m_rootfile;
00073 TTree* m_tree;
00074 FILE* m_masterfile;
00075 string m_fileName;
00076
00077 unsigned long m_NTrigger;
00078
00079 struct PmtProp {
00080 TH1F *h_Adc;
00081 TH1F *h_Tdc;
00082 TH1F *h_PreAdc;
00083 double Pedestal;
00084 double PedestalErr;
00085 double DarkRate;
00086 double DarkRateErr;
00087 double Gain;
00088 double GainErr;
00089 double Sigma;
00090 double SigmaErr;
00091 int Status;
00092 int NHits;
00093 int FitStatus;
00094 double Chi2;
00095 string PmtLabel;
00096 int PmtId;
00097 };
00098
00099 map<int,PmtProp> m_PmtPropMap;
00100
00101 double m_StartTime;
00102 double m_EndTime;
00103
00104 int m_Fix;
00105 int m_NStop;
00106 int m_FirstTrigSecond;
00107 int m_FirstTrigNanoSec;
00108 int m_LastTrigSecond;
00109 int m_LastTrigNanoSec;
00110 int m_startrun;
00111 int m_currentrun;
00112
00113 int m_site;
00114 int m_simFlag;
00115 double m_currentTime;
00116 double m_prevTrigTime;
00117 double m_lastFitTime;
00118 double m_fitPeriod;
00119 };
00120
00121 #endif // _ROLLINGGAIN_H_