void runRecoFOPI_MC_mb_recl_clcorr(TString digifile, int field, TString gas, int gain, unsigned int smoothing = 1, unsigned int nEvents = 0, bool reclust=true, bool varstep=true, double recl_fac = 1.0, double recl_off=.75, int recl_min=5, double proxc = 2.6, double proxZs = 1.45, double helixc = 1.7, unsigned int nEvStart = 0, unsigned int outnum=0, TString outfolderDes="NULL", TString outfolder="NULL", double fC=22, double fG=-1, //-1 std error; -2 unscaled shape cov; <0 scaled shape cov; >0 covOnPlane Int_t bfield=1, bool clcorr=false, bool weightedPlaneConstruction=false, bool cutCov=false, Int_t scaler=99, TString nameadd="", bool digiclcorr=false ) { // scaler: //55=reclustered cov on plane error //56=reclustered and scaled cov on plane error //65=not reclustered cov on plane error // ======================================================================== // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 0; Int_t persistence=1; bool useSPHitParamErr=true; if (digiclcorr) clcorr=false; // Input file TString inDigiFile = digifile; TString inSimFile = inDigiFile; inSimFile.ReplaceAll("raw.root", "mc.root"); // Parameter file TString parFile = inDigiFile; // Output file TString outFile = inDigiFile; inSimFile.ReplaceAll("raw.root", "mc.root"); parFile.ReplaceAll("raw.root", "param.root"); // ---- Load libraries ------------------------------------------------- TString basedir = gSystem->Getenv("VMCWORKDIR"); TStopwatch timer; timer.Start(); // ----- Digitization run ------------------------------------------- FairRunAna *fRun= new FairRunAna(); std::cout<<"Digifile:"<SetInputFile((char*)fp.getFile(i)); else fRun->AddFile((char*)fp.getFile(i)); //std::cout<<(char*)fp.getFile(i)<<"\n"; } TString filePattern=(char*)fp.getFile(0); TString mcPath=filePattern(0,filePattern.Last('/')); mcPath=mcPath(0,mcPath.Last('/')); TString fname=filePattern(filePattern.Last('/'),filePattern.Length()); fname.ReplaceAll("_splitraw.root",""); fname=fname(0,fname.Last('_')); fname+=".mc.root"; inSimFile = outFile = parFile = mcPath+fname; parFile.ReplaceAll("mc.root", "param.root"); } else { fRun->SetInputFile(inDigiFile); std::cout<<"Set Input File: "<0) outFile.ReplaceAll(".root",Form("_%04i.root",outnum)); if (outfolder!="NULL") { Ssiz_t beginn=outFile.Last('/'); Ssiz_t length=outFile.Length(); TSubString lastterm=outFile.operator()(beginn, length); TString outFile = outfolder+lastterm; } outFile.ReplaceAll(".root",".reco.root"); if (outfolderDes!="NULL") { Ssiz_t beginn=inSimFile.Last('/'); Ssiz_t length=inSimFile.Length(); TSubString lastterm=inSimFile.operator()(beginn, length); TString inSimFile = outfolderDes+lastterm; TString parFile = outfolderDes+lastterm; } fRun->AddFriend(inSimFile); std::cout<<"Set Friend MC File: "<SetOutputFile(outFile); std::cout<<"Set Output File: "<SetLogToScreen(kTRUE); //logger->SetLogScreenLevel("DEBUG4"); //logger->SetLogVerbosityLevel("HIGH"); // ----- Parameter database -------------------------------------------- std::cout<<"Create FairRuntimeDb"<GetRuntimeDb(); //ROOT Based parameter FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); parInput1->print(); //ASCII Based Parameter FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo(); TString tpcDigiFile = gSystem->Getenv("VMCWORKDIR"); tpcDigiFile += "/tpc/FOPI/par/tpc."; tpcDigiFile += field; tpcDigiFile += gas; tpcDigiFile += gain; tpcDigiFile +="MC.par"; std::cout<<"PARFILE:"<open(tpcDigiFile.Data(),"in"); rtdb->setFirstInput(parInput1); //rtdb->setSecondInput(parInput2); //TpcDigiPar* tpcpar = FairRun::Instance()->GetRuntimeDb()->getContainer("TpcDigiPar"); TpcDigiPar* tpcpar = (TpcDigiPar*) rtdb->getContainer("TpcDigiPar"); //tpcpar->setInputVersion(fRun->GetRunId(),1); PndGeoHandling* geoH = PndGeoHandling::Instance(); Double_t taroff = -65; Double_t targetpos = taroff+41.; // possible materials: copper (default), lead, carbon TString targetmat = TString("carbon"); //TString alignmentFileName = par->getAlignmentFile(); if (bfield==1) { std::cout<<"Setting Magnetic Field"<SetTargetOffset(taroff); fRun->SetField(fMagField); } else if (bfield==2) { std::cout<<"running with 0 Magnetic Field"<SetField(0., 0. , 0.616 ); // values are in kG fMagField->SetFieldRegion(-50, 50,-50, 50, -2000, 2000); // values are in cm fRun->SetField(fMagField); } else { std::cout<<"running with 0 Magnetic Field"<SetField(0., 0. , 0. ); // values are in kG fMagField->SetFieldRegion(-50, 50,-50, 50, -2000, 2000); // values are in cm fRun->SetField(fMagField); } //initialize GF field GFFieldManager::getInstance()->init(new PndFieldAdaptor(fRun->GetField())); GFMaterialEffects::getInstance()->init(new GFTGeoMaterialInterface()); // ------- RECO procedure ------------------------------------------------ std::cout<<"Setting up Event Counter"<AddTask(evCount); if (digiclcorr) { std::cout<<"Setting up cluster digi correction task"<SetDigiBranchName("TpcDigi"); tpcDC->SetUseDigis(); //tpcCC->SetClusterOutBranchName("TpcDigi"); tpcDC->SetDevMap(""); fRun->AddTask(tpcDC); } std::cout<<"Setting up ClusterFinderTAsk"<SetClusterBranchName("TpcCluster_raw"); else if (reclust) tpcCF->SetClusterBranchName("TpcPreCluster"); else tpcCF->SetClusterBranchName("TpcCluster"); tpcCF->SetDigiPersistence(persistence); // keep reference to digis in clusters tpcCF->SetPersistence(persistence); // keep Clusters tpcCF->timeslice(6); //in samples //tpcCF->SetThreshold(1); //tpcCF->SetSingleDigiClusterAmpCut(0.); tpcCF->SetClusterAmpCut(0.); // cut on mean digi amplitude if (reclust) tpcCF->SetErrorPars(-1.,22.); else tpcCF->SetErrorPars(fG,fC); //tpcCF->SetTrivialClustering(); //tpcCF->SetSimpleClustering(kFALSE); // do not use TpcClusterFinderSimple tpcCF->SetSimpleClustering(kTRUE); // use TpcClusterFinderSimple fRun->AddTask(tpcCF); if (clcorr) { std::cout<<"Setting up cluster correction task"<SetDigiBranchName("TpcDigi"); tpcCC->SetClusterBranchName("TpcCluster_raw"); if (reclust) tpcCC->SetClusterOutBranchName("TpcPreCluster"); else tpcCC->SetClusterOutBranchName("TpcCluster"); tpcCC->SetDevMap(""); tpcCC->SetPersistence(persistence); fRun->AddTask(tpcCC); } std::cout<<"Setting up Rieman Task"<SetClusterBranchName("TpcPreCluster"); else tpcSPR->SetClusterBranchName("TpcCluster"); tpcSPR->SetRiemannTrackBranchName("RiemannTrack"); tpcSPR->SetRiemannHitBranchName("RiemannHit"); //tpcSPR->SetPersistence(persistence); tpcSPR->SetSortingParameters(true,1,0); tpcSPR->SetTrkFinderParameters(proxc,helixc,3,proxZs); tpcSPR->SetVerbose(iVerbose); //tpcSPR->SetVerbose(1); fRun->AddTask(tpcSPR); std::cout<<"Setting up TrackInitTask"<SetPersistence(persistence); if (reclust) { trackInit->SetRiemannBranchName("RiemannTrack"); trackInit->SetTrackOutBranchName("TpcPreTrackPreFit"); trackInit->SetClusterBranchName("TpcPreCluster"); trackInit->SetRecoHitOutBranchName("TpcPreSPHit"); } else { trackInit->SetTrackOutBranchName("TpcTrackPreFit"); trackInit->SetClusterBranchName("TpcCluster"); trackInit->SetRecoHitOutBranchName("TpcSPHit"); } trackInit->SetCosmicSorting(); trackInit->SetVerbose(iVerbose); trackInit->SetPDG(13); trackInit->SetWeightedPlaneConstruction(weightedPlaneConstruction); trackInit->SetCutCov(cutCov); trackInit->SetSimulation(); trackInit->SetDipCut(0.05); if (smoothing==1) trackInit->SetSmoothing(true); //if(fG>0) //trackInit->SetUseFullCov(); fRun->AddTask(trackInit); if (reclust) { std::cout<<"Setting up KalmanTask 1"<SetTpcClusterBranchName("TpcPreSPHit"); kalman1->SetTrackBranchName("TpcPreTrackPreFit"); kalman1->SetOutBranchName("TrackPrePostFit"); kalman1->SetPersistence(persistence); kalman1->SetNumIterations(3); // number of fitting iterations (back and forth) kalman1->SetUseDAF(); fRun->AddTask(kalman1); std::cout<<"Setting up Reclusterizer"<SetTrackBranchName("TrackPrePostFit"); tpcReCl->SetClusterBranchName("TpcPreCluster"); tpcReCl->SetRecoHitBranchName("TpcPreSPHit"); tpcReCl->SetReClusterBranchName("TpcCluster"); //This error pars are either scaling the old standard error or steering the new error. fG: -1 std error; -2 unscaled shape cov; <0 scaled shape cov; >0 covOnPlane // fC just linearly scales the old standard error if fG==-1. otherwise its useless. tpcReCl->SetErrorPars(fG,fC); //set the reclustering fixed stepsize if (!varstep) tpcReCl->SetStepSize(1); //set the minimal cluster size in padhits. if a cluster would be smaller than this number the stepsize is doubled. tpcReCl->SetMinClusterSize(recl_min); //verbosity tpcReCl->SetVerbose(0); //persistency of SPHit and cluster and tracks tpcReCl->SetPersistence(persistence); //set to start reclustering at the firts digi. other posibility would be SetUseChamberEdge() to start at the edge of the tpc tpcReCl->SetUseFirstDigiPos(); if (varstep) { //set to use a square root dependent variable stepsize size=A+B*D*sqrt(z+off); D=diffusion constant tpcReCl->SetVarStepSqrt(); //the linear offset A tpcReCl->SetStepOff_sqrt(recl_off); //the factor B tpcReCl->SetFac(recl_fac); //tpcReCl->SetStepOff_0_sqrt(-62.5); //the offset off (deprecated) tpcReCl->SetStepOff_0_sqrt(0); std::cout<<"using sqrt approach"<SetUseCosmics(); //set this to also check if digis originally not belonging to the track should be checked if they are at a certain distance to the track. developement of this was stopped due to huge computing times causeb by noise. //tpcReCl->SetUseAllDigis(); //set to initialize new track. if not set a new pattern reco and track init task have to follow after reclusterizer. tpcReCl->SetTrackInit(); if(fG>0) //set this to give the found covariance matrix to the SPHit. if not done SPHit will use only XYZ errors and NO correlations. tpcReCl->SetUseFullCov(); //set to make the SPHit use the covariance matrix weighted detectorplane construction tpcReCl->SetWeightedPlaneConstruction(weightedPlaneConstruction); //set this to make the SPHit use the cut through the covariance instead the projection tpcReCl->SetCutCov(cutCov); if(clcorr) //set this to use the e-field based clusterposition corrrection. if no filename is given it will be read from the parameterfile. tpcReCl->SetClusterCorr(""); if ( scaler>=55 && fG>0 ) { //set this to use the padhit onto detplane projection method to calculate the error tpcReCl->SetUseOnPlaneCov(); } if(scaler==63 && fG>0) { //use the parametrization of the error directly inside the sphit tpcReCl->SetUseSPHitParam(useSPHitParamErr); } //set this to correct for small (2pad and 3pad) cluster. actually useless. //tpcReCl->SetSmallClusterCorr(); double corrParXY1[4*6]={2.76408e-02,-1.03886e+00,5.71669e+00,-1.29633e+01,1.35966e+01,-5.35287e+00, -1.25022e-01,-3.35926e-01,3.30173e+00,-7.26344e+00,7.42493e+00,-2.86672e+00, -1.44861e-01,-3.43595e-01,3.66492e+00,-8.49128e+00,9.16607e+00,-3.70415e+00, -2.38510e-01,-1.41061e-01,3.29007e+00,-6.98007e+00,7.05405e+00,-2.74203e+00}; double corrParXY2[4*6]={3.08616e-02,-4.80244e-01,2.94207e+00,-7.58296e+00,8.43231e+00,-3.37289e+00, -1.52434e-02,-3.46957e-01,2.91788e+00,-7.89718e+00,8.92806e+00,-3.57132e+00, -1.57970e-02,-6.31171e-01,4.93165e+00,-1.30991e+01,1.47170e+01,-5.88684e+00, -9.00679e-02,-8.28669e-01,7.36550e+00,-1.93725e+01,2.16922e+01,-8.67638e+00}; double corrParT1[6]={-1.68581e-02,-4.76058e-02,4.50379e-01,-9.88313e-01,1.03212e+00,-4.12863e-01}; double corrParT2[6]={-1.46991e-02,-3.70572e-02,6.16316e-01,-1.80067e+00,2.08467e+00,-8.33863e-01}; //set all used parameters for the small cluster correction tpcReCl->SetCorrParameterXY(corrParXY1); tpcReCl->SetCorrParameterXY2(corrParXY2); tpcReCl->SetCorrParameterT(corrParT1); tpcReCl->SetCorrParameterT2(corrParT2); if ((scaler==65 || scaler==66) && fG>0) tpcReCl->SetOnlyStep(); //set this to use a padresponse based correction of the padhit position. not working. dont use! //tpcReCl->SetRecalcDigiPos(); //a factor for the padresponse based correction of the padhit position. //tpcReCl->SetCorrFactor(1); //add the task fRun->AddTask(tpcReCl); } TpcAlignmentTask* align = new TpcAlignmentTask(); align->SetRecoHitBranchName("TpcSPHit"); //fRun->AddTask(align); std::cout<<"Setting up KalmanTask 2"<SetTpcClusterBranchName("TpcSPHit"); kalman2->SetTrackBranchName("TpcTrackPreFit"); kalman2->SetOutBranchName("TrackPostFit"); kalman2->SetPersistence(persistence); kalman2->SetNumIterations(3); // number of fitting iterations (back and forth) //kalman2->SetVerbose(iVerbose); kalman2->SetVerbose(0); kalman2->SetUseDAF(); fRun->AddTask(kalman2); if(useSPHitParamErr && (fG > 0) && (scaler==63)) { TpcClusterErrorRecalcTask* clErrRec=new TpcClusterErrorRecalcTask(); fRun->AddTask(clErrRec); } std::cout<<"Setting up CosmicTask 2"<SetTpcPointBranchName("TpcPoint"); Cos->SetClusterBranchName("TpcCluster"); Cos->SetTrackBranchName("TrackPostFit"); Cos->SetPersistence(); Cos->SetNumberOfTrackReps(1); // set to 2 if you use GeaneTrackrep (tpcSPR->useGeane();) //Cos->SetVerbose(0); Cos->SetEventCounter(nEvStart); if (smoothing==1) Cos->SetUnbiased(); if (cutCov) Cos->SetCutCov(); Cos->SetAddGTrack(); Cos->SetDoDigiMC(); fRun->AddTask(Cos); std::cout<<"Setting up ana Task\n"<SetCosmics(); //tpcTrCl->SetThetaCut(40,140); tpcTrCl->SetClMeanCut(400); //tpcTrCl->SetPhiCut(70,110); tpcTrCl->SetVerbose(iVerbose); //tpcTrCl->SetVerbose(1); tpcTrCl->SetKeepDelTracks(); fRun->AddTask(tpcTrCl); // ----- Intialise and run -------------------------------------------- std::cout<<"Initialising run"<Init(); // Initialize the Digimapper: tpcpar->setChanged(kTRUE); tpcpar->init(); TpcAlignmentManager::init(tpcpar->getAlignmentFile()); TpcAlignmentManager::getInstance(); //create an instance of the singleton ClusterErrorScaler. Be aware that the second number is there to steer the cluster error scaler. The default is set to read the lookup file. switch (scaler) { case 0: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.physNO1.86.par",0); break; case 10: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.phys.86.par",0); break; case 1: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.physNum.86.par",0); break; case 15: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.physNumProj.86.par",0); break; case 4: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.physMeanUV.86.par",4); break; case 44: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.physMeanUVcut.86.par",4); break; case 20: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.exp.86.par",20); break; case 55: break; case 56: TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/error_lookup.txt",56); break; case 57: //TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.pol.86.num.par",57); TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/error_lookup_num.txt",56); break; case 61: //parametrization in XYZ and cut by plane TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorParam.86.par",61); break; case 62: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorParam_fitOnly.86.par",61); break; case 63: //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28534_target_fitCovOnPlane_cut_firstIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28543_target_fitCovOnPlane_cut_secondIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28544_target_fitCovOnPlane_cut_thirdIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28548_target_fitCovOnPlane_cut_firstIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28551_target_fitCovOnPlane_cut_secondIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28551_target_fitCovOnPlane_cut_thirdIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28564_target_fitCovOnPlane_cut_firstIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28571_target_fitCovOnPlane_cut_firstIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28572_target_fitCovOnPlane_cut_secondIteration_param.txt",61); //TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28576_target_fitCovOnPlane_cut_thirdIteration_param.txt",61); TpcClusterErrorScaler::getInstance()->init("./outfiles_e12/bat/bat_rev28591_target_fitCovOnPlane_cut_fourthIteration_param.txt",61); break; case 65: break; case 66: break; case 98: TpcClusterErrorScaler::getInstance()->init("./tpc/FOPI/par/tpc.errorScale.recl.Ax1_1000.par",0); break; case 99: TpcClusterErrorScaler::getInstance()->init("",-1); break; } TpcDigiMapper::getInstance()->init(tpcpar); //this two are neccessary to silence RooFit. RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); RooMsgService::instance().setSilentMode(true); //GFMaterialEffects::getInstance()->setNoEffects(); std::cout<<"Number of events to process:"<Run(nEvStart, nEvents); rtdb->saveOutput(); rtdb->print(); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); std::cout << std::endl << std::endl; std::cout << "Macro finished succesfully." << std::endl; std::cout << "Output file is " << outFile << std::endl; std::cout << "Parameter file is " << parFile << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; std::cout << std::endl; // ------------------------------------------------------------------------ std::cout<<"OutputFile: "<