void runDigiFOPISimple(TString filename, Int_t field, TString gas, Int_t gain, TString distfile="", Int_t nEvents=0) { // ======================================================================== // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 0; // Number of events to process //Int_t nEvents = 0; TString mcMode = "TGeant3"; // ---- Load libraries ------------------------------------------------- TString sysFile = gSystem->Getenv("VMCWORKDIR"); TString inFile = filename; TString outFile = filename; outFile.ReplaceAll("mc.root", "raw.root"); //if (distfile!="") // outFile.ReplaceAll("raw.root","disto.raw.root"); TString parFile = filename; parFile.ReplaceAll("mc.root", "param.root"); // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ----- Digitization run ------------------------------------------- FairRunAna *fRun= new FairRunAna(); fRun->SetInputFile(inFile); fRun->SetOutputFile(outFile); // ------------------------------------------------------------------------ // ----- Parameter database -------------------------------------------- TString allDigiFile = sysFile; allDigiFile+= Form("/tpc/FOPI/par/tpc.%i%s%iMC.par",field,gas.Data(),gain); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(allDigiFile.Data(),"in"); rtdb->setFirstInput(parInput1); rtdb->setSecondInput(parIo1); // ------------------------------------------------------------------------ // ----- TPC digi producers --------------------------------- TpcEventCounter* evCount = new TpcEventCounter(); // evCount->SetnEvts(nEvents); //evCount->SetStep(1); fRun->AddTask(evCount); //TpcClusterizerTask* tpcClusterizer = new TpcClusterizerTask(); //if(mcMode=="TGeant3") tpcClusterizer->SetMereChargeConversion(); //tpcClusterizer->SetPersistence(); //fRun->AddTask(tpcClusterizer); TpcSimpleEvtGen* tpcSimpleEvt = new TpcSimpleEvtGen(); tpcSimpleEvt->setMode("alongZ"); tpcSimpleEvt->setPrimGen(); fRun->AddTask(tpcSimpleEvt); TpcDriftTask* tpcDrifter = new TpcDriftTask(); tpcDrifter->SetPersistence(); if (distfile!="") { std::cout<<"using distortion file: "<SetDistort(true); tpcDrifter->SetDeviationFile(distfile.Data()); } else tpcDrifter->SetDistort(false); fRun->AddTask(tpcDrifter); TpcGemTask* tpcGem = new TpcGemTask(); tpcGem->SetPersistence(); fRun->AddTask(tpcGem); TpcPadResponseTask* tpcPadResponse = new TpcPadResponseTask(); tpcPadResponse->SetPersistence(); fRun->AddTask(tpcPadResponse); Double_t cal=2.125+0.05+0.05+0.05+0.05;//3.677-0.35-0.32-0.31-0.5;//0.;//3.63433;//2.58544-0.590136;//2.78; TpcElectronicsTask* tpcElec = new TpcElectronicsTask(); tpcElec->SetPersistence(); tpcElec->SetPSATimeCalib(cal); tpcElec->SetSamplePersistence(); tpcElec->SetShaper("T2K"); fRun->AddTask(tpcElec); TpcElectronicsTask* tpcElec2 = new TpcElectronicsTask(); //tpcElec2->SetPersistence(); tpcElec2->SetPSATimeCalib(cal); tpcElec2->SetPSA(1); tpcElec2->SetSampleBranchName("TpcSample2"); tpcElec2->SetDigiBranchName("TpcDigi2"); //tpcElec2->SetSamplePersistence(); tpcElec2->SetShaper("T2K"); //fRun->AddTask(tpcElec2); // ----- Intialise and run -------------------------------------------- fRun->Init(); fRun->Run(0,nEvents); rtdb->saveOutput(); rtdb->print(); // tpcDrifter->WriteHistograms(); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outFile << endl; cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; cout << endl; // ------------------------------------------------------------------------ }