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

Annotation of /PamVMC_update/include/PamVMCDigMgr.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Oct 15 15:52:29 2013 UTC (11 years, 1 month ago) by formato
Branch: MAIN, rel
CVS Tags: reltag, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
PamVMC update

1 formato 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 "PamVMCTofDig.h"
11     #include "PamVMCAcDig.h"
12     #include "PamVMCCaloDig.h"
13     #include "PamVMCS4Dig.h"
14     #include "PamVMCNDDig.h"
15    
16    
17     class PamVMCDigMgr: public TObject {
18    
19     private:
20    
21     static PamVMCDigMgr * fdig;
22     TMap fdigmap;
23    
24    
25     protected:
26     PamVMCDigMgr(){
27     //detectors should be ordered.. First calibrations
28     SetDIG("Tof", new PamVMCTofDig());
29     SetDIG("AC", new PamVMCAcDig());
30     SetDIG("CAST",new PamVMCCaloDig());
31     SetDIG("TSPA", new PamVMCTrkDig());
32     SetDIG("S4",new PamVMCS4Dig());
33     SetDIG("NDTI",new PamVMCNDDig());
34     }
35    
36     PamVMCDigMgr(TString ext){
37     cout<<"External PamVMCDiG constructor called "<<ext<<endl;
38     }
39    
40    
41     public:
42    
43     ~PamVMCDigMgr(){ fdigmap.DeleteAll(); }
44    
45     static PamVMCDigMgr * Instance();
46     static PamVMCDigMgr * Instance_ext();
47    
48     PamVMCDigitizer * GetDIG(const char *name){
49     return (PamVMCDigitizer*)fdigmap(name);
50     }
51    
52     /* Setting pointer to random objects for all Digitizers */
53     /* All digitizers load calibrations and calibrate */
54     void Initialize(TRandom3* random){
55     TMapIter *n= (TMapIter *)fdigmap.MakeIterator();
56     TObject *o; while( (o=(TObject *) n->Next())) {
57     ((PamVMCDigitizer *)fdigmap.GetValue(o))->LoadCalib();
58     if(!random->GetSeed()){
59     cout<<"DigMgr: creating a random object, wait 1.5 s"<<endl;
60     gSystem->Sleep(1500);
61     }
62     ((PamVMCDigitizer *)fdigmap.GetValue(o))->SetRandom(random);
63     }
64     delete n;
65     }
66    
67     /* This method calls only from manager. It is owner of all
68     digitizer objects */
69     void SetDIG(const char *name, PamVMCDigitizer *detDIG){ fdigmap.Add(new TObjString(name),detDIG);
70     fdigmap.Print();
71     }
72    
73    
74     /*This method set up a random object for specific detector digitizer*/
75     void SetRandom(const char *name, TRandom3* random){
76     PamVMCDigitizer * dig = GetDIG(name);
77     if(dig) dig->SetRandom(random);
78     }
79    
80     /* This calls digitization for all detector */
81     void Digitize(Int_t EventNo, Int_t PrimaryPDG){
82     TMapIter *n= (TMapIter *)fdigmap.MakeIterator();
83     TObject *o; while( (o=(TObject *) n->Next())) {
84     ((PamVMCDigitizer *)fdigmap.GetValue(o))->Digitize();
85     }
86     delete n;
87    
88     TObject* ob1 = fdigmap.FindObject("Tof");
89     if(ob1) ((PamVMCTofDig*)((TPair*)ob1)->Value())->DigitizeTOF(EventNo, PrimaryPDG);
90    
91     TObject* ob2 = fdigmap.FindObject("AC");
92     if(ob2) ((PamVMCAcDig*)((TPair*)ob2)->Value())->DigitizeAC(EventNo);
93    
94     /* +++From this moment all detctors a filled their buffers an we will form packet+++ */
95    
96     TObject* b1 = fdigmap.FindObject("Tof");
97     if(b1) ((PamVMCTofDig*)((TPair*)b1)->Value())->WriteToBuff();
98    
99     #ifdef DIG_DEBUG
100     cout<<"TOF Written.."<<endl;
101     #endif
102    
103     TObject* b2 = fdigmap.FindObject("AC");
104     if(b2) ((PamVMCAcDig*)((TPair*)b2)->Value())->WriteToBuff();
105    
106     #ifdef DIG_DEBUG
107     cout<<"AC Written.."<<endl;
108     #endif
109    
110     TObject* b3 = fdigmap.FindObject("CAST");
111     if(b3) ((PamVMCCaloDig*)((TPair*)b3)->Value())->WriteToBuff();
112    
113     #ifdef DIG_DEBUG
114     cout<<"CALO Written.."<<endl;
115     #endif
116    
117     TObject* b4 = fdigmap.FindObject("TSPA");
118     if(b4) ((PamVMCTrkDig*)((TPair*)b4)->Value())->WriteToBuff();
119     #ifdef DIG_DEBUG
120     cout<<"TRK Written.."<<endl;
121     #endif
122    
123     TObject* b5 = fdigmap.FindObject("S4");
124     if(b5) ((PamVMCS4Dig*)((TPair*)b5)->Value())->WriteToBuff();
125    
126     #ifdef DIG_DEBUG
127     cout<<"S4 Written.."<<endl;
128     #endif
129    
130     TObject* b6 = fdigmap.FindObject("NDTI");
131     if(b6) ((PamVMCNDDig*)((TPair*)b6)->Value())->WriteToBuff();
132     #ifdef DIG_DEBUG
133     cout<<"ND Written.."<<endl;
134     #endif
135     }
136    
137    
138     virtual void Print(const Option_t* = "") const { fdigmap.Print(); }
139    
140     void PrintCollections(){
141     TMapIter *n= (TMapIter *)fdigmap.MakeIterator();
142     TObject *o; while( (o=(TObject *) n->Next())) {
143     ((PamVMCDigitizer *)fdigmap.GetValue(o))->PrintCollections();
144     }
145     delete n;
146     }
147    
148     };
149    
150     #endif

  ViewVC Help
Powered by ViewVC 1.1.23