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,
10 // that can be accessed by the shuttle
12 void TestPreprocessor()
15 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
17 // create AliTestShuttle instance
18 // The parameters are run, startTime, endTime
19 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
22 printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
24 // TODO if needed, change location of OCDB and Reference test folders
25 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB
28 AliTestShuttle::SetMainCDB("local://TestCDB");
29 AliTestShuttle::SetMainRefStorage("local://TestReference");
31 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
32 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
37 // The shuttle can read DCS data, if the preprocessor should be
38 // tested to process DCS data,
39 // some fake data has to be created.
41 // The "fake" input data can be taken using either (a) or (b):
42 // (a) data from a file: Use ReadDCSAliasMap()
43 // the format of the file is explained in ReadDCSAliasMap()
44 // To use it uncomment the following line:
46 // TMap* dcsAliasMap = ReadDCSAliasMap();
48 // (b) generated in this macro: Use CreateDCSAliasMap() and
50 // To use it uncomment the following line:
53 TMap* dcsAliasMap = CreateDCSAliasMap();
55 // now give the alias map to the shuttle
57 shuttle->SetDCSInput(dcsAliasMap);
61 // The shuttle can also process files that originate from DCS, DAQ and HLT.
62 // To test it, we provide some local files and locations where these would
64 // the online machinery would be there.
65 // In real life this functions would be produces by the sub-detectors
66 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
68 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
69 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
70 // In this example we add a file originating from the GDC with the id PEDESTALS
71 // Three files originating from different LDCs but with the same id are also added
72 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
73 // the "online" naming convention ALICE-INT-2003-039.
75 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMD_PED", "GDC0", "PMD_PED.root");
76 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMDGAINS", "GDC0", "xy.root");
80 // The shuttle can read run type stored in the DAQ logbook.
81 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
82 // using GetRunType function.
84 shuttle->SetInputRunType("PEDESTAL_RUN");
88 // The shuttle can read run parameters stored in the DAQ run logbook.
89 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
90 // using GetRunParameter function.
92 shuttle->AddInputRunParameter("totalEvents", "30000");
93 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
97 // The shuttle can query condition parameters valid from the current run from the OCDB
98 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
99 // using GetFromOCDB function.
101 TObjString obj("This is a condition parameter stored in OCDB");
102 AliCDBId id("TPC/Calib/Data", 0, AliCDBRunRange::Infinity());
104 AliCDBEntry entry(&obj, id, &md);
106 shuttle->AddInputCDBEntry(&entry);
110 // Create the preprocessor that should be tested, it registers
111 // itself automatically to the shuttle
112 // AliPreprocessor* test = new AliTestPreprocessor(shuttle);
113 AliPMDPreprocessor* test = new AliPMDPreprocessor(shuttle);
115 // Test the preprocessor
119 // In the preprocessor AliShuttleInterface::Store should be called to put the final
120 // data to the CDB. To check if all went fine have a look at the files produced in
121 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
123 // Check the file which should have been created
124 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
125 ->Get("PMD/Calib/Ped", 7);
128 printf("The file is not there. Something went wrong.\n");
132 AliPMDPedestal* output = dynamic_cast<AliPMDPedestal*> (chkEntry->GetObject());
133 // If everything went fine, draw the result
138 TMap* CreateDCSAliasMap()
140 // Creates a DCS structure
141 // The structure is the following:
142 // TMap (key --> value)
143 // <DCSAlias> --> <valueList>
144 // <DCSAlias> is a string
145 // <valueList> is a TObjArray of AliDCSValue
146 // An AliDCSValue consists of timestamp and a value in form
147 // of a AliSimpleValue
149 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
150 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
152 TMap* aliasMap = new TMap;
153 aliasMap->SetOwner(1);
157 for(int nAlias=0;nAlias<6;nAlias++)
159 TObjArray* valueSet = new TObjArray;
160 valueSet->SetOwner(1);
162 TString aliasName="DCSAlias";
164 //printf("\n\n alias: %s\n\n",aliasName.Data());
166 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
168 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
169 //printf("%s\n",dcsVal->ToString().Data());
170 valueSet->Add(dcsVal);
172 aliasMap->Add(new TObjString(aliasName), valueSet);
178 TMap* ReadDCSAliasMap()
180 // Open a file that contains DCS input data
181 // The CDB framework is used to open the file, this means the file is located
182 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
183 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
184 // An explanation of the structure can be found in CreateDCSAliasMap()
186 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
187 ->Get("DET/DCS/Data", 0);
188 return dynamic_cast<TMap*> (entry->GetObject());
191 void WriteDCSAliasMap()
193 // This writes the output from CreateDCSAliasMap to a CDB file
195 TMap* dcsAliasMap = CreateDCSAliasMap();
197 AliCDBMetaData metaData;
198 metaData.SetBeamPeriod(0);
199 metaData.SetResponsible("Responsible person");
200 metaData.SetComment("Test object for TestPreprocessor.C");
202 AliCDBId id("DET/DCS/Data", 0, 0);
204 // look into AliTestShuttle's CDB main folder
206 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
207 ->Put(dcsAliasMap, id, &metaData);