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