00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef FLASHERIDTOOL_H
00011 #define FLASHERIDTOOL_H
00012
00013
00014
00015 #define FLASHERQVST 0
00016 #define FLASHERRINGVSCOLUMN 1
00017 #define NHISTOGRAMS 2
00018
00019 #define NBOARDS 21
00020 #define NCONNECTORS 17
00021
00022 #define MAXHISTS NBOARDS*NCONNECTORS*NHISTOGRAMS
00023
00024 #define MAXDT 4000
00025
00026 #include "GaudiAlg/GaudiTool.h"
00027 #include "Context/TimeStamp.h"
00028 #include "Context/Context.h"
00029 #include "Conventions/Detectors.h"
00030 #include "ProcessTools/IReadoutProcessor.h"
00031 #include <vector>
00032 #include <map>
00033 #include <string>
00034
00035 class IStatisticsSvc;
00036 class ICableSvc;
00037 class IPmtGeomInfoSvc;
00038 class TH1;
00039
00040 class FlasherIdTool : public GaudiTool,
00041 virtual public IReadoutProcessor
00042 {
00043
00044 public:
00045 FlasherIdTool(const std::string& type,
00046 const std::string& name,
00047 const IInterface* parent);
00048 virtual ~FlasherIdTool();
00049
00050
00051 virtual StatusCode initialize();
00052 virtual StatusCode finalize();
00053
00054
00055 virtual StatusCode process(const DayaBay::ReadoutHeader* readoutHeader);
00056
00057 private:
00058 TH1* getOrMakeHist(int run, const DayaBay::Detector& detector,
00059 int board, int connector, int histogram);
00060 std::string getPath(int run, const char* detectorName,
00061 int board, int connector,
00062 const char* histName);
00063 StatusCode initializeDistanceTable(const Context& context);
00064 unsigned int channelIndex(unsigned int board, unsigned int connector);
00065 double tdcOffset(int board, int connector);
00066 double transitTime(unsigned int board);
00067
00068
00069 double m_flasherThreshold;
00070 std::string m_detectorName;
00071
00072
00073 IStatisticsSvc* m_statsSvc;
00074 ICableSvc* m_cableSvc;
00075 IPmtGeomInfoSvc* m_pmtInfoSvc;
00076
00077 TimeStamp* m_firstTriggerTime;
00078 TimeStamp m_lastTriggerTime;
00079 std::map<int,TH1**> m_shortCuts;
00080
00081 DayaBay::Detector m_detector;
00082 unsigned int m_nEvents;
00083 unsigned int m_maxTdcCalibEvents;
00084 double m_boardTdcOffset[NBOARDS];
00085 unsigned int m_boardNTdcs[NBOARDS];
00086 double m_topCalibTdcOffset;
00087 unsigned int m_topCalibNTdcs;
00088 double m_bottomCalibTdcOffset;
00089 unsigned int m_bottomCalibNTdcs;
00090 unsigned int m_flashBoard[NBOARDS*NCONNECTORS];
00091 unsigned int m_flashConnector[NBOARDS*NCONNECTORS];
00092 unsigned int m_flashRing[NBOARDS*NCONNECTORS];
00093 unsigned int m_flashColumn[NBOARDS*NCONNECTORS];
00094 float m_flashDeltaAdc[NBOARDS*NCONNECTORS];
00095 double m_flashTdc[NBOARDS*NCONNECTORS];
00096 double m_flashLikelihood[NBOARDS*NCONNECTORS];
00097 double m_adcSum;
00098 double m_dt;
00099 unsigned int m_nChannels;
00100 double m_minDt;
00101 double m_logLikelihood[MAXDT];
00102 double m_distance[NBOARDS*NCONNECTORS][NBOARDS*NCONNECTORS];
00103 unsigned int m_ring[NBOARDS*NCONNECTORS];
00104 unsigned int m_column[NBOARDS*NCONNECTORS];
00105 };
00106
00107 #endif // FLASHERIDTOOL_H