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 extern TBenchmark *gBenchmark;
14 void TOFPreprocessorFDR()
16 gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
18 AliLog::SetClassDebugLevel("AliTOFPreprocessorFDR",1);
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");
23 // create AliTestShuttle instance
24 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
26 // Generation of "fake" input DCS data
27 TMap* dcsAliasMap = CreateDCSAliasMap();
29 // now give the alias map to the shuttle
30 shuttle->SetDCSInput(dcsAliasMap);
32 // instantiation of the preprocessor
33 AliPreprocessor* pp = new AliTOFPreprocessorFDR(shuttle);
36 gBenchmark->Start("process");
38 gBenchmark->Stop("process");
39 gBenchmark->Print("process");
41 // checking the file which should have been created
42 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/DCSData", 0);
45 printf("The file is not there. Something went wrong.\n");
49 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
50 // If everything went fine, draw the result
52 printf("Output found.\n");
57 TMap* CreateDCSAliasMap()
59 // Creates a DCS structure
60 // The structure is the following:
61 // TMap (key --> value)
62 // <DCSAlias> --> <valueList>
63 // <DCSAlias> is a string
64 // <valueList> is a TObjArray of AliDCSValue
65 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
67 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
68 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
70 TMap* aliasMap = new TMap;
71 aliasMap->SetOwner(1);
74 TDatime *datime = new TDatime();
75 Int_t time = datime->GetTime();
76 Int_t date = datime->GetDate();
77 Int_t pid = gSystem->GetPid();
79 Int_t iseed = TMath::Abs(10000 * pid + time - date);
81 Float_t tentLVv33=3.3, tentLVv48=48, tentLVi33=100, tentLVi48=10;
82 Float_t sigmaLVv33=0.1, sigmaLVv48=1, sigmaLVi33=10, sigmaLVi48=2;
84 Float_t tent=0, sigma=0, thr=0;
87 for(int nAlias=0;nAlias<NAliases;nAlias++) {
89 TObjArray* valueSet = new TObjArray;
90 valueSet->SetOwner(1);
95 aliasName = "tof_lv_i48_02";
100 aliasName = "tof_lv_v48_02";
105 aliasName = "tof_lv_i33_02";
110 aliasName = "tof_lv_v33_02";
115 // gauss generation of values
116 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
117 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
118 if (TMath::Abs(gaussvalue-tent)>sigma){
119 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
120 valueSet->Add(dcsVal);
124 aliasMap->Add(new TObjString(aliasName), valueSet);
130 TMap* ReadDCSAliasMap()
132 // Open a file that contains DCS input data
133 // The CDB framework is used to open the file, this means the file is located
134 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
135 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
136 // An explanation of the structure can be found in CreateDCSAliasMap()
138 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
139 return dynamic_cast<TMap*> (entry->GetObject());
142 void WriteDCSAliasMap()
144 // This writes the output from CreateDCSAliasMap to a CDB file
146 TMap* dcsAliasMap = CreateDCSAliasMap();
148 AliCDBMetaData metaData;
149 metaData.SetBeamPeriod(0);
150 metaData.SetResponsible("Chiara");
151 metaData.SetComment("Test object for TOFPreprocessorDCS.C");
153 AliCDBId id("TOF/DCS/Data", 0, 0);
155 // initialize location of CDB
156 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
158 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);