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 TestPMDPreprocessor()
14 gSystem->Load("libTestShuttle.so");
16 // TODO if needed, change location of OCDB and Reference test folders
17 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
19 AliTestShuttle::SetOCDBStorage("local://TestCDB");
20 // AliTestShuttle::SetReferenceStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
22 printf("Test OCDB storage Uri: %s\n", AliTestShuttle::GetOCDBStorage().Data());
24 // create AliTestShuttle instance
25 // The parameters are run, startTime, endTime
26 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
30 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
31 // some fake data has to be created.
33 // The "fake" input data can be taken using either (a) or (b):
34 // (a) data from a file: Use ReadDCSAliasMap()
35 // the format of the file is explained in ReadDCSAliasMap()
36 // To use it uncomment the following line:
38 //TMap* dcsAliasMap = ReadDCSAliasMap();
40 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
41 // To use it uncomment the following line:
43 TMap* dcsAliasMap = CreateDCSAliasMap();
45 // now give the alias map to the shuttle
46 shuttle->SetDCSInput(dcsAliasMap);
50 // The shuttle can also process files that originate from DCS, DAQ and HLT.
51 // To test it, we provide some local files and locations where these would be found when
52 // the online machinery would be there.
53 // In real life this functions would be produces by the sub-detectors
54 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
56 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
57 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
58 // In this example we add a file originating from the GDC with the id PEDESTALS
59 // Three files originating from different LDCs but with the same id are also added
61 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMDGAINS", "LDC1", "xy.root");
65 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
67 AliPreprocessor* test = new AliPMDPreprocessor("PMD", shuttle);
69 printf("Starting SHUTTLE!\n");
71 // Test the preprocessor
74 printf("SHUTTLE done!\n");
79 // In the preprocessor AliShuttleInterface::Store should be called to put the final
82 // Check the file which should have been created
83 AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetOCDBStorage())
84 ->Get("PMD/Calib/Data", 7);
87 printf("The file is not there. Something went wrong.\n");
91 AliPMDCalibData* output = dynamic_cast<AliPMDCalibData*> (entry->GetObject());
93 // If everything went fine, print the result
95 printf("Gain of det=1, smn=2, row=3, col=4: %f\n", output->GetGainFact(1,2,3,4));
97 AliCDBManager::Instance()->Destroy();
102 TMap* CreateDCSAliasMap()
104 // Creates a DCS structure
105 // The structure is the following:
106 // TMap (key --> value)
107 // <DCSAlias> --> <valueList>
108 // <DCSAlias> is a string
109 // <valueList> is a TObjArray of AliDCSValue
110 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
112 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
113 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
115 TMap* aliasMap = new TMap;
116 aliasMap->SetOwner(1);
120 for(int nAlias=0;nAlias<6;nAlias++)
122 TObjArray* valueSet = new TObjArray;
123 valueSet->SetOwner(1);
125 TString aliasName="DCSAlias";
127 //printf("\n\n alias: %s\n\n",aliasName.Data());
129 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
131 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
132 //printf("%s\n",dcsVal->ToString().Data());
133 valueSet->Add(dcsVal);
135 aliasMap->Add(new TObjString(aliasName), valueSet);