00001 #ifndef HELPERS_H
00002 #define HELPERS_H
00003
00004 #include <fstream>
00005 #include <string>
00006 #include <map>
00007 #include <cmath>
00008
00009 #include "Rtypes.h"
00010 #include "Plex/PlexSEIdAltL.h"
00011 #include "Plex/PlexStripEndId.h"
00012 #include "CandDigit/CandDigitHandle.h"
00013 #include "RawData/RawChannelId.h"
00014 #include "REROOT_Classes/REROOT_FLSDigit.h"
00015
00016
00017 class NavKey;
00018
00019 namespace CalHelpers
00020 {
00021 Int_t GetPlane(const CandDigitHandle&);
00022 Int_t GetBestStrip(const CandDigitHandle&);
00023 Int_t GetBestEnd(const CandDigitHandle&);
00024 float ComputeSine(float p1, float s1, float p2, float s2,
00025 float scale_p= 5.8, float scale_s = 4.1);
00026 NavKey KeyFromPlane(const CandDigitHandle* cdh);
00027 NavKey KeyFromStrip(const CandDigitHandle* cdh);
00028 NavKey KeyFromEnd(const CandDigitHandle* cdh);
00029 NavKey KeyFromTime(const CandDigitHandle* cdh);
00030 NavKey KeyFromCrate(const CandDigitHandle* cdh);
00031 NavKey KeyFromVarc(const CandDigitHandle* cdh);
00032 NavKey KeyFromDigitTime(const CandDigitHandle* cdh);
00033
00034 class MCDigit{
00035 public:
00036 MCDigit();
00037 MCDigit(const PlexStripEndId pse, REROOT_FLSDigit flsdig);
00038 MCDigit(const MCDigit &mcd);
00039 ~MCDigit();
00040
00041
00042
00043
00044 const int GetMCPlane() const;
00045 const int GetMCExtr() const;
00046 const int GetMCCell() const;
00047 const float GetMCTPos() const;
00048 const float GetMCRAWPE() const;
00049 const float GetMCCorrPE() const;
00050 const float GetMCTDC() const;
00051 const int GetMCTubePixel() const;
00052 const float GetMCSignalPE() const;
00053 const float GetMCInitialTDC() const;
00054 const float GetMCAveDistTrue() const;
00055 const int GetMCHitBits() const;
00056 const int GetMCCellPos() const;
00057 const int GetMCPlanePos() const;
00058 const float GetMCSumETrue() const;
00059 private:
00060 int fMCPlane;
00061 int fMCExtr;
00062 int fMCCell;
00063 float fMCTPos;
00064 float fMCRAWPE;
00065 float fMCCorrPE;
00066 float fMCTDC;
00067 int fMCTubePixel;
00068 float fMCSignalPE;
00069 float fMCInitialTDC;
00070 float fMCAveDistTrue;
00071 int fMCHitBits;
00072 int fMCCellPos;
00073 int fMCPlanePos;
00074 float fMCSumETrue;
00075 };
00076
00077 class MCDigitMap{
00078 public:
00079 MCDigitMap();
00080 ~MCDigitMap();
00081
00082 void MakeMCDigitMap();
00083 std::map<const PlexStripEndId, MCDigit> *GetMCDigitMap();
00084
00085 private:
00086 std::map<const PlexStripEndId, MCDigit> fMCDigitMap;
00087 };
00088
00089
00090 inline const int MCDigit::GetMCPlane() const {return fMCPlane;}
00091 inline const int MCDigit::GetMCExtr() const {return fMCExtr;}
00092 inline const int MCDigit::GetMCCell() const {return fMCCell;}
00093 inline const float MCDigit::GetMCTPos() const {return fMCTPos;}
00094 inline const float MCDigit::GetMCRAWPE() const {return fMCRAWPE;}
00095 inline const float MCDigit::GetMCCorrPE() const {return fMCCorrPE;}
00096 inline const float MCDigit::GetMCTDC() const {return fMCTDC;}
00097 inline const int MCDigit::GetMCTubePixel() const {return fMCTubePixel;}
00098 inline const float MCDigit::GetMCSignalPE() const {return fMCSignalPE;}
00099 inline const float MCDigit::GetMCInitialTDC() const {return fMCInitialTDC;}
00100 inline const float MCDigit::GetMCAveDistTrue() const {return fMCAveDistTrue;}
00101 inline const int MCDigit::GetMCHitBits() const {return fMCHitBits;}
00102 inline const int MCDigit::GetMCCellPos() const {return fMCCellPos;}
00103 inline const int MCDigit::GetMCPlanePos() const {return fMCPlanePos;}
00104
00105
00106 inline const float MCDigit::GetMCSumETrue() const {return fMCSumETrue;}
00107
00108 inline std::map<const PlexStripEndId, MCDigit> *MCDigitMap::GetMCDigitMap()
00109 {return &fMCDigitMap;}
00110
00111
00112 }
00113
00114 inline Int_t CalHelpers::GetPlane(const CandDigitHandle& cdh)
00115 {
00116 return cdh.GetPlexSEIdAltL().GetPlane();
00117 }
00118
00119 inline Int_t CalHelpers::GetBestStrip(const CandDigitHandle& cdh)
00120 {
00121 return cdh.GetPlexSEIdAltL().GetBestSEId().GetStrip();
00122 }
00123
00124 inline Int_t CalHelpers::GetBestEnd(const CandDigitHandle& cdh)
00125 {
00126 return cdh.GetPlexSEIdAltL().GetBestSEId().GetEnd();
00127 }
00128
00129 inline float CalHelpers::ComputeSine(float p1, float s1, float p2, float s2,
00130 float scale_p, float scale_s)
00131 {
00132 float s= (s2-s1)*scale_s;
00133 float p= (p2-p1)*scale_p;
00134 return s/sqrt(s*s + p*p);
00135 }
00136
00137 namespace CalDetConstants
00138 {
00139
00140 static const UShort_t PLANECONST=60;
00141 static const UShort_t STRIPCONST=24;
00142 static const Float_t PLANEWIDTH=5.90;
00143 static const Float_t STRIPWIDTH=4.10;
00144 static const UShort_t KOVCONST=3;
00145 static const UShort_t TOFCONST=3;
00146 static const Float_t FARTIMECONVERT=1.5625;
00147
00148
00149
00150 static const RawChannelId kCerenkovChannel1(Detector::kCalDet,
00151 ElecType::kVA,
00152 0, 1, 5, 1, 2, 16);
00153 static const RawChannelId kCerenkovChannel2(Detector::kCalDet,
00154 ElecType::kVA,
00155 0, 2, 5, 1, 2, 16);
00156 static const RawChannelId kCerenkovChannel3(Detector::kCalDet,
00157 ElecType::kVA,
00158 0, 1, 5, 1, 1, 16);
00159 static const RawChannelId kTriggerPMTChannel(Detector::kCalDet,
00160 ElecType::kVA,
00161 0, 2, 5, 0, 1, 4);
00162 static const RawChannelId kTofADCChannel0(Detector::kCalDet,
00163 ElecType::kVA,
00164 0, 2, 5, 1, 0, 16);
00165 static const RawChannelId kTofADCChannel1(Detector::kCalDet,
00166 ElecType::kVA,
00167 0, 2, 5, 1, 1, 16);
00168 static const RawChannelId kTofADCChannel2(Detector::kCalDet,
00169 ElecType::kVA,
00170 0, 2, 5, 1, 2, 16);
00171 static const RawChannelId kTofTimeStampChannel(Detector::kCalDet,
00172 ElecType::kVA,
00173 0, 2, 6, 0, 0, 2);
00174
00175
00176 }
00177
00178 #endif //HELPERS_H