]>
Commit | Line | Data |
---|---|---|
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 | ||
13 | extern TBenchmark *gBenchmark; | |
14 | void TOFPreprocessor(Char_t * RunType="PHYSICS") | |
15 | { | |
16 | gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); | |
17 | ||
18 | AliLog::SetClassDebugLevel("AliTOFPreprocessor",2); | |
19 | // initialize location of CDB | |
20 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); | |
21 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); | |
22 | ||
23 | // create AliTestShuttle instance | |
24 | Int_t nrun = 6; | |
25 | AliTestShuttle* shuttle = new AliTestShuttle(nrun, 30, 980); | |
26 | //setting run type to physiscs | |
27 | shuttle->SetInputRunType(RunType); | |
28 | shuttle->SetTimeCreated(20); | |
29 | shuttle->SetDCSQueryOffset(20); | |
30 | ||
31 | // Generation of "fake" input DCS data | |
32 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
33 | ||
34 | // now give the alias map to the shuttle | |
35 | shuttle->SetDCSInput(dcsAliasMap); | |
36 | ||
37 | // processing files. for the time being, the files are local. | |
38 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root"); | |
39 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root"); | |
40 | shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeLightMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEElight.20090616.102605.8000"); | |
41 | ||
42 | TString filename; | |
43 | TString LDCname; | |
44 | //char filename[100]; | |
45 | //char LDCname[5]; | |
46 | ||
47 | for (Int_t iLDC=0;iLDC<2;iLDC++){ | |
48 | filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2); | |
49 | LDCname.Form("LDC%i",iLDC*2); | |
50 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename); | |
51 | filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2); | |
52 | LDCname.Form("LDC%i",iLDC*2); | |
53 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename); | |
54 | } | |
55 | ||
56 | ||
57 | // instantiation of the preprocessor | |
58 | AliPreprocessor* pp = new AliTOFPreprocessor(shuttle); | |
59 | ||
60 | // preprocessing | |
61 | gBenchmark->Start("process"); | |
62 | shuttle->Process(); | |
63 | gBenchmark->Stop("process"); | |
64 | gBenchmark->Print("process"); | |
65 | ||
66 | // checking the file which should have been created | |
67 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnlineDelay", nrun); | |
68 | if (!chkEntry) | |
69 | { | |
70 | printf("The file is not there. Something went wrong.\n"); | |
71 | return; | |
72 | } | |
73 | ||
74 | AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject()); | |
75 | // If everything went fine, draw the result | |
76 | if (output) | |
77 | printf("Output found.\n"); | |
78 | // output->Draw(); | |
79 | ||
80 | } | |
81 | ||
82 | TMap* CreateDCSAliasMap() | |
83 | { | |
84 | // Creates a DCS structure | |
85 | // The structure is the following: | |
86 | // TMap (key --> value) | |
87 | // <DCSAlias> --> <valueList> | |
88 | // <DCSAlias> is a string | |
89 | // <valueList> is a TObjArray of AliDCSValue | |
90 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
91 | ||
92 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 | |
93 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
94 | ||
95 | TMap* aliasMap = new TMap; | |
96 | aliasMap->SetOwner(1); | |
97 | ||
98 | TRandom random; | |
99 | TDatime *datime = new TDatime(); | |
100 | Int_t time = datime->GetTime(); | |
101 | Int_t date = datime->GetDate(); | |
102 | Int_t pid = gSystem->GetPid(); | |
103 | delete datime; | |
104 | Int_t iseed = TMath::Abs(10000 * pid + time - date); | |
105 | ||
106 | //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5, | |
107 | //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000; | |
108 | //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5, | |
109 | // tentFEEthr=0.5, te result=0; | |
110 | //ntFEEt=20, tentTemp=25, tentPress=900; | |
111 | //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25, | |
112 | // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10; | |
113 | ||
114 | Float_t tentHVv=6500, tentHVi=80; | |
115 | Float_t sigmaHVv=10, sigmaHVi=10; | |
116 | ||
117 | Float_t tent=0, sigma=0, thr=0; | |
118 | // to have all the aliases, decomment the following line: | |
119 | Int_t NAliases=360, NHV=90; | |
120 | ||
121 | // if not all the aliases are there, use this: | |
122 | //Int_t NAliases=120, NHV=90; | |
123 | ||
124 | for(int nAlias=0;nAlias<NAliases;nAlias++) { | |
125 | ||
126 | TObjArray* valueSet = new TObjArray; | |
127 | valueSet->SetOwner(1); | |
128 | ||
129 | TString sindex; | |
130 | TString aliasName; | |
131 | if (nAlias<NHV){ | |
132 | aliasName = "tof_hv_vp_"; | |
133 | sindex.Form("%02i",nAlias); | |
134 | aliasName += sindex; | |
135 | //aliasName += nAlias; | |
136 | tent=tentHVv; | |
137 | sigma=sigmaHVv; | |
138 | // thr=thrHVv; | |
139 | } | |
140 | else if (nAlias<NHV*2){ | |
141 | // aliasName = "HVvneg"; | |
142 | //aliasName += nAlias-NHV; | |
143 | aliasName = "tof_hv_vn_"; | |
144 | sindex.Form("%02i",nAlias-NHV); | |
145 | aliasName += sindex; | |
146 | tent=-tentHVv; | |
147 | sigma=-sigmaHVv; | |
148 | //thr=-thrHVv; | |
149 | } | |
150 | else if (nAlias<NHV*3){ | |
151 | // aliasName = "HVcpos"; | |
152 | //aliasName += nAlias-2*NHV; | |
153 | aliasName = "tof_hv_ip_"; | |
154 | sindex.Form("%02i",nAlias-2*NHV); | |
155 | aliasName += sindex; | |
156 | tent=tentHVi; | |
157 | sigma=sigmaHVi; | |
158 | //thr=thrHVc; | |
159 | } | |
160 | else if (nAlias<NHV*4){ | |
161 | // aliasName = "HVcneg"; | |
162 | //aliasName += nAlias-3*NHV; | |
163 | aliasName = "tof_hv_in_"; | |
164 | sindex.Form("%02i",nAlias-3*NHV); | |
165 | aliasName += sindex; | |
166 | tent=-tentHVi; | |
167 | sigma=-sigmaHVi; | |
168 | //thr=-thrHVc; | |
169 | } | |
170 | // gauss generation of values | |
171 | for (int timeStamp=0;timeStamp<1000;timeStamp+=10){ | |
172 | //for (int timeStamp=0;timeStamp<1;timeStamp++){ | |
173 | Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma)); | |
174 | if (TMath::Abs(gaussvalue-tent)>sigma){ | |
175 | AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp); | |
176 | valueSet->Add(dcsVal); | |
177 | } | |
178 | } | |
179 | ||
180 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
181 | } | |
182 | ||
183 | return aliasMap; | |
184 | } | |
185 | ||
186 | TMap* ReadDCSAliasMap() | |
187 | { | |
188 | // Open a file that contains DCS input data | |
189 | // The CDB framework is used to open the file, this means the file is located | |
190 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
191 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
192 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
193 | ||
194 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0); | |
195 | return dynamic_cast<TMap*> (entry->GetObject()); | |
196 | } | |
197 | ||
198 | void WriteDCSAliasMap() | |
199 | { | |
200 | // This writes the output from CreateDCSAliasMap to a CDB file | |
201 | ||
202 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
203 | ||
204 | AliCDBMetaData metaData; | |
205 | metaData.SetBeamPeriod(0); | |
206 | metaData.SetResponsible("Chiara"); | |
207 | metaData.SetComment("Test object for TOFPreprocessor.C"); | |
208 | ||
209 | AliCDBId id("TOF/DCS/Data", 0, 0); | |
210 | ||
211 | // initialize location of CDB | |
212 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); | |
213 | ||
214 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); | |
215 | } |