5 // This class runs the test TOF preprocessor
6 // It uses AliTestShuttle to simulate a full Shuttle process
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
13 void TOFPreprocessor()
15 gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
17 // initialize location of CDB
18 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
20 // create AliTestShuttle instance
21 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
23 // Generation of "fake" input DCS data
24 TMap* dcsAliasMap = CreateDCSAliasMap();
26 // now give the alias map to the shuttle
27 shuttle->SetDCSInput(dcsAliasMap);
29 // processing files. for the time being, the files are local.
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");
33 // instantiation of the preprocessor
34 AliPreprocessor* pp = new AliTOFPreprocessor("TOF", shuttle);
39 // checking the file which should have been created
40 AliCDBEntry* entry = AliCDBManager::Instance()->Get("TOF/Calib/OnlineDelay", 0);
43 printf("The file is not there. Something went wrong.\n");
47 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (entry->GetObject());
48 // If everything went fine, draw the result
54 TMap* CreateDCSAliasMap()
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
64 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
65 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
67 TMap* aliasMap = new TMap;
68 aliasMap->SetOwner(1);
71 TDatime *datime = new TDatime();
72 Int_t time = datime->GetTime();
73 Int_t date = datime->GetDate();
74 Int_t pid = gSystem->GetPid();
76 Int_t iseed = TMath::Abs(10000 * pid + time - date);
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;
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;
88 for(int nAlias=0;nAlias<NAliases;nAlias++) {
90 TObjArray* valueSet = new TObjArray;
91 valueSet->SetOwner(1);
101 else if (nAlias<NHV*2){
102 aliasName = "HVvneg";
103 aliasName += nAlias-NHV;
108 else if (nAlias<NHV*3){
109 aliasName = "HVcpos";
110 aliasName += nAlias-2*NHV;
115 else if (nAlias<NHV*4){
116 aliasName = "HVcneg";
117 aliasName += nAlias-3*NHV;
122 else if (nAlias<NHV*4+NLV){
124 aliasName += nAlias-4*NHV;
129 else if (nAlias<NHV*4+2*NLV){
131 aliasName += nAlias-(4*NHV+NLV);
136 else if (nAlias<NHV*4+2*NLV+NFEEthr){
137 aliasName = "FEEthr";
138 aliasName += nAlias-(4*NHV+2*NLV);
143 else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt){
144 //cout << " nalias fee temp = " << nAlias << endl;
146 aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
147 //cout << " nalias fee temp name = " << aliasName << endl;
152 else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt+1){
153 aliasName = "Temperature";
158 else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt+2){
159 aliasName = "Pressure";
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);
175 aliasMap->Add(new TObjString(aliasName), valueSet);
181 TMap* ReadDCSAliasMap()
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()
189 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
190 return dynamic_cast<TMap*> (entry->GetObject());
193 void WriteDCSAliasMap()
195 // This writes the output from CreateDCSAliasMap to a CDB file
197 TMap* dcsAliasMap = CreateDCSAliasMap();
199 AliCDBMetaData metaData;
200 metaData.SetBeamPeriod(0);
201 metaData.SetResponsible("Chiara");
202 metaData.SetComment("Test object for TOFPreprocessor.C");
204 AliCDBId id("TOF/DCS/Data", 0, 0);
206 // initialize location of CDB
207 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
209 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);