void runMCFOPI_AlignmentTest(TString outdir, int nEvents=1, Int_t run = 0, bool field, unsigned int seed=0,bool target=true, int jobset=0) { // ------------------------------------------------------------------------ gRandom->SetSeed(seed); gROOT->ProcessLine(".x $VMCWORKDIR/gconfig/rootlogon.C"); // ======================================================================== // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 1; FairRunSim *fRun = new FairRunSim(); // set the MC version used // -------------------------------------------------- TString mcMode = "TGeant3"; fRun->SetName(mcMode); TString jobdir=outdir; int length = jobdir.Length(); if(jobdir[length-1] != "/") jobdir.Append("/"); TString jobname; if(jobset!=0){ jobname=Form("AlignmentTest_set%i_run%i.mc.root",jobset,run); }else{ jobname=Form("AlignmentTest_%i.mc.root",run); } TString outfile = jobdir+jobname; std::cout<SetOutputFile(outfile); std::cout<<"Set output file to "<Getenv("VMCWORKDIR"); if(jobset!=0){ digifile += Form("/tpc/FOPI/par/tpc.gibuu_sverre_al%i.par",jobset); }else{ digifile += Form("/tpc/FOPI/par/tpc.alignmentTest_sverre.par",jobset); } cout<SetLogScreenLevel("WARNING"); FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(digifile.Data(),"in"); rtdb->setFirstInput(parIo1); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* parOut=new FairParRootFileIo(kParameterMerged); parOut->open(parfile.Data()); rtdb->setOutput(parOut); TpcDigiPar* par = (TpcDigiPar*) rtdb->getContainer("TpcDigiPar"); par->setInputVersion(fRun->GetRunId(),1); par->setChanged(kTRUE); std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<init(); std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<getAlignmentFile(); TString geoFile; TString command; TString tpcGeoName=TString::Format("FOPI_TPC_%i.root",run); TString targetGeoName=TString::Format("FOPI_TARGET_%i.root",run); // TString targetGeoName=TString::Format("FOPI_TPC_SHIELD.root",run); command.Form(".! root -b -q '$VMCWORKDIR/macro/tpc/FOPI/make_TPC_geo.C(kTRUE,\"%s\",false,\"\",\"%s\")'",alignmentFileName.Data() ,tpcGeoName.Data()); cout<ProcessLine(command); TString command2; command2.Form(".! root -b -q '$VMCWORKDIR/macro/tpc/FOPI/make_FOPI_target.C(\"%s\",false,\"\",\"%s\")'",targetmat.Data(),targetGeoName.Data()); cout<ProcessLine(command2); TString command3; // command3.Form(".! root -b -q '$VMCWORKDIR/macro/tpc/FOPI/make_shield_geo.C(kTRUE,\"%s\")'",alignmentFileName.Data()); // command3.Form(".! root -b -q '$VMCWORKDIR/macro/tpc/FOPI/make_shield_geo.C()'"); // cout<ProcessLine(command); // In general, the following parts need not be touched // ======================================================================== // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // Set Material file Name //----------------------- fRun->SetMaterials("media_pnd.geo"); // Create and add detectors //------------------------- // FairModule *Cave= new FopiDetector("FOPI"); // Cave->SetGeometryFileName(geoFile); // fRun->AddModule(Cave); FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); FairModule* fopitarget= (FairModule*) new FopiTarget("fopitarget","fopi target"); fopitarget->SetGeometryFileName(targetGeoName); fRun->AddModule(fopitarget); TpcDetector *Tpc = new TpcDetector("TPC", kTRUE); //Tpc->SetGeometryFileName(geoFileName); Tpc->SetGeometryFileName(tpcGeoName); Tpc->SetMixture("TPCmixture"); // TPCmixture: Neon CO2 (90/10) //NEEDS TO BE IMPLEMENTED!! if(mcMode=="TGeant3") Tpc->SetAliMC(); fRun->AddModule(Tpc); TpcShield* TpcShield = new TpcShield("SHIELD", kTRUE); TpcShield->SetGeometryFileName("FOPI_TPC_SHIELD.root"); fRun->AddModule(TpcShield); FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); TpcAsciiGiBUUGenerator* gibuuGen = new TpcAsciiGiBUUGenerator("/scratch/sdorheim/FOPI/GiBUU/piCarbon11.dat"); // gibuuGen->SetStartEvent(220063); //Ordering of next two calls important! // gibuuGen->ParticleFilter(3122); gibuuGen->SetStartEvent(nEvents*run); gibuuGen->SetTargetThickness(0); gibuuGen->SetVetoRadius(0); primGen->AddGenerator(gibuuGen); // Create and Set Magnetic Field // -------------------- // Constant Field if(!field){ PndConstField *fMagField=new PndConstField(); fMagField->SetField(0., 0. , 0. ); // values are in kG fMagField->SetFieldRegion(-50, 50,-50, 50, -2000, 2000); // values are in cm fRun->SetField(fMagField); }else{ FOPIField *fMagField = new FOPIField(0.616); fMagField->SetTargetOffset(taroff); fRun->SetField(fMagField); } /**Initialize the session*/ fRun->Init(); // PndStack* stack = (PndStack*) gMC->GetStack(); // stack->StoreSecondaries(kTRUE) // stack->SetMinPoints(0) // stack->SetEnergyCut(0) // stack->StoreMothers(kTRUE) // Initialize the Digimapper: // TpcDigiPar* tpcpar = FairRun::Instance()->GetRuntimeDb()->getContainer("TpcDigiPar"); // TpcDigiMapper::getInstance()->init(tpcpar); // //TpcDigiMapper::getInstance()->forceManualDriftVel(forceDriftVel); // TpcAlignmentManager::init(tpcpar->getAlignmentFile()); rtdb->saveOutput(); rtdb->print(); // Transport nEvents // ----------------- fRun->Run(nEvents); 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; cout << endl; // ------------------------------------------------------------------------ }