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