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
10 // Taking as input runtype and errorLevel
11 // errorLevel used to simulate errors:
13 // 1 --> DAQ logbook error
14 // 2 --> DAQ FXS error
15 // 3 --> DAQ logbook_trigger_config erro
16 // 4 --> DCS FXS error
17 // 5 --> DCS DPs error
18 // 6 --> Missing beamEnergy
19 // 7 --> null buffer for Trigger Config
21 // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers
22 // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C)
24 // Modified by C. Zampolli
31 void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0)
33 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
36 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10);
38 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
39 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
41 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
42 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
45 shuttle->SetInputRunType(runtype);
48 TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel);
49 shuttle->SetDCSInput(dcsAliasMap);
51 // simulating input from DAQ FXS
53 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");
54 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");
55 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");
56 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");
60 // simulating input from DCS FXS
61 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
62 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
65 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
69 int length = is.tellg();
70 const char *buffer = new char[length];
72 is.read(buffer,length);
74 const char *emptybuffer = NULL;
76 // simulating input from DAQ logbook_trigger_config
78 (errorLevel != 3 errorLevel != 7 && !partition.IsNull() && detector.IsNull()) shuttle->SetInputTriggerConfiguration(buffer);
80 else if (errorLevel == 7) {
81 shuttle->SetInputTriggerConfiguration(emptybuffer);
84 // simulating input from DAQ logbook
86 shuttle->AddInputRunParameter("DAQ_time_start", "1233213.22");
89 shuttle->AddInputRunParameter("beamEnergy", "1400.");
92 shuttle->AddInputRunParameter("DAQ_time_end", "1345645.22");
93 shuttle->AddInputRunParameter("beamType", beamType);
94 shuttle->AddInputRunParameter("numberOfDetectors", "5");
95 shuttle->AddInputRunParameter("detectorMask", "34555");
96 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
97 shuttle->AddInputRunParameter("partition",partition);
98 shuttle->AddInputRunParameter("detector",detector);
101 Bool_t hltStatus = kTRUE;
102 shuttle->SetInputHLTStatus(hltStatus);
104 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
105 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
107 // Test the preprocessor
112 // Check the file which should have been created
113 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
114 ->Get("GRP/GRP/Data", kRun);
116 printf("The file is not there. Something went wrong.\n");
120 chkEntry->GetObject()->Print();
125 TMap* CreateDCSAliasMap(Int_t errorLevel)
127 // Creates a DCS structure
128 // The structure is the following:
129 // TMap (key --> value)
130 // <DCSAlias> --> <valueList>
131 // <DCSAlias> is a string
132 // <valueList> is a TObjArray of AliDCSValue
133 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
135 const Int_t fgknDCSDP = 50;
136 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
137 "LHCState", // missing in DCS
140 "LHCLuminosity", // missing in DCS
141 "BeamIntensity", // missing in DCS
147 "L3_BSF17_Temperature",
151 "L3_BSF4_Temperature",
155 "L3_BKF17_Temperature",
159 "L3_BKF4_Temperature",
163 "L3_BSF13_Temperature",
167 "L3_BSF8_Temperature",
171 "L3_BKF13_Temperature",
175 "L3_BKF8_Temperature",
179 "Dipole_Inside_Temperature",
183 "Dipole_Outside_Temperature",
185 "CavernAtmosPressure",
186 "SurfaceAtmosPressure"
194 aliasMap->SetOwner(1);
197 valueSet = new TObjArray;
198 valueSet->SetOwner(1);
199 dcsVal = new AliDCSValue( 'F', 2 );
200 valueSet->Add(dcsVal);
201 aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
204 valueSet = new TObjArray;
205 valueSet->SetOwner(1);
206 dcsVal = new AliDCSValue( kTRUE, 2 );
207 valueSet->Add(dcsVal);
208 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
211 valueSet = new TObjArray;
212 valueSet->SetOwner(1);
213 dcsVal = new AliDCSValue( kTRUE, 2 );
214 valueSet->Add(dcsVal);
215 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
219 Int_t maxDPindex = 0;
220 if (errorLevel != 5) {
221 maxDPindex = fgknDCSDP;
224 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
227 for( int nAlias=3; nAlias<maxDPindex; nAlias++) {
228 if (nAlias>=7 && nAlias < 47) continue;
229 valueSet = new TObjArray;
230 valueSet->SetOwner(1);
232 for (int timeStamp=0; timeStamp<10; timeStamp++) {
233 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStamp+1);
234 valueSet->Add(dcsVal);
236 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
240 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
241 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
242 TString probe3[4] = {"H1","H2","H3","Temperature"};
245 for (Int_t i=0;i<3;i++){
246 for (Int_t j=0;j<6;j++){
247 for (Int_t k=0;k<4;k++){
248 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
249 valueSet = new TObjArray;
250 valueSet->SetOwner(1);
251 for (int timeStamp=0; timeStamp<10; timeStamp++) {
252 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStamp+1);
253 valueSet->Add(dcsVal);
254 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
256 aliasMap->Add( new TObjString(dpAlias), valueSet );
266 TMap* ReadDCSAliasMap()
268 // Open a file that contains DCS input data
269 // The CDB framework is used to open the file, this means the file is located
270 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
271 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
272 // An explanation of the structure can be found in CreateDCSAliasMap()
274 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
275 ->Get("DET/DCS/Data", 0);
276 return dynamic_cast<TMap*> (entry->GetObject());
281 void WriteDCSAliasMap()
283 // This writes the output from CreateDCSAliasMap to a CDB file
285 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
287 AliCDBMetaData metaData;
288 metaData.SetBeamPeriod(0);
289 metaData.SetResponsible("Ernesto Lopez Torres");
290 metaData.SetComment("Test object for TestGRPPreprocessor.C");
292 AliCDBId id("GRP/Data", 0, 0);
294 // look into AliTestShuttle's CDB main folder
296 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
297 ->Put(dcsAliasMap, id, &metaData);