2 // This macro runs the GRP test preprocessor
3 // It uses AliTestShuttle to simulate a full Shuttle process
5 // The input data is created in the functions
6 // CreateDCSAliasMap() creates input that would in the same way come from DCS
7 // ReadDCSAliasMap() reads from a file
8 // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
14 void TestGRPPreprocessor()
17 // gSystem->Load("libSTEER.so"); // needed for AliGRPPreprocessor
18 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
20 // create AliTestShuttle instance
21 // The parameters are run, startTime, endTime
23 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10);
25 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
26 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
27 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
29 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
30 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
33 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
34 // some fake data has to be created.
36 // The "fake" input data can be taken using either (a) or (b):
37 // (a) data from a file: Use ReadDCSAliasMap()
38 // the format of the file is explained in ReadDCSAliasMap()
39 // To use it uncomment the following line:
41 //TMap* dcsAliasMap = ReadDCSAliasMap();
43 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
44 // To use it uncomment the following line:
46 TMap* dcsAliasMap = CreateDCSAliasMap();
48 // now give the alias map to the shuttle
49 shuttle->SetDCSInput(dcsAliasMap);
51 // The shuttle can also process files that originate from DCS, DAQ and HLT.
52 // To test it, we provide some local files and locations where these would be found when
53 // the online machinery would be there.
54 // In real life this functions would be produces by the sub-detectors
55 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
57 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
58 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
59 // In this example we add a file originating from the GDC with the id PEDESTALS
60 // Three files originating from different LDCs but with the same id are also added
61 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
62 // the "online" naming convention ALICE-INT-2003-039.
63 //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test000.tag.root", "GDC0", "runTags01.root");
64 //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test001.tag.root", "GDC1", "runTags02.root");
65 //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test002.tag.root", "GDC2", "runTags03.root");
67 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
68 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
69 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
70 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root");
72 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_runconfig", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"));
73 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "DCS FXS", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
75 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
79 int length = is.tellg();
80 const char *buffer = new char[length];
82 is.read(buffer,length);
85 shuttle->SetInputTriggerConfiguration(buffer);
87 // The shuttle can read run type stored in the DAQ logbook.
88 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
89 // using GetRunType function.
90 shuttle->SetInputRunType("PHYSICS");
92 // The shuttle can read run parameters stored in the DAQ run logbook.
93 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
94 // using GetRunParameter function.
95 shuttle->AddInputRunParameter("time_start", "1233213.22");
96 shuttle->AddInputRunParameter("time_end", "1345645.22");
97 shuttle->AddInputRunParameter("beamEnergy", "1400.");
98 shuttle->AddInputRunParameter("beamType", "p-p");
99 shuttle->AddInputRunParameter("numberOfDetectors", "5");
100 shuttle->AddInputRunParameter("detectorMask", "34555");
101 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
103 // shuttle->AddInputRunParameter("totalEvents", "30000");
104 // shuttle->AddInputRunParameter("NumberOfGDCs", "15");
106 // TODO(5) NOT NEEDED
108 // This is for preprocessor that require data from HLT.
109 // Since HLT may be switched off, the preprocessor should first query the Run logbook where
110 // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
111 // a bool directly. 1 = HLT ON, 0 = HLT OFF
114 Bool_t hltStatus = kTRUE;
115 shuttle->SetInputHLTStatus(hltStatus);
118 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
119 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
121 // Test the preprocessor
126 // In the preprocessor AliShuttleInterface::Store should be called to put the final
127 // data to the CDB. To check if all went fine have a look at the files produced in
128 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
130 // Check the file which should have been created
131 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
132 ->Get("GRP/GRP/Data", kRun);
134 printf("The file is not there. Something went wrong.\n");
138 chkEntry->GetObject()->Print();
141 AliDCSSensor* sen = (AliDCSSensor*)(((TMap*)chkEntry->GetObject())->GetValue("fP2Pressure"));
143 sen->GetFit()->MakeGraph(1.5, 9.5, 15)->Draw();
145 // AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
146 // If everything went fine, draw the result
154 TMap* CreateDCSAliasMap()
156 // Creates a DCS structure
157 // The structure is the following:
158 // TMap (key --> value)
159 // <DCSAlias> --> <valueList>
160 // <DCSAlias> is a string
161 // <valueList> is a TObjArray of AliDCSValue
162 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
164 const Int_t fgknDCSDP = 10;
165 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
174 "CavernAtmosPressure",
175 "SurfaceAtmosPressure"
183 aliasMap->SetOwner(1);
186 valueSet = new TObjArray;
187 valueSet->SetOwner(1);
188 dcsVal = new AliDCSValue( 'F', 0 );
189 valueSet->Add(dcsVal);
190 // aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
193 valueSet = new TObjArray;
194 valueSet->SetOwner(1);
195 dcsVal = new AliDCSValue( kTRUE, 0 );
196 valueSet->Add(dcsVal);
197 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
200 valueSet = new TObjArray;
201 valueSet->SetOwner(1);
202 dcsVal = new AliDCSValue( kTRUE, 0 );
203 valueSet->Add(dcsVal);
204 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
208 // for( int nAlias=3; nAlias<fgknDCSDP-1; nAlias++) {
209 for( int nAlias=3; nAlias<fgknDCSDP; nAlias++) {
210 valueSet = new TObjArray;
211 valueSet->SetOwner(1);
213 for (int timeStamp=0; timeStamp<100; timeStamp++) {
214 dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
215 //printf("%s\n",dcsVal->ToString().Data());
216 valueSet->Add(dcsVal);
218 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
225 TMap* ReadDCSAliasMap()
227 // Open a file that contains DCS input data
228 // The CDB framework is used to open the file, this means the file is located
229 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
230 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
231 // An explanation of the structure can be found in CreateDCSAliasMap()
233 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
234 ->Get("DET/DCS/Data", 0);
235 return dynamic_cast<TMap*> (entry->GetObject());
240 void WriteDCSAliasMap()
242 // This writes the output from CreateDCSAliasMap to a CDB file
244 TMap* dcsAliasMap = CreateDCSAliasMap();
246 AliCDBMetaData metaData;
247 metaData.SetBeamPeriod(0);
248 metaData.SetResponsible("Ernesto Lopez Torres");
249 metaData.SetComment("Test object for TestGRPPreprocessor.C");
251 AliCDBId id("GRP/Data", 0, 0);
253 // look into AliTestShuttle's CDB main folder
255 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
256 ->Put(dcsAliasMap, id, &metaData);