import ROOT, glob, math, sys, os from ROOT import std #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) iVerbose = 1; # TStopwatch timer; # timer.Start(); basedir = ROOT.TString(gSystem->Getenv("VMCWORKDIR")) fRun = ROOT.FairRunAna(); jobdir = ROOT.TString(outpath) jobname=(filename.Data()); last = jobname.rfind("/"); if(last>0): jobname = jobname.jobname[last+1,jobname.size()+1] outName=ROOT.TString(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)); outFile = ROOT.TString(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(); TString geoFile = basedir; geoFile+="/tpc/TestBench/FOPIGeo.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); fRun->SetField(fMagField); //extract number of entries in external data tree TFile testFile(filename); unsigned int numEvents = ((TTree*)testFile.Get("tpcEvent"))->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 ------------------------------ 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(20); 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(); 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: "<