1 |
nikolas |
1.1 |
#ifndef PAMVMCDIGMGR_H |
2 |
|
|
#define PAMVMCDIGMGR_H |
3 |
|
|
#include <iostream> |
4 |
|
|
|
5 |
|
|
#include <TSystem.h> |
6 |
|
|
#include <TMap.h> |
7 |
|
|
#include <TObjString.h> |
8 |
|
|
#include "PamVMCDigitizer.h" |
9 |
|
|
#include "PamVMCTrkDig.h" |
10 |
|
|
#include "PamVMCDigRunHeader.h" |
11 |
|
|
#include "PamVMCDigRunTrailer.h" |
12 |
|
|
#include "PamVMCTofDig.h" |
13 |
|
|
#include "PamVMCAcDig.h" |
14 |
|
|
#include "PamVMCCaloDig.h" |
15 |
|
|
#include "PamVMCS4Dig.h" |
16 |
|
|
#include "PamVMCNDDig.h" |
17 |
|
|
|
18 |
|
|
class PamVMCDigMgr: public TObject { |
19 |
|
|
|
20 |
|
|
private: |
21 |
|
|
|
22 |
|
|
static PamVMCDigMgr * fdig; |
23 |
|
|
TMap fdigmap; |
24 |
|
|
|
25 |
|
|
/* This method calls only from manager. It is owner of all |
26 |
|
|
digitizer objects */ |
27 |
|
|
void SetDIG(const char *name, PamVMCDigitizer *detDIG){ |
28 |
|
|
fdigmap.Add(new TObjString(name),detDIG); |
29 |
|
|
fdigmap.Print(); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
protected: |
34 |
|
|
PamVMCDigMgr(){ |
35 |
|
|
//detectors should be ordered.. First calibrations |
36 |
|
|
SetDIG("Tof", new PamVMCTofDig()); |
37 |
|
|
SetDIG("AC", new PamVMCAcDig()); |
38 |
|
|
SetDIG("CAST",new PamVMCCaloDig()); |
39 |
|
|
SetDIG("TSPA", new PamVMCTrkDig()); |
40 |
|
|
SetDIG("S4",new PamVMCS4Dig()); |
41 |
|
|
SetDIG("NDTI",new PamVMCNDDig()); |
42 |
pam-rm2 |
1.5 |
//SetDIG("RunHeader", new PamVMCDigRunHeader()); |
43 |
|
|
//SetDIG("RunTrailer", new PamVMCDigRunTrailer()); |
44 |
nikolas |
1.1 |
} |
45 |
|
|
|
46 |
|
|
public: |
47 |
|
|
|
48 |
|
|
~PamVMCDigMgr(){ fdigmap.DeleteAll(); } |
49 |
|
|
|
50 |
|
|
static PamVMCDigMgr * Instance(); |
51 |
|
|
|
52 |
|
|
PamVMCDigitizer * GetDIG(const char *name){ |
53 |
|
|
return (PamVMCDigitizer*)fdigmap(name); |
54 |
|
|
} |
55 |
|
|
|
56 |
pam-rm2 |
1.5 |
/* Setting pointer to random objects for all Digitizers */ |
57 |
nikolas |
1.1 |
/* All digitizers load calibrations and calibrate */ |
58 |
pam-rm2 |
1.5 |
void Initialize(TRandom* random){ |
59 |
nikolas |
1.1 |
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
60 |
pam-rm2 |
1.5 |
TObject *o; while( (o=(TObject *) n->Next())) { |
61 |
nikolas |
1.1 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->LoadCalib(); |
62 |
pam-rm2 |
1.5 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->SetRandom(random); |
63 |
nikolas |
1.1 |
} |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
/* This calls digitization for all detector */ |
67 |
|
|
void Digitize(Int_t EventNo, Int_t PrimaryPDG){ |
68 |
|
|
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
69 |
pam-rm2 |
1.5 |
TObject *o; while( (o=(TObject *) n->Next())) { |
70 |
nikolas |
1.1 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->Digitize(); |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
TObject* ob1 = fdigmap.FindObject("Tof"); |
74 |
|
|
if(ob1) ((PamVMCTofDig*)((TPair*)ob1)->Value())->DigitizeTOF(EventNo, PrimaryPDG); |
75 |
|
|
|
76 |
|
|
TObject* ob2 = fdigmap.FindObject("AC"); |
77 |
|
|
if(ob2) ((PamVMCAcDig*)((TPair*)ob2)->Value())->DigitizeAC(EventNo); |
78 |
|
|
|
79 |
|
|
/* +++From this moment all detctors a filled their buffers an we will form packet+++ */ |
80 |
|
|
|
81 |
|
|
TObject* b1 = fdigmap.FindObject("Tof"); |
82 |
|
|
if(b1) ((PamVMCTofDig*)((TPair*)b1)->Value())->WriteToBuff(); |
83 |
|
|
|
84 |
|
|
cout<<"TOF Written.."<<endl; |
85 |
|
|
|
86 |
|
|
TObject* b2 = fdigmap.FindObject("AC"); |
87 |
|
|
if(b2) ((PamVMCAcDig*)((TPair*)b2)->Value())->WriteToBuff(); |
88 |
|
|
|
89 |
|
|
cout<<"AC Written.."<<endl; |
90 |
|
|
|
91 |
|
|
TObject* b3 = fdigmap.FindObject("CAST"); |
92 |
|
|
if(b3) ((PamVMCCaloDig*)((TPair*)b3)->Value())->WriteToBuff(); |
93 |
|
|
|
94 |
|
|
cout<<"CALO Written.."<<endl; |
95 |
|
|
|
96 |
|
|
TObject* b4 = fdigmap.FindObject("TSPA"); |
97 |
|
|
if(b4) ((PamVMCTrkDig*)((TPair*)b4)->Value())->WriteToBuff(); |
98 |
|
|
|
99 |
|
|
cout<<"TRK Written.."<<endl; |
100 |
|
|
|
101 |
|
|
TObject* b5 = fdigmap.FindObject("S4"); |
102 |
|
|
if(b5) ((PamVMCS4Dig*)((TPair*)b5)->Value())->WriteToBuff(); |
103 |
|
|
|
104 |
|
|
cout<<"S4 Written.."<<endl; |
105 |
|
|
|
106 |
|
|
TObject* b6 = fdigmap.FindObject("NDTI"); |
107 |
|
|
if(b6) ((PamVMCNDDig*)((TPair*)b6)->Value())->WriteToBuff(); |
108 |
|
|
|
109 |
|
|
cout<<"ND Written.."<<endl; |
110 |
|
|
|
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
/* This written for RunTrailer. It should put his data |
114 |
|
|
to raw-file only once, when run is over */ |
115 |
|
|
void FinishRun(){ |
116 |
|
|
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
117 |
pam-rm2 |
1.5 |
TObject *o; while( (o=(TObject *) n->Next())) { |
118 |
nikolas |
1.1 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->FinishRun(); |
119 |
|
|
} |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
virtual void Print(const Option_t* = "") const { fdigmap.Print(); } |
123 |
|
|
|
124 |
|
|
void PrintCollections(){ |
125 |
|
|
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
126 |
pam-rm2 |
1.5 |
TObject *o; while( (o=(TObject *) n->Next())) { |
127 |
nikolas |
1.1 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->PrintCollections(); |
128 |
|
|
} |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
}; |
132 |
|
|
|
133 |
|
|
#endif |