| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

RollingGain.h

Go to the documentation of this file.
00001 /*****************************************
00002 
00003    Rolling gain calibration and dark noise monitor
00004    Details: DocDB 5323, 5361
00005 
00006    Author: Qing He 
00007    Date: Sep., 2010
00008 
00009    Oct. 7, 2010 
00010    Zhe Wang
00011        Update to accommodate all PMT detectors 
00012        Fit range fine tuning
00013        Add all fit and error status
00014    Oct. 12, 2010
00015        First stable version. Result for AD2 dry run is in DocDB 5527
00016    Jan. 26, 2011
00017        Update to work with DaqFormat
00018 
00019    Mar 08, 2011
00020    Qing He 
00021        Update to fit (Adc-preAdc) instead of fit Adc, preAdc separately. 
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/*PmtId*/,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;                   // Site determined by the first trigger 
00114   int m_simFlag;                // SimFlag determined by the first trigger
00115   double m_currentTime;         // Time of current trigger
00116   double m_prevTrigTime;        // Time of previous trigger
00117   double m_lastFitTime;         // Time when last fit occurs
00118   double m_fitPeriod;           // Fitting period in second
00119 };
00120 
00121 #endif  // _ROLLINGGAIN_H_
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:29:02 2011 for RollingGain by doxygen 1.4.7