/* $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 TOFPreprocessor(Char_t * RunType="PHYSICS") { gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); AliLog::SetClassDebugLevel("AliTOFPreprocessor",1); // initialize location of CDB AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); // create AliTestShuttle instance AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000); //setting run type to physiscs shuttle->SetInputRunType(RunType); // Generation of "fake" input DCS data TMap* dcsAliasMap = CreateDCSAliasMap(); // now give the alias map to the shuttle shuttle->SetDCSInput(dcsAliasMap); // processing files. for the time being, the files are local. shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root"); shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root"); shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20080310.164003.4001"); char filename[100]; char LDCname[5]; for (Int_t iLDC=0;iLDC<2;iLDC++){ sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2); sprintf(LDCname,"LDC%i",iLDC*2); shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename); sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2); sprintf(LDCname,"LDC%i",iLDC*2); shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename); } // instantiation of the preprocessor AliPreprocessor* pp = new AliTOFPreprocessor(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/ParOnline", 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 thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5, //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000; //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5, // tentFEEthr=0.5, te result=0; //ntFEEt=20, tentTemp=25, tentPress=900; //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25, // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10; Float_t tentHVv=6500, tentHVi=80; Float_t sigmaHVv=10, sigmaHVi=10; Float_t tent=0, sigma=0, thr=0; // to have all the aliases, decomment the following line: Int_t NAliases=360, NHV=90; // if not all the aliases are there, use this: //Int_t NAliases=120, NHV=90; for(int nAlias=0;nAliasSetOwner(1); TString sindex; TString aliasName; if (nAliassigma){ 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 TOFPreprocessor.C"); AliCDBId id("TOF/DCS/Data", 0, 0); // initialize location of CDB AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); }