]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/TOFPreprocessor.C
A few mods in handling the return value and the deletes
[u/mrichter/AliRoot.git] / TOF / TOFPreprocessor.C
CommitLineData
ccc28861 1/*
2$Id$
3*/
4
5// This class runs the test TOF preprocessor
6// It uses AliTestShuttle to simulate a full Shuttle process
7
8// The input data is created in the functions
9// CreateDCSAliasMap() creates input that would in the same way come from DCS
10// ReadDCSAliasMap() reads from a file
11// CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
12
13void TOFPreprocessor()
14{
15 gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
16
17 // initialize location of CDB
18 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
19
20 // create AliTestShuttle instance
21 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
22
23 // Generation of "fake" input DCS data
24 TMap* dcsAliasMap = CreateDCSAliasMap();
25
26 // now give the alias map to the shuttle
27 shuttle->SetDCSInput(dcsAliasMap);
28
29 // processing files. for the time being, the files are local.
5abdf772 30 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
31 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
ccc28861 32
33 // instantiation of the preprocessor
34 AliPreprocessor* pp = new AliTOFPreprocessor("TOF", shuttle);
35
36 // preprocessing
37 shuttle->Process();
38
39 // checking the file which should have been created
40 AliCDBEntry* entry = AliCDBManager::Instance()->Get("TOF/Calib/OnlineDelay", 0);
41 if (!entry)
42 {
43 printf("The file is not there. Something went wrong.\n");
44 return;
45 }
46
47 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (entry->GetObject());
48 // If everything went fine, draw the result
49 if (output)
50 output->Draw();
51
52}
53
54TMap* CreateDCSAliasMap()
55{
56 // Creates a DCS structure
57 // The structure is the following:
58 // TMap (key --> value)
59 // <DCSAlias> --> <valueList>
60 // <DCSAlias> is a string
61 // <valueList> is a TObjArray of AliDCSValue
62 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
63
64 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
65 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
66
67 TMap* aliasMap = new TMap;
68 aliasMap->SetOwner(1);
69
70 TRandom random;
71 TDatime *datime = new TDatime();
72 Int_t time = datime->GetTime();
73 Int_t date = datime->GetDate();
74 Int_t pid = gSystem->GetPid();
75 delete datime;
76 Int_t iseed = TMath::Abs(10000 * pid + time - date);
77
78 //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
79 //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
80 Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
81 tentFEEthr=0.5, tentFEEt=20, tentTemp=25, tentPress=900;
82 Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
83 sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
84
85 Float_t tent=0, sigma=0, thr=0;
86 Int_t NAliases=10442, NHV=90, NLV=576, NFEEthr=1152, NFEEt=7776, NT=1, NP=1;
87
88 for(int nAlias=0;nAlias<NAliases;nAlias++) {
89
90 TObjArray* valueSet = new TObjArray;
91 valueSet->SetOwner(1);
92
93 TString aliasName;
94 if (nAlias<NHV){
95 aliasName = "HVvpos";
96 aliasName += nAlias;
97 tent=tentHVv;
98 sigma=sigmaHVv;
99 // thr=thrHVv;
100 }
101 else if (nAlias<NHV*2){
102 aliasName = "HVvneg";
103 aliasName += nAlias-NHV;
104 tent=-tentHVv;
105 sigma=-sigmaHVv;
106 //thr=-thrHVv;
107 }
108 else if (nAlias<NHV*3){
109 aliasName = "HVcpos";
110 aliasName += nAlias-2*NHV;
111 tent=tentHVc;
112 sigma=sigmaHVc;
113 //thr=thrHVc;
114 }
115 else if (nAlias<NHV*4){
116 aliasName = "HVcneg";
117 aliasName += nAlias-3*NHV;
118 tent=-tentHVc;
119 sigma=-sigmaHVc;
120 //thr=-thrHVc;
121 }
122 else if (nAlias<NHV*4+NLV){
123 aliasName = "LVv";
124 aliasName += nAlias-4*NHV;
125 tent=tentLVv;
126 sigma=sigmaLVv;
127 //thr=thrLVv;
128 }
129 else if (nAlias<NHV*4+2*NLV){
130 aliasName = "LVc";
131 aliasName += nAlias-(4*NHV+NLV);
132 tent=tentLVc;
133 sigma=sigmaLVc;
134 //thr=thrLVc;
135 }
136 else if (nAlias<NHV*4+2*NLV+NFEEthr){
137 aliasName = "FEEthr";
138 aliasName += nAlias-(4*NHV+2*NLV);
139 tent=tentFEEthr;
140 sigma=sigmaFEEthr;
141 //thr=thrFEEthr;
142 }
143 else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt){
144 //cout << " nalias fee temp = " << nAlias << endl;
145 aliasName = "FEEt";
146 aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
147 //cout << " nalias fee temp name = " << aliasName << endl;
148 tent=tentFEEt;
149 sigma=sigmaFEEt;
150 //thr=thrFEEthr;
151 }
152 else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt+1){
153 aliasName = "Temperature";
154 tent=tentTemp;
155 sigma=sigmaTemp;
156 //thr=thrTemp;
157 }
158 else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt+2){
159 aliasName = "Pressure";
160 tent=tentPress;
161 sigma=sigmaPress;
162 //thr=thrPress;
163 }
164
165
166 // gauss generation of values
167 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
168 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
169 if (TMath::Abs(gaussvalue-tent)>sigma){
170 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
171 valueSet->Add(dcsVal);
172 }
173 }
174
175 aliasMap->Add(new TObjString(aliasName), valueSet);
176 }
177
178 return aliasMap;
179}
180
181TMap* ReadDCSAliasMap()
182{
183 // Open a file that contains DCS input data
184 // The CDB framework is used to open the file, this means the file is located
185 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
186 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
187 // An explanation of the structure can be found in CreateDCSAliasMap()
188
189 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
190 return dynamic_cast<TMap*> (entry->GetObject());
191}
192
193void WriteDCSAliasMap()
194{
195 // This writes the output from CreateDCSAliasMap to a CDB file
196
197 TMap* dcsAliasMap = CreateDCSAliasMap();
198
199 AliCDBMetaData metaData;
200 metaData.SetBeamPeriod(0);
201 metaData.SetResponsible("Chiara");
202 metaData.SetComment("Test object for TOFPreprocessor.C");
203
204 AliCDBId id("TOF/DCS/Data", 0, 0);
205
206 // initialize location of CDB
207 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
208
209 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
210}