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(0, 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.root", "GDC0", "PMD_PED.root");
76 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMDGAINS.root", "GDC0", "PMDGAINS.root");
77 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMD_HOT.root", "GDC0", "PMD_HOT.root");
81 // The shuttle can read run type stored in the DAQ logbook.
82 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
83 // using GetRunType function.
85 shuttle->SetInputRunType("PHYSICS");
89 // The shuttle can read run parameters stored in the DAQ run logbook.
90 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
91 // using GetRunParameter function.
93 shuttle->AddInputRunParameter("totalEvents", "30000");
94 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
98 // The shuttle can query condition parameters valid from the current run from the OCDB
99 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
100 // using GetFromOCDB function.
102 TObjString obj("This is a condition parameter stored in OCDB");
103 AliCDBId id("PMD/Calib/Hot", 0, AliCDBRunRange::Infinity());
105 AliCDBEntry entry(&obj, id, &md);
107 shuttle->AddInputCDBEntry(&entry);
111 // Create the preprocessor that should be tested, it registers
112 // itself automatically to the shuttle
113 // AliPreprocessor* test = new AliTestPreprocessor(shuttle);
114 AliPMDPreprocessor* test = new AliPMDPreprocessor(shuttle);
116 // Test the preprocessor
120 // In the preprocessor AliShuttleInterface::Store should be called to put the final
121 // data to the CDB. To check if all went fine have a look at the files produced in
122 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
124 // Check the file which should have been created
125 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
126 ->Get("PMD/Calib/Hot", 7);
129 printf("The file is not there. Something went wrong.\n");
133 AliPMDHotData* output = dynamic_cast<AliPMDHotData*> (chkEntry->GetObject());
134 // If everything went fine, draw the result
139 TMap* CreateDCSAliasMap()
141 // Creates a DCS structure
142 // The structure is the following:
143 // TMap (key --> value)
144 // <DCSAlias> --> <valueList>
145 // <DCSAlias> is a string
146 // <valueList> is a TObjArray of AliDCSValue
147 // An AliDCSValue consists of timestamp and a value in form
148 // of a AliSimpleValue
150 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
151 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
153 TMap* aliasMap = new TMap;
154 aliasMap->SetOwner(1);
158 for(int nAlias=0;nAlias<6;nAlias++)
160 TObjArray* valueSet = new TObjArray;
161 valueSet->SetOwner(1);
163 TString aliasName="DCSAlias";
165 //printf("\n\n alias: %s\n\n",aliasName.Data());
167 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
169 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
170 //printf("%s\n",dcsVal->ToString().Data());
171 valueSet->Add(dcsVal);
173 aliasMap->Add(new TObjString(aliasName), valueSet);
179 TMap* ReadDCSAliasMap()
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()
187 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
188 ->Get("DET/DCS/Data", 0);
189 return dynamic_cast<TMap*> (entry->GetObject());
192 void WriteDCSAliasMap()
194 // This writes the output from CreateDCSAliasMap to a CDB file
196 TMap* dcsAliasMap = CreateDCSAliasMap();
198 AliCDBMetaData metaData;
199 metaData.SetBeamPeriod(0);
200 metaData.SetResponsible("Responsible person");
201 metaData.SetComment("Test object for TestPreprocessor.C");
203 AliCDBId id("DET/DCS/Data", 0, 0);
205 // look into AliTestShuttle's CDB main folder
207 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
208 ->Put(dcsAliasMap, id, &metaData);