void prod_pid_mva(TString outpre="", int ev=0) { // Macro created 02/10/2012 by S.Spataro // It loads a reconstruction file and compute PID informations // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 0; // just forget about it, for the moment // Number of events to process Int_t nEvents = ev; // if 0 all the vents will be processed // Parameter file TString parFile = outpre+"_par.root"; // at the moment you do not need it // Digitisation file (ascii) TString digiFile = "all.par"; // Output file TString outFile = outpre+"_pidmva.root"; // ----- Timer -------------------------------------------------------- TStopwatch timer; // ------------------------------------------------------------------------ // ----- Reconstruction run ------------------------------------------- FairRunAna *fRun= new FairRunAna(); fRun->SetInputFile(outpre+"_sim.root"); fRun->AddFriend(outpre+"_dig.root"); fRun->AddFriend(outpre+"_rec.root"); fRun->SetOutputFile(outFile); fRun->SetWriteRunInfoFile(kFALSE); FairGeane *Geane = new FairGeane(); fRun->AddTask(Geane); // ----- Parameter database -------------------------------------------- TString emcDigiFile = gSystem->Getenv("VMCWORKDIR"); emcDigiFile += "/macro/params/"; emcDigiFile += digiFile; FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(emcDigiFile.Data(),"in"); rtdb->setFirstInput(parInput1); rtdb->setSecondInput(parIo1); // ------------------------------------------------------------------------ PndPidCorrelator* corr = new PndPidCorrelator(); //corr->SetVerbose(); corr->SetInputBranch("SttMvdGemGenTrack"); corr->SetInputIDBranch("SttMvdGemGenTrackID"); corr->SetInputBranch2("FtsIdealGenTrack"); corr->SetInputIDBranch2("FtsIdealGenTrackID"); //corr->SetDebugMode(kTRUE); //corr->SetFast(kTRUE); fRun->AddTask(corr); PndMcCloner *clone = new PndMcCloner(); fRun->AddTask(clone); PndPidIdealAssociatorTask *assMC= new PndPidIdealAssociatorTask(); fRun->AddTask(assMC); PndPidMvdAssociatorTask *assMvd= new PndPidMvdAssociatorTask(); fRun->AddTask(assMvd); PndPidMdtHCAssociatorTask *assMdt= new PndPidMdtHCAssociatorTask(); fRun->AddTask(assMdt); PndPidDrcAssociatorTask *assDrc= new PndPidDrcAssociatorTask(); fRun->AddTask(assDrc); PndPidDiscAssociatorTask *assDisc= new PndPidDiscAssociatorTask(); fRun->AddTask(assDisc); PndPidSttAssociatorTask *assStt= new PndPidSttAssociatorTask(); fRun->AddTask(assStt); PndPidEmcBayesAssociatorTask *assEMC= new PndPidEmcBayesAssociatorTask(); fRun->AddTask(assEMC); // *** MVA std::vector labels; std::vector vars; // Class names labels.push_back("electron"); labels.push_back("muon"); labels.push_back("pion"); labels.push_back("kaon"); labels.push_back("proton"); // Variable names vars.push_back("p"); vars.push_back("tht"); vars.push_back("emc"); vars.push_back("lat"); vars.push_back("z20"); vars.push_back("stt"); vars.push_back("thetaC"); TString weights= gSystem->Getenv("VMCWORKDIR"); weights += "/macro/prod/PANDA_BDTG_Method.weights.xml"; PndPidMvaAssociatorTask *assMVA = new PndPidMvaAssociatorTask(); assMVA->SetWeightFileName(weights.Data()); assMVA->SetClassNames(labels); assMVA->SetVarNames(vars); assMVA->SetClassifier(TMVA_BDT); fRun->AddTask(assMVA); // ----- Intialise and run -------------------------------------------- PndEmcMapper::Init(1); cout << "fRun->Init()" << endl; fRun->Init(); timer.Start(); fRun->Run(0,nEvents); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished successfully." << 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; // ------------------------------------------------------------------------ cout << " Test passed" << endl; cout << " All ok " << endl; //exit(0); }