void run_sim() { TString transport = "TGeant4"; Bool_t userPList = kFALSE; // option for TGeant4 TString outFile = "sim.root"; TString parFile = "par.root"; Bool_t magnet = kTRUE; Float_t fieldScale = -0.68; TString generator1 = "box"; TString generator2 = "ascii"; TString generator3 = "r3b"; TString generator = generator1; TString inputFile = ""; Int_t nEvents = 1; Bool_t storeTrajectories = kTRUE; Int_t randomSeed = 335566; // 0 for time-dependent random numbers // Target type TString target1 = "LeadTarget"; TString target2 = "Para"; TString target3 = "Para45"; TString target4 = "LiH"; TString targetType = target4; // ------------------------------------------------------------------------ // Stable part ------------------------------------------------------------ TString dir = getenv("VMCWORKDIR"); // ---- Debug option ------------------------------------------------- gDebug = 0; // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName(transport); // Transport engine run->SetOutputFile(outFile.Data()); // Output file FairRuntimeDb* rtdb = run->GetRuntimeDb(); // R3B Special Physics List in G4 case if ((userPList == kTRUE) && (transport.CompareTo("TGeant4") == 0)) { run->SetUserConfig("g4R3bConfig.C"); run->SetUserCuts("SetCuts.C"); } // ----- Create media ------------------------------------------------- run->SetMaterials("media_r3b.geo"); // Materials // ----- Create R3B geometry -------------------------------------------- // R3B Cave definition FairModule* cave = new R3BCave("CAVE"); cave->SetGeometryFileName("r3b_cave.geo"); run->AddModule(cave); // To skip the detector comment out the line with: run->AddModule(... // Target run->AddModule(new R3BTarget(targetType, "target_" + targetType + ".geo.root")); // GLAD //run->AddModule(new R3BGladMagnet("glad_v17_flange.geo.root")); // GLAD should not be moved or rotated // PSP run->AddModule(new R3BPsp("psp_v13a.geo.root", {}, -221., -89., 94.1)); // R3B SiTracker Cooling definition //run->AddModule(new R3BVacVesselCool(targetType, "vacvessel_v14a.geo.root")); // STaRTrack //run->AddModule(new R3BSTaRTra("startra_v16-300_2layers.geo.root", { 0., 0., 20. })); // CALIFA R3BCalifa* califa = new R3BCalifa("califa_10_v8.11.geo.root"); califa->SelectGeometryVersion(10); // Selecting the Non-uniformity of the crystals (1 means +-1% max deviation) califa->SetNonUniformity(1.0); //run->AddModule(califa); // Tof //run->AddModule(new R3BTof("tof_v17a.geo.root", { -417.359574, 2.400000, 960.777114 }, { "", -90., +31., 90. })); // mTof run->AddModule(new R3BmTof("mtof_v17a.geo.root", { -155.824045, 0.523976, 761.870346 }, { "", -90., +16.7, 90. })); // MFI //run->AddModule(new R3BMfi("mfi_v17a.geo.root", { -63.82, 0., 520.25 }, { "", 90., +13.5, 90. })); // s412 // NeuLAND // run->AddModule(new R3BNeuland("neuland_test.geo.root", { 0., 0., 1400. + 12 * 5. })); // ----- Create R3B magnetic field ---------------------------------------- // NB: <D.B> // If the Global Position of the Magnet is changed // the Field Map has to be transformed accordingly R3BGladFieldMap* magField = new R3BGladFieldMap("R3BGladMap"); magField->SetScale(fieldScale); if (magnet == kTRUE) { run->SetField(magField); } else { run->SetField(NULL); } // ----- Create PrimaryGenerator -------------------------------------- // 1 - Create the Main API class for the Generator FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); if (generator.CompareTo("box") == 0) { FairIonGenerator* boxGen = new FairIonGenerator(50, 128, 50, 1, 0., 0., 1.3, 0., 0., 0.); primGen->AddGenerator(boxGen); } if (generator.CompareTo("ascii") == 0) { R3BAsciiGenerator* gen = new R3BAsciiGenerator((dir + "/input/" + inputFile).Data()); primGen->AddGenerator(gen); } run->SetGenerator(primGen); run->SetStoreTraj(storeTrajectories); FairLogger::GetLogger()->SetLogVerbosityLevel("LOW"); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); // ----- Initialize simulation run ------------------------------------ run->Init(); TVirtualMC::GetMC()->SetRandom(new TRandom3(randomSeed)); // ------ Increase nb of step for CALO Int_t nSteps = -15000; TVirtualMC::GetMC()->SetMaxNStep(nSteps); // ----- Runtime database --------------------------------------------- R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar"); if (NULL != magField) { fieldPar->SetParameters(magField); fieldPar->setChanged(); } Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ----- Start run ---------------------------------------------------- if (nEvents > 0) { run->Run(nEvents); } // ----- 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; cout << " Test passed" << endl; cout << " All ok " << endl; // Snap a picture of the geometry // If this crashes, set "OpenGL.SavePicturesViaFBO: no" in your .rootrc /*gStyle->SetCanvasPreferGL(kTRUE); gGeoManager->GetTopVolume()->Draw("ogl"); TGLViewer* v = (TGLViewer*)gPad->GetViewer3D(); v->SetStyle(TGLRnrCtx::kOutline); v->RequestDraw(); v->SavePicture("run_sim-side.png"); v->SetPerspectiveCamera(TGLViewer::kCameraPerspXOZ, 25., 0, 0, -90. * TMath::DegToRad(), 0. * TMath::DegToRad()); v->SavePicture("run_sim-top.png");*/ }
void run_sample_data() { TStopwatch timer; timer.Start(); const Int_t nev = -1; // number of events to read, -1 - untill CTRL+C const Int_t trigger = -1; // 1 - onspill, 2 - offspill. -1 - all TString filename = "sample_data_2.lmd"; TString outputFileName = "output_raw_land.root"; // name of output file const Int_t refresh = 100000; // refresh rate for saving control histograms TString parFileName = "params_raw_land.root"; // name of parameter file const Int_t updateRate = 150000; const Int_t minStats = 10000; // minimum number of entries for TCAL calibration const Int_t nModules = 800; // number of photomultipliers (for TCAL calibration) // Create source with unpackers ---------------------------------------------- TString ntuple_options = "UNPACK:EVENTNO,UNPACK:TRIGGER,RAW"; TString ucesb_dir = getenv("UCESB_DIR"); TString ucesb_path = ucesb_dir + "/../upexps/s438b/s438b"; EXT_STR_h101 ucesb_struct; R3BUcesbSource* source = new R3BUcesbSource(filename, ntuple_options, ucesb_path, &ucesb_struct, sizeof(ucesb_struct)); source->SetMaxEvents(nev); source->AddReader(new R3BUnpackReader((EXT_STR_h101_unpack*)&ucesb_struct.unpack, offsetof(EXT_STR_h101, unpack))); source->AddReader(new R3BNeulandTacquilaReader((EXT_STR_h101_raw_nnp*)&ucesb_struct.nnp, offsetof(EXT_STR_h101, nnp))); source->AddReader(new R3BLosReader((EXT_STR_h101_LOS*)&ucesb_struct.los, offsetof(EXT_STR_h101, los))); // --------------------------------------------------------------------------- // Create online run --------------------------------------------------------- FairRunOnline* run = new FairRunOnline(source); run->SetOutputFile(outputFileName.Data()); run->SetRunId(1111); // --------------------------------------------------------------------------- // Create ALADIN field map --------------------------------------------------- R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps"); Double_t fMeasCurrent = 2500.; // I_current [A] magField->SetCurrent(fMeasCurrent); magField->SetScale(1.); run->SetField(magField); // --------------------------------------------------------------------------- // TCAL ---------------------------------------------------------------------- R3BNeulandMapped2CalPar* tcalFill = new R3BNeulandMapped2CalPar("TcalFill"); tcalFill->SetUpdateRate(updateRate); tcalFill->SetMinStats(minStats); tcalFill->SetTrigger(trigger); tcalFill->SetNofModules(nModules); run->AddTask(tcalFill); R3BLosMapped2CalPar* losTcalFill = new R3BLosMapped2CalPar("LosTcalFill"); losTcalFill->SetUpdateRate(updateRate); losTcalFill->SetMinStats(minStats); losTcalFill->SetNofModules(1, 4); run->AddTask(losTcalFill); // --------------------------------------------------------------------------- // Add analysis task --------------------------------------------------------- R3BNeulandMappedHist* ana = new R3BNeulandMappedHist("LandRawAna", 1); run->AddTask(ana); // --------------------------------------------------------------------------- // Initialize ---------------------------------------------------------------- run->Init(); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); // --------------------------------------------------------------------------- // Runtime data base --------------------------------------------------------- FairRuntimeDb* rtdb = run->GetRuntimeDb(); R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFileName); rtdb->setOutput(parOut); rtdb->print(); // --------------------------------------------------------------------------- // Run ----------------------------------------------------------------------- if(nev < 0) { run->Run(nev, 0); } else { run->Run(0, nev); } rtdb->saveOutput(); // --------------------------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outputFileName << endl; cout << "Parameter file is " << parFileName << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; if(ana->GetNItemsTotal() > 3800) { cout << " Test passed" << endl; cout << " All ok " << endl; } delete run; }
void r3ball(Int_t nEvents = 1, TMap& fDetList, TString Target = "LeadTarget", Bool_t fVis = kFALSE, TString fMC = "TGeant3", TString fGenerator = "box", Bool_t fUserPList = kFALSE, Bool_t fR3BMagnet = kTRUE, Bool_t fCalifaHitFinder = kFALSE, Bool_t fStarTrackHitFinder = kFALSE, Double_t fMeasCurrent = 2000., TString OutFile = "r3bsim.root", TString ParFile = "r3bpar.root", TString InFile = "evt_gen.dat", double energy1, double energy2) { TString dir = getenv("VMCWORKDIR"); TString r3bdir = dir + "/macros"; TString r3b_geomdir = dir + "/geometry"; gSystem->Setenv("GEOMPATH",r3b_geomdir.Data()); TString r3b_confdir = dir + "gconfig"; gSystem->Setenv("CONFIG_DIR",r3b_confdir.Data()); // In general, the following parts need not be touched // ======================================================================== // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName(fMC.Data()); // Transport engine run->SetOutputFile(OutFile.Data()); // Output file FairRuntimeDb* rtdb = run->GetRuntimeDb(); FairLogger::GetLogger()->SetLogScreenLevel("DEBUG"); // R3B Special Physics List in G4 case if ( (fUserPList == kTRUE ) && (fMC.CompareTo("TGeant4") == 0) ){ run->SetUserConfig("g4R3bConfig.C"); run->SetUserCuts("SetCuts.C"); } // ----- Create media ------------------------------------------------- run->SetMaterials("media_r3b.geo"); // Materials // Magnetic field map type Int_t fFieldMap = 0; // Global Transformations //- Two ways for a Volume Rotation are supported //-- 1) Global Rotation (Euler Angles definition) //-- This represent the composition of : first a rotation about Z axis with //-- angle phi, then a rotation with theta about the rotated X axis, and //-- finally a rotation with psi about the new Z axis. Double_t phi,theta,psi; //-- 2) Rotation in Ref. Frame of the Volume //-- Rotation is Using Local Ref. Frame axis angles Double_t thetaX,thetaY,thetaZ; //- Global Translation Lab. frame. Double_t tx,ty,tz; // ----- Create R3B geometry -------------------------------------------- //R3B Cave definition FairModule* cave= new R3BCave("CAVE"); cave->SetGeometryFileName("r3b_cave.geo"); run->AddModule(cave); //R3B Target definition if (fDetList.FindObject("TARGET") ) { R3BModule* target= new R3BTarget(Target.Data()); target->SetGeometryFileName(((TObjString*)fDetList.GetValue("TARGET"))->GetString().Data()); run->AddModule(target); } //R3B SiTracker Cooling definition if (fDetList.FindObject("VACVESSELCOOL") ) { R3BModule* vesselcool= new R3BVacVesselCool(Target.Data()); vesselcool->SetGeometryFileName(((TObjString*)fDetList.GetValue("VACVESSELCOOL"))->GetString().Data()); run->AddModule(vesselcool); } //R3B Magnet definition if (fDetList.FindObject("ALADIN") ) { fFieldMap = 0; R3BModule* mag = new R3BMagnet("AladinMagnet"); mag->SetGeometryFileName(((TObjString*)fDetList.GetValue("ALADIN"))->GetString().Data()); run->AddModule(mag); } //R3B Magnet definition if (fDetList.FindObject("GLAD") ) { fFieldMap = 1; R3BModule* mag = new R3BGladMagnet("GladMagnet", ((TObjString*)fDetList->GetValue("GLAD"))->GetString(), "GLAD Magnet"); run->AddModule(mag); } if (fDetList.FindObject("CRYSTALBALL") ) { //R3B Crystal Calorimeter R3BDetector* xball = new R3BXBall("XBall", kTRUE); xball->SetGeometryFileName(((TObjString*)fDetList.GetValue("CRYSTALBALL"))->GetString().Data()); run->AddModule(xball); } if (fDetList.FindObject("CALIFA") ) { // CALIFA Calorimeter R3BDetector* califa = new R3BCalifa("Califa", kTRUE); // ((R3BCalifa *)califa)->SelectGeometryVersion(0x438b); ((R3BCalifa *)califa)->SelectGeometryVersion(17); //Selecting the Non-uniformity of the crystals (1 means +-1% max deviation) ((R3BCalifa *)califa)->SetNonUniformity(.0); califa->SetGeometryFileName(((TObjString*)fDetList.GetValue("CALIFA"))->GetString().Data()); run->AddModule(califa); } // Tracker if (fDetList.FindObject("TRACKER") ) { R3BDetector* tra = new R3BTra("Tracker", kTRUE); tra->SetGeometryFileName(((TObjString*)fDetList.GetValue("TRACKER"))->GetString().Data()); run->AddModule(tra); } // STaRTrack if (fDetList.FindObject("STaRTrack") ) { R3BDetector* tra = new R3BSTaRTra("STaRTrack", kTRUE); tra->SetGeometryFileName(((TObjString*)fDetList.GetValue("STaRTrack"))->GetString().Data()); run->AddModule(tra); } // DCH drift chambers if (fDetList.FindObject("DCH") ) { R3BDetector* dch = new R3BDch("Dch", kTRUE); dch->SetGeometryFileName(((TObjString*)fDetList.GetValue("DCH"))->GetString().Data()); run->AddModule(dch); } // Tof if (fDetList.FindObject("TOF") ) { R3BDetector* tof = new R3BTof("Tof", kTRUE); tof->SetGeometryFileName(((TObjString*)fDetList.GetValue("TOF"))->GetString().Data()); run->AddModule(tof); } // mTof if (fDetList.FindObject("MTOF") ) { R3BDetector* mTof = new R3BmTof("mTof", kTRUE); mTof->SetGeometryFileName(((TObjString*)fDetList.GetValue("MTOF"))->GetString().Data()); run->AddModule(mTof); } // GFI detector if (fDetList.FindObject("GFI") ) { R3BDetector* gfi = new R3BGfi("Gfi", kTRUE); gfi->SetGeometryFileName(((TObjString*)fDetList.GetValue("GFI"))->GetString().Data()); run->AddModule(gfi); } // Land Detector if (fDetList.FindObject("LAND") ) { R3BDetector* land = new R3BLand("Land", kTRUE); land->SetVerboseLevel(1); land->SetGeometryFileName(((TObjString*)fDetList.GetValue("LAND"))->GetString().Data()); run->AddModule(land); } // NeuLand Scintillator Detector if(fDetList.FindObject("SCINTNEULAND")) { R3BDetector* land = new R3BLand("Land", kTRUE); land->SetVerboseLevel(1); land->SetGeometryFileName(((TObjString*)fDetList.GetValue("SCINTNEULAND"))->GetString().Data()); run->AddModule(land); } // MFI Detector if(fDetList.FindObject("MFI")) { R3BDetector* mfi = new R3BMfi("Mfi", kTRUE); mfi->SetGeometryFileName(((TObjString*)fDetList.GetValue("MFI"))->GetString().Data()); run->AddModule(mfi); } // PSP Detector if(fDetList.FindObject("PSP")) { R3BDetector* psp = new R3BPsp("Psp", kTRUE); psp->SetGeometryFileName(((TObjString*)fDetList.GetValue("PSP"))->GetString().Data()); run->AddModule(psp); } // Luminosity detector if (fDetList.FindObject("LUMON") ) { R3BDetector* lumon = new ELILuMon("LuMon", kTRUE); lumon->SetGeometryFileName(((TObjString*)fDetList.GetValue("LUMON"))->GetString().Data()); run->AddModule(lumon); } // ----- Create R3B magnetic field ---------------------------------------- Int_t typeOfMagneticField = 0; Int_t fieldScale = 1; Bool_t fVerbose = kFALSE; //NB: <D.B> // If the Global Position of the Magnet is changed // the Field Map has to be transformed accordingly if (fFieldMap == 0) { R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps"); magField->SetCurrent(fMeasCurrent); magField->SetScale(fieldScale); if ( fR3BMagnet == kTRUE ) { run->SetField(magField); } else { run->SetField(NULL); } } else if(fFieldMap == 1){ R3BGladFieldMap* magField = new R3BGladFieldMap("R3BGladMap"); magField->SetScale(fieldScale); if ( fR3BMagnet == kTRUE ) { run->SetField(magField); } else { run->SetField(NULL); } } //! end of field map section // ----- Create PrimaryGenerator -------------------------------------- // 1 - Create the Main API class for the Generator FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); if (fGenerator.CompareTo("ion") == 0 ) { // R3B Ion Generator Int_t z = 30; // Atomic number Int_t a = 65; // Mass number Int_t q = 0; // Charge State Int_t m = 1; // Multiplicity Double_t px = 40./a; // X-Momentum / per nucleon!!!!!! Double_t py = 600./a; // Y-Momentum / per nucleon!!!!!! Double_t pz = 0.01/a; // Z-Momentum / per nucleon!!!!!! R3BIonGenerator* ionGen = new R3BIonGenerator(z,a,q,m,px,py,pz); ionGen->SetSpotRadius(1,1,0); // add the ion generator primGen->AddGenerator(ionGen); } if (fGenerator.CompareTo("ascii") == 0 ) { R3BAsciiGenerator* gen = new R3BAsciiGenerator((dir+"/input/"+InFile).Data()); primGen->AddGenerator(gen); } if (fGenerator.CompareTo("box") == 0 ) { // 2- Define the BOX generator Double_t pdgId=2212; // proton beam Double_t theta1= 25.; // polar angle distribution //Double_t theta2= 7.; Double_t theta2= 66.; // Double_t momentum=1.09008; // 500 MeV/c // Double_t momentum=0.4445834; // 100 MeV/c Double_t momentum1=TMath::Sqrt(energy1*energy1 + 2*energy1*0.938272046); Double_t momentum2=TMath::Sqrt(energy2*energy2 + 2*energy2*0.938272046); FairBoxGenerator* boxGen = new FairBoxGenerator(pdgId, 1); boxGen->SetThetaRange ( theta1, theta2); boxGen->SetPRange (momentum1,momentum2); boxGen->SetPhiRange (0,360.); //boxGen->SetXYZ(0.0,0.0,-1.5); boxGen->SetXYZ(0.0,0.0,0.0); boxGen->SetDebug(kFALSE); // add the box generator primGen->AddGenerator(boxGen); //primGen->SetTarget(0.25, 0.5); //primGen->SmearVertexZ(kTRUE); } if (fGenerator.CompareTo("gammas") == 0 ) { // 2- Define the CALIFA Test gamma generator //Double_t pdgId=22; // gamma emission Double_t pdgId=2212; // proton emission Double_t theta1= 10.; // polar angle distribution Double_t theta2= 40.; //Double_t theta2= 90.; //Double_t momentum=0.002; // 0.010 GeV/c = 10 MeV/c Double_t momentumI=0.002; // 0.010 GeV/c = 10 MeV/c Double_t momentumF=0.002; // 0.010 GeV/c = 10 MeV/c //Double_t momentumF=0.808065; // 0.808065 GeV/c (300MeV Kin Energy for protons) //Double_t momentumI=0.31016124; // 0.31016124 GeV/c (50MeV Kin Energy for protons) //Double_t momentum=0.4442972; // 0.4442972 GeV/c (100MeV Kin Energy for protons) //Double_t momentum=0.5509999; // 0.5509999 GeV/c (150MeV Kin Energy for protons) //Double_t momentumI=0.64405; // 0.64405 GeV/c (200MeV Kin Energy for protons) Int_t multiplicity = 1; R3BCALIFATestGenerator* gammasGen = new R3BCALIFATestGenerator(pdgId, multiplicity); gammasGen->SetThetaRange (theta1, theta2); gammasGen->SetCosTheta(); gammasGen->SetPRange(momentumI,momentumF); gammasGen->SetPhiRange(-180.,180.); //gammasGen->SetXYZ(0.0,0.0,-1.5); //gammasGen->SetXYZ(0.0,0.0,0); gammasGen->SetBoxXYZ(-0.1,0.1,-0.1,0.1,-0.1,0.1); //gammasGen->SetLorentzBoost(0.8197505718204776); //beta=0.81975 for 700 A MeV // add the gamma generator primGen->AddGenerator(gammasGen); } if (fGenerator.CompareTo("r3b") == 0 ) { R3BSpecificGenerator *pR3bGen = new R3BSpecificGenerator(); // R3bGen properties pR3bGen->SetBeamInteractionFlag("off"); pR3bGen->SetRndmFlag("off"); pR3bGen->SetRndmEneFlag("off"); pR3bGen->SetBoostFlag("off"); pR3bGen->SetReactionFlag("on"); pR3bGen->SetGammasFlag("off"); pR3bGen->SetDecaySchemeFlag("off"); pR3bGen->SetDissociationFlag("off"); pR3bGen->SetBackTrackingFlag("off"); pR3bGen->SetSimEmittanceFlag("off"); // R3bGen Parameters pR3bGen->SetBeamEnergy(1.); // Beam Energy in GeV pR3bGen->SetSigmaBeamEnergy(1.e-03); // Sigma(Ebeam) GeV pR3bGen->SetParticleDefinition(2212); // Use Particle Pdg Code pR3bGen->SetEnergyPrim(0.3); // Particle Energy in MeV Int_t fMultiplicity = 50; pR3bGen->SetNumberOfParticles(fMultiplicity); // Mult. // Reaction type // 1: "Elas" // 2: "iso" // 3: "Trans" pR3bGen->SetReactionType("Elas"); // Target type // 1: "LeadTarget" // 2: "Parafin0Deg" // 3: "Parafin45Deg" // 4: "LiH" pR3bGen->SetTargetType(Target.Data()); Double_t thickness = (0.11/2.)/10.; // cm pR3bGen->SetTargetHalfThicknessPara(thickness); // cm pR3bGen->SetTargetThicknessLiH(3.5); // cm pR3bGen->SetTargetRadius(1.); // cm pR3bGen->SetSigmaXInEmittance(1.); //cm pR3bGen->SetSigmaXPrimeInEmittance(0.0001); //cm // Dump the User settings pR3bGen->PrintParameters(); primGen->AddGenerator(pR3bGen); } if (fGenerator.CompareTo("p2p") == 0 ) { R3Bp2pGenerator* gen = new R3Bp2pGenerator(("/lustre/nyx/fairgsi/mwinkel/r3broot/input/p2p/build/" + InFile).Data()); primGen->AddGenerator(gen); #if 0 // Coincident gammas R3BGammaGenerator *gammaGen = new R3BGammaGenerator(); gammaGen->SetEnergyLevel(0, 0.); gammaGen->SetEnergyLevel(1, 3E-3); gammaGen->SetEnergyLevel(2, 4E-3); gammaGen->SetBranchingRatio(2, 1, 0.5); gammaGen->SetBranchingRatio(2, 0, 0.5); gammaGen->SetBranchingRatio(1, 0, 1.); gammaGen->SetInitialLevel(2); gammaGen->SetLorentzBoost(TVector3(0, 0, 0.777792)); primGen->AddGenerator(gammaGen); #endif } run->SetGenerator(primGen); //-------Set visualisation flag to true------------------------------------ run->SetStoreTraj(fVis); FairLogger::GetLogger()->SetLogVerbosityLevel("LOW"); // ----- Initialize CalifaHitFinder task (CrystalCal to Hit) ------------------------------------ if(fCalifaHitFinder) { R3BCalifaCrystalCal2Hit* califaHF = new R3BCalifaCrystalCal2Hit(); califaHF->SetClusteringAlgorithm(1,0); califaHF->SetDetectionThreshold(0.000050);//50 KeV califaHF->SetExperimentalResolution(6.); //percent @ 1 MeV //califaHF->SetComponentResolution(.25); //sigma = 0.5 MeV califaHF->SetPhoswichResolution(3.,5.); //percent @ 1 MeV for LaBr and LaCl califaHF->SelectGeometryVersion(17); califaHF->SetAngularWindow(0.25,0.25); //[0.25 around 14.3 degrees, 3.2 for the complete calorimeter] run->AddTask(califaHF); } // ----- Initialize StarTrackHitfinder task ------------------------------------ if(fStarTrackHitFinder) { R3BSTaRTraHitFinder* trackHF = new R3BSTaRTraHitFinder(); //trackHF->SetClusteringAlgorithm(1,0); trackHF->SetDetectionThreshold(0.000050); //50 KeV trackHF->SetExperimentalResolution(0.); //trackHF->SetAngularWindow(0.15,0.15); //[0.25 around 14.3 degrees, 3.2 for the complete calorimeter] run->AddTask(trackHF); } // ----- Initialize simulation run ------------------------------------ run->Init(); // ------ Increase nb of step for CALO Int_t nSteps = 150000; TVirtualMC::GetMC()->SetMaxNStep(nSteps); // ----- Runtime database --------------------------------------------- R3BFieldPar* fieldPar = (R3BFieldPar*) rtdb->getContainer("R3BFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(ParFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ----- Start run ---------------------------------------------------- if(nEvents > 0) { run->Run(nEvents); } // ----- 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; // ------------------------------------------------------------------------ cout << " Test passed" << endl; cout << " All ok " << endl; }
void r3ball(Int_t nEvents = 1, TMap* fDetList = NULL, TString Target = "LeadTarget", Bool_t fVis = kFALSE, TString fMC = "TGeant3", TString fGenerator = "box", Bool_t fUserPList = kFALSE, Bool_t fR3BMagnet = kTRUE, Double_t fMeasCurrent = 2000., TString OutFile = "r3bsim.root", TString ParFile = "r3bpar.root", TString InFile = "evt_gen.dat") { TString dir = getenv("VMCWORKDIR"); TString r3bdir = dir + "/macros"; TString r3b_geomdir = dir + "/geometry"; gSystem->Setenv("GEOMPATH",r3b_geomdir.Data()); TString r3b_confdir = dir + "gconfig"; gSystem->Setenv("CONFIG_DIR",r3b_confdir.Data()); // In general, the following parts need not be touched // ======================================================================== // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName(fMC.Data()); // Transport engine run->SetOutputFile(OutFile.Data()); // Output file FairRuntimeDb* rtdb = run->GetRuntimeDb(); // R3B Special Physics List in G4 case if ( (fUserPList == kTRUE ) && (fMC.CompareTo("TGeant4") == 0)) { run->SetUserConfig("g4R3bConfig.C"); run->SetUserCuts("SetR3BCuts.C"); } // ----- Create media ------------------------------------------------- run->SetMaterials("media_r3b.geo"); // Materials // Magnetic field map type Int_t fFieldMap = 0; // Global Transformations //- Two ways for a Volume Rotation are supported //-- 1) Global Rotation (Euler Angles definition) //-- This represent the composition of : first a rotation about Z axis with //-- angle phi, then a rotation with theta about the rotated X axis, and //-- finally a rotation with psi about the new Z axis. Double_t phi,theta,psi; //-- 2) Rotation in Ref. Frame of the Volume //-- Rotation is Using Local Ref. Frame axis angles Double_t thetaX,thetaY,thetaZ; //- Global Translation Lab. frame. Double_t tx,ty,tz; // ----- Create R3B geometry -------------------------------------------- //R3B Cave definition FairModule* cave= new R3BCave("CAVE"); cave->SetGeometryFileName("r3b_cave.geo"); run->AddModule(cave); //R3B Target definition if (fDetList->FindObject("TARGET") ) { R3BModule* target= new R3BTarget(Target.Data()); target->SetGeometryFileName(((TObjString*)fDetList->GetValue("TARGET"))->GetString().Data()); run->AddModule(target); } //R3B SiTracker Cooling definition if (fDetList->FindObject("VACVESSELCOOL") ) { R3BModule* vesselcool= new R3BVacVesselCool(Target.Data()); vesselcool->SetGeometryFileName(((TObjString*)fDetList->GetValue("VACVESSELCOOL"))->GetString().Data()); run->AddModule(vesselcool); } //R3B Magnet definition if (fDetList->FindObject("ALADIN") ) { fFieldMap = 0; R3BModule* mag = new R3BMagnet("AladinMagnet"); mag->SetGeometryFileName(((TObjString*)fDetList->GetValue("ALADIN"))->GetString().Data()); run->AddModule(mag); } //R3B Magnet definition if (fDetList->FindObject("GLAD") ) { fFieldMap = 1; R3BModule* mag = new R3BGladMagnet("GladMagnet"); mag->SetGeometryFileName(((TObjString*)fDetList->GetValue("GLAD"))->GetString().Data()); run->AddModule(mag); } if (fDetList->FindObject("CRYSTALBALL") ) { //R3B Crystal Calorimeter R3BDetector* xball = new R3BXBall("XBall", kTRUE); xball->SetGeometryFileName(((TObjString*)fDetList->GetValue("CRYSTALBALL"))->GetString().Data()); run->AddModule(xball); } if (fDetList->FindObject("CALIFA") ) { // CALIFA Calorimeter R3BDetector* calo = new R3BCalo("Califa", kTRUE); ((R3BCalo *)calo)->SelectGeometryVersion(10); //Selecting the Non-uniformity of the crystals (1 means +-1% max deviation) ((R3BCalo *)calo)->SetNonUniformity(1.0); calo->SetGeometryFileName(((TObjString*)fDetList->GetValue("CALIFA"))->GetString().Data()); run->AddModule(calo); } // Tracker if (fDetList->FindObject("TRACKER") ) { R3BDetector* tra = new R3BTra("Tracker", kTRUE); tra->SetGeometryFileName(((TObjString*)fDetList->GetValue("TRACKER"))->GetString().Data()); tra->SetEnergyCut(1e-4); run->AddModule(tra); } // STaRTrack if (fDetList->FindObject("STaRTrack") ) { R3BDetector* tra = new R3BSTaRTra("STaRTrack", kTRUE); tra->SetGeometryFileName(((TObjString*)fDetList->GetValue("STaRTrack"))->GetString().Data()); run->AddModule(tra); } // DCH drift chambers if (fDetList->FindObject("DCH") ) { R3BDetector* dch = new R3BDch("Dch", kTRUE); dch->SetGeometryFileName(((TObjString*)fDetList->GetValue("DCH"))->GetString().Data()); run->AddModule(dch); } // Tof if (fDetList->FindObject("TOF") ) { R3BDetector* tof = new R3BTof("Tof", kTRUE); tof->SetGeometryFileName(((TObjString*)fDetList->GetValue("TOF"))->GetString().Data()); run->AddModule(tof); } // mTof if (fDetList->FindObject("MTOF") ) { R3BDetector* mTof = new R3BmTof("mTof", kTRUE); mTof->SetGeometryFileName(((TObjString*)fDetList->GetValue("MTOF"))->GetString().Data()); run->AddModule(mTof); } // dTof if (fDetList->FindObject("DTOF") ) { R3BDetector* dTof = new R3BdTof("dTof", kTRUE); dTof->SetGeometryFileName(((TObjString*)fDetList->GetValue("DTOF"))->GetString().Data()); run->AddModule(dTof); } // GFI detector if (fDetList->FindObject("GFI") ) { R3BDetector* gfi = new R3BGfi("Gfi", kTRUE); gfi->SetGeometryFileName(((TObjString*)fDetList->GetValue("GFI"))->GetString().Data()); run->AddModule(gfi); } // Land Detector if (fDetList->FindObject("LAND") ) { R3BDetector* land = new R3BLand("Land", kTRUE); land->SetVerboseLevel(1); land->SetGeometryFileName(((TObjString*)fDetList->GetValue("LAND"))->GetString().Data()); run->AddModule(land); } // NeuLand Scintillator Detector if(fDetList->FindObject("SCINTNEULAND")) { R3BDetector* land = new R3BLand("Land", kTRUE); land->SetVerboseLevel(1); land->SetGeometryFileName(((TObjString*)fDetList->GetValue("SCINTNEULAND"))->GetString().Data()); run->AddModule(land); } // MFI Detector if(fDetList->FindObject("MFI")) { R3BDetector* mfi = new R3BMfi("Mfi", kTRUE); mfi->SetGeometryFileName(((TObjString*)fDetList->GetValue("MFI"))->GetString().Data()); run->AddModule(mfi); } // PSP Detector if(fDetList->FindObject("PSP")) { R3BDetector* psp = new R3BPsp("Psp", kTRUE); psp->SetGeometryFileName(((TObjString*)fDetList->GetValue("PSP"))->GetString().Data()); run->AddModule(psp); } // Luminosity detector if (fDetList->FindObject("LUMON") ) { R3BDetector* lumon = new ELILuMon("LuMon", kTRUE); lumon->SetGeometryFileName(((TObjString*)fDetList->GetValue("LUMON"))->GetString().Data()); run->AddModule(lumon); } // ----- Create R3B magnetic field ---------------------------------------- Int_t typeOfMagneticField = 0; Int_t fieldScale = 1; Bool_t fVerbose = kFALSE; //NB: <D.B> // If the Global Position of the Magnet is changed // the Field Map has to be transformed accordingly FairField *magField = NULL; if (fFieldMap == 0) { magField = new R3BAladinFieldMap("AladinMaps"); ((R3BAladinFieldMap*)magField)->SetCurrent(fMeasCurrent); ((R3BAladinFieldMap*)magField)->SetScale(fieldScale); if ( fR3BMagnet == kTRUE ) { run->SetField(magField); } else { run->SetField(NULL); } } else if(fFieldMap == 1){ magField = new R3BGladFieldMap("R3BGladMap"); ((R3BGladFieldMap*)magField)->SetPosition(0., 0., +350-119.94); ((R3BGladFieldMap*)magField)->SetScale(fieldScale); if ( fR3BMagnet == kTRUE ) { run->SetField(magField); } else { run->SetField(NULL); } } //! end of field map section // ----- Create PrimaryGenerator -------------------------------------- // 1 - Create the Main API class for the Generator FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); if (fGenerator.CompareTo("box") == 0 ) { // 2- Define the BOX generator Int_t pdgId = 211; // pion beam Double32_t theta1 = 0.; // polar angle distribution Double32_t theta2 = 7.; Double32_t momentum = 0.8; FairBoxGenerator* boxGen = new FairBoxGenerator(pdgId, 50); boxGen->SetThetaRange(theta1, theta2); boxGen->SetPRange(momentum, momentum*2.); boxGen->SetPhiRange(0, 360); boxGen->SetXYZ(0.0, 0.0, -1.5); // boxGen->SetXYZ(0.0, 0.0, -300.); // add the box generator primGen->AddGenerator(boxGen); } if (fGenerator.CompareTo("ascii") == 0 ) { R3BAsciiGenerator* gen = new R3BAsciiGenerator((dir+"/input/"+InFile).Data()); primGen->AddGenerator(gen); } if (fGenerator.CompareTo("r3b") == 0 ) { R3BSpecificGenerator *pR3bGen = new R3BSpecificGenerator(); // R3bGen properties pR3bGen->SetBeamInteractionFlag("off"); pR3bGen->SetBeamInteractionFlag("off"); pR3bGen->SetRndmFlag("off"); pR3bGen->SetRndmEneFlag("off"); pR3bGen->SetBoostFlag("off"); pR3bGen->SetReactionFlag("on"); pR3bGen->SetGammasFlag("off"); pR3bGen->SetDecaySchemeFlag("off"); pR3bGen->SetDissociationFlag("off"); pR3bGen->SetBackTrackingFlag("off"); pR3bGen->SetSimEmittanceFlag("off"); // R3bGen Parameters pR3bGen->SetBeamEnergy(1.); // Beam Energy in GeV pR3bGen->SetSigmaBeamEnergy(1.e-03); // Sigma(Ebeam) GeV pR3bGen->SetParticleDefinition(2212); // Use Particle Pdg Code pR3bGen->SetEnergyPrim(0.3); // Particle Energy in MeV Int_t fMultiplicity = 50; pR3bGen->SetNumberOfParticles(fMultiplicity); // Mult. // Reaction type // 1: "Elas" // 2: "iso" // 3: "Trans" pR3bGen->SetReactionType("Elas"); // Target type // 1: "LeadTarget" // 2: "Parafin0Deg" // 3: "Parafin45Deg" // 4: "LiH" pR3bGen->SetTargetType(Target.Data()); Double_t thickness = (0.11/2.)/10.; // cm pR3bGen->SetTargetHalfThicknessPara(thickness); // cm pR3bGen->SetTargetThicknessLiH(3.5); // cm pR3bGen->SetTargetRadius(1.); // cm pR3bGen->SetSigmaXInEmittance(1.); //cm pR3bGen->SetSigmaXPrimeInEmittance(0.0001); //cm // Dump the User settings pR3bGen->PrintParameters(); primGen->AddGenerator(pR3bGen); } run->SetGenerator(primGen); //-------Set visualisation flag to true------------------------------------ run->SetStoreTraj(fVis); FairLogger::GetLogger()->SetLogVerbosityLevel("LOW"); // ----- Initialize simulation run ------------------------------------ run->Init(); // ------ Increase nb of step for CALO Int_t nSteps = -15000; gMC->SetMaxNStep(nSteps); // ----- Runtime database --------------------------------------------- R3BFieldPar* fieldPar = (R3BFieldPar*) rtdb->getContainer("R3BFieldPar"); if(NULL != magField) { fieldPar->SetParameters(magField); fieldPar->setChanged(); } Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(ParFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ----- Start run ---------------------------------------------------- if(nEvents > 0) { run->Run(nEvents); } // ----- 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; // ------------------------------------------------------------------------ cout << " Test passed" << endl; cout << " All ok " << endl; }
void run(TString runNumber) { TStopwatch timer; timer.Start(); const Int_t nev = -1; // number of events to read, -1 - untill CTRL+C TString inDir = "/Volumes/Data/kresan/s438b/lmd/"; // directory with lmd files TString outDir = "/Volumes/Data/kresan/s438b/data/"; // output directory TString histDir = "/Users/kresan/Sites/"; // web-server directory TString outputFileName = outDir + runNumber + "_raw.root"; // name of output file TString histFileName = histDir + "hist_s438b_" + runNumber + "_raw.root"; // name of file with control histograms const Int_t refresh = 100000; // refresh rate for saving control histograms TString parFileName = outDir + "params_" + runNumber + "_raw.root"; // name of parameter file //const Long64_t maxSize = 1 * 1024 * 1024 * 1024; // 1 GByte // file split size const char *landMappingName = "cfg_neuland_s438b.hh"; // mapping file const Int_t nBarsPerPlane = 50; const Int_t updateRate = 150000; const Int_t minStats = 5000; const Int_t nModules = 800; // Create source with unpackers ---------------------------------------------- Int_t iFile = 0; Int_t kFile = 0; if(runNumber.Contains("run331")) { iFile = 5209; kFile = 5229; } FairLmdSource* source = new FairLmdSource(); char strName[1000]; for(Int_t i = iFile; i < kFile; i++) { sprintf(strName, "%s%s_%4d.lmd", inDir.Data(), runNumber.Data(), i); for(Int_t j = 0; j < 1000; j++) if(' ' == strName[j]) strName[j] = '0'; cout << strName << endl; source->AddFile(strName); } R3BEventHeaderUnpack *event_unpack = new R3BEventHeaderUnpack(); source->AddUnpacker(event_unpack); // NeuLAND MBS parameters ------------------------------- Short_t type = 94; Short_t subType = 9400; Short_t procId = 12; Short_t subCrate = 0; Short_t control = 3; source->AddUnpacker(new R3BLandUnpack(type, subType, procId, subCrate, control)); // ------------------------------------------------------ // LOS MBS parameters ----------------------------------- type = 88; subType = 8800; procId = 10; subCrate = 7; control = 5; //source->AddUnpacker(new R3BLosUnpack(type, subType, procId, subCrate, control)); // ------------------------------------------------------ // --------------------------------------------------------------------------- // Create online run --------------------------------------------------------- FairRunOnline* run = new FairRunOnline(source); run->SetOutputFile(outputFileName.Data()); run->SetGenerateHtml(kTRUE, histFileName.Data(), refresh); // --------------------------------------------------------------------------- // Create ALADIN field map --------------------------------------------------- R3BAladinFieldMap* magField = new R3BAladinFieldMap("AladinMaps"); Double_t fMeasCurrent = 2500.; // I_current [A] magField->SetCurrent(fMeasCurrent); magField->SetScale(1.); run->SetField(magField); // --------------------------------------------------------------------------- // Channel mapping ----------------------------------------------------------- R3BLandMapping* map = new R3BLandMapping(); map->SetFileName(landMappingName); map->SetNofBarsPerPlane(nBarsPerPlane); run->AddTask(map); // --------------------------------------------------------------------------- // TCAL ---------------------------------------------------------------------- R3BLandTcalFill* tcalFill = new R3BLandTcalFill("TcalFill"); tcalFill->SetUpdateRate(updateRate); tcalFill->SetMinStats(minStats); tcalFill->SetTrigger(2); tcalFill->SetNofModules(nModules, 50); run->AddTask(tcalFill); R3BLosTcalFill* losTcalFill = new R3BLosTcalFill("LosTcalFill"); losTcalFill->SetUpdateRate(updateRate); losTcalFill->SetMinStats(minStats); losTcalFill->SetNofModules(20); //run->AddTask(losTcalFill); // --------------------------------------------------------------------------- // Add analysis task --------------------------------------------------------- R3BLandRawAna* ana = new R3BLandRawAna("LandRawAna", 1); run->AddTask(ana); // --------------------------------------------------------------------------- // Initialize ---------------------------------------------------------------- run->Init(); //((TTree*)gFile->Get("cbmsim"))->SetMaxTreeSize(maxSize); FairLogger::GetLogger()->SetLogScreenLevel("INFO"); // --------------------------------------------------------------------------- // Runtime data base --------------------------------------------------------- FairRuntimeDb* rtdb = run->GetRuntimeDb(); R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFileName); rtdb->setOutput(parOut); rtdb->print(); // --------------------------------------------------------------------------- // Run ----------------------------------------------------------------------- run->Run(nev, 0); rtdb->saveOutput(); // --------------------------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outputFileName << endl; cout << "Parameter file is " << parFileName << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; }