void runRecoFOPI_batch_standalone_mb(TString filename, TString outpath, int field, TString gas, int bfield, unsigned int smoothing = 0, unsigned int nEvents = 0, unsigned int nEvStart = 0,unsigned int outnum=0) { // ======================================================================== // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 1; Double_t taroff = -65; Double_t targetpos = taroff+41.; TStopwatch timer; timer.Start(); // Load basic libraries in rootlogon // gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); // gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C"); // rootlogon.C // FairLogger::GetLogger()->SetLogToScreen(true); // FairLogger::GetLogger()->SetLogScreenLevel("logINFO"); TString basedir = gSystem->Getenv("VMCWORKDIR"); FairRunAna* fRun = new FairRunAna(); //FairRunSim* fSim = new FairRunSim(); TString jobdir = outpath; std::string jobname(filename.Data()); int last = jobname.rfind("/"); if(last>0) jobname = jobname.substr(last+1,jobname.size()+1); TString outName(jobname); if(outName.Contains("repaired.")) outName.ReplaceAll(".lmd_decoded_repaired.root",".reco.root"); if(outName.Contains("decoded.")) outName.ReplaceAll(".lmd_decoded.root",".reco.root"); if(smoothing) outName.ReplaceAll("reco.root", "smoothed_reco.root"); if(outnum>0) outName.ReplaceAll(".root",Form("%i.root",outnum)); TString outFile = outpath+"/"; outFile += outName; TString PROutFile = outFile; PROutFile.ReplaceAll(".reco.root",".patternReco.root"); TFile test(PROutFile, "recreate"); if(!test.IsZombie()) { //delete file gSystem->Setenv("PROUTFILENAME", PROutFile.Data()); gROOT->ProcessLine(".! rm $PROUTFILENAME"); gSystem->Unsetenv("PROUTFILENAME"); } fRun->SetOutputFile(outFile); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParAsciiFileIo* parInput1 = new FairParAsciiFileIo(); TString tpcDigiFile = basedir; tpcDigiFile += "/tpc/FOPI/par/tpc.TBtestChamber."; tpcDigiFile += field; tpcDigiFile += gas; tpcDigiFile +=".par"; parInput1->open(tpcDigiFile.Data(),"in"); rtdb->setFirstInput(parInput1); rtdb->Print(); TpcDigiPar* par = (TpcDigiPar*) rtdb->getContainer("TpcDigiPar"); par->setInputVersion(fRun->GetRunId(),1); par->setChanged(kTRUE); par->init(); Double_t taroff = -65; Double_t targetpos = taroff+41.; // possible materials: copper (default), lead, carbon TString targetmat = TString("carbon"); TString alignmentFileName = par->getAlignmentFile(); TString geoFile; geoFile.Form("$FOPI2ROOT/fopigeometry/FopiGeom_s339%5.1f.root",targetpos); TString cmd; cmd.Form(".! root -b -q '$FOPI2ROOT/fopigeometry/FopiGeom.C(%f,\"%s\",\"%s\",\"%s\",kFALSE)'",targetpos,targetmat.Data(),alignmentFileName.Data(),geoFile.Data()); gROOT->ProcessLine(cmd); // add geometry file to fRun fRun->SetGeomFile(geoFile); // TString geoFile = basedir; // geoFile+="/geometry/tpc_prototype_ArCo2.root"; // fRun->SetGeomFile(geoFile); //PndConstField *fMagField=new PndConstField(); //if (bfield == 1) // fMagField->SetField(0., 0. , 6. ); // values are in kG //if (bfield == 0) // fMagField->SetField(0., 0. , 0. ); // values are in kG // values are in cm //fMagField->SetFieldRegion(-50, 50,-50, 50, -2000, 2000); // FOPI magnetic field //For pion beam data, FOPIField(0.616) has to be used according to CDC/RPC analysis! // if the constructor is called with no argument, 0.6T is used FOPIField *fMagField = new FOPIField(0.616); fMagField->SetTargetOffset(taroff); fRun->SetField(fMagField); //extract number of entries in external data tree TFile testFile(filename); unsigned int numEvents = ((TTree*)testFile.Get("tpcEvent"))->GetEntries(); //unsigned int numEvents = ((TTree*)testFile.Get("cbmsim"))->GetEntries(); std::cout<<"Found "<numEvents) nEvents=numEvents; TpcAlignmentManager * align = TpcAlignmentManager::getInstance("/nfs/hicran/project/panda/SIM/bergerm/fopiroot/tpc/FOPI/par/dummy_alignment.txt"); //--------------------SET UP TASKS ------------------------------ TpcEventCounter* evCount = new TpcEventCounter(); //evCount->SetnEvts(nEvents); //evCount->SetStep(1); fRun->AddTask(evCount); FairGeane *Geane = new FairGeane(); fRun->AddTask(Geane); TpcDataReaderTask* read = new TpcDataReaderTask(); //read->SetPersistence(); read->SetDatafile(filename); read->SetClusterBranchName("TpcSample"); read->SetStartEvent(nEvStart); //read->SetCutSmallPad(); //read->SetMinSamples(1000); fRun->AddTask(read); TpcPSATask* tpsa = new TpcPSATask(); tpsa->SetPersistence(); tpsa->SetSamplePersistence(); tpsa->SetSampleBranchName("TpcSample"); // Input of PSA fRun->AddTask(tpsa); TpcClusterFinderTask* tpcCF = new TpcClusterFinderTask(); tpcCF->SetDigiPersistence(); // keep Digis copys in clusters tpcCF->SetPersistence(); // keep Clusters tpcCF->timeslice(6); //in samples tpcCF->SetSingleDigiClusterAmpCut(15); tpcCF->SetClusterAmpCut(9.1); // cut on mean digi amplitude tpcCF->SetErrorPars(600.,400.); tpcCF->SetSimpleClustering(); // use TpcClusterFinderSimple fRun->AddTask(tpcCF); TpcClusterAlignmentTask *tpcAlign = new TpcClusterAlignmentTask(); tpcAlign->SetPersistence(); tpcAlign->SetClusterInBranchName("TpcClusterRaw"); tpcAlign->SetClusterOutBranchName("TpcCluster"); fRun->AddTask(tpcAlign); //find TpcRiemannTracks in the TPC alone TpcRiemannTrackingTask* tpcSPR = new TpcRiemannTrackingTask(); tpcSPR->SetClusterBranchName("TpcCluster"); tpcSPR->SetPersistence(); tpcSPR->SetSortingParameters(true,1,0); fRun->AddTask(tpcSPR); //build GFTracks from TpcRiemannTracks TpcTrackInitTask* trackInit=new TpcTrackInitTask(); trackInit->SetClusterBranchName("TpcCluster"); trackInit->SetOutBranchName("TpcTrackPreFit"); trackInit->SetPersistence(); //trackInit->SetVerbose(1); //trackInit->SetMCPid(); // use ideal particle identification trackInit->SetPDG(211); //trackInit->useGeane(); // uses RKTrackrep and GeaneTrackrep if (smoothing==1) trackInit->SetSmoothing(true); fRun->AddTask(trackInit); // TpcSLPatternRecoTask* tpcSLPR = new TpcSLPatternRecoTask(); // tpcSLPR->SetPersistence(true); // tpcSLPR->SetStoreHistograms(PROutFile); // tpcSLPR->SetClusterAmpCut(20.); // tpcSLPR->SetCutTracksParallelZ(5); // //tpcSLPR->SetXSorting(true); // double parMins[4] = {-TMath::Pi(),0.,-TMath::Pi(),0.}; // double parMaxs[4] = {TMath::Pi(),10.,TMath::Pi(),20.}; // tpcSLPR->SetParameterSpace(parMins, parMaxs); // tpcSLPR->SetDepth(8); // tpcSLPR->SetThresh(15); // tpcSLPR->SetMinCandHits(15); // //tpcSLPR->SetClusterBranchName("TpcCluster_cut"); // tpcSLPR->SetAbsMomentum(1000); // //fRun->AddTask(tpcSLPR); KalmanTask* kalman =new KalmanTask(); kalman->SetTpcClusterBranchName("TpcCluster"); kalman->SetTrackBranchName("TpcTrackPreFit"); kalman->SetOutBranchName("TrackPostFit"); kalman->SetPersistence(); //kalman->SetClusterBranchName("TpcCluster_cut"); kalman->SetNumIterations(3); // number of fitting iterations (back and forth) fRun->AddTask(kalman); TpcResidualTask* Res = new TpcResidualTask(); Res->SetPersistence(); Res->SetNumberOfTrackReps(1); // set to 2 if you use GeaneTrackrep (tpcSPR->useGeane();) if (smoothing==1) Res->SetUnbiased(); //SLres->SetClusterBranchName("TpcCluster_cut"); fRun->AddTask(Res); // TpcSLResidualTask* SLres = new TpcSLResidualTask(); // SLres->SetPersistence(); //SLres->SetClusterBranchName("TpcCluster_cut"); // SLres->SetSecondarySuppression(true); //fRun->AddTask(SLres); // ----- Intialise and run -------------------------------------------- fRun->Init(); //Initialize te Digimapper: TpcDigiPar* tpcpar = FairRun::Instance()->GetRuntimeDb()->getContainer("TpcDigiPar"); TpcDigiMapper::getInstance()->init(tpcpar); TpcDigiMapper::getInstance()->forceManualDriftVel(forceDriftVel); std::cout<<"pads:"<getPadPlane()->GetNPads()<print(); std::cout<<"start:"<Run(nEvStart,nEvents); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime); std::cout<<"OutputFile: "<