1 |
#ifndef PAMVMC_DIGITIZER_H |
2 |
#define PAMVMC_DIGITIZER_H |
3 |
#include <iostream> |
4 |
#include <fstream> |
5 |
#include <TObject.h> |
6 |
#include <TString.h> |
7 |
#include <TFile.h> |
8 |
#include <TTree.h> |
9 |
#include <TMap.h> |
10 |
#include <TObjString.h> |
11 |
#include <TClonesArray.h> |
12 |
#include <TDatabasePDG.h> |
13 |
#include <TParticlePDG.h> |
14 |
#include <TRandom3.h> |
15 |
#include "PamVMCSQLMgr.h" |
16 |
#include "PamVMCRawMgr.h" |
17 |
#include "PamVMCDetectorHit.h" |
18 |
|
19 |
|
20 |
using namespace std; |
21 |
|
22 |
class PamVMCDigitizer : public TObject { |
23 |
|
24 |
TString fdname; |
25 |
|
26 |
protected: |
27 |
|
28 |
PamVMCSQLMgr * fsql; //pointer to SQL Mgr |
29 |
PamVMCRawMgr * fraw; //pointer to RAW Mgr |
30 |
|
31 |
ifstream fcfile; //binary file with calib data if any |
32 |
stringstream fquery; //query ty mysql |
33 |
Int_t fdberr; //error index (check db) |
34 |
TString fpath; //path to default calibration datafiles; |
35 |
TFile * fcrfile; //pointer to file with calibration |
36 |
|
37 |
TMap fhitscolmap; //vector of hit collections (TClonesArray), given by SD to digitize |
38 |
|
39 |
|
40 |
USBuffer fData; //detector's data vector |
41 |
UCBuffer fDataPSCU; //detector's PSCU data |
42 |
|
43 |
UInt_t fPadding; //data padding |
44 |
UCBuffer fDataPadding; //detector's Padding data |
45 |
|
46 |
TRandom * frandom; //pointer to random object. Warning, Class is not owner of this object |
47 |
|
48 |
public: |
49 |
|
50 |
|
51 |
PamVMCDigitizer(const char *dname="dummy"): fdname(dname) |
52 |
{ |
53 |
fsql = PamVMCSQLMgr::Instance(); |
54 |
fraw = PamVMCRawMgr::Instance(); |
55 |
fdberr = fPadding = 0; |
56 |
fpath = fsql->GetDataPath(); |
57 |
fquery.str(""); |
58 |
} |
59 |
|
60 |
|
61 |
virtual ~PamVMCDigitizer() { |
62 |
delete fcrfile; |
63 |
delete fraw; |
64 |
delete fsql; |
65 |
fhitscolmap.Clear("C"); |
66 |
} |
67 |
|
68 |
/*This method calls from SD to pass pointers to it's collection(s)*/ |
69 |
void RegisterCollections(const char* name, TClonesArray * hitcoll){ |
70 |
fhitscolmap.Add(new TObjString(name), hitcoll); |
71 |
} |
72 |
|
73 |
virtual void PrintCollections(){ |
74 |
cout<<"HitCollections Map for: "<<fdname<<endl; |
75 |
fhitscolmap.Print(); |
76 |
} |
77 |
|
78 |
/*Setting a pointer to random number if needed */ |
79 |
virtual void SetRandom(TRandom* random){ |
80 |
frandom = random; |
81 |
} |
82 |
|
83 |
/*This method calls from application*/ |
84 |
virtual void LoadCalib(){; }; |
85 |
|
86 |
/*This method looks into SD map and take the pointer to |
87 |
hit collection of specific detector... For TOF it overriden |
88 |
(we have here 6 hits collections */ |
89 |
virtual void Digitize()=0; |
90 |
|
91 |
/*This method calls by DigManager from it's digitize procedure. |
92 |
Method was created to force detectors push their data to main buffer |
93 |
according sequense of packet 0x10 organization*/ |
94 |
virtual void WriteToBuff() { fraw->CopyUShortToBuff(&fData); } |
95 |
|
96 |
/*This method calls from application after all evens. Designed for RunTrailer*/ |
97 |
virtual void FinishRun(){; }; |
98 |
|
99 |
void DigitizePSCU(UInt_t len, UChar_t type) |
100 |
{ fraw->DigitizePSCU(len, type, &fDataPSCU); } |
101 |
|
102 |
void AddPadding(){ fraw->AddPadding(fPadding,&fDataPadding); } |
103 |
|
104 |
void SetPadding(UInt_t pad){ fPadding = pad; } |
105 |
|
106 |
|
107 |
void ThrowCalFileUsage(const char* detname, const char* filename){ |
108 |
cout<<"Use calibrations for "<<detname<<" from file: "<<filename<<endl; |
109 |
} |
110 |
|
111 |
void ThrowCalFileWarning(const char* detname){ |
112 |
cout<<"!!!WARNING: No calibration for "<<detname<<" found... " |
113 |
<<" Calibration IMPOSSIBLE!!!"<<endl; |
114 |
} |
115 |
|
116 |
ClassDef(PamVMCDigitizer,1) |
117 |
}; |
118 |
|
119 |
|
120 |
#endif //PAMVMC_DIGITIZER_H |