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 <TRandom3.h> |
9 |
#include <TTree.h> |
10 |
#include <TMap.h> |
11 |
#include <TObjString.h> |
12 |
#include <TClonesArray.h> |
13 |
#include <TDatabasePDG.h> |
14 |
#include <TParticlePDG.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 |
TRandom3 *rnd; |
47 |
|
48 |
public: |
49 |
|
50 |
|
51 |
PamVMCDigitizer(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 |
/*This method calls from application*/ |
79 |
virtual void LoadCalib(){; }; |
80 |
|
81 |
/*This method looks into SD map and take the pointer to |
82 |
hit collection of specific detector... For TOF it overriden |
83 |
(we have here 6 hits collections */ |
84 |
virtual void Digitize()=0; |
85 |
|
86 |
/*This method calls by DigManager from it's digitize procedure. |
87 |
Method was created to force detectors push their data to main buffer |
88 |
according sequense of packet 0x10 organization*/ |
89 |
virtual void WriteToBuff() { fraw->CopyUShortToBuff(&fData); } |
90 |
|
91 |
/*This method calls from application after all evens. Designed for RunTrailer*/ |
92 |
virtual void FinishRun(){; }; |
93 |
|
94 |
void DigitizePSCU(UInt_t len, UChar_t type) |
95 |
{ fraw->DigitizePSCU(len, type, &fDataPSCU); } |
96 |
|
97 |
void AddPadding(){ fraw->AddPadding(fPadding,&fDataPadding); } |
98 |
|
99 |
void SetPadding(UInt_t pad){ fPadding = pad; } |
100 |
|
101 |
|
102 |
void ThrowCalFileUsage(const char* detname, const char* filename){ |
103 |
cout<<"Use calibrations for "<<detname<<" from file: "<<filename<<endl; |
104 |
} |
105 |
|
106 |
void ThrowCalFileWarning(const char* detname){ |
107 |
cout<<"!!!WARNING: No calibration for "<<detname<<" found... " |
108 |
<<" Calibration IMPOSSIBLE!!!"<<endl; |
109 |
} |
110 |
|
111 |
ClassDef(PamVMCDigitizer,2) |
112 |
}; |
113 |
|
114 |
|
115 |
#endif //PAMVMC_DIGITIZER_H |