/* $Id$ */ // This class runs the test TOF preprocessor // It uses AliTestShuttle to simulate a full Shuttle process // The input data is created in the functions // CreateDCSAliasMap() creates input that would in the same way come from DCS // ReadDCSAliasMap() reads from a file // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle extern TBenchmark *gBenchmark; void TOFPreprocessorFDR() { gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so"); AliLog::SetClassDebugLevel("AliTOFPreprocessorFDR",1); // initialize location of CDB AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); // create AliTestShuttle instance AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000); // Generation of "fake" input DCS data TMap* dcsAliasMap = CreateDCSAliasMap(); // now give the alias map to the shuttle shuttle->SetDCSInput(dcsAliasMap); // instantiation of the preprocessor AliPreprocessor* pp = new AliTOFPreprocessorFDR(shuttle); // preprocessing gBenchmark->Start("process"); shuttle->Process(); gBenchmark->Stop("process"); gBenchmark->Print("process"); // checking the file which should have been created AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/DCSData", 0); if (!chkEntry) { printf("The file is not there. Something went wrong.\n"); return; } AliTOFDataDCS* output = dynamic_cast (chkEntry->GetObject()); // If everything went fine, draw the result if (output) printf("Output found.\n"); // output->Draw(); } TMap* CreateDCSAliasMap() { // Creates a DCS structure // The structure is the following: // TMap (key --> value) // --> // is a string // is a TObjArray of AliDCSValue // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias TMap* aliasMap = new TMap; aliasMap->SetOwner(1); TRandom random; TDatime *datime = new TDatime(); Int_t time = datime->GetTime(); Int_t date = datime->GetDate(); Int_t pid = gSystem->GetPid(); delete datime; Int_t iseed = TMath::Abs(10000 * pid + time - date); Float_t tentLVv33=3.3, tentLVv48=48, tentLVi33=100, tentLVi48=10; Float_t sigmaLVv33=0.1, sigmaLVv48=1, sigmaLVi33=10, sigmaLVi48=2; Float_t tent=0, sigma=0, thr=0; Int_t NAliases=4; for(int nAlias=0;nAliasSetOwner(1); TString sindex; TString aliasName; if (nAlias==0){ aliasName = "tof_lv_i48_02"; tent=tentLVi48; sigma=sigmaLVi48; } else if (nAlias==1){ aliasName = "tof_lv_v48_02"; tent=tentLVv48; sigma=sigmaLVv48; } else if (nAlias==2){ aliasName = "tof_lv_i33_02"; tent=tentLVi33; sigma=sigmaLVi33; } else if (nAlias==3){ aliasName = "tof_lv_v33_02"; tent=tentLVv33; sigma=sigmaLVv33; } // gauss generation of values for (int timeStamp=0;timeStamp<1000;timeStamp+=10){ Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma)); if (TMath::Abs(gaussvalue-tent)>sigma){ AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp); valueSet->Add(dcsVal); } } aliasMap->Add(new TObjString(aliasName), valueSet); } return aliasMap; } TMap* ReadDCSAliasMap() { // Open a file that contains DCS input data // The CDB framework is used to open the file, this means the file is located // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB//DCS/Data // The file contains an AliCDBEntry that contains a TMap with the DCS structure. // An explanation of the structure can be found in CreateDCSAliasMap() AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0); return dynamic_cast (entry->GetObject()); } void WriteDCSAliasMap() { // This writes the output from CreateDCSAliasMap to a CDB file TMap* dcsAliasMap = CreateDCSAliasMap(); AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("Chiara"); metaData.SetComment("Test object for TOFPreprocessorDCS.C"); AliCDBId id("TOF/DCS/Data", 0, 0); // initialize location of CDB AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); }