/[PAMELA software]/PamVMC/include/PamVMCDigMgr.h
ViewVC logotype

Contents of /PamVMC/include/PamVMCDigMgr.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Mon Jul 13 12:27:06 2009 UTC (15 years, 5 months ago) by pam-rm2
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +10 -7 lines
File MIME type: text/plain
Some changes in PamVMCDigMgr class. Method SetDig became public to be used
by external digitizer

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

  ViewVC Help
Powered by ViewVC 1.1.23