void run_sample_data() { TStopwatch timer; timer.Start(); const Int_t nev = -1; // number of events to read, -1 - untill CTRL+C const Int_t trigger = -1; // 1 - onspill, 2 - offspill. -1 - all TString filename = "sample_data_2.lmd"; TString outputFileName = "output_raw_land.root"; // name of output file const Int_t refresh = 100000; // refresh rate for saving control histograms TString parFileName = "params_raw_land.root"; // name of parameter file const Int_t updateRate = 150000; const Int_t minStats = 10000; // minimum number of entries for TCAL calibration const Int_t nModules = 800; // number of photomultipliers (for TCAL calibration) // Create source with unpackers ---------------------------------------------- TString ntuple_options = "UNPACK:EVENTNO,UNPACK:TRIGGER,RAW"; TString ucesb_dir = getenv("UCESB_DIR"); TString ucesb_path = ucesb_dir + "/../upexps/s438b/s438b"; EXT_STR_h101 ucesb_struct; R3BUcesbSource* source = new R3BUcesbSource(filename, ntuple_options, ucesb_path, &ucesb_struct, sizeof(ucesb_struct)); source->SetMaxEvents(nev); source->AddReader(new R3BUnpackReader((EXT_STR_h101_unpack*)&ucesb_struct.unpack, offsetof(EXT_STR_h101, unpack))); source->AddReader(new R3BNeulandTacquilaReader((EXT_STR_h101_raw_nnp*)&ucesb_struct.nnp, offsetof(EXT_STR_h101, nnp))); source->AddReader(new R3BLosReader((EXT_STR_h101_LOS*)&ucesb_struct.los, offsetof(EXT_STR_h101, los))); // --------------------------------------------------------------------------- // Create online run --------------------------------------------------------- FairRunOnline* run = new FairRunOnline(source); run->SetOutputFile(outputFileName.Data()); run->SetRunId(1111); // --------------------------------------------------------------------------- // Create ALADIN field map --------------------------------------------------- R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps"); Double_t fMeasCurrent = 2500.; // I_current [A] magField->SetCurrent(fMeasCurrent); magField->SetScale(1.); run->SetField(magField); // --------------------------------------------------------------------------- // TCAL ---------------------------------------------------------------------- R3BNeulandMapped2CalPar* tcalFill = new R3BNeulandMapped2CalPar("TcalFill"); tcalFill->SetUpdateRate(updateRate); tcalFill->SetMinStats(minStats); tcalFill->SetTrigger(trigger); tcalFill->SetNofModules(nModules); run->AddTask(tcalFill); R3BLosMapped2CalPar* losTcalFill = new R3BLosMapped2CalPar("LosTcalFill"); losTcalFill->SetUpdateRate(updateRate); losTcalFill->SetMinStats(minStats); losTcalFill->SetNofModules(1, 4); run->AddTask(losTcalFill); // --------------------------------------------------------------------------- // Add analysis task --------------------------------------------------------- R3BNeulandMappedHist* ana = new R3BNeulandMappedHist("LandRawAna", 1); run->AddTask(ana); // --------------------------------------------------------------------------- // Initialize ---------------------------------------------------------------- run->Init(); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); // --------------------------------------------------------------------------- // Runtime data base --------------------------------------------------------- FairRuntimeDb* rtdb = run->GetRuntimeDb(); R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFileName); rtdb->setOutput(parOut); rtdb->print(); // --------------------------------------------------------------------------- // Run ----------------------------------------------------------------------- if(nev < 0) { run->Run(nev, 0); } else { run->Run(0, nev); } rtdb->saveOutput(); // --------------------------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outputFileName << endl; cout << "Parameter file is " << parFileName << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; if(ana->GetNItemsTotal() > 3800) { cout << " Test passed" << endl; cout << " All ok " << endl; } delete run; }
void tamex_multi_pc_ucesb_mh() { TStopwatch timer; timer.Start(); const Int_t nev = 10000; /* number of events to read, -1 - until CTRL+C */ const Int_t trigger = -1; // 1 - onspill, 2 - offspill. -1 - all /* Create source using ucesb for input ------------------ */ TString filename = "stream://x86l-3"; TString outputFileName = "tamex_text.root"; TString histFileName = "hist_neuland.root"; // name of file with control histograms const Int_t refresh = 100000; // refresh rate for saving control histograms TString parFileName = "params_neuland.root"; // name of parameter file TString ntuple_options = "UNPACK:EVENTNO,UNPACK:TRIGGER,RAW"; TString ucesb_dir = getenv("UCESB_DIR"); TString ucesb_path = ucesb_dir + "/../upexps/tamex_multi_pc_readout/tamex_multi_pc_readout"; EXT_STR_h101 ucesb_struct; R3BUcesbSource* source = new R3BUcesbSource(filename, ntuple_options, ucesb_path, &ucesb_struct, sizeof(ucesb_struct)); source->AddReader(new R3BUnpackReader(&ucesb_struct)); source->AddReader(new R3BNeulandTamexReader(&ucesb_struct)); /* ------------------------------------------------------ */ /* Create online run ------------------------------------ */ FairRunOnline* run = new FairRunOnline(source); run->SetOutputFile("output.root"); /* ------------------------------------------------------ */ /* Create ALADIN field map ------------------------------ */ R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps"); Double_t fMeasCurrent = 2500.; // I_current [A] magField->SetCurrent(fMeasCurrent); magField->SetScale(1.); run->SetField(magField); /* ------------------------------------------------------ */ const Int_t nBarsPerPlane = 50; // number of scintillator bars per plane const Int_t updateRate = 15000; const Int_t minStats = 10000; // minimum number of entries for TCAL calibration const Int_t nPlanes = 1; // number of planes (for TCAL calibration) // TCAL ---------------------------------------------------------------------- R3BNeulandTcalFill* tcalFill = new R3BNeulandTcalFill("TcalFill"); tcalFill->SetUpdateRate(updateRate); tcalFill->SetMinStats(minStats); tcalFill->SetTrigger(trigger); tcalFill->SetNofModules(nPlanes,nBarsPerPlane, 0); run->AddTask(tcalFill); /* Add analysis task ------------------------------------ */ R3BLandRawAna* ana = new R3BLandRawAna("R3BNeulandTamexMappedItem", 1); run->AddTask(ana); /* ------------------------------------------------------ */ /* Initialize ------------------------------------------- */ run->Init(); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); /* ------------------------------------------------------ */ /* Runtime data base ------------------------------------ */ /*FairRuntimeDb* rtdb = run->GetRuntimeDb(); R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFileName); rtdb->setOutput(parOut); rtdb->print();*/ /* ------------------------------------------------------ */ /* Run -------------------------------------------------- */ run->Run((nev < 0) ? nev : 0, (nev < 0) ? 0 : nev); /*rtdb->saveOutput();*/ delete run; /* ------------------------------------------------------ */ timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outputFileName << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl << endl; }
// ------------------------------------------------------------------------- // // ----- General Macro for R3B CALIFA Unpacking // Author: Hector Alvarez <*****@*****.**> // Last Update: 22/09/14 // Comments: // Runs the CALIFA Unpacker. Outputs a root file with // a collection (TClonesArray) of R3BCrystalHits // // ------------------------------------------------------------------------- // // Usage: e.g. // // root -l -b -q 'califaUnpack_batch.C("1000mv_30mev_",362,364)'; // ------------------------------------------------------------------------- void califaUnpack_batch(TString inputFile="", Int_t firstFileNumber=-999, Int_t lastFileNumber=-999, Int_t nevents=-1) { TStopwatch timer; timer.Start(); TString inDir = "./data/run336/"; // directory with lmd files TString outDir = "./data/run336/"; // output directory TString inputFileName = inDir + inputFile + ".lmd"; // name of input file TString outputFileName = outDir + inputFile + "_raw.root"; // name of output file TString parFileName = outDir + "params_" + inputFile + "_raw.root"; // name of parameter file FairLmdSource* source = new FairLmdSource(); char strName[1000]; for(Int_t i = firstFileNumber; i < lastFileNumber+1; i++) { sprintf(strName, "%s%s%4d.lmd", inDir.Data(), inputFile.Data(), i); for(Int_t j = 0; j < 1000; j++) if(' ' == strName[j]) strName[j] = '0'; cout << strName << endl; source->AddFile(strName); } // CALIFA MBS parameters ------------parameters ------------------- Short_t type = 100; // CALIFA in included in the general day Short_t subType = 10000; Short_t procId = 2; Short_t subCrate = 2; Short_t control = 9; /* Short_t type = 10; // CALIFA at the beginning of the experiment Short_t subType = 1; Short_t procId = 1; Short_t subCrate = -1; Short_t control = 9; */ source->AddUnpacker(new R3BCaloUnpack("", type, subType, procId, subCrate, control)); // ------------------------------------------------------ // Create analysis run ------------------------------------------------------- FairRunOnline* run = new FairRunOnline(source); run->SetOutputFile(outputFileName.Data()); // --------------------------------------------------------------------------- // Histograms ---------------------------------------------------------------- R3BCaloRawAna* rawAna = new R3BCaloRawAna(); run->AddTask(rawAna); // --------------------------------------------------------------------------- // Initialize ---------------------------------------------------------------- run->Init(); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); // --------------------------------------------------------------------------- // Run ----------------------------------------------------------------------- run->Run(nevents, 0); // --------------------------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outputFileName << endl; cout << "Parameter file is " << parFileName << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; }
void run(TString runNumber) { TStopwatch timer; timer.Start(); const Int_t nev = -1; // number of events to read, -1 - untill CTRL+C TString inDir = "/Volumes/Data/kresan/s438b/lmd/"; // directory with lmd files TString outDir = "/Volumes/Data/kresan/s438b/data/"; // output directory TString histDir = "/Users/kresan/Sites/"; // web-server directory TString outputFileName = outDir + runNumber + "_raw.root"; // name of output file TString histFileName = histDir + "hist_s438b_" + runNumber + "_raw.root"; // name of file with control histograms const Int_t refresh = 100000; // refresh rate for saving control histograms TString parFileName = outDir + "params_" + runNumber + "_raw.root"; // name of parameter file //const Long64_t maxSize = 1 * 1024 * 1024 * 1024; // 1 GByte // file split size const char *landMappingName = "cfg_neuland_s438b.hh"; // mapping file const Int_t nBarsPerPlane = 50; const Int_t updateRate = 150000; const Int_t minStats = 5000; const Int_t nModules = 800; // Create source with unpackers ---------------------------------------------- Int_t iFile = 0; Int_t kFile = 0; if(runNumber.Contains("run331")) { iFile = 5209; kFile = 5229; } FairLmdSource* source = new FairLmdSource(); char strName[1000]; for(Int_t i = iFile; i < kFile; i++) { sprintf(strName, "%s%s_%4d.lmd", inDir.Data(), runNumber.Data(), i); for(Int_t j = 0; j < 1000; j++) if(' ' == strName[j]) strName[j] = '0'; cout << strName << endl; source->AddFile(strName); } R3BEventHeaderUnpack *event_unpack = new R3BEventHeaderUnpack(); source->AddUnpacker(event_unpack); // NeuLAND MBS parameters ------------------------------- Short_t type = 94; Short_t subType = 9400; Short_t procId = 12; Short_t subCrate = 0; Short_t control = 3; source->AddUnpacker(new R3BLandUnpack(type, subType, procId, subCrate, control)); // ------------------------------------------------------ // LOS MBS parameters ----------------------------------- type = 88; subType = 8800; procId = 10; subCrate = 7; control = 5; //source->AddUnpacker(new R3BLosUnpack(type, subType, procId, subCrate, control)); // ------------------------------------------------------ // --------------------------------------------------------------------------- // Create online run --------------------------------------------------------- FairRunOnline* run = new FairRunOnline(source); run->SetOutputFile(outputFileName.Data()); run->SetGenerateHtml(kTRUE, histFileName.Data(), refresh); // --------------------------------------------------------------------------- // Create ALADIN field map --------------------------------------------------- R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps"); Double_t fMeasCurrent = 2500.; // I_current [A] magField->SetCurrent(fMeasCurrent); magField->SetScale(1.); run->SetField(magField); // --------------------------------------------------------------------------- // Channel mapping ----------------------------------------------------------- R3BLandMapping* map = new R3BLandMapping(); map->SetFileName(landMappingName); map->SetNofBarsPerPlane(nBarsPerPlane); run->AddTask(map); // --------------------------------------------------------------------------- // TCAL ---------------------------------------------------------------------- R3BLandTcalFill* tcalFill = new R3BLandTcalFill("TcalFill"); tcalFill->SetUpdateRate(updateRate); tcalFill->SetMinStats(minStats); tcalFill->SetTrigger(2); tcalFill->SetNofModules(nModules, 50); run->AddTask(tcalFill); R3BLosTcalFill* losTcalFill = new R3BLosTcalFill("LosTcalFill"); losTcalFill->SetUpdateRate(updateRate); losTcalFill->SetMinStats(minStats); losTcalFill->SetNofModules(20); //run->AddTask(losTcalFill); // --------------------------------------------------------------------------- // Add analysis task --------------------------------------------------------- R3BLandRawAna* ana = new R3BLandRawAna("LandRawAna", 1); run->AddTask(ana); // --------------------------------------------------------------------------- // Initialize ---------------------------------------------------------------- run->Init(); //((TTree*)gFile->Get("cbmsim"))->SetMaxTreeSize(maxSize); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); // --------------------------------------------------------------------------- // Runtime data base --------------------------------------------------------- FairRuntimeDb* rtdb = run->GetRuntimeDb(); R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFileName); rtdb->setOutput(parOut); rtdb->print(); // --------------------------------------------------------------------------- // Run ----------------------------------------------------------------------- run->Run(nev, 0); rtdb->saveOutput(); // --------------------------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outputFileName << endl; cout << "Parameter file is " << parFileName << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; }