00001
00002
00003
00004
00005
00006
00008
00009 #ifndef CALIBRATOR_H
00010 #define CALIBRATOR_H
00011
00012 #include "TObject.h"
00013 #include "TTimeStamp.h"
00014 #include "TH1D.h"
00015 #include <iostream>
00016 #include <vector>
00017 #include <map>
00018 #include <string>
00019
00020 #include "Geometry/Geometry.h"
00021 #include "RawData/DAQHeader.h"
00022 #include "RawData/RawDigit.h"
00023 #include "RecoBase/CellHit.h"
00024 #include "RecoBase/RecoHit.h"
00025
00026 using namespace rawdata;
00027 using namespace recobase;
00028
00029 namespace calib {
00030
00031 struct attlen {
00032 float a1, l1;
00033 float a2, l2;
00034 float a1sig, l1sig;
00035 float a2sig, l2sig;
00036 };
00037
00038 class Calibrator {
00039
00040 public:
00041 Calibrator();
00042
00043
00044 static Calibrator& Instance(TTimeStamp timestamp,
00045 rawdata::det_id_ detector,
00046 const geo::Geometry &geometry);
00047
00048
00049 TTimeStamp GetTimeStamp() const { return fCurrTimeStamp; }
00050 rawdata::det_id_ GetDetector () const { return fCurrDetector; }
00051
00052
00053 private:
00054
00055 void SetContext(TTimeStamp timestamp,
00056 rawdata::det_id_ detector,
00057 const geo::Geometry &geometry);
00058 static Calibrator* fInstance;
00059 TTimeStamp fCurrTimeStamp;
00060 rawdata::det_id_ fCurrDetector;
00061 const geo::Geometry* fCurrGeo;
00062
00063
00064
00065
00066 public:
00067
00068 void MakeCellHit (const RawDigit *rawdigit, CellHit *cellhit);
00069
00070 float GetPE (const RawDigit *rawdigit);
00071 float GetPECorrFactor (const RawDigit *rawdigit);
00072 float GetTNS (const RawDigit *rawdigit);
00073
00074
00075
00076
00077
00078
00079
00080 public:
00081
00082
00083
00084 void MakeRecoHit(const CellHit *cellhit, RecoHit *recohit, float w);
00085
00086 float GetT (const CellHit *cellhit, float dist_to_readout);
00087 float GetPEAtt (const CellHit *cellhit, float dist_to_readout);
00088 float GetMIPScale(const CellHit *cellhit);
00089 float GetGeVScale(const CellHit *cellhit);
00090
00091 float fPEACperMIP;
00092 float fPEACperMIPErr;
00093 std::vector<float> fMIPtoGeV;
00094 std::vector<float> fMIPtoGeVErr;
00095 std::map<int,float> fADCtoPE;
00096 std::map<int,float> fPEtoSigCor;
00097 std::map<int,attlen> fSCtoPEAC;
00098 std::vector<float> fFTDistNDX;
00099 std::vector<float> fFTDistNDY;
00100 std::vector<float> fFTDistFDX;
00101 std::vector<float> fFTDistFDY;
00102
00103 private:
00104 bool fLoadedFineTimeDistros;
00105
00106
00107
00108 void GetXYZD(const CellHit *cellhit, float w, double *xyzd);
00109
00110 bool LoadADCtoPE();
00111 bool LoadPEtoSigCor();
00112 bool LoadSCtoPEAC();
00113 bool LoadPEACtoMIP();
00114 bool LoadMIPtoGeV();
00115 bool LoadFineTimeDistros();
00116
00117 };
00118 }
00119 #endif
00120