3 // This class runs the test preprocessor
4 // It uses AliTestShuttle to simulate a full Shuttle process
6 // The input data is created in the functions
7 // CreateDCSAliasMap() creates input that would in the same way come from DCS
8 // ReadDCSAliasMap() reads from a file
9 // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
11 void TestPreprocessor()
14 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
16 // create AliTestShuttle instance
17 // The parameters are run, startTime, endTime
18 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
21 printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
23 // TODO if needed, change location of OCDB and Reference test folders
24 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
25 AliTestShuttle::SetMainCDB("local://TestCDB");
26 AliTestShuttle::SetMainRefStorage("local://TestReference");
28 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
29 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
34 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
35 // some fake data has to be created.
37 // The "fake" input data can be taken using either (a) or (b):
38 // (a) data from a file: Use ReadDCSAliasMap()
39 // the format of the file is explained in ReadDCSAliasMap()
40 // To use it uncomment the following line:
42 //TMap* dcsAliasMap = ReadDCSAliasMap();
44 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
45 // To use it uncomment the following line:
47 TMap* dcsAliasMap = CreateDCSAliasMap();
49 // now give the alias map to the shuttle
50 shuttle->SetDCSInput(dcsAliasMap);
54 // The shuttle can also process files that originate from DCS, DAQ and HLT.
55 // To test it, we provide some local files and locations where these would be found when
56 // the online machinery would be there.
57 // In real life this functions would be produces by the sub-detectors
58 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
60 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
61 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
62 // In this example we add a file originating from the GDC with the id PEDESTALS
63 // Three files originating from different LDCs but with the same id are also added
64 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
65 // the "online" naming convention ALICE-INT-2003-039.
66 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMD_PED", "GDC0", "PMD_PED.root");
67 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMDGAINS", "GDC0", "xy.root");
71 // The shuttle can read run type stored in the DAQ logbook.
72 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
73 // using GetRunType function.
74 shuttle->SetInputRunType("PEDESTAL_RUN");
78 // The shuttle can read run parameters stored in the DAQ run logbook.
79 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
80 // using GetRunParameter function.
81 shuttle->AddInputRunParameter("totalEvents", "30000");
82 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
86 // The shuttle can query condition parameters valid from the current run from the OCDB
87 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
88 // using GetFromOCDB function.
90 TObjString obj("This is a condition parameter stored in OCDB");
91 AliCDBId id("TPC/Calib/Data", 0, AliCDBRunRange::Infinity());
93 AliCDBEntry entry(&obj, id, &md);
95 shuttle->AddInputCDBEntry(&entry);
99 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
100 // AliPreprocessor* test = new AliTestPreprocessor(shuttle);
101 AliPMDPreprocessor* test = new AliPMDPreprocessor(shuttle);
103 // Test the preprocessor
107 // In the preprocessor AliShuttleInterface::Store should be called to put the final
108 // data to the CDB. To check if all went fine have a look at the files produced in
109 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
111 // Check the file which should have been created
112 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
113 ->Get("PMD/Calib/Ped", 7);
116 printf("The file is not there. Something went wrong.\n");
120 AliPMDPedestal* output = dynamic_cast<AliPMDPedestal*> (chkEntry->GetObject());
121 // If everything went fine, draw the result
126 TMap* CreateDCSAliasMap()
128 // Creates a DCS structure
129 // The structure is the following:
130 // TMap (key --> value)
131 // <DCSAlias> --> <valueList>
132 // <DCSAlias> is a string
133 // <valueList> is a TObjArray of AliDCSValue
134 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
136 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
137 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
139 TMap* aliasMap = new TMap;
140 aliasMap->SetOwner(1);
144 for(int nAlias=0;nAlias<6;nAlias++)
146 TObjArray* valueSet = new TObjArray;
147 valueSet->SetOwner(1);
149 TString aliasName="DCSAlias";
151 //printf("\n\n alias: %s\n\n",aliasName.Data());
153 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
155 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
156 //printf("%s\n",dcsVal->ToString().Data());
157 valueSet->Add(dcsVal);
159 aliasMap->Add(new TObjString(aliasName), valueSet);
165 TMap* ReadDCSAliasMap()
167 // Open a file that contains DCS input data
168 // The CDB framework is used to open the file, this means the file is located
169 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
170 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
171 // An explanation of the structure can be found in CreateDCSAliasMap()
173 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
174 ->Get("DET/DCS/Data", 0);
175 return dynamic_cast<TMap*> (entry->GetObject());
178 void WriteDCSAliasMap()
180 // This writes the output from CreateDCSAliasMap to a CDB file
182 TMap* dcsAliasMap = CreateDCSAliasMap();
184 AliCDBMetaData metaData;
185 metaData.SetBeamPeriod(0);
186 metaData.SetResponsible("Responsible person");
187 metaData.SetComment("Test object for TestPreprocessor.C");
189 AliCDBId id("DET/DCS/Data", 0, 0);
191 // look into AliTestShuttle's CDB main folder
193 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
194 ->Put(dcsAliasMap, id, &metaData);