void run_reco( TString mcEngine="TGeant3" ) { FairLogger *logger = FairLogger::GetLogger(); logger->SetLogFileName("MyLog.log"); logger->SetLogToScreen(kTRUE); // logger->SetLogToFile(kTRUE); logger->SetLogVerbosityLevel("LOW"); // logger->SetLogFileLevel("DEBUG4"); logger->SetLogScreenLevel("INFO"); // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 0; // just forget about it, for the moment // Input file (MC events) TString inFile = "data/testdigi_"; inFile = inFile + mcEngine + ".root"; // Parameter file TString parFile = "data/testparams_"; parFile = parFile + mcEngine + ".root"; // Output file TString outFile = "data/testreco_"; outFile = outFile + mcEngine + ".root"; // ----- Timer -------------------------------------------------------- TStopwatch timer; // ----- Reconstruction run ------------------------------------------- FairRunAna *fRun= new FairRunAna(); fRun->SetInputFile(inFile); fRun->SetOutputFile(outFile); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); rtdb->setFirstInput(parInput1); // ----- TorinoDetector hit producers --------------------------------- FairTestDetectorRecoTask* hitProducer = new FairTestDetectorRecoTask(); fRun->AddTask(hitProducer); fRun->Init(); timer.Start(); fRun->Run(); // ----- 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); }
void makeDummy(const Int_t nEvents = 10) { gRandom -> SetSeed(time(0)); //TString dir = gSystem->Getenv("SPIRITDIR"); //TString geomdir = dir + "/geometry"; //gSystem->Setenv("GEOMPATH", geomdir.Data()); FairLogger *logger = FairLogger::GetLogger(); logger->SetLogToScreen(kTRUE); logger->SetLogVerbosityLevel("MEDIUM"); TString outFile = "mc.dummy.root"; TString parFile = "param.dummy.root"; // ----- Create simulation run ---------------------------------------- // FairRunSim* run = new FairRunSim(); run->SetName("TGeant4"); // Transport engine run->SetOutputFile(outFile); // Output file run->SetWriteRunInfoFile(kFALSE); FairRuntimeDb* rtdb = run->GetRuntimeDb(); ATVertexPropagator* vertex_prop = new ATVertexPropagator(); // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- /*FairModule* cave= new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); run->AddModule(cave); FairModule* target= new FairTarget("SnTarget"); target->SetGeometryFileName("target.geo"); run->AddModule(target); FairDetector* spirit = new STDetector("STDetector", kTRUE); spirit->SetGeometryFileName("spirit_v03.1.root"); run->AddModule(spirit);*/ FairModule* cave= new AtCave("CAVE"); cave->SetGeometryFileName("cave.geo"); run->AddModule(cave); FairModule* magnet = new AtMagnet("Magnet"); run->AddModule(magnet); FairModule* pipe = new AtPipe("Pipe"); run->AddModule(pipe); FairDetector* ATTPC = new AtTpc("ATTPC", kTRUE); ATTPC->SetGeometryFileName("ATTPC_v1.1.root"); //ATTPC->SetModifyGeometry(kTRUE); run->AddModule(ATTPC); // ------------------------------------------------------------------------ run->SetMaterials("media.geo"); // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator *primGen = new FairPrimaryGenerator(); FairParticleGenerator *particleGen = new FairParticleGenerator(2112, 1, 0, 0, 0, 0, 0, 0); primGen->AddGenerator(particleGen); run->SetGenerator(primGen); /* Int_t dnum=7; const int gennum=pid[dnum].size(); cout << gennum << endl; FairParticleGenerator *fIongen[gennum]; for (Int_t i=0; i<gennum; i++) { fIongen[i] = new FairParticleGenerator(pid[dnum][i],1,pxl[dnum][i],pyl[dnum][i],pzl[dnum][i],0.0,-21.33,-3.52); //cout << pid[dnum][i] << "\t" << pxl[dnum][i] << "\t" << pyl[dnum][i] << "\t" << pzl[dnum][i] << "\t" << kinl[dnum][i] << endl; primGen->AddGenerator(fIongen[i]); } //primGen->AddTrack(pdg,pionpC[0][i],pionpC[1][i],pionpC[2][i],pionrC[0][i]*1.0E-13,pionrC[1][i]*1.0E-13-21.33,pionrC[2][i]*1.0E-13-3.52); //fIongen[i] = new FairParticleGenerator(pdg,1,pionpC[0][i],pionpC[1][i],pionpC[2][i],pionrC[0][i]*1.0E-13,pionrC[1][i]*1.0E-13-21.33,pionrC[2][i]*1.0E-13-3.52); //fIongen[i] = new FairParticleGenerator(pdg,1,px,py,pz,0.0,-21.33,-3.52); //primGen->AddGenerator(fIongen[i]); //primGen->AddTrack(pdg,pionpC[0][i],pionpC[1][i],pionpC[2][i],pionrC[0][i]*1.0E-13,pionrC[1][i]*1.0E-13-21.33,pionrC[2][i]*1.0E-13-3.52); //} //} // if (partt==0) FairBoxGenerator* boxGen1 = new FairBoxGenerator(2212, 1); // if (partt==1) FairBoxGenerator* boxGen1 = new FairBoxGenerator(1000010020, 1); // if (partt==2) FairBoxGenerator* boxGen1 = new FairBoxGenerator(1000010030, 1); // if (partt==3) FairBoxGenerator* boxGen1 = new FairBoxGenerator(1000020030, 1); // if (partt==4) FairBoxGenerator* boxGen1 = new FairBoxGenerator(1000020040, 1); // if (partt==5) FairBoxGenerator* boxGen1 = new FairBoxGenerator(211, 1); // if (partt==6) FairBoxGenerator* boxGen1 = new FairBoxGenerator(-211, 1); // if (partt==7) FairBoxGenerator* boxGen1 = new FairBoxGenerator(11, 1); // if (partt==8) FairBoxGenerator* boxGen1 = new FairBoxGenerator(-11, 1); // //FairBoxGenerator* boxGen1 = new FairBoxGenerator(1000020040, 1); // boxGen1->SetPRange(0.25,0.5); //GeV/c ?? // boxGen1->SetPhiRange(0.,360.); //degrees // boxGen1->SetThetaRange(0.,90.); //degrees // boxGen1->SetXYZ(0.,-21.33, -3.52); // cm // primGen->AddGenerator(boxGen1); // ------------------------------------------------------------------------ run->SetStoreTraj(kTRUE); */ // ----- Run initialisation ------------------------------------------- run->Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- run->Run(nEvents); // ----- Finish ------------------------------------------------------- }
/******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ void run_reco( TString mcEngine="TGeant3", Bool_t AlignDone=true ) { // ---- Load libraries ------------------------------------------------- FairLogger *logger = FairLogger::GetLogger(); // logger->SetLogFileName("MyLog.log"); logger->SetLogToScreen(kTRUE); // logger->SetLogToFile(kTRUE); // logger->SetLogVerbosityLevel("HIGH"); // logger->SetLogFileLevel("DEBUG4"); logger->SetLogScreenLevel("INFO"); // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 0; // just forget about it, for the moment TString Align= ""; if (AlignDone) { Align= "align_"; } TString InDir = "./data/"; // Input file (MC Events) TString inFile ="testrun_"; inFile = InDir +inFile + Align + mcEngine + ".root"; // Output file name TString outFile ="testreco_"; outFile = InDir + outFile + Align + mcEngine + ".root"; // Parameter file TString parFile ="testparams_"; parFile = InDir + parFile + Align + mcEngine + ".root"; // Millepede file name TString milleFile ="testmille_"; milleFile = InDir + milleFile + Align + mcEngine; TList *parFileList = new TList(); TString workDir = gSystem->Getenv("VMCWORKDIR"); TString paramDir = workDir + "/simulation/Tutorial4/parameters/"; TString paramFile = paramDir + "example.par"; TObjString tutDetDigiFile; tutDetDigiFile.SetString(paramFile); parFileList->Add(&tutDetDigiFile); // ----- Timer -------------------------------------------------------- TStopwatch timer; // ----- Reconstruction run ------------------------------------------- FairRunAna *fRun= new FairRunAna(); FairFileSource *fFileSource = new FairFileSource(inFile); fRun->SetSource(fFileSource); fRun->SetSink(new FairRootFileSink(outFile)); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); parIo2->open(parFileList, "in"); parInput1->open(parFile.Data()); parIo2->open(parFileList, "in"); rtdb->setFirstInput(parInput1); rtdb->setSecondInput(parIo2); rtdb->setOutput(parInput1); rtdb->saveOutput(); // ----- TorinoDetector hit producers --------------------------------- FairTutorialDet4HitProducerIdealMisalign* hitProducer = new FairTutorialDet4HitProducerIdealMisalign(); hitProducer->DoMisalignment(kFALSE); fRun->AddTask(hitProducer); FairTutorialDet4StraightLineFitter* fitter = new FairTutorialDet4StraightLineFitter(); fitter->SetVersion(2); fRun->AddTask(fitter); FairTutorialDet4MilleWriter* writer = new FairTutorialDet4MilleWriter(); // writer->SetWriteAscii(kTRUE); writer->SetVersion(2); writer->SetFileName(milleFile); fRun->AddTask(writer); fRun->Init(); timer.Start(); fRun->Run(); // ----- Finish ------------------------------------------------------- cout << endl << endl; // Extract the maximal used memory an add is as Dart measurement // This line is filtered by CTest and the value send to CDash FairSystemInfo sysInfo; Float_t maxMemory=sysInfo.GetMaxMemory(); cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; cout << maxMemory; cout << "</DartMeasurement>" << endl; timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); Float_t cpuUsage=ctime/rtime; cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; cout << cpuUsage; cout << "</DartMeasurement>" << endl; cout << endl << endl; cout << "Output file is " << outFile << endl; cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; cout << "Macro finished successfully." << endl; // ------------------------------------------------------------------------ }
void run_rad(Int_t nEvents = 100, TString mcEngine="TGeant3") { TString dir = gSystem->Getenv("VMCWORKDIR"); TString tutdir = dir + "/rutherford/macros"; TString tut_geomdir = dir + "/geometry"; gSystem->Setenv("GEOMPATH",tut_geomdir.Data()); TString tut_configdir = dir + "/gconfig"; gSystem->Setenv("CONFIG_DIR",tut_configdir.Data()); TString outDir = "data"; TString outFile = outDir + "/test1_"; outFile = outFile + mcEngine + ".mc.root"; TString parFile = outDir + "/params1_"; parFile = parFile + mcEngine + ".root"; // In general, the following parts need not be touched // ======================================================================== // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ FairLogger *logger = FairLogger::GetLogger(); // define log file name logger->SetLogFileName("MyLog.log"); // log to screen and to file logger->SetLogToScreen(kTRUE); logger->SetLogToFile(kTRUE); // Print very accurate output. Levels are LOW, MEDIUM and HIGH logger->SetLogVerbosityLevel("HIGH"); // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName(mcEngine); // Transport engine run->SetOutputFile(outFile); // Output file FairRuntimeDb* rtdb = run->GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- run->SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ //----Start the radiation length manager ---------------------------------- run->SetRadLenRegister(kTRUE); // ----- Create geometry ---------------------------------------------- FairModule* cave= new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); run->AddModule(cave); FairModule* target= new FairTarget("Target"); target->SetGeometryFileName("target_rutherford.geo"); run->AddModule(target); FairDetector* rutherford = new FairRutherford("RutherfordDetector", kFALSE); rutherford->SetGeometryFileName("rutherford.geo"); run->AddModule(rutherford); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); run->SetGenerator(primGen); FairBoxGenerator* boxGen1 = new FairBoxGenerator(0, 1); boxGen1->SetPRange(.005,.005); boxGen1->SetPhiRange(0.,0.); boxGen1->SetThetaRange(-90.,90.); boxGen1->SetXYZ(0.,0.,-3.); primGen->AddGenerator(boxGen1); // ------------------------------------------------------------------------ run->SetStoreTraj(kTRUE); // ----- Run initialisation ------------------------------------------- run->Init(); // ------------------------------------------------------------------------ // Set cuts for storing the trajectories. // Switch this on only if trajectories are stored. // Choose this cuts according to your needs, but be aware // that the file size of the output file depends on these cuts FairTrajFilter* trajFilter = FairTrajFilter::Instance(); // trajFilter->SetStepSizeCut(0.01); // 1 cm // trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.); // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV // trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV trajFilter->SetStorePrimaries(kTRUE); trajFilter->SetStoreSecondaries(kTRUE); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- run->Run(nEvents); // ------------------------------------------------------------------------ run->CreateGeometryFile("data/geofile_full.root"); // ----- 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 << endl; // ------------------------------------------------------------------------ }