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