diff --git a/Examples/Example1/Analysis.cxx b/Examples/Example1/Analysis.cxx index fa8554aebb8d4a91f48286322f34a9f005aa5fbf..0a60fe37dc998bf3977f6574983f3a109b90a94f 100644 --- a/Examples/Example1/Analysis.cxx +++ b/Examples/Example1/Analysis.cxx @@ -75,6 +75,9 @@ void Analysis::TreatEvent(){ OriginalELab = ReactionConditions->GetKineticEnergy(0); OriginalThetaLab = ReactionConditions->GetTheta(0); OriginalBeamEnergy = ReactionConditions->GetBeamEnergy(); + ReactionVertexX = ReactionConditions->GetVertexPositionX(); + ReactionVertexY = ReactionConditions->GetVertexPositionY(); + ReactionVertexZ = ReactionConditions->GetVertexPositionZ(); // Get the Init information on beam position and energy // and apply by hand the experimental resolution // This is because the beam diagnosis are not simulated @@ -207,6 +210,9 @@ void Analysis::InitOutputBranch() { RootOutput::getInstance()->GetTree()->Branch("OriginalELab",&OriginalELab,"OriginalELab/D"); RootOutput::getInstance()->GetTree()->Branch("OriginalThetaLab",&OriginalThetaLab,"OriginalThetaLab/D"); RootOutput::getInstance()->GetTree()->Branch("OriginalBeamEnergy",&OriginalBeamEnergy,"OriginalBeamEnergy/D"); + RootOutput::getInstance()->GetTree()->Branch("ReactionVertexX",&ReactionVertexX,"ReactionVertexX/D"); + RootOutput::getInstance()->GetTree()->Branch("ReactionVertexY",&ReactionVertexY,"ReactionVertexY/D"); + RootOutput::getInstance()->GetTree()->Branch("ReactionVertexZ",&ReactionVertexZ,"ReactionVertexZ/D"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/Examples/Example1/Analysis.h b/Examples/Example1/Analysis.h index 908a9f782c1812208524ef2cab6eae4dde6b4de7..7c2408efc4df64191df2b28f36793f17c080017b 100644 --- a/Examples/Example1/Analysis.h +++ b/Examples/Example1/Analysis.h @@ -54,6 +54,9 @@ class Analysis: public NPL::VAnalysis{ double OriginalELab; double OriginalThetaLab; double OriginalBeamEnergy; + double ReactionVertexX; + double ReactionVertexY; + double ReactionVertexZ; NPL::Reaction* He10Reaction; // intermediate variable diff --git a/Examples/Example1/ShowResults.C b/Examples/Example1/ShowResults.C index 8ea68944e989e3f7845c980a10f7837f31c3488e..3c8f9dfa9bdf91acea8e3538dee8f460449ab6a3 100644 --- a/Examples/Example1/ShowResults.C +++ b/Examples/Example1/ShowResults.C @@ -86,7 +86,7 @@ void ShowResults(){ f->SetNpx(1000); TCanvas* c2 = new TCanvas("Simulated","Simulated",600,0,600,600); - c2->Divide(2,2); + c2->Divide(2,3); c2->cd(1); chain->Draw("OriginalELab:OriginalThetaLab>>hS(1000,0,90,1000,0,30)","","col"); @@ -110,6 +110,7 @@ void ShowResults(){ TLine* lT = new TLine(0,0,90,90); lT->Draw(); + c2->cd(4); chain->Draw("OriginalBeamEnergy:BeamEnergy>>hS4(1000,500,600,1000,500,600)","BeamEnergy>0","col"); TH1F* hS4 = (TH1F*) gDirectory->FindObjectAny("hS4"); @@ -120,5 +121,16 @@ void ShowResults(){ lB->Draw(); + c2->cd(5); + chain->Draw("ReactionVertexY:ReactionVertexX>>hVXY(1000,-20,20,1000,-20,20)","","col"); + TH2F* hVXY = (TH2F*) gDirectory->FindObjectAny("hVXY"); + hVXY->GetYaxis()->SetTitle("Reaction vertex Y (mm)"); + hVXY->GetXaxis()->SetTitle("Reaction vertex X (mm)"); + + c2->cd(6); + chain->Draw("ReactionVertexX:ReactionVertexZ*1000.>>hVXZ(1000,-15,15,1000,-20,20)","","col"); + TH2F* hVXZ = (TH2F*) gDirectory->FindObjectAny("hVXZ"); + hVXZ->GetZaxis()->SetTitle("Reaction vertex X (mm)"); + hVXZ->GetXaxis()->SetTitle("Reaction vertex Z (um)"); } diff --git a/Examples/Example1/run.mac b/Examples/Example1/run.mac new file mode 100644 index 0000000000000000000000000000000000000000..b379ed9bcf78d80c4a29d004189059437aaa84d3 --- /dev/null +++ b/Examples/Example1/run.mac @@ -0,0 +1 @@ +/run/beamOn 10000 diff --git a/Examples/Example1/sim.sh b/Examples/Example1/sim.sh new file mode 100755 index 0000000000000000000000000000000000000000..561a386a8ee24fc95ae23f21b4c9e7881b5c3a76 --- /dev/null +++ b/Examples/Example1/sim.sh @@ -0,0 +1,3 @@ +npsimulation -D Example1.detector -E Example1.reaction -O Example1 -B run.mac +npanalysis --last-sim -O Example1 +root ShowResults.C diff --git a/Examples/Example4/run.mac b/Examples/Example4/run.mac new file mode 100644 index 0000000000000000000000000000000000000000..ced78f72769fe42cd7cc053d0387e39f4e254d76 --- /dev/null +++ b/Examples/Example4/run.mac @@ -0,0 +1 @@ +/run/beamOn 10 diff --git a/Examples/Example4/sim.sh b/Examples/Example4/sim.sh new file mode 100755 index 0000000000000000000000000000000000000000..f461643d72b3de002d3084c74932518aae0fa5c7 --- /dev/null +++ b/Examples/Example4/sim.sh @@ -0,0 +1 @@ +npsimulation -D Example4.detector -E Example4.reaction -O Example4 -B run.mac diff --git a/Examples/Example5/CheckSimu.C b/Examples/Example5/CheckSimu.C new file mode 100644 index 0000000000000000000000000000000000000000..188924f8734171aba8e62f958fb976e725385b07 --- /dev/null +++ b/Examples/Example5/CheckSimu.C @@ -0,0 +1,207 @@ +#include <iostream> +#include <ctime> +#include <cstdlib> +using namespace std; + +// ROOT headers +#include "TROOT.h" +#include "TStyle.h" +#include "TCanvas.h" +#include "TSystem.h" +#include "TFile.h" +#include "TString.h" +#include "TEllipse.h" +#include "TLegend.h" +#include "TTree.h" +#include "TBranch.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TGraph.h" + +// nptool headers +#include "TReactionConditions.h" +#include "TInteractionCoordinates.h" +#include "NPReaction.h" +#include "NPQFS.h" + +using namespace NPL; + +TCanvas* canvas2; + +void CheckSimu(const char * fname = "Example5"){ + // for the style + gStyle->SetOptStat(0); + gROOT->SetStyle("nptool"); + gROOT->ForceStyle(true); + gStyle->SetPalette(1); + + // Open output ROOT file from NPTool simulation run + TString path = gSystem->Getenv("NPTOOL"); + path += "/Outputs/Simulation/"; + TString inFileName = fname; + if (!inFileName.Contains("root")) inFileName += ".root"; + TFile *inFile = new TFile(path + inFileName); + if (!inFile->IsOpen()) exit(1); + TTree *tree = (TTree*) inFile->Get("SimulatedTree"); + + // Connect the branches of the TTree and activate then if necessary + // TReactionConditions branch + TReactionConditions *reacCond = 0; + tree->SetBranchAddress("ReactionConditions", &reacCond); + tree->SetBranchStatus("ReactionConditions", 1); + + // TInteractionCoordinates branch + TInteractionCoordinates *interCoord = 0; + tree->SetBranchAddress("InteractionCoordinates", &interCoord); + tree->SetBranchStatus("InteractionCoordinates", 1); + + // Declare histograms + // for emitted particle + TH1F *hEmThetaCM = new TH1F("hEmThetaCM", "Light Ejectile Theta CM",180, 0, 180); + TH1F *hEmInternalMomX = new TH1F("hEmInternalMomX", "Internal Momentum (X) of removed cluster",500, -500, 500); + TH1F *hEmInternalMomY = new TH1F("hEmInternalMomY", "Internal Momentum (Y) of removed cluster",500, -500, 500); + TH1F *hEmInternalMomZ = new TH1F("hEmInternalMomZ", "Internal Momentum (Z) of removed cluster",500, -500, 500); + TH1F *hEmTheta1IF = new TH1F("hEmTheta1IF", "Ejectile1 Theta (reaction frame)", 180, 0, 180); + TH1F *hEmPhi1IF = new TH1F("hEmPhi1IF", "Ejectile1 Phi (reaction frame)", 360, 0, 360); + TH1F *hEmTheta1WF = new TH1F("hEmTheta1WF", "Ejectile1 Theta (world frame)", 180, 0, 180); + TH1F *hEmPhi1WF = new TH1F("hEmPhi1WF", "Ejectile1 Phi (world frame)", 360, 0, 360); + TH1F *hEmTheta2IF = new TH1F("hEmTheta2IF", "Ejectile2 Theta (reaction frame)", 180, 0, 180); + TH1F *hEmPhi2IF = new TH1F("hEmPhi2IF", "Ejectile2 Phi (reaction frame)", 360, 0, 360); + TH1F *hEmTheta2WF = new TH1F("hEmTheta2WF", "Ejectile2 Theta (world frame)", 180, 0, 180); + TH1F *hEmPhi2WF = new TH1F("hEmPhi2WF", "Ejectile2 Phi (world frame)", 360, 0, 360); + + TH1F *hEmOpAngle = new TH1F("hEmOpAngle", "Opening angle betw. (1) and (2)", 100, 0, 100); + TH1F *hdPhi = new TH1F("hdPhi", "Phi angle difference between (1) and (2)", 200, 0, 200); + TH2F *hEmE1Theta1 = new TH2F("hEmE1Theta1", "Kinematics (1)", 900, 0, 90, 1000, 0, 500); + TH2F *hEmE2Theta2 = new TH2F("hEmE1Theta1", "Kinematics (2)", 900, 0, 90, 1000, 0, 500); + + TH2F *hEmE1VsE2 = new TH2F("hEmE1VsE2", " E1 VS E2 (reaction frame)", 300, 0, 300,300,0,300); + TH2F *hEmTheta1VsTheta2 = new TH2F("hEmTheta1VsTheta2", " Theta1 VS Theta2 (reaction frame)", 360, 0, 90,360,0,90); + TH2F *hEmPhi1VsPhi2 = new TH2F("hEmPhi1VsPhi2", " Phi1 VS Phi2 (reaction frame)", 360, 0, 360,360,0,360); + + // Read the TTree + Int_t nentries = tree->GetEntries(); + cout << endl << " TTree contains " << nentries << " events" << endl; + + for (Int_t i = 0; i < nentries; i++) { + if (i%10000 == 0 && i!=0) { + cout.precision(5); + Double_t percent = (Double_t)i/nentries ; + cout << "\r Progression: " << percent*100 << " %" << flush; + } + else if (i==nentries-1) cout << "\r Progression:" << " 100%" << endl; + + // Get entry + tree->GetEntry(i); + + // Fill histos + // ejected particles + hEmThetaCM -> Fill(reacCond->GetThetaCM()); + hEmInternalMomX -> Fill(reacCond->GetInternalMomentum().X()); + hEmInternalMomY -> Fill(reacCond->GetInternalMomentum().Y()); + hEmInternalMomZ -> Fill(reacCond->GetInternalMomentum().Z()); + + hEmTheta1IF -> Fill(reacCond->GetThetaLab_BeamFrame(0)); + hEmTheta1WF -> Fill(reacCond->GetThetaLab_WorldFrame(0)); + hEmE1Theta1 -> Fill(reacCond->GetThetaLab_BeamFrame(0), reacCond->GetKineticEnergy(0)); + hEmTheta2IF -> Fill(reacCond->GetThetaLab_BeamFrame(1)); + hEmTheta2WF -> Fill(reacCond->GetThetaLab_WorldFrame(1)); + hEmE2Theta2 -> Fill(reacCond->GetThetaLab_BeamFrame(1), reacCond->GetKineticEnergy(1)); + + hEmTheta1VsTheta2 -> Fill(reacCond->GetTheta(1), reacCond->GetTheta(0)); + hEmPhi1VsPhi2 -> Fill(reacCond->GetPhi(1), reacCond->GetPhi(0)); + hEmE1VsE2 -> Fill(reacCond->GetKineticEnergy(1), reacCond->GetKineticEnergy(0)); + + double theta1 = reacCond->GetThetaLab_BeamFrame(0)*TMath::Pi()/180.; + double theta2 = reacCond->GetThetaLab_BeamFrame(1)*TMath::Pi()/180.; + double phi1 = reacCond->GetPhiLab_BeamFrame(0)*TMath::Pi()/180.; + double phi2 = reacCond->GetPhiLab_BeamFrame(1)*TMath::Pi()/180.; + double Opang = acos( sin(theta1)*sin(theta2)*cos(phi1-phi2) + + cos(theta1)* cos(theta2) ); + hEmOpAngle->Fill(Opang*180./TMath::Pi()); + + double df = fabs(phi1-phi2)*180./TMath::Pi(); + + if(df>0 && df <= 180) hdPhi->Fill(df); + else hdPhi->Fill(360 - df); + } + + + // Display emmitted paricles histograms + canvas2 = new TCanvas("canvas2", "Emmited particles properties in reaction frame",1000,1000); + canvas2->Divide(3,3); + + canvas2->cd(1); + hEmThetaCM->SetXTitle("#theta_{c.m.}"); + hEmThetaCM->SetYTitle("counts / 1^{#circ}"); + hEmThetaCM->GetYaxis()->SetTitleOffset(1.18); + hEmThetaCM->GetYaxis()->SetRangeUser(0,400); + hEmThetaCM->Draw(); + + canvas2->cd(2); + hEmE1Theta1->SetXTitle("#theta_{1}"); + hEmE1Theta1->SetYTitle("E_{1} (MeV)"); + hEmE1Theta1->Draw("colz"); + + canvas2->cd(3); + hdPhi->Draw(); + hdPhi->SetXTitle("#phi_{1} - #phi_{2} (deg)"); + hdPhi->SetYTitle("Counts"); + + canvas2->cd(4); + hEmTheta1VsTheta2->Draw("colz"); + hEmTheta1VsTheta2->SetXTitle("#theta_{1} (deg)"); + hEmTheta1VsTheta2->SetYTitle("#theta_{2} (deg)"); + NPL::QFS qfs; + qfs.ReadConfigurationFile("Example5.reaction"); + qfs.SetMomentumSigma(0.); + TGraph* Kine = qfs.GetTheta2VsTheta1(1); + Kine->SetLineWidth(2); + Kine->SetLineColor(kRed); + Kine->SetLineStyle(2); + Kine->Draw("csame"); + TGraph* Kine2 = qfs.GetTheta2VsTheta1(10); + Kine2->SetLineColor(kRed); + Kine2->SetMarkerColor(kRed); + Kine2->SetMarkerStyle(20); + Kine2->SetMarkerSize(1.3); + Kine2->Draw("Psame"); + + + + + canvas2->cd(5); + hEmPhi1VsPhi2->Draw("colz"); + hEmPhi1VsPhi2->SetXTitle("#phi_{1} (deg)"); + hEmPhi1VsPhi2->SetYTitle("#phi_{2} (deg)"); + TGraph* KinePhi = qfs.GetPhi2VsPhi1(1); + KinePhi->SetMarkerColor(kRed); + KinePhi->SetMarkerSize(0.4); + KinePhi->Draw("Psame"); + + + canvas2->cd(6); + hEmOpAngle->Draw(); + hEmOpAngle->SetXTitle("Opening angle (1-2) (deg)"); + hEmOpAngle->SetYTitle("Counts"); + + canvas2->cd(7); + hEmInternalMomX->Draw(); + hEmInternalMomX->SetXTitle("P_{x} (MeV/c)"); + hEmInternalMomX->SetYTitle("Counts"); + + canvas2->cd(8); + hEmInternalMomY->Draw(); + hEmInternalMomY->SetXTitle("P_{y} (MeV/c)"); + hEmInternalMomY->SetYTitle("Counts"); + + canvas2->cd(9); + hEmInternalMomZ->Draw(); + hEmInternalMomZ->SetXTitle("P_{z} (MeV/c)"); + hEmInternalMomZ->SetYTitle("Counts"); + + + +} + + diff --git a/Examples/Example5/Example5.detector b/Examples/Example5/Example5.detector new file mode 100644 index 0000000000000000000000000000000000000000..d0c21ac27837989b3763f89e4fb20716e1ca5cf8 --- /dev/null +++ b/Examples/Example5/Example5.detector @@ -0,0 +1,35 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Target + Thickness= 1 mm + Radius= 30 mm + Material= H2 + Angle= 0 deg + X= 0 mm + Y= 0 mm + Z= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ScintillatorPlastic +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Plastic + X= 0 mm + Y= 0 mm + Z= 2000 mm + Shape= Square + Height= 500 mm + Width= 500 mm + Thickness= 0.001 mm + Scintillator= BC400 + LeadThickness= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Plastic + X= 0 mm + Y= 0 mm + Z= 2255 mm + Shape= Square + Height= 500 mm + Width= 500 mm + Thickness= 500 mm + Scintillator= Pb + LeadThickness= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/Examples/Example5/Example5.mac b/Examples/Example5/Example5.mac new file mode 100644 index 0000000000000000000000000000000000000000..3a7cd691db31d7a1eac6f083ab4c07bdbb3e0beb --- /dev/null +++ b/Examples/Example5/Example5.mac @@ -0,0 +1 @@ +/run/beamOn 50000 diff --git a/Examples/Example5/Example5.reaction b/Examples/Example5/Example5.reaction new file mode 100755 index 0000000000000000000000000000000000000000..ff84b32b49330ddc798e311fa404b7b643a4b58c --- /dev/null +++ b/Examples/Example5/Example5.reaction @@ -0,0 +1,29 @@ +%%%%%%%%%%%%%%%%%% QFS Example in progress %%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 12C + Energy= 4800 MeV + SigmaEnergy= 0 MeV + SigmaThetaX= 0 deg + SigmaPhiY= 0 deg + SigmaX= 0 mm + SigmaY= 0 mm + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 0 mm + MeanY= 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +QFSReaction + Beam= 12C + Target= 1H + Scattered= 1H + KnockedOut= 1H + Heavy= 11B + ExcitationEnergyBeam= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + MomentumSigma= 50.0 + ShootHeavy= 1 + ShootLight= 1 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Examples/Example5/PhysicsListOption.txt b/Examples/Example5/PhysicsListOption.txt new file mode 100644 index 0000000000000000000000000000000000000000..602b8c7764fcf14b906236dbcf6e2ae9d1579abf --- /dev/null +++ b/Examples/Example5/PhysicsListOption.txt @@ -0,0 +1 @@ +DefaultCutOff 100000000000 diff --git a/Examples/Example5/sim.sh b/Examples/Example5/sim.sh new file mode 100755 index 0000000000000000000000000000000000000000..7d32d779ea6913783ae355a478a399a16f1221f4 --- /dev/null +++ b/Examples/Example5/sim.sh @@ -0,0 +1,2 @@ +npsimulation -D Example5.detector -E Example5.reaction -O Example5 -B Example5.mac + diff --git a/Inputs/EventGenerator/Example1.reaction b/Inputs/EventGenerator/Example1.reaction index 2461a6e242fd81cbbffbee76be42f21a82f03038..4eb8f8ee2fa5c39f0b4f555f9b8372cda2d276c8 100644 --- a/Inputs/EventGenerator/Example1.reaction +++ b/Inputs/EventGenerator/Example1.reaction @@ -34,12 +34,12 @@ TwoBodyReaction ShootHeavy= 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%Decay 10He -% Daughter= 8He n n -% ExcitationEnergy= 0 0 0 MeV -% Threshold= 0 MeV -% BranchingRatio= 0.5 -% LifeTime= 0 ns -% Shoot= 1 1 1 +Decay 10He + Daughter= 8He n n + ExcitationEnergy= 0 0 0 MeV + Threshold= 0 MeV + BranchingRatio= 0.5 + LifeTime= 0 ns + Shoot= 1 1 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Inputs/EventGenerator/proton.source b/Inputs/EventGenerator/proton.source index 79844f1159c10dc98b1da545bbfdac48889de247..e281714a76034aef4623805289e1a55910471548 100644 --- a/Inputs/EventGenerator/proton.source +++ b/Inputs/EventGenerator/proton.source @@ -4,10 +4,11 @@ % Energy are given in MeV , Position in mm % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Isotropic - EnergyLow= 0 MeV - EnergyHigh= 25 MeV + EnergyLow= 5 MeV + EnergyHigh= 5 MeV + EnergyDistribution= flat HalfOpenAngleMin= 0 deg - HalfOpenAngleMax= 90 deg + HalfOpenAngleMax= 180 deg x0= 0 mm y0= 0 mm z0= 0 mm diff --git a/NPLib/CMakeLists.txt b/NPLib/CMakeLists.txt index e4a77e6eca82127049b9d464ac4f43286db631bc..7d54fcd7ca875a2b8a4c2d909331265e4d30ea76 100644 --- a/NPLib/CMakeLists.txt +++ b/NPLib/CMakeLists.txt @@ -7,7 +7,8 @@ set(CMAKE_BUILD_TYPE Release) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) # include the nptool standard CMake preamble -include("ressources/CMake/NPTool_CMake_Preamble.cmake") +include("${CMAKE_BINARY_DIR}/ressources/CMake/NPTool_CMake_Preamble.cmake") + # Major change in the Core/Physics (affecting the detector/analysis/simulation) set(NPLIB_VERSION_MAJOR 2) diff --git a/NPLib/Calibration/CMakeLists.txt b/NPLib/Calibration/CMakeLists.txt index 5f78fd6c32576fb16ed94cbf55431e22624cbf9f..11537d6c02978c8303c373f77259a3b057d81bce 100644 --- a/NPLib/Calibration/CMakeLists.txt +++ b/NPLib/Calibration/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT NPSiliconCalibratorDict.cxx COMMAND ../scripts/build_dict.sh NPSiliconCalibrator.h NPSiliconCalibratorDict.cxx NPSiliconCalibrator.rootmap libNPCalibration.so NPCalibrationLinkDef1.h) -add_custom_command(OUTPUT NPCalibrationSourceDict.cxx COMMAND ../scripts/build_dict.sh NPCalibrationSource.h NPCalibrationSourceDict.cxx NPCalibrationSource.rootmap libNPCalibration.so NPCalibrationLinkDef2.h) +add_custom_command(OUTPUT NPSiliconCalibratorDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPSiliconCalibrator.h NPSiliconCalibratorDict.cxx NPSiliconCalibrator.rootmap libNPCalibration.so NPCalibrationLinkDef1.h) +add_custom_command(OUTPUT NPCalibrationSourceDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPCalibrationSource.h NPCalibrationSourceDict.cxx NPCalibrationSource.rootmap libNPCalibration.so NPCalibrationLinkDef2.h) add_library(NPCalibration SHARED NPCalibrationSource.cxx NPSiliconCalibrator.cxx NPSiliconCalibratorDict.cxx NPCalibrationSourceDict.cxx) target_link_libraries(NPCalibration ${ROOT_LIBRARIES} -lSpectrum NPCore NPPhysics) install(FILES NPCalibrationSource.h NPSiliconCalibrator.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Core/CMakeLists.txt b/NPLib/Core/CMakeLists.txt index 9bf6b2c319ca55a04be36e9627dd3d7038d946b5..b5fc0cff91488663d5b90d483c1fe1e68ea2d865 100644 --- a/NPLib/Core/CMakeLists.txt +++ b/NPLib/Core/CMakeLists.txt @@ -1,7 +1,7 @@ -add_custom_command(OUTPUT TAsciiFileDict.cxx COMMAND ../scripts/build_dict.sh TAsciiFile.h TAsciiFileDict.cxx TAsciiFile.rootmap libNPCore.so) -add_custom_command(OUTPUT NPDeltaSpectraDict.cxx COMMAND ../scripts/build_dict.sh NPDeltaSpectra.h NPDeltaSpectraDict.cxx NPDeltaSpectra.rootmap libNPCore.so NPDeltaSpectraLinkdef.h) +add_custom_command(OUTPUT TAsciiFileDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAsciiFile.h TAsciiFileDict.cxx TAsciiFile.rootmap libNPCore.so) +add_custom_command(OUTPUT NPDeltaSpectraDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPDeltaSpectra.h NPDeltaSpectraDict.cxx NPDeltaSpectra.rootmap libNPCore.so NPDeltaSpectraLinkdef.h) -add_custom_command(OUTPUT NPVDetectorDict.cxx COMMAND ../scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h) +add_custom_command(OUTPUT NPVDetectorDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h) add_library(NPCore SHARED NPCore.cxx NPRandom.cxx NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDeltaSpectraDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx NPImage.cxx NPElog.cxx NPDeltaSpectra.cxx) target_link_libraries(NPCore ${ROOT_LIBRARIES}) install(FILES NPCore.h NPVAnalysis.h NPAnalysisFactory.h NPRandom.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h NPImage.h NPElog.h NPDeltaSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Core/NPOptionManager.cxx b/NPLib/Core/NPOptionManager.cxx index 25b2beecf2fa88ebfa64173c31e76c13f8fecc1a..8a42e82e6da5d3cd815e1e445b31f6aa994b0583 100644 --- a/NPLib/Core/NPOptionManager.cxx +++ b/NPLib/Core/NPOptionManager.cxx @@ -1,4 +1,4 @@ -/***************************************************************************** +;/***************************************************************************** * Copyright (C) 2009-2016 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * @@ -73,6 +73,7 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ fNumberOfEntryToAnalyse = -1; fFirstEntryToAnalyse = 0; fSpectraServerPort = 9092; + fRandomSeed = -1; fDisableAllBranchOption = false; fInputPhysicalTreeOption = false; fGenerateHistoOption = false ; @@ -95,7 +96,7 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ - for (int i = 0; i < argc; i++) { + for (int i = 1; i < argc; i++) { std::string argument = argv[i]; if (argument == "-H" || argument == "-h" || argument == "--help") DisplayHelp(); @@ -151,6 +152,8 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ else if (argument == "-L") fNumberOfEntryToAnalyse = atoi(argv[++i]) ; + else if (argument == "--random-seed") fRandomSeed = atoi(argv[++i]) ; + else if (argument == "-F") fFirstEntryToAnalyse = atoi(argv[++i]); else if (argument == "--last-sim") fLastSimFile = true ; @@ -165,8 +168,11 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ else if (argument == "--circular") {fCircularTree = true;} + else if (argument == "--definition" && argc >= i + 1) {std::string def= argv[++i];fDefinition.insert(def);} - //else ; + else{ + SendErrorAndExit(argument.c_str()); + } } CheckArguments(); if(argc!=0) @@ -381,7 +387,8 @@ void NPOptionManager::SendErrorAndExit(const char* type) const{ } else { - std::cout << "NPOptionManager::SendErrorAndExit() unkwown keyword" << std::endl; + std::cout << "NPOptionManager::SendErrorAndExit() unkwown program argument: " << type << std::endl; + exit(1); } } @@ -396,6 +403,7 @@ void NPOptionManager::DisplayHelp(){ std::cout << "\t--event-generator -E <arg>\tSet arg as the event generator file" << std::endl ; std::cout << "\t--output -O <arg>\t\tSet arg as the Output File Name (output tree)" << std::endl ; std::cout << "\t--tree-name <arg>\t\tSet arg as the Output Tree Name " << std::endl ; + std::cout << "\t--definition <definition> \tAdd <definition> to the list of definition" << std::endl ; std::cout << "\t--verbose -V <arg>\t\tSet the verbose level, 0 for nothing, 1 for normal printout."<<std::endl; std::cout << "\t\t\t\t\tError and warning are not affected" << std::endl ; std::cout << std::endl << "NPAnalysis only:"<<std::endl; @@ -419,7 +427,7 @@ void NPOptionManager::DisplayHelp(){ std::cout << std::endl << "NPSimulation only:"<<std::endl; std::cout << "\t-M <arg>\t\t\tExecute Geant4 macro <arg> at startup" << std::endl ; std::cout << "\t-B <arg>\t\t\tExecute in batch mode (no ui) with Geant4 macro <arg> at startup" << std::endl ; - + std::cout << "\t--random-seed <arg>\t\tSet the random generator seed to <arg> (unsigned int)" << std::endl ; std::cout << std::endl << std::endl ; // exit current program diff --git a/NPLib/Core/NPOptionManager.h b/NPLib/Core/NPOptionManager.h index a21212b3663824c76f598ba6079c32102343ad2b..a628d8fe0edaee7e1194d0f4ba62eaef47f8de28 100644 --- a/NPLib/Core/NPOptionManager.h +++ b/NPLib/Core/NPOptionManager.h @@ -26,6 +26,7 @@ // C++ headers #include <iostream> #include <string> +#include <set> class NPOptionManager{ public: @@ -107,6 +108,7 @@ class NPOptionManager{ int GetNumberOfEntryToAnalyse() {return fNumberOfEntryToAnalyse;} int GetFirstEntryToAnalyse() {return fFirstEntryToAnalyse;} int GetSpectraServerPort() {return fSpectraServerPort;} + int GetRandomSeed() {return fRandomSeed;} std::string GetSharedLibExtension() {return fSharedLibExtension;} std::string GetLastFile(); @@ -115,7 +117,10 @@ class NPOptionManager{ void SetDetectorFile(const std::string& name) {fDetectorFileName = name;CheckDetectorConfiguration();} void SetRunToReadFile(const std::string& name) {fRunToReadFileName = name;} void SetVerboseLevel(int VerboseLevel) {fVerboseLevel = VerboseLevel;} - + + public: // user definition + bool HasDefinition(std::string def) {return(fDefinition.find(def)!=fDefinition.end());} + private: // default values std::string fDefaultReactionFileName; @@ -125,7 +130,7 @@ class NPOptionManager{ std::string fDefaultOutputFileName; std::string fDefaultOutputTreeName; std::string fDefaultG4MacroPath; - + // assigned values std::string fReactionFileName; std::string fDetectorFileName; @@ -148,9 +153,11 @@ class NPOptionManager{ int fNumberOfEntryToAnalyse; // use to limit the number of analysed in NPA int fFirstEntryToAnalyse; // use to set the first event analysed in NPA (total: fFirstEntryToAnalyse -> fFirstEntryToAnalyse + fNumberOfEntryToAnalyse) int fSpectraServerPort; + int fRandomSeed; std::string fSharedLibExtension; // lib extension is platform dependent std::string fG4MacroPath; // Path to a geant4 macro to execute at start of nps bool fG4BatchMode; // Execute geant4 in batch mode, running the given macro + std::set<std::string> fDefinition; // a set of user defined definition }; #endif diff --git a/NPLib/Detectors/AGATA/CMakeLists.txt b/NPLib/Detectors/AGATA/CMakeLists.txt index 0e21e9bbde0782565ff5d9db8c19b65958c79349..eefb98e970153a025d407c63e01c484fe1a6e869 100644 --- a/NPLib/Detectors/AGATA/CMakeLists.txt +++ b/NPLib/Detectors/AGATA/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TAGATAPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TAGATAPhysics.h TAGATAPhysicsDict.cxx TAGATAPhysics.rootmap libNPAGATA.dylib DEPENDS TAGATAPhysics.h) -add_custom_command(OUTPUT TAGATADataDict.cxx COMMAND ../../scripts/build_dict.sh TAGATAData.h TAGATADataDict.cxx TAGATAData.rootmap libNPAGATA.dylib DEPENDS TAGATAData.h) +add_custom_command(OUTPUT TAGATAPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAGATAPhysics.h TAGATAPhysicsDict.cxx TAGATAPhysics.rootmap libNPAGATA.dylib DEPENDS TAGATAPhysics.h) +add_custom_command(OUTPUT TAGATADataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAGATAData.h TAGATADataDict.cxx TAGATAData.rootmap libNPAGATA.dylib DEPENDS TAGATAData.h) add_library(NPAGATA SHARED TAGATASpectra.cxx TAGATAData.cxx TAGATAPhysics.cxx TAGATADataDict.cxx TAGATAPhysicsDict.cxx ) target_link_libraries(NPAGATA ${ROOT_LIBRARIES} NPCore) install(FILES TAGATAData.h TAGATAPhysics.h TAGATASpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/AnnularCsI/CMakeLists.txt b/NPLib/Detectors/AnnularCsI/CMakeLists.txt index 07e1b7135cf976ddb7ee3e54c2a5ae08ff2b2bac..dfa7d196f442b6d2a0f65474917f6166c5f80e24 100644 --- a/NPLib/Detectors/AnnularCsI/CMakeLists.txt +++ b/NPLib/Detectors/AnnularCsI/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TAnnularCsIPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularCsIPhysics.h TAnnularCsIPhysicsDict.cxx TAnnularCsIPhysics.rootmap libNPAnnularCsI.dylib DEPENDS TAnnularCsIPhysics.h) -add_custom_command(OUTPUT TAnnularCsIDataDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularCsIData.h TAnnularCsIDataDict.cxx TAnnularCsIData.rootmap libNPAnnularCsI.dylib DEPENDS TAnnularCsIData.h) +add_custom_command(OUTPUT TAnnularCsIPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularCsIPhysics.h TAnnularCsIPhysicsDict.cxx TAnnularCsIPhysics.rootmap libNPAnnularCsI.dylib DEPENDS TAnnularCsIPhysics.h) +add_custom_command(OUTPUT TAnnularCsIDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularCsIData.h TAnnularCsIDataDict.cxx TAnnularCsIData.rootmap libNPAnnularCsI.dylib DEPENDS TAnnularCsIData.h) add_library(NPAnnularCsI SHARED TAnnularCsISpectra.cxx TAnnularCsIData.cxx TAnnularCsIPhysics.cxx TAnnularCsIDataDict.cxx TAnnularCsIPhysicsDict.cxx AnnularCsI_Utils.cxx) target_link_libraries(NPAnnularCsI ${ROOT_LIBRARIES} NPCore) install(FILES TAnnularCsIData.h TAnnularCsIPhysics.h TAnnularCsISpectra.h AnnularCsI_Utils.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/AnnularS1/CMakeLists.txt b/NPLib/Detectors/AnnularS1/CMakeLists.txt index b3317ab79dfac622852c05a475e86d2c825a12ae..d067d03dd2444a5c8c5f3490247987b7574f69c4 100644 --- a/NPLib/Detectors/AnnularS1/CMakeLists.txt +++ b/NPLib/Detectors/AnnularS1/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TAnnularS1PhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularS1Physics.h TAnnularS1PhysicsDict.cxx TAnnularS1Physics.rootmap libNPAnnularS1.dylib DEPENDS TAnnularS1Physics.h) -add_custom_command(OUTPUT TS1DataDict.cxx COMMAND ../../scripts/build_dict.sh TS1Data.h TS1DataDict.cxx TS1Data.rootmap libNPAnnularS1.dylib DEPENDS TS1Data.h) +add_custom_command(OUTPUT TAnnularS1PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularS1Physics.h TAnnularS1PhysicsDict.cxx TAnnularS1Physics.rootmap libNPAnnularS1.dylib DEPENDS TAnnularS1Physics.h) +add_custom_command(OUTPUT TS1DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TS1Data.h TS1DataDict.cxx TS1Data.rootmap libNPAnnularS1.dylib DEPENDS TS1Data.h) add_library(NPAnnularS1 SHARED TS1Data.cxx TAnnularS1Physics.cxx TS1DataDict.cxx TAnnularS1PhysicsDict.cxx) target_link_libraries(NPAnnularS1 ${ROOT_LIBRARIES} NPCore) install(FILES TS1Data.h TAnnularS1Physics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/AnnularS2/CMakeLists.txt b/NPLib/Detectors/AnnularS2/CMakeLists.txt index 2a7c6ad70a11a698ca91c755bf8c9eea18034886..f502012e31066e168d36110b7772284d6c9c96e4 100644 --- a/NPLib/Detectors/AnnularS2/CMakeLists.txt +++ b/NPLib/Detectors/AnnularS2/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TS2PhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TS2Physics.h TS2PhysicsDict.cxx TS2Physics.rootmap libNPAnnularS2.dylib DEPENDS TS2Physics.h) -add_custom_command(OUTPUT TS2DataDict.cxx COMMAND ../../scripts/build_dict.sh TS2Data.h TS2DataDict.cxx TS2Data.rootmap libNPAnnularS2.dylib DEPENDS TS2Data.h) +add_custom_command(OUTPUT TS2PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TS2Physics.h TS2PhysicsDict.cxx TS2Physics.rootmap libNPAnnularS2.dylib DEPENDS TS2Physics.h) +add_custom_command(OUTPUT TS2DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TS2Data.h TS2DataDict.cxx TS2Data.rootmap libNPAnnularS2.dylib DEPENDS TS2Data.h) add_library(NPAnnularS2 SHARED TS2Data.cxx TS2Physics.cxx TS2DataDict.cxx TS2PhysicsDict.cxx ) target_link_libraries(NPAnnularS2 ${ROOT_LIBRARIES} NPCore) install(FILES TS2Data.h TS2Physics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/AnnularS4/CMakeLists.txt b/NPLib/Detectors/AnnularS4/CMakeLists.txt index 570d77d958b1da5f447b4fadf31bd65d56081516..4c8b98b7419baad9824bcbd1a830a1d9ca2613da 100644 --- a/NPLib/Detectors/AnnularS4/CMakeLists.txt +++ b/NPLib/Detectors/AnnularS4/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TAnnularS4PhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularS4Physics.h TAnnularS4PhysicsDict.cxx TAnnularS4Physics.rootmap libNPAnnularS4.dylib DEPENDS TAnnularS4Physics.h) -add_custom_command(OUTPUT TAnnularS4DataDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularS4Data.h TAnnularS4DataDict.cxx TAnnularS4Data.rootmap libNPAnnularS4.dylib DEPENDS TAnnularS4Data.h) +add_custom_command(OUTPUT TAnnularS4PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularS4Physics.h TAnnularS4PhysicsDict.cxx TAnnularS4Physics.rootmap libNPAnnularS4.dylib DEPENDS TAnnularS4Physics.h) +add_custom_command(OUTPUT TAnnularS4DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularS4Data.h TAnnularS4DataDict.cxx TAnnularS4Data.rootmap libNPAnnularS4.dylib DEPENDS TAnnularS4Data.h) add_library(NPAnnularS4 SHARED TAnnularS4Spectra.cxx TAnnularS4Data.cxx TAnnularS4Physics.cxx TAnnularS4DataDict.cxx TAnnularS4PhysicsDict.cxx ) target_link_libraries(NPAnnularS4 ${ROOT_LIBRARIES} NPCore) install(FILES TAnnularS4Data.h TAnnularS4Physics.h TAnnularS4Spectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/AnnularTelescope/CMakeLists.txt b/NPLib/Detectors/AnnularTelescope/CMakeLists.txt index a84cdcfe3437b3ba1fec3a476cc3fb3585cd498e..81faffe0ca26b9cc01d78c6acaaf6a748fd529b0 100644 --- a/NPLib/Detectors/AnnularTelescope/CMakeLists.txt +++ b/NPLib/Detectors/AnnularTelescope/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TAnnularTelescopePhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularTelescopePhysics.h TAnnularTelescopePhysicsDict.cxx TAnnularTelescopePhysics.rootmap libNPAnnularTelescope.dylib DEPENDS TAnnularTelescopePhysics.h) -add_custom_command(OUTPUT TAnnularTelescopeDataDict.cxx COMMAND ../../scripts/build_dict.sh TAnnularTelescopeData.h TAnnularTelescopeDataDict.cxx TAnnularTelescopeData.rootmap libNPAnnularTelescope.dylib DEPENDS TAnnularTelescopeData.h) +add_custom_command(OUTPUT TAnnularTelescopePhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularTelescopePhysics.h TAnnularTelescopePhysicsDict.cxx TAnnularTelescopePhysics.rootmap libNPAnnularTelescope.dylib DEPENDS TAnnularTelescopePhysics.h) +add_custom_command(OUTPUT TAnnularTelescopeDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TAnnularTelescopeData.h TAnnularTelescopeDataDict.cxx TAnnularTelescopeData.rootmap libNPAnnularTelescope.dylib DEPENDS TAnnularTelescopeData.h) add_library(NPAnnularTelescope SHARED TAnnularTelescopeSpectra.cxx TAnnularTelescopeData.cxx TAnnularTelescopePhysics.cxx TAnnularTelescopeDataDict.cxx TAnnularTelescopePhysicsDict.cxx AnnularTelescope_Utils.cxx) target_link_libraries(NPAnnularTelescope ${ROOT_LIBRARIES} NPCore) install(FILES TAnnularTelescopeData.h TAnnularTelescopePhysics.h TAnnularTelescopeSpectra.h AnnularTelescope_Utils.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/CATS/CMakeLists.txt b/NPLib/Detectors/CATS/CMakeLists.txt index cfc5685586195a2e025dd198cfe9a08a897ef02a..3eab080524bdaa1f73869fe48ba41b2f1db398fb 100644 --- a/NPLib/Detectors/CATS/CMakeLists.txt +++ b/NPLib/Detectors/CATS/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TCATSPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TCATSPhysics.h TCATSPhysicsDict.cxx TCATSPhysics.rootmap libNPCATS.dylib DEPENDS TCATSPhysics.h) -add_custom_command(OUTPUT TCATSDataDict.cxx COMMAND ../../scripts/build_dict.sh TCATSData.h TCATSDataDict.cxx TCATSData.rootmap libNPCATS.dylib DEPENDS TCATSData.h) +add_custom_command(OUTPUT TCATSPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TCATSPhysics.h TCATSPhysicsDict.cxx TCATSPhysics.rootmap libNPCATS.dylib DEPENDS TCATSPhysics.h) +add_custom_command(OUTPUT TCATSDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TCATSData.h TCATSDataDict.cxx TCATSData.rootmap libNPCATS.dylib DEPENDS TCATSData.h) add_library(NPCATS SHARED TCATSData.cxx TCATSPhysics.cxx TCATSDataDict.cxx TCATSPhysicsDict.cxx TCATSSpectra.cxx) target_link_libraries(NPCATS ${ROOT_LIBRARIES} NPCore) install(FILES TCATSData.h TCATSPhysics.h TCATSSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Charissa/CMakeLists.txt b/NPLib/Detectors/Charissa/CMakeLists.txt index 2e30231ddf2cf8139ad689daa385bf899d539ccb..48abe8fe207fc9ad4e602f3d605c715438bf7beb 100644 --- a/NPLib/Detectors/Charissa/CMakeLists.txt +++ b/NPLib/Detectors/Charissa/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TCharissaPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TCharissaPhysics.h TCharissaPhysicsDict.cxx TCharissaPhysics.rootmap libNPCharissa.dylib DEPENDS TCharissaPhysics.h) -add_custom_command(OUTPUT TCharissaDataDict.cxx COMMAND ../../scripts/build_dict.sh TCharissaData.h TCharissaDataDict.cxx TCharissaData.rootmap libNPCharissa.dylib DEPENDS TCharissaData.h) +add_custom_command(OUTPUT TCharissaPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TCharissaPhysics.h TCharissaPhysicsDict.cxx TCharissaPhysics.rootmap libNPCharissa.dylib DEPENDS TCharissaPhysics.h) +add_custom_command(OUTPUT TCharissaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TCharissaData.h TCharissaDataDict.cxx TCharissaData.rootmap libNPCharissa.dylib DEPENDS TCharissaData.h) add_library(NPCharissa SHARED TCharissaData.cxx TCharissaPhysics.cxx TCharissaDataDict.cxx TCharissaPhysicsDict.cxx TCharissaSpectra.cxx) target_link_libraries(NPCharissa ${ROOT_LIBRARIES} NPCore) install(FILES TCharissaData.h TCharissaPhysics.h TCharissaSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/ChateauCristal/CMakeLists.txt b/NPLib/Detectors/ChateauCristal/CMakeLists.txt index 7da76b7e702bf7da304f823e9d515db4d68d670c..5d87ea50d0d99f2acb33590ec0d16131100075fb 100644 --- a/NPLib/Detectors/ChateauCristal/CMakeLists.txt +++ b/NPLib/Detectors/ChateauCristal/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TChateauCristalPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TChateauCristalPhysics.h TChateauCristalPhysicsDict.cxx TChateauCristalPhysics.rootmap libNPChateauCristal.dylib DEPENDS TChateauCristalPhysics.h) -add_custom_command(OUTPUT TChateauCristalDataDict.cxx COMMAND ../../scripts/build_dict.sh TChateauCristalData.h TChateauCristalDataDict.cxx TChateauCristalData.rootmap libNPChateauCristal.dylib DEPENDS TChateauCristalData.h) +add_custom_command(OUTPUT TChateauCristalPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChateauCristalPhysics.h TChateauCristalPhysicsDict.cxx TChateauCristalPhysics.rootmap libNPChateauCristal.dylib DEPENDS TChateauCristalPhysics.h) +add_custom_command(OUTPUT TChateauCristalDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChateauCristalData.h TChateauCristalDataDict.cxx TChateauCristalData.rootmap libNPChateauCristal.dylib DEPENDS TChateauCristalData.h) add_library(NPChateauCristal SHARED TChateauCristalData.cxx TChateauCristalPhysics.cxx TChateauCristalDataDict.cxx TChateauCristalPhysicsDict.cxx ) target_link_libraries(NPChateauCristal ${ROOT_LIBRARIES} NPCore) install(FILES TChateauCristalData.h TChateauCristalPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/ChiNu/CMakeLists.txt b/NPLib/Detectors/ChiNu/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..65901944efb3089f69f9fd7ed3d922bd06dfed46 --- /dev/null +++ b/NPLib/Detectors/ChiNu/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TChiNuPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChiNuPhysics.h TChiNuPhysicsDict.cxx TChiNuPhysics.rootmap libNPChiNu.dylib DEPENDS TChiNuPhysics.h) +add_custom_command(OUTPUT TChiNuDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChiNuData.h TChiNuDataDict.cxx TChiNuData.rootmap libNPChiNu.dylib DEPENDS TChiNuData.h) +add_library(NPChiNu SHARED TChiNuSpectra.cxx TChiNuData.cxx TChiNuPhysics.cxx TChiNuDataDict.cxx TChiNuPhysicsDict.cxx ) +target_link_libraries(NPChiNu ${ROOT_LIBRARIES} NPCore) +install(FILES TChiNuData.h TChiNuPhysics.h TChiNuSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/ChiNu/TChiNuData.cxx b/NPLib/Detectors/ChiNu/TChiNuData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..93290619cafb5eb0dbd74ee5f8716ea514a8b213 --- /dev/null +++ b/NPLib/Detectors/ChiNu/TChiNuData.cxx @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : February 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold ChiNu Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TChiNuData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TChiNuData) + + +////////////////////////////////////////////////////////////////////// +TChiNuData::TChiNuData() { +} + + + +////////////////////////////////////////////////////////////////////// +TChiNuData::~TChiNuData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TChiNuData::Clear() { + // Energy + fChiNu_E_DetectorNbr.clear(); + fChiNu_Energy.clear(); + // Time + fChiNu_T_DetectorNbr.clear(); + fChiNu_Time.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TChiNuData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TChiNuData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fChiNu_E_DetectorNbr.size(); + cout << "ChiNu_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fChiNu_E_DetectorNbr[i] + << " Energy: " << fChiNu_Energy[i]; + } + + // Time + mysize = fChiNu_T_DetectorNbr.size(); + cout << "ChiNu_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fChiNu_T_DetectorNbr[i] + << " Time: " << fChiNu_Time[i]; + } +} diff --git a/NPLib/Detectors/ChiNu/TChiNuData.h b/NPLib/Detectors/ChiNu/TChiNuData.h new file mode 100644 index 0000000000000000000000000000000000000000..c4b01d371fe718e5dff20a9bb40a1f2c2f4fc030 --- /dev/null +++ b/NPLib/Detectors/ChiNu/TChiNuData.h @@ -0,0 +1,104 @@ +#ifndef __ChiNuDATA__ +#define __ChiNuDATA__ +/***************************************************************************** + * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : February 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold ChiNu Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TChiNuData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // Energy + vector<UShort_t> fChiNu_E_DetectorNbr; + vector<Double_t> fChiNu_Energy; + + // Time + vector<UShort_t> fChiNu_T_DetectorNbr; + vector<Double_t> fChiNu_Time; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TChiNuData(); + ~TChiNuData(); + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + ////////////////////////////////////////////////////////////// + // Getters and Setters + // Prefer inline declaration to avoid unnecessary called of + // frequently used methods + // add //! to avoid ROOT creating dictionnary for the methods + public: + ////////////////////// SETTERS //////////////////////// + // Energy + inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){ + fChiNu_E_DetectorNbr.push_back(DetNbr); + fChiNu_Energy.push_back(Energy); + };//! + + // Time + inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) { + fChiNu_T_DetectorNbr.push_back(DetNbr); + fChiNu_Time.push_back(Time); + };//! + + + ////////////////////// GETTERS //////////////////////// + // Energy + inline UShort_t GetMultEnergy() const + {return fChiNu_E_DetectorNbr.size();} + inline UShort_t GetE_DetectorNbr(const unsigned int &i) const + {return fChiNu_E_DetectorNbr[i];}//! + inline Double_t Get_Energy(const unsigned int &i) const + {return fChiNu_Energy[i];}//! + + // Time + inline UShort_t GetMultTime() const + {return fChiNu_T_DetectorNbr.size();} + inline UShort_t GetT_DetectorNbr(const unsigned int &i) const + {return fChiNu_T_DetectorNbr[i];}//! + inline Double_t Get_Time(const unsigned int &i) const + {return fChiNu_Time[i];}//! + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TChiNuData,1) // ChiNuData structure +}; + +#endif diff --git a/NPLib/Detectors/ChiNu/TChiNuPhysics.cxx b/NPLib/Detectors/ChiNu/TChiNuPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bb1d4c3e8023a0a19155eb0bc9cac0bca5d0493b --- /dev/null +++ b/NPLib/Detectors/ChiNu/TChiNuPhysics.cxx @@ -0,0 +1,343 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : February 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold ChiNu Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TChiNuPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" + +// ROOT +#include "TChain.h" + +ClassImp(TChiNuPhysics) + + +/////////////////////////////////////////////////////////////////////////// +TChiNuPhysics::TChiNuPhysics() + : m_EventData(new TChiNuData), + m_PreTreatedData(new TChiNuData), + m_EventPhysics(this), + m_Spectra(0), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + m_NumberOfDetectors(0) { +} + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +void TChiNuPhysics::AddDetector(TVector3){ + // In That simple case nothing is done + // Typically for more complex detector one would calculate the relevant + // positions (stripped silicon) or angles (gamma array) + m_NumberOfDetectors++; +} + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::AddDetector(double R, double Theta, double Phi){ + // Compute the TVector3 corresponding + TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); + // Call the cartesian method + AddDetector(Pos); + m_DetectorPosition.push_back(Pos); +} + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::BuildPhysicalEvent() { + // apply thresholds and calibration + PreTreat(); + + // match energy and time together + unsigned int mysizeE = m_PreTreatedData->GetMultEnergy(); + unsigned int mysizeT = m_PreTreatedData->GetMultTime(); + for (UShort_t e = 0; e < mysizeE ; e++) { + for (UShort_t t = 0; t < mysizeT ; t++) { + if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) { + DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e)); + Energy.push_back(m_PreTreatedData->Get_Energy(e)); + Time.push_back(m_PreTreatedData->Get_Time(t)); + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::PreTreat() { + // This method typically applies thresholds and calibrations + // Might test for disabled channels for more complex detector + + // clear pre-treated object + ClearPreTreatedData(); + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + + // Energy + unsigned int mysize = m_EventData->GetMultEnergy(); + for (UShort_t i = 0; i < mysize ; ++i) { + if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = Cal->ApplyCalibration("ChiNu/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy); + } + } + } + + // Time + mysize = m_EventData->GetMultTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time= Cal->ApplyCalibration("ChiNu/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigChiNu.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigChiNu.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigChiNu.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigChiNu.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigChiNu"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + } + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::Clear() { + DetectorNumber.clear(); + Energy.clear(); + Time.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ChiNu"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS"}; + vector<string> sphe = {"R","Theta","Phi"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// ChiNu " << i+1 << endl; + + TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); + AddDetector(Pos); + } + else if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// ChiNu " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + AddDetector(R,Theta,Phi); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::InitSpectra() { + m_Spectra = new TChiNuSpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TChiNuPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("ChiNu", "D"+ NPL::itoa(i+1)+"_ENERGY","ChiNu_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("ChiNu", "D"+ NPL::itoa(i+1)+"_TIME","ChiNu_D"+ NPL::itoa(i+1)+"_TIME"); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("ChiNu", true ); + inputChain->SetBranchAddress("ChiNu", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("ChiNu", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TChiNuPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("ChiNu", "TChiNuPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TChiNuPhysics::Construct() { + return (NPL::VDetector*) new TChiNuPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_ChiNu{ + public: + proxy_ChiNu(){ + NPL::DetectorFactory::getInstance()->AddToken("ChiNu","ChiNu"); + NPL::DetectorFactory::getInstance()->AddDetector("ChiNu",TChiNuPhysics::Construct); + } +}; + +proxy_ChiNu p_ChiNu; +} + diff --git a/NPLib/Detectors/ChiNu/TChiNuPhysics.h b/NPLib/Detectors/ChiNu/TChiNuPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..6afd1af4956f7936823b704fdf265f066c3cefa4 --- /dev/null +++ b/NPLib/Detectors/ChiNu/TChiNuPhysics.h @@ -0,0 +1,182 @@ +#ifndef TChiNuPHYSICS_H +#define TChiNuPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : February 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold ChiNu Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> +#include <map> +#include <string> +using namespace std; + +// ROOT headers +#include "TObject.h" +#include "TH1.h" +#include "TVector3.h" +// NPTool headers +#include "TChiNuData.h" +#include "TChiNuSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TChiNuSpectra; + + + +class TChiNuPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TChiNuPhysics(); + ~TChiNuPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + + + ////////////////////////////////////////////////////////////// + // data obtained after BuildPhysicalEvent() and stored in + // output ROOT file + public: + vector<int> DetectorNumber; + vector<double> Energy; + vector<double> Time; + + /// A usefull method to bundle all operation to add a detector + void AddDetector(TVector3 POS); + void AddDetector(double R, double Theta, double Phi); + + double GetDetectorPosition(int DetNumber) {return m_DetectorPosition[DetNumber-1].Mag();} + TVector3 GetVectorDetectorPosition(int DetNumber) {return m_DetectorPosition[DetNumber-1];} + ////////////////////////////////////////////////////////////// + // methods inherited from the VDetector ABC class + public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); + + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // method called event by event, aiming at extracting the + // physical information from detector + void BuildPhysicalEvent(); + + // same as BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); + + // same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // activate raw data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // activate physics data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputPhysics(); + + // create branches of output ROOT file + void InitializeRootOutput(); + + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // methods related to the TChiNuSpectra class + // instantiate the TChiNuSpectra class and + // declare list of histograms + void InitSpectra(); + + // fill the spectra + void FillSpectra(); + + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); + + // used for Online only, clear all the spectra + void ClearSpectra(); + + // write spectra to ROOT output file + void WriteSpectra(); + + + ////////////////////////////////////////////////////////////// + // specific methods to ChiNu array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TChiNuData object to TChiNuPhysics. + // needed for online analysis for example + void SetRawDataPointer(TChiNuData* rawDataPointer) {m_EventData = rawDataPointer;} + + // objects are not written in the TTree + private: + TChiNuData* m_EventData; //! + TChiNuData* m_PreTreatedData; //! + TChiNuPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TChiNuData* GetRawData() const {return m_EventData;} + TChiNuData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + // number of detectors + private: + int m_NumberOfDetectors; //! + vector<TVector3> m_DetectorPosition; //! + // spectra class + private: + TChiNuSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TChiNuPhysics,1) // ChiNuPhysics structure +}; +#endif diff --git a/NPLib/Detectors/ChiNu/TChiNuSpectra.cxx b/NPLib/Detectors/ChiNu/TChiNuSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d4a25eb35dbd1c77f5b914e1343aa77402e165f4 --- /dev/null +++ b/NPLib/Detectors/ChiNu/TChiNuSpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : April 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold ChiNu Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TChiNuSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TChiNuSpectra::TChiNuSpectra() + : fNumberOfDetectors(0) { + SetName("ChiNu"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TChiNuSpectra::TChiNuSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TChiNuSpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("ChiNu"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TChiNuSpectra::~TChiNuSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TChiNuSpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "ChiNu"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "ChiNu/RAW"); + // Time + name = "ChiNu"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "ChiNu/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TChiNuSpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "ChiNu"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "ChiNu/CAL"); + // Time + name = "ChiNu"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "ChiNu/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TChiNuSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "ChiNu_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "ChiNu/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TChiNuSpectra::FillRawSpectra(TChiNuData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "ChiNu"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "ChiNu/RAW"; + + FillSpectra(family,name,RawData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "ChiNu"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; + family = "ChiNu/RAW"; + + FillSpectra(family,name,RawData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TChiNuSpectra::FillPreTreatedSpectra(TChiNuData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "ChiNu"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "ChiNu/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "ChiNu"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; + family = "ChiNu/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TChiNuSpectra::FillPhysicsSpectra(TChiNuPhysics* Physics) { + static string name; + static string family; + family= "ChiNu/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->Energy.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "ChiNu_ENERGY_TIME"; + FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/ChiNu/TChiNuSpectra.h b/NPLib/Detectors/ChiNu/TChiNuSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..3b74c1496344cefcf95864b651e8be86878e0caf --- /dev/null +++ b/NPLib/Detectors/ChiNu/TChiNuSpectra.h @@ -0,0 +1,62 @@ +#ifndef TChiNuSPECTRA_H +#define TChiNuSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : April 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold ChiNu Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TChiNuData.h" +#include "TChiNuPhysics.h" + +// Forward Declaration +class TChiNuPhysics; + + +class TChiNuSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TChiNuSpectra(); + TChiNuSpectra(unsigned int NumberOfDetectors); + ~TChiNuSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TChiNuData*); + void FillPreTreatedSpectra(TChiNuData*); + void FillPhysicsSpectra(TChiNuPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPLib/Detectors/Chio/CMakeLists.txt b/NPLib/Detectors/Chio/CMakeLists.txt index 1532dea305138a51727311ba9a39c6f2f28dcf7e..d00b2c64a6f13a33a97ec3825ffbd699bf1154f8 100644 --- a/NPLib/Detectors/Chio/CMakeLists.txt +++ b/NPLib/Detectors/Chio/CMakeLists.txt @@ -1,7 +1,7 @@ -add_custom_command(OUTPUT TChio_digPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TChio_digPhysics.h TChio_digPhysicsDict.cxx TChio_digPhysics.rootmap libNPChio.dylib DEPENDS TChio_digPhysics.h) -add_custom_command(OUTPUT TChio_anPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TChio_anPhysics.h TChio_anPhysicsDict.cxx TChio_anPhysics.rootmap libNPChio.dylib DEPENDS TChio_anPhysics.h) -add_custom_command(OUTPUT TChio_digDataDict.cxx COMMAND ../../scripts/build_dict.sh TChio_digData.h TChio_digDataDict.cxx TChio_digData.rootmap libNPChio.dylib DEPENDS TChio_digData.h) -add_custom_command(OUTPUT TChio_anDataDict.cxx COMMAND ../../scripts/build_dict.sh TChio_anData.h TChio_anDataDict.cxx TChio_anData.rootmap libNPChio.dylib DEPENDS TChio_anData.h) +add_custom_command(OUTPUT TChio_digPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChio_digPhysics.h TChio_digPhysicsDict.cxx TChio_digPhysics.rootmap libNPChio.dylib DEPENDS TChio_digPhysics.h) +add_custom_command(OUTPUT TChio_anPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChio_anPhysics.h TChio_anPhysicsDict.cxx TChio_anPhysics.rootmap libNPChio.dylib DEPENDS TChio_anPhysics.h) +add_custom_command(OUTPUT TChio_digDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChio_digData.h TChio_digDataDict.cxx TChio_digData.rootmap libNPChio.dylib DEPENDS TChio_digData.h) +add_custom_command(OUTPUT TChio_anDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TChio_anData.h TChio_anDataDict.cxx TChio_anData.rootmap libNPChio.dylib DEPENDS TChio_anData.h) add_library(NPChio SHARED TChio_anData.cxx TChio_anPhysics.cxx TChio_anDataDict.cxx TChio_anPhysicsDict.cxx TChio_digData.cxx TChio_digPhysics.cxx TChio_digDataDict.cxx TChio_digPhysicsDict.cxx ) target_link_libraries(NPChio ${ROOT_LIBRARIES} NPCore) diff --git a/NPLib/Detectors/ComptonTelescope/CMakeLists.txt b/NPLib/Detectors/ComptonTelescope/CMakeLists.txt index 930c7583ec4e04643138f5fae63fd8cff6bb7739..585d18e7079b3f5a82a59077869157ad77f07d0d 100644 --- a/NPLib/Detectors/ComptonTelescope/CMakeLists.txt +++ b/NPLib/Detectors/ComptonTelescope/CMakeLists.txt @@ -1,6 +1,6 @@ -add_custom_command(OUTPUT TComptonTelescopePhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TComptonTelescopePhysics.h TComptonTelescopePhysicsDict.cxx TComptonTelescopePhysics.rootmap libNPComptonTelescope.dylib DEPENDS TComptonTelescopePhysics.h) -add_custom_command(OUTPUT TComptonTelescopeProcessDataDict.cxx COMMAND ../../scripts/build_dict.sh TComptonTelescopeProcessData.h TComptonTelescopeProcessDataDict.cxx TComptonTelescopeProcessData.rootmap libNPComptonTelescope.dylib DEPENDS TComptonTelescopeProcessData.h) -add_custom_command(OUTPUT TComptonTelescopeDataDict.cxx COMMAND ../../scripts/build_dict.sh TComptonTelescopeData.h TComptonTelescopeDataDict.cxx TComptonTelescopeData.rootmap libNPComptonTelescope.dylib DEPENDS TComptonTelescopeData.h) +add_custom_command(OUTPUT TComptonTelescopePhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TComptonTelescopePhysics.h TComptonTelescopePhysicsDict.cxx TComptonTelescopePhysics.rootmap libNPComptonTelescope.dylib DEPENDS TComptonTelescopePhysics.h) +add_custom_command(OUTPUT TComptonTelescopeProcessDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TComptonTelescopeProcessData.h TComptonTelescopeProcessDataDict.cxx TComptonTelescopeProcessData.rootmap libNPComptonTelescope.dylib DEPENDS TComptonTelescopeProcessData.h) +add_custom_command(OUTPUT TComptonTelescopeDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TComptonTelescopeData.h TComptonTelescopeDataDict.cxx TComptonTelescopeData.rootmap libNPComptonTelescope.dylib DEPENDS TComptonTelescopeData.h) add_library(NPComptonTelescope SHARED TComptonTelescopeData.cxx TComptonTelescopePhysics.cxx TComptonTelescopeDataDict.cxx TComptonTelescopePhysicsDict.cxx TComptonTelescopeSpectra.cxx TComptonTelescopeProcessData.cxx TComptonTelescopeProcessDataDict.cxx) target_link_libraries(NPComptonTelescope ${ROOT_LIBRARIES} NPCore) install(FILES TComptonTelescopeProcessData.h TComptonTelescopeData.h TComptonTelescopePhysics.h TComptonTelescopeSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/CsI/CMakeLists.txt b/NPLib/Detectors/CsI/CMakeLists.txt index 6c60751b109c9701a91cb35c425842c4a24f5dec..d07c9c57410666e536b15adfc1672a1a25be5b13 100644 --- a/NPLib/Detectors/CsI/CMakeLists.txt +++ b/NPLib/Detectors/CsI/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TCsIPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TCsIPhysics.h TCsIPhysicsDict.cxx TCsIPhysics.rootmap libNPCsI.dylib DEPENDS TCsIPhysics.h) -add_custom_command(OUTPUT TCsIDataDict.cxx COMMAND ../../scripts/build_dict.sh TCsIData.h TCsIDataDict.cxx TCsIData.rootmap libNPCsI.dylib DEPENDS TCsIData.h) +add_custom_command(OUTPUT TCsIPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TCsIPhysics.h TCsIPhysicsDict.cxx TCsIPhysics.rootmap libNPCsI.dylib DEPENDS TCsIPhysics.h) +add_custom_command(OUTPUT TCsIDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TCsIData.h TCsIDataDict.cxx TCsIData.rootmap libNPCsI.dylib DEPENDS TCsIData.h) add_library(NPCsI SHARED TCsIData.cxx TCsIPhysics.cxx TCsIDataDict.cxx TCsIPhysicsDict.cxx ) target_link_libraries(NPCsI ${ROOT_LIBRARIES} NPCore) install(FILES TCsIData.h TCsIPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Dali/CMakeLists.txt b/NPLib/Detectors/Dali/CMakeLists.txt index 7e3a9c4d3f5be7ad882a84e51a0806c0d6287ee3..b508778c268a676661bbdaee0f4f553a870b6ff3 100644 --- a/NPLib/Detectors/Dali/CMakeLists.txt +++ b/NPLib/Detectors/Dali/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TDaliPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TDaliPhysics.h TDaliPhysicsDict.cxx TDaliPhysics.rootmap libNPDali.dylib DEPENDS TDaliPhysics.h) -add_custom_command(OUTPUT TDaliDataDict.cxx COMMAND ../../scripts/build_dict.sh TDaliData.h TDaliDataDict.cxx TDaliData.rootmap libNPDali.dylib DEPENDS TDaliData.h) +add_custom_command(OUTPUT TDaliPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TDaliPhysics.h TDaliPhysicsDict.cxx TDaliPhysics.rootmap libNPDali.dylib DEPENDS TDaliPhysics.h) +add_custom_command(OUTPUT TDaliDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TDaliData.h TDaliDataDict.cxx TDaliData.rootmap libNPDali.dylib DEPENDS TDaliData.h) add_library(NPDali SHARED TDaliSpectra.cxx TDaliData.cxx TDaliPhysics.cxx TDaliDataDict.cxx TDaliPhysicsDict.cxx ) target_link_libraries(NPDali ${ROOT_LIBRARIES} NPCore) install(FILES TDaliData.h TDaliPhysics.h TDaliSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Dali/TDaliData.cxx b/NPLib/Detectors/Dali/TDaliData.cxx index 542de349e870945908a19791576e294c234fefa6..70bc43ecbad125333353ae25e26f97e845fb84c2 100644 --- a/NPLib/Detectors/Dali/TDaliData.cxx +++ b/NPLib/Detectors/Dali/TDaliData.cxx @@ -52,10 +52,13 @@ void TDaliData::Clear() { fDali_T_DetectorNbr.clear(); fDali_TDC.clear(); fDali_Time.clear(); + + /* fDali_ParticleID.clear(); */ } + ////////////////////////////////////////////////////////////////////// void TDaliData::Dump() const { // This method is very useful for debuging and worth the dev. diff --git a/NPLib/Detectors/Dali/TDaliData.h b/NPLib/Detectors/Dali/TDaliData.h index 43c26549f4c3d8fd256d839ddc66fe280d79b2d6..6c58a2fd80bb51adb1f546c557edf22edfbbdf4a 100644 --- a/NPLib/Detectors/Dali/TDaliData.h +++ b/NPLib/Detectors/Dali/TDaliData.h @@ -44,13 +44,12 @@ class TDaliData : public TObject { vector<Double_t> fDali_TDC; vector<Double_t> fDali_Time; - + /* vector<Int_t> fDali_ParticleID; */ ////////////////////////////////////////////////////////////// // Constructor and destructor public: TDaliData(); ~TDaliData(); - ////////////////////////////////////////////////////////////// // Inherited from TObject and overriden to avoid warnings @@ -59,7 +58,6 @@ class TDaliData : public TObject { void Clear(const Option_t*) {}; void Dump() const; - ////////////////////////////////////////////////////////////// // Getters and Setters // Prefer inline declaration to avoid unnecessary called of @@ -93,6 +91,11 @@ class TDaliData : public TObject { fDali_T_DetectorNbr.push_back(DetNbr); fDali_Time.push_back(Time); };//! + + // ID for simulation + /* inline void SetParticleID(const Int_t& ID) { */ + /* fDali_ParticleID.push_back(ID); */ + /* };//! */ // (A&T DC) inline void SetADCAndTDC(const UShort_t& DetNbr,const Double_t& Energy,const Double_t& Time){ @@ -133,7 +136,9 @@ class TDaliData : public TObject { inline Double_t Get_Time(const unsigned int &i) const {return fDali_Time[i];}//! - + + /* inline Int_t GetParticleID(const unsigned int &i) const */ + /* {return fDali_ParticleID[i];}//! */ ////////////////////////////////////////////////////////////// // Required for ROOT dictionnary ClassDef(TDaliData,1) // DaliData structure diff --git a/NPLib/Detectors/Dali/TDaliPhysics.cxx b/NPLib/Detectors/Dali/TDaliPhysics.cxx index 11df06300100125dee5587f1212aabe3933dfd70..72f870f57b62e15db01fae952424ee062c4f36ce 100644 --- a/NPLib/Detectors/Dali/TDaliPhysics.cxx +++ b/NPLib/Detectors/Dali/TDaliPhysics.cxx @@ -75,8 +75,6 @@ void TDaliPhysics::BuildSimplePhysicalEvent() { BuildPhysicalEvent(); } - - /////////////////////////////////////////////////////////////////////////// void TDaliPhysics::BuildPhysicalEvent() { // apply thresholds and calibration @@ -94,6 +92,8 @@ void TDaliPhysics::BuildPhysicalEvent() { } } } + + } /////////////////////////////////////////////////////////////////////////// @@ -110,6 +110,8 @@ void TDaliPhysics::PreTreat() { // Energy unsigned int mysize = m_EventData->GetMultEnergy(); for (UShort_t i = 0; i < mysize ; ++i) { + + /* ParticleID.push_back(m_EventData->GetParticleID(i)); */ if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) { Double_t Energy = Cal->ApplyCalibration("Dali/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); if (Energy > m_E_Threshold) { @@ -124,10 +126,11 @@ void TDaliPhysics::PreTreat() { Double_t Time= Cal->ApplyCalibration("Dali/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time); } -} +} + /////////////////////////////////////////////////////////////////////////// void TDaliPhysics::ReadAnalysisConfig() { bool ReadingStatus = false; @@ -190,13 +193,12 @@ void TDaliPhysics::ReadAnalysisConfig() { } } - - /////////////////////////////////////////////////////////////////////////// void TDaliPhysics::Clear() { DetectorNumber.clear(); Energy.clear(); Time.clear(); + /* ParticleID.clear(); */ } @@ -207,32 +209,32 @@ void TDaliPhysics::ReadConfiguration(NPL::InputParser parser) { if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> cart = {"POS","Shape"}; - vector<string> sphe = {"R","Theta","Phi","Shape"}; + /* vector<string> cart = {"POS","Shape"}; */ + /* vector<string> sphe = {"R","Theta","Phi","Shape"}; */ - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Dali " << i+1 << endl; + /* for(unsigned int i = 0 ; i < blocks.size() ; i++){ */ + /* if(blocks[i]->HasTokenList(cart)){ */ + /* if(NPOptionManager::getInstance()->GetVerboseLevel()) */ + /* cout << endl << "//// Dali " << i+1 << endl; */ - TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(Pos,Shape); - } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Dali " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(R,Theta,Phi,Shape); - } - else{ - cout << "ERROR: check your input file formatting " << endl; - exit(1); - } - } + /* TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); */ + /* string Shape = blocks[i]->GetString("Shape"); */ + /* AddDetector(Pos,Shape); */ + /* } */ + /* else if(blocks[i]->HasTokenList(sphe)){ */ + /* if(NPOptionManager::getInstance()->GetVerboseLevel()) */ + /* cout << endl << "//// Dali " << i+1 << endl; */ + /* double R = blocks[i]->GetDouble("R","mm"); */ + /* double Theta = blocks[i]->GetDouble("Theta","deg"); */ + /* double Phi = blocks[i]->GetDouble("Phi","deg"); */ + /* string Shape = blocks[i]->GetString("Shape"); */ + /* AddDetector(R,Theta,Phi,Shape); */ + /* } */ + /* else{ */ + /* cout << "ERROR: check your input file formatting " << endl; */ + /* exit(1); */ + /* } */ + /* } */ } /////////////////////////////////////////////////////////////////////////// diff --git a/NPLib/Detectors/Dali/TDaliPhysics.h b/NPLib/Detectors/Dali/TDaliPhysics.h index 60d4a5cade4844fd193e7d1a579b3a909ffb6574..39a60b4e3a555d749dd99517edbbd59bdf81717b 100644 --- a/NPLib/Detectors/Dali/TDaliPhysics.h +++ b/NPLib/Detectors/Dali/TDaliPhysics.h @@ -67,6 +67,7 @@ class TDaliPhysics : public TObject, public NPL::VDetector { vector<double> Energy; vector<double> TDC; vector<double> Time; + /* vector<int> ParticleID; */ /// A usefull method to bundle all operation to add a detector void AddDetector(TVector3 POS, string shape); @@ -155,6 +156,16 @@ class TDaliPhysics : public TObject, public NPL::VDetector { TDaliData* GetRawData() const {return m_EventData;} TDaliData* GetPreTreatedData() const {return m_PreTreatedData;} + // Use to access energies et det number + + int GetDetNumber(const int &i) const {return DetectorNumber[i];}; + int GetMultEnergy() const {return Energy.size();}; + double GetEnergy(const int &i) const {return Energy[i];}; + /* int GetParticleID(const int &i) const {return ParticleID[i];}; */ + + + + // parameters used in the analysis private: // thresholds diff --git a/NPLib/Detectors/EXL/CMakeLists.txt b/NPLib/Detectors/EXL/CMakeLists.txt index 90d72bbe46f82a9160e8ae261a2f573c54fa31ef..2349f4860722d522822aa1ee1b36e6c46821a8ba 100644 --- a/NPLib/Detectors/EXL/CMakeLists.txt +++ b/NPLib/Detectors/EXL/CMakeLists.txt @@ -1,6 +1,6 @@ -add_custom_command(OUTPUT TExlPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TExlPhysics.h TExlPhysicsDict.cxx TExlPhysics.rootmap libNPEXL.dylib DEPENDS TExlPhysics.h) -add_custom_command(OUTPUT TExlDataDict.cxx COMMAND ../../scripts/build_dict.sh TExlData.h TExlDataDict.cxx TExlData.rootmap libNPEXL.dylib DEPENDS TExlData.h) -add_custom_command(OUTPUT TExlSpectraDict.cxx COMMAND ../../scripts/build_dict.sh TExlSpectra.h TExlSpectraDict.cxx TExlSpectra.rootmap libNPEXL.dylib DEPENDS TExlSpectra.h) +add_custom_command(OUTPUT TExlPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TExlPhysics.h TExlPhysicsDict.cxx TExlPhysics.rootmap libNPEXL.dylib DEPENDS TExlPhysics.h) +add_custom_command(OUTPUT TExlDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TExlData.h TExlDataDict.cxx TExlData.rootmap libNPEXL.dylib DEPENDS TExlData.h) +add_custom_command(OUTPUT TExlSpectraDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TExlSpectra.h TExlSpectraDict.cxx TExlSpectra.rootmap libNPEXL.dylib DEPENDS TExlSpectra.h) add_library(NPEXL SHARED TExlData.cxx TExlPhysics.cxx TExlSpectra.cxx TExlDataDict.cxx TExlPhysicsDict.cxx TExlSpectraDict.cxx) target_link_libraries(NPEXL ${ROOT_LIBRARIES} NPCore) install(FILES TExlData.h TExlPhysics.h TExlSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Eurogam/CMakeLists.txt b/NPLib/Detectors/Eurogam/CMakeLists.txt index 555d606fcd371b15dd69828ca2838f1918c294e5..61fbebe6730b6e992ec4c2ff15ded4d8c86a7b53 100644 --- a/NPLib/Detectors/Eurogam/CMakeLists.txt +++ b/NPLib/Detectors/Eurogam/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_command(OUTPUT TEurogamDataDict.cxx COMMAND ../../scripts/build_dict.sh TEurogamData.h TEurogamDataDict.cxx TEurogamData.rootmap libNPEurogam.dylib DEPENDS TEurogamData.h) +add_custom_command(OUTPUT TEurogamDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TEurogamData.h TEurogamDataDict.cxx TEurogamData.rootmap libNPEurogam.dylib DEPENDS TEurogamData.h) add_library(NPEurogam SHARED TEurogamData.cxx TEurogamDataDict.cxx ) target_link_libraries(NPEurogam ${ROOT_LIBRARIES} NPCore) install(FILES TEurogamData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Exogam/CMakeLists.txt b/NPLib/Detectors/Exogam/CMakeLists.txt index e7fbc634b2cd63e197cd5ecf15b127a05e922013..66c3fcef707dfcac3842fbccef42431fc3588e71 100644 --- a/NPLib/Detectors/Exogam/CMakeLists.txt +++ b/NPLib/Detectors/Exogam/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TExogamPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TExogamPhysics.h TExogamPhysicsDict.cxx TExogamPhysics.rootmap libNPExogam.dylib DEPENDS TExogamPhysics.h) -add_custom_command(OUTPUT TExogamDataDict.cxx COMMAND ../../scripts/build_dict.sh TExogamData.h TExogamDataDict.cxx TExogamData.rootmap libNPExogam.dylib DEPENDS TExogamData.h) +add_custom_command(OUTPUT TExogamPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TExogamPhysics.h TExogamPhysicsDict.cxx TExogamPhysics.rootmap libNPExogam.dylib DEPENDS TExogamPhysics.h) +add_custom_command(OUTPUT TExogamDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TExogamData.h TExogamDataDict.cxx TExogamData.rootmap libNPExogam.dylib DEPENDS TExogamData.h) add_library(NPExogam SHARED TExogamData.cxx TExogamPhysics.cxx TExogamDataDict.cxx TExogamPhysicsDict.cxx TExogamSpectra.cxx) target_link_libraries(NPExogam ${ROOT_LIBRARIES} NPCore) install(FILES TExogamData.h TExogamPhysics.h TExogamSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/FPDTamu/CMakeLists.txt b/NPLib/Detectors/FPDTamu/CMakeLists.txt index ac13ca0d0d062557bf4ce98216c1fb283a9502fd..b09b9e8c29371f172e08a22ba7ed27042367bbd0 100644 --- a/NPLib/Detectors/FPDTamu/CMakeLists.txt +++ b/NPLib/Detectors/FPDTamu/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TFPDTamuPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TFPDTamuPhysics.h TFPDTamuPhysicsDict.cxx TFPDTamuPhysics.rootmap libNPFPDTamu.dylib DEPENDS TFPDTamuPhysics.h) -add_custom_command(OUTPUT TFPDTamuDataDict.cxx COMMAND ../../scripts/build_dict.sh TFPDTamuData.h TFPDTamuDataDict.cxx TFPDTamuData.rootmap libNPFPDTamu.dylib DEPENDS TFPDTamuData.h) +add_custom_command(OUTPUT TFPDTamuPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TFPDTamuPhysics.h TFPDTamuPhysicsDict.cxx TFPDTamuPhysics.rootmap libNPFPDTamu.dylib DEPENDS TFPDTamuPhysics.h) +add_custom_command(OUTPUT TFPDTamuDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TFPDTamuData.h TFPDTamuDataDict.cxx TFPDTamuData.rootmap libNPFPDTamu.dylib DEPENDS TFPDTamuData.h) add_library(NPFPDTamu SHARED TFPDTamuSpectra.cxx TFPDTamuData.cxx TFPDTamuPhysics.cxx TFPDTamuDataDict.cxx TFPDTamuPhysicsDict.cxx ) target_link_libraries(NPFPDTamu ${ROOT_LIBRARIES} NPCore) install(FILES TFPDTamuData.h TFPDTamuPhysics.h TFPDTamuSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Fatima/CMakeLists.txt b/NPLib/Detectors/Fatima/CMakeLists.txt index 11ac9e6be8f1c96f680083206391dc32ebd4516e..64dec0a436b780b34354f9bdb3257b2a22c7f5a6 100644 --- a/NPLib/Detectors/Fatima/CMakeLists.txt +++ b/NPLib/Detectors/Fatima/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TFatimaPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TFatimaPhysics.h TFatimaPhysicsDict.cxx TFatimaPhysics.rootmap libNPFatima.dylib DEPENDS TFatimaPhysics.h) -add_custom_command(OUTPUT TFatimaDataDict.cxx COMMAND ../../scripts/build_dict.sh TFatimaData.h TFatimaDataDict.cxx TFatimaData.rootmap libNPFatima.dylib DEPENDS TFatimaData.h) +add_custom_command(OUTPUT TFatimaPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TFatimaPhysics.h TFatimaPhysicsDict.cxx TFatimaPhysics.rootmap libNPFatima.dylib DEPENDS TFatimaPhysics.h) +add_custom_command(OUTPUT TFatimaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TFatimaData.h TFatimaDataDict.cxx TFatimaData.rootmap libNPFatima.dylib DEPENDS TFatimaData.h) add_library(NPFatima SHARED TFatimaData.cxx TFatimaPhysics.cxx TFatimaDataDict.cxx TFatimaPhysicsDict.cxx ) target_link_libraries(NPFatima ${ROOT_LIBRARIES} NPCore) install(FILES TFatimaData.h TFatimaPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Foil/CMakeLists.txt b/NPLib/Detectors/Foil/CMakeLists.txt index 045b1b59c893afa542d8a52a2d7ac23f2dce9975..f48c57f4797283c188f34dcffd98ebfcaec8c1dc 100644 --- a/NPLib/Detectors/Foil/CMakeLists.txt +++ b/NPLib/Detectors/Foil/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TFoilPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TFoilPhysics.h TFoilPhysicsDict.cxx TFoilPhysics.rootmap libNPFoil.dylib DEPENDS TFoilPhysics.h) -add_custom_command(OUTPUT TFoilDataDict.cxx COMMAND ../../scripts/build_dict.sh TFoilData.h TFoilDataDict.cxx TFoilData.rootmap libNPFoil.dylib DEPENDS TFoilData.h) +add_custom_command(OUTPUT TFoilPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TFoilPhysics.h TFoilPhysicsDict.cxx TFoilPhysics.rootmap libNPFoil.dylib DEPENDS TFoilPhysics.h) +add_custom_command(OUTPUT TFoilDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TFoilData.h TFoilDataDict.cxx TFoilData.rootmap libNPFoil.dylib DEPENDS TFoilData.h) add_library(NPFoil SHARED TFoilData.cxx TFoilPhysics.cxx TFoilDataDict.cxx TFoilPhysicsDict.cxx ) target_link_libraries(NPFoil ${ROOT_LIBRARIES} NPCore) install(FILES TFoilData.h TFoilPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/ForwardArray/CMakeLists.txt b/NPLib/Detectors/ForwardArray/CMakeLists.txt index 3e862d3b6485541e33b43ec4e89ca9aabfdf183a..c57fd56b2e930f344bde816e6a2b80c1725db349 100644 --- a/NPLib/Detectors/ForwardArray/CMakeLists.txt +++ b/NPLib/Detectors/ForwardArray/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TForwardArrayPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TForwardArrayPhysics.h TForwardArrayPhysicsDict.cxx TForwardArrayPhysics.rootmap libNPForwardArray.dylib DEPENDS TForwardArrayPhysics.h) -add_custom_command(OUTPUT TForwardArrayDataDict.cxx COMMAND ../../scripts/build_dict.sh TForwardArrayData.h TForwardArrayDataDict.cxx TForwardArrayData.rootmap libNPForwardArray.dylib DEPENDS TForwardArrayData.h) +add_custom_command(OUTPUT TForwardArrayPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TForwardArrayPhysics.h TForwardArrayPhysicsDict.cxx TForwardArrayPhysics.rootmap libNPForwardArray.dylib DEPENDS TForwardArrayPhysics.h) +add_custom_command(OUTPUT TForwardArrayDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TForwardArrayData.h TForwardArrayDataDict.cxx TForwardArrayData.rootmap libNPForwardArray.dylib DEPENDS TForwardArrayData.h) add_library(NPForwardArray SHARED TForwardArraySpectra.cxx TForwardArrayData.cxx TForwardArrayPhysics.cxx TForwardArrayDataDict.cxx TForwardArrayPhysicsDict.cxx ) target_link_libraries(NPForwardArray ${ROOT_LIBRARIES} NPCore) install(FILES TForwardArrayData.h TForwardArrayPhysics.h TForwardArraySpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/GANIL/CMakeLists.txt b/NPLib/Detectors/GANIL/CMakeLists.txt index 72e7f377e2405e1dad2f91ace7c60028868cfae8..0f442987797c4aeacbdb46885d215c22e942da37 100644 --- a/NPLib/Detectors/GANIL/CMakeLists.txt +++ b/NPLib/Detectors/GANIL/CMakeLists.txt @@ -1,6 +1,6 @@ -add_custom_command(OUTPUT TTacPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTacPhysics.h TTacPhysicsDict.cxx TTacPhysics.rootmap libNPGANIL.dylib DEPENDS TTacPhysics.h) -add_custom_command(OUTPUT TTriggerDataDict.cxx COMMAND ../../scripts/build_dict.sh TTriggerData.h TTriggerDataDict.cxx TTriggerData.rootmap libNPGANIL.dylib DEPENDS TTriggerData.h) -add_custom_command(OUTPUT TTacDataDict.cxx COMMAND ../../scripts/build_dict.sh TTacData.h TTacDataDict.cxx TTacData.rootmap libNPGANIL.dylib DEPENDS TTacData.h) +add_custom_command(OUTPUT TTacPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTacPhysics.h TTacPhysicsDict.cxx TTacPhysics.rootmap libNPGANIL.dylib DEPENDS TTacPhysics.h) +add_custom_command(OUTPUT TTriggerDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTriggerData.h TTriggerDataDict.cxx TTriggerData.rootmap libNPGANIL.dylib DEPENDS TTriggerData.h) +add_custom_command(OUTPUT TTacDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTacData.h TTacDataDict.cxx TTacData.rootmap libNPGANIL.dylib DEPENDS TTacData.h) add_library(NPGANIL SHARED TTacPhysics.cxx TTacData.cxx TTriggerData.cxx TTacDataDict.cxx TTriggerDataDict.cxx TTacPhysicsDict.cxx) target_link_libraries(NPGANIL ${ROOT_LIBRARIES} NPCore) install(FILES TTacData.h TTriggerData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/GASPARD/CMakeLists.txt b/NPLib/Detectors/GASPARD/CMakeLists.txt index a998025247b3a00720561ef4cbf0e6d2f9df3841..c065c221d836fe365c9d4b12e8bd511cee29d993 100644 --- a/NPLib/Detectors/GASPARD/CMakeLists.txt +++ b/NPLib/Detectors/GASPARD/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TGaspardTrackerPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TGaspardTrackerPhysics.h TGaspardTrackerPhysicsDict.cxx TGaspardTrackerPhysics.rootmap libNPGASPARD.dylib DEPENDS TGaspardTrackerPhysics.h) -add_custom_command(OUTPUT TGaspardTrackerDataDict.cxx COMMAND ../../scripts/build_dict.sh TGaspardTrackerData.h TGaspardTrackerDataDict.cxx TGaspardTrackerData.rootmap libNPGASPARD.dylib DEPENDS TGaspardTrackerData.h) +add_custom_command(OUTPUT TGaspardTrackerPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TGaspardTrackerPhysics.h TGaspardTrackerPhysicsDict.cxx TGaspardTrackerPhysics.rootmap libNPGASPARD.dylib DEPENDS TGaspardTrackerPhysics.h) +add_custom_command(OUTPUT TGaspardTrackerDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TGaspardTrackerData.h TGaspardTrackerDataDict.cxx TGaspardTrackerData.rootmap libNPGASPARD.dylib DEPENDS TGaspardTrackerData.h) add_library(NPGASPARD SHARED GaspardTracker.cxx GaspardTrackerAnnular.cxx GaspardTrackerDummyShape.cxx GaspardTrackerModule.cxx GaspardTrackerTrapezoid.cxx GaspardTrackerSquare.cxx GaspardTrackerRectangle.cxx TGaspardTrackerData.cxx TGaspardTrackerPhysics.cxx TGaspardTrackerDataDict.cxx TGaspardTrackerPhysicsDict.cxx ) target_link_libraries(NPGASPARD ${ROOT_LIBRARIES} NPCore) install(FILES TGaspardTrackerData.h TGaspardTrackerPhysics.h GaspardTracker.h GaspardTrackerAnnular.h GaspardTrackerDummyShape.h GaspardTrackerModule.h GaspardTrackerRectangle.h GaspardTrackerSquare.h GaspardTrackerTrapezoid.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/GeTAMU/CMakeLists.txt b/NPLib/Detectors/GeTAMU/CMakeLists.txt index f903e7c54184130b4847ddf163ef18529e89dd84..6d840205eb9fe922363ed6566368de26943b3f5d 100644 --- a/NPLib/Detectors/GeTAMU/CMakeLists.txt +++ b/NPLib/Detectors/GeTAMU/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TGeTAMUPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TGeTAMUPhysics.h TGeTAMUPhysicsDict.cxx TGeTAMUPhysics.rootmap libNPGeTAMU.dylib DEPENDS TGeTAMUPhysics.h) -add_custom_command(OUTPUT TGeTAMUDataDict.cxx COMMAND ../../scripts/build_dict.sh TGeTAMUData.h TGeTAMUDataDict.cxx TGeTAMUData.rootmap libNPGeTAMU.dylib DEPENDS TGeTAMUData.h) +add_custom_command(OUTPUT TGeTAMUPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TGeTAMUPhysics.h TGeTAMUPhysicsDict.cxx TGeTAMUPhysics.rootmap libNPGeTAMU.dylib DEPENDS TGeTAMUPhysics.h) +add_custom_command(OUTPUT TGeTAMUDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TGeTAMUData.h TGeTAMUDataDict.cxx TGeTAMUData.rootmap libNPGeTAMU.dylib DEPENDS TGeTAMUData.h) add_library(NPGeTAMU SHARED TGeTAMUData.cxx TGeTAMUPhysics.cxx TGeTAMUDataDict.cxx TGeTAMUPhysicsDict.cxx ) target_link_libraries(NPGeTAMU ${ROOT_LIBRARIES} NPCore) install(FILES TGeTAMUData.h TGeTAMUPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/HYDE2/CMakeLists.txt b/NPLib/Detectors/HYDE2/CMakeLists.txt index 59091a64af3b5b11c720e8b0b14a12caf9699701..a2c577d9e013af7da52ac418f590ac4ad1480abd 100644 --- a/NPLib/Detectors/HYDE2/CMakeLists.txt +++ b/NPLib/Detectors/HYDE2/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT THyde2TrackerPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh THyde2TrackerPhysics.h THyde2TrackerPhysicsDict.cxx THyde2TrackerPhysics.rootmap libNPHYDE2.dylib DEPENDS THyde2TrackerPhysics.h) -add_custom_command(OUTPUT THyde2TrackerDataDict.cxx COMMAND ../../scripts/build_dict.sh THyde2TrackerData.h THyde2TrackerDataDict.cxx THyde2TrackerData.rootmap libNPHYDE2.dylib DEPENDS THyde2TrackerData.h) +add_custom_command(OUTPUT THyde2TrackerPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh THyde2TrackerPhysics.h THyde2TrackerPhysicsDict.cxx THyde2TrackerPhysics.rootmap libNPHYDE2.dylib DEPENDS THyde2TrackerPhysics.h) +add_custom_command(OUTPUT THyde2TrackerDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh THyde2TrackerData.h THyde2TrackerDataDict.cxx THyde2TrackerData.rootmap libNPHYDE2.dylib DEPENDS THyde2TrackerData.h) add_library(NPHYDE2 SHARED Hyde2Tracker.cxx Hyde2TrackerModule.cxx Hyde2TrackerTrapezoid1.cxx Hyde2TrackerTrapezoid2.cxx Hyde2TrackerSquare1.cxx THyde2TrackerData.cxx THyde2TrackerPhysics.cxx THyde2TrackerDataDict.cxx THyde2TrackerPhysicsDict.cxx ) target_link_libraries(NPHYDE2 ${ROOT_LIBRARIES} NPCore) install(FILES THyde2TrackerData.h THyde2TrackerPhysics.h Hyde2Tracker.h Hyde2TrackerModule.h Hyde2TrackerSquare1.h Hyde2TrackerTrapezoid1.h Hyde2TrackerTrapezoid2.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Helios/CMakeLists.txt b/NPLib/Detectors/Helios/CMakeLists.txt index b97770f02e0804a9de5cd7accd547adebab75885..f396f282a18bfe5f0560fd11003a237911a27e02 100644 --- a/NPLib/Detectors/Helios/CMakeLists.txt +++ b/NPLib/Detectors/Helios/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT THeliosPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh THeliosPhysics.h THeliosPhysicsDict.cxx THeliosPhysics.rootmap libNPHelios.dylib DEPENDS THeliosPhysics.h) -add_custom_command(OUTPUT THeliosDataDict.cxx COMMAND ../../scripts/build_dict.sh THeliosData.h THeliosDataDict.cxx THeliosData.rootmap libNPHelios.dylib DEPENDS THeliosData.h) +add_custom_command(OUTPUT THeliosPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh THeliosPhysics.h THeliosPhysicsDict.cxx THeliosPhysics.rootmap libNPHelios.dylib DEPENDS THeliosPhysics.h) +add_custom_command(OUTPUT THeliosDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh THeliosData.h THeliosDataDict.cxx THeliosData.rootmap libNPHelios.dylib DEPENDS THeliosData.h) add_library(NPHelios SHARED THeliosSpectra.cxx THeliosData.cxx THeliosPhysics.cxx THeliosDataDict.cxx THeliosPhysicsDict.cxx ) target_link_libraries(NPHelios ${ROOT_LIBRARIES} NPCore) install(FILES THeliosData.h THeliosPhysics.h THeliosSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Hira/CMakeLists.txt b/NPLib/Detectors/Hira/CMakeLists.txt index a74d38d13c62bf32f50999eb5368f2b49fa474c6..4a403dcd48ce19eed98afa905de28a181398df2c 100644 --- a/NPLib/Detectors/Hira/CMakeLists.txt +++ b/NPLib/Detectors/Hira/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT THiraPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh THiraPhysics.h THiraPhysicsDict.cxx THiraPhysics.rootmap libNPHira.dylib DEPENDS THiraPhysics.h) -add_custom_command(OUTPUT THiraDataDict.cxx COMMAND ../../scripts/build_dict.sh THiraData.h THiraDataDict.cxx THiraData.rootmap libNPHira.dylib DEPENDS THiraData.h) +add_custom_command(OUTPUT THiraPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh THiraPhysics.h THiraPhysicsDict.cxx THiraPhysics.rootmap libNPHira.dylib DEPENDS THiraPhysics.h) +add_custom_command(OUTPUT THiraDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh THiraData.h THiraDataDict.cxx THiraData.rootmap libNPHira.dylib DEPENDS THiraData.h) add_library(NPHira SHARED THiraData.cxx THiraPhysics.cxx THiraDataDict.cxx THiraPhysicsDict.cxx ) target_link_libraries(NPHira ${ROOT_LIBRARIES} NPCore) install(FILES THiraData.h THiraPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/LaBr3/CMakeLists.txt b/NPLib/Detectors/LaBr3/CMakeLists.txt index d891779846470145666249d2e12080c2515a6b47..cfbe1a62dc7c5392113a912f0b07aeb3f6065fb6 100644 --- a/NPLib/Detectors/LaBr3/CMakeLists.txt +++ b/NPLib/Detectors/LaBr3/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TLaBr3PhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TLaBr3Physics.h TLaBr3PhysicsDict.cxx TLaBr3Physics.rootmap libNPLaBr3.dylib DEPENDS TLaBr3Physics.h) -add_custom_command(OUTPUT TLaBr3DataDict.cxx COMMAND ../../scripts/build_dict.sh TLaBr3Data.h TLaBr3DataDict.cxx TLaBr3Data.rootmap libNPLaBr3.dylib DEPENDS TLaBr3Data.h) +add_custom_command(OUTPUT TLaBr3PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TLaBr3Physics.h TLaBr3PhysicsDict.cxx TLaBr3Physics.rootmap libNPLaBr3.dylib DEPENDS TLaBr3Physics.h) +add_custom_command(OUTPUT TLaBr3DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TLaBr3Data.h TLaBr3DataDict.cxx TLaBr3Data.rootmap libNPLaBr3.dylib DEPENDS TLaBr3Data.h) add_library(NPLaBr3 SHARED TLaBr3Data.cxx TLaBr3Physics.cxx TLaBr3DataDict.cxx TLaBr3PhysicsDict.cxx TLaBr3Spectra.cxx) target_link_libraries(NPLaBr3 ${ROOT_LIBRARIES} NPCore) install(FILES TLaBr3Data.h TLaBr3Physics.h TLaBr3Spectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Lassa/CMakeLists.txt b/NPLib/Detectors/Lassa/CMakeLists.txt index 905a47b7b724c14c8becc694d13fab7efb730d1d..d931588362d1c38679f135a55bd64571594a1211 100644 --- a/NPLib/Detectors/Lassa/CMakeLists.txt +++ b/NPLib/Detectors/Lassa/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TLassaPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TLassaPhysics.h TLassaPhysicsDict.cxx TLassaPhysics.rootmap libNPLassa.dylib DEPENDS TLassaPhysics.h) -add_custom_command(OUTPUT TLassaDataDict.cxx COMMAND ../../scripts/build_dict.sh TLassaData.h TLassaDataDict.cxx TLassaData.rootmap libNPLassa.dylib DEPENDS TLassaData.h) +add_custom_command(OUTPUT TLassaPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TLassaPhysics.h TLassaPhysicsDict.cxx TLassaPhysics.rootmap libNPLassa.dylib DEPENDS TLassaPhysics.h) +add_custom_command(OUTPUT TLassaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TLassaData.h TLassaDataDict.cxx TLassaData.rootmap libNPLassa.dylib DEPENDS TLassaData.h) add_library(NPLassa SHARED TLassaData.cxx TLassaPhysics.cxx TLassaDataDict.cxx TLassaPhysicsDict.cxx ) target_link_libraries(NPLassa ${ROOT_LIBRARIES} NPCore) install(FILES TLassaData.h TLassaPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/LightPipe/CMakeLists.txt b/NPLib/Detectors/LightPipe/CMakeLists.txt index 75f70cf2b36aa3329585bb4648364bd1aa32264f..c82ddaa50a69913a3db42140e1d0ddc21070dda2 100644 --- a/NPLib/Detectors/LightPipe/CMakeLists.txt +++ b/NPLib/Detectors/LightPipe/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TLightPipePhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TLightPipePhysics.h TLightPipePhysicsDict.cxx TLightPipePhysics.rootmap libNPLightPipe.dylib DEPENDS TLightPipePhysics.h) -add_custom_command(OUTPUT TLightPipeDataDict.cxx COMMAND ../../scripts/build_dict.sh TLightPipeData.h TLightPipeDataDict.cxx TLightPipeData.rootmap libNPLightPipe.dylib DEPENDS TLightPipeData.h) +add_custom_command(OUTPUT TLightPipePhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TLightPipePhysics.h TLightPipePhysicsDict.cxx TLightPipePhysics.rootmap libNPLightPipe.dylib DEPENDS TLightPipePhysics.h) +add_custom_command(OUTPUT TLightPipeDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TLightPipeData.h TLightPipeDataDict.cxx TLightPipeData.rootmap libNPLightPipe.dylib DEPENDS TLightPipeData.h) add_library(NPLightPipe SHARED TLightPipeSpectra.cxx TLightPipeData.cxx TLightPipePhysics.cxx TLightPipeDataDict.cxx TLightPipePhysicsDict.cxx ) target_link_libraries(NPLightPipe ${ROOT_LIBRARIES} NPCore) install(FILES TLightPipeData.h TLightPipePhysics.h TLightPipeSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/MDM/CMakeLists.txt b/NPLib/Detectors/MDM/CMakeLists.txt index 0d433a44bcb999665b7ab0e40efb96b7aed4199d..a19d84ba6821c9327de91ac28bf4c990681b1894 100644 --- a/NPLib/Detectors/MDM/CMakeLists.txt +++ b/NPLib/Detectors/MDM/CMakeLists.txt @@ -1,8 +1,8 @@ include(CheckLanguage) -add_custom_command(OUTPUT TMDMPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMDMPhysics.h TMDMPhysicsDict.cxx TMDMPhysics.rootmap libNPMDM.dylib DEPENDS TMDMPhysics.h) -add_custom_command(OUTPUT TMDMPhysicsMinimizerDict.cxx COMMAND ../../scripts/build_dict.sh TMDMPhysicsMinimizer.h TMDMPhysicsMinimizerDict.cxx TMDMPhysicsMinimizer.rootmap libNPMDM.dylib DEPENDS TMDMPhysicsMinimizer.h) -add_custom_command(OUTPUT TMDMDataDict.cxx COMMAND ../../scripts/build_dict.sh TMDMData.h TMDMDataDict.cxx TMDMData.rootmap libNPMDM.dylib DEPENDS TMDMData.h) +add_custom_command(OUTPUT TMDMPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMDMPhysics.h TMDMPhysicsDict.cxx TMDMPhysics.rootmap libNPMDM.dylib DEPENDS TMDMPhysics.h) +add_custom_command(OUTPUT TMDMPhysicsMinimizerDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMDMPhysicsMinimizer.h TMDMPhysicsMinimizerDict.cxx TMDMPhysicsMinimizer.rootmap libNPMDM.dylib DEPENDS TMDMPhysicsMinimizer.h) +add_custom_command(OUTPUT TMDMDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMDMData.h TMDMDataDict.cxx TMDMData.rootmap libNPMDM.dylib DEPENDS TMDMData.h) ## ## Check if MINUIT2 is installed along with ROOT diff --git a/NPLib/Detectors/MUST2/CMakeLists.txt b/NPLib/Detectors/MUST2/CMakeLists.txt index cfad4bca9a86e10258eff0f0a965fd2a0f6eb803..db5eba5e356d841bb42c38325071d13295ee6314 100644 --- a/NPLib/Detectors/MUST2/CMakeLists.txt +++ b/NPLib/Detectors/MUST2/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TMust2PhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMust2Physics.h TMust2PhysicsDict.cxx TMust2Physics.rootmap libNPMUST2.dylib DEPENDS TMust2Physics.h) -add_custom_command(OUTPUT TMust2DataDict.cxx COMMAND ../../scripts/build_dict.sh TMust2Data.h TMust2DataDict.cxx TMust2Data.rootmap libNPMUST2.dylib DEPENDS TMust2Data.h) +add_custom_command(OUTPUT TMust2PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMust2Physics.h TMust2PhysicsDict.cxx TMust2Physics.rootmap libNPMUST2.dylib DEPENDS TMust2Physics.h) +add_custom_command(OUTPUT TMust2DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMust2Data.h TMust2DataDict.cxx TMust2Data.rootmap libNPMUST2.dylib DEPENDS TMust2Data.h) add_library(NPMUST2 SHARED TMust2Data.cxx TMust2Physics.cxx TMust2DataDict.cxx TMust2PhysicsDict.cxx TMust2Spectra.cxx) target_link_libraries(NPMUST2 ${ROOT_LIBRARIES} NPCore) install(FILES TMust2Data.h TMust2Physics.h TMust2Spectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Maya/CMakeLists.txt b/NPLib/Detectors/Maya/CMakeLists.txt index 7abe143da52867713f2a0dea13690819d1f06d97..af13de01276c903ded28b6ff0a236962a1b17994 100644 --- a/NPLib/Detectors/Maya/CMakeLists.txt +++ b/NPLib/Detectors/Maya/CMakeLists.txt @@ -1,6 +1,6 @@ if(DEFINED ENV{ROOTSYS}) -add_custom_command(OUTPUT TMayaDataDict.cxx COMMAND ../../scripts/build_dict.sh TMayaData.h TMayaDataDict.cxx TMayaData.rootmap libNPMaya.dylib DEPENDS TMayaData.h) -add_custom_command(OUTPUT TMayaHistoDict.cxx COMMAND ../../scripts/build_dict.sh TMayaHisto.h TMayaHistoDict.cxx TMayaHisto.rootmap libNPMaya.dylib DEPENDS TMayaHisto.h) +add_custom_command(OUTPUT TMayaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMayaData.h TMayaDataDict.cxx TMayaData.rootmap libNPMaya.dylib DEPENDS TMayaData.h) +add_custom_command(OUTPUT TMayaHistoDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMayaHisto.h TMayaHistoDict.cxx TMayaHisto.rootmap libNPMaya.dylib DEPENDS TMayaHisto.h) add_library(NPMaya SHARED TMayaData.cxx TMayaHisto.cxx TMayaDataDict.cxx TMayaHistoDict.cxx ConfigReader.cxx) diff --git a/NPLib/Detectors/Microball/CMakeLists.txt b/NPLib/Detectors/Microball/CMakeLists.txt index 63ea5977a7d9d5885bbcd8c568e2343e8792711d..430ffa152c1e20259c5cfc7c128e2039b2ac8581 100644 --- a/NPLib/Detectors/Microball/CMakeLists.txt +++ b/NPLib/Detectors/Microball/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TMicroballPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMicroballPhysics.h TMicroballPhysicsDict.cxx TMicroballPhysics.rootmap libNPMicroball.dylib DEPENDS TMicroballPhysics.h) -add_custom_command(OUTPUT TMicroballDataDict.cxx COMMAND ../../scripts/build_dict.sh TMicroballData.h TMicroballDataDict.cxx TMicroballData.rootmap libNPMicroball.dylib DEPENDS TMicroballData.h) +add_custom_command(OUTPUT TMicroballPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMicroballPhysics.h TMicroballPhysicsDict.cxx TMicroballPhysics.rootmap libNPMicroball.dylib DEPENDS TMicroballPhysics.h) +add_custom_command(OUTPUT TMicroballDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMicroballData.h TMicroballDataDict.cxx TMicroballData.rootmap libNPMicroball.dylib DEPENDS TMicroballData.h) add_library(NPMicroball SHARED TMicroballSpectra.cxx TMicroballData.cxx TMicroballPhysics.cxx TMicroballDataDict.cxx TMicroballPhysicsDict.cxx ) target_link_libraries(NPMicroball ${ROOT_LIBRARIES} NPCore) install(FILES TMicroballData.h TMicroballPhysics.h TMicroballSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Miniball/CMakeLists.txt b/NPLib/Detectors/Miniball/CMakeLists.txt index 56254714f37e01bcb16d16062da6d869a7900ef7..475a12d1eb029027fcadd3b405d5d5f8676a15d7 100644 --- a/NPLib/Detectors/Miniball/CMakeLists.txt +++ b/NPLib/Detectors/Miniball/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TMiniballPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMiniballPhysics.h TMiniballPhysicsDict.cxx TMiniballPhysics.rootmap libNPMiniball.dylib DEPENDS TMiniballPhysics.h) -add_custom_command(OUTPUT TMiniballDataDict.cxx COMMAND ../../scripts/build_dict.sh TMiniballData.h TMiniballDataDict.cxx TMiniballData.rootmap libNPMiniball.dylib DEPENDS TMiniballData.h) +add_custom_command(OUTPUT TMiniballPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMiniballPhysics.h TMiniballPhysicsDict.cxx TMiniballPhysics.rootmap libNPMiniball.dylib DEPENDS TMiniballPhysics.h) +add_custom_command(OUTPUT TMiniballDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMiniballData.h TMiniballDataDict.cxx TMiniballData.rootmap libNPMiniball.dylib DEPENDS TMiniballData.h) add_library(NPMiniball SHARED TMiniballSpectra.cxx TMiniballData.cxx TMiniballPhysics.cxx TMiniballDataDict.cxx TMiniballPhysicsDict.cxx ) target_link_libraries(NPMiniball ${ROOT_LIBRARIES} NPCore) install(FILES TMiniballData.h TMiniballPhysics.h TMiniballSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Minos/CMakeLists.txt b/NPLib/Detectors/Minos/CMakeLists.txt index 4e7173cabc758116b79916d94233c3fa5266f128..49ea047f815daef3723e7b599d040d6d910e6f3c 100644 --- a/NPLib/Detectors/Minos/CMakeLists.txt +++ b/NPLib/Detectors/Minos/CMakeLists.txt @@ -5,7 +5,7 @@ add_custom_command(OUTPUT TMinosDataDict.cxx COMMAND ../../scripts/build_dict.sh add_custom_command(OUTPUT TMinosClustDict.cxx COMMAND ../../scripts/build_dict.sh TMinosClust.h TMinosClustDict.cxx TMinosClust.rootmap libNPMinos.dylib DEPENDS TMinosClust.h) add_custom_command(OUTPUT TMinosResultDict.cxx COMMAND ../../scripts/build_dict.sh TMinosResult.h TMinosResultDict.cxx TMinosResult.rootmap libNPMinos.dylib DEPENDS TMinosResult.h) -## Check if MINUIT2 is installed along with ROOT +## Check if MINUIT is installed along with ROOT find_library(libMinuit_FOUND NAMES Minuit HINTS "$ENV{ROOTSYS}/lib") if(libMinuit_FOUND) message(STATUS "Minuit support enabled for Minos.") @@ -14,15 +14,18 @@ else() message(STATUS "Minuit support disabled for Minos. Not found in $ENV{ROOTSYS}/lib") endif() -add_library(NPMinos SHARED TMinosClust.cxx TMinosData.cxx TMinosPhysics.cxx TMinosResult TMinosDataDict.cxx TMinosPhysicsDict.cxx TMinosClustDict.cxx TMinosResultDict.cxx) if(libMinuit_FOUND) -## Link to Minuit2 library - target_link_libraries(NPMinos ${ROOT_LIBRARIES} NPCore NPTrackReconstruction Minuit) +## Link to Minuit library + add_library(NPMinos SHARED TMinosClust.cxx TMinosData.cxx TMinosPhysics.cxx TMinosResult TMinosDataDict.cxx TMinosPhysicsDict.cxx TMinosClustDict.cxx TMinosResultDict.cxx) + target_link_libraries(NPMinos ${ROOT_LIBRARIES} Minuit NPCore NPTrackReconstruction ) + install(FILES TMinosClust.h TMinosData.h TMinosPhysics.h TMinosResult.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) else() -## No Minuit2 library, skip linking - target_link_libraries(NPMinos ${ROOT_LIBRARIES} NPCore NPTrackReconstruction) +## No Minuit library, skip linking + add_library(NPMinos SHARED TMinosData.cxx TMinosDataDict.cxx) + target_link_libraries(NPMinos ${ROOT_LIBRARIES} NPCore ) + install(FILES TMinosData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + endif() -install(FILES TMinosClust.h TMinosData.h TMinosPhysics.h TMinosResult.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Minos/TMinosPhysics.cxx b/NPLib/Detectors/Minos/TMinosPhysics.cxx index 6435da703fedac6e4dc1207c9292b43feaeef8e6..ceda3da527066e0c569c0e9098d1c427e97c4427 100644 --- a/NPLib/Detectors/Minos/TMinosPhysics.cxx +++ b/NPLib/Detectors/Minos/TMinosPhysics.cxx @@ -53,22 +53,22 @@ TMinosPhysics* current_phy = 0; /////////////////////////////////////////////////////////////////////////// TMinosPhysics::TMinosPhysics() - : m_EventData(new TMinosData), - m_PreTreatedData(new TMinosData), - m_EventPhysics(this), - Tracking_functions(new Tracking), - m_E_RAW_Threshold(0), // adc channels - m_E_Threshold(0), // MeV - hfit(new TH1F("hfit","hfit",512,0,512)), - grxztmp(new TGraph()), - gryztmp(new TGraph()), - npoint_temp(0), - allevt_2pfiltered(0), - m_NumberOfDetectors(0) { + : m_EventData(new TMinosData), + m_PreTreatedData(new TMinosData), + m_EventPhysics(this), + Tracking_functions(new Tracking), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + hfit(new TH1F("hfit","hfit",512,0,512)), + grxztmp(new TGraph()), + gryztmp(new TGraph()), + npoint_temp(0), + allevt_2pfiltered(0), + m_NumberOfDetectors(0) { current_phy = this; data_result.SetClass("TMinosResult"); fitdata.SetClass("TMinosClust"); - } + } int NclusterFit; @@ -86,7 +86,7 @@ void TMinosPhysics::AddDetector(double R, double Theta, TVector3 POS, double Phi // Compute the TVector3 corresponding // Call the cartesian method } - + /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::BuildSimplePhysicalEvent() { BuildPhysicalEvent(); @@ -113,736 +113,665 @@ void TMinosPhysics::PreTreat() { // This method applies thresholds and calibrations // Isolate 2D tracks with the modified HoughTransformation // Calculate z for each pad - + data_result.Clear(); fitdata.Clear(); + + for(int i = 0; i <2 ; i++){ + parFit1.push_back(-1000); + parFit2.push_back(-1000); + parFit3.push_back(-1000); + parFit4.push_back(-1000); + } + + Xvertex = -1000; + Yvertex = -1000; + Zvertex = -1000; + sumTheta = -1000; + + Theta1 = -1000; + Theta2 = -1000; + Theta_1= -1000; + Theta_2= -1000; + + Phi1 = -1000; + Phi2 = -1000; + Dmin = -1000; + TMinosClust *minosfitdata; - + ////////////////////fit variables////////////////////// - + fit_function = new TF1("fit_function",conv_fit, 0, 511, 3); int fit2DStatus = 0.; double fit_function_max = 0., fit_function_Tpad = 0.; double Chi2 = 0.; double Tshaping = 333.9; const double TimeBinElec = 30.; // in ns - double MINOSthresh, VDrift, Z_Shift, DelayTrig; - - if(SimulationBool){ // case of simulated data - MINOSthresh = 1000000000.; // + double MINOSthresh, UperFitLim, VDrift, Z_Shift, DelayTrig, ZRot_Minos; + + if(SimulationBool){ // Simulated data + UperFitLim = 1000000000.; // + MINOSthresh = 899.; DelayTrig = 0.; - /* VDrift = 0.036; */ - VDrift = 0.03; + VDrift = 0.03475; Z_Shift = 0; - } - else{ // case of experiment data - MINOSthresh = 100000.; - DelayTrig = 10170; - VDrift = 0.03475; // in mm/ns - /* Z_Shift = 57.16; // */ - Z_Shift = 0. ; // } - + else{ // Experiment data + MINOSthresh = 100; + UperFitLim = 100000.; + DelayTrig = 1515; // ns, s034 par. + ZRot_Minos = 33.81; // Rotation of Minos along Z axis, s034 par. + VDrift = 0.03475; // mm/ns, s034 par. + Z_Shift = -2.5 ; // mm, s034 par. + } + /////////////////////////////////////////////////////// ClearPreTreatedData(); /// Read Q(t) signal to fit and extract DriftTime - + unsigned int NbOfPad = m_EventData->GetPadNumberMult(); filled =0;trackNbr=0; trackNbr_FINAL=0; - ringsum=0; - zmax=0.;Iteration=0; + ringsum=0; + zmax=0.;Iteration=0; for (unsigned int e = 0; e < NbOfPad; e++){ - + x_mm = 0.; y_mm = 0.; z_mm = 0.;maxCharge = 0.; t_pad =0; q_pad=0; x_mm = m_EventData->GetPadX(e); y_mm = m_EventData->GetPadY(e); - + if ( !(abs(x_mm)<0.0001 && abs(y_mm)<0.0001) ) { for (UShort_t o = 0; o < m_EventData->GetTime(e).size() ; ++o){ if(m_EventData->GetCharge(e)[o]> maxCharge){ maxCharge = m_EventData->GetCharge(e)[o]; } } - - if((maxCharge < MINOSthresh && round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) < 16 && round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) >4 )) { // to remove rings 1,2,3,4 and 16,17,18 - /* if((maxCharge < MINOSthresh && ( SimulationBool==1 || round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) < 16 && round((sqrt(x_mm*x_mm+y_mm*y_mm)-43.8)/2.1) >4 )) ) { // to remove rings 1,2,3,4 and 16,17,18 // to not apply the ring condition for simulation*/ - Xpad.push_back(x_mm); - Ypad.push_back(y_mm); - Qpad.push_back(maxCharge); - filled++; // - } - } - } //end of NbOfPad - - if(filled>0) { // Nbr of activated pads - while(Xpad.size()>=10 && Iteration< 20 ) { // !!!!!!!! - filter_result = 0; // Nbr of pads in the Track - Iteration++; - XpadTemp.clear(); - YpadTemp.clear(); - QpadTemp.clear(); - clusterringboolTemp.clear(); - - filter_result = Tracking_functions->Hough_modified(&Xpad, &Ypad, &Qpad, &XpadTemp, &YpadTemp, &QpadTemp, &clusterringboolTemp); - - if(filter_result<0) break; - if(filter_result>10 && clusterringboolTemp.back()==1){ - /* if(filter_result>4 ){ // modified for the simu w 0 dispersion */ - trackNbr++; - for(int ik=0; ik<filter_result; ik++) { - XpadNew.push_back(XpadTemp[ik]); - YpadNew.push_back(YpadTemp[ik]); - ZpadNew.push_back(-10000); - QpadNew.push_back(QpadTemp[ik]); - clusterringbool.push_back(clusterringboolTemp[ik]); - clusternbr.push_back(Iteration); - clusterpads.push_back(filter_result); - } + /* if((maxCharge >= MINOSthresh && round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) < 14 && round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) >7 )) { // to remove rings 1,2,3,4 and 16,17,18 */ + if((maxCharge >= MINOSthresh )) { // to remove rings 1,2,3,4 and 16,17,18 + /* if((maxCharge >= MINOSthresh && round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) < 16 && round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) >4 )) { // to remove rings 1,2,3,4 and 16,17,18 */ + /* if((maxCharge >= MINOSthresh && ( SimulationBool==1 || (round((sqrt(x_mm*x_mm+y_mm*y_mm)-44.15)/2.1) < 16 && round((sqrt(x_mm*x_mm+y_mm*y_mm)-43.8)/2.1) >4 ))) ) { // to not apply the ring condition for simulation */ + Xpad.push_back(x_mm); + Ypad.push_back(y_mm); + Qpad.push_back(maxCharge); + filled++; // } - - - } - } - - for(unsigned int il=0; il<XpadNew.size(); il++){ - minosfitdata = (TMinosClust*)fitdata.ConstructedAt(il); - minosfitdata->Set(XpadNew[il], YpadNew[il], - -10000, -10000, QpadNew[il], - clusternbr[il],clusterpads[il], 0.); - ZpadNew.push_back(-10000.); - - } - - if(trackNbr>0 && trackNbr < 5 ){ /////////// - - if(filled==0) cerr << "Error !!!" << endl; - //------------------------------------------------------- - // STEP 4.1: Fitting taken pads for Qmax and Ttrig info - //------------------------------------------------------- - - for(unsigned int i=0 ; i< NbOfPad; i++ ) { - hfit->Reset(); - bool fitbool = false; - x_mm = m_EventData->GetPadX(i); - y_mm = m_EventData->GetPadY(i); - - for(unsigned int jj=0; jj<XpadNew.size(); jj++) { - if( abs(XpadNew[jj]-x_mm)<0.0001 && abs(YpadNew[jj]-y_mm)<0.0001) { - fitbool = true; - indexfill=jj; - break; - } } - - if( fitbool==true ) { - - /* TGraph gfit( m_EventData->GetTime(i).size() ,&(m_EventData->GetTime(i)[0]),&(m_EventData->GetCharge(i)[0])); */ - /* for (UShort_t o = 0; o < m_EventData->GetTime(i).size() ; ++o){ */ - /* gfit.SetPoint(o,m_EventData->GetTime(i)[o],m_EventData->GetCharge(i)[o]+250); */ - /* if(m_EventData->GetCharge(i)[o]+250> hfit_max){ */ - /* hfit_max_T = m_EventData->GetTime(i)[o]; */ - /* hfit_max=m_EventData->GetCharge(i)[o]+250; */ - /* } */ - /* } */ - - for(Int_t j=0; j< m_EventData->GetTime(i).size(); j++) { - if(m_EventData->GetCharge(i)[j]>=0){ - hfit->SetBinContent(hfit->FindBin(m_EventData->GetTime(i)[j]), m_EventData->GetCharge(i)[j]+250); + } //end of NbOfPad + + if(filled>0){ // Nbr of activated pads + while(Xpad.size()>=7 && Iteration< 20 ) { // !!!!!!!! + /* while(Xpad.size()>=10 && Iteration< 20 ) { // !!!!!!!! */ + filter_result = 0; // Nbr of pads in the Track + Iteration++; + XpadTemp.clear(); + YpadTemp.clear(); + QpadTemp.clear(); + clusterringboolTemp.clear(); + + filter_result = Tracking_functions->Hough_modified(&Xpad, &Ypad, &Qpad, &XpadTemp, &YpadTemp, &QpadTemp, &clusterringboolTemp); + + if(filter_result<0) break; + /* if(filter_result>10 && clusterringboolTemp.back()==1){ */ + /* if(filter_result>4 ){ // modified for the simu w 0 dispersion */ + if(filter_result>7 ){ + trackNbr++; + for(int ik=0; ik<filter_result; ik++) { // selected pads + XpadNew.push_back(XpadTemp[ik]); + YpadNew.push_back(YpadTemp[ik]); + ZpadNew.push_back(-10000); + QpadNew.push_back(QpadTemp[ik]); + clusterringbool.push_back(clusterringboolTemp[ik]); + clusternbr.push_back(Iteration); + clusterpads.push_back(filter_result); } } - - // Fitting the hfit histogram of last channel if not empty - - if(hfit->GetSumOfWeights()>0) { - hfit->GetXaxis()->SetRange(0,510); - hfit_max = hfit->GetMaximum(); - hfit_max_T = hfit->GetMaximumBin(); - T_min=-1; - T_max=-1; - - // Find the T_min & T_max limits of the signal non zero - for(int h=hfit_max_T;h>0;h--) { - if(T_min == -1 && (hfit->GetBinContent(h))<=250 ) { - T_min = h; - break; - } - } - for(int h=hfit_max_T;h<510;h++) { - if(T_max == -1 && (hfit->GetBinContent(h)) < 1 ) { - T_max = h; + } + } + for(unsigned int il=0; il<XpadNew.size(); il++){ + minosfitdata = (TMinosClust*)fitdata.ConstructedAt(il); + minosfitdata->Set(XpadNew[il], YpadNew[il], + -10000, -10000, QpadNew[il], + clusternbr[il],clusterpads[il], 0.); + /* ZpadNew.push_back(-10000.); */ + } + + /* if(trackNbr >= 0 && trackNbr < 5 ){ /////////// */ + if(trackNbr == 2){ /////////// + + /* if(filled==0) cerr << "Error !!!" << endl; */ + //------------------------------------------------------- + // STEP 4.1: Fitting taken pads for Qmax and Ttrig info + //------------------------------------------------------- + + for(unsigned int i=0 ; i< NbOfPad; i++ ) { + hfit->Reset(); + bool fitbool = false; + x_mm = m_EventData->GetPadX(i); + y_mm = m_EventData->GetPadY(i); + + for(unsigned int jj=0; jj<XpadNew.size(); jj++) { + if( abs(XpadNew[jj]-x_mm)<0.0001 && abs(YpadNew[jj]-y_mm)<0.0001) { + fitbool = true; + indexfill=jj; break; } } - - if((hfit_max_T-3.5*(Tshaping/TimeBinElec)) > T_min) T_min = hfit_max_T-2*Tshaping/TimeBinElec; - if((hfit_max_T+10) < T_max || T_max==-1) T_max = hfit_max_T+10.; - T_min = max(T_min,0.); - if(T_max>510) T_max = 510; - - // Set fit parameters - fit_function->SetParameter(0, hfit_max-250.); - fit_function->SetParameter(1,hfit_max_T - Tshaping/TimeBinElec); - fit_function->SetParameter(2, Tshaping/TimeBinElec); - fit_function->SetParLimits(0,0,MINOSthresh); - fit_function->SetParLimits(1,-20,512); - fit_function->SetParLimits(2,0,512); - - fit2DStatus = hfit->Fit(fit_function,"QN","",T_min,T_max); - /* fit2DStatus = gfit.Fit(fit_function,"QN","",hfit_max-2*Tshaping,hfit_max+2*Tshaping); */ - - double fit_function_max = 0., fit_function_Tpad = 0.; - if(fit2DStatus==0) { - Chi2 = fit_function->GetChisquare(); - fit_function_max = fit_function->GetMaximum(); - fit_function_Tpad = fit_function->GetParameter(1); - } - - //attribute q_pad and z_mm value - if(fit2DStatus!=0 || fit_function_max<=20. || - fit_function_max >= MINOSthresh || fit_function_Tpad<=0.15 || - fit_function_Tpad>=513. || fit_function->GetParameter(2)<=0.15 || - fit_function->GetParameter(2)>=513.) { - q_pad = hfit_max-250.; - z_mm = -10000; - - } - - else { - t_pad = fit_function_Tpad; - /* z_mm = 300.-(-t_pad*TimeBinElec+DelayTrig)*VDrift[int((sqrt(x_mm*x_mm+y_mm*y_mm)-43.8)/2.1)] */ - - if(SimulationBool)z_mm = t_pad*TimeBinElec*VDrift; // for simu - else z_mm = 300.-(-t_pad*TimeBinElec+DelayTrig)*VDrift; - - Q_Pad.push_back(fit_function_max-250); - T_Pad.push_back(t_pad*TimeBinElec); - X_Pad.push_back(x_mm); - Y_Pad.push_back(y_mm); - Z_Pad.push_back(z_mm); - q_pad = fit_function_max-250.; - + if( fitbool==true ) { + + /* TGraph gfit( m_EventData->GetTime(i).size() ,&(m_EventData->GetTime(i)[0]),&(m_EventData->GetCharge(i)[0])); */ + /* for (UShort_t o = 0; o < m_EventData->GetTime(i).size() ; ++o){ */ + /* gfit.SetPoint(o,m_EventData->GetTime(i)[o],m_EventData->GetCharge(i)[o]+250); */ + /* if(m_EventData->GetCharge(i)[o]+250> hfit_max){ */ + /* hfit_max_T = m_EventData->GetTime(i)[o]; */ + /* hfit_max=m_EventData->GetCharge(i)[o]+250; */ + /* } */ + /* } */ + + for(Int_t j=0; j< m_EventData->GetTime(i).size(); j++) { + if(m_EventData->GetCharge(i)[j]>=0){ + hfit->SetBinContent(hfit->FindBin(m_EventData->GetTime(i)[j]), m_EventData->GetCharge(i)[j]+250); + } } - ZpadNew[indexfill] = z_mm; - minosfitdata = (TMinosClust*)fitdata.ConstructedAt(indexfill); - minosfitdata->Set(XpadNew[indexfill], YpadNew[indexfill], t_pad*TimeBinElec, ZpadNew[indexfill], q_pad, clusternbr[indexfill], clusterpads[indexfill], Chi2); - QpadNew[indexfill] = q_pad ; - - } // end if SumOfWeights > 0 - - } // end if fitbool==True + + // Fitting the hfit histogram of last channel if not empty + if(hfit->GetSumOfWeights()>0) { + hfit->GetXaxis()->SetRange(0,510); + hfit_max = hfit->GetMaximum(); + hfit_max_T = hfit->GetMaximumBin(); + T_min=-1; + T_max=-1; + + // Find the T_min & T_max limits of the signal non zero + for(int h=hfit_max_T;h>0;h--) { + if(T_min == -1 && (hfit->GetBinContent(h))<=250 ) { + T_min = h; + break; + } + } + for(int h=hfit_max_T;h<510;h++) { + if(T_max == -1 && (hfit->GetBinContent(h)) < 1 ) { + T_max = h; + break; + } + } + + if((hfit_max_T-3.5*(Tshaping/TimeBinElec)) > T_min) T_min = hfit_max_T-2*Tshaping/TimeBinElec; + if((hfit_max_T+10) < T_max || T_max==-1) T_max = hfit_max_T+10.; + T_min = max(T_min,0.); + if(T_max>510) T_max = 510; + + // Set fit parameters + fit_function->SetParameter(0, hfit_max-250.); + fit_function->SetParameter(1,hfit_max_T - Tshaping/TimeBinElec); + fit_function->SetParameter(2, Tshaping/TimeBinElec); + fit_function->SetParLimits(0,0,UperFitLim); + fit_function->SetParLimits(1,-20,512); + fit_function->SetParLimits(2,0,512); + + fit2DStatus = hfit->Fit(fit_function,"QN","",T_min,T_max); + /* fit2DStatus = gfit.Fit(fit_function,"QN","",hfit_max-2*Tshaping,hfit_max+2*Tshaping); */ + + double fit_function_max = 0., fit_function_Tpad = 0.; + if(fit2DStatus==0) { + Chi2 = fit_function->GetChisquare(); + fit_function_max = fit_function->GetMaximum(); + fit_function_Tpad = fit_function->GetParameter(1); + } + //attribute q_pad and z_mm value + if(fit2DStatus!=0 || fit_function_max<=20. || + fit_function_max >= UperFitLim || fit_function_Tpad<=0.15 || + fit_function_Tpad>=513. || fit_function->GetParameter(2)<=0.15 || + fit_function->GetParameter(2)>=513.) { + q_pad = hfit_max-250.; + z_mm = -10000; + } + else { + t_pad = fit_function_Tpad; + /* z_mm = 300.-(-t_pad*TimeBinElec+DelayTrig)*VDrift[int((sqrt(x_mm*x_mm+y_mm*y_mm)-43.8)/2.1)] */ + if(SimulationBool)z_mm = t_pad*TimeBinElec*VDrift; // for simu + else z_mm =(t_pad*TimeBinElec-DelayTrig)*VDrift; + /* else z_mm = 300.-(-t_pad*TimeBinElec+DelayTrig)*VDrift; */ + Q_Pad.push_back(fit_function_max-250); + T_Pad.push_back(t_pad*TimeBinElec); + X_Pad.push_back(x_mm); + Y_Pad.push_back(y_mm); + Z_Pad.push_back(z_mm); + q_pad = fit_function_max-250.; + } + ZpadNew[indexfill] = z_mm + Z_Shift; // CYRIL Test + /* ZpadNew[indexfill] = z_mm; */ + QpadNew[indexfill] = q_pad; + minosfitdata = (TMinosClust*)fitdata.ConstructedAt(indexfill); + minosfitdata->Set(XpadNew[indexfill], YpadNew[indexfill], t_pad*TimeBinElec, z_mm, q_pad, clusternbr[indexfill], clusterpads[indexfill], Chi2); + } // end if SumOfWeights > 0 + } // end if fitbool==True else continue; - } // end of NbOfPad - - //------------------------------------------------------- - // STEP 3.2: Filtering the tracks off possible noise - // with Hough3D (3*2D planes) - //------------------------------------------------------- - - cluster_temp = 0; - int ringtouch[19]={0}; - /* for(int ko=1; ko<19; ko++) ringtouch[ko] = 0; ///// Added by Cyril */ - - for(unsigned int i=0;i<(XpadNew.size());i++){ - if(xin.size()>0 && ((cluster_temp!=int(clusternbr[i]) && i!=0) || i==(XpadNew.size() - 1))){ - - Tracking_functions->Hough_3D(&xin, &yin, &zin, &qin, &xout, &yout, &zout, &qout); - - for(unsigned int ij=0; ij<xout.size();ij++){ - if(zout[ij]>zmax) {zmax = zout[ij];} - ringtouch[int(round((sqrt(xout[ij]*xout[ij]+yout[ij]*yout[ij])-44.15)/2.1))]++; // Corr by Cyril - } - - for(int ko=0; ko<19; ko++){ - if(ringtouch[ko]>0) ringsum++; - } - - /* if(zmax> 290 ) ringsum = 16; //comment it if z_mm is not well reconstruct by Vdrift and DelayTrig ! */ - - // Tracks of interest: >10 pads and >=12 rings hit - - /* if(xout.size()>10 &&(SimulationBool==1 || ringsum>=8)){ */ - if(xout.size()>10 && ringsum>=8){ + } // end of NbOfPad + + //------------------------------------------------------- + // STEP 3.2: Filtering the tracks off possible noise + // with Hough3D (3*2D planes) + //------------------------------------------------------- + + cluster_temp = 0; + int ringtouch[19]={0}; + /* for(int ko=1; ko<19; ko++) ringtouch[ko] = 0; ///// Added by Cyril */ + for(unsigned int i=0;i<(XpadNew.size());i++){ + if(xin.size()>0 && ((cluster_temp != int(clusternbr[i]) && i!=0) || i==(XpadNew.size()-1))){ // We fill xin until the next cluster + Tracking_functions->Hough_3D(&xin, &yin, &zin, &qin, &xout, &yout, &zout, &qout); + for(unsigned int ij=0; ij<xout.size();ij++){ + if(zout[ij]>zmax) {zmax = zout[ij];} + ringtouch[int(round((sqrt(xout[ij]*xout[ij]+yout[ij]*yout[ij])-44.15)/2.1))]++; // Corr by Cyril + } + for(int ko=0; ko<19; ko++){ + if(ringtouch[ko]>0) ringsum++; + } + + // Tracks of interest: >10 pads and >=12 rings hit + if(xout.size()>10 && ringsum>=8){ + + npoint=0; + trackNbr_FINAL++; + double charge_temp=0.; + double lenght_temp=0; + double zintarget=300; + double zouttarget=0; + int indexin=0; int indexout=0; + for(unsigned int ij=0; ij<xout.size(); ij++){ + + point.SetXYZ(xout[ij],yout[ij],zout[ij]); + if(!SimulationBool)point.RotateZ(ZRot_Minos*TMath::DegToRad());//15.6*TMath::DegToRad() CHANGE#### + xoutprime.push_back(point.X());youtprime.push_back(point.Y());zoutprime.push_back(point.Z()); + TOTxoutprime.push_back(point.X()); + // Added line to see events used for fit of lines in tree + TOTyoutprime.push_back(point.Y()); + TOTzoutprime.push_back(point.Z()); + TOTqout.push_back(qout[ij]); + // save cluster_temp + // save numbtrack + trackclusternbr.push_back(clusternbr[i]); + tracknbr.push_back( trackNbr_FINAL ) ; + + grxztmp->SetPoint(npoint,zoutprime[ij],xoutprime[ij]); + gryztmp->SetPoint(npoint,zoutprime[ij],youtprime[ij]); + charge_temp += qout[ij]; + minosdata_result = (TMinosResult*)data_result.ConstructedAt(array_final); + minosdata_result->Set(xoutprime[ij], youtprime[ij], zoutprime[ij], qout[ij], trackNbr_FINAL, xout.size(), zmax); + array_final++; + npoint++; + + if(zoutprime[ij]<zintarget) {zintarget=zoutprime[ij];indexin=ij;} + if(zoutprime[ij]>zouttarget) {zouttarget=zoutprime[ij];indexout=ij;} + } + + if(xout.size()>0)lenght_temp=sqrt(pow(zoutprime[indexin]-zoutprime[indexout],2)+pow(youtprime[indexin]-youtprime[indexout],2)+pow(xoutprime[indexin]-xoutprime[indexout],2)); + + grxz.push_back(*grxztmp); + gryz.push_back(*gryztmp); + grxztmp->Set(0); + /* if(maxCharge >= MINOSthresh ) { */ + gryztmp->Set(0); + + chargeTot.push_back(charge_temp); + lenght.push_back(lenght_temp); + } // end of if(xout.size()>10 &&) + //X_mm->Fill(); + xin.clear(); + yin.clear(); + zin.clear(); + qin.clear(); + xout.clear(); + yout.clear(); + zout.clear(); + xoutprime.clear(); + youtprime.clear(); + zoutprime.clear(); + qout.clear(); + npoint_temp=0; + ringsum=0;// angle between 1st track and z axis in 3D in degrees + zmax=0.; + for(int ko=0; ko<18; ko++) ringtouch[ko] = 0; + + } // if(xin.size()>0 && (( cluster_temp .... ) - npoint=0; - trackNbr_FINAL++; - double charge_temp=0.; - double lenght_temp=0; - double zintarget=300; - double zouttarget=0; - int indexin=0; int indexout=0; - for(unsigned int ij=0; ij<xout.size(); ij++){ - - point.SetXYZ(xout[ij],yout[ij],zout[ij]); - point.RotateZ(0.);//15.6*TMath::DegToRad() CHANGE#### - xoutprime.push_back(point.X());youtprime.push_back(point.Y());zoutprime.push_back(point.Z()); - TOTxoutprime.push_back(point.X()); - // Added line to see events used for fit of lines in tree - TOTyoutprime.push_back(point.Y()); - TOTzoutprime.push_back(point.Z()); - TOTqout.push_back(qout[ij]); - // save cluster_temp - // save numbtrack - trackclusternbr.push_back(clusternbr[i]); - tracknbr.push_back( trackNbr_FINAL ) ; - - grxztmp->SetPoint(npoint,zoutprime[ij],xoutprime[ij]); - gryztmp->SetPoint(npoint,zoutprime[ij],youtprime[ij]); - charge_temp += qout[ij]; - minosdata_result = (TMinosResult*)data_result.ConstructedAt(array_final); - minosdata_result->Set(xoutprime[ij], youtprime[ij], zoutprime[ij], qout[ij], trackNbr_FINAL, xout.size(), zmax); - array_final++; - npoint++; - - ///////// to exclude data w/ rings from 15to18 - if(sqrt(xout[ij]*xout[ij]+yout[ij]*yout[ij])<70 && sqrt(xout[ij]*xout[ij]+yout[ij]*yout[ij])> 53 ){ - if(zoutprime[ij]<zintarget) {zintarget=zoutprime[ij];indexin=ij;} - if(zoutprime[ij]>zouttarget) {zouttarget=zoutprime[ij];indexout=ij;} + cluster_temp = clusternbr[i]; // Number of the track/cluster + /* if(!(clusterpads[i]>=10 && clusterringbool[i]==1 && ZpadNew[i]>-100 && ZpadNew[i]<=310)) continue; // Warning <=310 necessary ? (Cyril) */ + if(!(clusterpads[i]>=10 && clusterringbool[i]==1 && ZpadNew[i]>-100 && ZpadNew[i]<=310)) continue; // Warning <=310 necessary ? (Cyril) + else + { + xin.push_back(XpadNew[i]); + yin.push_back(YpadNew[i]); + zin.push_back(ZpadNew[i]); + qin.push_back(QpadNew[i]); + npoint_temp++; } - } - - if(xout.size()>0)lenght_temp=sqrt(pow(zoutprime[indexin]-zoutprime[indexout],2)+pow(youtprime[indexin]-youtprime[indexout],2)+pow(xoutprime[indexin]-xoutprime[indexout],2)); - - grxz.push_back(*grxztmp); - gryz.push_back(*gryztmp); - grxztmp->Set(0); - gryztmp->Set(0); - - chargeTot.push_back(charge_temp); - lenght.push_back(lenght_temp); - } // end of if(xout.size()>10 &&) - - //X_mm->Fill(); - - xin.clear(); - yin.clear(); - zin.clear(); - qin.clear(); - xout.clear(); - yout.clear(); - zout.clear(); - xoutprime.clear(); - youtprime.clear(); - zoutprime.clear(); - qout.clear(); - npoint_temp=0; - ringsum=0;// angle between 1st track and z axis in 3D in degrees - zmax=0.; - for(int ko=0; ko<18; ko++) ringtouch[ko] = 0; - - } // if(xin.size()>0 && (( cluster_temp .... ) - - cluster_temp = clusternbr[i]; - - if(!(clusterpads[i]>=10 && clusterringbool[i]==1 && ZpadNew[i]>-100 && ZpadNew[i]<=310)) continue; - else - { - xin.push_back(XpadNew[i]); - yin.push_back(YpadNew[i]); - zin.push_back(ZpadNew[i]); - qin.push_back(QpadNew[i]); - npoint_temp++; - } - }//end of loop on padsNews - - - /* //------------------------------------------------------- */ - /* // STEP 3.2: Fitting the filtered tracks in 3D */ - /* // (weight by charge, TMinuit) */ - /* //------------------------------------------------------- */ - - - if(trackNbr_FINAL>= 1){ // !!! Just for 1 or more tracks! - /* if(trackNbr_FINAL== 2){ */ - - //////////Minimization in 3D to reconstruct track lines - allevt_2pfiltered++; - - for(int itr= 0 ; itr<trackNbr_FINAL; itr++) { - - - pStart[0]=0; pStart[2]=0; pStart[1]=1; pStart[3]=3; - min = new TMinuit(4); - min->SetPrintLevel(-1); - arglist[0] = 3; - - Tracking_functions->FindStart(pStart,chi,fitStatus, &grxz.at(itr), &gryz.at(itr)); - - NclusterFit = itr+1; - current_phy=this; - min->SetFCN(SumDistance); - - - // Set starting values and step sizes for parameters - min->mnparm(0,"x0",pStart[0],0.1,-500,500,iflag); - min->mnparm(1,"Ax",pStart[1],0.1,-10,10,iflag); - min->mnparm(2,"y0",pStart[2],0.1,-500,500,iflag); - min->mnparm(3,"Ay",pStart[3],0.1,-10,10,iflag); - arglist[0] = 200; // number of function calls - arglist[1] = 0.000001; // tolerance - - min->mnexcm("MIGRAD",arglist,2,iflag); // minimization with MIGRAD - - min->mnstat(amin,edm,errdef,nvpar,nparx,iflag); //returns current status of the minimization - - - // get fit parameters - - for(int i = 0; i <4; i++) min->GetParameter(i,parFit_temp[i],err_temp[i]); - - /* if( (parFit_temp[0] >-499 && parFit_temp[0]<499) && (parFit_temp[2] >-499 && parFit_temp[2]<499)) { */ - parFit1.push_back(parFit_temp[0]); - parFit2.push_back(parFit_temp[1]); - parFit3.push_back(parFit_temp[2]); - parFit4.push_back(parFit_temp[3]); - /* } */ - delete min; - } - - if(trackNbr_FINAL==2){ - - double ParTrack1[4]; - double ParTrack2[4]; - - ParTrack1[0] = parFit1[0]; - ParTrack1[1] = parFit2[0]; - ParTrack1[2] = parFit3[0]; - ParTrack1[3] = parFit4[0]; - - ParTrack2[0] = parFit1[1]; - ParTrack2[1] = parFit2[1]; - ParTrack2[2] = parFit3[1]; - ParTrack2[3] = parFit4[1]; - - Dist_min=0, Theta_tr1=0, Theta_tr2=0; - Tracking_functions->vertex(ParTrack1, ParTrack2, xv, yv, zv, Dist_min, Theta_tr1, Theta_tr2); - - /* if(abs(xv)<20 && abs(yv)<20){ */ - Xvertex.push_back(xv); - Yvertex.push_back(yv); - Zvertex.push_back(zv-Z_Shift); - - /* if (zv <-50){ */ - /* cout << ParTrack1[0]<< " " << ParTrack1[1]<< " " << ParTrack1[2]<<" " << ParTrack1[3]<<endl; */ - /* cout << xv<< " " << yv<< " " << zv<<endl; */ - /* } */ - - - if(Theta_tr1>Theta_tr2){ - Theta1.push_back(Theta_tr1); - Theta2.push_back(Theta_tr2); - } - else if(Theta_tr1<Theta_tr2){ - Theta1.push_back(Theta_tr2); - Theta2.push_back(Theta_tr1); - } + }//end of PadNews - sumTheta.push_back(Theta_tr1+Theta_tr2); - /* sumTheta.push_back(156.9-(Theta_tr1+Theta_tr2)); */ - /* } */ - /* else{ */ - - /* Xvertex.push_back(-99); */ - /* Yvertex.push_back(-99); */ - /* Zvertex.push_back(-99); */ - /* sumTheta.push_back(1000); */ - /* } */ - - } - else - { - Xvertex.push_back(-1000); - Yvertex.push_back(-1000); - Zvertex.push_back(-1000); - sumTheta.push_back(1000); - } + /* //------------------------------------------------------- */ + /* // STEP 3.2: Fitting the filtered tracks in 3D */ + /* // (weight by charge, TMinuit) */ + /* //------------------------------------------------------- */ - }// end if trackNbr_FINAL>=1 - else - { - Xvertex.push_back(-1000); - Yvertex.push_back(-1000); - Zvertex.push_back(-1000); - sumTheta.push_back(1000); - } - - } // end loop if 0<trackNbr < 5 - else - { - Xvertex.push_back(-1000); - Yvertex.push_back(-1000); - Zvertex.push_back(-1000); - sumTheta.push_back(1000); - } - // instantiate CalibrationManager - static CalibrationManager* Cal = CalibrationManager::getInstance(); -} -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::ReadAnalysisConfig() { - bool ReadingStatus = false; + /* if(trackNbr_FINAL>= 1){ // !!! Just for 1 or more tracks! */ + if(trackNbr_FINAL== 2){ - // path to file - string FileName = "./configs/ConfigMinos.dat"; + //////////Minimization in 2D to reconstruct track lines + allevt_2pfiltered++; - // open analysis config file - ifstream AnalysisConfigFile; - AnalysisConfigFile.open(FileName.c_str()); + for(int itr= 0 ; itr < trackNbr_FINAL; itr++) { - if (!AnalysisConfigFile.is_open()) { - cout << " No ConfigMinos.dat found: Default parameter loaded for Analayis " << FileName << endl; - return; - } - cout << " Loading user parameter for Analysis from ConfigMinos.dat " << endl; - - // Save it in a TAsciiFile - TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); - asciiConfig->AppendLine("%%% ConfigMinos.dat %%%"); - asciiConfig->Append(FileName.c_str()); - asciiConfig->AppendLine(""); - // read analysis config file - string LineBuffer,DataBuffer,whatToDo; - while (!AnalysisConfigFile.eof()) { - // Pick-up next line - getline(AnalysisConfigFile, LineBuffer); - - // search for "header" - string name = "ConfigMinos"; - if (LineBuffer.compare(0, name.length(), name) == 0) - ReadingStatus = true; - - // loop on tokens and data - while (ReadingStatus ) { - whatToDo=""; - AnalysisConfigFile >> whatToDo; - - // Search for comment symbol (%) - if (whatToDo.compare(0, 1, "%") == 0) { - AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); - } + pStart[0]=0; pStart[2]=0; pStart[1]=1; pStart[3]=3; + min = new TMinuit(4); + min->SetPrintLevel(-1); + arglist[0] = 3; - else if (whatToDo=="E_RAW_THRESHOLD") { - AnalysisConfigFile >> DataBuffer; - m_E_RAW_Threshold = atof(DataBuffer.c_str()); - cout << whatToDo << " " << m_E_RAW_Threshold << endl; - } + Tracking_functions->FindStart(pStart,chi,fitStatus, &grxz.at(itr), &gryz.at(itr)); - else if (whatToDo=="E_THRESHOLD") { - AnalysisConfigFile >> DataBuffer; - m_E_Threshold = atof(DataBuffer.c_str()); - cout << whatToDo << " " << m_E_Threshold << endl; - } + NclusterFit = itr+1; + current_phy=this; + min->SetFCN(SumDistance); - else { - ReadingStatus = false; - } - } - } + // Set starting values and step sizes for parameters + min->mnparm(0,"x0",pStart[0],0.1,-500,500,iflag); + min->mnparm(1,"Ax",pStart[1],0.1,-10,10,iflag); + min->mnparm(2,"y0",pStart[2],0.1,-500,500,iflag); + min->mnparm(3,"Ay",pStart[3],0.1,-10,10,iflag); + arglist[0] = 200; // number of function calls + arglist[1] = 0.000001; // tolerance -} + min->mnexcm("MIGRAD",arglist,2,iflag); // minimization with MIGRAD -double TMinosPhysics::distance2(double x,double y,double z, double *p) { - // distance line point is D= | (xp-x0) cross ux | - // where ux is direction of line and x0 is a point in the line (like t = 0) - ROOT::Math::XYZVector xp(x,y,z); //point of the track - ROOT::Math:: XYZVector x0(p[0], p[2], 0. ); - ROOT::Math::XYZVector x1(p[0] + p[1], p[2] + p[3], 1. ); //line - ROOT::Math::XYZVector u = (x1-x0).Unit(); - double d2 = ((xp-x0).Cross(u)) .Mag2(); - return d2; -} + min->mnstat(amin,edm,errdef,nvpar,nparx,iflag); //returns current status of the minimization -void TMinosPhysics::SumDistance(int &, double *, double & sum, double * par, int) { - TMinosPhysics* phy = current_phy; - int nused=0; - double qtot=0; - sum = 0; - - for(int i=0; i < phy->data_result.GetEntriesFast(); i++) - { - phy->minosdata_result = (TMinosResult*)phy->data_result.At(i); - if(phy->minosdata_result->n_Cluster==NclusterFit) - { - float x=phy->minosdata_result->x_mm; - float y=phy->minosdata_result->y_mm; - float z=phy->minosdata_result->z_mm; - float q=phy->minosdata_result->Chargemax; - //if(nused<2)cout<<minosdata_result->n_Cluster<<" "<<x<<" "<<y<<" "<<z<<" "<<q<<endl; - /* double d = Tracking_functions->distance2(x, y, z, par); */ - double d = TMinosPhysics::distance2(x, y, z, par); - sum += d*q; - nused++; - qtot+=q; - } - } - //sum/=nused; - sum/=qtot; - return; -} + // get fit parameters + for(int i = 0; i <4; i++) min->GetParameter(i,parFit_temp[i],err_temp[i]); -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::Clear() { - - Xpad.clear(); - Ypad.clear(); - Qpad.clear(); - XpadNew.clear(); - YpadNew.clear(); - ZpadNew.clear(); - QpadNew.clear(); - - clusterringboolTemp.clear(); - clusterringbool.clear(); - clusternbr.clear(); - clusterpads.clear(); - hfit->Reset(); - - xin.clear(); - yin.clear(); - zin.clear(); - qin.clear(); - xout.clear(); - yout.clear(); - zout.clear(); - xoutprime.clear(); - youtprime.clear(); - zoutprime.clear(); - qout.clear(); - - trackclusternbr.clear(); - tracknbr.clear(); - TOTxoutprime.clear(); - TOTyoutprime.clear(); - TOTzoutprime.clear(); - TOTqout.clear(); - - lenght.clear(); - chargeTot.clear(); - parFit1.clear(); - parFit2.clear(); - parFit3.clear(); - parFit4.clear(); - - Xvertex.clear(); - Yvertex.clear(); - Zvertex.clear(); - sumTheta.clear(); - - grxz.clear(); - gryz.clear(); - - Theta1.clear(); - Theta2.clear(); - - hfit->Reset(); - - - filled=0; - indexfill = 0; - ChargeBin = 0.; - maxCharge = 0.; - Iteration=0; - filter_result=0; - fit2DStatus=0; - trackNbr=0; - trackNbr_FINAL=0; - x_mm = 0.; y_mm = 0.; z_mm = 0.; q_pad = 0.; t_pad = 0.; - array_final=0; - ringsum=0; - zmax=0.; + /* if( (parFit_temp[0] >-499 && parFit_temp[0]<499) && (parFit_temp[2] >-499 && parFit_temp[2]<499)) { */ + /* parFit1[itr] = push_back(parFit_temp[0]); */ + /* parFit2.push_back(parFit_temp[1]); */ + /* parFit3.push_back(parFit_temp[2]); */ + /* parFit4.push_back(parFit_temp[3]); */ + parFit1[itr]=parFit_temp[0]; + parFit2[itr]=parFit_temp[1]; + parFit3[itr]=parFit_temp[2]; + parFit4[itr]=parFit_temp[3]; -} + /* } */ + delete min; + } -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::ReadConfiguration(NPL::InputParser parser) { - /* vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Minos"); */ - /* if(NPOptionManager::getInstance()->GetVerboseLevel()) */ - /* cout << "//// " << blocks.size() << " detectors found " << endl; */ - - /* vector<string> cart = {"POS","Shape"}; */ - /* vector<string> sphe = {"R","THETA","POS","Phi","TargetLength"}; */ - - /* for(unsigned int i = 0 ; i < blocks.size() ; i++){ */ - /* if(blocks[i]->HasTokenList(cart)){ */ - /* if(NPOptionManager::getInstance()->GetVerboseLevel()) */ - /* cout << endl << "//// Minos " << i+1 << endl; */ - - /* TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); */ - /* string Shape = blocks[i]->GetString("Shape"); */ - /* AddDetector(Pos,Shape); */ - /* } */ - /* else if(blocks[i]->HasTokenList(sphe)){ */ - /* if(NPOptionManager::getInstance()->GetVerboseLevel()) */ - /* cout << endl << "//// Minos " << i+1 << endl; */ - /* double R = blocks[i]->GetDouble("R","mm"); */ - /* double Theta = blocks[i]->GetDouble("THETA","deg"); */ - /* TVector3 POS = blocks[i]->GetTVector3("POS","cm"); */ - /* double Phi = blocks[i]->GetDouble("PHI","deg"); */ - /* double TargetLenght = blocks[i]->GetDouble("TargetLength","mm"); */ - /* AddDetector(R,Theta,POS,Phi,TargetLenght); */ - /* } */ - /* else{ */ - /* cout << "ERROR: check your input file formatting " << endl; */ - /* exit(1); */ - /* } */ - /* } */ -} + if(trackNbr_FINAL==2){ + /* if(trackNbr_FINAL>=0){ */ + double ParTrack1[4]; + double ParTrack2[4]; -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::AddParameterToCalibrationManager() { - CalibrationManager* Cal = CalibrationManager::getInstance(); - for (int i = 0; i < m_NumberOfDetectors; ++i) { - Cal->AddParameter("Minos", "D"+ NPL::itoa(i+1)+"_ENERGY","Minos_D"+ NPL::itoa(i+1)+"_ENERGY"); - Cal->AddParameter("Minos", "D"+ NPL::itoa(i+1)+"_TIME","Minos_D"+ NPL::itoa(i+1)+"_TIME"); - } -} + ParTrack1[0] = parFit1[0]; + ParTrack1[1] = parFit2[0]; + ParTrack1[2] = parFit3[0]; + ParTrack1[3] = parFit4[0]; -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::InitializeRootInputRaw() { - TChain* inputChain = RootInput::getInstance()->GetChain(); - inputChain->SetBranchStatus("Minos", true ); - inputChain->SetBranchAddress("Minos", &m_EventData ); - if( strlen(inputChain->GetTree()->GetName())==13) SimulationBool= true; // Test if TreeName==SimulatedTree -} + ParTrack2[0] = parFit1[1]; + ParTrack2[1] = parFit2[1]; + ParTrack2[2] = parFit3[1]; + ParTrack2[3] = parFit4[1]; -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::InitializeRootInputPhysics() { - TChain* inputChain = RootInput::getInstance()->GetChain(); - inputChain->SetBranchAddress("Minos", &m_EventPhysics); -} + Dist_min=0, Theta_tr1=0, Theta_tr2=0; -/////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::InitializeRootOutput() { - TTree* outputTree = RootOutput::getInstance()->GetTree(); - outputTree->Branch("Minos", "TMinosPhysics", &m_EventPhysics); -} + Tracking_functions->vertex(ParTrack1, ParTrack2, xv, yv, zv, Dist_min, Theta_tr1, Theta_tr2, Phi1, Phi2); + + Xvertex=xv; + Yvertex=yv; + Zvertex = zv; + /* Zvertex = zv+Z_Shift; */ + + Dmin = Dist_min; + Theta_1 = Theta_tr1; + Theta_2 = Theta_tr2 ; + + Theta1 = Theta_tr1; + Theta2 = Theta_tr2; -//////////////////////////////////////////////////////////////////////////////// -// Construct Method to be pass to the DetectorFactory // -//////////////////////////////////////////////////////////////////////////////// -NPL::VDetector* TMinosPhysics::Construct() { - return (NPL::VDetector*) new TMinosPhysics(); -} + sumTheta = Theta_tr1+Theta_tr2; + } -//////////////////////////////////////////////////////////////////////////////// -// Registering the construct method to the factory // -//////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_Minos{ - public: - proxy_Minos(){ - NPL::DetectorFactory::getInstance()->AddToken("Minos","Minos"); - NPL::DetectorFactory::getInstance()->AddDetector("Minos",TMinosPhysics::Construct); - } -}; - -proxy_Minos p_Minos; -} + }// end if trackNbr_FINAL>=1 + + } // end loop if 0<trackNbr < 5 + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + } + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigMinos.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigMinos.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigMinos.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigMinos.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigMinos"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + } + } + + } + + double TMinosPhysics::distance2(double x,double y,double z, double *p) { + // distance line point is D= | (xp-x0) cross ux | + // where ux is direction of line and x0 is a point in the line (like t = 0) + ROOT::Math::XYZVector xp(x,y,z); //point of the track + ROOT::Math:: XYZVector x0(p[0], p[2], 0. ); + ROOT::Math::XYZVector x1(p[0] + p[1], p[2] + p[3], 1. ); //line + ROOT::Math::XYZVector u = (x1-x0).Unit(); + double d2 = ((xp-x0).Cross(u)) .Mag2(); + return d2; + } + + void TMinosPhysics::SumDistance(int &, double *, double & sum, double * par, int) { + TMinosPhysics* phy = current_phy; + int nused=0; + double qtot=0; + sum = 0; + + for(int i=0; i < phy->data_result.GetEntriesFast(); i++) + { + phy->minosdata_result = (TMinosResult*)phy->data_result.At(i); + if(phy->minosdata_result->n_Cluster==NclusterFit) + { + float x=phy->minosdata_result->x_mm; + float y=phy->minosdata_result->y_mm; + float z=phy->minosdata_result->z_mm; + float q=phy->minosdata_result->Chargemax; + //if(nused<2)cout<<minosdata_result->n_Cluster<<" "<<x<<" "<<y<<" "<<z<<" "<<q<<endl; + /* double d = Tracking_functions->distance2(x, y, z, par); */ + double d = TMinosPhysics::distance2(x, y, z, par); + sum += d*q; + nused++; + qtot+=q; + } + } + //sum/=nused; + sum/=qtot; + return; + } + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::Clear() { + + Xpad.clear(); + Ypad.clear(); + Qpad.clear(); + XpadNew.clear(); + YpadNew.clear(); + ZpadNew.clear(); + QpadNew.clear(); + + clusterringboolTemp.clear(); + clusterringbool.clear(); + clusternbr.clear(); + clusterpads.clear(); + hfit->Reset(); + + xin.clear(); + yin.clear(); + zin.clear(); + qin.clear(); + xout.clear(); + yout.clear(); + zout.clear(); + xoutprime.clear(); + youtprime.clear(); + zoutprime.clear(); + qout.clear(); + + trackclusternbr.clear(); + tracknbr.clear(); + TOTxoutprime.clear(); + TOTyoutprime.clear(); + TOTzoutprime.clear(); + TOTqout.clear(); + + lenght.clear(); + chargeTot.clear(); + parFit1.clear(); + parFit2.clear(); + parFit3.clear(); + parFit4.clear(); + + grxz.clear(); + gryz.clear(); + + hfit->Reset(); + + + filled=0; + indexfill = 0; + ChargeBin = 0.; + maxCharge = 0.; + Iteration=0; + filter_result=0; + fit2DStatus=0; + trackNbr=0; + trackNbr_FINAL=0; + x_mm = 0.; y_mm = 0.; z_mm = 0.; q_pad = 0.; t_pad = 0.; + array_final=0; + ringsum=0; + zmax=0.; + + + } + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::ReadConfiguration(NPL::InputParser parser) { + } + + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("Minos", "D"+ NPL::itoa(i+1)+"_ENERGY","Minos_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("Minos", "D"+ NPL::itoa(i+1)+"_TIME","Minos_D"+ NPL::itoa(i+1)+"_TIME"); + } + } + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("Minos", true ); + inputChain->SetBranchAddress("Minos", &m_EventData ); + if( strlen(inputChain->GetTree()->GetName())==13) SimulationBool= true; // Test if TreeName==SimulatedTree + } + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("Minos", &m_EventPhysics); + } + + /////////////////////////////////////////////////////////////////////////// + void TMinosPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("Minos", "TMinosPhysics", &m_EventPhysics); + } + + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPL::VDetector* TMinosPhysics::Construct() { + return (NPL::VDetector*) new TMinosPhysics(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern "C"{ + class proxy_Minos{ + public: + proxy_Minos(){ + NPL::DetectorFactory::getInstance()->AddToken("Minos","Minos"); + NPL::DetectorFactory::getInstance()->AddDetector("Minos",TMinosPhysics::Construct); + } + }; + + proxy_Minos p_Minos; + } diff --git a/NPLib/Detectors/Minos/TMinosPhysics.h b/NPLib/Detectors/Minos/TMinosPhysics.h index 23d9d57e5c6ed5739a27b8b959cf6628daed0325..2ac1d0cb9963adc00d1e9b74e5c63a6bff7f3acc 100644 --- a/NPLib/Detectors/Minos/TMinosPhysics.h +++ b/NPLib/Detectors/Minos/TMinosPhysics.h @@ -63,8 +63,6 @@ class TMinosPhysics : public TObject, public NPL::VDetector { void Clear(const Option_t*) {}; - /* static void SumDistance(int &, double *, double & sum, double * par, int); */ - ////////////////////////////////////////////////////////////// // data obtained after BuildPhysicalEvent() and stored in // output ROOT file @@ -116,12 +114,10 @@ class TMinosPhysics : public TObject, public NPL::VDetector { NPL::Tracking* Tracking_functions; //! - /* int NclusterFit; //! */ // fit function for the Q(t) signals at each pad static double conv_fit(double *x, double *p); static double distance2(double x,double y,double z, double *p); static void SumDistance(int &, double *, double & sum, double * par, int); - // remove bad channels, calibrate the data and apply thresholds void PreTreat(); @@ -164,16 +160,22 @@ TMinosResult *minosdata_result;//! vector<double> GetPad_X() {return X_Pad;} vector<double> GetPad_Y() {return Y_Pad;} vector<double> GetPad_Z() {return Z_Pad;} + vector<double> GetPad_T() {return T_Pad;} vector<double> GetParFit1() {return parFit1;} vector<double> GetParFit2() {return parFit2;} vector<double> GetParFit3() {return parFit3;} vector<double> GetParFit4() {return parFit4;} - double GetVertexZ() {return Zvertex[0];} + double GetVertexZ() {return Zvertex;} + double GetVertexX() {return Xvertex;} + double GetVertexY() {return Yvertex;} - /* TClonesArray fitdata; */ - - /* fitdata.SetClass("TMinosClust"); */ - + double GetTheta1() {return Theta1 ;} + double GetTheta2() {return Theta2 ;} + double GetTheta_1() {return Theta_1 ;} + double GetTheta_2() {return Theta_2 ;} + + double GetPhi1(){return Phi1;} + double GetPhi2(){return Phi2;} // parameters used in the analysis private: @@ -256,13 +258,19 @@ TMinosResult *minosdata_result;//! vector<double> TOTzoutprime; vector<double> TOTqout; - vector<double> Xvertex; - vector<double> Yvertex; - vector<double> Zvertex; + double Xvertex; + double Yvertex; + double Zvertex; + double Dmin; - vector<double> sumTheta; - vector<double> Theta1; - vector<double> Theta2; + double sumTheta; + double Theta1; + double Theta2; + double Theta_1; + double Theta_2; + + double Phi1; + double Phi2; vector<int> trackclusternbr;//! vector<int> tracknbr;//! @@ -302,12 +310,11 @@ TMinosResult *minosdata_result;//! vector<double> errFit3_local; vector<double> errFit4_local; - double xv;//! double yv;//! double zv;//! - double Dist_min;//! + double Dist_min; double Theta_tr1;//! double Theta_tr2;//! // number of detectors diff --git a/NPLib/Detectors/ModularLeaf/CMakeLists.txt b/NPLib/Detectors/ModularLeaf/CMakeLists.txt index 104b310bb4d476a71a8a09537ded520680292c05..7064dda935943e627b71fc966696f4387ae2ef14 100644 --- a/NPLib/Detectors/ModularLeaf/CMakeLists.txt +++ b/NPLib/Detectors/ModularLeaf/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_command(OUTPUT TModularLeafPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TModularLeafPhysics.h TModularLeafPhysicsDict.cxx TModularLeafPhysics.rootmap libNPModularLeaf.dylib DEPENDS TModularLeafPhysics.h) +add_custom_command(OUTPUT TModularLeafPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TModularLeafPhysics.h TModularLeafPhysicsDict.cxx TModularLeafPhysics.rootmap libNPModularLeaf.dylib DEPENDS TModularLeafPhysics.h) add_library(NPModularLeaf SHARED TModularLeafPhysics.cxx TModularLeafPhysicsDict.cxx TModularLeafSpectra.cxx) target_link_libraries(NPModularLeaf ${ROOT_LIBRARIES} NPCore) install(FILES TModularLeafPhysics.h TModularLeafSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Mugast/CMakeLists.txt b/NPLib/Detectors/Mugast/CMakeLists.txt index e11a41e88cd4b9110560a0ceb913d6f962f95fb9..61c30d22685a1224ac05d5cebe94fc7e5a50c6c3 100644 --- a/NPLib/Detectors/Mugast/CMakeLists.txt +++ b/NPLib/Detectors/Mugast/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TMugastPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMugastPhysics.h TMugastPhysicsDict.cxx TMugastPhysics.rootmap libNPMugast.dylib DEPENDS TMugastPhysics.h) -add_custom_command(OUTPUT TMugastDataDict.cxx COMMAND ../../scripts/build_dict.sh TMugastData.h TMugastDataDict.cxx TMugastData.rootmap libNPMugast.dylib DEPENDS TMugastData.h) +add_custom_command(OUTPUT TMugastPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMugastPhysics.h TMugastPhysicsDict.cxx TMugastPhysics.rootmap libNPMugast.dylib DEPENDS TMugastPhysics.h) +add_custom_command(OUTPUT TMugastDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TMugastData.h TMugastDataDict.cxx TMugastData.rootmap libNPMugast.dylib DEPENDS TMugastData.h) #add_library(NPMUST2 SHARED TMugastData.cxx TMugastPhysics.cxx TMugastDataDict.cxx TMugastPhysicsDict.cxx TMugastSpectra.cxx) add_library(NPMugast SHARED TMugastData.cxx TMugastDataDict.cxx TMugastPhysics.cxx TMugastPhysicsDict.cxx TMugastSpectra.h TMugastSpectra.cxx) target_link_libraries(NPMugast ${ROOT_LIBRARIES} NPCore) diff --git a/NPLib/Detectors/Nana/CMakeLists.txt b/NPLib/Detectors/Nana/CMakeLists.txt index c0f7a9453522fb6eb164e8147a345ac13976ad45..19e2dcae61ec9eeeb0ae2f960fb59c6a2d6df175 100644 --- a/NPLib/Detectors/Nana/CMakeLists.txt +++ b/NPLib/Detectors/Nana/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TNanaPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TNanaPhysics.h TNanaPhysicsDict.cxx TNanaPhysics.rootmap libNPNana.dylib DEPENDS TNanaPhysics.h) -add_custom_command(OUTPUT TNanaDataDict.cxx COMMAND ../../scripts/build_dict.sh TNanaData.h TNanaDataDict.cxx TNanaData.rootmap libNPNana.dylib DEPENDS TNanaData.h) +add_custom_command(OUTPUT TNanaPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNanaPhysics.h TNanaPhysicsDict.cxx TNanaPhysics.rootmap libNPNana.dylib DEPENDS TNanaPhysics.h) +add_custom_command(OUTPUT TNanaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNanaData.h TNanaDataDict.cxx TNanaData.rootmap libNPNana.dylib DEPENDS TNanaData.h) add_library(NPNana SHARED TNanaData.cxx TNanaPhysics.cxx TNanaDataDict.cxx TNanaPhysicsDict.cxx ) target_link_libraries(NPNana ${ROOT_LIBRARIES} NPCore) install(FILES TNanaData.h TNanaPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Nebula/CMakeLists.txt b/NPLib/Detectors/Nebula/CMakeLists.txt index 1b0a243842d9117ae7afe6046e4f33304a92a472..51226c56ca4432329dabb4b21eccd809a60d33a2 100644 --- a/NPLib/Detectors/Nebula/CMakeLists.txt +++ b/NPLib/Detectors/Nebula/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TNebulaPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TNebulaPhysics.h TNebulaPhysicsDict.cxx TNebulaPhysics.rootmap libNPNebula.dylib DEPENDS TNebulaPhysics.h) -add_custom_command(OUTPUT TNebulaDataDict.cxx COMMAND ../../scripts/build_dict.sh TNebulaData.h TNebulaDataDict.cxx TNebulaData.rootmap libNPNebula.dylib DEPENDS TNebulaData.h) +add_custom_command(OUTPUT TNebulaPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNebulaPhysics.h TNebulaPhysicsDict.cxx TNebulaPhysics.rootmap libNPNebula.dylib DEPENDS TNebulaPhysics.h) +add_custom_command(OUTPUT TNebulaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNebulaData.h TNebulaDataDict.cxx TNebulaData.rootmap libNPNebula.dylib DEPENDS TNebulaData.h) add_library(NPNebula SHARED TNebulaSpectra.cxx TNebulaData.cxx TNebulaPhysics.cxx TNebulaDataDict.cxx TNebulaPhysicsDict.cxx ) target_link_libraries(NPNebula ${ROOT_LIBRARIES} NPCore) install(FILES TNebulaData.h TNebulaPhysics.h TNebulaSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/NeutronWall/CMakeLists.txt b/NPLib/Detectors/NeutronWall/CMakeLists.txt index aa9017a8d3279957bac96b5fad3a74c31fed1b6c..8ba7f9f70e1629c7d34d19198e45bfd458b000a1 100644 --- a/NPLib/Detectors/NeutronWall/CMakeLists.txt +++ b/NPLib/Detectors/NeutronWall/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TNeutronWallPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TNeutronWallPhysics.h TNeutronWallPhysicsDict.cxx TNeutronWallPhysics.rootmap libNPNeutronWall.dylib DEPENDS TNeutronWallPhysics.h) -add_custom_command(OUTPUT TNeutronWallDataDict.cxx COMMAND ../../scripts/build_dict.sh TNeutronWallData.h TNeutronWallDataDict.cxx TNeutronWallData.rootmap libNPNeutronWall.dylib DEPENDS TNeutronWallData.h) +add_custom_command(OUTPUT TNeutronWallPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNeutronWallPhysics.h TNeutronWallPhysicsDict.cxx TNeutronWallPhysics.rootmap libNPNeutronWall.dylib DEPENDS TNeutronWallPhysics.h) +add_custom_command(OUTPUT TNeutronWallDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNeutronWallData.h TNeutronWallDataDict.cxx TNeutronWallData.rootmap libNPNeutronWall.dylib DEPENDS TNeutronWallData.h) add_library(NPNeutronWall SHARED TNeutronWallSpectra.cxx TNeutronWallData.cxx TNeutronWallPhysics.cxx TNeutronWallDataDict.cxx TNeutronWallPhysicsDict.cxx ) target_link_libraries(NPNeutronWall ${ROOT_LIBRARIES} NPCore) install(FILES TNeutronWallData.h TNeutronWallPhysics.h TNeutronWallSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/PISTA/CMakeLists.txt b/NPLib/Detectors/PISTA/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe7686eee6bfe0d91d709d23238b4c5153050672 --- /dev/null +++ b/NPLib/Detectors/PISTA/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TPISTAPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TPISTAPhysics.h TPISTAPhysicsDict.cxx TPISTAPhysics.rootmap libNPPISTA.dylib DEPENDS TPISTAPhysics.h) +add_custom_command(OUTPUT TPISTADataDict.cxx COMMAND ../../scripts/build_dict.sh TPISTAData.h TPISTADataDict.cxx TPISTAData.rootmap libNPPISTA.dylib DEPENDS TPISTAData.h) +add_library(NPPISTA SHARED TPISTASpectra.cxx TPISTAData.cxx TPISTAPhysics.cxx TPISTADataDict.cxx TPISTAPhysicsDict.cxx ) +target_link_libraries(NPPISTA ${ROOT_LIBRARIES} NPCore) +install(FILES TPISTAData.h TPISTAPhysics.h TPISTASpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/PISTA/TPISTAData.cxx b/NPLib/Detectors/PISTA/TPISTAData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5a5970934c58048f7570b77e68b6693fcf7898f4 --- /dev/null +++ b/NPLib/Detectors/PISTA/TPISTAData.cxx @@ -0,0 +1,107 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold PISTA Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TPISTAData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TPISTAData) + + +////////////////////////////////////////////////////////////////////// +TPISTAData::TPISTAData() { +} + + + +////////////////////////////////////////////////////////////////////// +TPISTAData::~TPISTAData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TPISTAData::Clear() { + // Energy X + fFirstStage_XE_DetectorNbr.clear(); + fFirstStage_XE_StripNbr.clear(); + fFirstStage_XE_Energy.clear(); + // Energy Y + fFirstStage_YE_DetectorNbr.clear(); + fFirstStage_YE_StripNbr.clear(); + fFirstStage_YE_Energy.clear(); + // Time X + fFirstStage_XT_DetectorNbr.clear(); + fFirstStage_XT_StripNbr.clear(); + fFirstStage_XT_Time.clear(); + // Time Y + fFirstStage_YT_DetectorNbr.clear(); + fFirstStage_YT_StripNbr.clear(); + fFirstStage_YT_Time.clear(); + + // Energy X + fSecondStage_XE_DetectorNbr.clear(); + fSecondStage_XE_StripNbr.clear(); + fSecondStage_XE_Energy.clear(); + // Energy Y + fSecondStage_YE_DetectorNbr.clear(); + fSecondStage_YE_StripNbr.clear(); + fSecondStage_YE_Energy.clear(); + // Time X + fSecondStage_XT_DetectorNbr.clear(); + fSecondStage_XT_StripNbr.clear(); + fSecondStage_XT_Time.clear(); + // Time Y + fSecondStage_YT_DetectorNbr.clear(); + fSecondStage_YT_StripNbr.clear(); + fSecondStage_YT_Time.clear(); + +} + + + +////////////////////////////////////////////////////////////////////// +void TPISTAData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TPISTAData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fFirstStage_XE_DetectorNbr.size(); + cout << "First Stage PISTA_XE_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "X-DetNbr: " << fFirstStage_XE_DetectorNbr[i] + << " X-Energy: " << fFirstStage_XE_Energy[i]; + } + + // Time + mysize = fFirstStage_XT_DetectorNbr.size(); + cout << "First Stage PISTA_XT_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "X-DetNbr: " << fFirstStage_XT_DetectorNbr[i] + << " X-Time: " << fFirstStage_XT_Time[i]; + } +} diff --git a/NPLib/Detectors/PISTA/TPISTAData.h b/NPLib/Detectors/PISTA/TPISTAData.h new file mode 100644 index 0000000000000000000000000000000000000000..82f0a3861ec51b516bea5432d803167448709eaf --- /dev/null +++ b/NPLib/Detectors/PISTA/TPISTAData.h @@ -0,0 +1,227 @@ +#ifndef __PISTADATA__ +#define __PISTADATA__ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold PISTA Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TPISTAData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // First Stage Front Energy + vector<unsigned short> fFirstStage_XE_DetectorNbr; + vector<unsigned short> fFirstStage_XE_StripNbr; + vector<double> fFirstStage_XE_Energy; + // First Stage Front Time + vector<unsigned short> fFirstStage_XT_DetectorNbr; + vector<unsigned short> fFirstStage_XT_StripNbr; + vector<double> fFirstStage_XT_Time; + // First Stage Back Energy + vector<unsigned short> fFirstStage_YE_DetectorNbr; + vector<unsigned short> fFirstStage_YE_StripNbr; + vector<double> fFirstStage_YE_Energy; + // First Stage Back Time + vector<unsigned short> fFirstStage_YT_DetectorNbr; + vector<unsigned short> fFirstStage_YT_StripNbr; + vector<double> fFirstStage_YT_Time; + + // Second Stage Front Energy + vector<unsigned short> fSecondStage_XE_DetectorNbr; + vector<unsigned short> fSecondStage_XE_StripNbr; + vector<double> fSecondStage_XE_Energy; + // Second Stage Front Time + vector<unsigned short> fSecondStage_XT_DetectorNbr; + vector<unsigned short> fSecondStage_XT_StripNbr; + vector<double> fSecondStage_XT_Time; + // Second Stage Back Energy + vector<unsigned short> fSecondStage_YE_DetectorNbr; + vector<unsigned short> fSecondStage_YE_StripNbr; + vector<double> fSecondStage_YE_Energy; + // Second Stage Back Time + vector<unsigned short> fSecondStage_YT_DetectorNbr; + vector<unsigned short> fSecondStage_YT_StripNbr; + vector<double> fSecondStage_YT_Time; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TPISTAData(); + ~TPISTAData(); + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + ////////////////////////////////////////////////////////////// + // Getters and Setters + // Prefer inline declaration to avoid unnecessary called of + // frequently used methods + // add //! to avoid ROOT creating dictionnary for the methods + public: + ////////////////////// SETTERS //////////////////////// + // First Stage Energy Front + inline void SetFirstStageXE(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Energy){ + fFirstStage_XE_DetectorNbr.push_back(DetNbr); + fFirstStage_XE_StripNbr.push_back(StripNbr); + fFirstStage_XE_Energy.push_back(Energy); + };//! + // First Stage Energy Back + inline void SetFirstStageYE(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Energy){ + fFirstStage_YE_DetectorNbr.push_back(DetNbr); + fFirstStage_YE_StripNbr.push_back(StripNbr); + fFirstStage_YE_Energy.push_back(Energy); + };//! + // First Stage Time Front + inline void SetFirstStageXT(const UShort_t& DetNbr, const UShort_t StripNbr, const Double_t& Time) { + fFirstStage_XT_DetectorNbr.push_back(DetNbr); + fFirstStage_XT_StripNbr.push_back(StripNbr); + fFirstStage_XT_Time.push_back(Time); + };//! + // First Stage Time Back + inline void SetFirstStageYT(const UShort_t& DetNbr, const UShort_t StripNbr, const Double_t& Time) { + fFirstStage_YT_DetectorNbr.push_back(DetNbr); + fFirstStage_YT_StripNbr.push_back(StripNbr); + fFirstStage_YT_Time.push_back(Time); + };//! + + ////// + // Second Stage Energy Front + inline void SetSecondStageXE(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Energy){ + fSecondStage_XE_DetectorNbr.push_back(DetNbr); + fSecondStage_XE_StripNbr.push_back(StripNbr); + fSecondStage_XE_Energy.push_back(Energy); + };//! + // Second Stage Energy Back + inline void SetSecondStageYE(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Energy){ + fSecondStage_YE_DetectorNbr.push_back(DetNbr); + fSecondStage_YE_StripNbr.push_back(StripNbr); + fSecondStage_YE_Energy.push_back(Energy); + };//! + // Second Stage Time Front + inline void SetSecondStageXT(const UShort_t& DetNbr, const UShort_t StripNbr, const Double_t& Time) { + fSecondStage_XT_DetectorNbr.push_back(DetNbr); + fSecondStage_XT_StripNbr.push_back(StripNbr); + fSecondStage_XT_Time.push_back(Time); + };//! + // Second Stage Time Back + inline void SetSecondStageYT(const UShort_t& DetNbr, const UShort_t StripNbr, const Double_t& Time) { + fSecondStage_YT_DetectorNbr.push_back(DetNbr); + fSecondStage_YT_StripNbr.push_back(StripNbr); + fSecondStage_YT_Time.push_back(Time); + };//! + + ////////////////////// GETTERS //////////////////////// + // First Stage Energy X + inline UShort_t GetFirstStageMultXEnergy() const + {return fFirstStage_XE_DetectorNbr.size();} + inline UShort_t GetFirstStage_XE_DetectorNbr(const unsigned int &i) const + {return fFirstStage_XE_DetectorNbr[i];}//! + inline UShort_t GetFirstStage_XE_StripNbr(const unsigned int &i) const + {return fFirstStage_XE_StripNbr[i];}//! + inline Double_t GetFirstStage_XE_Energy(const unsigned int &i) const + {return fFirstStage_XE_Energy[i];}//! + // First Stage Energy Y + inline UShort_t GetFirstStageMultYEnergy() const + {return fFirstStage_YE_DetectorNbr.size();} + inline UShort_t GetFirstStage_YE_DetectorNbr(const unsigned int &i) const + {return fFirstStage_YE_DetectorNbr[i];}//! + inline UShort_t GetFirstStage_YE_StripNbr(const unsigned int &i) const + {return fFirstStage_YE_StripNbr[i];}//! + inline Double_t GetFirstStage_YE_Energy(const unsigned int &i) const + {return fFirstStage_YE_Energy[i];}//! + // First Stage Time X + inline UShort_t GetFirstStageMultXTime() const + {return fFirstStage_XT_DetectorNbr.size();} + inline UShort_t GetFirstStage_XT_DetectorNbr(const unsigned int &i) const + {return fFirstStage_XT_DetectorNbr[i];}//! + inline UShort_t GetFirstStage_XT_StripNbr(const unsigned int &i) const + {return fFirstStage_XT_StripNbr[i];}//! + inline Double_t GetFirstStage_XT_Time(const unsigned int &i) const + {return fFirstStage_XT_Time[i];}//! + // First Stage Time Y + inline UShort_t GetFirstStageMultYTime() const + {return fFirstStage_YT_DetectorNbr.size();} + inline UShort_t GetFirstStage_YT_DetectorNbr(const unsigned int &i) const + {return fFirstStage_YT_DetectorNbr[i];}//! + inline UShort_t GetFirstStage_YT_StripNbr(const unsigned int &i) const + {return fFirstStage_YT_StripNbr[i];}//! + inline Double_t GetFirstStage_YT_Time(const unsigned int &i) const + {return fFirstStage_YT_Time[i];}//! + + ////// + // Second Stage Energy X + inline UShort_t GetSecondStageMultXEnergy() const + {return fSecondStage_XE_DetectorNbr.size();} + inline UShort_t GetSecondStage_XE_DetectorNbr(const unsigned int &i) const + {return fSecondStage_XE_DetectorNbr[i];}//! + inline UShort_t GetSecondStage_XE_StripNbr(const unsigned int &i) const + {return fSecondStage_XE_StripNbr[i];}//! + inline Double_t GetSecondStage_XE_Energy(const unsigned int &i) const + {return fSecondStage_XE_Energy[i];}//! + // Second Stage Energy Y + inline UShort_t GetSecondStageMultYEnergy() const + {return fSecondStage_YE_DetectorNbr.size();} + inline UShort_t GetSecondStage_YE_DetectorNbr(const unsigned int &i) const + {return fSecondStage_YE_DetectorNbr[i];}//! + inline UShort_t GetSecondStage_YE_StripNbr(const unsigned int &i) const + {return fSecondStage_YE_StripNbr[i];}//! + inline Double_t GetSecondStage_YE_Energy(const unsigned int &i) const + {return fSecondStage_YE_Energy[i];}//! + // Second Stage Time X + inline UShort_t GetSecondStageMultXTime() const + {return fSecondStage_XT_DetectorNbr.size();} + inline UShort_t GetSecondStage_XT_DetectorNbr(const unsigned int &i) const + {return fSecondStage_XT_DetectorNbr[i];}//! + inline UShort_t GetSecondStage_XT_StripNbr(const unsigned int &i) const + {return fSecondStage_XT_StripNbr[i];}//! + inline Double_t GetSecondStage_XT_Time(const unsigned int &i) const + {return fSecondStage_XT_Time[i];}//! + // Second Stage Time Y + inline UShort_t GetSecondStageMultYTime() const + {return fSecondStage_YT_DetectorNbr.size();} + inline UShort_t GetSecondStage_YT_DetectorNbr(const unsigned int &i) const + {return fSecondStage_YT_DetectorNbr[i];}//! + inline UShort_t GetSecondStage_YT_StripNbr(const unsigned int &i) const + {return fSecondStage_YT_StripNbr[i];}//! + inline Double_t GetSecondStage_YT_Time(const unsigned int &i) const + {return fSecondStage_YT_Time[i];}//! + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TPISTAData,1) // PISTAData structure +}; + +#endif diff --git a/NPLib/Detectors/PISTA/TPISTAPhysics.cxx b/NPLib/Detectors/PISTA/TPISTAPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c0893cc90e0c4512e5ce865c93031b880fa948ee --- /dev/null +++ b/NPLib/Detectors/PISTA/TPISTAPhysics.cxx @@ -0,0 +1,555 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold PISTA Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TPISTAPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" + +// ROOT +#include "TChain.h" + +ClassImp(TPISTAPhysics) + /////////////////////////////////////////////////////////////////////////// + TPISTAPhysics::TPISTAPhysics(){ + EventMultiplicity = 0; + m_EventData = new TPISTAData; + m_PreTreatedData = new TPISTAData; + m_EventPhysics = this; + m_Spectra = NULL; + m_E_RAW_Threshold = 0; // adc channels + m_E_Threshold = 0; // MeV + m_NumberOfDetectors = 0; + m_MaximumStripMultiplicityAllowed = 10; + m_StripEnergyMatching = 0.050; + } + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +void TPISTAPhysics::AddDetector(TVector3){ + // In That simple case nothing is done + // Typically for more complex detector one would calculate the relevant + // positions (stripped silicon) or angles (gamma array) + m_NumberOfDetectors++; +} + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::AddDetector(double R, double Theta, double Phi){ + m_NumberOfDetectors++; + + //double Height = 118; // mm + double Height = 61.8; // mm + //double Base = 95; // mm + double Base = 78.1; // mm + double NumberOfStrips = 128; + double StripPitchHeight = Height / NumberOfStrips; // mm + double StripPitchBase = Base / NumberOfStrips; // mm + + + // Vector U on detector face (parallel to Y strips) Y strips are along X axis + TVector3 U; + // Vector V on detector face (parallel to X strips) + TVector3 V; + // Vector W normal to detector face (pointing to the back) + TVector3 W; + // Vector C position of detector face center + TVector3 C; + + C = TVector3(R*sin(Theta)*cos(Phi), + R*sin(Theta)*sin(Phi), + Height*0.5+R*cos(Theta)); + + TVector3 P = TVector3(cos(Theta)*cos(Phi), + cos(Theta)*sin(Phi), + -sin(Theta)); + + W = C.Unit(); + U = W.Cross(P); + V = W.Cross(U); + + U = U.Unit(); + V = V.Unit(); + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + double X, Y, Z; + + // Moving C to the 1.1 Corner; + TVector3 Strip_1_1; + Strip_1_1 = C - (0.5*Base*U + 0.5*Height*V) + U*(StripPitchBase / 2.) + V*(StripPitchHeight / 2.); + + TVector3 StripPos; + for(int i=0; i<NumberOfStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + for(int j=0; j<NumberOfStrips; j++){ + StripPos = Strip_1_1 + i*U*StripPitchBase + j*V*StripPitchHeight; + lineX.push_back(StripPos.X()); + lineY.push_back(StripPos.Y()); + lineZ.push_back(StripPos.Z()); + } + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back(OneDetectorStripPositionX); + m_StripPositionY.push_back(OneDetectorStripPositionY); + m_StripPositionZ.push_back(OneDetectorStripPositionZ); +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TPISTAPhysics::GetPositionOfInteraction(const int i){ + TVector3 Position = TVector3(GetStripPositionX(DetectorNumber[i], StripX[i], StripY[i]), + GetStripPositionY(DetectorNumber[i], StripX[i], StripY[i]), + GetStripPositionZ(DetectorNumber[i], StripX[i], StripY[i])); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TPISTAPhysics::GetDetectorNormal(const int i){ + TVector3 U = TVector3(GetStripPositionX(DetectorNumber[i],128,1), + GetStripPositionY(DetectorNumber[i],128,1), + GetStripPositionZ(DetectorNumber[i],128,1)) + + -TVector3(GetStripPositionX(DetectorNumber[i],1,1), + GetStripPositionY(DetectorNumber[i],1,1), + GetStripPositionZ(DetectorNumber[i],1,1)); + + TVector3 V = TVector3(GetStripPositionX(DetectorNumber[i],128,128), + GetStripPositionY(DetectorNumber[i],128,128), + GetStripPositionZ(DetectorNumber[i],128,128)) + + -TVector3(GetStripPositionX(DetectorNumber[i],128,1), + GetStripPositionY(DetectorNumber[i],128,1), + GetStripPositionZ(DetectorNumber[i],128,1)); + + TVector3 Normal = U.Cross(V); + + return (Normal.Unit()); +} +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::BuildPhysicalEvent() { + // apply thresholds and calibration + PreTreat(); + + if(1 /*CheckEvent() == 1*/){ + vector<TVector2> couple = Match_X_Y(); + + EventMultiplicity = couple.size(); + for(unsigned int i=0; i<couple.size(); i++){ + int N = m_PreTreatedData->GetFirstStage_XE_DetectorNbr(couple[i].X()); + int X = m_PreTreatedData->GetFirstStage_XE_StripNbr(couple[i].X()); + int Y = m_PreTreatedData->GetFirstStage_YE_StripNbr(couple[i].Y()); + + double XE = m_PreTreatedData->GetFirstStage_XE_Energy(couple[i].X()); + double YE = m_PreTreatedData->GetFirstStage_YE_Energy(couple[i].Y()); + DetectorNumber.push_back(N); + StripX.push_back(X); + StripY.push_back(Y); + DE.push_back(XE); + + PosX.push_back(GetPositionOfInteraction(i).x()); + PosY.push_back(GetPositionOfInteraction(i).y()); + PosZ.push_back(GetPositionOfInteraction(i).z()); + + int SecondStageMult = m_PreTreatedData->GetSecondStageMultXEnergy(); + for(unsigned int j=0; j<SecondStageMult; j++){ + if(m_PreTreatedData->GetSecondStage_XE_DetectorNbr(j)==N){ + double XDE = m_PreTreatedData->GetSecondStage_XE_Energy(j); + double YDE = m_PreTreatedData->GetSecondStage_YE_Energy(j); + + E.push_back(XDE); + } + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +vector<TVector2> TPISTAPhysics::Match_X_Y(){ + vector<TVector2> ArrayOfGoodCouple; + + static unsigned int m_XEMult, m_YEMult; + m_XEMult = m_PreTreatedData->GetFirstStageMultXEnergy(); + m_YEMult = m_PreTreatedData->GetFirstStageMultYEnergy(); + + if(m_XEMult>m_MaximumStripMultiplicityAllowed || m_YEMult>m_MaximumStripMultiplicityAllowed){ + return ArrayOfGoodCouple; + } + + for(unsigned int i=0; i<m_XEMult; i++){ + for(unsigned int j=0; j<m_YEMult; j++){ + + // Declaration of variable for clarity + int XDetNbr = m_PreTreatedData->GetFirstStage_XE_DetectorNbr(i); + int YDetNbr = m_PreTreatedData->GetFirstStage_YE_DetectorNbr(j); + + // if same detector check energy + if(XDetNbr == YDetNbr){ + // Declaration of variable for clarity + double XE = m_PreTreatedData->GetFirstStage_XE_Energy(i); + double YE = m_PreTreatedData->GetFirstStage_YE_Energy(i); + double XStripNbr = m_PreTreatedData->GetFirstStage_XE_StripNbr(i); + double YStripNbr = m_PreTreatedData->GetFirstStage_YE_StripNbr(i); + + // look if energy matches + if(abs(XE-YE)/2.<m_StripEnergyMatching){ + ArrayOfGoodCouple.push_back(TVector2(i,j)); + } + } + } + } + + return ArrayOfGoodCouple; +} + +/////////////////////////////////////////////////////////////////////////// +int TPISTAPhysics::CheckEvent(){ + // Check the size of the different elements + if(m_PreTreatedData->GetFirstStageMultXEnergy() == m_PreTreatedData->GetFirstStageMultYEnergy() ) + return 1; + + else + return -1; +} + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::PreTreat() { + // This method typically applies thresholds and calibrations + // Might test for disabled channels for more complex detector + + // clear pre-treated object + ClearPreTreatedData(); + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + + ////// + // First Stage Energy + unsigned int sizeFront = m_EventData->GetFirstStageMultXEnergy(); + for (UShort_t i = 0; i < sizeFront ; ++i) { + if (m_EventData->GetFirstStage_XE_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetFirstStage_XE_Energy(i); + //Double_t Energy = Cal->ApplyCalibration("PISTA/ENERGY"+NPL::itoa(m_EventData->GetFirstStage_XE_DetectorNbr(i)),m_EventData->GetFirstStage_XE_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetFirstStageXE(m_EventData->GetFirstStage_XE_DetectorNbr(i), m_EventData->GetFirstStage_XE_StripNbr(i), Energy); + } + } + } + unsigned int sizeBack = m_EventData->GetFirstStageMultXEnergy(); + for (UShort_t i = 0; i < sizeBack ; ++i) { + if (m_EventData->GetFirstStage_YE_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetFirstStage_YE_Energy(i); + //Double_t Energy = Cal->ApplyCalibration("PISTA/ENERGY"+NPL::itoa(m_EventData->GetFirstStage_YE_DetectorNbr(i)),m_EventData->GetFirstStage_YE_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetFirstStageYE(m_EventData->GetFirstStage_YE_DetectorNbr(i), m_EventData->GetFirstStage_YE_StripNbr(i), Energy); + } + } + } + // First Stage Time + unsigned int mysize = m_EventData->GetFirstStageMultXTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time= Cal->ApplyCalibration("PISTA/TIME"+NPL::itoa(m_EventData->GetFirstStage_XT_DetectorNbr(i)),m_EventData->GetFirstStage_XT_Time(i)); + m_PreTreatedData->SetFirstStageXT(m_EventData->GetFirstStage_XT_DetectorNbr(i), m_EventData->GetFirstStage_XT_StripNbr(i), Time); + } + + ////// + // Second Stage Energy + sizeFront = m_EventData->GetSecondStageMultXEnergy(); + for (UShort_t i = 0; i < sizeFront ; ++i) { + if (m_EventData->GetSecondStage_XE_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetSecondStage_XE_Energy(i); + //Double_t Energy = Cal->ApplyCalibration("PISTA/ENERGY"+NPL::itoa(m_EventData->GetSecondStage_XE_DetectorNbr(i)),m_EventData->GetSecondStage_XE_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetSecondStageXE(m_EventData->GetSecondStage_XE_DetectorNbr(i), m_EventData->GetSecondStage_XE_StripNbr(i), Energy); + } + } + } + sizeBack = m_EventData->GetSecondStageMultXEnergy(); + for (UShort_t i = 0; i < sizeBack ; ++i) { + if (m_EventData->GetSecondStage_YE_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetSecondStage_YE_Energy(i); + //Double_t Energy = Cal->ApplyCalibration("PISTA/ENERGY"+NPL::itoa(m_EventData->GetSecondStage_YE_DetectorNbr(i)),m_EventData->GetSecondStage_YE_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetSecondStageYE(m_EventData->GetSecondStage_YE_DetectorNbr(i), m_EventData->GetSecondStage_YE_StripNbr(i), Energy); + } + } + } + +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigPISTA.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigPISTA.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigPISTA.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigPISTA.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigPISTA"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + } + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::Clear() { + EventMultiplicity = 0; + + // Position Information + PosX.clear(); + PosY.clear(); + PosZ.clear(); + + // DSSD + DetectorNumber.clear(); + E.clear(); + StripX.clear(); + StripY.clear(); + Time.clear(); + DE.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("PISTA"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS"}; + vector<string> sphe = {"R","Theta","Phi"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// PISTA " << i+1 << endl; + + TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); + + AddDetector(Pos); + } + else if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// PISTA " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + + AddDetector(R, Theta, Phi); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::InitSpectra() { + m_Spectra = new TPISTASpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TPISTAPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("PISTA", "D"+ NPL::itoa(i+1)+"_ENERGY","PISTA_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("PISTA", "D"+ NPL::itoa(i+1)+"_TIME","PISTA_D"+ NPL::itoa(i+1)+"_TIME"); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("PISTA", true ); + inputChain->SetBranchAddress("PISTA", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("PISTA", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TPISTAPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("PISTA", "TPISTAPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TPISTAPhysics::Construct() { + return (NPL::VDetector*) new TPISTAPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ + class proxy_PISTA{ + public: + proxy_PISTA(){ + NPL::DetectorFactory::getInstance()->AddToken("PISTA","PISTA"); + NPL::DetectorFactory::getInstance()->AddDetector("PISTA",TPISTAPhysics::Construct); + } + }; + + proxy_PISTA p_PISTA; +} + diff --git a/NPLib/Detectors/PISTA/TPISTAPhysics.h b/NPLib/Detectors/PISTA/TPISTAPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..e2c2071a49957200e2c02753f067c4b08ebbbe11 --- /dev/null +++ b/NPLib/Detectors/PISTA/TPISTAPhysics.h @@ -0,0 +1,216 @@ +#ifndef TPISTAPHYSICS_H +#define TPISTAPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold PISTA Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> +#include <map> +#include <string> +using namespace std; + +// ROOT headers +#include "TObject.h" +#include "TH1.h" +#include "TVector3.h" +// NPTool headers +#include "TPISTAData.h" +#include "TPISTASpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TPISTASpectra; + + + +class TPISTAPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TPISTAPhysics(); + ~TPISTAPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: + vector<TVector2> Match_X_Y(); + int CheckEvent(); + + ////////////////////////////////////////////////////////////// + // data obtained after BuildPhysicalEvent() and stored in + // output ROOT file + public: + Int_t EventMultiplicity; + vector<int> DetectorNumber; + vector<double> E; + vector<double> DE; + vector<int> StripX; + vector<int> StripY; + vector<double> Time; + + vector<double> PosX; + vector<double> PosY; + vector<double> PosZ; + + + ////////////////////////////////////////////////////////////// + // methods inherited from the VDetector ABC class + public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); + + /// A usefull method to bundle all operation to add a detector + void AddDetector(TVector3 POS); + void AddDetector(double R, double Theta, double Phi); + + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // method called event by event, aiming at extracting the + // physical information from detector + void BuildPhysicalEvent(); + + // same as BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); + + // same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // activate raw data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // activate physics data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputPhysics(); + + // create branches of output ROOT file + void InitializeRootOutput(); + + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // methods related to the TPISTASpectra class + // instantiate the TPISTASpectra class and + // declare list of histograms + void InitSpectra(); + + // fill the spectra + void FillSpectra(); + + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); + + // used for Online only, clear all the spectra + void ClearSpectra(); + + // write spectra to ROOT output file + void WriteSpectra(); + + + ////////////////////////////////////////////////////////////// + // specific methods to PISTA array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TPISTAData object to TPISTAPhysics. + // needed for online analysis for example + void SetRawDataPointer(TPISTAData* rawDataPointer) {m_EventData = rawDataPointer;} + + double GetNumberOfTelescope() const {return m_NumberOfDetectors;} + int GetEventMultiplicity() const {return EventMultiplicity;} + + double GetStripPositionX(const int N, const int X, const int Y){ + return m_StripPositionX[N-1][X-1][Y-1]; + }; + double GetStripPositionY(const int N, const int X, const int Y){ + return m_StripPositionY[N-1][X-1][Y-1]; + }; + double GetStripPositionZ(const int N, const int X, const int Y){ + return m_StripPositionZ[N-1][X-1][Y-1]; + }; + + + TVector3 GetPositionOfInteraction(const int i); + TVector3 GetDetectorNormal(const int i); + + // objects are not written in the TTree + private: + TPISTAData* m_EventData; //! + TPISTAData* m_PreTreatedData; //! + TPISTAPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TPISTAData* GetRawData() const {return m_EventData;} + TPISTAData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + int m_NumberOfDetectors; //! + + vector<vector<vector<double>>> m_StripPositionX; //! + vector<vector<vector<double>>> m_StripPositionY; //! + vector<vector<vector<double>>> m_StripPositionZ; //! + + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + private: + unsigned int m_MaximumStripMultiplicityAllowed;// + double m_StripEnergyMatching;// + + + // spectra class + private: + TPISTASpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TPISTAPhysics,1) // PISTAPhysics structure +}; +#endif diff --git a/NPLib/Detectors/PISTA/TPISTASpectra.cxx b/NPLib/Detectors/PISTA/TPISTASpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c40fe4d4fe86b5f494c4255f199987b878c8e0e1 --- /dev/null +++ b/NPLib/Detectors/PISTA/TPISTASpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold PISTA Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TPISTASpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TPISTASpectra::TPISTASpectra() + : fNumberOfDetectors(0) { + SetName("PISTA"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TPISTASpectra::TPISTASpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TPISTASpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("PISTA"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TPISTASpectra::~TPISTASpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TPISTASpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "PISTA"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "PISTA/RAW"); + // Time + name = "PISTA"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "PISTA/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TPISTASpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "PISTA"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "PISTA/CAL"); + // Time + name = "PISTA"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "PISTA/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TPISTASpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "PISTA_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "PISTA/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TPISTASpectra::FillRawSpectra(TPISTAData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetFirstStageMultXEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "PISTA"+NPL::itoa(RawData->GetFirstStage_XE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "PISTA/RAW"; + + FillSpectra(family,name,RawData->GetFirstStage_XE_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetFirstStageMultXTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "PISTA"+NPL::itoa(RawData->GetFirstStage_XT_DetectorNbr(i))+"_TIME_RAW"; + family = "PISTA/RAW"; + + FillSpectra(family,name,RawData->GetFirstStage_XT_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TPISTASpectra::FillPreTreatedSpectra(TPISTAData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetFirstStageMultXEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "PISTA"+NPL::itoa(PreTreatedData->GetFirstStage_XE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "PISTA/CAL"; + + FillSpectra(family,name,PreTreatedData->GetFirstStage_XE_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetFirstStageMultXTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "PISTA"+NPL::itoa(PreTreatedData->GetFirstStage_XT_DetectorNbr(i))+"_TIME_CAL"; + family = "PISTA/CAL"; + + FillSpectra(family,name,PreTreatedData->GetFirstStage_XT_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TPISTASpectra::FillPhysicsSpectra(TPISTAPhysics* Physics) { + static string name; + static string family; + family= "PISTA/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->E.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "PISTA_ENERGY_TIME"; + FillSpectra(family,name,Physics->E[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/PISTA/TPISTASpectra.h b/NPLib/Detectors/PISTA/TPISTASpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..97239755cd2efb3e9216c0caab255aed89d004ad --- /dev/null +++ b/NPLib/Detectors/PISTA/TPISTASpectra.h @@ -0,0 +1,62 @@ +#ifndef TPISTASPECTRA_H +#define TPISTASPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold PISTA Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TPISTAData.h" +#include "TPISTAPhysics.h" + +// Forward Declaration +class TPISTAPhysics; + + +class TPISTASpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TPISTASpectra(); + TPISTASpectra(unsigned int NumberOfDetectors); + ~TPISTASpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TPISTAData*); + void FillPreTreatedSpectra(TPISTAData*); + void FillPhysicsSpectra(TPISTAPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPLib/Detectors/Paris/CMakeLists.txt b/NPLib/Detectors/Paris/CMakeLists.txt index 8f7a01bccde5b3ab4623bf4d0f6667d29099f9af..edba1d0326e8e0778edb1bafdf05bf5104e0e321 100644 --- a/NPLib/Detectors/Paris/CMakeLists.txt +++ b/NPLib/Detectors/Paris/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TParisPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TParisPhysics.h TParisPhysicsDict.cxx TParisPhysics.rootmap libNPParis.dylib DEPENDS TParisPhysics.h) -add_custom_command(OUTPUT TParisDataDict.cxx COMMAND ../../scripts/build_dict.sh TParisData.h TParisDataDict.cxx TParisData.rootmap libNPParis.dylib DEPENDS TParisData.h) +add_custom_command(OUTPUT TParisPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TParisPhysics.h TParisPhysicsDict.cxx TParisPhysics.rootmap libNPParis.dylib DEPENDS TParisPhysics.h) +add_custom_command(OUTPUT TParisDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TParisData.h TParisDataDict.cxx TParisData.rootmap libNPParis.dylib DEPENDS TParisData.h) add_library(NPParis SHARED TParisData.cxx TParisPhysics.cxx TParisDataDict.cxx TParisPhysicsDict.cxx ) target_link_libraries(NPParis ${ROOT_LIBRARIES} NPCore) install(FILES TParisData.h TParisPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Plastic/CMakeLists.txt b/NPLib/Detectors/Plastic/CMakeLists.txt index c56c6e794e6c9dec6f7b3208ddc041f6cf9ddce8..3ac6906763cf279ffd37def35c0f9ed07539af6e 100644 --- a/NPLib/Detectors/Plastic/CMakeLists.txt +++ b/NPLib/Detectors/Plastic/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TPlasticPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TPlasticPhysics.h TPlasticPhysicsDict.cxx TPlasticPhysics.rootmap libNPPlastic.dylib DEPENDS TPlasticPhysics.h) -add_custom_command(OUTPUT TPlasticDataDict.cxx COMMAND ../../scripts/build_dict.sh TPlasticData.h TPlasticDataDict.cxx TPlasticData.rootmap libNPPlastic.dylib DEPENDS TPlasticData.h) +add_custom_command(OUTPUT TPlasticPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TPlasticPhysics.h TPlasticPhysicsDict.cxx TPlasticPhysics.rootmap libNPPlastic.dylib DEPENDS TPlasticPhysics.h) +add_custom_command(OUTPUT TPlasticDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TPlasticData.h TPlasticDataDict.cxx TPlasticData.rootmap libNPPlastic.dylib DEPENDS TPlasticData.h) add_library(NPPlastic SHARED TPlasticData.cxx TPlasticPhysics.cxx TPlasticDataDict.cxx TPlasticPhysicsDict.cxx ) target_link_libraries(NPPlastic ${ROOT_LIBRARIES} NPCore) install(FILES TPlasticData.h TPlasticPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Pyramid/CMakeLists.txt b/NPLib/Detectors/Pyramid/CMakeLists.txt index f41ebaf9bb2050406d9d1b853300de1390a70309..6d6bd0ccd87ed0412f94d81cd3784a9c9b329201 100644 --- a/NPLib/Detectors/Pyramid/CMakeLists.txt +++ b/NPLib/Detectors/Pyramid/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TPyramidPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TPyramidPhysics.h TPyramidPhysicsDict.cxx TPyramidPhysics.rootmap libNPPyramid.dylib DEPENDS TPyramidPhysics.h) -add_custom_command(OUTPUT TPyramidDataDict.cxx COMMAND ../../scripts/build_dict.sh TPyramidData.h TPyramidDataDict.cxx TPyramidData.rootmap libNPPyramid.dylib DEPENDS TPyramidData.h) +add_custom_command(OUTPUT TPyramidPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TPyramidPhysics.h TPyramidPhysicsDict.cxx TPyramidPhysics.rootmap libNPPyramid.dylib DEPENDS TPyramidPhysics.h) +add_custom_command(OUTPUT TPyramidDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TPyramidData.h TPyramidDataDict.cxx TPyramidData.rootmap libNPPyramid.dylib DEPENDS TPyramidData.h) add_library(NPPyramid SHARED TPyramidSpectra.cxx TPyramidData.cxx TPyramidPhysics.cxx TPyramidDataDict.cxx TPyramidPhysicsDict.cxx ) target_link_libraries(NPPyramid ${ROOT_LIBRARIES} NPCore) install(FILES TPyramidData.h TPyramidPhysics.h TPyramidSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/QQQ/CMakeLists.txt b/NPLib/Detectors/QQQ/CMakeLists.txt index eee539be9f1ba351367dcf978868b196af005573..668ef33aa2c147901f3a9a3180ede80ad47a952d 100644 --- a/NPLib/Detectors/QQQ/CMakeLists.txt +++ b/NPLib/Detectors/QQQ/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TQQQPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TQQQPhysics.h TQQQPhysicsDict.cxx TQQQPhysics.rootmap libNPQQQ.dylib DEPENDS TQQQPhysics.h) -add_custom_command(OUTPUT TQQQDataDict.cxx COMMAND ../../scripts/build_dict.sh TQQQData.h TQQQDataDict.cxx TQQQData.rootmap libNPQQQ.dylib DEPENDS TQQQData.h) +add_custom_command(OUTPUT TQQQPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TQQQPhysics.h TQQQPhysicsDict.cxx TQQQPhysics.rootmap libNPQQQ.dylib DEPENDS TQQQPhysics.h) +add_custom_command(OUTPUT TQQQDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TQQQData.h TQQQDataDict.cxx TQQQData.rootmap libNPQQQ.dylib DEPENDS TQQQData.h) add_library(NPQQQ SHARED TQQQData.cxx TQQQPhysics.cxx TQQQDataDict.cxx TQQQPhysicsDict.cxx ) target_link_libraries(NPQQQ ${ROOT_LIBRARIES} NPCore) install(FILES TQQQData.h TQQQPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Riken/CMakeLists.txt b/NPLib/Detectors/Riken/CMakeLists.txt index 7fec7b86eb0a5384f006e50201820b14aa56ef08..62411f26fa16b41bbacb3b4cde343f93d387cfdf 100644 --- a/NPLib/Detectors/Riken/CMakeLists.txt +++ b/NPLib/Detectors/Riken/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_command(OUTPUT TRIPSDataDict.cxx COMMAND ../../scripts/build_dict.sh TRIPSData.h TRIPSDataDict.cxx TRIPSData.rootmap libNPRiken.dylib DEPENDS TRIPSData.h) +add_custom_command(OUTPUT TRIPSDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TRIPSData.h TRIPSDataDict.cxx TRIPSData.rootmap libNPRiken.dylib DEPENDS TRIPSData.h) add_library(NPRiken SHARED TRIPSData.cxx TRIPSDataDict.cxx ) target_link_libraries(NPRiken ${ROOT_LIBRARIES} NPCore) install(FILES TRIPSData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/SPEG/CMakeLists.txt b/NPLib/Detectors/SPEG/CMakeLists.txt index c33358ba6ee2f339714c426806f617e20d14a150..232221535927aa7f4d985bf9ca61e1a777e8e4bf 100644 --- a/NPLib/Detectors/SPEG/CMakeLists.txt +++ b/NPLib/Detectors/SPEG/CMakeLists.txt @@ -1,7 +1,7 @@ -add_custom_command(OUTPUT TSpegPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TSpegPhysics.h TSpegPhysicsDict.cxx TSpegPhysics.rootmap libNPSPEG.dylib DEPENDS TSpegPhysics.h) -add_custom_command(OUTPUT TSpegPlasticDataDict.cxx COMMAND ../../scripts/build_dict.sh TSpegPlasticData.h TSpegPlasticDataDict.cxx TSpegPlasticData.rootmap libNPSPEG.dylib DEPENDS TSpegPlasticData.h) -add_custom_command(OUTPUT TSpegDCDataDict.cxx COMMAND ../../scripts/build_dict.sh TSpegDCData.h TSpegDCDataDict.cxx TSpegDCData.rootmap libNPSPEG.dylib DEPENDS TSpegDCData.h) -add_custom_command(OUTPUT TSpegCHIODataDict.cxx COMMAND ../../scripts/build_dict.sh TSpegCHIOData.h TSpegCHIODataDict.cxx TSpegCHIOData.rootmap libNPSPEG.dylib DEPENDS TSpegCHIOData.h) +add_custom_command(OUTPUT TSpegPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSpegPhysics.h TSpegPhysicsDict.cxx TSpegPhysics.rootmap libNPSPEG.dylib DEPENDS TSpegPhysics.h) +add_custom_command(OUTPUT TSpegPlasticDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSpegPlasticData.h TSpegPlasticDataDict.cxx TSpegPlasticData.rootmap libNPSPEG.dylib DEPENDS TSpegPlasticData.h) +add_custom_command(OUTPUT TSpegDCDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSpegDCData.h TSpegDCDataDict.cxx TSpegDCData.rootmap libNPSPEG.dylib DEPENDS TSpegDCData.h) +add_custom_command(OUTPUT TSpegCHIODataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSpegCHIOData.h TSpegCHIODataDict.cxx TSpegCHIOData.rootmap libNPSPEG.dylib DEPENDS TSpegCHIOData.h) add_library(NPSPEG SHARED TSpegCHIOData.cxx TSpegDCData.cxx TSpegPlasticData.cxx TSpegPhysics.cxx TSpegCHIODataDict.cxx TSpegDCDataDict.cxx TSpegPlasticDataDict.cxx TSpegPhysicsDict.cxx ) target_link_libraries(NPSPEG ${ROOT_LIBRARIES} NPCore) install(FILES TSpegCHIOData.h TSpegDCData.h TSpegPlasticData.h TSpegPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/SSSD/CMakeLists.txt b/NPLib/Detectors/SSSD/CMakeLists.txt index 01dc9fa2a624166938170904345e856020049315..999b2d20a240b525aebd7b5dbd258f3b92f00ed3 100644 --- a/NPLib/Detectors/SSSD/CMakeLists.txt +++ b/NPLib/Detectors/SSSD/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TSSSDPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TSSSDPhysics.h TSSSDPhysicsDict.cxx TSSSDPhysics.rootmap libNPSSSD.dylib DEPENDS TSSSDPhysics.h) -add_custom_command(OUTPUT TSSSDDataDict.cxx COMMAND ../../scripts/build_dict.sh TSSSDData.h TSSSDDataDict.cxx TSSSDData.rootmap libNPSSSD.dylib DEPENDS TSSSDData.h) +add_custom_command(OUTPUT TSSSDPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSSSDPhysics.h TSSSDPhysicsDict.cxx TSSSDPhysics.rootmap libNPSSSD.dylib DEPENDS TSSSDPhysics.h) +add_custom_command(OUTPUT TSSSDDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSSSDData.h TSSSDDataDict.cxx TSSSDData.rootmap libNPSSSD.dylib DEPENDS TSSSDData.h) add_library(NPSSSD SHARED TSSSDData.cxx TSSSDPhysics.cxx TSSSDDataDict.cxx TSSSDPhysicsDict.cxx ) target_link_libraries(NPSSSD ${ROOT_LIBRARIES} NPCore) install(FILES TSSSDData.h TSSSDPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Scone/CMakeLists.txt b/NPLib/Detectors/Scone/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2d5e14a2e3a1e23b9b9945bb48477fca465cb4c0 --- /dev/null +++ b/NPLib/Detectors/Scone/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TSconePhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSconePhysics.h TSconePhysicsDict.cxx TSconePhysics.rootmap libNPScone.dylib DEPENDS TSconePhysics.h) +add_custom_command(OUTPUT TSconeDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSconeData.h TSconeDataDict.cxx TSconeData.rootmap libNPScone.dylib DEPENDS TSconeData.h) +add_library(NPScone SHARED TSconeSpectra.cxx TSconeData.cxx TSconePhysics.cxx TSconeDataDict.cxx TSconePhysicsDict.cxx ) +target_link_libraries(NPScone ${ROOT_LIBRARIES} NPCore) +install(FILES TSconeData.h TSconePhysics.h TSconeSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/Scone/TSconeData.cxx b/NPLib/Detectors/Scone/TSconeData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..08c25870dfafd1321a63ebc58af69fb700abc4cf --- /dev/null +++ b/NPLib/Detectors/Scone/TSconeData.cxx @@ -0,0 +1,81 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Scone Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TSconeData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TSconeData) + + +////////////////////////////////////////////////////////////////////// +TSconeData::TSconeData() { +} + + + +////////////////////////////////////////////////////////////////////// +TSconeData::~TSconeData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TSconeData::Clear() { + // Energy + fScone_E_DetectorNbr.clear(); + fScone_E_PlasticNbr.clear(); + fScone_Energy.clear(); + // Time + fScone_T_DetectorNbr.clear(); + fScone_T_PlasticNbr.clear(); + fScone_Time.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TSconeData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TSconeData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fScone_E_DetectorNbr.size(); + cout << "Scone_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fScone_E_DetectorNbr[i] + << " Energy: " << fScone_Energy[i]; + } + + // Time + mysize = fScone_T_DetectorNbr.size(); + cout << "Scone_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fScone_T_DetectorNbr[i] + << " Time: " << fScone_Time[i]; + } +} diff --git a/NPLib/Detectors/Scone/TSconeData.h b/NPLib/Detectors/Scone/TSconeData.h new file mode 100644 index 0000000000000000000000000000000000000000..a920bd7d442de3621ef58f3032037a109c545cda --- /dev/null +++ b/NPLib/Detectors/Scone/TSconeData.h @@ -0,0 +1,112 @@ +#ifndef __SconeDATA__ +#define __SconeDATA__ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Scone Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TSconeData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // Energy + vector<UShort_t> fScone_E_DetectorNbr; + vector<UShort_t> fScone_E_PlasticNbr; + vector<Double_t> fScone_Energy; + + // Time + vector<UShort_t> fScone_T_DetectorNbr; + vector<UShort_t> fScone_T_PlasticNbr; + vector<Double_t> fScone_Time; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TSconeData(); + ~TSconeData(); + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + ////////////////////////////////////////////////////////////// + // Getters and Setters + // Prefer inline declaration to avoid unnecessary called of + // frequently used methods + // add //! to avoid ROOT creating dictionnary for the methods + public: + ////////////////////// SETTERS //////////////////////// + // Energy + inline void SetEnergy(const UShort_t& DetNbr,const UShort_t& PlasticNbr, const Double_t& Energy){ + fScone_E_DetectorNbr.push_back(DetNbr); + fScone_E_PlasticNbr.push_back(PlasticNbr); + fScone_Energy.push_back(Energy); + };//! + + // Time + inline void SetTime(const UShort_t& DetNbr,const UShort_t& PlasticNbr, const Double_t& Time) { + fScone_T_DetectorNbr.push_back(DetNbr); + fScone_T_PlasticNbr.push_back(PlasticNbr); + fScone_Time.push_back(Time); + };//! + + + ////////////////////// GETTERS //////////////////////// + // Energy + inline UShort_t GetMultEnergy() const + {return fScone_E_DetectorNbr.size();} + inline UShort_t GetE_DetectorNbr(const unsigned int &i) const + {return fScone_E_DetectorNbr[i];}//! + inline UShort_t GetE_PlasticNbr(const unsigned int &i) const + {return fScone_E_PlasticNbr[i];}//! + inline Double_t Get_Energy(const unsigned int &i) const + {return fScone_Energy[i];}//! + + // Time + inline UShort_t GetMultTime() const + {return fScone_T_DetectorNbr.size();} + inline UShort_t GetT_DetectorNbr(const unsigned int &i) const + {return fScone_T_DetectorNbr[i];}//! + inline UShort_t GetT_PlasticNbr(const unsigned int &i) const + {return fScone_T_PlasticNbr[i];}//! + inline Double_t Get_Time(const unsigned int &i) const + {return fScone_Time[i];}//! + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TSconeData,1) // SconeData structure +}; + +#endif diff --git a/NPLib/Detectors/Scone/TSconePhysics.cxx b/NPLib/Detectors/Scone/TSconePhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..54031fe4c5e4cb5c4729a0b0e274b8de92f9d6dd --- /dev/null +++ b/NPLib/Detectors/Scone/TSconePhysics.cxx @@ -0,0 +1,354 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Scone Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TSconePhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" + +// ROOT +#include "TChain.h" + +ClassImp(TSconePhysics) + + +/////////////////////////////////////////////////////////////////////////// +TSconePhysics::TSconePhysics() + : m_EventData(new TSconeData), + m_PreTreatedData(new TSconeData), + m_EventPhysics(this), + m_Spectra(0), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + m_NumberOfDetectors(0) { +} + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +void TSconePhysics::AddDetector(TVector3 ){ + // In That simple case nothing is done + // Typically for more complex detector one would calculate the relevant + // positions (stripped silicon) or angles (gamma array) + m_NumberOfDetectors++; +} + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::BuildPhysicalEvent() { + // apply thresholds and calibration + PreTreat(); + + double Energy_det[40]; + double Time_det[40]; + int iTime[40]; + + for(int i=0; i<40; i++){ + Energy_det[i] = 0; + Time_det[i] = 0; + iTime[i] = 0; + } + // match energy and time together + unsigned int mysizeE = m_PreTreatedData->GetMultEnergy(); + unsigned int mysizeT = m_PreTreatedData->GetMultTime(); + //for (UShort_t e = 0; e < mysizeE ; e++) { + if (mysizeE == mysizeT) { + for (UShort_t t = 0; t < mysizeT ; t++) { + if (m_PreTreatedData->GetE_DetectorNbr(t) == m_PreTreatedData->GetT_DetectorNbr(t)) { + int det = m_PreTreatedData->GetE_DetectorNbr(t); + Energy_det[det-1] += m_PreTreatedData->Get_Energy(t); + //cout << det << " " << Energy_det[det-1] << " " << m_PreTreatedData->GetE_PlasticNbr(t) << endl; + if(m_PreTreatedData->Get_Time(t)>Time_det[det-1]){ + Time_det[det-1] = m_PreTreatedData->Get_Time(t); + } + iTime[det-1]++; + //DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e)); + //Energy.push_back(m_PreTreatedData->Get_Energy(e)); + //Time.push_back(m_PreTreatedData->Get_Time(t)); + } + } + } + + for(int i=0; i<40; i++){ + //Time_det[i] = Time_det[i]/iTime[i]; + if(Energy_det[i]>m_E_Threshold && Time_det[i]>0){ + DetectorNumber.push_back(i+1); + Energy.push_back(Energy_det[i]); + Time.push_back(Time_det[i]); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::PreTreat() { + // This method typically applies thresholds and calibrations + // Might test for disabled channels for more complex detector + + // clear pre-treated object + ClearPreTreatedData(); + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + + // Energy + unsigned int mysize = m_EventData->GetMultEnergy(); + for (UShort_t i = 0; i < mysize ; ++i) { + if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = Cal->ApplyCalibration("Scone/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), m_EventData->GetE_PlasticNbr(i),Energy); + } + } + } + + // Time + mysize = m_EventData->GetMultTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time= Cal->ApplyCalibration("Scone/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), m_EventData->GetT_PlasticNbr(i), Time); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigScone.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigScone.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigScone.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigScone.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigScone"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + } + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::Clear() { + DetectorNumber.clear(); + Energy.clear(); + Time.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Scone"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS","Ring1","Ring2"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Scone " << i+1 << endl; + + TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); + m_BuildRing1 = blocks[i]->GetInt("Ring1"); + m_BuildRing2 = blocks[i]->GetInt("Ring2"); + AddDetector(Pos); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::InitSpectra() { + m_Spectra = new TSconeSpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TSconePhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("Scone", "D"+ NPL::itoa(i+1)+"_ENERGY","Scone_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("Scone", "D"+ NPL::itoa(i+1)+"_TIME","Scone_D"+ NPL::itoa(i+1)+"_TIME"); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("Scone", true ); + inputChain->SetBranchAddress("Scone", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("Scone", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TSconePhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("Scone", "TSconePhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TSconePhysics::Construct() { + return (NPL::VDetector*) new TSconePhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_Scone{ + public: + proxy_Scone(){ + NPL::DetectorFactory::getInstance()->AddToken("Scone","Scone"); + NPL::DetectorFactory::getInstance()->AddDetector("Scone",TSconePhysics::Construct); + } +}; + +proxy_Scone p_Scone; +} + diff --git a/NPLib/Detectors/Scone/TSconePhysics.h b/NPLib/Detectors/Scone/TSconePhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..a23d663fb8ea33dae6f9c92eb250ae1273d5b67a --- /dev/null +++ b/NPLib/Detectors/Scone/TSconePhysics.h @@ -0,0 +1,180 @@ +#ifndef TSconePHYSICS_H +#define TSconePHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Scone Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> +#include <map> +#include <string> +using namespace std; + +// ROOT headers +#include "TObject.h" +#include "TH1.h" +#include "TVector3.h" +// NPTool headers +#include "TSconeData.h" +#include "TSconeSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TSconeSpectra; + + + +class TSconePhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TSconePhysics(); + ~TSconePhysics() {}; + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + + + ////////////////////////////////////////////////////////////// + // data obtained after BuildPhysicalEvent() and stored in + // output ROOT file + public: + vector<int> DetectorNumber; + vector<double> Energy; + vector<double> Time; + + /// A usefull method to bundle all operation to add a detector + void AddDetector(TVector3 POS); + + ////////////////////////////////////////////////////////////// + // methods inherited from the VDetector ABC class + public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); + + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // method called event by event, aiming at extracting the + // physical information from detector + void BuildPhysicalEvent(); + + // same as BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); + + // same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // activate raw data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // activate physics data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputPhysics(); + + // create branches of output ROOT file + void InitializeRootOutput(); + + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // methods related to the TSconeSpectra class + // instantiate the TSconeSpectra class and + // declare list of histograms + void InitSpectra(); + + // fill the spectra + void FillSpectra(); + + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); + + // used for Online only, clear all the spectra + void ClearSpectra(); + + // write spectra to ROOT output file + void WriteSpectra(); + + + ////////////////////////////////////////////////////////////// + // specific methods to Scone array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TSconeData object to TSconePhysics. + // needed for online analysis for example + void SetRawDataPointer(TSconeData* rawDataPointer) {m_EventData = rawDataPointer;} + + // objects are not written in the TTree + private: + TSconeData* m_EventData; //! + TSconeData* m_PreTreatedData; //! + TSconePhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TSconeData* GetRawData() const {return m_EventData;} + TSconeData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + // number of detectors + private: + int m_NumberOfDetectors; //! + int m_BuildRing1; //! + int m_BuildRing2; //! + // spectra class + private: + TSconeSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TSconePhysics,1) // SconePhysics structure +}; +#endif diff --git a/NPLib/Detectors/Scone/TSconeSpectra.cxx b/NPLib/Detectors/Scone/TSconeSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0887b29e9cadaffdfa7326cd13cc22d97267b4bb --- /dev/null +++ b/NPLib/Detectors/Scone/TSconeSpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Scone Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TSconeSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TSconeSpectra::TSconeSpectra() + : fNumberOfDetectors(0) { + SetName("Scone"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TSconeSpectra::TSconeSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TSconeSpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("Scone"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TSconeSpectra::~TSconeSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TSconeSpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "Scone"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "Scone/RAW"); + // Time + name = "Scone"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "Scone/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TSconeSpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "Scone"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "Scone/CAL"); + // Time + name = "Scone"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "Scone/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TSconeSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "Scone_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "Scone/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TSconeSpectra::FillRawSpectra(TSconeData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "Scone"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "Scone/RAW"; + + FillSpectra(family,name,RawData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "Scone"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; + family = "Scone/RAW"; + + FillSpectra(family,name,RawData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TSconeSpectra::FillPreTreatedSpectra(TSconeData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "Scone"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "Scone/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "Scone"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; + family = "Scone/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TSconeSpectra::FillPhysicsSpectra(TSconePhysics* Physics) { + static string name; + static string family; + family= "Scone/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->Energy.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "Scone_ENERGY_TIME"; + FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/Scone/TSconeSpectra.h b/NPLib/Detectors/Scone/TSconeSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..15ee3fd5159c08012367af1189d9b8299c015460 --- /dev/null +++ b/NPLib/Detectors/Scone/TSconeSpectra.h @@ -0,0 +1,62 @@ +#ifndef TSconeSPECTRA_H +#define TSconeSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Scone Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TSconeData.h" +#include "TSconePhysics.h" + +// Forward Declaration +class TSconePhysics; + + +class TSconeSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TSconeSpectra(); + TSconeSpectra(unsigned int NumberOfDetectors); + ~TSconeSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TSconeData*); + void FillPreTreatedSpectra(TSconeData*); + void FillPhysicsSpectra(TSconePhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPLib/Detectors/Sharc/CMakeLists.txt b/NPLib/Detectors/Sharc/CMakeLists.txt index 8804ce2de415db5ee47aa4530b1ad839de029ca1..dca1589ddc4f297cffd855b72f8ce03564683e93 100644 --- a/NPLib/Detectors/Sharc/CMakeLists.txt +++ b/NPLib/Detectors/Sharc/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TSharcPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TSharcPhysics.h TSharcPhysicsDict.cxx TSharcPhysics.rootmap libNPSharc.dylib DEPENDS TSharcPhysics.h) -add_custom_command(OUTPUT TSharcDataDict.cxx COMMAND ../../scripts/build_dict.sh TSharcData.h TSharcDataDict.cxx TSharcData.rootmap libNPSharc.dylib DEPENDS TSharcData.h) +add_custom_command(OUTPUT TSharcPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSharcPhysics.h TSharcPhysicsDict.cxx TSharcPhysics.rootmap libNPSharc.dylib DEPENDS TSharcPhysics.h) +add_custom_command(OUTPUT TSharcDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSharcData.h TSharcDataDict.cxx TSharcData.rootmap libNPSharc.dylib DEPENDS TSharcData.h) add_library(NPSharc SHARED TSharcSpectra.cxx TSharcData.cxx TSharcPhysics.cxx TSharcDataDict.cxx TSharcPhysicsDict.cxx ) target_link_libraries(NPSharc ${ROOT_LIBRARIES} NPCore) install(FILES TSharcData.h TSharcPhysics.h TSharcSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/SiLi/CMakeLists.txt b/NPLib/Detectors/SiLi/CMakeLists.txt index 8912eb28253a80c6e6e0215fbadb6e0e06d3d65b..3fe9b911e18231696e1918f7534ce0316d3ce6d7 100644 --- a/NPLib/Detectors/SiLi/CMakeLists.txt +++ b/NPLib/Detectors/SiLi/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TSiLiPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TSiLiPhysics.h TSiLiPhysicsDict.cxx TSiLiPhysics.rootmap libNPSiLi.dylib DEPENDS TSiLiPhysics.h) -add_custom_command(OUTPUT TSiLiDataDict.cxx COMMAND ../../scripts/build_dict.sh TSiLiData.h TSiLiDataDict.cxx TSiLiData.rootmap libNPSiLi.dylib DEPENDS TSiLiData.h) +add_custom_command(OUTPUT TSiLiPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSiLiPhysics.h TSiLiPhysicsDict.cxx TSiLiPhysics.rootmap libNPSiLi.dylib DEPENDS TSiLiPhysics.h) +add_custom_command(OUTPUT TSiLiDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSiLiData.h TSiLiDataDict.cxx TSiLiData.rootmap libNPSiLi.dylib DEPENDS TSiLiData.h) add_library(NPSiLi SHARED TSiLiData.cxx TSiLiPhysics.cxx TSiLiDataDict.cxx TSiLiPhysicsDict.cxx TSiLiSpectra.cxx) target_link_libraries(NPSiLi ${ROOT_LIBRARIES} NPCore) install(FILES TSiLiData.h TSiLiPhysics.h TSiLiSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/SiRes/CMakeLists.txt b/NPLib/Detectors/SiRes/CMakeLists.txt index dcd1104d3c4affd47fa422f753f97d0a87dc040e..8318c4571fe4ee0ea0ee8a8638bfc76eb72d5e2e 100644 --- a/NPLib/Detectors/SiRes/CMakeLists.txt +++ b/NPLib/Detectors/SiRes/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TSiResPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TSiResPhysics.h TSiResPhysicsDict.cxx TSiResPhysics.rootmap libNPSiRes.dylib DEPENDS TSiResPhysics.h) -add_custom_command(OUTPUT TSiResDataDict.cxx COMMAND ../../scripts/build_dict.sh TSiResData.h TSiResDataDict.cxx TSiResData.rootmap libNPSiRes.dylib DEPENDS TSiResData.h) +add_custom_command(OUTPUT TSiResPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSiResPhysics.h TSiResPhysicsDict.cxx TSiResPhysics.rootmap libNPSiRes.dylib DEPENDS TSiResPhysics.h) +add_custom_command(OUTPUT TSiResDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSiResData.h TSiResDataDict.cxx TSiResData.rootmap libNPSiRes.dylib DEPENDS TSiResData.h) add_library(NPSiRes SHARED TSiResData.cxx TSiResPhysics.cxx TSiResDataDict.cxx TSiResPhysicsDict.cxx TSiResSpectra.cxx) target_link_libraries(NPSiRes ${ROOT_LIBRARIES} NPCore) install(FILES TSiResData.h TSiResPhysics.h TSiResSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/SplitPole/CMakeLists.txt b/NPLib/Detectors/SplitPole/CMakeLists.txt index 387cae3b4930251d915f250e0e50902c6ea07756..2c25ca36681adbf33559cbe3c535d68f8bfd7b60 100644 --- a/NPLib/Detectors/SplitPole/CMakeLists.txt +++ b/NPLib/Detectors/SplitPole/CMakeLists.txt @@ -1,6 +1,6 @@ -add_custom_command(OUTPUT TSplitPolePhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TSplitPolePhysics.h TSplitPolePhysicsDict.cxx TSplitPolePhysics.rootmap libNPSplitPole.dylib DEPENDS TSplitPolePhysics.h) -add_custom_command(OUTPUT TSplitPoleDataDict.cxx COMMAND ../../scripts/build_dict.sh TSplitPoleData.h TSplitPoleDataDict.cxx TSplitPoleData.rootmap libNPSplitPole.dylib DEPENDS TSplitPoleData.h) -add_custom_command(OUTPUT TSplitPoleNMRDict.cxx COMMAND ../../scripts/build_dict.sh TSplitPoleNMR.h TSplitPoleNMRDict.cxx TSplitPoleNMR.rootmap libNPSplitPole.dylib DEPENDS TSplitPoleNMR.h) +add_custom_command(OUTPUT TSplitPolePhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSplitPolePhysics.h TSplitPolePhysicsDict.cxx TSplitPolePhysics.rootmap libNPSplitPole.dylib DEPENDS TSplitPolePhysics.h) +add_custom_command(OUTPUT TSplitPoleDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSplitPoleData.h TSplitPoleDataDict.cxx TSplitPoleData.rootmap libNPSplitPole.dylib DEPENDS TSplitPoleData.h) +add_custom_command(OUTPUT TSplitPoleNMRDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSplitPoleNMR.h TSplitPoleNMRDict.cxx TSplitPoleNMR.rootmap libNPSplitPole.dylib DEPENDS TSplitPoleNMR.h) add_library(NPSplitPole SHARED TSplitPoleSpectra.cxx TSplitPoleData.cxx TSplitPolePhysics.cxx TSplitPoleNMR.cxx TSplitPoleDataDict.cxx TSplitPolePhysicsDict.cxx TSplitPoleNMRDict.cxx) target_link_libraries(NPSplitPole ${ROOT_LIBRARIES} NPCore) install(FILES TSplitPoleData.h TSplitPolePhysics.h TSplitPoleSpectra.h TSplitPoleNMR.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/TACTIC/CMakeLists.txt b/NPLib/Detectors/TACTIC/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ee7f804d8716f08e376a270f837e2125bf392b2c --- /dev/null +++ b/NPLib/Detectors/TACTIC/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TTACTICPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTACTICPhysics.h TTACTICPhysicsDict.cxx TTACTICPhysics.rootmap libNPTACTIC.dylib DEPENDS TTACTICPhysics.h) +add_custom_command(OUTPUT TTACTICDataDict.cxx COMMAND ../../scripts/build_dict.sh TTACTICData.h TTACTICDataDict.cxx TTACTICData.rootmap libNPTACTIC.dylib DEPENDS TTACTICData.h) +add_library(NPTACTIC SHARED TTACTICSpectra.cxx TTACTICData.cxx TTACTICPhysics.cxx TTACTICDataDict.cxx TTACTICPhysicsDict.cxx ) +target_link_libraries(NPTACTIC ${ROOT_LIBRARIES} NPCore) +install(FILES TTACTICData.h TTACTICPhysics.h TTACTICSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/TACTIC/TTACTICData.cxx b/NPLib/Detectors/TACTIC/TTACTICData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..11b67cc87c443714e88294df2ff341322db0321f --- /dev/null +++ b/NPLib/Detectors/TACTIC/TTACTICData.cxx @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: warren.lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TACTIC Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TTACTICData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TTACTICData) + + +////////////////////////////////////////////////////////////////////// +TTACTICData::TTACTICData() { +} + + + +////////////////////////////////////////////////////////////////////// +TTACTICData::~TTACTICData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TTACTICData::Clear() { + // Energy + fTACTIC_E_DetectorNbr.clear(); + fTACTIC_Energy.clear(); + // Time + fTACTIC_T_DetectorNbr.clear(); + fTACTIC_Time.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TTACTICData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TTACTICData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fTACTIC_E_DetectorNbr.size(); + cout << "TACTIC_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fTACTIC_E_DetectorNbr[i] + << " Energy: " << fTACTIC_Energy[i]; + } + + // Time + mysize = fTACTIC_T_DetectorNbr.size(); + cout << "TACTIC_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fTACTIC_T_DetectorNbr[i] + << " Time: " << fTACTIC_Time[i]; + } +} diff --git a/NPLib/Detectors/TACTIC/TTACTICData.h b/NPLib/Detectors/TACTIC/TTACTICData.h new file mode 100644 index 0000000000000000000000000000000000000000..65e6388e243ecfc97fed2b2d46a0f055a48b9f06 --- /dev/null +++ b/NPLib/Detectors/TACTIC/TTACTICData.h @@ -0,0 +1,104 @@ +#ifndef __TACTICDATA__ +#define __TACTICDATA__ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: warren.lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TACTIC Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TTACTICData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // Energy + vector<UShort_t> fTACTIC_E_DetectorNbr; + vector<Double_t> fTACTIC_Energy; + + // Time + vector<UShort_t> fTACTIC_T_DetectorNbr; + vector<Double_t> fTACTIC_Time; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TTACTICData(); + ~TTACTICData(); + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + ////////////////////////////////////////////////////////////// + // Getters and Setters + // Prefer inline declaration to avoid unnecessary called of + // frequently used methods + // add //! to avoid ROOT creating dictionnary for the methods + public: + ////////////////////// SETTERS //////////////////////// + // Energy + inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){ + fTACTIC_E_DetectorNbr.push_back(DetNbr); + fTACTIC_Energy.push_back(Energy); + };//! + + // Time + inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) { + fTACTIC_T_DetectorNbr.push_back(DetNbr); + fTACTIC_Time.push_back(Time); + };//! + + + ////////////////////// GETTERS //////////////////////// + // Energy + inline UShort_t GetMultEnergy() const + {return fTACTIC_E_DetectorNbr.size();} + inline UShort_t GetE_DetectorNbr(const unsigned int &i) const + {return fTACTIC_E_DetectorNbr[i];}//! + inline Double_t Get_Energy(const unsigned int &i) const + {return fTACTIC_Energy[i];}//! + + // Time + inline UShort_t GetMultTime() const + {return fTACTIC_T_DetectorNbr.size();} + inline UShort_t GetT_DetectorNbr(const unsigned int &i) const + {return fTACTIC_T_DetectorNbr[i];}//! + inline Double_t Get_Time(const unsigned int &i) const + {return fTACTIC_Time[i];}//! + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TTACTICData,1) // TACTICData structure +}; + +#endif diff --git a/NPLib/Detectors/TACTIC/TTACTICPhysics.cxx b/NPLib/Detectors/TACTIC/TTACTICPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..033b2ba08478945695f133e2a1197ac02cbdde43 --- /dev/null +++ b/NPLib/Detectors/TACTIC/TTACTICPhysics.cxx @@ -0,0 +1,344 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: warren.lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TACTIC Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TTACTICPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" + +// ROOT +#include "TChain.h" + +ClassImp(TTACTICPhysics) + + +/////////////////////////////////////////////////////////////////////////// +TTACTICPhysics::TTACTICPhysics() + : m_EventData(new TTACTICData), + m_PreTreatedData(new TTACTICData), + m_EventPhysics(this), + m_Spectra(0), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + m_NumberOfDetectors(0) { +} + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +void TTACTICPhysics::AddDetector(TVector3 , string ){ + // In That simple case nothing is done + // Typically for more complex detector one would calculate the relevant + // positions (stripped silicon) or angles (gamma array) + m_NumberOfDetectors++; +} + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::AddDetector(double R, double Theta, double Phi, string shape){ + // Compute the TVector3 corresponding + TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); + // Call the cartesian method + AddDetector(Pos,shape); +} + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::BuildPhysicalEvent() { + // apply thresholds and calibration + PreTreat(); + + // match energy and time together + unsigned int mysizeE = m_PreTreatedData->GetMultEnergy(); + unsigned int mysizeT = m_PreTreatedData->GetMultTime(); + for (UShort_t e = 0; e < mysizeE ; e++) { + for (UShort_t t = 0; t < mysizeT ; t++) { + if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) { + DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e)); + Energy.push_back(m_PreTreatedData->Get_Energy(e)); + Time.push_back(m_PreTreatedData->Get_Time(t)); + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::PreTreat() { + // This method typically applies thresholds and calibrations + // Might test for disabled channels for more complex detector + + // clear pre-treated object + ClearPreTreatedData(); + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + + // Energy + unsigned int mysize = m_EventData->GetMultEnergy(); + for (UShort_t i = 0; i < mysize ; ++i) { + if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = Cal->ApplyCalibration("TACTIC/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy); + } + } + } + + // Time + mysize = m_EventData->GetMultTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time= Cal->ApplyCalibration("TACTIC/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigTACTIC.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigTACTIC.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigTACTIC.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigTACTIC.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigTACTIC"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + } + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::Clear() { + DetectorNumber.clear(); + Energy.clear(); + Time.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("TACTIC"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS","Shape"}; + vector<string> sphe = {"R","Theta","Phi","Shape"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TACTIC " << i+1 << endl; + + TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); + string Shape = blocks[i]->GetString("Shape"); + AddDetector(Pos,Shape); + } + else if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TACTIC " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + string Shape = blocks[i]->GetString("Shape"); + AddDetector(R,Theta,Phi,Shape); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::InitSpectra() { + m_Spectra = new TTACTICSpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TTACTICPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("TACTIC", "D"+ NPL::itoa(i+1)+"_ENERGY","TACTIC_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("TACTIC", "D"+ NPL::itoa(i+1)+"_TIME","TACTIC_D"+ NPL::itoa(i+1)+"_TIME"); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("TACTIC", true ); + inputChain->SetBranchAddress("TACTIC", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("TACTIC", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTACTICPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("TACTIC", "TTACTICPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TTACTICPhysics::Construct() { + return (NPL::VDetector*) new TTACTICPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_TACTIC{ + public: + proxy_TACTIC(){ + NPL::DetectorFactory::getInstance()->AddToken("TACTIC","TACTIC"); + NPL::DetectorFactory::getInstance()->AddDetector("TACTIC",TTACTICPhysics::Construct); + } +}; + +proxy_TACTIC p_TACTIC; +} + diff --git a/NPLib/Detectors/TACTIC/TTACTICPhysics.h b/NPLib/Detectors/TACTIC/TTACTICPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..02d22e3d52c14a3f427976163c6191693426f7a1 --- /dev/null +++ b/NPLib/Detectors/TACTIC/TTACTICPhysics.h @@ -0,0 +1,180 @@ +#ifndef TTACTICPHYSICS_H +#define TTACTICPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: warren.lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TACTIC Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> +#include <map> +#include <string> +using namespace std; + +// ROOT headers +#include "TObject.h" +#include "TH1.h" +#include "TVector3.h" +// NPTool headers +#include "TTACTICData.h" +#include "TTACTICSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TTACTICSpectra; + + + +class TTACTICPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TTACTICPhysics(); + ~TTACTICPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + + + ////////////////////////////////////////////////////////////// + // data obtained after BuildPhysicalEvent() and stored in + // output ROOT file + public: + vector<int> DetectorNumber; + vector<double> Energy; + vector<double> Time; + + /// A usefull method to bundle all operation to add a detector + void AddDetector(TVector3 POS, string shape); + void AddDetector(double R, double Theta, double Phi, string shape); + + ////////////////////////////////////////////////////////////// + // methods inherited from the VDetector ABC class + public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); + + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // method called event by event, aiming at extracting the + // physical information from detector + void BuildPhysicalEvent(); + + // same as BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); + + // same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // activate raw data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // activate physics data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputPhysics(); + + // create branches of output ROOT file + void InitializeRootOutput(); + + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // methods related to the TTACTICSpectra class + // instantiate the TTACTICSpectra class and + // declare list of histograms + void InitSpectra(); + + // fill the spectra + void FillSpectra(); + + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); + + // used for Online only, clear all the spectra + void ClearSpectra(); + + // write spectra to ROOT output file + void WriteSpectra(); + + + ////////////////////////////////////////////////////////////// + // specific methods to TACTIC array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TTACTICData object to TTACTICPhysics. + // needed for online analysis for example + void SetRawDataPointer(TTACTICData* rawDataPointer) {m_EventData = rawDataPointer;} + + // objects are not written in the TTree + private: + TTACTICData* m_EventData; //! + TTACTICData* m_PreTreatedData; //! + TTACTICPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TTACTICData* GetRawData() const {return m_EventData;} + TTACTICData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + // number of detectors + private: + int m_NumberOfDetectors; //! + + // spectra class + private: + TTACTICSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TTACTICPhysics,1) // TACTICPhysics structure +}; +#endif diff --git a/NPLib/Detectors/TACTIC/TTACTICSpectra.cxx b/NPLib/Detectors/TACTIC/TTACTICSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4642385cdadf380d9316d99729ad385f05664117 --- /dev/null +++ b/NPLib/Detectors/TACTIC/TTACTICSpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: warren.lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TACTIC Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TTACTICSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TTACTICSpectra::TTACTICSpectra() + : fNumberOfDetectors(0) { + SetName("TACTIC"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TTACTICSpectra::TTACTICSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TTACTICSpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("TACTIC"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TTACTICSpectra::~TTACTICSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTACTICSpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "TACTIC"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "TACTIC/RAW"); + // Time + name = "TACTIC"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "TACTIC/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTACTICSpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "TACTIC"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "TACTIC/CAL"); + // Time + name = "TACTIC"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "TACTIC/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTACTICSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "TACTIC_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "TACTIC/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTACTICSpectra::FillRawSpectra(TTACTICData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "TACTIC"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "TACTIC/RAW"; + + FillSpectra(family,name,RawData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "TACTIC"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; + family = "TACTIC/RAW"; + + FillSpectra(family,name,RawData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTACTICSpectra::FillPreTreatedSpectra(TTACTICData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "TACTIC"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "TACTIC/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "TACTIC"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; + family = "TACTIC/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTACTICSpectra::FillPhysicsSpectra(TTACTICPhysics* Physics) { + static string name; + static string family; + family= "TACTIC/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->Energy.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "TACTIC_ENERGY_TIME"; + FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/TACTIC/TTACTICSpectra.h b/NPLib/Detectors/TACTIC/TTACTICSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..9eb2c79fe55d8d7c4331ef1149dedf4d3da1f3e7 --- /dev/null +++ b/NPLib/Detectors/TACTIC/TTACTICSpectra.h @@ -0,0 +1,62 @@ +#ifndef TTACTICSPECTRA_H +#define TTACTICSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: warren.lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TACTIC Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TTACTICData.h" +#include "TTACTICPhysics.h" + +// Forward Declaration +class TTACTICPhysics; + + +class TTACTICSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TTACTICSpectra(); + TTACTICSpectra(unsigned int NumberOfDetectors); + ~TTACTICSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TTACTICData*); + void FillPreTreatedSpectra(TTACTICData*); + void FillPhysicsSpectra(TTACTICPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPLib/Detectors/TNT/CMakeLists.txt b/NPLib/Detectors/TNT/CMakeLists.txt index ec8c67a2ba998838d7334e4f26650ee0bfd033cc..b0a0537a112cfe8bd4e6e7d5b41a559acb2d7471 100644 --- a/NPLib/Detectors/TNT/CMakeLists.txt +++ b/NPLib/Detectors/TNT/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TTNTPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTNTPhysics.h TTNTPhysicsDict.cxx TTNTPhysics.rootmap libNPTNT.dylib DEPENDS TTNTPhysics.h) -add_custom_command(OUTPUT TTNTDataDict.cxx COMMAND ../../scripts/build_dict.sh TTNTData.h TTNTDataDict.cxx TTNTData.rootmap libNPTNT.dylib DEPENDS TTNTData.h) +add_custom_command(OUTPUT TTNTPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTNTPhysics.h TTNTPhysicsDict.cxx TTNTPhysics.rootmap libNPTNT.dylib DEPENDS TTNTPhysics.h) +add_custom_command(OUTPUT TTNTDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTNTData.h TTNTDataDict.cxx TTNTData.rootmap libNPTNT.dylib DEPENDS TTNTData.h) add_library(NPTNT SHARED TTNTSpectra.cxx TTNTData.cxx TTNTPhysics.cxx TTNTDataDict.cxx TTNTPhysicsDict.cxx ) target_link_libraries(NPTNT ${ROOT_LIBRARIES} NPCore) install(FILES TTNTData.h TTNTPhysics.h TTNTSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/TRex/CMakeLists.txt b/NPLib/Detectors/TRex/CMakeLists.txt index 7c32b75b193892ddfc1b1198e8c703f8324368cd..16d33b12f443d90ad2930961cfb82f75db008bfa 100644 --- a/NPLib/Detectors/TRex/CMakeLists.txt +++ b/NPLib/Detectors/TRex/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TTRexPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTRexPhysics.h TTRexPhysicsDict.cxx TTRexPhysics.rootmap libNPTRex.dylib DEPENDS TTRexPhysics.h) -add_custom_command(OUTPUT TTRexDataDict.cxx COMMAND ../../scripts/build_dict.sh TTRexData.h TTRexDataDict.cxx TTRexData.rootmap libNPTRex.dylib DEPENDS TTRexData.h) +add_custom_command(OUTPUT TTRexPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTRexPhysics.h TTRexPhysicsDict.cxx TTRexPhysics.rootmap libNPTRex.dylib DEPENDS TTRexPhysics.h) +add_custom_command(OUTPUT TTRexDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTRexData.h TTRexDataDict.cxx TTRexData.rootmap libNPTRex.dylib DEPENDS TTRexData.h) add_library(NPTRex SHARED TTRexSpectra.cxx TTRexData.cxx TTRexPhysics.cxx TTRexDataDict.cxx TTRexPhysicsDict.cxx ) target_link_libraries(NPTRex ${ROOT_LIBRARIES} NPCore) install(FILES TTRexData.h TTRexPhysics.h TTRexSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Tiara/CMakeLists.txt b/NPLib/Detectors/Tiara/CMakeLists.txt index 22462ea3bdadaec020c0a939add36131e9177757..5c5f41c1d0667829d8cf96b191c922c15b82221c 100644 --- a/NPLib/Detectors/Tiara/CMakeLists.txt +++ b/NPLib/Detectors/Tiara/CMakeLists.txt @@ -1,7 +1,7 @@ -add_custom_command(OUTPUT TTiaraHyballPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTiaraHyballPhysics.h TTiaraHyballPhysicsDict.cxx TTiaraHyballPhysics.rootmap libNPTiara.dylib DEPENDS TTiaraHyballPhysics.h) -add_custom_command(OUTPUT TTiaraBarrelPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTiaraBarrelPhysics.h TTiaraBarrelPhysicsDict.cxx TTiaraBarrelPhysics.rootmap libNPTiara.dylib DEPENDS TTiaraBarrelPhysics.h) -add_custom_command(OUTPUT TTiaraHyballDataDict.cxx COMMAND ../../scripts/build_dict.sh TTiaraHyballData.h TTiaraHyballDataDict.cxx TTiaraHyballData.rootmap libNPTiara.dylib DEPENDS TTiaraHyballData.h) -add_custom_command(OUTPUT TTiaraBarrelDataDict.cxx COMMAND ../../scripts/build_dict.sh TTiaraBarrelData.h TTiaraBarrelDataDict.cxx TTiaraBarrelData.rootmap libNPTiara.dylib DEPENDS TTiaraBarrelData.h) +add_custom_command(OUTPUT TTiaraHyballPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTiaraHyballPhysics.h TTiaraHyballPhysicsDict.cxx TTiaraHyballPhysics.rootmap libNPTiara.dylib DEPENDS TTiaraHyballPhysics.h) +add_custom_command(OUTPUT TTiaraBarrelPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTiaraBarrelPhysics.h TTiaraBarrelPhysicsDict.cxx TTiaraBarrelPhysics.rootmap libNPTiara.dylib DEPENDS TTiaraBarrelPhysics.h) +add_custom_command(OUTPUT TTiaraHyballDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTiaraHyballData.h TTiaraHyballDataDict.cxx TTiaraHyballData.rootmap libNPTiara.dylib DEPENDS TTiaraHyballData.h) +add_custom_command(OUTPUT TTiaraBarrelDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTiaraBarrelData.h TTiaraBarrelDataDict.cxx TTiaraBarrelData.rootmap libNPTiara.dylib DEPENDS TTiaraBarrelData.h) add_library(NPTiara SHARED TTiaraBarrelData.cxx TTiaraBarrelPhysics.cxx TTiaraBarrelDataDict.cxx TTiaraBarrelPhysicsDict.cxx TTiaraBarrelSpectra.cxx TTiaraHyballData.cxx TTiaraHyballPhysics.cxx TTiaraHyballDataDict.cxx TTiaraHyballPhysicsDict.cxx TTiaraHyballSpectra.cxx) diff --git a/NPLib/Detectors/Tigress/CMakeLists.txt b/NPLib/Detectors/Tigress/CMakeLists.txt index 2e7675b9f0d829d681806c68126877dff7b7e833..74519defc3db6df091ec64017dba8e74a0573bd8 100644 --- a/NPLib/Detectors/Tigress/CMakeLists.txt +++ b/NPLib/Detectors/Tigress/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TTigressPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTigressPhysics.h TTigressPhysicsDict.cxx TTigressPhysics.rootmap libNPTigress.dylib DEPENDS TTigressPhysics.h) -add_custom_command(OUTPUT TTigressDataDict.cxx COMMAND ../../scripts/build_dict.sh TTigressData.h TTigressDataDict.cxx TTigressData.rootmap libNPTigress.dylib DEPENDS TTigressData.h) +add_custom_command(OUTPUT TTigressPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTigressPhysics.h TTigressPhysicsDict.cxx TTigressPhysics.rootmap libNPTigress.dylib DEPENDS TTigressPhysics.h) +add_custom_command(OUTPUT TTigressDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTigressData.h TTigressDataDict.cxx TTigressData.rootmap libNPTigress.dylib DEPENDS TTigressData.h) add_library(NPTigress SHARED TTigressData.cxx TTigressPhysics.cxx TTigressDataDict.cxx TTigressPhysicsDict.cxx ) target_link_libraries(NPTigress ${ROOT_LIBRARIES} NPCore) install(FILES TTigressData.h TTigressPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Trifoil/CMakeLists.txt b/NPLib/Detectors/Trifoil/CMakeLists.txt index 5fe685250e61ac87fc3befa483b9c872f6bdbe0a..5bd07763c1d8c7b6277d521951cb597657a31fc2 100644 --- a/NPLib/Detectors/Trifoil/CMakeLists.txt +++ b/NPLib/Detectors/Trifoil/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TTrifoilPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTrifoilPhysics.h TTrifoilPhysicsDict.cxx TTrifoilPhysics.rootmap libNPTrifoil.dylib DEPENDS TTrifoilPhysics.h) -add_custom_command(OUTPUT TTrifoilDataDict.cxx COMMAND ../../scripts/build_dict.sh TTrifoilData.h TTrifoilDataDict.cxx TTrifoilData.rootmap libNPTrifoil.dylib DEPENDS TTrifoilData.h) +add_custom_command(OUTPUT TTrifoilPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTrifoilPhysics.h TTrifoilPhysicsDict.cxx TTrifoilPhysics.rootmap libNPTrifoil.dylib DEPENDS TTrifoilPhysics.h) +add_custom_command(OUTPUT TTrifoilDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TTrifoilData.h TTrifoilDataDict.cxx TTrifoilData.rootmap libNPTrifoil.dylib DEPENDS TTrifoilData.h) add_library(NPTrifoil SHARED TTrifoilData.cxx TTrifoilPhysics.cxx TTrifoilDataDict.cxx TTrifoilPhysicsDict.cxx ) target_link_libraries(NPTrifoil ${ROOT_LIBRARIES} -lSpectrum NPCore) install(FILES TTrifoilData.h TTrifoilPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Vamos/CMakeLists.txt b/NPLib/Detectors/Vamos/CMakeLists.txt index 04ae96ae27bc9b59cd0710bfa2bab2aea72338c6..31ca9d343a99e90608992b105f135107a3274695 100644 --- a/NPLib/Detectors/Vamos/CMakeLists.txt +++ b/NPLib/Detectors/Vamos/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TVamosPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TVamosPhysics.h TVamosPhysicsDict.cxx TVamosPhysics.rootmap libNPVamos.dylib DEPENDS TVamosPhysics.h) -add_custom_command(OUTPUT TVamosDataDict.cxx COMMAND ../../scripts/build_dict.sh TVamosData.h TVamosDataDict.cxx TVamosData.rootmap libNPVamos.dylib DEPENDS TVamosData.h) +add_custom_command(OUTPUT TVamosPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TVamosPhysics.h TVamosPhysicsDict.cxx TVamosPhysics.rootmap libNPVamos.dylib DEPENDS TVamosPhysics.h) +add_custom_command(OUTPUT TVamosDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TVamosData.h TVamosDataDict.cxx TVamosData.rootmap libNPVamos.dylib DEPENDS TVamosData.h) add_library(NPVamos SHARED TVamosData.cxx TVamosPhysics.cxx TVamosDataDict.cxx TVamosPhysicsDict.cxx ) target_link_libraries(NPVamos ${ROOT_LIBRARIES} NPCore) install(FILES TVamosData.h TVamosPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/W1/CMakeLists.txt b/NPLib/Detectors/W1/CMakeLists.txt index ea8f5511c675c51cd646cf00530fbd8684e1df2a..55ed11be4341a30305f827f2a8ea5f92bb9d69a5 100644 --- a/NPLib/Detectors/W1/CMakeLists.txt +++ b/NPLib/Detectors/W1/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT TW1PhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TW1Physics.h TW1PhysicsDict.cxx TW1Physics.rootmap libNPW1.dylib DEPENDS TW1Physics.h) -add_custom_command(OUTPUT TW1DataDict.cxx COMMAND ../../scripts/build_dict.sh TW1Data.h TW1DataDict.cxx TW1Data.rootmap libNPW1.dylib DEPENDS TW1Data.h) +add_custom_command(OUTPUT TW1PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TW1Physics.h TW1PhysicsDict.cxx TW1Physics.rootmap libNPW1.dylib DEPENDS TW1Physics.h) +add_custom_command(OUTPUT TW1DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TW1Data.h TW1DataDict.cxx TW1Data.rootmap libNPW1.dylib DEPENDS TW1Data.h) add_library(NPW1 SHARED TW1Spectra.cxx TW1Data.cxx TW1Physics.cxx TW1DataDict.cxx TW1PhysicsDict.cxx ) target_link_libraries(NPW1 ${ROOT_LIBRARIES} NPCore) install(FILES TW1Data.h TW1Physics.h TW1Spectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/beam_dump/CMakeLists.txt b/NPLib/Detectors/beam_dump/CMakeLists.txt index fa831276c4b49125d0f384d3d0f9372987e70d93..09ed63c24718d7bcc11433d2c916d16a28629da1 100755 --- a/NPLib/Detectors/beam_dump/CMakeLists.txt +++ b/NPLib/Detectors/beam_dump/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_command(OUTPUT Tbeam_dumpPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh Tbeam_dumpPhysics.h Tbeam_dumpPhysicsDict.cxx Tbeam_dumpPhysics.rootmap libNPbeam_dump.dylib DEPENDS Tbeam_dumpPhysics.h) -add_custom_command(OUTPUT Tbeam_dumpDataDict.cxx COMMAND ../../scripts/build_dict.sh Tbeam_dumpData.h Tbeam_dumpDataDict.cxx Tbeam_dumpData.rootmap libNPbeam_dump.dylib DEPENDS Tbeam_dumpData.h) +add_custom_command(OUTPUT Tbeam_dumpPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh Tbeam_dumpPhysics.h Tbeam_dumpPhysicsDict.cxx Tbeam_dumpPhysics.rootmap libNPbeam_dump.dylib DEPENDS Tbeam_dumpPhysics.h) +add_custom_command(OUTPUT Tbeam_dumpDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh Tbeam_dumpData.h Tbeam_dumpDataDict.cxx Tbeam_dumpData.rootmap libNPbeam_dump.dylib DEPENDS Tbeam_dumpData.h) add_library(NPbeam_dump SHARED Tbeam_dumpSpectra.cxx Tbeam_dumpData.cxx Tbeam_dumpPhysics.cxx Tbeam_dumpDataDict.cxx Tbeam_dumpPhysicsDict.cxx ) target_link_libraries(NPbeam_dump ${ROOT_LIBRARIES} NPCore) install(FILES Tbeam_dumpData.h Tbeam_dumpPhysics.h Tbeam_dumpSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Online/CMakeLists.txt b/NPLib/Online/CMakeLists.txt index 85690ed0975714ea642e04b0d8dc04082b9a07c4..ca09ff56b3f596db81ab4166754311b951b98e66 100644 --- a/NPLib/Online/CMakeLists.txt +++ b/NPLib/Online/CMakeLists.txt @@ -1,4 +1,4 @@ -add_custom_command(OUTPUT NPOnlineDict.cxx COMMAND ../scripts/build_dict.sh NPOnlineGUI.h NPOnlineDict.cxx NPOnline.rootmap libNPCore.dylib NPOnlineLinkDef.h DEPENDS NPOnlineGUI.h) +add_custom_command(OUTPUT NPOnlineDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPOnlineGUI.h NPOnlineDict.cxx NPOnline.rootmap libNPCore.dylib NPOnlineLinkDef.h DEPENDS NPOnlineGUI.h) add_library(NPOnline SHARED NPSpectraClient.cxx NPOnlineGUI.cxx NPOnlineDict.cxx ) target_link_libraries(NPOnline ${ROOT_LIBRARIES} Thread NPCore) install(FILES NPOnlineGUI.h NPSpectraClient.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Physics/CMakeLists.txt b/NPLib/Physics/CMakeLists.txt index 47cac7428f05ae453f8748c9547eecccb3acc33f..ed76e00bfe5f56332048acb0e91d6fb441c178dc 100644 --- a/NPLib/Physics/CMakeLists.txt +++ b/NPLib/Physics/CMakeLists.txt @@ -1,18 +1,18 @@ -add_custom_command(OUTPUT NPNucleusDict.cxx COMMAND ../scripts/build_dict.sh NPNucleus.h NPNucleusDict.cxx NPNucleus.rootmap libNPPhysics.so NPNucleusLinkDef.h DEPENDS NPNucleus.h NPNucleusLinkDef.h) +add_custom_command(OUTPUT NPNucleusDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPNucleus.h NPNucleusDict.cxx NPNucleus.rootmap libNPPhysics.so NPNucleusLinkDef.h DEPENDS NPNucleus.h NPNucleusLinkDef.h) -add_custom_command(OUTPUT NPReactionDict.cxx COMMAND ../scripts/build_dict.sh NPReaction.h NPReactionDict.cxx NPReaction.rootmap libNPPhysics.so NPReactionLinkDef.h DEPENDS NPReaction.h NPReactionLinkDef.h) +add_custom_command(OUTPUT NPReactionDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPReaction.h NPReactionDict.cxx NPReaction.rootmap libNPPhysics.so NPReactionLinkDef.h DEPENDS NPReaction.h NPReactionLinkDef.h) -add_custom_command(OUTPUT NPQFSDict.cxx COMMAND ../scripts/build_dict.sh NPQFS.h NPQFSDict.cxx NPQFS.rootmap libNPPhysics.so NPQFSLinkDef.h DEPENDS NPQFS.h NPQFSLinkDef.h) +add_custom_command(OUTPUT NPQFSDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPQFS.h NPQFSDict.cxx NPQFS.rootmap libNPPhysics.so NPQFSLinkDef.h DEPENDS NPQFS.h NPQFSLinkDef.h) -add_custom_command(OUTPUT NPDecayDict.cxx COMMAND ../scripts/build_dict.sh NPDecay.h NPDecayDict.cxx NPDecay.rootmap libNPPhysics.so NPDecayLinkDef.h DEPENDS NPDecay.h NPDecayLinkDef.h) +add_custom_command(OUTPUT NPDecayDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPDecay.h NPDecayDict.cxx NPDecay.rootmap libNPPhysics.so NPDecayLinkDef.h DEPENDS NPDecay.h NPDecayLinkDef.h) -add_custom_command(OUTPUT NPEnergyLossDict.cxx COMMAND ../scripts/build_dict.sh NPEnergyLoss.h NPEnergyLossDict.cxx NPEnergyLoss.rootmap libNPPhysics.so NPEnergyLossLinkDef.h DEPENDS NPEnergyLoss.h NPEnergyLossLinkDef.h) +add_custom_command(OUTPUT NPEnergyLossDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPEnergyLoss.h NPEnergyLossDict.cxx NPEnergyLoss.rootmap libNPPhysics.so NPEnergyLossLinkDef.h DEPENDS NPEnergyLoss.h NPEnergyLossLinkDef.h) -add_custom_command(OUTPUT TInitialConditionsDict.cxx COMMAND ../scripts/build_dict.sh TInitialConditions.h TInitialConditionsDict.cxx TInitialConditions.rootmap libNPInitialConditions.so DEPENDS TInitialConditions.h) +add_custom_command(OUTPUT TInitialConditionsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TInitialConditions.h TInitialConditionsDict.cxx TInitialConditions.rootmap libNPInitialConditions.so DEPENDS TInitialConditions.h) -add_custom_command(OUTPUT TInteractionCoordinatesDict.cxx COMMAND ../scripts/build_dict.sh TInteractionCoordinates.h TInteractionCoordinatesDict.cxx TInteractionCoordinates.rootmap libNPInteractionCoordinates.so DEPENDS TInteractionCoordinates.h) +add_custom_command(OUTPUT TInteractionCoordinatesDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TInteractionCoordinates.h TInteractionCoordinatesDict.cxx TInteractionCoordinates.rootmap libNPInteractionCoordinates.so DEPENDS TInteractionCoordinates.h) -add_custom_command(OUTPUT TReactionConditionsDict.cxx COMMAND ../scripts/build_dict.sh TReactionConditions.h TReactionConditionsDict.cxx TReactionConditions.rootmap libNPReactionConditions.so DEPENDS TReactionConditions.h) +add_custom_command(OUTPUT TReactionConditionsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TReactionConditions.h TReactionConditionsDict.cxx TReactionConditions.rootmap libNPReactionConditions.so DEPENDS TReactionConditions.h) add_library(NPPhysics SHARED NPDecay.cxx NPBeam.cxx NPEnergyLoss.cxx NPFunction.cxx NPNucleus.cxx NPReaction.cxx NPQFS.cxx NPNucleusDict.cxx NPReactionDict.cxx NPQFSDict.cxx NPEnergyLossDict.cxx ) target_link_libraries(NPPhysics ${ROOT_LIBRARIES} Physics NPCore) diff --git a/NPLib/Physics/NPBeam.cxx b/NPLib/Physics/NPBeam.cxx index d9487db7aaf14d5c7e0b7b9dcd77498aecf55d93..e7644c7e4076621954b17203ce309dcb608e451a 100644 --- a/NPLib/Physics/NPBeam.cxx +++ b/NPLib/Physics/NPBeam.cxx @@ -50,6 +50,7 @@ using namespace NPL; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... Beam::Beam(){ + fExcitationEnergy = 0; fEnergy = 0; fSigmaEnergy = -1 ; fMeanX = 0 ; diff --git a/NPLib/Physics/NPFunction.cxx b/NPLib/Physics/NPFunction.cxx index 053fd0f7d2381bc121912bd8019ebd6327c32657..9de2b666211aa8facae9ba279fafad1734c3437d 100644 --- a/NPLib/Physics/NPFunction.cxx +++ b/NPLib/Physics/NPFunction.cxx @@ -279,7 +279,7 @@ namespace NPL{ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - string ChangeNameToG4Standard(string OriginalName){ + string ChangeNameToG4Standard(string OriginalName,bool excited){ string NumberOfMass ; string Nucleid; @@ -354,6 +354,8 @@ namespace NPL{ // Special case for light particles string FinalName=Nucleid+NumberOfMass; + + if(!excited){ if (FinalName=="H1") FinalName="proton"; else if (FinalName=="H2") FinalName="deuteron"; else if (FinalName=="H3") FinalName="triton"; @@ -363,6 +365,7 @@ namespace NPL{ else if (FinalName=="t") FinalName="triton"; else if (FinalName=="a") FinalName="alpha"; else if (FinalName=="n") FinalName="neutron"; + } return(FinalName); } @@ -440,8 +443,8 @@ namespace NPL{ else if (character.str()=="z") Nucleid+="z"; } - // Special case for light particles string FinalName=NumberOfMass+Nucleid; + // Special case for light particles if (FinalName=="H1") FinalName="proton"; else if (FinalName=="H2") FinalName="deuteron"; else if (FinalName=="H3") FinalName="triton"; diff --git a/NPLib/Physics/NPFunction.h b/NPLib/Physics/NPFunction.h index b6373860d8c04d2559877846e4b025ac0fbc1099..8150a644e5c321bb6c80aa2eee3bc893d993b851 100644 --- a/NPLib/Physics/NPFunction.h +++ b/NPLib/Physics/NPFunction.h @@ -58,7 +58,7 @@ namespace NPL{ void RandomGaussian2D(double MeanX, double MeanY, double SigmaX, double SigmaY, double &X, double &Y); // Change nucleus name from G4 standard to Physics standard (11Li vs Li11) - string ChangeNameToG4Standard(string name); + string ChangeNameToG4Standard(string name,bool excited=false); string ChangeNameFromG4Standard(string name); // Hyperbolic shape generator for cryogenic target deformation diff --git a/NPLib/Physics/NPQFS.cxx b/NPLib/Physics/NPQFS.cxx index 391ffa6c0571bf27e68b88a1156b365ab328e086..d3156d6d98eb7b93cc292e7c2ba532f0bb323d29 100644 --- a/NPLib/Physics/NPQFS.cxx +++ b/NPLib/Physics/NPQFS.cxx @@ -7,29 +7,32 @@ /***************************************************************************** * * - * Original Author : F. Flavigny contact address: flavigny@ipno.in2p3.fr * + * Original Author : F. Flavigny contact address: flavigny@lpccaen.in2p3.fr * * * * Creation Date : April 2019 * - * Last update : April 2019 * + * Last update : Nov 2019 * *---------------------------------------------------------------------------* * Decription: * * This class deal with Quasi Free Scattering Reaction in which a cluster * * or a nucleon is removed from a projectile by interaction with a target * * nucleon (proton target in general) * * * - * Labeling is: * - * A --> i ==> B + (i -> a) => B + 1 + 2 * + * First step (dissociation): A -> B + a * + * Second step (scattering) : a + T -> 1 + 2 * + * Labeling is: * + * * + * A --> T ==> B + (a -> T) => B + 1 + 2 * * * * where: * * + A is the beam nucleus * - * + i is the target nucleon (proton) * + * + T is the target nucleon (proton) * * * * + B is the residual fragment (beam-like) * - * + 1 is the scattered target nucleon (former i) * + * + 1 is the scattered target nucleon (former T) * * + 2 is the knocked-out cluster/nucleon (noted a) in the intermediate * *---------------------------------------------------------------------------* * Comment: * - * + * + * + Adapted from original event generator from V. Panin (R3B collab) * * * *****************************************************************************/ @@ -57,14 +60,768 @@ using namespace NPUNITS; #include"TF1.h" ClassImp(QFS) -/* -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +//////////////////////////////////////////////////////////////////////////////// + QFS::QFS(){ - fVerboseLevel=0; + + //------------- Default Constructor ------------- + fVerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); + fBeamEnergy = 0; + fThetaCM = 0; + fPhiCM = 0; + + fExcitationA = 0; + fExcitationB = 0; + fMomentumSigma = 0; + fInternalMomentum = {0., 0.,0. }; + fshootB=false; + fshoot1=true; + fshoot2=true; + fisotropic = true; + + fTheta2VsTheta1 = 0; + fPhi2VsPhi1 = 0; + + fPerpMomentumHist = NULL; + fParMomentumHist = NULL; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +//////////////////////////////////////////////////////////////////////////////// + QFS::~QFS(){ + +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +void QFS::ReadConfigurationFile(string Path){ + ifstream ReactionFile; + string GlobalPath = getenv("NPTOOL"); + string StandardPath = GlobalPath + "/Inputs/EventGenerator/" + Path; + ReactionFile.open(Path.c_str()); + if (!ReactionFile.is_open()) { + ReactionFile.open(StandardPath.c_str()); + if(ReactionFile.is_open()) { + Path = StandardPath; + } + else {cout << "QFS File " << Path << " not found" << endl;exit(1);} + } + NPL::InputParser parser(Path); + ReadConfigurationFile(parser); +} + +//////////////////////////////////////////////////////////////////////////////// + +void QFS::ReadConfigurationFile(NPL::InputParser parser){ + + cout << " In QFS ReadConfiguration " << endl; + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("QFSReaction"); + if(blocks.size()>0 && NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "\033[1;35m//// QFS reaction found " << endl; + + vector<string> token1 = {"Beam","Target","Scattered","KnockedOut","Heavy"}; + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(token1)){ + int v = NPOptionManager::getInstance()->GetVerboseLevel(); + NPOptionManager::getInstance()->SetVerboseLevel(0); + fNucleiA.ReadConfigurationFile(parser); + NPOptionManager::getInstance()->SetVerboseLevel(v); + + fBeamEnergy= fNucleiA.GetEnergy(); + GetNucleus(blocks[i]->GetString("Beam"),parser); + fNucleiT = GetNucleus(blocks[i]->GetString("Target"),parser); + fNucleiB = GetNucleus(blocks[i]->GetString("Heavy"),parser); + fNuclei1 = GetNucleus(blocks[i]->GetString("Scattered"),parser); + fNuclei2 = GetNucleus(blocks[i]->GetString("KnockedOut"),parser); + } + else{ + cout << "ERROR: check your input file formatting \033[0m" << endl; + exit(1); + } + if(blocks[i]->HasToken("ExcitationEnergyBeam")){ + fExcitationA = blocks[i]->GetDouble("ExcitationEnergyBeam","MeV"); + } + if(blocks[i]->HasToken("ExcitationEnergyHeavy")){ + fExcitationB = blocks[i]->GetDouble("ExcitationEnergyHeavy","MeV"); + } + if(blocks[i]->HasToken("MomentumSigma")){ + fMomentumSigma = blocks[i]->GetDouble("MomentumSigma","MeV"); + } + if(blocks[i]->HasToken("ShootHeavy")){ + fshootB = blocks[i]->GetInt("ShootHeavy"); + } + if(blocks[i]->HasToken("ShootLight")){ + fshoot1 = blocks[i]->GetInt("ShootLight"); + fshoot2 = blocks[i]->GetInt("ShootLight"); + } + if(blocks[i]->HasToken("PerpMomentumPath")){ + vector<string> file_perp = blocks[i]->GetVectorString("PerpMomentumPath"); + TH1F* Perptemp = Read1DProfile(file_perp[0], file_perp[1]); + SetPerpMomentumHist(Perptemp); + } + if(blocks[i]->HasToken("ParMomentumPath")){ + vector<string> file_par = blocks[i]->GetVectorString("ParMomentumPath"); + TH1F* Partemp = Read1DProfile(file_par[0], file_par[1]); + SetParMomentumHist(Partemp); + } + } + + cout << "\033[0m" ; +} + +//////////////////////////////////////////////////////////////////////////////// +Nucleus QFS::GetNucleus(string name, NPL::InputParser parser){ + + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("DefineNucleus",name); + unsigned int size = blocks.size(); + if(size==0) + return NPL::Nucleus(name); + else if(size==1){ + cout << " -- User defined nucleus " << name << " -- " << endl; + vector<string> token = {"SubPart","BindingEnergy"}; + if(blocks[0]->HasTokenList(token)){ + NPL::Nucleus N(name,blocks[0]->GetVectorString("SubPart"),blocks[0]->GetDouble("BindingEnergy","MeV")); + if(blocks[0]->HasToken("ExcitationEnergy")) + N.SetExcitationEnergy(blocks[0]->GetDouble("ExcitationEnergy","MeV")); + if(blocks[0]->HasToken("SpinParity")) + N.SetSpinParity(blocks[0]->GetString("SpinParity").c_str()); + if(blocks[0]->HasToken("Spin")) + N.SetSpin(blocks[0]->GetDouble("Spin","")); + if(blocks[0]->HasToken("Parity")) + N.SetParity(blocks[0]->GetString("Parity").c_str()); + if(blocks[0]->HasToken("LifeTime")) + N.SetLifeTime(blocks[0]->GetDouble("LifeTime","s")); + + cout << " -- -- -- -- -- -- -- -- -- -- --" << endl; + return N; + } + } + else{ + NPL::SendErrorAndExit("NPL::QFS","Too many nuclei define with the same name"); + return NPL::Nucleus(); + } + return NPL::Nucleus(); +} + + +//////////////////////////////////////////////////////////////////////////////////////////// +void QFS::CalculateVariables(){ + + if(fBeamEnergy < 0) + fBeamEnergy = 0 ; + + //cout<<"---- COMPUTE ------"<<endl; + // cout<<"--CM--"<<endl; + + mA = fNucleiA.Mass(); // Beam mass in MeV + mT = fNucleiT.Mass(); // Target mass in MeV + mB = fNucleiB.Mass(); // Heavy residual mass in MeV + m1 = mT; // scattered target nucleon (same mass); + m2 = fNuclei2.Mass(); // knocked out cluster mass in MeV + ma = m2; // intermediate cluster mass in MeV (same); + + double TA = fBeamEnergy; // Beam kinetic energy + double PA = sqrt(TA*(TA+2*mA)); // Beam momentum (norm) + double EA = sqrt(mA*mA + PA*PA); // Beam total energy + fEnergyImpulsionLab_A = TLorentzVector(0.,0.,PA,EA); + + //Internal momentum of removed cluster/nucleon + Pa.SetX(fInternalMomentum.X()); + Pa.SetY(fInternalMomentum.Y()); + Pa.SetZ(fInternalMomentum.Z()); + + //Internal momentum of heavy recoil after removal + PB.SetXYZ( (-Pa.X()) , (-Pa.Y()) , (-Pa.Z()) ); + + // Off-shell mass of the bound nucleon from E conservation + // in virtual dissociation of A -> B + a + double buffer = mA*mA + mB*mB - 2*mA*sqrt(mB*mB+Pa.Mag2()) ; + if(buffer<=0) { cout<<"ERROR off shell mass ma_off=\t"<<buffer<<endl; return;} + ma_off = sqrt(buffer); + + //deduced total energies of "a" and "B" in restframe of A + double Ea = sqrt(ma_off*ma_off + Pa.Mag2()); + double EB = sqrt(mB*mB + PB.Mag2()); + + fEnergyImpulsionCM_a = TLorentzVector(Pa,Ea); + fEnergyImpulsionCM_B = TLorentzVector(PB,EB); + + fEnergyImpulsionLab_a = TLorentzVector(Pa,Ea); + fEnergyImpulsionLab_B = TLorentzVector(PB,EB); + fEnergyImpulsionLab_a.Boost(0,0,fEnergyImpulsionLab_A.Beta()); + fEnergyImpulsionLab_B.Boost(0,0,fEnergyImpulsionLab_A.Beta()); + Ea_lab = fEnergyImpulsionLab_a.E(); + EB_lab = fEnergyImpulsionLab_B.E(); + Pa_lab = fEnergyImpulsionLab_a.Vect(); + PB_lab = fEnergyImpulsionLab_B.Vect(); + + // Scattering part (2-body kinematics) + // virtual cluster of mass "ma_off" scattering on target T + // to give scattered cluster with real mass (ma=m2) + // and scattered target (mT=m1) + + fQValue =ma_off+mT-m1-m2; + + s = ma_off*ma_off + mT*mT + 2*mT*Ea_lab ; + fTotalEnergyImpulsionCM = TLorentzVector(0,0,0,sqrt(s)); + fEcm = sqrt(s) - m1 -m2; + if(fEcm<=0) { cout<<"ERROR Ecm negative =\t"<<fEcm<<endl;Dump(); return;} + + ECM_a = (s + ma_off*ma_off - mT*mT)/(2*sqrt(s)); + ECM_T = (s + mT*mT - ma_off*ma_off)/(2*sqrt(s)); + ECM_1 = (s + m1*m1 - m2*m2)/(2*sqrt(s)); + ECM_2 = (s + m2*m2 - m1*m1)/(2*sqrt(s)); + + pCM_a = sqrt(ECM_a*ECM_a - ma_off*ma_off); + pCM_T = sqrt(ECM_T*ECM_T - mT*mT); + pCM_1 = sqrt(ECM_1*ECM_1 - m1*m1); + pCM_2 = sqrt(ECM_2*ECM_2 - m2*m2); + + } + +//////////////////////////////////////////////////////////////////////////////////////////// + +void QFS::KineRelativistic(double& ThetaLab1, double& PhiLab1, double& KineticEnergyLab1, double& ThetaLab2, double& PhiLab2, double& KineticEnergyLab2){ + + CalculateVariables(); + + double thetaCM_1 = fThetaCM; + double thetaCM_2 = M_PI - thetaCM_1; + double phiCM_2 = fPhiCM; + + TVector3 z_axis(0.,0.,1.); + +/* // OTHER WAY of doing + TVector3 pCM_2_temp(0.,0.,1.); + pCM_2_temp.SetMag(pCM_2); + pCM_2_temp.SetTheta(thetaCM_2); + pCM_2_temp.SetPhi(phiCM_2); + fEnergyImpulsionCM_2 = TLorentzVector(pCM_2_temp,ECM_2); + fEnergyImpulsionCM_1 = TLorentzVector(-1*pCM_2_temp,ECM_1); */ + fEnergyImpulsionCM_2 = TLorentzVector( + pCM_2*sin(thetaCM_2)*cos(phiCM_2), + pCM_2*sin(thetaCM_2)*sin(phiCM_2), + pCM_2*cos(thetaCM_2), + ECM_2); + + fEnergyImpulsionCM_1 = fTotalEnergyImpulsionCM - fEnergyImpulsionCM_2; + + //-- Boost in the direction of the moving cluster "a" --// + BetaCM = Pa_lab.Mag() / (Ea_lab + mT); + fEnergyImpulsionLab_1 = fEnergyImpulsionCM_1; + fEnergyImpulsionLab_1.Boost(0,0,BetaCM); + fEnergyImpulsionLab_2 = fEnergyImpulsionCM_2; + fEnergyImpulsionLab_2.Boost(0,0,BetaCM); + + //-- Rotation to go from cluster frame to beam frame --// + TVector3 direction = Pa_lab.Unit(); + fEnergyImpulsionLab_1.RotateUz(direction); + fEnergyImpulsionLab_2.RotateUz(direction); +/* + // Angle in the Lab frame + ThetaLab1 = fEnergyImpulsionLab_1.Angle(fEnergyImpulsionLab_A.Vect()); + //ThetaLab1 = fEnergyImpulsionLab_1.Angle(z_axis); + if (ThetaLab1 < 0) ThetaLab1 += M_PI; + ThetaLab2 = fEnergyImpulsionLab_2.Angle(fEnergyImpulsionLab_A.Vect()); + //ThetaLab2 = fEnergyImpulsionLab_2.Angle(z_axis); + if (fabs(ThetaLab1) < 1e-6) ThetaLab1 = 0; + ThetaLab2 = fabs(ThetaLab2); + if (fabs(ThetaLab2) < 1e-6) ThetaLab2 = 0; + + PhiLab1 = M_PI + fEnergyImpulsionLab_1.Vect().Phi(); + if (fabs(PhiLab1) < 1e-6) PhiLab1 = 0; + PhiLab2 = M_PI + fEnergyImpulsionLab_2.Vect().Phi(); + if (fabs(PhiLab2) < 1e-6) PhiLab2 = 0; +*/ + + ThetaLab1 = fEnergyImpulsionLab_1.Angle(fEnergyImpulsionLab_A.Vect()); + ThetaLab2 = fEnergyImpulsionLab_2.Angle(fEnergyImpulsionLab_A.Vect()); + PhiLab1 = fEnergyImpulsionLab_1.Vect().Phi(); + PhiLab2 = fEnergyImpulsionLab_2.Vect().Phi(); + + // Kinetic Energy in the lab frame + KineticEnergyLab1 = fEnergyImpulsionLab_1.E() - m1; + KineticEnergyLab2 = fEnergyImpulsionLab_2.E() - m2; + + // test for total energy conversion + //if (fabs(fTotalEnergyImpulsionLab.E() - (fEnergyImpulsionLab_1.E()+fEnergyImpulsionLab_2.E())) > 1e-6) + // cout << "Problem for energy conservation" << endl; + + //Dump(); + +} + +//////////////////////////////////////////////////////////////////////////////////////////// +void QFS::Dump(){ + + cout<<endl; + cout<<"------------------------------------"<<endl; + cout<<"------------ DUMP QFS --------------"<<endl; + cout<<"------------------------------------"<<endl; + cout<<endl; + cout<<"Cluster/recoil momentum (in the beam nucleus frame):"<<endl; + cout<<"Pa=\t("<<Pa.Px()<<","<<Pa.Py()<<","<<Pa.Pz()<<") MeV/c"<<endl; + cout<<"PB=\t("<<PB.Px()<<","<<PB.Py()<<","<<PB.Pz()<<") MeV/c"<<endl; + cout<<endl; + cout<<"Off-shell mass of the bound nucleon from E conservation "<<endl; + cout<<" in virtual dissociation of A -> B + a"<<endl; + cout<<"ma=\t"<<ma<<endl; + cout<<"ma_off=\t"<<ma_off<<endl; + cout<<"mB=\t"<<mB<<endl; + cout<<"Deduced total energies of a and B in restframe of A"<<endl; + cout<<"Ea=\t"<<fEnergyImpulsionCM_a.E()<<"\tMeV"<<endl; + cout<<"EB=\t"<<fEnergyImpulsionCM_B.E()<<"\tMeV"<<endl; + cout<<endl; + cout<<"-- Boosted in lab frame with beam on Z axis --"<<endl; + cout<<"Beta_z=\t"<<fEnergyImpulsionLab_A.Beta()<<endl; + cout<<"Pa_lab=\t("<<Pa_lab.Px()<<","<<Pa_lab.Py()<<","<<Pa_lab.Pz()<<") MeV/c"<<endl; + cout<<"PB_lab=\t("<<PB_lab.Px()<<","<<PB_lab.Py()<<","<<PB_lab.Pz()<<") MeV/c"<<endl; + cout<<"Ea_lab=\t"<<Ea_lab<<"\tMeV"<<endl; + cout<<"EB_lab=\t"<<EB_lab<<"\tMeV"<<endl; + cout<<endl; + cout<<"-- Scattering off virtual cluster a of virtual mass --"<<endl; + cout<<"-- ma_off and energy Ea_lab on target T at rest ------"<<endl; + cout<<"fQValue=\t"<<fQValue<<endl; + cout<<"s=\t"<<s<<endl; + cout<<"Ecm=\t"<<fEcm<<endl; + cout<<"ea*=\t"<<ECM_a<<endl; + cout<<"pa*=\t"<<pCM_a<<endl; + cout<<"eT*=\t"<<ECM_T<<endl; + cout<<"pT*=\t"<<pCM_T<<endl; + cout<<"e1*=\t"<<ECM_1<<endl; + cout<<"p1*=\t"<<pCM_1<<endl; + cout<<"e2*=\t"<<ECM_2<<endl; + cout<<"p2*=\t"<<pCM_2<<endl; + cout<<"beta_cm=\t"<<BetaCM<<endl; + cout<<endl; + cout<<"-- Emitted Particles --"<<endl; + cout<<"Theta_cm:"<<fThetaCM*180./TMath::Pi()<<endl; + cout<<"Phi_cm:"<<fPhiCM*180./TMath::Pi()<<endl; + cout<<"P1_CM=\t("<<fEnergyImpulsionCM_1.Px()<<","<<fEnergyImpulsionCM_1.Py()<<","<<fEnergyImpulsionCM_1.Pz()<<")"<<endl; + cout<<"P2_CM=\t("<<fEnergyImpulsionCM_2.Px()<<","<<fEnergyImpulsionCM_2.Py()<<","<<fEnergyImpulsionCM_2.Pz()<<")"<<endl; + cout<<"E1_lab=\t"<<fEnergyImpulsionLab_1.E()<<endl; + cout<<"E2_lab=\t"<<fEnergyImpulsionLab_2.E()<<endl; + cout<<"P1_lab=\t("<<fEnergyImpulsionLab_1.Px()<<","<<fEnergyImpulsionLab_1.Py()<<","<<fEnergyImpulsionLab_1.Pz()<<")"<<endl; + cout<<"P2_lab=\t("<<fEnergyImpulsionLab_2.Px()<<","<<fEnergyImpulsionLab_2.Py()<<","<<fEnergyImpulsionLab_2.Pz()<<")"<<endl; + cout<<"Theta1:\t"<<fEnergyImpulsionLab_1.Vect().Theta()*180./TMath::Pi()<<endl; + cout<<"Theta2:\t"<<fEnergyImpulsionLab_2.Vect().Theta()*180./TMath::Pi()<<endl; + cout<<"Phi1:\t"<<fEnergyImpulsionLab_1.Vect().Phi()*180./TMath::Pi()<<endl; + cout<<"Phi2:\t"<<fEnergyImpulsionLab_2.Vect().Phi()*180./TMath::Pi()<<endl; + +} +//////////////////////////////////////////////////////////////////////////////////////////// + +TVector3 QFS::ShootInternalMomentum(){ + + //Shoot a momentum (vector) for the internal cluster in the beam-at-rest frame + // (1) if only a width is provided: shoot in 3 independant Gaussian + // (2) if input histos are provided: use them instead of option (1) + // Remark : if both width and input histos are provided only histos are considered + + TVector3 momentum = {0,0,0}; + double PerpMomentum =0; + double ParMomentum =0; + double angle_tmp =0; + + momentum.SetX(gRandom->Gaus(0.,fMomentumSigma)); + momentum.SetY(gRandom->Gaus(0.,fMomentumSigma)); + momentum.SetZ(gRandom->Gaus(0.,fMomentumSigma)); + + if(fPerpMomentumHist){ + PerpMomentum=fPerpMomentumHist->GetRandom(); + angle_tmp = gRandom->Rndm()*2*M_PI; + momentum.SetX(PerpMomentum * TMath::Cos(angle_tmp)); + momentum.SetY(PerpMomentum * TMath::Sin(angle_tmp)); + } + if(fParMomentumHist){ + ParMomentum=fParMomentumHist->GetRandom(); + momentum.SetZ(ParMomentum); + } + + //cout << " Shooting Random Momentum: " << endl; + //cout<<"Px:"<<momentum.X() << endl; + //cout<<"Py:"<<momentum.Y() << endl; + //cout<<"Pz:"<<momentum.Z() << endl; + SetInternalMomentum(momentum); + return momentum; +} + +//////////////////////////////////////////////////////////////////////////////////////////// + +TGraph* QFS::GetTheta2VsTheta1(double AngleStep_CM){ + + vector<double> vx; + vector<double> vy; + double theta1,phi1,E1,theta2,phi2,E2; + SetPhiCM(0.*TMath::Pi()/180.); + + for (double angle=0 ; angle <= 180 ; angle+=AngleStep_CM){ + SetThetaCM(angle*TMath::Pi()/180.); + KineRelativistic(theta1, phi1, E1, theta2, phi2, E2); + vx.push_back(theta1*180./M_PI); + vy.push_back(theta2*180./M_PI); + } + fTheta2VsTheta1 = new TGraph(vx.size(),&vx[0],&vy[0]); + + return(fTheta2VsTheta1); +} + +//////////////////////////////////////////////////////////////////////////////////////////// + +TGraph* QFS::GetPhi2VsPhi1(double AngleStep_CM){ + + vector<double> vx; + vector<double> vy; + double theta1,phi1,E1,theta2,phi2,E2; + SetThetaCM(0.*TMath::Pi()/180.); + + for (double angle=-180 ; angle <= 180 ; angle+=AngleStep_CM){ + SetPhiCM(angle*TMath::Pi()/180.); + KineRelativistic(theta1, phi1, E1, theta2, phi2, E2); + vx.push_back(phi1*180./M_PI); + vy.push_back(phi2*180./M_PI); + } + fPhi2VsPhi1 = new TGraph(vx.size(),&vx[0],&vy[0]); + + return(fPhi2VsPhi1); +} + +/////////////////////////////////////////////////////////////////////////////// +// Check whenever the reaction is allowed at a given energy +bool QFS::IsAllowed(){//double Energy){ + //double AvailableEnergy = Energy + fNuclei1.Mass() + fNuclei2.Mass(); + //double RequiredEnergy = fNuclei3.Mass() + fNuclei4.Mass(); + + //if(AvailableEnergy>RequiredEnergy) + return true; + //else + // return false; +} + +//////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// +///////////////// Old R3B method not using TLorentz Vector //////////////////////////////// +/////////////////// (used as a reference)/////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////// + +void QFS::TestR3B() +{ +CalculateVariablesOld(); +} +void QFS::CalculateVariablesOld(){ + + if(fBeamEnergy < 0) + fBeamEnergy = 0 ; + + //cout<<"---- COMPUTE ------"<<endl; + // cout<<"--CM--"<<endl; + + mA = fNucleiA.Mass(); // Beam mass in MeV + mT = fNucleiT.Mass(); // Target mass in MeV + mB = fNucleiB.Mass(); // Heavy residual mass in MeV + m1 = mT; // scattered target nucleon (same mass); + m2 = fNuclei2.Mass(); // knocked out cluster mass in MeV + ma = m2; // intermediate cluster mass in MeV (same); + + double TA = fBeamEnergy; // Beam kinetic energy + double PA = sqrt(TA*(TA+2*mA)); // Beam momentum (norm) + double EA = sqrt(mA*mA + PA*PA); // Beam total energy + fEnergyImpulsionLab_A = TLorentzVector(0.,0.,PA,EA); + + //Internal momentum of removed cluster/nucleon + //gRandom->SetSeed(0); + //double mom_sigma = 0; // MeV/c + //Pa.SetX(gRandom->Gaus(0.,fMomentumSigma)); + //Pa.SetY(gRandom->Gaus(0.,fMomentumSigma)); + //Pa.SetZ(gRandom->Gaus(0.,fMomentumSigma)); + Pa.SetX(50); + Pa.SetY(50); + Pa.SetZ(50); + + + + //Internal momentum of heavy recoil after removal + PB.SetXYZ( (-Pa.X()) , (-Pa.Y()) , (-Pa.Z()) ); + + // Off-shell mass of the bound nucleon from E conservation + // in virtual dissociation of A -> B + a + double buffer = mA*mA + mB*mB - 2*mA*sqrt(mB*mB+Pa.Mag2()) ; + if(buffer<=0) { cout<<"ERROR off shell mass ma_off=\t"<<buffer<<endl; return;} + ma_off = sqrt(buffer); + + //deduced total energies of "a" and "B" in restframe of A + double Ea = sqrt(ma_off*ma_off + Pa.Mag2()); + double EB = sqrt(mB*mB + PB.Mag2()); + + fEnergyImpulsionCM_a = TLorentzVector(Pa,Ea); + fEnergyImpulsionCM_B = TLorentzVector(PB,EB); + + fEnergyImpulsionLab_a = TLorentzVector(Pa,Ea); + fEnergyImpulsionLab_B = TLorentzVector(PB,EB); + fEnergyImpulsionLab_a.Boost(0,0,fEnergyImpulsionLab_A.Beta()); + fEnergyImpulsionLab_B.Boost(0,0,fEnergyImpulsionLab_A.Beta()); + Ea_lab = fEnergyImpulsionLab_a.E(); + EB_lab = fEnergyImpulsionLab_B.E(); + Pa_lab = fEnergyImpulsionLab_a.Vect(); + PB_lab = fEnergyImpulsionLab_B.Vect(); + + + // Scattering part (2-body kinematics) + // virtual cluster of mass "ma_off" scattering on target T + // to give scattered cluster with real mass (ma=m2) + // and scattered target (mT=m1) + + fQValue =ma_off+mT-m1-m2; + + s = ma_off*ma_off + mT*mT + 2*mT*Ea_lab ; + fTotalEnergyImpulsionCM = TLorentzVector(0,0,0,sqrt(s)); + fEcm = sqrt(s) - m1 -m2; + if(fEcm<=0) { cout<<"ERROR Ecm negative =\t"<<fEcm<<endl;Dump(); return;} + + vector<double> theta1; + vector<double> theta2; + vector<double> phi1; + vector<double> phi2; + + //for(int i=0; i<=180; i++){ + int i = 30; + KineR3B(s, ma_off, mT, ma, (double)i); + if(!good) { cout<<"ERROR CM calculations!!!"<<endl; return;} + + cout<<endl; + cout<<"------------------------------------"<<endl; + cout<<"------------ DUMP R3B --------------"<<endl; + cout<<"------------------------------------"<<endl; + cout<<endl; + cout<<"Cluster/recoil momentum (in the beam nucleus frame):"<<endl; + cout<<"Pa=\t("<<Pa.Px()<<","<<Pa.Py()<<","<<Pa.Pz()<<") MeV/c"<<endl; + cout<<"PB=\t("<<PB.Px()<<","<<PB.Py()<<","<<PB.Pz()<<") MeV/c"<<endl; + cout<<endl; + cout<<"Off-shell mass of the bound nucleon from E conservation "<<endl; + cout<<" in virtual dissociation of A -> B + a"<<endl; + cout<<"ma=\t"<<ma<<endl; + cout<<"ma_off=\t"<<ma_off<<endl; + cout<<"mB=\t"<<mB<<endl; + cout<<"Deduced total energies of a and B in restframe of A"<<endl; + cout<<"Ea=\t"<<fEnergyImpulsionCM_a.E()<<"\tMeV"<<endl; + cout<<"EB=\t"<<fEnergyImpulsionCM_B.E()<<"\tMeV"<<endl; + cout<<endl; + cout<<"-- Boosted in lab frame with beam on Z axis --"<<endl; + cout<<"Beta_z=\t"<<fEnergyImpulsionLab_A.Beta()<<endl; + cout<<"Pa_lab=\t("<<Pa_lab.Px()<<","<<Pa_lab.Py()<<","<<Pa_lab.Pz()<<") MeV/c"<<endl; + cout<<"PB_lab=\t("<<PB_lab.Px()<<","<<PB_lab.Py()<<","<<PB_lab.Pz()<<") MeV/c"<<endl; + cout<<"Ea_lab=\t"<<Ea_lab<<"\tMeV"<<endl; + cout<<"EB_lab=\t"<<EB_lab<<"\tMeV"<<endl; + cout<<endl; + cout<<"-- Scattering off virtual cluster a of virtual mass --"<<endl; + cout<<"-- ma_off and energy Ea_lab on target T at rest ------"<<endl; + cout<<"fQValue=\t"<<fQValue<<endl; + cout<<"s=\t"<<s<<endl; + cout<<"Ecm=\t"<<fEcm<<endl; + cout<<endl; + + + TVector3 P1_cm(0.,0.,1.), P2_cm(0.,0.,1.); + P2_cm.SetMag(p_clust); + P2_cm.SetTheta(theta_clust); + //TRandom3 ra; + //ra.SetSeed(0); + //P2_cm.SetPhi(ra.Uniform(-1*TMath::Pi(),+1*TMath::Pi())); + P2_cm.SetPhi(20.*TMath::Pi()/180.); + P1_cm.SetX(-P2_cm.X()); + P1_cm.SetY(-P2_cm.Y()); + P1_cm.SetZ(-P2_cm.Z()); + + cout<<"P1_CM=\t("<<P1_cm.X()<<","<<P1_cm.Y()<<","<<P1_cm.Z()<<")"<<endl; + cout<<"P2_CM=\t("<<P2_cm.X()<<","<<P2_cm.Y()<<","<<P2_cm.Z()<<")"<<endl; + + // Calculate relative to direction of quasi-particle (cluster) + + double beta_cm = -Pa_lab.Mag() / (Ea_lab + mT); + double gamma_cm = 1/sqrt(1-beta_cm*beta_cm); + + pair<double,double> lor_a1 = Lorentz(gamma_cm,beta_cm,e_scat,P1_cm.Z()); + pair<double,double> lor_a2 = Lorentz(gamma_cm,beta_cm,e_clust,P2_cm.Z()); + + P1_cm.SetZ(lor_a1.second); + P2_cm.SetZ(lor_a2.second); + + //Rotating back to beam direction + TVector3 P1_L = Rotations(P1_cm, Pa_lab); + TVector3 P2_L = Rotations(P2_cm, Pa_lab); + + //TVector3 P1_L = P1_cm; + //TVector3 P2_L = P2_cm; + //TVector3 direction = Pa.Unit(); + //P1_L.RotateUz(direction); + //P1_L.RotateUz(direction); + + cout<<"----Calculate variables output------"<<endl; + cout<<"--CM--"<<endl; + cout<<"theta1*=\t"<<theta_scat*180/TMath::Pi()<<endl; + cout<<"theta2*=\t"<<theta_clust*180/TMath::Pi()<<endl; + cout<<"e1*=\t"<<e_scat<<endl; + cout<<"p1*=\t"<<p_scat<<endl; + cout<<"e2*=\t"<<e_clust<<endl; + cout<<"p2*=\t"<<p_clust<<endl; + cout<<"T=\t"<<T<<endl; + cout<<"beta_cm=\t"<<beta_cm<<endl; + cout<<"gamma_cm=\t"<<gamma_cm<<endl; + + cout<<"--LAB (cluster dir)--"<<endl; + cout<<"P1_lab=\t("<<P1_cm.X()<<","<<P1_cm.Y()<<","<<P1_cm.Z()<<")"<<endl; + cout<<"P2_lab=\t("<<P2_cm.X()<<","<<P2_cm.Y()<<","<<P2_cm.Z()<<")"<<endl; + cout<<"Theta1:\t"<<P1_cm.Theta()*180./TMath::Pi()<<endl; + cout<<"Theta2:\t"<<P2_cm.Theta()*180./TMath::Pi()<<endl; + + cout<<"--LAB--"<<endl; + cout<<"Pa_lab=\t("<<Pa_lab.X()<<","<<Pa_lab.Y()<<","<<Pa_lab.Z()<<")"<<endl; + cout<<"P1_L=\t("<<P1_L.X()<<","<<P1_L.Y()<<","<<P1_L.Z()<<")"<<endl; + cout<<"P2_L=\t("<<P2_L.X()<<","<<P2_L.Y()<<","<<P2_L.Z()<<")"<<endl; + cout<<"Theta1L:\t"<<P1_L.Theta()*180./TMath::Pi()<<endl; + cout<<"Theta2L:\t"<<P2_L.Theta()*180./TMath::Pi()<<endl; + cout<<"Phi1L:\t"<<P1_L.Phi()*180./TMath::Pi()<<endl; + cout<<"Phi2L:\t"<<P2_L.Phi()*180./TMath::Pi()<<endl; + + + //cout<<P1_cm.Theta()*180./TMath::Pi()<<"\t"<<P2_cm.Theta()*180./TMath::Pi()<<endl; + //cout<<P1_L.Phi()*180./TMath::Pi()<<"\t"<<P2_L.Phi()*180./TMath::Pi()<<endl; + + theta1.push_back(P1_L.Theta()*180./TMath::Pi()); + theta2.push_back(P2_L.Theta()*180./TMath::Pi()); + + double temp_phi1 = P1_L.Phi(); + double temp_phi2 = P2_L.Phi(); + phi1.push_back(180. + P1_L.Phi()*180./TMath::Pi()); + phi2.push_back(180. + P2_L.Phi()*180./TMath::Pi()); + + //} + TGraph* fTheta2VsTheta1 = new TGraph(theta1.size(),&theta1[0],&theta2[0]); + TGraph* fPhi2VsPhi1 = new TGraph(phi1.size(),&phi1[0],&phi2[0]); + fTheta2VsTheta1->SetName("Theta2VsTheta1"); + fPhi2VsPhi1->SetName("Phi2VsPhi1"); + TFile* f = new TFile("graphs.root","RECREATE"); + fTheta2VsTheta1->Write(); + fPhi2VsPhi1->Write(); + f->Close(); + + +} + +// Calculate elastic scattering kinematics in CM-system (1-target proton, 2-cluster) +void QFS::KineR3B(double s,double m2off,double m1,double m2,double thetacm) +{ + if(thetacm>180 || thetacm<0){ + cout << "\nERROR! ThetaCM (in deg) should be between 0 and 180"<<endl; + return; + } + + e_clust = 0; + p_clust = 0; + theta_clust = 0; + e_scat = 0; + p_scat = 0; + theta_scat = 0; + T = 0; + good = false; + + + double X = s; + double Y = m2off*m2off; + double Z = m1*m1; + double sqrt_s = sqrt(s); + + // Kinematics before the scattering process + // (with one off-shell mass) + double p2_off = sqrt(function(X,Y,Z))/2/sqrt_s; + double p1_off = p2_off; + // CM energies + double e1_off = (s+Z-Y)/2/sqrt_s; + double e2_off = (s+Y-Z)/2/sqrt_s; + + // Now take the real masses (after scattering) + Y = m2*m2; Z = m1*m1; + //And check whether the kinematical function is ok + //for this specific kinematical case + double ERROR_CI = function(X,Y,Z); + if(ERROR_CI <= 0.){ + cout << "\nERROR!!! Kinematical function is negative!"; + return; + } + + // Kinematics after the scattering process + // (with all real masses) + double p2 = sqrt(function(X,Y,Z))/2/sqrt_s; + double p1 = p2; + double e1 = (s+Z-Y)/2/sqrt_s; + double e2 = (s+Y-Z)/2/sqrt_s; + + // Let's consider momentum transfer <t> from the + // target particle 1 to the cluster 2 + double t = 2*(m1*m1 - e1_off*e1 + p1_off*p1*cos(thetacm*TMath::Pi()/180.)); + + //CM scattering angles + double theta1 = thetacm*TMath::Pi()/180.; + double theta2 = TMath::Pi() - theta1; + + e_clust = e2; + p_clust = p2; + theta_clust = theta2; + + e_scat = e1; + p_scat = p1; + theta_scat = theta1; + + T = t; + good = true; + + +} + + + +double QFS::function(double x,double y,double z) +{ + double lambda = x*x + y*y + z*z - 2*x*y - 2*x*z - 2*y*z; + return lambda; +} + +//---- Two consecutive rotations +//first around Z on <phi>, then around new X' on <theta> (1=Pcm, 2=Pa in lab) +TVector3 QFS::Rotations(TVector3 v1,TVector3 v2) +{ + double CT = v2.Z()/v2.Mag(); // cos(theta) of v2 wrt. Z-axis + double ST = sqrt(1-CT*CT); // sin(theta) + double CF = v2.X()/v2.Mag()/ST; + double SF = v2.Y()/v2.Mag()/ST; + + TVector3 v3; + double _v3x = v1.X()*CT*CF - v1.Y()*SF + v1.Z()*ST*CF; + double _v3y = v1.X()*CT*SF + v1.Y()*CF + v1.Z()*ST*SF; + double _v3z = -v1.X()*ST + v1.Z()*CT; + v3.SetXYZ(_v3x,_v3y,_v3z); + + cout<<"--- ROTATION---"<<endl; + cout<<"CT=\t"<<CT<<endl; + cout<<"ST=\t"<<ST<<endl; + cout<<"CF=\t"<<CF<<endl; + cout<<"SF=\t"<<SF<<endl; + cout<<"v3x=\t"<<_v3x<<endl; + cout<<"v3y=\t"<<_v3y<<endl; + cout<<"v3z=\t"<<_v3z<<endl; + return v3; +} + + + +pair<double, double> QFS::Lorentz(double gamma,double beta,double e,double p) +{ + double eL = gamma*e - gamma*beta*p; + double pL = gamma*p - gamma*beta*e; + return make_pair(eL, pL); +} diff --git a/NPLib/Physics/NPQFS.h b/NPLib/Physics/NPQFS.h index b0107b6c85c3def61911987017ee613fa918ed36..0016793dde93bf66fcd5f72c8b332f444be2b78d 100644 --- a/NPLib/Physics/NPQFS.h +++ b/NPLib/Physics/NPQFS.h @@ -1,6 +1,5 @@ #ifndef NPQFS_h #define NPQFS_h -/*****************************************************************************/ /***************************************************************************** * Copyright (C) 2009-2019 this file is part of the NPTool Project * * * @@ -10,29 +9,32 @@ /***************************************************************************** * * - * Original Author : F. Flavigny contact address: flavigny@ipno.in2p3.fr * + * Original Author : F. Flavigny contact address: flavigny@lpccaen.in2p3.fr * * * * Creation Date : April 2019 * - * Last update : April 2019 * + * Last update : Nov 2019 * *---------------------------------------------------------------------------* * Decription: * * This class deal with Quasi Free Scattering Reaction in which a cluster * * or a nucleon is removed from a projectile by interaction with a target * * nucleon (proton target in general) * * * - * Labeling is: * - * A --> i ==> B + (i -> a) => B + 1 + 2 * + * First step (dissociation): A -> B + c * + * Second step (scattering) : c + T -> 1 + 2 * + * Labeling is: * + * * + * A --> T ==> B + (c -> T) => B + 1 + 2 * * * * where: * * + A is the beam nucleus * - * + i is the target nucleon (proton) * + * + T is the target nucleon (proton) * * * * + B is the residual fragment (beam-like) * - * + 1 is the scattered target nucleon (former i) * - * + 2 is the knocked-out cluster/nucleon (noted a) in the intermediate * + * + 1 is the scattered target nucleon (former T) * + * + 2 is the knocked-out cluster/nucleon (noted c) in the intermediate * *---------------------------------------------------------------------------* * Comment: * - * + * + * + Adapted from original event generator from V. Panin (R3B collab) * * * *****************************************************************************/ @@ -41,6 +43,7 @@ // NPL #include "NPNucleus.h" +#include "NPBeam.h" #include "NPInputParser.h" using namespace NPL; @@ -51,7 +54,6 @@ using namespace NPL; #include "TGraph.h" #include "TCanvas.h" #include "TH1F.h" -#include "TRandom3.h" using namespace std; @@ -60,12 +62,167 @@ namespace NPL{ class QFS{ public: // Constructors and Destructors - QFS(){}; - ~QFS(){}; + QFS(); + ~QFS(); private: int fVerboseLevel; + Beam fNucleiA; // Beam (A) + Nucleus fNucleiT; // Target (T) + Nucleus fNucleiB; // Beam-like ejectile (B) + Nucleus fNuclei1; // Target-like ejectile (1) + Nucleus fNuclei2; // Knocked-out nucleon/cluster (2) + double fQValue; // Q-value in MeV + double fEcm; // Ecm in MeV + double fThetaCM; // Center-of-mass theta angle in radian + double fPhiCM; // Center-of-mass Phi angle in radian + double fBeamEnergy; // Beam energy in MeV + double fExcitationA; // Excitation energy in MeV of the beam, useful for isomers + double fExcitationB; // Excitation energy in MeV of beam-like ejectile + double fMomentumSigma; // Width of the momentum distribution (sigma) + TVector3 fInternalMomentum; // Internal momentum of the removed cluster + TH1F* fPerpMomentumHist; // Perpendicular momentum distribution in beam at rest frame + TH1F* fParMomentumHist; // Parallel momentum distribution in beam at rest frame + double fisotropic; + + TGraph* fTheta2VsTheta1; + TGraph* fPhi2VsPhi1; + + // used for MC simulations + bool fshootB; // shoot beam-like ejectile + bool fshoot1; // shoot light ejectile & + bool fshoot2; // shoot light ejectile 2 + + public: + Nucleus GetNucleus(string name, NPL::InputParser parser); + void ReadConfigurationFile(string Path); + void ReadConfigurationFile(NPL::InputParser); + void CalculateVariables(); + void TestR3B(); + void KineRelativistic(double &ThetaLab1, double &PhiLab1, double &KineticEnergyLab1, double &ThetaLab2, double &PhiLab2, double &KineticEnergyLab2); + TVector3 ShootInternalMomentum(); + bool IsAllowed(); + void Dump(); + + private: // intern precompute variable + double mA; + double mB; + double ma_off; + double ma; + double mT; + double m1; + double m2; + + TVector3 Pa, PB, Pa_lab, PB_lab; + double Ea_lab,EB_lab; + + // Lorentz Vector + TLorentzVector fEnergyImpulsionLab_A; + TLorentzVector fEnergyImpulsionLab_B; + TLorentzVector fEnergyImpulsionLab_a; + TLorentzVector fEnergyImpulsionLab_T; + TLorentzVector fEnergyImpulsionLab_1; + TLorentzVector fEnergyImpulsionLab_2; + TLorentzVector fTotalEnergyImpulsionLab; + + TLorentzVector fEnergyImpulsionCM_A; + TLorentzVector fEnergyImpulsionCM_B; + TLorentzVector fEnergyImpulsionCM_a; + TLorentzVector fEnergyImpulsionCM_T; + TLorentzVector fEnergyImpulsionCM_1; + TLorentzVector fEnergyImpulsionCM_2; + TLorentzVector fTotalEnergyImpulsionCM; + + // Impulsion Vector3 + TVector3 fImpulsionLab_a; + TVector3 fImpulsionLab_T; + TVector3 fImpulsionLab_1; + TVector3 fImpulsionLab_2; + + TVector3 fImpulsionCM_a; + TVector3 fImpulsionCM_T; + TVector3 fImpulsionCM_1; + TVector3 fImpulsionCM_2; + + // CM Energy composante & CM impulsion norme + Double_t ECM_a; + Double_t ECM_T; + Double_t ECM_1; + Double_t ECM_2; + Double_t pCM_a; + Double_t pCM_T; + Double_t pCM_1; + Double_t pCM_2; + + // Mandelstam variable + Double_t s; + + // Center of Mass Kinematic + Double_t BetaCM; + + public: + //SETTERS + void SetBeamEnergy(const double& eBeam) {fBeamEnergy = eBeam;} + void SetThetaCM(const double& angle) {fThetaCM = angle;} + void SetPhiCM(const double& angle) {fPhiCM = angle;} + void SetInternalMomentum(const TVector3& mom) {fInternalMomentum = mom;} + void SetMomentumSigma(const double& sigma) {fMomentumSigma = sigma;} + void SetPerpMomentumHist (TH1F* PerpMomentumHist) + {delete fPerpMomentumHist; fPerpMomentumHist = PerpMomentumHist;} + void SetParMomentumHist (TH1F* ParMomentumHist) + {delete fParMomentumHist; fParMomentumHist = ParMomentumHist;} + + //GETTERS + Nucleus* GetNucleusA() {return &fNucleiA;} + Nucleus* GetNucleusT() {return &fNucleiT;} + Nucleus* GetNucleusB() {return &fNucleiB;} + Nucleus* GetNucleus1() {return &fNuclei1;} + Nucleus* GetNucleus2() {return &fNuclei2;} + bool GetShoot1() const {return fshoot1;} + bool GetShoot2() const {return fshoot2;} + bool GetShootB() const {return fshootB;} + double GetThetaCM() const {return fThetaCM;} + double GetMomentumSigma() const {return fMomentumSigma;} + TVector3 GetInternalMomentum() const {return fInternalMomentum;} + + TLorentzVector* GetEnergyImpulsionLab_A() {return &fEnergyImpulsionLab_A;} + TLorentzVector* GetEnergyImpulsionLab_T() {return &fEnergyImpulsionLab_T;} + TLorentzVector* GetEnergyImpulsionLab_a() {return &fEnergyImpulsionLab_a;} + TLorentzVector* GetEnergyImpulsionLab_1() {return &fEnergyImpulsionLab_1;} + TLorentzVector* GetEnergyImpulsionLab_2() {return &fEnergyImpulsionLab_2;} + TLorentzVector* GetEnergyImpulsionLab_B() {return &fEnergyImpulsionLab_B;} + + TLorentzVector* GetEnergyImpulsionCM_A() {return &fEnergyImpulsionCM_A;} + TLorentzVector* GetEnergyImpulsionCM_T() {return &fEnergyImpulsionCM_T;} + TLorentzVector* GetEnergyImpulsionCM_a() {return &fEnergyImpulsionCM_a;} + TLorentzVector* GetEnergyImpulsionCM_1() {return &fEnergyImpulsionCM_1;} + TLorentzVector* GetEnergyImpulsionCM_2() {return &fEnergyImpulsionCM_2;} + TLorentzVector* GetEnergyImpulsionCM_B() {return &fEnergyImpulsionCM_B;} + TGraph* GetTheta2VsTheta1(double AngleStep_CM=1); + TGraph* GetPhi2VsPhi1(double AngleStep_CM=1); + + + + + //TO REMOVE AT SOME POINT WHEN CLASS IS ROBUSTLY TESTED + private: + // R3B Methods and Variables used as a starting point for this class (useful for checks) + void CalculateVariablesOld(); + pair<double,double> Lorentz(double, double, double, double); + double function(double, double, double); + void KineR3B(double, double, double, double, double); + TVector3 Rotations(TVector3,TVector3); + double e_clust; + double p_clust; + double theta_clust; + double e_scat; + double p_scat; + double theta_scat; + bool good; + double T; + + ClassDef(QFS,0) }; } diff --git a/NPLib/Physics/NPReaction.cxx b/NPLib/Physics/NPReaction.cxx index 766ceca7750095b7f9f673ce3944ddf05c7ccd6a..566194f56458581b04e8dd22f16548e31bec6c4c 100644 --- a/NPLib/Physics/NPReaction.cxx +++ b/NPLib/Physics/NPReaction.cxx @@ -87,7 +87,6 @@ ClassImp(Reaction) fshoot3=true; fshoot4=true; fUseExInGeant4=true; - RandGen=new TRandom3(); fLabCrossSection=false; // flag if the provided cross-section is in the lab or not @@ -156,7 +155,6 @@ Reaction::Reaction(string reaction){ fshoot3=true; fshoot4=true; - RandGen=new TRandom3(); fLabCrossSection=false; @@ -357,7 +355,7 @@ double Reaction::EnergyLabFromThetaLab(double ThetaLab){ if(B>D) { ThetaLabMax = asin(sqrt(D/B)); - if(RandGen->Rndm()<0.5) sign=-1; + if(gRandom->Rndm()<0.5) sign=-1; } if(ThetaLab>ThetaLabMax) return -1; diff --git a/NPLib/Physics/NPReaction.h b/NPLib/Physics/NPReaction.h index 3808c20a4abeceb138f5a834d810062c892bd3ac..a30118af258ee1cd12c4c2c44e152077ded37790 100644 --- a/NPLib/Physics/NPReaction.h +++ b/NPLib/Physics/NPReaction.h @@ -44,7 +44,7 @@ using namespace NPL; #include "TGraph.h" #include "TCanvas.h" #include "TH1F.h" -#include "TRandom3.h" +#include "TRandom.h" using namespace std; @@ -65,7 +65,7 @@ namespace NPL{ void ReadConfigurationFile(NPL::InputParser); private: - TRandom3* RandGen; + TRandom* RandGen; private: int fVerboseLevel; diff --git a/NPLib/Physics/TReactionConditions.cxx b/NPLib/Physics/TReactionConditions.cxx index 31e8a1d1d77d9d2c3c4b5db0a5d07aac0411d613..0a2fa85cce65c6f9943fe709d5af60a67fa410b4 100644 --- a/NPLib/Physics/TReactionConditions.cxx +++ b/NPLib/Physics/TReactionConditions.cxx @@ -49,6 +49,7 @@ void TReactionConditions::Clear(){ fRC_Vertex_Position_Z = -1; fRC_ThetaCM = -1; + fRC_Internal_Momentum = {-1, -1, -1}; // emmitted particles fRC_Particle_Name.clear(); @@ -81,6 +82,11 @@ void TReactionConditions::Dump() const{ << fRC_Vertex_Position_X << " ; " << fRC_Vertex_Position_Y << " ; " << fRC_Vertex_Position_Z << ")" << endl; + cout << "\t If QFS, internal momentum, otherwise unused (-1) : ( " + << fRC_Internal_Momentum.X() << " ; " + << fRC_Internal_Momentum.Y() << " ; " + << fRC_Internal_Momentum.Z() << ")" << endl; + // emmitted particle unsigned int size = fRC_Particle_Name.size(); diff --git a/NPLib/Physics/TReactionConditions.h b/NPLib/Physics/TReactionConditions.h index cf8936209fcb6d522ed81b5e819680529c6733b2..307af4ad2143c808e047966cd0ec377c635601c8 100644 --- a/NPLib/Physics/TReactionConditions.h +++ b/NPLib/Physics/TReactionConditions.h @@ -59,6 +59,7 @@ private: double fRC_ExcitationEnergy3; double fRC_ExcitationEnergy4; double fRC_ThetaCM; + TVector3 fRC_Internal_Momentum; // emmitted particles vector<string> fRC_Particle_Name; vector<double> fRC_Theta; @@ -92,6 +93,7 @@ public: void SetExcitationEnergy3 (const double& Ex) {fRC_ExcitationEnergy3=Ex;};//! void SetExcitationEnergy4 (const double& Ex) {fRC_ExcitationEnergy4=Ex;};//! void SetThetaCM (const double & ThetaCM) {fRC_ThetaCM = ThetaCM;}//! + void SetInternalMomentum (const TVector3& IntMom) {fRC_Internal_Momentum = IntMom;}//! // emmitted particles void SetParticleName (const string & Particle_Name) {fRC_Particle_Name.push_back(Particle_Name);}//! @@ -118,6 +120,7 @@ public: double GetExcitation3 () const {return fRC_ExcitationEnergy3 ;}//! double GetExcitation4 () const {return fRC_ExcitationEnergy4 ;}//! double GetThetaCM () const {return fRC_ThetaCM;}//! + TVector3 GetInternalMomentum () const {return fRC_Internal_Momentum;}//! // emmitted particles int GetParticleMultiplicity() const {return fRC_Kinetic_Energy.size();}//! @@ -136,14 +139,20 @@ public: double GetThetaLab_WorldFrame(const int i) const{ return (GetParticleDirection(i).Theta())/deg; } - - double GetPhiLab_WorldFrame (const int i) const { - return (GetParticleDirection(i).Phi())/deg; - } - double GetThetaLab_BeamFrame (const int i) const{ return (GetParticleDirection(i).Angle(GetBeamDirection()))/deg; } + + double GetPhiLab_WorldFrame (const int i) const { + return (M_PI + GetParticleDirection(i).Phi())/deg; + // to have Phi in [0,2pi]] and not [-pi,pi]] + } + double GetPhiLab_BeamFrame (const int i) const{ + TVector3 rot = GetParticleDirection(i); + rot.RotateUz(GetBeamDirection()); + return (M_PI + rot.Phi())/deg; + } + unsigned int GetEmittedMult() const {return fRC_Particle_Name.size();} diff --git a/NPLib/TrackReconstruction/CMakeLists.txt b/NPLib/TrackReconstruction/CMakeLists.txt index 7b71a04dc59dd8877f5930c939e056c631c9e36c..1b61b7ecb9ed0fedb0e7c677ac93a740734e158b 100644 --- a/NPLib/TrackReconstruction/CMakeLists.txt +++ b/NPLib/TrackReconstruction/CMakeLists.txt @@ -1,8 +1,8 @@ -add_custom_command(OUTPUT NPRansacDict.cxx COMMAND ../scripts/build_dict.sh NPRansac.h NPRansacDict.cxx NPRansac.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS NPRansac.h) +add_custom_command(OUTPUT NPRansacDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPRansac.h NPRansacDict.cxx NPRansac.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS NPRansac.h) -add_custom_command(OUTPUT NPClusterDict.cxx COMMAND ../scripts/build_dict.sh NPCluster.h NPClusterDict.cxx NPCluster.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS NPCluster.h) +add_custom_command(OUTPUT NPClusterDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPCluster.h NPClusterDict.cxx NPCluster.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS NPCluster.h) -add_custom_command(OUTPUT TrackingDict.cxx COMMAND ../scripts/build_dict.sh Tracking.h TrackingDict.cxx Tracking.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS Tracking.h) +add_custom_command(OUTPUT TrackingDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh Tracking.h TrackingDict.cxx Tracking.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS Tracking.h) add_library(NPTrackReconstruction SHARED NPRansac.cxx NPCluster.cxx NPTrack.cxx Tracking.cxx NPRansacDict.cxx NPClusterDict.cxx TrackingDict.cxx) target_link_libraries(NPTrackReconstruction ${ROOT_LIBRARIES} NPCore) diff --git a/NPLib/TrackReconstruction/Tracking.cxx b/NPLib/TrackReconstruction/Tracking.cxx index 02bda352a39d2814fe2ec96193cfe7af00f61eae..3edd675d5d302d1fd0f55f0fed83fecf46bb7763 100644 --- a/NPLib/TrackReconstruction/Tracking.cxx +++ b/NPLib/TrackReconstruction/Tracking.cxx @@ -48,427 +48,446 @@ NPL::Tracking::~Tracking() /* } */ int NPL::Tracking::Hough_modified(vector<double> *x,vector<double> *y,vector<double> *q, vector<double> *x_out,vector<double> *y_out, vector<double> *q_out, vector<int> *ringbool) { - double bint1=2.; - double bint2=2.; - int maxt = 360.; - int mint = 0.; - int nt1=(maxt-mint)/bint1; - int nt2=(maxt-mint)/bint1; - - double PI = TMath::Pi(); - double Rint = 45.2; - double Rext = 45.2 + 18*2.1; - int filter_result = 0; - - TH2F *hp_xy = new TH2F("hp_xy","hp_xy",nt1,mint,maxt,nt2,mint,maxt); - TH2F *hpDiag_xy = new TH2F("hpDiag_xy","hpDiag_xy",nt1,mint,maxt,nt2,mint,maxt); - - double max_xy; - - vector<double> xTemp, yTemp, qTemp; - - double theta1, theta2, xt1, yt1, xt2, yt2; - double line0=0., line1=0.; - double delta=0., AA=0., BB=0., CC=0.; - double maxtheta1=0., maxtheta2=0., xmax1=0., ymax1=0., xmax2=0., ymax2=0.; - double par0=0., par1=0.; - double r_mm=0.; - int ringsum=0; - bool maxfound = false; - - for(unsigned int i=0;i<x->size();i++){ - xTemp.push_back(x->at(i)); - yTemp.push_back(y->at(i)); - qTemp.push_back(q->at(i)); - + double bint1=2.; + double bint2=2.; + int maxt = 360.; + int mint = 0.; + int nt1=(maxt-mint)/bint1; + int nt2=(maxt-mint)/bint1; + + double PI = TMath::Pi(); + double Rint = 45.2; + double Rext = 45.2 + 18*2.1; + int filter_result = 0; + + TH2F *hp_xy = new TH2F("hp_xy","hp_xy",nt1,mint,maxt,nt2,mint,maxt); + TH2F *hpDiag_xy = new TH2F("hpDiag_xy","hpDiag_xy",nt1,mint,maxt,nt2,mint,maxt); + + double max_xy; + + vector<double> xTemp, yTemp, qTemp; + + double theta1, theta2, xt1, yt1, xt2, yt2; + double line0=0., line1=0.; + double delta=0., AA=0., BB=0., CC=0.; + double maxtheta1=0., maxtheta2=0., xmax1=0., ymax1=0., xmax2=0., ymax2=0.; + double par0=0., par1=0.; + double r_mm=0.; + int ringsum=0; + bool maxfound = false; + + for(unsigned int i=0;i<x->size();i++){ + xTemp.push_back(x->at(i)); + yTemp.push_back(y->at(i)); + qTemp.push_back(q->at(i)); + //Loop of indices - for(int j=0;j<nt1;j++){ - + for(int j=0;j<nt1;j++){ + theta1 = (j+0.5)*bint1 + mint; - xt1 = Rint * TMath::Cos(theta1*PI/180.); - yt1 = Rint * TMath::Sin(theta1*PI/180.); - line1 = (yt1 - y->at(i))/(xt1 - x->at(i)); - line0 = yt1 - xt1 * line1; - AA = 1 + line1*line1; - BB = 2*line0*line1; - CC = line0*line0 - Rext*Rext; - - delta = BB*BB - 4*AA*CC; - + xt1 = Rint * TMath::Cos(theta1*PI/180.); + yt1 = Rint * TMath::Sin(theta1*PI/180.); + line1 = (yt1 - y->at(i))/(xt1 - x->at(i)); + line0 = yt1 - xt1 * line1; + AA = 1 + line1*line1; + BB = 2*line0*line1; + /* CC = line0*line0 - Rext; // Warning likely Error : Rext and not Rext^2 (Cyril) */ + CC = line0*line0 - Rext*Rext; // Warning likely Error : Rext and not Rext^2 (Cyril) + + delta = BB*BB - 4*AA*CC; + if(delta>=0){ - xt2 = (-BB - sqrt(delta))/(2*AA); - yt2 = line0 + line1*xt2; - + xt2 = (-BB - sqrt(delta))/(2*AA); + yt2 = line0 + line1*xt2; if(xt2<=0) theta2= 180 - asin(yt2/Rext)*180/PI; - else if(xt2>0){ - if(yt2>0) theta2= asin(yt2/Rext)*180/PI; + if(yt2>0) theta2= asin(yt2/Rext)*180/PI; else if(yt2<=0) theta2= 360 + asin(yt2/Rext)*180/PI; - } - - if( (xt1*x->at(i) + yt1*y->at(i))>=0 && (xt2*x->at(i) + yt2*y->at(i))>=0 && (xt1*xt2+yt1*yt2)>=0){ - hp_xy->Fill(theta1,theta2); - if(abs(theta1-theta2)<=10) hpDiag_xy->Fill(theta1,theta2); - } - else{ - if(delta!=0){ - xt2 = (-BB + sqrt(delta))/(2*AA); - yt2 = line0 + line1*xt2; - + } + if( (xt1*x->at(i) + yt1*y->at(i))>=0 && (xt2*x->at(i) + yt2*y->at(i))>=0 && (xt1*xt2+yt1*yt2)>=0){ + hp_xy->Fill(theta1,theta2); + if(abs(theta1-theta2)<=10) hpDiag_xy->Fill(theta1,theta2); + } + else{ + if(delta!=0){ + xt2 = (-BB + sqrt(delta))/(2*AA); + yt2 = line0 + line1*xt2; if(xt2<=0) theta2= 180 - asin(yt2/Rext)*180/PI; - else if(xt2>0){ if(yt2>0) theta2= asin(yt2/Rext)*180/PI; else if(yt2<=0) theta2= 360 + asin(yt2/Rext)*180/PI; - } - + } if( (xt1*x->at(i) + yt1*y->at(i))>=0 && (xt2*x->at(i) + yt2*y->at(i))>=0 && (xt1*xt2+yt1*yt2)>=0){ - hp_xy->Fill(theta1,theta2); + hp_xy->Fill(theta1,theta2); if(abs(theta1-theta2)<=10) hpDiag_xy->Fill(theta1,theta2); - } - } - } - } // end if delta>=0 - } // end loop on indices - } // end loop on pads - + } + } + } + } // end if delta>=0 + } // end loop on indices + } // end loop on pads + x->clear(); - y->clear(); - q->clear(); - - if(hpDiag_xy->GetMaximum()>=10) max_xy = hpDiag_xy->GetMaximum(); -// cout << "Max taken in diag... withh value=" << max_xy << endl; - else max_xy = hp_xy->GetMaximum(); - - for(int ii=0; ii<nt1; ii++){ - if(maxfound ==true) break; - for(int jj=0; jj<nt2; jj++){ - if(hp_xy->GetBinContent(ii+1, jj+1) == max_xy){ - maxtheta1 = (ii+0.5)*bint1 + mint; - maxtheta2 = (jj+0.5)*bint2 + mint; - maxfound = true; - //cout << "xy: theta max are " << maxtheta1 << " , " << maxtheta2 << endl; - } - if(maxfound ==true) break; - } - } - - xmax1 = Rint * TMath::Cos(maxtheta1*PI/180.); - ymax1 = Rint * TMath::Sin(maxtheta1*PI/180.); - xmax2 = Rext * TMath::Cos(maxtheta2*PI/180.); - ymax2 = Rext * TMath::Sin(maxtheta2*PI/180.); - - // xy PEAK - par1 = (ymax2-ymax1)/(xmax2-xmax1); - par0 = (ymax1 - xmax1*par1); - //Selection of x,y points IN the maxmean+/-1 found in Obertelli transform of xy plane - for(unsigned int i=0;i<xTemp.size();i++){ - if( (abs(par1*xTemp[i]-yTemp[i]+par0)/sqrt(1+par1*par1))<= 6 && ((xmax1*xTemp[i] + ymax1*yTemp[i]) >= 0) && ((xmax2*xTemp[i] + ymax2*yTemp[i]) >= 0) && ((xmax1*xmax2 + ymax1*ymax2) >= 0)){ -// couti<< "Taken points= " << xTemp[i] << " , " << yTemp[i] << " , " << zTemp[i] << endl; -// hcnew_xy->Fill(xTemp[i],yTemp[i],qTemp[i]); - x_out->push_back(xTemp[i]); - y_out->push_back(yTemp[i]); - q_out->push_back(qTemp[i]); - filter_result++; - /* r_mm = sqrt(xTemp[i]*xTemp[i]+yTemp[i]*yTemp[i]); */ + y->clear(); + q->clear(); + + if(hpDiag_xy->GetMaximum()>=10) max_xy = hpDiag_xy->GetMaximum(); + // cout << "Max taken in diag... withh value=" << max_xy << endl; + else max_xy = hp_xy->GetMaximum(); + + for(int ii=0; ii<nt1; ii++){ + if(maxfound ==true) break; + for(int jj=0; jj<nt2; jj++){ + if(hp_xy->GetBinContent(ii+1, jj+1) == max_xy){ + maxtheta1 = (ii+0.5)*bint1 + mint; + maxtheta2 = (jj+0.5)*bint2 + mint; + maxfound = true; + //cout << "xy: theta max are " << maxtheta1 << " , " << maxtheta2 << endl; + } + if(maxfound ==true) break; + } + } + + xmax1 = Rint * TMath::Cos(maxtheta1*PI/180.); + ymax1 = Rint * TMath::Sin(maxtheta1*PI/180.); + xmax2 = Rext * TMath::Cos(maxtheta2*PI/180.); + ymax2 = Rext * TMath::Sin(maxtheta2*PI/180.); + + // xy PEAK + par1 = (ymax2-ymax1)/(xmax2-xmax1); + par0 = (ymax1 - xmax1*par1); + //Selection of x,y points IN the maxmean+/-1 found in Obertelli transform of xy plane + for(unsigned int i=0;i<xTemp.size();i++){ + if( (abs(par1*xTemp[i]-yTemp[i]+par0)/sqrt(1+par1*par1))<= 6 && ((xmax1*xTemp[i] + ymax1*yTemp[i]) >= 0) && ((xmax2*xTemp[i] + ymax2*yTemp[i]) >= 0) && ((xmax1*xmax2 + ymax1*ymax2) >= 0)){ + // couti<< "Taken points= " << xTemp[i] << " , " << yTemp[i] << " , " << zTemp[i] << endl; + // hcnew_xy->Fill(xTemp[i],yTemp[i],qTemp[i]); + x_out->push_back(xTemp[i]); + y_out->push_back(yTemp[i]); + q_out->push_back(qTemp[i]); + filter_result++; + /* r_mm = sqrt(xTemp[i]*xTemp[i]+yTemp[i]*yTemp[i]); */ /* if(r_mm<(45.2+5*2.1)) ringsum++; */ // commented by Cyril - - } - else{ - x->push_back(xTemp[i]); - y->push_back(yTemp[i]); - q->push_back(qTemp[i]); - - } - } - + } + else{ + x->push_back(xTemp[i]); + y->push_back(yTemp[i]); + q->push_back(qTemp[i]); + } + } /* cout << "ringsum = " << ringsum << endl; */ /* cout << "Filter_result = " << filter_result << endl; */ - for(int ip=0; ip<filter_result; ip++){ - /* if(ringsum>2) ringbool->push_back(1); */ - /* else ringbool->push_back(0); */ - ringbool->push_back(1); - } - - delete hp_xy; - delete hpDiag_xy; - - return filter_result; - + for(int ip=0; ip<filter_result; ip++){ + /* if(ringsum>2) ringbool->push_back(1); */ + /* else ringbool->push_back(0); */ + ringbool->push_back(1); + } + delete hp_xy; + delete hpDiag_xy; + return filter_result; } double NPL::Tracking::FitFunction(double *x, double *p) { - double val=p[0]+p[1]*x[0]; - return(val); + double val=p[0]+p[1]*x[0]; + return(val); } void NPL::Tracking::FindStart(double pStart[4], double chi[2], int fitStatus[2],TGraph *grxz, TGraph *gryz) { - double par1D[2]; - TF1 *myfit1 = new TF1("myfit1","[0]+[1]*x", -100,500); - myfit1->SetParameter(0,0); - myfit1->SetParameter(1,10); - fitStatus[0] =0; - grxz->Fit(myfit1,"RQM"); - chi[0]=myfit1->GetChisquare(); - par1D[0]=myfit1->GetParameter(0); - par1D[1]=myfit1->GetParameter(1); - pStart[0]=par1D[0]; - pStart[1]=par1D[1]; - fitStatus[1] =0; - gryz->Fit(myfit1,"RQM"); - chi[1]=myfit1->GetChisquare(); - par1D[0]=myfit1->GetParameter(0); - par1D[1]=myfit1->GetParameter(1); - pStart[2]=par1D[0]; - pStart[3]=par1D[1]; - //AC 07/12/14 - delete myfit1; + double par1D[2]; + TF1 *myfit1 = new TF1("myfit1","[0]+[1]*x", -100,500); + myfit1->SetParameter(0,0); + myfit1->SetParameter(1,10); + fitStatus[0] =0; + grxz->Fit(myfit1,"RQM"); + chi[0]=myfit1->GetChisquare(); + par1D[0]=myfit1->GetParameter(0); + par1D[1]=myfit1->GetParameter(1); + pStart[0]=par1D[0]; + pStart[1]=par1D[1]; + fitStatus[1] =0; + gryz->Fit(myfit1,"RQM"); + chi[1]=myfit1->GetChisquare(); + par1D[0]=myfit1->GetParameter(0); + par1D[1]=myfit1->GetParameter(1); + pStart[2]=par1D[0]; + pStart[3]=par1D[1]; + //AC 07/12/14 + delete myfit1; } // Calculation of the distance line-point double NPL::Tracking::distance2(double x,double y,double z, double *p) { - // distance line point is D= | (xp-x0) cross ux | - // where ux is direction of line and x0 is a point in the line (like t = 0) - ROOT::Math::XYZVector xp(x,y,z); //point of the track - ROOT::Math:: XYZVector x0(p[0], p[2], 0. ); - ROOT::Math::XYZVector x1(p[0] + p[1], p[2] + p[3], 1. ); //line - ROOT::Math::XYZVector u = (x1-x0).Unit(); - double d2 = ((xp-x0).Cross(u)) .Mag2(); - return d2; + // distance line point is D= | (xp-x0) cross ux | + // where ux is direction of line and x0 is a point in the line (like t = 0) + ROOT::Math::XYZVector xp(x,y,z); //point of the track + ROOT::Math:: XYZVector x0(p[0], p[2], 0. ); + ROOT::Math::XYZVector x1(p[0] + p[1], p[2] + p[3], 1. ); //line + ROOT::Math::XYZVector u = (x1-x0).Unit(); + double d2 = ((xp-x0).Cross(u)) .Mag2(); + return d2; } //void Hough_3D(TCanvas *c1, vector<double> *x,vector<double> *y,vector<double> *z,vector<double> *q, vector<double> *x_out,vector<double> *y_out,vector<double> *z_out,vector<double> *q_out) { void NPL::Tracking::Hough_3D(vector<double> *x,vector<double> *y,vector<double> *z,vector<double> *q,vector<double> *x_out,vector<double> *y_out,vector<double> *z_out,vector<double> *q_out) { int nt_xy=180; - int nt_xz=180; - int nt_yz=180; - int nr_xy=45; - int nr_xz=300; - int nr_yz=300; - double bint_xy=2.; - double bint_xz=2.; - double bint_yz=2.; - double binr_xy=3.; - double binr_xz=3.; - double binr_yz=3.; - int nt,nr; - double PI = TMath::Pi(); - - double rho_xy,rho_xz,rho_yz; - double theta_xy,theta_xz,theta_yz; - - TH2F *hp_xy = new TH2F("hp_xy","hp_xy",nt_xy,0,180,nr_xy,-1*nr_xy,nr_xy); - TH2F *hp_xz = new TH2F("hp_xz","hp_xz",nt_xz,0,180,nr_xz,-1*nr_xz,nr_xz); - TH2F *hp_yz = new TH2F("hp_yz","hp_yz",nt_yz,0,180,nr_yz,-1*nr_yz,nr_yz); - + int nt_xz=180; + int nt_yz=180; + int nr_xy=45; + int nr_xz=300; + int nr_yz=300; + double bint_xy=2.; + double bint_xz=2.; + double bint_yz=2.; + double binr_xy=3.; + double binr_xz=3.; + double binr_yz=3.; + int nt,nr; + double PI = TMath::Pi(); + + double rho_xy,rho_xz,rho_yz; + double theta_xy,theta_xz,theta_yz; + + TH2F *hp_xy = new TH2F("hp_xy","hp_xy",nt_xy,0,180,nr_xy,-1*nr_xy,nr_xy); + TH2F *hp_xz = new TH2F("hp_xz","hp_xz",nt_xz,0,180,nr_xz,-1*nr_xz,nr_xz); + TH2F *hp_yz = new TH2F("hp_yz","hp_yz",nt_yz,0,180,nr_yz,-1*nr_yz,nr_yz); + // int npeaks_xy, npeaks_xz, npeaks_yz; vector<double> thetapeaks_xy, rpeaks_xy, thetapeaks_xz, rpeaks_xz, thetapeaks_yz, rpeaks_yz; - double max_xy, max_xz, max_yz; - double rmean_xy=0, thetamean_xy=0, rmean_xz=0, thetamean_xz=0, rmean_yz=0, thetamean_yz=0; - - double r0_xy=0., r0_xz=0., r0_yz=0., rmin_xy=0., rmin_xz=0., rmin_yz=0., rmax_xy=0., rmax_xz=0., rmax_yz=0.; - double tmin=0., tmax=0.; - double rinf=0., rsup=0.; - - nt=nt_xy; - nr=nr_xy; - if(nt<nt_xz)nt=nt_xz; - if(nr<nr_xz)nr=nr_xz; - if(nt<nt_yz)nt=nt_yz; - if(nr<nr_yz)nr=nr_yz; - + double max_xy, max_xz, max_yz; + double rmean_xy=0, thetamean_xy=0, rmean_xz=0, thetamean_xz=0, rmean_yz=0, thetamean_yz=0; + + double r0_xy=0., r0_xz=0., r0_yz=0., rmin_xy=0., rmin_xz=0., rmin_yz=0., rmax_xy=0., rmax_xz=0., rmax_yz=0.; + double tmin=0., tmax=0.; + double rinf=0., rsup=0.; + + nt=nt_xy; + nr=nr_xy; + if(nt<nt_xz)nt=nt_xz; + if(nr<nr_xz)nr=nr_xz; + if(nt<nt_yz)nt=nt_yz; + if(nr<nr_yz)nr=nr_yz; + for(unsigned int i=0;i<x->size();i++) - { - //Fill coordinate space histograms for plots - //Loop of indices and fill Histograms + { + //Fill coordinate space histograms for plots + //Loop of indices and fill Histograms for(int j=0;j<nt;j++) - { - + { //xy - theta_xy = j*180./nt_xy; - - /* cout <<y->at(i) << endl; */ + theta_xy = j*180./nt_xy; rho_xy = x->at(i)*TMath::Cos(theta_xy*PI/180.)+y->at(i)*TMath::Sin(theta_xy*PI/180.); if(abs(theta_xy)<180. && abs(rho_xy)<nr_xy) - { - hp_xy->Fill(theta_xy,rho_xy); - } - - //xz - theta_xz = j*180./nt_xz; - rho_xz = z->at(i)*TMath::Cos(theta_xz*PI/180.)+x->at(i)*TMath::Sin(theta_xz*PI/180.); - if(abs(theta_xz)<180. && abs(rho_xz)<nr_xz) - { - hp_xz->Fill(theta_xz,rho_xz); - } - - //yz - theta_yz = j*180./nt_yz; - rho_yz = z->at(i)*TMath::Cos(theta_yz*PI/180.)+y->at(i)*TMath::Sin(theta_yz*PI/180.); - if(abs(theta_yz)<180. && abs(rho_yz)<nr_yz) - { - hp_yz->Fill(theta_yz,rho_yz); - } - } - } - - max_xy = hp_xy->GetMaximum(); - max_xz = hp_xz->GetMaximum(); - max_yz = hp_yz->GetMaximum(); - - for(int ii=0; ii<nt; ii++) - { - for(int jj=0; jj<nr; jj++) - { - if(hp_xy->GetBinContent(ii+1, jj+1) == max_xy && jj<nr_xy) - { - thetapeaks_xy.push_back((ii+0.5)*nt_xy/nt); - rpeaks_xy.push_back((jj+0.5)*2 - nr_xy); - rmean_xy += rpeaks_xy.back(); - thetamean_xy += thetapeaks_xy.back(); - } - if(hp_xz->GetBinContent(ii+1, jj+1) == max_xz) - { - thetapeaks_xz.push_back((ii+0.5)*nt_xz/nt); - rpeaks_xz.push_back((jj+0.5)*2 - nr_xz); - rmean_xz += rpeaks_xz.back(); - thetamean_xz += thetapeaks_xz.back(); - } - if(hp_yz->GetBinContent(ii+1, jj+1) == max_yz) - { - thetapeaks_yz.push_back((ii+0.5)*nt_yz/nt); - rpeaks_yz.push_back((jj+0.5)*2 - nr_yz); - rmean_yz += rpeaks_yz.back(); - thetamean_yz += thetapeaks_yz.back(); - } - } - } - - // xy PEAK - rmean_xy = rmean_xy / rpeaks_xy.size(); - thetamean_xy = thetamean_xy / thetapeaks_xy.size(); - - // xz PEAK - rmean_xz = rmean_xz / rpeaks_xz.size(); - thetamean_xz = thetamean_xz / thetapeaks_xz.size(); - - // yz PEAK - rmean_yz = rmean_yz / rpeaks_yz.size(); - thetamean_yz = thetamean_yz / thetapeaks_yz.size(); - - rmean_xy = rpeaks_xy[0]; - thetamean_xy = thetapeaks_xy[0]; - rmean_xz = rpeaks_xz[0]; - thetamean_xz = thetapeaks_xz[0]; - rmean_yz = rpeaks_yz[0]; - thetamean_yz = thetapeaks_yz[0]; - - //Selection of x,y,z points COMMON to the 3 maxmean+/-1 found in Hough spaces for xy, xz and yz spaces - for(unsigned int i=0;i<x->size();i++) - { - r0_xy = x->at(i)*TMath::Cos(thetamean_xy*PI/180.)+y->at(i)*TMath::Sin(thetamean_xy*PI/180.); - tmin = thetamean_xy-bint_xy; - tmax = thetamean_xy+bint_xy; - if((tmin)<0) tmin = tmin + 180.; - if((tmax)>180) tmax = tmax - 180.; - rmin_xy = x->at(i)*TMath::Cos(tmin*PI/180.)+y->at(i)*TMath::Sin(tmin*PI/180.); - rmax_xy = x->at(i)*TMath::Cos(tmax*PI/180.)+y->at(i)*TMath::Sin(tmax*PI/180.); - - rinf = min( rmean_xy - binr_xy, rmean_xy + binr_xy); - rsup = max( rmean_xy - binr_xy, rmean_xy + binr_xy); - if((r0_xy>=rinf || rmin_xy>=rinf || rmax_xy>=rinf) && (r0_xy<=rsup || rmin_xy<=rsup || rmax_xy<=rsup)) - { - r0_xz = z->at(i)*TMath::Cos(thetamean_xz*PI/180.)+x->at(i)*TMath::Sin(thetamean_xz*PI/180.); - tmin = thetamean_xz-bint_xz; - tmax = thetamean_xz+bint_xz; - if((tmin)<0) tmin = tmin + 180.; - if((tmax)>180) tmax = tmax - 180.; - rmin_xz = z->at(i)*TMath::Cos(tmin*PI/180.)+x->at(i)*TMath::Sin(tmin*PI/180.); - rmax_xz = z->at(i)*TMath::Cos(tmax*PI/180.)+x->at(i)*TMath::Sin(tmax*PI/180.); - - rinf = min( rmean_xz - binr_xz, rmean_xz + binr_xz); - rsup = max( rmean_xz - binr_xz, rmean_xz + binr_xz); - - if((r0_xz>=rinf || rmin_xz>=rinf || rmax_xz>=rinf) && (r0_xz<=rsup || rmin_xz<=rsup || rmax_xz<=rsup)) - { - r0_yz = z->at(i)*TMath::Cos(thetamean_yz*PI/180.)+y->at(i)*TMath::Sin(thetamean_yz*PI/180.); - tmin = thetamean_yz-bint_yz; - tmax = thetamean_yz+bint_yz; - if((tmin)<0) tmin = tmin + 180.; - if((tmax)>180) tmax = tmax - 180.; - rmin_yz = z->at(i)*TMath::Cos(tmin*PI/180.)+y->at(i)*TMath::Sin(tmin*PI/180.); - rmax_yz = z->at(i)*TMath::Cos(tmax*PI/180.)+y->at(i)*TMath::Sin(tmax*PI/180.); - - rinf = min( rmean_yz - binr_yz, rmean_yz + binr_yz); - rsup = max( rmean_yz - binr_yz, rmean_yz + binr_yz); - - if((r0_yz>=rinf || rmin_yz>=rinf || rmax_yz>=rinf) && (r0_yz<=rsup || rmin_yz<=rsup || rmax_yz<=rsup)) - { - x_out->push_back(x->at(i)); - y_out->push_back(y->at(i)); - z_out->push_back(z->at(i)); - q_out->push_back(q->at(i)); - } - } - } - - } - delete hp_xy; - delete hp_xz; - delete hp_yz; - + { + hp_xy->Fill(theta_xy,rho_xy); + } + + //xz + theta_xz = j*180./nt_xz; + rho_xz = z->at(i)*TMath::Cos(theta_xz*PI/180.)+x->at(i)*TMath::Sin(theta_xz*PI/180.); + if(abs(theta_xz)<180. && abs(rho_xz)<nr_xz) + { + hp_xz->Fill(theta_xz,rho_xz); + } + + //yz + theta_yz = j*180./nt_yz; + rho_yz = z->at(i)*TMath::Cos(theta_yz*PI/180.)+y->at(i)*TMath::Sin(theta_yz*PI/180.); + if(abs(theta_yz)<180. && abs(rho_yz)<nr_yz) + { + hp_yz->Fill(theta_yz,rho_yz); + } + } + } + + max_xy = hp_xy->GetMaximum(); + max_xz = hp_xz->GetMaximum(); + max_yz = hp_yz->GetMaximum(); + + for(int ii=0; ii<nt; ii++) + { + for(int jj=0; jj<nr; jj++) + { + if(hp_xy->GetBinContent(ii+1, jj+1) == max_xy && jj<nr_xy) + { + thetapeaks_xy.push_back((ii+0.5)*nt_xy/nt); + rpeaks_xy.push_back((jj+0.5)*2 - nr_xy); + rmean_xy += rpeaks_xy.back(); + thetamean_xy += thetapeaks_xy.back(); + } + if(hp_xz->GetBinContent(ii+1, jj+1) == max_xz) + { + thetapeaks_xz.push_back((ii+0.5)*nt_xz/nt); + rpeaks_xz.push_back((jj+0.5)*2 - nr_xz); + rmean_xz += rpeaks_xz.back(); + thetamean_xz += thetapeaks_xz.back(); + } + if(hp_yz->GetBinContent(ii+1, jj+1) == max_yz) + { + thetapeaks_yz.push_back((ii+0.5)*nt_yz/nt); + rpeaks_yz.push_back((jj+0.5)*2 - nr_yz); + rmean_yz += rpeaks_yz.back(); + thetamean_yz += thetapeaks_yz.back(); + } + } + } + + // xy PEAK + rmean_xy = rmean_xy / rpeaks_xy.size(); + thetamean_xy = thetamean_xy / thetapeaks_xy.size(); + + // xz PEAK + rmean_xz = rmean_xz / rpeaks_xz.size(); + thetamean_xz = thetamean_xz / thetapeaks_xz.size(); + + // yz PEAK + rmean_yz = rmean_yz / rpeaks_yz.size(); + thetamean_yz = thetamean_yz / thetapeaks_yz.size(); + + rmean_xy = rpeaks_xy[0]; + thetamean_xy = thetapeaks_xy[0]; + rmean_xz = rpeaks_xz[0]; + thetamean_xz = thetapeaks_xz[0]; + rmean_yz = rpeaks_yz[0]; + thetamean_yz = thetapeaks_yz[0]; + + //Selection of x,y,z points COMMON to the 3 maxmean+/-1 found in Hough spaces for xy, xz and yz spaces + for(unsigned int i=0;i<x->size();i++) + { + r0_xy = x->at(i)*TMath::Cos(thetamean_xy*PI/180.)+y->at(i)*TMath::Sin(thetamean_xy*PI/180.); + tmin = thetamean_xy-bint_xy; + tmax = thetamean_xy+bint_xy; + if((tmin)<0) tmin = tmin + 180.; + if((tmax)>180) tmax = tmax - 180.; + rmin_xy = x->at(i)*TMath::Cos(tmin*PI/180.)+y->at(i)*TMath::Sin(tmin*PI/180.); + rmax_xy = x->at(i)*TMath::Cos(tmax*PI/180.)+y->at(i)*TMath::Sin(tmax*PI/180.); + + rinf = min( rmean_xy - binr_xy, rmean_xy + binr_xy); + rsup = max( rmean_xy - binr_xy, rmean_xy + binr_xy); + if((r0_xy>=rinf || rmin_xy>=rinf || rmax_xy>=rinf) && (r0_xy<=rsup || rmin_xy<=rsup || rmax_xy<=rsup)) + { + r0_xz = z->at(i)*TMath::Cos(thetamean_xz*PI/180.)+x->at(i)*TMath::Sin(thetamean_xz*PI/180.); + tmin = thetamean_xz-bint_xz; + tmax = thetamean_xz+bint_xz; + if((tmin)<0) tmin = tmin + 180.; + if((tmax)>180) tmax = tmax - 180.; + rmin_xz = z->at(i)*TMath::Cos(tmin*PI/180.)+x->at(i)*TMath::Sin(tmin*PI/180.); + rmax_xz = z->at(i)*TMath::Cos(tmax*PI/180.)+x->at(i)*TMath::Sin(tmax*PI/180.); + + rinf = min( rmean_xz - binr_xz, rmean_xz + binr_xz); + rsup = max( rmean_xz - binr_xz, rmean_xz + binr_xz); + + if((r0_xz>=rinf || rmin_xz>=rinf || rmax_xz>=rinf) && (r0_xz<=rsup || rmin_xz<=rsup || rmax_xz<=rsup)) + { + r0_yz = z->at(i)*TMath::Cos(thetamean_yz*PI/180.)+y->at(i)*TMath::Sin(thetamean_yz*PI/180.); + tmin = thetamean_yz-bint_yz; + tmax = thetamean_yz+bint_yz; + if((tmin)<0) tmin = tmin + 180.; + if((tmax)>180) tmax = tmax - 180.; + rmin_yz = z->at(i)*TMath::Cos(tmin*PI/180.)+y->at(i)*TMath::Sin(tmin*PI/180.); + rmax_yz = z->at(i)*TMath::Cos(tmax*PI/180.)+y->at(i)*TMath::Sin(tmax*PI/180.); + + rinf = min( rmean_yz - binr_yz, rmean_yz + binr_yz); + rsup = max( rmean_yz - binr_yz, rmean_yz + binr_yz); + + if((r0_yz>=rinf || rmin_yz>=rinf || rmax_yz>=rinf) && (r0_yz<=rsup || rmin_yz<=rsup || rmax_yz<=rsup)) + { + x_out->push_back(x->at(i)); + y_out->push_back(y->at(i)); + z_out->push_back(z->at(i)); + q_out->push_back(q->at(i)); + } + } + } + + } + delete hp_xy; + delete hp_xz; + delete hp_yz; + } // Calculation of the minimal distance between 2 lines in 3D space & calculation of mid-point=>vertex of interaction -void NPL::Tracking::vertex(double *p, double *pp, double &xv,double &yv,double &zv,double &min_dist, double &Theta_tr1, double &Theta_tr2) { - double a1 = p[0]; - double a2 = p[2]; - double b1 = p[1]; - double b2 = p[3]; - double ap1 = pp[0]; - double ap2 = pp[2]; - double bp1 = pp[1]; - double bp2 = pp[3]; - - double alpha, beta, A, B, C; - - alpha = (bp1*(a1-ap1)+bp2*(a2-ap2))/(bp1*bp1 + bp2*bp2 + 1); - beta = (bp1*b1+bp2*b2+1)/(bp1*bp1 + bp2*bp2 + 1); - - A = beta*(bp1*bp1 + bp2*bp2 + 1) - (bp1*b1 + bp2*b2 + 1); - B = (b1*b1 + b2*b2 + 1) - beta*(bp1*b1+bp2*b2+1); - C = beta*(bp1*(ap1-a1) + bp2*(ap2-a2)) - (b1*(ap1-a1) + b2*(ap2-a2)); - - double sol1, solf1; - double x,y,z,xp,yp,zp; - - - sol1 = -(A*alpha + C)/(A*beta + B); - solf1 = alpha + beta* sol1; - - x = a1 + b1*sol1; - y = a2 + b2*sol1; - z = sol1; - xp = ap1 + bp1*solf1; - yp = ap2 + bp2*solf1; - zp = solf1; - - xv = (x+xp)/2.; - yv = (y+yp)/2.; - zv = (z+zp)/2.; - - Theta_tr1 = TMath::ATan(TMath::Sqrt((x-a1)*(x-a1)+(y-a2)*(y-a2))/TMath::Abs(sol1)); - Theta_tr2 = TMath::ATan(TMath::Sqrt((xp-ap1)*(xp-ap1)+(yp-ap2)*(yp-ap2))/TMath::Abs(solf1)); - Theta_tr1 = Theta_tr1*180./TMath::Pi(); - Theta_tr2 = Theta_tr2*180./TMath::Pi(); - - //cout << "Vertex 1st :" << x << "," << y << "," << z << endl; - //cout << "Vertex 2nd :" << xp << "," << yp << "," << zp << endl; - //cout << "Vertex middle :" << xv << "," << yv << "," << zv << endl; - - //cout << "min dist " << sqrt(pow((x-xp),2) + pow((y-yp),2) + pow((z-zp),2)) << endl; - +void NPL::Tracking::vertex(double *p, double *pp, double &xv,double &yv,double &zv,double &min_dist, double &Theta_tr1, double &Theta_tr2, double &Phi1, double &Phi2) { + double a1 = p[0]; + double a2 = p[2]; + double b1 = p[1]; + double b2 = p[3]; + double ap1 = pp[0]; + double ap2 = pp[2]; + double bp1 = pp[1]; + double bp2 = pp[3]; + + // calcul the closest pointis between track1 && track2 + double alpha, beta, A, B, C; + + alpha = (bp1*(a1-ap1)+bp2*(a2-ap2))/(bp1*bp1 + bp2*bp2 + 1); + beta = (bp1*b1+bp2*b2+1)/(bp1*bp1 + bp2*bp2 + 1); + + A = beta*(bp1*bp1 + bp2*bp2 + 1) - (bp1*b1 + bp2*b2 + 1); + B = (b1*b1 + b2*b2 + 1) - beta*(bp1*b1+bp2*b2+1); + C = beta*(bp1*(ap1-a1) + bp2*(ap2-a2)) - (b1*(ap1-a1) + b2*(ap2-a2)); + + double sol1, solf1; + double x,y,z,xp,yp,zp; + + sol1 = -(A*alpha + C)/(A*beta + B); + solf1 = alpha + beta* sol1; + + // point from track1 + x = a1 + b1*sol1; + y = a2 + b2*sol1; + z = sol1; + // point from track2 + xp = ap1 + bp1*solf1; + yp = ap2 + bp2*solf1; + zp = solf1; + // vertex (mid-ditance between the 2 points) + xv = (x+xp)/2.; + yv = (y+yp)/2.; + zv = (z+zp)/2.; + + // calulate Theta and Phi + double xa,ya,za,zap,xap,yap; + double zpoint = 3000; + xa = a1 + b1*zpoint; + ya = a2 + b2*zpoint; + + xap = ap1 + bp1*zpoint; + yap = ap2 + bp2*zpoint; + + /* Theta_tr1 = TMath::ACos((zpoint-z)/TMath::Sqrt((xa-x)*(xa-x)+(ya-y)*(ya-y)+(zpoint-z)*(zpoint-z))); */ + /* Theta_tr2 = TMath::ACos((zpoint-zp)/TMath::Sqrt((xap-xp)*(xap-xp)+(yap-yp)*(yap-yp)+(zpoint-zp)*(zpoint-zp))); */ + // Aldric Revel version : + Theta_tr1 = TMath::ATan(TMath::Sqrt((x-a1)*(x-a1)+(y-a2)*(y-a2))/TMath::Abs(sol1)); + Theta_tr2 = TMath::ATan(TMath::Sqrt((xp-ap1)*(xp-ap1)+(yp-ap2)*(yp-ap2))/TMath::Abs(solf1)); + Phi1 = TMath::ATan2(b2,b1); + Phi2 = TMath::ATan2(bp2,bp1); + + /* Phi1 = TMath::RadToDeg()*TMath::ATan2(parFit4->at(0),parFit2->at(0)); */ + /* if( xa-x > 0 && ya-y >= 0) */ + /* Phi1 = TMath::ATan((ya-y)/(xa-x)); */ + /* else if(xa-x > 0 && ya-y < 0) */ + /* Phi1 = TMath::ATan((ya-y)/(xa-x)) + 2*TMath::Pi(); */ + /* else if(xa-x < 0) */ + /* Phi1 = TMath::ATan((ya-y)/(xa-x)) + TMath::Pi(); */ + + /* if(xap-xp > 0 && yap-yp >= 0) */ + /* Phi2 = TMath::ATan((yap-yp)/(xap-xp)); */ + /* else if(xap-xp > 0 && yap-yp < 0) */ + /* Phi2 = TMath::ATan((yap-yp)/(xap-xp)) + 2*TMath::Pi(); */ + /* else if(xap-xp < 0) */ + /* Phi2 = TMath::ATan((yap-yp)/(xap-xp)) + TMath::Pi(); */ + + /* if(Phi1>TMath::Pi()) Phi1 = Phi1-2*TMath::Pi(); */ + /* if(Phi2>TMath::Pi()) Phi2 = Phi2-2*TMath::Pi(); */ + + Phi1 = 180*Phi1/TMath::Pi(); + Phi2 = 180*Phi2/TMath::Pi(); + Theta_tr1 = Theta_tr1*180./TMath::Pi(); + Theta_tr2 = Theta_tr2*180./TMath::Pi(); + + min_dist = sqrt(pow((x-xp),2) + pow((y-yp),2) + pow((z-zp),2)); + } void NPL::Tracking::ParFor_Vertex(double *a, double *b, double *parFit) { @@ -478,7 +497,7 @@ void NPL::Tracking::ParFor_Vertex(double *a, double *b, double *parFit) { APX=a[0]-b[0]; APY=a[1]-b[1]; APZ=a[2]-b[2]; APX0=APX/APZ; APY0=APY/APZ; X0=a[0]-a[2]*APX0; Y0=a[1]-a[2]*APY0; //Z0=0 - + parFit[0]=X0; parFit[1]=APX0; parFit[2]=Y0; diff --git a/NPLib/TrackReconstruction/Tracking.h b/NPLib/TrackReconstruction/Tracking.h index ee158a5bb2061cc60c6dd5f29512cba9c36ebd08..a198da8a90339dc31c3426fea2771a29cbf19048 100644 --- a/NPLib/TrackReconstruction/Tracking.h +++ b/NPLib/TrackReconstruction/Tracking.h @@ -23,7 +23,7 @@ class Tracking { void FindStart(double pStart[4], double chi[2], int fitStatus[2],TGraph *grxz, TGraph *gryz); double distance2(double x,double y,double z, double *p); void Hough_3D(vector<double> *x,vector<double> *y,vector<double> *z,vector<double> *q,vector<double> *x_out,vector<double> *y_out,vector<double> *z_out,vector<double> *q_out); - void vertex(double *p, double *pp, double &xv,double &yv,double &zv, double &min_dist, double &Theta_tr1, double &Theta_tr2); + void vertex(double *p, double *pp, double &xv,double &yv,double &zv, double &min_dist, double &Theta_tr1, double &Theta_tr2, double &Phi1, double &Phi2); void ParFor_Vertex(double *a, double *b, double *parFit); ClassDef(Tracking,1); diff --git a/NPLib/Utility/CMakeLists.txt b/NPLib/Utility/CMakeLists.txt index 6f3b543c7358748b39433842d45d038e538288de..82bf3b9140ad36728b46bc05f6c653b9a1fa5b4f 100644 --- a/NPLib/Utility/CMakeLists.txt +++ b/NPLib/Utility/CMakeLists.txt @@ -8,4 +8,4 @@ add_executable(npspectra_test npspectra_test.cxx) target_link_libraries(npspectra_test ${ROOT_LIBRARIES} NPCore NPOnline) install(PROGRAMS nptool-installer npanalysis nponline DESTINATION ${CMAKE_BINARY_OUTPUT_DIRECTORY}) -install(SCRIPT ../scripts/post_install.cmake ${DETLIST}) +install(SCRIPT ${CMAKE_BINARY_DIR}/scripts/post_install.cmake ${DETLIST}) diff --git a/NPLib/scripts/NPToolLogon.C b/NPLib/scripts/NPToolLogon.C index d3bdf5e8d522dce0bdab1163475232fe6e6386c3..f33ea030d0d6fb7846185f486c88ade64b4ae402 100644 --- a/NPLib/scripts/NPToolLogon.C +++ b/NPLib/scripts/NPToolLogon.C @@ -36,6 +36,14 @@ using namespace std; #include"TRandom.h" #include"TRandom2.h" +bool contains(std::string path,std::string search){ + if(path.find(search)!=std::string::npos) + return true; + else + return false; + } + +///////////////////////////////////////////////////// void NPToolLogon(){ #ifdef __APPLE__ @@ -74,8 +82,8 @@ void NPToolLogon(){ if(!check){ // Add shared libraries - TString libpath = Form("%s/NPLib/lib", path.c_str()); - TSystemDirectory libdir("libdir", libpath); + std::string libpath = Form("%s/NPLib/lib", path.c_str()); + TSystemDirectory libdir("libdir", libpath.c_str()); TList* listfile = libdir.GetListOfFiles(); // Since the list is ordered alphabetically and that the @@ -83,7 +91,8 @@ void NPToolLogon(){ // lib*Physics.dylib libraries, it is then loaded manually // first. // Test if the lib directory is empty or not - if (listfile->GetEntries() > 2) gSystem->Load(libpath+"/libNPCore"+Lib_Extension); + std::string load_path = libpath+"/libNPCore"+Lib_Extension; + if (listfile->GetEntries() > 2) gSystem->Load(load_path.c_str()); gSystem->Load("libPhysics.so"); // Needed by Must2 and Sharc gSystem->Load("libHist.so"); // Needed by TSpectra Class @@ -91,30 +100,30 @@ void NPToolLogon(){ // Loop on Data libraries Int_t i = 0; while (listfile->At(i)) { - TString libname = listfile->At(i++)->GetName(); - if (libname.Contains(Lib_Extension) && libname.Contains("Data") && !libname.Contains("libVDetector"+Lib_Extension)) { - TString lib = libpath + "/" + libname; - gSystem->Load(lib); + std::string libname = listfile->At(i++)->GetName(); + if (contains(libname,Lib_Extension) && contains(libname,"Data") && !contains(libname,"libVDetector"+Lib_Extension)) { + std::string lib = libpath + "/" + libname; + gSystem->Load(lib.c_str()); } } // Loop on Physics Library i = 0; while (listfile->At(i)) { - TString libname = listfile->At(i++)->GetName(); - if (libname.Contains(Lib_Extension) && libname.Contains("Physics") &&!libname.Contains("libVDetector"+Lib_Extension)) { - TString lib = libpath + "/" + libname; - gSystem->Load(lib); + std::string libname = listfile->At(i++)->GetName(); + if (contains(libname,Lib_Extension) && contains(libname,"Physics") &&!contains(libname,"libVDetector"+Lib_Extension)) { + std::string lib = libpath + "/" + libname; + gSystem->Load(lib.c_str()); } } // Loop on the Reset of the Library i = 0; while (listfile->At(i)) { - TString libname = listfile->At(i++)->GetName(); - if (libname.Contains(Lib_Extension) && !libname.Contains("Physics") && !libname.Contains("Data") &&!libname.Contains("libVDetector"+Lib_Extension)) { - TString lib = libpath + "/" + libname; - gSystem->Load(lib); + std::string libname = listfile->At(i++)->GetName(); + if (contains(libname,Lib_Extension) && !contains(libname,"Physics") && !contains(libname,"Data") &&!contains(libname,"libVDetector"+Lib_Extension)) { + std::string lib = libpath + "/" + libname; + gSystem->Load(lib.c_str()); } } @@ -125,3 +134,5 @@ void NPToolLogon(){ gSystem->cd(currentpath.c_str()); } } + + diff --git a/NPLib/scripts/test/simulation_run.sh b/NPLib/scripts/test/simulation_run.sh index 0d3a0fdc1dda954642b885a188d3361898b020f7..cf65c8b6fb70c1294605a059e51fbf389ea47725 100755 --- a/NPLib/scripts/test/simulation_run.sh +++ b/NPLib/scripts/test/simulation_run.sh @@ -4,7 +4,14 @@ set -ev # go to nps + +cd $NPTOOL/Examples/Example1 +npsimulation -D Example1.detector -E Example1.reaction -O Example1 -B run.mac cd $NPTOOL/Examples/Example2 npsimulation -D Example2.detector -E Example2.reaction -O Example2 -B 28Mg.mac npanalysis --last-sim -O Example2 echo ".q" | root -b -l ShowResults.C +cd $NPTOOL/Examples/Example4 +./sim.sh +cd $NPTOOL/Examples/Example5 +./sim.sh diff --git a/NPSimulation/Core/EventAction.cc b/NPSimulation/Core/EventAction.cc index a1eb1d4c76b8d75e0bac18632b1d91763763e300..bd00d152cd524c63bc3d8851476d50fb6533237b 100644 --- a/NPSimulation/Core/EventAction.cc +++ b/NPSimulation/Core/EventAction.cc @@ -22,10 +22,10 @@ // G4 headers #include "G4Event.hh" #include "G4UnitsTable.hh" -//#include "G4SDManager.hh" #include "G4RunManager.hh" #include "G4Trajectory.hh" #include "G4TrajectoryContainer.hh" +#include "Randomize.hh" // NPTool headers #include "EventAction.hh" #include "DetectorConstruction.hh" @@ -44,6 +44,10 @@ EventAction::EventAction(){ total=0; mean_rate=0; displayed=0; + + m_tree = RootOutput::getInstance()->GetTree(); + // m_tree->Branch("Geant4RandomState",&m_G4State ); + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -54,19 +58,21 @@ EventAction::~EventAction(){ void EventAction::BeginOfEventAction(const G4Event* event){ treated= event->GetEventID()+1; ProgressDisplay(); +// SaveRandomGeneratorInitialState(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::EndOfEventAction(const G4Event* event){ m_detector->ReadAllSensitive(event) ; - static TTree* tree = RootOutput::getInstance()->GetTree(); - tree->Fill(); + m_tree->Fill(); m_detector->ClearInteractionCoordinates(); // if(treated%10000==0){ // tree->AutoSave(); // RootOutput::getInstance()->GetFile()->SaveSelf(kTRUE); // } + + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -74,6 +80,17 @@ void EventAction::SetDetector(DetectorConstruction* detector){ m_detector = detector ; } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void EventAction::SaveRandomGeneratorInitialState(){ + // This allow to restore the geant4 random generator status for problematic + // event + + CLHEP::HepRandom::saveFullState(m_Geant4RandomFullState); + m_G4State=m_Geant4RandomFullState.str(); + m_Geant4RandomFullState.str(""); + m_Geant4RandomFullState.clear(); +} + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventAction::ProgressDisplay(){ if(treated==0){ diff --git a/NPSimulation/Core/EventAction.hh b/NPSimulation/Core/EventAction.hh index 914b38accf69b7835ec77ff89074a68da6b0fe9a..78c587077dbc17c8885bf71a796aa9483d2201ba 100644 --- a/NPSimulation/Core/EventAction.hh +++ b/NPSimulation/Core/EventAction.hh @@ -27,11 +27,16 @@ // G4 header #include "G4UserEventAction.hh" +//Root +#include "TTree.h" + // NPTool header #include "DetectorConstruction.hh" // STL #include<time.h> +#include<iostream> +#include<string> //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... class EventAction : public G4UserEventAction{ public: @@ -43,7 +48,12 @@ class EventAction : public G4UserEventAction{ void EndOfEventAction(const G4Event*); void SetDetector(DetectorConstruction* detector); void ProgressDisplay(); + void SaveRandomGeneratorInitialState(); void SetRunLength(int); + + private: // tree + TTree* m_tree; + private: // Progress Display clock_t begin; clock_t end; @@ -53,6 +63,10 @@ class EventAction : public G4UserEventAction{ double mean_rate; int displayed; + private: // Random state + std::ostringstream m_Geant4RandomFullState; + std::string m_G4State; + private: DetectorConstruction* m_detector; static EventAction* m_EventAction; diff --git a/NPSimulation/Core/MaterialManager.cc b/NPSimulation/Core/MaterialManager.cc index 7a94a28d67e4addb72f46471758b7b6597703c33..cb9e2933807bc7907dd4bd378f419ab27cbc6be3 100644 --- a/NPSimulation/Core/MaterialManager.cc +++ b/NPSimulation/Core/MaterialManager.cc @@ -33,6 +33,7 @@ #include "G4PVPlacement.hh" #include "G4ParticleTable.hh" #include "G4VisAttributes.hh" +#include "G4HadronicProcessStore.hh" // STL #include <iostream> #include <string> @@ -63,11 +64,11 @@ void MaterialManager::Destroy() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void MaterialManager::ClearMaterialLibrary() { - // map<string, G4Material*>::iterator it; - // for (it = m_Material.begin(); it != m_Material.end(); it++) { - // delete it->second; - // } - + // map<string, G4Material*>::iterator it; + // for (it = m_Material.begin(); it != m_Material.end(); it++) { + // delete it->second; + // } + // Geant4 own pointer to the material // we can forget about them but not delete it // as they can be deleted by the kernel e.g. when Cleaning the PVPStore @@ -80,7 +81,7 @@ void MaterialManager::ClearMaterialLibrary() { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Material* MaterialManager::GetMaterialFromLibrary(string Name, - double density) { + double density) { // Search if the material is already instantiate map<string, G4Material*>::iterator it; it = m_Material.find(Name); @@ -134,6 +135,19 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } + else if (Name == "Rogers4003C") { + if (!density) + density = 1.79 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 4); + material->AddElement(GetElementFromLibrary("H"), 2); + material->AddElement(GetElementFromLibrary("C"), 50); + material->AddElement(GetElementFromLibrary("O"), 38); + material->AddElement(GetElementFromLibrary("Si"), 10); + m_Material[Name] = material; + return material; + } + + else if (Name == "Mylar") { if (!density) density = 1.397 * g / cm3; @@ -147,11 +161,12 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "Kapton") { if (!density) - density = 1.39 * g / cm3; - G4Material* material = new G4Material("NPS_" + Name, density, 3); - material->AddElement(GetElementFromLibrary("H"), 4); - material->AddElement(GetElementFromLibrary("C"), 10); - material->AddElement(GetElementFromLibrary("O"), 2); + density = 1.42 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 4); + material->AddElement(GetElementFromLibrary("H"), 0.026); + material->AddElement(GetElementFromLibrary("C"), 0.69); + material->AddElement(GetElementFromLibrary("O"), 0.21); + material->AddElement(GetElementFromLibrary("N"), 0.074); m_Material[Name] = material; return material; } @@ -197,7 +212,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 0.808 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, 7, 14.01 * g / mole, - density, kStateLiquid, 77 * kelvin); + density, kStateLiquid, 77 * kelvin); m_Material[Name] = material; return material; } @@ -233,6 +248,27 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } + else if (Name == "EJ200") { + if (!density) + density = 1.023 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 2); + material->AddElement(GetElementFromLibrary("C"), 5); + material->AddElement(GetElementFromLibrary("H"), 4); + m_Material[Name] = material; + return material; + } + + else if (Name == "EJ309") { + if (!density) + density = 0.964 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 2); + material->AddElement(GetElementFromLibrary("C"), 5); + material->AddElement(GetElementFromLibrary("H"), 4); + m_Material[Name] = material; + return material; + } + + else if (Name == "Cu") { if (!density) density = 8.96 * g / cm3; @@ -242,6 +278,66 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } + else if(Name == "235U"){ + if(!density) + density = 19.1 * g / cm3; + G4Element* U235 = new G4Element("U235","U235",1); + + G4Isotope* isotope = new G4Isotope("235U",92,235); + U235->AddIsotope(isotope,1); + + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15*kelvin); + material->AddElement(U235,1); + m_Material[Name] = material; + return material; + } + + else if(Name == "238U"){ + if(!density) + density = 19.1 * g / cm3; + G4Element* U238 = new G4Element("U238","U238",1); + + G4Isotope* isotope = new G4Isotope("238U",92,238); + U238->AddIsotope(isotope,1); + + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15*kelvin); + material->AddElement(U238,1); + m_Material[Name] = material; + return material; + } + + + else if (Name == "Gd") { + if (!density) + density = 7.90 * g / cm3; + G4Element* Gd = new G4Element("Gd","Gd",6); + G4Isotope* isotope; + + isotope = new G4Isotope("154Gd", 64, 154); + Gd->AddIsotope(isotope,0.0218); + + isotope = new G4Isotope("155Gd",64,155); + Gd->AddIsotope(isotope,0.1480); + + isotope = new G4Isotope("156Gd",64,156); + Gd->AddIsotope(isotope,0.2047); + + isotope = new G4Isotope("157Gd",64,157); + Gd->AddIsotope(isotope,0.1565); + + isotope = new G4Isotope("158Gd",64,158); + Gd->AddIsotope(isotope,0.2484); + + isotope = new G4Isotope("160Gd",64,160); + Gd->AddIsotope(isotope,0.2186); + + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15*kelvin); + material->AddElement(Gd,1); + m_Material[Name] = material; + return material; + } + + else if (Name == "Au") { if (!density) density = 19.3 * g / cm3; @@ -315,6 +411,57 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, m_Material[Name] = material; return material; } + + else if (Name=="MgO"){ //cyril + if (!density) + density = 3.6* g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 2); + material->AddElement(GetElementFromLibrary("Mg"), 1); + material->AddElement(GetElementFromLibrary("O"), 1); + m_Material[Name] = material; + return material; + } + else if (Name=="mixMINOS"){ //cyril + if (!density) + density = 0.0019836* g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 3); + material->AddMaterial(GetMaterialFromLibrary("CF4"), .15); + material->AddMaterial(GetMaterialFromLibrary("isobutane"), .03); + material->AddElement(GetElementFromLibrary("Ar"), .82); + m_Material[Name] = material; + return material; + } + else if (Name=="mumetal"){ //cyril + if (!density) + density = 8.7* g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 3); + material->AddElement(GetElementFromLibrary("Ni"), .8); + material->AddElement(GetElementFromLibrary("Fe"), .15); + material->AddElement(GetElementFromLibrary("Mo"), .05); + m_Material[Name] = material; + return material; + } + else if (Name=="LH2"){ //cyril + if (!density) + density = 0.07293* g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 1); + material->AddElement(GetElementFromLibrary("H"), 2); + m_Material[Name] = material; + return material; + } + else if (Name=="Rohacell"){ //cyril + if (!density) + density = 0.075* g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 4); + material->AddElement(GetElementFromLibrary("H"), 0.0805); + material->AddElement(GetElementFromLibrary("C"), 0.6014); + material->AddElement(GetElementFromLibrary("O"), 0.3154); + material->AddElement(GetElementFromLibrary("N"), 0.00276); + m_Material[Name] = material; + return material; + } + + // Usual detector material else if (Name == "Si") { if (!density) @@ -456,13 +603,13 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, wl = wlmin + i * step; // Formula from www.refractiveindex.info rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) - + 0.26090 / (1 - pow(0.147 / wl, 2)) - + 0.06256 / (1 - pow(0.163 / wl, 2)) - + 0.06527 / (1 - pow(0.177 / wl, 2)) - + 0.14991 / (1 - pow(0.185 / wl, 2)) - + 0.51818 / (1 - pow(0.206 / wl, 2)) - + 0.01918 / (1 - pow(0.218 / wl, 2)) - + 3.38229 / (1 - pow(161.29 / wl, 2))); + + 0.26090 / (1 - pow(0.147 / wl, 2)) + + 0.06256 / (1 - pow(0.163 / wl, 2)) + + 0.06527 / (1 - pow(0.177 / wl, 2)) + + 0.14991 / (1 - pow(0.185 / wl, 2)) + + 0.51818 / (1 - pow(0.206 / wl, 2)) + + 0.01918 / (1 - pow(0.218 / wl, 2)) + + 3.38229 / (1 - pow(161.29 / wl, 2))); // check below block energy_r[i] = h_Planck * c_light / wl; // To be defined properly @@ -476,9 +623,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, MPT->AddProperty("SCINTILLATION", energy_e, scint, 5); // check MPT->AddProperty("RINDEX", energy_r, rindex, NumberOfPoints); // check MPT->AddProperty("ABSLENGTH", energy_r, absorption, - NumberOfPoints); // check - MPT->AddProperty("FASTCOMPONENT", energy_e, fast, 2.1); // good - MPT->AddProperty("SLOWCOMPONENT", energy_e, slow, 22.6); // good + NumberOfPoints); // check + MPT->AddProperty("FASTCOMPONENT", energy_e, fast, 5); // good + MPT->AddProperty("SLOWCOMPONENT", energy_e, slow, 5); // good MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); // check MPT->AddConstProperty("FASTTIMECONSTANT", 1000 * ns); // check MPT->AddConstProperty("SLOWTIMECONSTANT", 1000 * ns); // check @@ -570,13 +717,13 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, wl = wlmin + i * step; // Formula from www.refractiveindex.info rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) - + 0.26090 / (1 - pow(0.147 / wl, 2)) - + 0.06256 / (1 - pow(0.163 / wl, 2)) - + 0.06527 / (1 - pow(0.177 / wl, 2)) - + 0.14991 / (1 - pow(0.185 / wl, 2)) - + 0.51818 / (1 - pow(0.206 / wl, 2)) - + 0.01918 / (1 - pow(0.218 / wl, 2)) - + 3.38229 / (1 - pow(161.29 / wl, 2))); + + 0.26090 / (1 - pow(0.147 / wl, 2)) + + 0.06256 / (1 - pow(0.163 / wl, 2)) + + 0.06527 / (1 - pow(0.177 / wl, 2)) + + 0.14991 / (1 - pow(0.185 / wl, 2)) + + 0.51818 / (1 - pow(0.206 / wl, 2)) + + 0.01918 / (1 - pow(0.218 / wl, 2)) + + 3.38229 / (1 - pow(161.29 / wl, 2))); energy_r[i] = h_Planck * c_light / wl; // To be defined properly @@ -634,6 +781,15 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, } // Misc + else if (Name == "Be") { + if (!density) + density = 1.848 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 1); + material->AddElement(GetElementFromLibrary("Be"), 1); + m_Material[Name] = material; + return material; + } + else if (Name == "Al") { if (!density) density = 2.702 * g / cm3; @@ -674,7 +830,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 1.74 * mg / cm3; G4Material* material - = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1 atm + = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1 atm material->AddElement(GetElementFromLibrary("Ar"), 0.9222); material->AddElement(GetElementFromLibrary("C"), 0.0623); material->AddElement(GetElementFromLibrary("H"), 0.0155); @@ -686,7 +842,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 0.57 * mg / cm3; G4Material* material - = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1/3 atm + = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1/3 atm material->AddElement(GetElementFromLibrary("Ar"), 0.9222); material->AddElement(GetElementFromLibrary("C"), 0.0623); material->AddElement(GetElementFromLibrary("H"), 0.0155); @@ -704,13 +860,23 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } + else if(Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane"){ + density = 0.002506*g/cm3; + G4Material* material = new G4Material("NPS_"+Name,density,2); + material->AddElement(GetElementFromLibrary("C"), 4); + material->AddElement(GetElementFromLibrary("H"), 10); + m_Material[Name]=material; + return material; + } + else if (Name == "CF4") { // 52 torr if (!density) density = 3.78 * mg / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2, - kStateGas, 300, 0.0693276 * bar); + kStateGas, 300, 0.0693276 * bar); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("F"), 4); + material->GetIonisation()->SetMeanExcitationEnergy(20.0*eV); m_Material[Name] = material; return material; } @@ -726,6 +892,18 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } + else if (Name == "PMMA") { + if (!density) + density = 1.18 * mg / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 3); + material->AddElement(GetElementFromLibrary("C"), 5); + material->AddElement(GetElementFromLibrary("O"), 2); + material->AddElement(GetElementFromLibrary("H"), 8); + m_Material[Name] = material; + return material; + } + + else if (Name == "Pyrex") { if (!density) density = 2.23 * g / cm3; @@ -735,24 +913,37 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("B"), 7); material->AddElement(GetElementFromLibrary("Na"), 2); material->AddElement(GetElementFromLibrary("Al"), 1); + m_Material[Name] = material; + return material; + } + + else if (Name == "Pyrex_optical") { + if (!density) + density = 2.23 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 5); + material->AddElement(GetElementFromLibrary("Si"), 25); + material->AddElement(GetElementFromLibrary("O"), 65); + material->AddElement(GetElementFromLibrary("B"), 7); + material->AddElement(GetElementFromLibrary("Na"), 2); + material->AddElement(GetElementFromLibrary("Al"), 1); //--------------------- PMMA optical Properties ---------------------// const G4int NUMENTRIES = 15; G4double PMMA_PP[NUMENTRIES] - = {10 * eV, 3.25 * eV, 3.099 * eV, 2.88 * eV, 2.695 * eV, - 2.53 * eV, 2.38 * eV, 2.254 * eV, 2.138 * eV, 2.033 * eV, - 1.937 * eV, 1.859 * eV, 1.771 * eV, 1.6 * eV, 0 * eV}; + = {10 * eV, 3.25 * eV, 3.099 * eV, 2.88 * eV, 2.695 * eV, + 2.53 * eV, 2.38 * eV, 2.254 * eV, 2.138 * eV, 2.033 * eV, + 1.937 * eV, 1.859 * eV, 1.771 * eV, 1.6 * eV, 0 * eV}; G4double PMMA_RIND[NUMENTRIES] - = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, - 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47}; + = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, + 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47}; G4double PMMA_ABSL[NUMENTRIES] - = {35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, - 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, - 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm}; + = {35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, + 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, + 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm}; /*G4double THICK_ABSL[NUMENTRIES] = - {0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm, - 0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm};*/ + {0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm, + 0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm,0.01*mm};*/ G4MaterialPropertiesTable* myMPT2 = new G4MaterialPropertiesTable(); myMPT2->AddProperty("RINDEX", PMMA_PP, PMMA_RIND, NUMENTRIES); @@ -774,30 +965,30 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, //--------------------- Optical Properties ---------------------// const G4int NUMENTRIES = 15; G4double CsI_PP[NUMENTRIES] - = {10 * eV, 3.5 * eV, 3.25 * eV, 3.2 * eV, 3.15 * eV, - 3.099 * eV, 3.0 * eV, 2.95 * eV, 2.88 * eV, 2.75 * eV, - 2.695 * eV, 2.53 * eV, 2.38 * eV, 2.30 * eV, 0 * eV}; + = {10 * eV, 3.5 * eV, 3.25 * eV, 3.2 * eV, 3.15 * eV, + 3.099 * eV, 3.0 * eV, 2.95 * eV, 2.88 * eV, 2.75 * eV, + 2.695 * eV, 2.53 * eV, 2.38 * eV, 2.30 * eV, 0 * eV}; G4double CsI_SCINT[NUMENTRIES] - = {0.0, 0.0, 0.1, 0.2, 0.4, 0.65, 0.8, 0.95, - 0.82, 0.7, 0.5, 0.21, 0.05, 0, 0}; + = {0.0, 0.0, 0.1, 0.2, 0.4, 0.65, 0.8, 0.95, + 0.82, 0.7, 0.5, 0.21, 0.05, 0, 0}; G4double CsI_RIND[NUMENTRIES] - = {1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, - 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505}; + = {1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, + 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505}; G4double CsI_ABSL[NUMENTRIES] - = {1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, - 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, - 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m}; + = {1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, + 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, + 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m}; G4MaterialPropertiesTable* myMPT1 = new G4MaterialPropertiesTable(); myMPT1->AddProperty("RINDEX", CsI_PP, CsI_RIND, NUMENTRIES); /// Constant? myMPT1->AddProperty("ABSLENGTH", CsI_PP, CsI_ABSL, - NUMENTRIES); // Constant? + NUMENTRIES); // Constant? myMPT1->AddProperty("FASTCOMPONENT", CsI_PP, CsI_SCINT, - NUMENTRIES); // Spectrum + NUMENTRIES); // Spectrum myMPT1->AddProperty("SLOWCOMPONENT", CsI_PP, CsI_SCINT, - NUMENTRIES); // Spectrum + NUMENTRIES); // Spectrum myMPT1->AddConstProperty("SCINTILLATIONYIELD", 13000. / MeV); myMPT1->AddConstProperty("RESOLUTIONSCALE", 1.0); @@ -813,8 +1004,8 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else { G4cout << "ERROR: Material requested \"" << Name - << "\" is not available in the Material Library, trying with NIST" - << G4endl; + << "\" is not available in the Material Library, trying with NIST" + << G4endl; G4NistManager* man = G4NistManager::Instance(); return man->FindOrBuildMaterial(Name.c_str()); } @@ -837,7 +1028,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { if (!m_D) { m_D = new G4Element(Name.c_str(), Name.c_str(), 1); G4Isotope* isotope - = new G4Isotope(Name.c_str(), 1, 2, 2.01410178 * g / mole); + = new G4Isotope(Name.c_str(), 1, 2, 2.01410178 * g / mole); m_D->AddIsotope(isotope, 1); } return m_D; @@ -847,7 +1038,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { if (!m_T) { m_T = new G4Element(Name.c_str(), Name.c_str(), 1); G4Isotope* isotope - = new G4Isotope(Name.c_str(), 1, 3, 3.0160492 * g / mole); + = new G4Isotope(Name.c_str(), 1, 3, 3.0160492 * g / mole); m_T->AddIsotope(isotope, 1); } return m_T; @@ -857,7 +1048,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { if (!m_He3) { m_He3 = new G4Element(Name.c_str(), Name.c_str(), 1); G4Isotope* isotope - = new G4Isotope(Name.c_str(), 2, 1, 3.0160293 * g / mole); + = new G4Isotope(Name.c_str(), 2, 1, 3.0160293 * g / mole); m_He3->AddIsotope(isotope, 1); } return m_He3; @@ -870,95 +1061,104 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, double Temperature){ - ostringstream oss; - oss << Name<< "_"<<Pressure<<"_"<<Temperature; - string newName= oss.str(); - map<string,G4Material*>::iterator it; - it = m_Material.find(Name); - - double density = 0 ; - - G4double Vm=0.08206*Temperature*atmosphere/(Pressure*kelvin); - - // The element is not found - if(it==m_Material.end()){ - if(Name == "CF4"){ // 52 torr - density = 3.72*kg/m3; - double refTemp= (273.15+15)*kelvin; - double refPres= 1.01325*bar; - density = density*(refTemp/Temperature)/(refPres/Pressure); - G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("C"), 1); - material->AddElement(GetElementFromLibrary("F"), 4); - m_Material[newName]=material; - return material; - } + ostringstream oss; + oss << Name<< "_"<<Pressure<<"_"<<Temperature; + string newName= oss.str(); + map<string,G4Material*>::iterator it; + it = m_Material.find(Name); - if(Name == "He"){ - density = (4.0026/Vm)*mg/cm3; - G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("He"), 1); - m_Material[newName]=material; - return material; - } - - if(Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane"){ - density = ((4*12.0107+10*1.00794)/Vm)*mg/cm3; - G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("C"), 4); - material->AddElement(GetElementFromLibrary("H"), 10); - m_Material[newName]=material; - return material; - } - - if(Name == "CH4"){ - density = ((12.0107+4*1.00794)/Vm)*mg/cm3; - G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("C"), 1); - material->AddElement(GetElementFromLibrary("H"), 4); - m_Material[newName]=material; - return material; - } + double density = 0 ; - if(Name == "CO2"){ - density = ((12.0107+2*16)/Vm)*mg/cm3; - G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("C"), 1); - material->AddElement(GetElementFromLibrary("O"), 2); - m_Material[newName]=material; - return material; - } + G4double Vm=0.08206*Temperature*atmosphere/(Pressure*kelvin); - if(Name == "H2"){ - density = (2*1.00794/Vm)*mg/cm3; - G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("H"), 2); - //material->AddElement(GetElementFromLibrary("H"), 1); - m_Material[newName]=material; - return material; - } - - if(Name == "D2"){ - density = (2*2.0140/Vm)*mg/cm3; - G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); - material->AddElement(GetElementFromLibrary("D"), 2); - //material->AddElement(GetElementFromLibrary("D"), 1); - m_Material[newName]=material; - return material; - } - + // The element is not found + if(it==m_Material.end()){ + if(Name == "CF4"){ // 52 torr + density = 3.72*kg/m3; + double refTemp= (273.15+15)*kelvin; + double refPres= 1.01325*bar; + density = density*(refTemp/Temperature)/(refPres/Pressure); + G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("C"), 1); + material->AddElement(GetElementFromLibrary("F"), 4); + m_Material[newName]=material; + return material; + } - else{ - exit(1); - } - } + if(Name == "He"){ + density = (4.0026/Vm)*mg/cm3; + G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("He"), 1); + m_Material[newName]=material; + return material; + } + + if(Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane"){ + density = ((4*12.0107+10*1.00794)/Vm)*mg/cm3; + G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("C"), 4); + material->AddElement(GetElementFromLibrary("H"), 10); + m_Material[newName]=material; + return material; + } + + if(Name == "CH4"){ + density = ((12.0107+4*1.00794)/Vm)*mg/cm3; + G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("C"), 1); + material->AddElement(GetElementFromLibrary("H"), 4); + m_Material[newName]=material; + return material; + } + + if(Name == "CO2"){ + density = ((12.0107+2*16)/Vm)*mg/cm3; + G4Material* material = new G4Material("NPS_"+newName,density,2,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("C"), 1); + material->AddElement(GetElementFromLibrary("O"), 2); + m_Material[newName]=material; + return material; + } + + if(Name == "H2"){ + density = (2*1.00794/Vm)*mg/cm3; + G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("H"), 2); + //material->AddElement(GetElementFromLibrary("H"), 1); + m_Material[newName]=material; + return material; + } + + if(Name == "D2"){ + density = (2*2.0140/Vm)*mg/cm3; + G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); + material->AddElement(GetElementFromLibrary("D"), 2); + //material->AddElement(GetElementFromLibrary("D"), 1); + m_Material[newName]=material; + return material; + } + + /* if(Name == "mixMINOS"){ */ + /* density = (2*2.0140/Vm)*mg/cm3; */ + /* G4Material* material = new G4Material("NPS_"+newName,density,1,kStateGas,Temperature,Pressure); */ + /* material->AddElement(GetElementFromLibrary("D"), 2); */ + /* //material->AddElement(GetElementFromLibrary("D"), 1); */ + /* m_Material[newName]=material; */ + /* return material; */ + /* } */ + + + else{ + exit(1); + } + } return NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate a DEDX file table using the material used in the geometry void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, - G4double Emin, G4double Emax) { + G4double Emin, G4double Emax) { map<string, G4Material*>::iterator it; if (Particle->GetPDGCharge() == 0) return; @@ -969,7 +1169,7 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, // Remove NPS name Name.erase(0, 4); G4String Path = GlobalPath + "/Inputs/EnergyLoss/" - + Particle->GetParticleName() + "_" + Name + ".G4table"; + + Particle->GetParticleName() + "_" + Name + ".G4table"; ofstream File; File.open(Path); @@ -978,8 +1178,8 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, return; File << "Table from Geant4 generate using NPSimulation \t" - << "Particle: " << Particle->GetParticleName() - << "\tMaterial: " << it->second->GetName() << G4endl; + << "Particle: " << Particle->GetParticleName() + << "\tMaterial: " << it->second->GetName() << G4endl; // G4cout << Particle->GetParticleName() << "\tMaterial: " << // it->second->GetName() <<endl; @@ -993,7 +1193,7 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, for (G4double E = Emin; E < Emax; E += step) { dedx = emCalculator.ComputeTotalDEDX(E, Particle, it->second) - / (MeV / micrometer); + / (MeV / micrometer); if (before) { if (abs(before - dedx) / abs(before) < 0.01) step *= 2; @@ -1009,14 +1209,101 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate a DEDX file table using the material used in the geometry void MaterialManager::WriteDEDXTable(std::set<string> Particle, G4double Emin, - G4double Emax) { + G4double Emax) { std::set<string>::iterator it; for (it = Particle.begin(); it != Particle.end(); it++) { G4ParticleDefinition* p - = G4ParticleTable::GetParticleTable()->FindParticle((*it)); + = G4ParticleTable::GetParticleTable()->FindParticle((*it)); WriteDEDXTable(p, Emin, Emax); } } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Generate Cross Section table using the material used in the geomtry +void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, G4double Emin, G4double Emax){ + G4HadronicProcessStore* store = G4HadronicProcessStore::Instance(); + + map<string, G4Material*>::iterator it; + + for (it = m_Material.begin(); it != m_Material.end(); it++) { + G4String GlobalPath = getenv("NPTOOL"); + + int NumberOfElements = it->second->GetNumberOfElements(); + + for(int i=0; i<NumberOfElements; i++){ + G4String path1; + G4String path2; + G4String path3; + G4String path4; + G4String ParticleName = Particle->GetParticleName(); + G4String MaterialName = it->second->GetName(); + G4String ElementName = it->second->GetElement(i)->GetName(); + + path1 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_elastic_" + ParticleName + "_" + ElementName + ".dat"; + path2 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_inelastic_" + ParticleName + "_" + ElementName + ".dat"; + path3 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_capture_" + ParticleName + "_" + ElementName + ".dat"; + path4 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_fission_" + ParticleName + "_" + ElementName + ".dat"; + + ofstream ofile_elastic; + ofstream ofile_inelastic; + ofstream ofile_capture; + ofstream ofile_fission; + ofile_elastic.open(path1); + ofile_inelastic.open(path2); + ofile_capture.open(path3); + ofile_fission.open(path4); + //std::cout << path << std::endl; + double xs; + double step_keV = 1*keV; + double step_eV = 1*eV; + double step_meV = 50e-3*eV; + //for(G4double E=Emin+step; E<Emax; E+=step){ + double E=Emin; + while(E<Emax){ + if(E<1e-3*eV) E+= 50e-6*eV; + else if(E<1*eV) E+= step_meV; + else if(E>1*eV && E<1*keV) E += step_eV; + else E += step_keV; + if(E>1*keV){ + // Elastic Cross Section + xs = store->GetElasticCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); + ofile_elastic << E/MeV << " " << xs/barn << G4endl; + + // Inelastic Cross Section + xs = store->GetInelasticCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); + ofile_inelastic << E/MeV << " " << xs/barn << G4endl; + } + // Capture Cross Section + xs = store->GetCaptureCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); + ofile_capture << E/MeV << " " << xs/barn << G4endl; + + // Fission Cross Section + xs = store->GetFissionCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); + ofile_fission << E/MeV << " " << xs/barn << G4endl; + } + + ofile_elastic.close(); + ofile_inelastic.close(); + ofile_capture.close(); + ofile_fission.close(); + } + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Generate Cross Section table using the material used in the geomtry +void MaterialManager::WriteCrossSectionTable(std::set<string> Particle, G4double Emin, G4double Emax){ + std::set<string>::iterator it; + for (it = Particle.begin(); it != Particle.end(); it++) { + G4ParticleDefinition* p + = G4ParticleTable::GetParticleTable()->FindParticle((*it)); + if(p->GetParticleName()=="neutron"){ + WriteCrossSectionTable(p, Emin, Emax); + } + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void MaterialManager::CreateSampleVolumes(G4LogicalVolume* world_log) { @@ -1024,18 +1311,18 @@ void MaterialManager::CreateSampleVolumes(G4LogicalVolume* world_log) { G4double SampleSize = 1 * um; G4double WorldSize = 10.0 * m; G4Box* sample_box - = new G4Box("sample_box", SampleSize, SampleSize, SampleSize); + = new G4Box("sample_box", SampleSize, SampleSize, SampleSize); G4int i = 1; G4double Coord1 = WorldSize - SampleSize; G4double Coord2 = 0; map<string, G4Material*>::iterator it; for (it = m_Material.begin(); it != m_Material.end(); it++) { G4LogicalVolume* sample_log - = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0); + = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0); sample_log->SetVisAttributes(G4VisAttributes::Invisible); Coord2 = WorldSize - i * 2 * SampleSize; i++; new G4PVPlacement(0, G4ThreeVector(Coord1, Coord2, -Coord1), sample_log, - "sample", world_log, false, 0); + "sample", world_log, false, 0); } } diff --git a/NPSimulation/Core/MaterialManager.hh b/NPSimulation/Core/MaterialManager.hh index 977f988a8186dadc5fe5b837ef839f1d6a2847a5..d1b78b84cc60b107fb69c53e14edec6bebe07bda 100644 --- a/NPSimulation/Core/MaterialManager.hh +++ b/NPSimulation/Core/MaterialManager.hh @@ -96,5 +96,14 @@ public: // for a list of particle name void WriteDEDXTable(std::set<string> Particle ,G4double Emin,G4double Emax); + // Write the Cross Section table for all material instantiate in the MaterialManager + // for a given particle + void WriteCrossSectionTable(G4ParticleDefinition* Particle ,G4double Emin,G4double Emax); + + // Write the Cross Section table for all material instantiate in the MaterialManager + // for a list of particle name + void WriteCrossSectionTable(std::set<string> Particle ,G4double Emin,G4double Emax); + + }; #endif diff --git a/NPSimulation/Core/ParticleStack.cc b/NPSimulation/Core/ParticleStack.cc index 769fcb2bcd5f88e59cabb7bec09b1d1b1c584a5f..9d52f4024450a9376cee50aef637832be20a52ec 100644 --- a/NPSimulation/Core/ParticleStack.cc +++ b/NPSimulation/Core/ParticleStack.cc @@ -91,8 +91,13 @@ void ParticleStack::AddParticleToStack(Particle& particle){ // If the particle is the first one to be added, then the IC are cleared if(m_First) m_InitialConditions->Clear(); - + m_ParticleStack.push_back(particle); + + //m_InitialConditions-> SetIncidentInitialKineticEnergy (particle. GetParticleKineticEnergy()); + m_InitialConditions-> SetIncidentPositionX (particle. GetParticlePosition().x()); + m_InitialConditions-> SetIncidentPositionY (particle. GetParticlePosition().y()); + m_InitialConditions-> SetIncidentPositionZ (particle. GetParticlePosition().z()); m_First=false; } diff --git a/NPSimulation/Core/RunAction.cc b/NPSimulation/Core/RunAction.cc index 3d91ba45d760623cec6c07a7045c953ed633d310..a3a503e00f645f7c1815f708a40a676ee75553b1 100644 --- a/NPSimulation/Core/RunAction.cc +++ b/NPSimulation/Core/RunAction.cc @@ -30,6 +30,7 @@ #include "G4Event.hh" #include "G4VTrajectory.hh" #include "G4RegionStore.hh" +//----------------------// // NPL #include "RootOutput.h" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -68,9 +69,12 @@ void RunAction::EndOfRunAction(const G4Run* aRun){ for(unsigned int e = 0 ; e < sizeE ; e++){ TrajectoryVector* traj = (*events)[e]->GetTrajectoryContainer()->GetVector(); unsigned int size = traj->size(); + for(unsigned int i = 0 ; i < size ; i++) Particles.insert( (*traj)[i]->GetParticleName()); } - MaterialManager::getInstance()->WriteDEDXTable(Particles,0,10*GeV); + MaterialManager::getInstance()->WriteCrossSectionTable(Particles,0,20*MeV); } + + diff --git a/NPSimulation/Detectors/AGATA/AGATA.cc b/NPSimulation/Detectors/AGATA/AGATA.cc index 2b5d1a717f3b6e9a48c7d64a137538ec8578ad3d..8ce56b5fba26ca0cc9a8ab6828e8d2823133ec65 100644 --- a/NPSimulation/Detectors/AGATA/AGATA.cc +++ b/NPSimulation/Detectors/AGATA/AGATA.cc @@ -60,7 +60,7 @@ namespace AGATA_NS{ const double EnergyThreshold = 1*keV; const double ResoTime = 4.5*ns ; const double ResoEnergy = 2*keV ; - const double ResoAngle = 5*deg; + //const double ResoAngle = 5*deg; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Detectors/Actar/Actar.cc b/NPSimulation/Detectors/Actar/Actar.cc index 98592a35e713c7354dfbd8a08a643c91256fce35..b45b90f881f75cc4842112e0a6a94a2c7a16b55e 100644 --- a/NPSimulation/Detectors/Actar/Actar.cc +++ b/NPSimulation/Detectors/Actar/Actar.cc @@ -78,7 +78,7 @@ using namespace CLHEP; namespace Actar_NS{ // Energy and time Resolution const double ChargeThreshold = 0; - const double ResoTime = 0.1*ns ; + //const double ResoTime = 0.1*ns ; const double ResoCharge = 5./100 ; const double ChamberThickness = 376*mm ; const double ChamberWidth = 376*mm ; @@ -117,7 +117,7 @@ namespace Actar_NS{ const double CsIWidth = 2.5*cm; const double DistInterCsI = 1.*mm; const double CsI_PosZ = 16.*cm; - const double ResoCsI = 0.200/2.35; + //const double ResoCsI = 0.200/2.35; const double BeamDumpRadius = 30*mm; const double BeamDumpThickness = 5*mm; @@ -149,7 +149,7 @@ Actar::Actar(){ m_build_Silicon=1; m_build_Vamos_Silicon=0; m_build_CsI=1; - + m_ReactionRegion=NULL; // Lookup table // // bool ReadingLookupTable = false; string LT_FileName = "./Detectors/Actar/LT.dat"; @@ -598,7 +598,6 @@ void Actar::ConstructDetector(G4LogicalVolume* world){ BuildDetector(), "Actar",world,false,i+1); } - if(!m_ReactionRegion){ G4ProductionCuts* ecut = new G4ProductionCuts(); ecut->SetProductionCut(1000,"e-"); @@ -612,21 +611,17 @@ void Actar::ConstructDetector(G4LogicalVolume* world){ Region_cut->SetProductionCuts(ecut); Region_cut->AddRootLogicalVolume(m_SquareDetector); } - G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); - unsigned int size = m_ReactionModel.size(); for(unsigned int i = 0 ; i < size ; i++){ mng->RemoveFastSimulationModel(m_ReactionModel[i]); } - m_ReactionModel.clear(); G4VFastSimulationModel* fsm; fsm = new NPS::BeamReaction("BeamReaction",m_ReactionRegion); m_ReactionModel.push_back(fsm); fsm = new NPS::Decay("Decay",m_ReactionRegion); m_ReactionModel.push_back(fsm); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. diff --git a/NPSimulation/Detectors/ChiNu/CMakeLists.txt b/NPSimulation/Detectors/ChiNu/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..34f8184209c62387d4a4617a70963203bf3d37d8 --- /dev/null +++ b/NPSimulation/Detectors/ChiNu/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSChiNu SHARED ChiNu.cc) +target_link_libraries(NPSChiNu NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPChiNu) diff --git a/NPSimulation/Detectors/ChiNu/ChiNu.cc b/NPSimulation/Detectors/ChiNu/ChiNu.cc new file mode 100644 index 0000000000000000000000000000000000000000..1f948124ecc42431b681979acc051ec1cba2b5fe --- /dev/null +++ b/NPSimulation/Detectors/ChiNu/ChiNu.cc @@ -0,0 +1,532 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : February 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe ChiNu simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Tubs.hh" +#include "G4Box.hh" +#include "G4Cons.hh" +#include "G4Sphere.hh" +#include "G4Polycone.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4Material.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4SubtractionSolid.hh" + +// NPTool header +#include "ChiNu.hh" +#include "CalorimeterScorers.hh" +#include "InteractionScorers.hh" +#include "RootOutput.h" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" +#include "NPOptionManager.h" +#include "NPSHitsMap.hh" +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace ChiNu_NS{ + // EJ309 Scintillator - Energy and time Resolution + const double EnergyThreshold = 0.*MeV; + const double ResoTime = 1*ns ; + const double ResoEnergy = 0.1*MeV ; + const double Radius = 8.90*cm ; + const double Thickness = 5.08*cm ; + const string Material = "EJ309"; + + // PMT + const double PMT_Height = 392*mm; + const string PMT_Material = "Al"; + + // Light guide + const double LG_Rmin1 = 0*mm; + const double LG_Rmax1 = Radius; + const double LG_Rmin2 = 0*mm; + const double LG_Rmax2 = 50*mm; + const double LG_Thickness = 30*mm; + const string LG_Material = "PMMA"; + + // Pyrex Window + const double Pyrex_radius = Radius; + const double Pyrex_thickness = 6.4*mm; + const string Pyrex_material = "Pyrex"; + + // Lead shield + const double Lead_Radius = 9*cm; + const double Lead_Thickness = 2*mm; + + // Fission Chamber + const string FCWall_Material = "CH2"; + const double Cu_Thickness = 17*micrometer; + // const double Al_Thickness = 12*micrometer; + const double Kapton_Thickness = 50*micrometer; +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// ChiNu Specific Method +ChiNu::ChiNu(){ + m_Event = new TChiNuData() ; + m_ChiNuScorer = 0; + m_PMT = 0; + m_LightGuide = 0; + m_CylindricalDetector = 0; + m_LeadShield = 0; + m_AssemblyVolume = 0; + + m_BuildLeadShield = 0; + + m_FissionChamberWall = 0; + m_FissionChamberVolume = 0; + + // RGB Color + Transparency + m_VisCylinder = new G4VisAttributes(G4Colour(0.0, 0.5, 1, 1)); + m_VisPMT = new G4VisAttributes(G4Colour(0.3, 0.1, 0.1, 0.3)); + m_VisLightGuide = new G4VisAttributes(G4Colour(0.1,0.5,0.7,1)); + m_VisPyrex = new G4VisAttributes(G4Colour(0.1,0.5,0.7,0.7)); + m_VisLeadShield = new G4VisAttributes(G4Colour(0.2,0.2,0.2,1)); + m_VisFCWall = new G4VisAttributes(G4Colour(0.1,0.5,0.7,1)); + m_VisAl = new G4VisAttributes(G4Colour(0.839,0.803,0.803,1)); + m_VisTi = new G4VisAttributes(G4Colour(0.776,0.662,0.662,0.5)); + m_VisCu = new G4VisAttributes(G4Colour(0.70, 0.40, 0. ,1)); + m_VisRogers4003C = new G4VisAttributes(G4Colour(0.60, 0.60, 0.2 ,1)); +} + +ChiNu::~ChiNu(){ +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void ChiNu::AddDetector(G4ThreeVector POS){ + // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 + m_R.push_back(POS.mag()); + m_Theta.push_back(POS.theta()); + m_Phi.push_back(POS.phi()); +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void ChiNu::AddDetector(double R, double Theta, double Phi){ + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4AssemblyVolume* ChiNu::BuildFissionChamber(){ + if(!m_FissionChamberVolume){ + m_FissionChamberVolume = new G4AssemblyVolume(); + + G4RotationMatrix *Rv=new G4RotationMatrix(0,0,0); + G4ThreeVector Tv; + Tv.setX(0); Tv.setY(0); Tv.setZ(0); + + // Bottom PCB plate // + double PCB_width = 18.*cm; + double PCB_length = 33.*cm; + double PCB_Rogers_height = 1.6*mm; + double PCB_Cu_height = 6*35.*um; + double PCB_PosY = -8.5*cm; + // Cu layers + G4Box* PCB_Cu_solid = new G4Box("PCB_Cu_solid",0.5*PCB_width,0.5*PCB_Cu_height,0.5*PCB_length); + G4Material* Cu_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); + G4LogicalVolume* PCB_Cu_vol = new G4LogicalVolume(PCB_Cu_solid, Cu_material,"PCB_Cu_logic",0,0,0); + PCB_Cu_vol->SetVisAttributes(m_VisCu); + Tv.setY(PCB_PosY); + m_FissionChamberVolume->AddPlacedVolume(PCB_Cu_vol, Tv, Rv); + + // Rogers 4003C layers + G4Box* PCB_Rogers_solid = new G4Box("PCB_Rogers_solid",0.5*PCB_width,0.5*PCB_Rogers_height,0.5*PCB_length); + G4Material* Rogers_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Rogers4003C"); + G4LogicalVolume* PCB_Rogers_vol = new G4LogicalVolume(PCB_Rogers_solid, Rogers_material,"PCB_Rogers_logic",0,0,0); + PCB_Rogers_vol->SetVisAttributes(m_VisRogers4003C); + Tv.setY(PCB_PosY + 0.5*PCB_Cu_height + 0.5*PCB_Rogers_height); + m_FissionChamberVolume->AddPlacedVolume(PCB_Rogers_vol, Tv, Rv); + + //Al frame // + double frame1_width = 18.*cm; + double frame1_height = 5.*mm; + double frame1_length = 33.*cm; + double frame2_width = 15.2*cm; + double frame2_height = 5.1*mm; + double frame2_length = 30.2*cm; + + G4Box* frame1 = new G4Box("frame1", 0.5*frame1_width, 0.5*frame1_height, 0.5*frame1_length); + G4Box* frame2 = new G4Box("frame2", 0.5*frame2_width, 0.5*frame2_height, 0.5*frame2_length); + G4VSolid* Al_frame = (G4VSolid*) new G4SubtractionSolid("Al_frame",frame1,frame2,0,G4ThreeVector(0,0,0)); + G4Material* Al_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4LogicalVolume* Al_frame_vol = new G4LogicalVolume(Al_frame,Al_material,"Al_frame_logic",0,0,0); + Al_frame_vol->SetVisAttributes(m_VisAl); + Tv.setY(PCB_PosY+ 0.5*PCB_Cu_height + PCB_Rogers_height + 0.5*frame1_height); + m_FissionChamberVolume->AddPlacedVolume(Al_frame_vol, Tv, Rv); + Tv.setY(PCB_PosY- 0.5*PCB_Cu_height - 0.5*frame1_height); + m_FissionChamberVolume->AddPlacedVolume(Al_frame_vol, Tv, Rv); + + double box1_width = 15.*cm; + double box1_height = 16.*cm; + double box1_length = 30.*cm; + double box2_width = 14.8*cm; + double box2_height = 15.8*cm; + double box2_length = 29.8*cm; + double box3_width = 12.5*cm; + double box3_height = 11.7*cm; + double box3_length = 30.1*cm; + double box4_width = 15.1*cm; + double box4_height = 11.8*cm; + double box4_length = 27.4*cm; + double box5_width = 12.4*cm; + double box5_height = 16.1*cm; + double box5_length = 27.4*cm; + + G4Box* box1 = new G4Box("box1", 0.5*box1_width, 0.5*box1_height, 0.5*box1_length); + G4Box* box2 = new G4Box("box2", 0.5*box2_width, 0.5*box2_height, 0.5*box2_length); + G4Box* box3 = new G4Box("box3", 0.5*box3_width, 0.5*box3_height, 0.5*box3_length); + G4Box* box4 = new G4Box("box4", 0.5*box4_width, 0.5*box4_height, 0.5*box4_length); + G4Box* box5 = new G4Box("box5", 0.5*box5_width, 0.5*box5_height, 0.5*box5_length); + + G4VSolid* box_int1 = (G4VSolid*) new G4SubtractionSolid("box_int1",box1,box2,0,G4ThreeVector(0,0,0)); + G4VSolid* box_int2 = (G4VSolid*) new G4SubtractionSolid("box_int2",box_int1,box3,0,G4ThreeVector(0,0,0)); + G4VSolid* box_int3 = (G4VSolid*) new G4SubtractionSolid("box_int3",box_int2,box4,0,G4ThreeVector(0,0,0)); + G4VSolid* box_int4 = (G4VSolid*) new G4SubtractionSolid("box_int4",box_int3,box5,0,G4ThreeVector(0,0,0)); + + G4LogicalVolume* full_box_vol = new G4LogicalVolume(box_int4, Al_material, "full_box_logic", 0,0,0); + full_box_vol->SetVisAttributes(m_VisAl); + Tv.setY(0); + m_FissionChamberVolume->AddPlacedVolume(full_box_vol, Tv, Rv); + + // Ti foils // + double foil1_width = 13*cm; + double foil1_length = 29*cm; + double foil1_thickness = 100*um; + double foil2_width = 13*cm; + double foil2_height = 14*cm; + double foil2_thickness = 50*um; + + G4Material* Ti_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Ti"); + G4Box* foil1_solid = new G4Box("foil1", 0.5*foil1_width, 0.5*foil1_thickness, 0.5*foil1_length); + G4LogicalVolume* foil1_vol = new G4LogicalVolume(foil1_solid, Ti_material, "foil1_logic", 0, 0, 0); + foil1_vol->SetVisAttributes(m_VisTi); + Tv.setY(0.5*box2_height); + m_FissionChamberVolume->AddPlacedVolume(foil1_vol, Tv, Rv); + Tv.setY(0); + Tv.setX(-0.5*box2_width); + Rv->rotateZ(90*deg); + m_FissionChamberVolume->AddPlacedVolume(foil1_vol, Tv, Rv); + Tv.setX(0.5*box2_width); + m_FissionChamberVolume->AddPlacedVolume(foil1_vol, Tv, Rv); + + G4Box* foil2_solid = new G4Box("foil2", 0.5*foil2_width, 0.5*foil2_height, 0.5*foil2_thickness); + G4LogicalVolume* foil2_vol = new G4LogicalVolume(foil2_solid, Ti_material, "foil2_logic", 0, 0, 0); + foil2_vol->SetVisAttributes(m_VisTi); + Tv.setX(0);Tv.setY(0);Tv.setZ(-0.5*box2_length); + m_FissionChamberVolume->AddPlacedVolume(foil2_vol, Tv, Rv); + Tv.setZ(0.5*box2_length); + m_FissionChamberVolume->AddPlacedVolume(foil2_vol, Tv, Rv); + + // Cathode and Anode // + BuildCathode(-27.5); + double origine_anode = -25*mm; + double origine_cathode = -22.5*mm; + for(int i=0; i<11; i++){ + BuildAnode(origine_anode+i*5*mm); + } + for(int i=0; i<10; i++){ + BuildCathode(origine_cathode+i*5*mm); + } + BuildCathode(27.5); + + + } + return m_FissionChamberVolume; +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void ChiNu::BuildCathode(double Zpos){ + // Al plate: 12 um + G4Tubs* Al_plate_solid = new G4Tubs("Al_plate",0,40*mm,12*micrometer,0,360*deg); + G4Material* Al_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4LogicalVolume* Al_vol = new G4LogicalVolume(Al_plate_solid, Al_material,"logic_Al",0,0,0); + Al_vol->SetVisAttributes(m_VisAl); + + G4RotationMatrix *Rv=new G4RotationMatrix(0,0,0); + G4ThreeVector Tv; + Tv.setX(0); Tv.setY(0); Tv.setZ(0); + + Tv.setZ(Zpos); + m_FissionChamberVolume->AddPlacedVolume(Al_vol, Tv, Rv); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void ChiNu::BuildAnode(double Zpos){ + // Cu plate: 17 um + G4Tubs* Cu_plate_solid = new G4Tubs("Cu_plate",0,40*mm,0.5*ChiNu_NS::Cu_Thickness,0,360*deg); + G4Material* Cu_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); + G4LogicalVolume* Cu_vol = new G4LogicalVolume(Cu_plate_solid, Cu_material,"logic_Cu",0,0,0); + Cu_vol->SetVisAttributes(m_VisCu); + + // Kapton: 50 um + G4Tubs* Kapton_solid = new G4Tubs("Kapton",0,40*mm,0.5*ChiNu_NS::Kapton_Thickness,0,360*deg); + G4Material* Kapton_material = MaterialManager::getInstance()->GetMaterialFromLibrary("Kapton"); + G4LogicalVolume* Kapton_vol = new G4LogicalVolume(Kapton_solid, Kapton_material,"logic_Kapton",0,0,0); + Kapton_vol->SetVisAttributes(m_VisFCWall); + + G4RotationMatrix *Rv=new G4RotationMatrix(0,0,0); + G4ThreeVector Tv; + Tv.setX(0); Tv.setY(0); Tv.setZ(0); + + Tv.setZ(Zpos); + m_FissionChamberVolume->AddPlacedVolume(Kapton_vol, Tv, Rv); + Tv.setZ(Zpos-0.5*ChiNu_NS::Kapton_Thickness-0.5*ChiNu_NS::Cu_Thickness); + m_FissionChamberVolume->AddPlacedVolume(Cu_vol, Tv, Rv); + Tv.setZ(Zpos+0.5*ChiNu_NS::Kapton_Thickness+0.5*ChiNu_NS::Cu_Thickness); + m_FissionChamberVolume->AddPlacedVolume(Cu_vol, Tv, Rv); + + +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4AssemblyVolume* ChiNu::BuildDetector(){ + if(!m_CylindricalDetector){ + m_AssemblyVolume = new G4AssemblyVolume(); + G4RotationMatrix *Rv=new G4RotationMatrix(0,0,0); + G4ThreeVector Tv; + Tv.setX(0); Tv.setY(0); Tv.setZ(0); + + // Scintillator + G4Tubs* tub = new G4Tubs("ChiNu_Cyl",0,ChiNu_NS::Radius,ChiNu_NS::Thickness*0.5,0,360*deg); + G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(ChiNu_NS::Material); + m_CylindricalDetector = new G4LogicalVolume(tub,DetectorMaterial,"logic_ChiNu_tub",0,0,0); + m_CylindricalDetector->SetVisAttributes(m_VisCylinder); + m_CylindricalDetector->SetSensitiveDetector(m_ChiNuScorer); + m_AssemblyVolume->AddPlacedVolume(m_CylindricalDetector, Tv, Rv); + + // Pyrex Window + G4Tubs* Pyrex_tub = new G4Tubs("Pyrex_tub",0,ChiNu_NS::Pyrex_radius, ChiNu_NS::Pyrex_thickness*0.5, 0 , 360*deg); + G4Material* PyrexMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(ChiNu_NS::Pyrex_material); + G4LogicalVolume* LogPyrex = new G4LogicalVolume(Pyrex_tub, PyrexMaterial,"logic_pyrex",0,0,0); + LogPyrex->SetVisAttributes(m_VisPyrex); + Tv.setZ(ChiNu_NS::Thickness*0.5 + ChiNu_NS::Pyrex_thickness*0.5); + m_AssemblyVolume->AddPlacedVolume(LogPyrex, Tv, Rv); + + + // Light guide + G4Cons* LGsolid = new G4Cons("light_guide", ChiNu_NS::LG_Rmin1, ChiNu_NS::LG_Rmax1, ChiNu_NS::LG_Rmin2, ChiNu_NS::LG_Rmax2, ChiNu_NS::LG_Thickness*0.5,0,360*deg); + G4Material* LGMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(ChiNu_NS::LG_Material); + m_LightGuide = new G4LogicalVolume(LGsolid,LGMaterial,"logic_light_guide",0,0,0); + m_LightGuide->SetVisAttributes(m_VisLightGuide); + Tv.setZ(ChiNu_NS::Thickness*0.5 + ChiNu_NS::Pyrex_thickness + ChiNu_NS::LG_Thickness*0.5); + m_AssemblyVolume->AddPlacedVolume(m_LightGuide, Tv, Rv); + + // PMT + //G4Tubs* pmt = new G4Tubs("ChiNu_pmt",ChiNu_NS::PMT_InnerDiameter*0.5,ChiNu_NS::PMT_OuterDiameter*0.5,ChiNu_NS::PMT_Thickness*0.5,0,360*deg); + + double zplane[4] ={0, 18*cm, 24*cm, ChiNu_NS::PMT_Height}; + double rin[4] = {ChiNu_NS::Radius+0.2*mm, ChiNu_NS::Radius+0.2*mm, 40*mm, 40*mm}; + double rout[4] = {ChiNu_NS::Radius+2.2*mm, ChiNu_NS::Radius+2.2*mm, 42*mm, 42*mm}; + G4Polycone* pmt = new G4Polycone("ChiNu_PMT", 0, 360*deg, 4, zplane, rin, rout); + G4Material* pmtMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(ChiNu_NS::PMT_Material); + m_PMT = new G4LogicalVolume(pmt,pmtMaterial,"logic_pmt_tub",0,0,0); + m_PMT->SetVisAttributes(m_VisPMT); + //Tv.setZ(ChiNu_NS::Thickness*0.5 + ChiNu_NS::LG_Thickness + ChiNu_NS::Pyrex_thickness + ChiNu_NS::PMT_Height*0.5); + Tv.setZ(-ChiNu_NS::Thickness*0.5); + m_AssemblyVolume->AddPlacedVolume(m_PMT, Tv, Rv); + + // Lead shield + if(m_BuildLeadShield){ + G4Tubs* lead = new G4Tubs("lead_shield", 0, ChiNu_NS::Lead_Radius, ChiNu_NS::Lead_Thickness*0.5, 0, 360*deg); + G4Material* LeadMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); + m_LeadShield = new G4LogicalVolume(lead, LeadMaterial, "logic_lead_shield",0,0,0); + m_LeadShield->SetVisAttributes(m_VisLeadShield); + Tv.setZ(-ChiNu_NS::Thickness*0.5 - ChiNu_NS::Lead_Thickness*0.5-10*mm); + m_AssemblyVolume->AddPlacedVolume(m_LeadShield, Tv, Rv); + } + + } + return m_AssemblyVolume; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void ChiNu::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ChiNu"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS"}; + vector<string> sphe = {"R","Theta","Phi"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// ChiNu " << i+1 << endl; + + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); + AddDetector(Pos); + } + else if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// ChiNu " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + m_BuildLeadShield = blocks[i]->GetInt("LeadShield"); + AddDetector(R,Theta,Phi); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void ChiNu::ConstructDetector(G4LogicalVolume* world){ + + for (unsigned short i = 0 ; i < m_R.size() ; i++) { + + G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; + G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; + G4double wZ = m_R[i] * cos(m_Theta[i] ) ; + G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; + // So the face of the detector is at R instead of the middle + Det_pos+=Det_pos.unit()*ChiNu_NS::Thickness*0.5; + // Building Detector reference frame + G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]); + G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]); + G4double kk = -sin(m_Theta[i]); + G4ThreeVector Y(ii,jj,kk); + G4ThreeVector w = Det_pos.unit(); + G4ThreeVector u = w.cross(Y); + G4ThreeVector v = w.cross(u); + v = v.unit(); + u = u.unit(); + + G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); + BuildDetector()->MakeImprint(world,Det_pos,Rot,i); + } + + G4RotationMatrix* Rot_FC = new G4RotationMatrix(0,0,0); + G4ThreeVector Pos_FC = G4ThreeVector(0,0,0) ; + BuildFissionChamber()->MakeImprint(world,Pos_FC,Rot_FC,0); + + +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void ChiNu::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("ChiNu")){ + pTree->Branch("ChiNu", "TChiNuData", &m_Event) ; + } + pTree->SetBranchAddress("ChiNu", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void ChiNu::ReadSensitive(const G4Event* ){ + m_Event->Clear(); + + /////////// + // Calorimeter scorer + CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_ChiNuScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for(unsigned int i = 0 ; i < size ; i++){ + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i),ChiNu_NS::ResoEnergy); + if(Energy>ChiNu_NS::EnergyThreshold){ + double Time = RandGauss::shoot(Scorer->GetTime(i),ChiNu_NS::ResoTime); + int DetectorNbr = level[0]; + m_Event->SetEnergy(DetectorNbr,Energy); + m_Event->SetTime(DetectorNbr,Time); + } + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void ChiNu::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_ChiNuScorer = CheckScorer("ChiNuScorer",already_exist) ; + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + vector<int> level; level.push_back(0); + G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; + G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; + //and register it to the multifunctionnal detector + m_ChiNuScorer->RegisterPrimitive(Calorimeter); + m_ChiNuScorer->RegisterPrimitive(Interaction); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ChiNuScorer) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* ChiNu::Construct(){ + return (NPS::VDetector*) new ChiNu(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_ChiNu{ + public: + proxy_nps_ChiNu(){ + NPS::DetectorFactory::getInstance()->AddToken("ChiNu","ChiNu"); + NPS::DetectorFactory::getInstance()->AddDetector("ChiNu",ChiNu::Construct); + } + }; + + proxy_nps_ChiNu p_nps_ChiNu; +} diff --git a/NPSimulation/Detectors/ChiNu/ChiNu.hh b/NPSimulation/Detectors/ChiNu/ChiNu.hh new file mode 100644 index 0000000000000000000000000000000000000000..879f101ae910fae1745f4d8625a7f3f303830ade --- /dev/null +++ b/NPSimulation/Detectors/ChiNu/ChiNu.hh @@ -0,0 +1,132 @@ +#ifndef ChiNu_h +#define ChiNu_h 1 +/***************************************************************************** + * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : February 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe ChiNu simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ header +#include <string> +#include <vector> +using namespace std; + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4AssemblyVolume.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool header +#include "NPSVDetector.hh" +#include "TChiNuData.h" +#include "NPInputParser.h" + +class ChiNu : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + ChiNu() ; + virtual ~ChiNu() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + // Cartesian + void AddDetector(G4ThreeVector POS); + // Spherical + void AddDetector(double R,double Theta,double Phi); + + + G4AssemblyVolume* BuildDetector(); + G4AssemblyVolume* BuildFissionChamber(); + void BuildAnode(double PosZ); + void BuildCathode(double PosZ); + + private: + G4LogicalVolume* m_CylindricalDetector; + G4LogicalVolume* m_PMT; + G4LogicalVolume* m_LightGuide; + G4LogicalVolume* m_LeadShield; + G4AssemblyVolume* m_AssemblyVolume; + + G4LogicalVolume* m_FissionChamberWall; + G4AssemblyVolume* m_FissionChamberVolume; + + //////////////////////////////////////////////////// + ////// Inherite from NPS::VDetector class ///////// + //////////////////////////////////////////////////// + public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + public: // Scorer + // Initialize all Scorer used by the MUST2Array + void InitializeScorers() ; + + // Associated Scorer + G4MultiFunctionalDetector* m_ChiNuScorer ; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TChiNuData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: // Geometry + // Detector Coordinate + vector<double> m_R; + vector<double> m_Theta; + vector<double> m_Phi; + bool m_BuildLeadShield; + + // Visualisation Attribute + G4VisAttributes* m_VisCylinder; + G4VisAttributes* m_VisPMT; + G4VisAttributes* m_VisLightGuide; + G4VisAttributes* m_VisPyrex; + G4VisAttributes* m_VisLeadShield; + G4VisAttributes* m_VisFCWall; + G4VisAttributes* m_VisAl; + G4VisAttributes* m_VisCu; + G4VisAttributes* m_VisTi; + G4VisAttributes* m_VisRogers4003C; + + // Needed for dynamic loading of the library + public: + static NPS::VDetector* Construct(); +}; +#endif diff --git a/NPSimulation/Detectors/Dali/Dali.cc b/NPSimulation/Detectors/Dali/Dali.cc index 84c1eb247c175828562e59f22c37809277ba84ab..561a665fadeb415d65cee0695606d419e7882f73 100644 --- a/NPSimulation/Detectors/Dali/Dali.cc +++ b/NPSimulation/Detectors/Dali/Dali.cc @@ -73,13 +73,13 @@ namespace Dali_NS{ // Energy and time Resolution const double EnergyThreshold = 0*MeV; const double ResoTime = 0.0*ns; //4.5*ns ; - const double ResoEnergy = 1.36*MeV ; // mean Resolution(FWHM) 1.7% of 80MeV from slides 20170214-SAMURAI34-setup-DALI.pdf if 1.7% of 30MeV = 0.51 MeV // 0.001*MeV ; - const double Radius = 50*mm ; + const double ResoEnergy = 0.122; //Relative resolution DeltaE = 0.122*Sqrt(E) + /* const double ResoEnergy = 1.36*MeV ; // mean Resolution(FWHM) 1.7% of 80MeV from slides 20170214-SAMURAI34-setup-DALI.pdf if 1.7% of 30MeV = 0.51 MeV // 0.001*MeV ; */ + //const double Radius = 50*mm ; const double Width = 49.76*mm ; const double Hight = 84.81*mm ; const double Thickness = 164.82*mm ; const double LengthPMT = 152.62*mm ; - const string Material = "NaI"; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -87,287 +87,194 @@ namespace Dali_NS{ // Dali Specific Method Dali::Dali(){ m_Event = new TDaliData() ; - m_DaliScorer = 0; m_SquareDetector = 0; - m_SquareDetector_Can = 0; - m_SquareDetector_CanMgO =0; - m_CylindricalDetector = 0; - m_SquareDetector_Crystal = 0; - Logic_ArrayDali_1 =0; - - // RGB Color + Transparency - m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 1/*, 0.3*/)); - m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1/*, 0.3*/)); - -} + m_DaliScorer = 0; + Log_Dali_1Volume = 0; + Log_Al_Cryst_can = 0; + Log_MgO_Cryst_can =0; + Log_Crystal = 0; + Log_Dali_3Volume=0; + } Dali::~Dali(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Dali::AddDetector(G4ThreeVector POS, string Shape){ +void Dali::AddDetector(G4ThreeVector POS ){ // Convert the POS value to R theta Phi as Cylindrical coordinate is easier in G4 m_R.push_back(POS.perp()); m_Alpha.push_back(POS.phi()); m_Zeta.push_back(POS.y()); - m_Shape.push_back(Shape); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Dali::AddDetector(double R, double Theta, double Phi, string Shape){ - +void Dali::AddDetector(double R, double Theta, double Phi){ double m_r, m_alpha, m_zeta; - m_r = R*cos(Phi); m_alpha = Theta; m_zeta = R*sin(Phi); - m_R.push_back(m_r); m_Alpha.push_back(m_alpha); m_Zeta.push_back(m_zeta); - m_Shape.push_back(Shape); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Dali::AddDetector2(double R, double Alpha, double Zeta, string Shape){ +void Dali::AddDetector(double R, double Alpha, double Zeta, int Ring){ m_R.push_back(R); m_Alpha.push_back(Alpha); m_Zeta.push_back(Zeta); - m_Shape.push_back(Shape); + m_Ring.push_back(Ring); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Definition Materials MgO and NaI(Tl) void Dali::DefinitionMaterials() { - //G4Element* H = new G4Element("Hydrogen","H" , 1., 1.01*g/mole); - - G4Isotope* Mg24 = new G4Isotope ("Mg24", 12, 24, 23.985041*g/mole); - G4Isotope* Mg25 = new G4Isotope ("Mg25", 12, 25, 24.985836*g/mole); - G4Isotope* Mg26 = new G4Isotope ("Mg26", 12, 26, 25.982592*g/mole); - G4Element* Mg= new G4Element("elMagnesium","Mg",3); - Mg->AddIsotope(Mg24, 78.99*perCent); - Mg->AddIsotope(Mg25, 10*perCent); - Mg->AddIsotope(Mg26, 11.01*perCent); - - G4Isotope* O16 = new G4Isotope ("O16", 8, 16, 15.99*g/mole); - G4Isotope* O17 = new G4Isotope ("O17", 8, 17, 17.00*g/mole); - G4Isotope* O18 = new G4Isotope ("O18", 8, 18, 18.00*g/mole); - G4Element* O = new G4Element("elOxygen","O",3); - O->AddIsotope(O16, 99.76*perCent); - O->AddIsotope(O17, 0.04*perCent); - O->AddIsotope(O18, 0.20*perCent); + + G4Element *Tl = new G4Element("Thallium","Tl",81.,204.383*g/mole ); - - MgO = new G4Material("MgO",3.6*g/cm3, 2 ); - MgO->AddElement(Mg,1); - MgO->AddElement(O, 1); - - G4Element *elTl = new G4Element("Thallium","Tl",81.,204.383*g/mole ); - NaI_Tl = new G4Material("NaI_Tl",3.6667*g/cm3, 2); NaI_Tl->AddMaterial(MaterialManager::getInstance()->GetMaterialFromLibrary("NaI"), 99.6*perCent); - NaI_Tl->AddElement(elTl, 0.4*perCent); - + NaI_Tl->AddElement(Tl, 0.4*perCent); + } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - G4LogicalVolume* Dali::BuildSquareDetector(){ if(!m_SquareDetector){ - -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - - G4Box* box_3can = new G4Box("Dali_3BoxCan", Dali_NS::Hight*0.5, - Dali_NS::Width*0.5*3, Dali_NS::Thickness*0.5 + Dali_NS::LengthPMT/2.+11.5/2.*mm /*last part is PMTVolume*/ ); - G4Material* Aria = MaterialManager::getInstance()->GetMaterialFromLibrary("Air"); - Logic_ArrayDali_1 = new G4LogicalVolume(box_3can,Aria,"logic_ArrayDali",0,0,0); - - Logic_ArrayDali_1->SetVisAttributes(G4VisAttributes(G4Colour(1,1,1, 0))); - - G4Box* box_can = new G4Box("Dali_BoxCan", Dali_NS::Hight*0.5, - Dali_NS::Width*0.5, Dali_NS::Thickness*0.5); - - G4Box* box_canandPMT = new G4Box("Dali_BoxCan", Dali_NS::Hight*0.5, - Dali_NS::Width*0.5, Dali_NS::Thickness*0.5 + Dali_NS::LengthPMT/2.+11.5/2.*mm /*last part is PMTVolume*/ ); - std::vector<G4TwoVector> polygon; - polygon.push_back(G4TwoVector(Dali_NS::Hight*0.5, Dali_NS::Width*0.5*3. ) ) ; - polygon.push_back(G4TwoVector(Dali_NS::Hight*0.5, -Dali_NS::Width*0.5*3. ) ) ; - polygon.push_back(G4TwoVector(-Dali_NS::Hight*0.5, -Dali_NS::Width*0.5*3. ) ) ; - polygon.push_back(G4TwoVector(-Dali_NS::Hight*0.5, Dali_NS::Width*0.5*3. ) ) ; - - // std::vector<ZSection> zsection; - // zsection.push_back(ZSection (Dali_NS::Thickness*0.5, {0,0}, 1. ) ); - // zsection.push_back(ZSection (-Dali_NS::Thickness*0.5-19.5*2.*mm , {0,0}, 1. ) ); - + polygon.push_back(G4TwoVector(Dali_NS::Hight*0.5, Dali_NS::Width*0.5*3.) ) ; + polygon.push_back(G4TwoVector(Dali_NS::Hight*0.5, -Dali_NS::Width*0.5*3.) ) ; + polygon.push_back(G4TwoVector(-Dali_NS::Hight*0.5, -Dali_NS::Width*0.5*3.) ) ; + polygon.push_back(G4TwoVector(-Dali_NS::Hight*0.5, Dali_NS::Width*0.5*3.) ) ; - G4Box* Extrudedbox_can = new G4Box("Dali_BoxCan", Dali_NS::Hight*0.5,Dali_NS::Width*0.5, Dali_NS::LengthPMT/2.+11.5/2.*mm); - + G4Material* Aria = MaterialManager::getInstance()->GetMaterialFromLibrary("Air"); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4Material* MgO = MaterialManager::getInstance()->GetMaterialFromLibrary("MgO"); + //G4Material* muMetal = MaterialManager::getInstance()->GetMaterialFromLibrary("mumetal"); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + //G4Material* BoroSili_Glass = MaterialManager::getInstance()->GetMaterialFromLibrary("Borosillicate_Glass"); + + ///// CONTENAIR VOLUMES + G4Box* Dali_3Volume = new G4Box("Dali_3Volume", + Dali_NS::Hight*0.5, + Dali_NS::Width*0.5*3, + Dali_NS::Thickness*0.5 + Dali_NS::LengthPMT/2.+11.5/2.*mm ); + Log_Dali_3Volume = new G4LogicalVolume(Dali_3Volume, + Aria,"log_Dali_3Volume",0,0,0); + G4Box* Dali_1Volume = new G4Box("Dali_1Volume", + Dali_NS::Hight*0.5, + Dali_NS::Width*0.5, + Dali_NS::Thickness*0.5 + Dali_NS::LengthPMT/2.+11.5/2.*mm ); + Log_Dali_1Volume = new G4LogicalVolume(Dali_1Volume, + Aria,"logic_1DaliVolume",0,0,0); + + G4Box* Extrudedbox_can = new G4Box("extrude_box", Dali_NS::Hight*0.5, + Dali_NS::Width*0.5, + Dali_NS::LengthPMT/2.+11.5/2.*mm); AriaExtrude = new G4LogicalVolume(Extrudedbox_can,Aria, "logic_Ariaextrude",0,0,0); - G4Material* DetectorCanMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_SquareDetector_Can = new G4LogicalVolume(box_can,DetectorCanMaterial,"logic_Dali_Can",0,0,0); - m_Square2Detector_Can = new G4LogicalVolume(box_canandPMT, Aria,"logic_Dali_CanandPMT",0,0,0); - - //THE PMT + /////// PMTs objets G4Tubs* AlPMT = new G4Tubs("AlPMT",16.5*mm, 19.5*mm,Dali_NS::LengthPMT/2.,0*deg,360*deg); + lAlPMT = new G4LogicalVolume(AlPMT, Vacuum ,"lAlPMT",0,0,0); + G4Tubs* MuPMT = new G4Tubs("MuPMT",16.5*mm,20.*mm,Dali_NS::LengthPMT/2.,0*deg,360*deg); + lMuPMT = new G4LogicalVolume(MuPMT, Vacuum ,"lMuPMT",0,0,0); + G4Box* TopPlatePMT = new G4Box("TopPlatePMT", Dali_NS::Hight*0.5-1*mm, - Dali_NS::Width*0.5-1*mm, 11.5/2.*mm ); + Dali_NS::Width*0.5-1*mm, + 11.5/2.*mm ); + lTopPlatePMT = new G4LogicalVolume(TopPlatePMT, Vacuum ,"lTopPlatePMT",0,0,0); + G4Tubs* GlassPMT = new G4Tubs("GlassPMT", 0. , 16.5*mm , 11.5/2.*mm ,0*deg,360*deg); + lGlassPMT = new G4LogicalVolume(GlassPMT , Vacuum ,"lGlassPMT",0,0,0); // Cyril - lAlPMT = new G4LogicalVolume(AlPMT, DetectorCanMaterial ,"lAlPMT",0,0,0); - lMuPMT = new G4LogicalVolume(MuPMT, DetectorCanMaterial ,"lMuPMT",0,0,0); - lTopPlatePMT = new G4LogicalVolume(TopPlatePMT, DetectorCanMaterial ,"lTopPlatePMT",0,0,0); - lGlassPMT = new G4LogicalVolume(GlassPMT , MaterialManager::getInstance()->GetMaterialFromLibrary("Borosillicate_Glass") ,"lGlassPMT",0,0,0); - - - G4VisAttributes* Can_Attributes = new G4VisAttributes(G4Colour(0.5,0.5,0.5, .3)); - m_SquareDetector_Can->SetVisAttributes(Can_Attributes); - m_Square2Detector_Can->SetVisAttributes(G4VisAttributes(G4Colour(1,1,1,0))); - - AriaExtrude->SetVisAttributes(G4VisAttributes(G4Colour(1,1,1,0))); - lAlPMT->SetVisAttributes(Can_Attributes); - lMuPMT->SetVisAttributes(Can_Attributes); - lTopPlatePMT->SetVisAttributes(Can_Attributes); - - G4Box* box_MgO = new G4Box("Dali_BoxMgO", Dali_NS::Hight*0.5-1*mm, - Dali_NS::Width*0.5-1*mm, Dali_NS::Thickness*0.5-1*mm); // Size of Al Can but w/o thickness of AlCan - - m_SquareDetector_CanMgO = new G4LogicalVolume(box_MgO,MgO,"logic_Dali_CanMg0",0,0,0); - G4Box* box_crystal = new G4Box("Dali_BoxNaI", Dali_NS::Hight*0.5-2.4*mm, - Dali_NS::Width*0.5-2.4*mm, Dali_NS::Thickness*0.5-2.4*mm); // Size of AlCan but w/o thickness of AlCan and MgO -// G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Dali_NS::Material); + //////////////// CRYSTAL part + G4Box* Al_Cryst_can = new G4Box("Al_Cryst_can", + Dali_NS::Hight*0.5, + Dali_NS::Width*0.5, + Dali_NS::Thickness*0.5); + Log_Al_Cryst_can = new G4LogicalVolume(Al_Cryst_can, + Al,"log_Al_Cryst_can",0,0,0); + + G4Box* MgO_Cryst_can = new G4Box("MgO_Cryst_can", + Dali_NS::Hight*0.5-1*mm, + Dali_NS::Width*0.5-1*mm, + Dali_NS::Thickness*0.5-1*mm); + Log_MgO_Cryst_can = new G4LogicalVolume(MgO_Cryst_can, + MgO, "logic_Dali_CanMg0",0,0,0); + + G4Box* Crystal = new G4Box("Crystal", + Dali_NS::Hight*0.5-2.4*mm, + Dali_NS::Width*0.5-2.4*mm, + Dali_NS::Thickness*0.5-2.4*mm); + Log_Crystal = new G4LogicalVolume(Crystal, + NaI_Tl,"logic_Dali_Box",0,0,0); - m_SquareDetector_Crystal = new G4LogicalVolume(box_crystal, - NaI_Tl, - // DetectorMaterial, - "logic_Dali_Box",0,0,0); - G4ThreeVector positionnull = G4ThreeVector(0,0,0); - - // PMT Volume - + // PMT part - new G4PVPlacement(0, positionnull, - lAlPMT , - "AlPMT", - lMuPMT, - false, - 0); + lAlPMT ,"AlPMT",lMuPMT,false,0); new G4PVPlacement(0, G4ThreeVector(0,0, -11.5/2.*mm ), - lMuPMT , - "MuPMT", - AriaExtrude, - false, - 0); - - - new G4PVPlacement(0, positionnull, - lGlassPMT, - "GlassPMT", - lTopPlatePMT, - false, - 0); + lMuPMT ,"MuPMT",AriaExtrude,false,0); + new G4PVPlacement(0, positionnull,lGlassPMT,"GlassPMT", + lTopPlatePMT,false,0); new G4PVPlacement(0, G4ThreeVector(0,0, Dali_NS::LengthPMT/2. ), - lTopPlatePMT, - "TopPlatePMT", - AriaExtrude, - false, - 0); - - - + lTopPlatePMT,"TopPlatePMT",AriaExtrude,false,0); new G4PVPlacement(0, G4ThreeVector(0,0, -Dali_NS::Thickness*0.5 ), - AriaExtrude, - "PMTVolume", - m_Square2Detector_Can, - false, - 0); - - - + AriaExtrude,"PMTVolume",Log_Dali_1Volume,false,0); + - new G4PVPlacement(0, G4ThreeVector(0,0, Dali_NS::LengthPMT/2.+11.5/2.*mm ), - m_SquareDetector_Can, + // Cryst Part - + new G4PVPlacement(0, G4ThreeVector(0,0, + Dali_NS::LengthPMT/2.+11.5/2.*mm ), + Log_Al_Cryst_can, "DetectorVolume", - m_Square2Detector_Can, - false, - 0); - - - // MgO Volume - + Log_Dali_1Volume,false,0); + new G4PVPlacement(0, positionnull, - m_SquareDetector_CanMgO, - "MgO", - m_SquareDetector_Can, - false, - 0); - G4VisAttributes* MgO_Attributes = new G4VisAttributes(G4Colour(1,1,1, .3)); - m_SquareDetector_CanMgO->SetVisAttributes(MgO_Attributes); - - - // NaI Volume - + Log_MgO_Cryst_can, + "MgO_Can", + Log_Al_Cryst_can,false,0); new G4PVPlacement(0, positionnull, - m_SquareDetector_Crystal, - "CrystalNaI", - m_SquareDetector_CanMgO, - false, - 0); - - m_SquareDetector_Crystal->SetVisAttributes(m_VisSquare); - m_SquareDetector_Crystal->SetSensitiveDetector(m_DaliScorer); - - - // new G4PVPlacement(0, positionnull, - // m_SquareDetector_Crystal, - // "CrystalNaI", - // m_SquareDetector_CanMgO, - // false, - // 0); - - - + Log_Crystal, + "CrystalNaI", + Log_MgO_Cryst_can,false,0); new G4PVReplica("DaliArrayElement", - m_Square2Detector_Can, - Logic_ArrayDali_1 , - kYAxis, - 3, - Dali_NS::Width, //????????? - 0); - - - - } - - return Logic_ArrayDali_1; -} + Log_Dali_1Volume, + Log_Dali_3Volume , + kYAxis,3,Dali_NS::Width,0); + + G4VisAttributes* MgO_Color = new G4VisAttributes(G4Colour(1,1,1, .4)); + G4VisAttributes* Al_Color = new G4VisAttributes(G4Colour(0.5,0.5,0.5, .3)); + G4VisAttributes* Crystal_Color = new G4VisAttributes(G4Colour(0, 1, 1)); + //G4VisAttributes* mumetal_Color = new G4VisAttributes(G4Colour(0, 0.5, 1, .3)); -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Dali::BuildCylindricalDetector(){ - if(!m_CylindricalDetector){ - G4Tubs* tub = new G4Tubs("Dali_Cyl",0,Dali_NS::Radius, Dali_NS::Thickness*0.5,0,360*deg); - G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Dali_NS::Material); - m_CylindricalDetector = new G4LogicalVolume(tub,DetectorMaterial,"logic_Dali_tub",0,0,0); - m_CylindricalDetector->SetVisAttributes(m_VisSquare); - m_CylindricalDetector->SetSensitiveDetector(m_DaliScorer); + Log_Dali_3Volume->SetVisAttributes(G4VisAttributes(G4Colour(1,1,1, 0))); + Log_Dali_1Volume->SetVisAttributes(G4VisAttributes(G4Colour(1,1,1,0))); + AriaExtrude->SetVisAttributes(G4VisAttributes(G4Colour(1,1,1,0))); + + Log_MgO_Cryst_can->SetVisAttributes(MgO_Color); + Log_Crystal->SetVisAttributes(Crystal_Color); + Log_Al_Cryst_can->SetVisAttributes(Al_Color); + + lAlPMT->SetVisAttributes(Al_Color); + lMuPMT->SetVisAttributes(Al_Color); + lTopPlatePMT->SetVisAttributes(Al_Color); + Log_Crystal->SetSensitiveDetector(m_DaliScorer); } - return m_CylindricalDetector; -} + return Log_Dali_3Volume; +} // end BuildSquareDetector //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -381,36 +288,25 @@ void Dali::ReadConfiguration(NPL::InputParser parser){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> cart = {"POS","Shape"}; - vector<string> sphe = {"R","Theta","Phi","Shape"}; - vector<string> cyli = {"R","Alpha","Zeta","Shape"}; + vector<string> cart = {"POS"}; + vector<string> cyli = {"R","Alpha","Zeta"}; for(unsigned int i = 0 ; i < blocks.size() ; i++){ if(blocks[i]->HasTokenList(cart)){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Dali " << i+1 << endl; - G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(Pos,Shape); - } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Dali " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(R,Theta,Phi,Shape); + AddDetector(Pos); } + else if(blocks[i]->HasTokenList(cyli)){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Dali " << i+1 << endl; double R = blocks[i]->GetDouble("R","mm"); double Alpha = blocks[i]->GetDouble("Alpha","deg"); double Zeta = blocks[i]->GetDouble("Zeta","mm"); - string Shape = blocks[i]->GetString("Shape"); - AddDetector2(R,Alpha,Zeta,Shape); + int Ring = blocks[i]->GetInt("Ring"); + AddDetector(R,Alpha,Zeta,Ring); } else{ cout << "ERROR: check your input file formatting " << endl; @@ -426,44 +322,25 @@ void Dali::ReadConfiguration(NPL::InputParser parser){ // Called After DetecorConstruction::AddDetector Method void Dali::ConstructDetector(G4LogicalVolume* world){ - DefinitionMaterials(); - for (unsigned short i = 0 ; i < m_R.size() ; i++) { - G4double wX = m_R[i] * cos(m_Alpha[i] ) ; G4double wY = m_R[i] * sin(m_Alpha[i] ) ; G4double wZ = m_Zeta[i]; - if(m_Zeta[i]<0) wZ = wZ - Dali_NS::LengthPMT/2.+11.5/2.*mm; - else wZ = wZ + Dali_NS::LengthPMT/2.+11.5/2.*mm; + if(m_Ring[i]==1) wZ = wZ - (Dali_NS::Thickness+11.5*mm+Dali_NS::LengthPMT)/2. + Dali_NS::Thickness/2.; + else wZ = wZ + (Dali_NS::Thickness+11.5*mm+Dali_NS::LengthPMT)/2. - Dali_NS::Thickness/2.; G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; - - G4RotationMatrix* Rot = new G4RotationMatrix(); - - - Rot->rotateX(180*deg); - if(m_Zeta[i]<0){ + if(m_Ring[i]==1){ Rot->rotateY(180*deg); Rot->rotateZ(m_Alpha[i]); } else{Rot->rotateZ(m_Alpha[i]);} - - if(m_Shape[i] == "Cylindrical"){ - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildCylindricalDetector(), - "Dali",world,false,i+1); - } - - else if(m_Shape[i] == "Square"){ - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildSquareDetector(), - "Dali",world,false,i+1); - - - } + new G4PVPlacement(G4Transform3D(*Rot,Det_pos), + BuildSquareDetector(), + "Dali",world,false,i+1); } } @@ -483,20 +360,17 @@ void Dali::InitializeRootOutput(){ // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion void Dali::ReadSensitive(const G4Event* ){ - m_Event->Clear(); + m_Event->Clear(); /////////// - // Calorimeter scorer CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_DaliScorer->GetPrimitive(0); //cout << m_DaliScorer->GetNumberOfPrimitives()<<endl; - - unsigned int size = Scorer->GetMult(); for(unsigned int i = 0 ; i < size ; i++){ vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Dali_NS::ResoEnergy); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Dali_NS::ResoEnergy*std::sqrt(Scorer->GetEnergy(i))); // cout << Energy << endl; if(Energy>Dali_NS::EnergyThreshold){ double Time = RandGauss::shoot(Scorer->GetTime(i),Dali_NS::ResoTime); @@ -505,6 +379,7 @@ void Dali::ReadSensitive(const G4Event* ){ int DetectorNbr = (ArrayNbr-1)*3+DetectinsArrayNbr; m_Event->SetEnergy(DetectorNbr,Energy); m_Event->SetTime(DetectorNbr,Time); + /* m_Event->SetParticleID(Scorer->GetParticleID(i)); */ } } } @@ -517,14 +392,13 @@ void Dali::InitializeScorers() { vector<int> NestingLevel; NestingLevel.push_back(3); NestingLevel.push_back(4); - + m_DaliScorer = CheckScorer("DaliScorer",already_exist) ; if(already_exist) //Necessary? return ; //Necessary? - // Otherwise the scorer is initialised -// vector<int> level; level.push_back(0); + // vector<int> level; level.push_back(0); G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter", NestingLevel) ; G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; //and register it to the multifunctionnal detector diff --git a/NPSimulation/Detectors/Dali/Dali.hh b/NPSimulation/Detectors/Dali/Dali.hh index 02fb8c6dd394c31c5b3180526c1ca79f131e3276..9b265abcecce41596b228bf9ebd46d77374f0deb 100644 --- a/NPSimulation/Detectors/Dali/Dali.hh +++ b/NPSimulation/Detectors/Dali/Dali.hh @@ -51,35 +51,33 @@ class Dali : public NPS::VDetector{ //////////////////////////////////////////////////// public: // Cartesian - void AddDetector(G4ThreeVector POS, string Shape); + void AddDetector(G4ThreeVector POS); // Spherical - void AddDetector(double R,double Theta,double Phi,string Shape); + void AddDetector(double R,double Theta,double Phi); //Cylindrical - void AddDetector2(double R,double Alpha,double Zeta,string Shape); + void AddDetector(double R,double Alpha,double Zeta, int Ring); G4LogicalVolume* BuildSquareDetector(); G4LogicalVolume* BuildCylindricalDetector(); private: + G4LogicalVolume* m_SquareDetector; - G4LogicalVolume* m_SquareDetector_Can; - G4LogicalVolume* m_Square2Detector_Can; - G4LogicalVolume* m_CylindricalDetector; - G4LogicalVolume* m_SquareDetector_CanMgO; - G4LogicalVolume* m_SquareDetector_Crystal; + G4LogicalVolume* Log_Dali_box; + G4LogicalVolume* Log_Al_Cryst_can; + G4LogicalVolume* Log_MgO_Cryst_can; + G4LogicalVolume* Log_Crystal; G4LogicalVolume* lAlPMT; + G4LogicalVolume* Log_Dali_1Volume; + G4LogicalVolume* Log_Dali_3Volume; + G4LogicalVolume* m_CylindricalDetector; G4LogicalVolume* lMuPMT; G4LogicalVolume* lTopPlatePMT; G4LogicalVolume* lGlassPMT; G4LogicalVolume* AriaExtrude; - G4LogicalVolume* Logic_ArrayDali_1; - G4Material* MgO; G4Material* NaI_Tl; - - - //////////////////////////////////////////////////// ////// Inherite from NPS::VDetector class ///////// //////////////////////////////////////////////////// @@ -91,7 +89,6 @@ class Dali : public NPS::VDetector{ // Definition of materials // Called in ConstructDetector() void DefinitionMaterials(); - // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method @@ -125,13 +122,10 @@ class Dali : public NPS::VDetector{ vector<double> m_Zeta; vector<double> m_R; vector<double> m_Alpha; + vector<int> m_Ring; - // Shape type - vector<string> m_Shape ; - // Visualisation Attribute G4VisAttributes* m_VisSquare; - G4VisAttributes* m_VisCylinder; // Needed for dynamic loading of the library public: diff --git a/NPSimulation/Detectors/Exogam/Exogam.cc b/NPSimulation/Detectors/Exogam/Exogam.cc index 7b6b5f3e01834fdc710621fdd7509d712cb12c86..698523717185af5b9b422784cf7dd5bd96af0a06 100644 --- a/NPSimulation/Detectors/Exogam/Exogam.cc +++ b/NPSimulation/Detectors/Exogam/Exogam.cc @@ -1,18 +1,18 @@ /***************************************************************************** - * Copyright (C) 2009-2019 this file is part of the NPTool Project * + * Copyright (C) 2009-2019 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: Thomas Goigoux contact address: thomas.goigoux@cea.fr * + * Original Author: Thomas Goigoux contact address: thomas.goigoux@cea.fr * * * - * Creation Date : july 2019 * + * Creation Date : july 2019 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class describe Exogam simulation * + * This class describe Exogam simulation * * * *---------------------------------------------------------------------------* * Comment: * @@ -72,7 +72,7 @@ using namespace CLHEP; namespace Exogam_NS{ // Energy and time Resolution const double EnergyThreshold = 10*keV; - const double ResoTime = 4.5*ns ; //not used + //const double ResoTime = 4.5*ns ; //not used const double ResoEnergy = 2.*keV ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -628,7 +628,7 @@ void Exogam::InitializeRootOutput(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Exogam::ReadSensitive(const G4Event* event){ +void Exogam::ReadSensitive(const G4Event*){ m_Event->Clear(); /////////// diff --git a/NPSimulation/Detectors/LightPipe/LightPipe.hh b/NPSimulation/Detectors/LightPipe/LightPipe.hh index 9980c8d220a36915901e9bfd29a84dd4259f0ae5..ea431390f5f20a919b74ea810859071f02a0c78d 100644 --- a/NPSimulation/Detectors/LightPipe/LightPipe.hh +++ b/NPSimulation/Detectors/LightPipe/LightPipe.hh @@ -1,20 +1,20 @@ #ifndef LightPipe_h #define LightPipe_h 1 /***************************************************************************** - * Copyright (C) 2009-2018 this file is part of the NPTool Project * + * Copyright (C) 2009-2018 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: Greg Christian contact address: gchristian@tamu.edu * + * Original Author: Greg Christian contact address: gchristian@tamu.edu * * * - * Creation Date : July 2018 * + * Creation Date : July 2018 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class describe LightPipe simulation * + * This class describe LightPipe simulation * * * *---------------------------------------------------------------------------* * Comment: * @@ -78,7 +78,7 @@ public: private: G4Material* m_ScintillatorMaterial; G4Material* m_PipeMaterial; - G4Material* m_WrappingMaterial; + //G4Material* m_WrappingMaterial; G4OpticalSurface* m_ReflectiveSurface; G4Material* CreateScintillatorMaterial() const; diff --git a/NPSimulation/Detectors/Miniball/Miniball.cc b/NPSimulation/Detectors/Miniball/Miniball.cc index 0da1686617c935f21e1078cbc970f3337309f91d..04821fddda63dcb6daa37af7c9dbd2cdb53041f5 100644 --- a/NPSimulation/Detectors/Miniball/Miniball.cc +++ b/NPSimulation/Detectors/Miniball/Miniball.cc @@ -58,7 +58,7 @@ namespace Miniball_NS{ const double EnergyThreshold = 0.01*MeV; const double ResoTime = 4.5*ns ; const double ResoEnergy = 0.003*MeV ; - const double ResoAngle = 5*deg; + //const double ResoAngle = 5*deg; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Detectors/Minos/Minos.cc b/NPSimulation/Detectors/Minos/Minos.cc index 121b390ae7d0a0403ab6412eb943044a3d119f0a..38a58decd0fe6476fa5193fcdeb8bb7d6d6a6c6d 100644 --- a/NPSimulation/Detectors/Minos/Minos.cc +++ b/NPSimulation/Detectors/Minos/Minos.cc @@ -80,18 +80,19 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... namespace Minos_NS{ - // TPC - const G4double ChamberInnerRadius = 37.*mm; - const G4double ChamberThickness = 2.*mm; - const G4double ChamberLength = 300.*mm; - const G4double InnerRohacellThickness = 1.*mm; - const G4double KaptonThickness = 0.125*mm; - const G4double OuterRohacellThickness = 2.*mm; - const G4double TPCRadiusExt = 91.525*mm; - - // MINOS - const G4double TargetRadius = 28.*mm; - const G4double WindowThickness = 0.150*mm; +// TPC +const G4double ChamberInnerRadius = 37.*mm; +/* const G4double ChamberInnerRadius = 29*mm; */ //big TPC +//const G4double ChamberThickness = 2.*mm; +const G4double ChamberLength = 300.*mm; +const G4double KaptonThickness = 0.125*mm; +const G4double RohacellThickness = 2.*mm; +const G4double TPCRadiusExt = 91.525*mm; +/* const G4double TPCRadiusExt = 150*mm; //big TPC */ + +// MINOS +const G4double TargetRadius = 28.*mm; +const G4double WindowThickness = 0.150*mm; } @@ -101,49 +102,41 @@ using namespace Minos_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Minos Specific Method Minos::Minos(){ - m_Event = new TMinosData() ; - m_MinosPadScorer = 0; - m_ReactionRegion=NULL; - - // RGB Color + Transparency - m_VisTarget= new G4VisAttributes(G4Colour(0.6,1.,1., .4)); - m_VissimpleBox= new G4VisAttributes(G4Colour(0,1,0,.6)); - m_VisTPC= new G4VisAttributes(G4Colour(1.,0.5,0.6,0.3)); - m_VisInnerRohacell= new G4VisAttributes(G4Colour(1.,1.,1., .3)); - m_VisOuterRohacell= new G4VisAttributes(G4Colour(1.,1.,1., .4)); - m_VisOuterOuterRohacell= new G4VisAttributes(G4Colour(1.,1.,1., .8)); - m_VisKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.4)); - m_VisTargetCell = new G4VisAttributes(G4Colour(0,0,1, .4)); - m_VisTargetCell->SetForceSolid(true); - m_VisOuterKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.8)); - - Raw_Signal = new TH1F("raw_Signal","raw_Signal",350,0,350); // 30ns per bin - Elec_Signal = new TH1F("Elec_Signal","Elec_Signal",350,0,350); - +m_Event = new TMinosData() ; +m_MinosPadScorer = 0; +m_ReactionRegion=NULL; + +// RGB Color + Transparency +m_VisTarget= new G4VisAttributes(G4Colour(0.6,1.,1., .4)); +m_VissimpleBox= new G4VisAttributes(G4Colour(0,1,0,.6)); +m_VisTPC= new G4VisAttributes(G4Colour(1.,0.5,0.6,0.3)); +m_VisRohacell= new G4VisAttributes(G4Colour(1.,1.,1., .8)); +m_VisKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.4)); +m_VisTargetCell = new G4VisAttributes(G4Colour(0,0,1, .4)); +m_VisTargetCell->SetForceSolid(true); +m_VisOuterKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.8)); + +Raw_Signal = new TH1F("raw_Signal","raw_Signal",350,0,350); // 30ns per bin +Elec_Signal = new TH1F("Elec_Signal","Elec_Signal",350,0,350); + /* Raw_Signal = new TH1F;*/ /* Elec_Signal = new TH1F;*/ - - fa1 = new TF1("fa1","[0]*exp(-3.*(x-[1])/[2]) * sin((x-[1])/[2]) * pow((x-[1])/[2], 3)",0,1000); - - solidTarget=0; - logicTarget=0; - solidChamber=0; - logicChamber=0; - solidTPC=0; - logicTPC=0; - solidWindow0=0; - logicWindow0=0; - solidWindow1=0; - logicWindow1=0; - solidWindow2=0; - logicWindow2=0; - solidInnerRohacell=0; - logicInnerRohacell=0; - solidOuterRohacell=0; - logicOuterRohacell=0; - solidKapton=0; - logicKapton=0; + +fa1 = new TF1("fa1","[0]*exp(-3.*(x-[1])/[2]) * sin((x-[1])/[2]) * pow((x-[1])/[2], 3)",0,1000); + +solidTarget=0; +logicTarget=0; +solidChamber=0; +logicChamber=0; +solidTPC=0; +logicTPC=0; +solidWindow0=0; +logicWindow0=0; +solidRohacell=0; +logicRohacell=0; +solidKapton=0; +logicKapton=0; } Minos::~Minos(){ @@ -154,208 +147,19 @@ Minos::~Minos(){ /* void Minos::AddDetector(G4ThreeVector POS, double LengthOfTarget, int PresenceOfMinos){ */ void Minos::AddDetector(G4ThreeVector POS, double LengthOfTarget, G4String MaterialOfTarget,G4String MaterialOfCell, int PresenceOfMinos){ - m_POS.push_back(POS); - m_TargetLength.push_back(LengthOfTarget); - m_TargetMaterial.push_back(MaterialOfTarget); - m_CellMaterial.push_back(MaterialOfCell); - m_TPCOnly.push_back(PresenceOfMinos); +m_POS.push_back(POS); +m_TargetLength.push_back(LengthOfTarget); +m_TargetMaterial.push_back(MaterialOfTarget); +m_CellMaterial.push_back(MaterialOfCell); +m_TPCOnly.push_back(PresenceOfMinos); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -void Minos::DefineMaterials() -{ - //This function illustrates the possible ways to define materials - - G4String symbol; //a=mass of a mole; - G4double a, z, density; //z=mean number of protons; - - G4int ncomponents, natoms; - G4double fractionmass; - - // - // define Elements - // - - G4Element* H = new G4Element("Hydrogen",symbol="H" , z= 1., a= 1.01*g/mole); - G4Element* C = new G4Element("Carbon" ,symbol="C" , z= 6., a= 12.01*g/mole); - G4Element* F = new G4Element("Fluorin" ,symbol="F" , z= 9., a= 19.0*g/mole); - G4Element* N = new G4Element("Nitrogen",symbol="N" , z= 7., a= 14.01*g/mole); - G4Element* O = new G4Element("Oxygen" ,symbol="O" , z= 8., a= 16.00*g/mole); - G4Element* Ar = new G4Element("Argon", symbol="Ar", z=18, a=39.948*g/mole); - G4Element* Fe = new G4Element("Fer",symbol="Fe" , z= 26., a= 55.9*g/mole); - G4Element* Cr = new G4Element("Chrome",symbol="Cr" , z= 24., a= 52.*g/mole); - - new G4Material("Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3); - new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3); - new G4Material("Lead" , z=82., a= 207.19*g/mole, density= 11.35*g/cm3); - new G4Material("Silicium", z=14., a=28.09*g/mole, density=2.330*g/cm3); - new G4Material("Titanium", z=22., a=47.87*g/mole, density=4.510*g/cm3); - - G4Material* iso = new G4Material("isobutane", density=0.002506*g/cm3, ncomponents=2); - iso->AddElement(C, natoms=4); - iso->AddElement(H, natoms=10); - G4Material* CF4 = - new G4Material("CF4", density= 0.0036586*g/cm3, ncomponents=2); - CF4->AddElement(C, natoms=1); - CF4->AddElement(F, natoms=4); - // overwrite computed meanExcitationEnergy with ICRU recommended value - CF4->GetIonisation()->SetMeanExcitationEnergy(20.0*eV); - G4Material* mix = - new G4Material("mix", density= 0.0019836*g/cm3, ncomponents=3); - mix->AddMaterial(CF4, fractionmass=15.*perCent); - mix->AddMaterial(iso, fractionmass=3.*perCent); - mix->AddElement(Ar, fractionmass=82.*perCent); - // overwrite computed meanExcitationEnergy with ICRU recommended value - mix->GetIonisation()->SetMeanExcitationEnergy(25.0*eV); - - ///////// Drift properties - - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddConstProperty("DE_PAIRENERGY",30*eV); - MPT->AddConstProperty("DE_ABSLENGTH",10*pc); - MPT->AddConstProperty("DE_DRIFTSPEED",3.6*cm/microsecond); - MPT->AddConstProperty("DE_TRANSVERSALSPREAD",7e-5*mm2/ns); - MPT->AddConstProperty("DE_LONGITUDINALSPREAD",7e-5*mm2/ns); - /* MPT->AddConstProperty("DE_TRANSVERSALSPREAD",7e-15*mm2/ns); */ - /* MPT->AddConstProperty("DE_LONGITUDINALSPREAD",7e-15*mm2/ns); */ - mix->SetMaterialPropertiesTable(MPT); - - G4Material* Ar_CF4_95_5 = - new G4Material("Ar_CF4_95_5", density= 0.0017611*g/cm3, ncomponents=2); - Ar_CF4_95_5->AddMaterial(CF4, fractionmass=5.*perCent); - Ar_CF4_95_5->AddElement(Ar, fractionmass=95.*perCent); - Ar_CF4_95_5->GetIonisation()->SetMeanExcitationEnergy(30.0*eV); - - G4Material* Ar_CF4_90_10 = - new G4Material("Ar_CF4_90_10", density= 0.0018610*g/cm3, ncomponents=2); - Ar_CF4_90_10->AddMaterial(CF4, fractionmass=10.*perCent); - Ar_CF4_90_10->AddElement(Ar, fractionmass=90.*perCent); - Ar_CF4_90_10->GetIonisation()->SetMeanExcitationEnergy(25.0*eV); - - G4Material* Ar_iso_97_3 = - new G4Material("Ar_iso_97_3", density= 0.0016838*g/cm3, ncomponents=2); - Ar_iso_97_3->AddMaterial(iso, fractionmass=3.*perCent); - Ar_iso_97_3->AddElement(Ar, fractionmass=97.*perCent); - Ar_iso_97_3->GetIonisation()->SetMeanExcitationEnergy(25.0*eV); - - G4Material* Ar_iso_95_5 = - new G4Material("Ar_iso_95_5", density= 0.0016990*g/cm3, ncomponents=2); - Ar_iso_95_5->AddMaterial(iso, fractionmass=5.*perCent); - Ar_iso_95_5->AddElement(Ar, fractionmass=95.*perCent); - Ar_iso_95_5->GetIonisation()->SetMeanExcitationEnergy(25.0*eV); - - G4Material* LH2 = - new G4Material("LH2", density= 0.07293*g/cm3, ncomponents=1); - LH2->AddElement(H, natoms=2); - G4Material* Myl = - new G4Material("Mylar", density= 1.397*g/cm3, ncomponents=3); - Myl->AddElement(C, natoms=10); - Myl->AddElement(H, natoms= 8); - Myl->AddElement(O, natoms= 4); - - G4Material* Epo = - new G4Material("Epoxy", density= 1.85*g/cm3, ncomponents=3); //density of FR4 (Wikipedia) - Epo->AddElement(C, natoms=18); - Epo->AddElement(H, natoms= 20); - Epo->AddElement(O, natoms= 3); - - G4Material* Air = - new G4Material("Air" , density= 1.290*mg/cm3, ncomponents=3); - Air->AddElement(N, fractionmass=0.781); - Air->AddElement(O, fractionmass=0.21); - Air->AddElement(Ar, fractionmass=0.009); - - /* G4Material* Vacuum = */ - /* new G4Material("Vacuum", z=1., a=1.01*g/mole,density= universe_mean_density, */ - /* kStateGas, 2.73*kelvin, 3.e-18*pascal); */ - - G4Material* Vacuum = - new G4Material("Vacuum", density= universe_mean_density, ncomponents=2); - Vacuum-> AddElement(N,.7); - Vacuum-> AddElement(O,.3); - - G4Material* beam = - new G4Material("Beam", density= 1.e-5*g/cm3, ncomponents=1, - kStateGas, STP_Temperature, 2.e-2*bar); - beam->AddMaterial(Air, fractionmass=1.); - - G4Material* Inox = - new G4Material("Inox", density= 8.02*g/cm3, ncomponents=3); - Inox->AddElement(C, fractionmass=0.001); - Inox->AddElement(Fe, fractionmass=0.829); - Inox->AddElement(Cr, fractionmass=0.17); - - G4Material* Kapton = - new G4Material("Kapton", density= 1.42*g/cm3, ncomponents=4); - Kapton->AddElement(C, fractionmass=0.691133); - Kapton->AddElement(H, fractionmass=0.026362); - Kapton->AddElement(O, fractionmass=0.209235); - Kapton->AddElement(N, fractionmass=0.073270); - - G4Material* Rohacell = - new G4Material("Rohacell", density= 0.075*g/cm3, ncomponents=4); - Rohacell->AddElement(C, fractionmass=0.6014); - Rohacell->AddElement(H, fractionmass=0.0805); - Rohacell->AddElement(O, fractionmass=0.3154); - Rohacell->AddElement(N, fractionmass=0.00276); - - //default materials of the World - defaultMaterial = Vacuum; -} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//SET MATERIALS -void Minos::SetTargetMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) TargetMaterial = pttoMaterial; -} -void Minos::SetChamberMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) ChamberMaterial = pttoMaterial; -} - -void Minos::SetTPCMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) TPCMaterial = pttoMaterial; -} - -void Minos::SetWindowMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) WindowMaterial = pttoMaterial; -} -void Minos::SetInnerRohacellMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) InnerRohacellMaterial = pttoMaterial; -} -void Minos::SetOuterRohacellMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) OuterRohacellMaterial = pttoMaterial; -} -void Minos::SetKaptonMaterial(G4String materialChoice) -{ - // search the material by its name - G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); - if (pttoMaterial) KaptonMaterial = pttoMaterial; -} - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Below are vis attributes that permits someone to test / play // with the interactive expansion / contraction geometry system of the // vis/OpenInventor driver : @@ -376,122 +180,90 @@ G4LogicalVolume* Minos::BuildTarget(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildChamber(){ - if(!logicChamber){ - // - // Chamber +G4LogicalVolume* Minos::BuildTPC(){ + if(!logicTPC){ + // + // TPC // - solidChamber = new G4Tubs("Chamber", //its name - ChamberInnerRadius,ChamberInnerRadius+ChamberThickness,ChamberLength/2.,0,360.); //size - logicChamber = new G4LogicalVolume(solidChamber, //its solid - ChamberMaterial, //its material - "Chamber"); //its name - m_VissimpleBox->SetVisibility(true); - logicChamber->SetVisAttributes(m_VissimpleBox); + solidTPC = new G4Tubs("TPC", + ChamberInnerRadius ,TPCRadiusExt,ChamberLength/2.,0,360.); + logicTPC = new G4LogicalVolume(solidTPC, //its solid + TPCMaterial, //its material + "TPC"); //name + logicTPC->SetVisAttributes(m_VisTPC); } - return logicChamber; + return logicTPC; } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +/* G4LogicalVolume* Minos::BuildChamber(){ */ +/* if(!logicChamber){ */ +/* solidChamber = new G4Tubs("Chamber", //its name */ +/* ChamberInnerRadius,ChamberInnerRadius+ChamberThickness,ChamberLength/2.,0,360.); //size */ +/* logicChamber = new G4LogicalVolume(solidChamber, //its solid */ +/* ChamberMaterial, //its material */ +/* "Chamber"); //its name */ +/* m_VissimpleBox->SetVisibility(true); */ +/* logicChamber->SetVisAttributes(m_VissimpleBox); */ +/* } */ +/* return logicChamber; */ +/* } */ + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* Minos::BuildInnerRohacell(){ - if(!logicInnerRohacell){ - // - // Inner Rohacell - // - solidInnerRohacell = new G4Tubs("InnerRohacell", //its name - ChamberInnerRadius /*+ ChamberThickness*/,ChamberInnerRadius + ChamberThickness+InnerRohacellThickness,ChamberLength/2.,0,360.); //size - logicInnerRohacell = new G4LogicalVolume(solidInnerRohacell, //its solid - InnerRohacellMaterial, //its material + if(!logicRohacell){ + solidRohacell = new G4Tubs("InnerRohacell", //its name + ChamberInnerRadius ,ChamberInnerRadius + RohacellThickness ,ChamberLength/2.,0,360.); //size + logicRohacell = new G4LogicalVolume(solidRohacell, //its solid + RohacellMaterial, //its material "InnerRohacell"); //its name - logicInnerRohacell->SetVisAttributes(m_VisInnerRohacell); + logicRohacell->SetVisAttributes(m_VisRohacell); } - return logicInnerRohacell; + return logicRohacell; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildOuterRohacell(){ - if(!logicOuterRohacell){ - // - // Outer Rohacell - // - solidOuterRohacell = new G4Tubs("OuterRohacell", //its name - ChamberInnerRadius /*+ ChamberThickness + InnerRohacellThickness + KaptonThickness*/,ChamberInnerRadius + ChamberThickness + InnerRohacellThickness + KaptonThickness+OuterRohacellThickness,ChamberLength/2.,0,360.); //size - logicOuterRohacell = new G4LogicalVolume(solidOuterRohacell, //its solid - OuterRohacellMaterial, //its material - "OuterRohacell"); //its name - logicOuterRohacell->SetVisAttributes(m_VisOuterRohacell); - } - return logicOuterRohacell; -} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//I redefine the Rohacell for bigger cylinder -G4LogicalVolume* Minos::BuildOuterOuterRohacell(){ - if(logicOuterRohacell){ - // - // Outer Rohacell - // - solidOuterRohacell = new G4Tubs("OuterRohacell", //its name - TPCRadiusExt-OuterRohacellThickness-KaptonThickness, TPCRadiusExt ,ChamberLength/2.,0,360.); //size - logicOuterRohacell = new G4LogicalVolume(solidOuterRohacell, //its solid - OuterRohacellMaterial, //its material + +G4LogicalVolume* Minos::BuildOuterRohacell(){ + if(logicRohacell){ + solidRohacell = new G4Tubs("OuterRohacell", //its name + TPCRadiusExt-RohacellThickness, TPCRadiusExt ,ChamberLength/2.,0,360.); //size + logicRohacell = new G4LogicalVolume(solidRohacell, //its solid + RohacellMaterial, //its material "OuterRohacell"); //its name - logicOuterRohacell->SetVisAttributes(m_VisOuterOuterRohacell); + logicRohacell->SetVisAttributes(m_VisRohacell); } - return logicOuterRohacell; + return logicRohacell; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* Minos::BuildKapton(){ if(!logicKapton){ - // - // Kapton - // solidKapton = new G4Tubs("Kapton", //its name - ChamberInnerRadius+ ChamberThickness +InnerRohacellThickness ,ChamberInnerRadius + ChamberThickness+InnerRohacellThickness+KaptonThickness,ChamberLength/2.,0,360.); //size + ChamberInnerRadius+RohacellThickness ,ChamberInnerRadius +RohacellThickness+KaptonThickness,ChamberLength/2.,0,360.); //size logicKapton = new G4LogicalVolume(solidKapton, //its solid KaptonMaterial, //its material "Kapton"); //its name logicKapton->SetVisAttributes(m_VisKapton); } - return logicKapton; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* Minos::BuildOuterKapton(){ if(logicKapton){ - // - // Kapton - // solidKapton = new G4Tubs("Kapton", //its name - TPCRadiusExt-OuterRohacellThickness-KaptonThickness, TPCRadiusExt-OuterRohacellThickness,ChamberLength/2.,0,360.); //size - + TPCRadiusExt-RohacellThickness-KaptonThickness, TPCRadiusExt-RohacellThickness,ChamberLength/2.,0,360.); //size logicKapton = new G4LogicalVolume(solidKapton, //its solid KaptonMaterial, //its material "Kapton"); //its name - logicKapton->SetVisAttributes(m_VisOuterKapton); + logicKapton->SetVisAttributes(m_VisOuterKapton); } - - return logicKapton; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildTPC(){ - if(!logicTPC){ - // - // TPC - // - solidTPC = new G4Tubs("TPC", - ChamberInnerRadius /*+ ChamberThickness + InnerRohacellThickness + KaptonThickness + OuterRohacellThickness*/,TPCRadiusExt,ChamberLength/2.,0,360.); - logicTPC = new G4LogicalVolume(solidTPC, //its solid - TPCMaterial, //its material - "TPC"); //name - logicTPC->SetVisAttributes(m_VisTPC); - } - return logicTPC; -} + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -503,7 +275,6 @@ G4LogicalVolume* Minos::BuildWindow0(){ if(!logicWindow0){ solidWindow0 = new G4Tubs("WindowTube", //its name 0.,TargetRadius+WindowThickness,TargetLength/2.+WindowThickness,0,360.); - logicWindow0 = new G4LogicalVolume(solidWindow0, //its solid WindowMaterial, //its material "WindowTube"); //name @@ -511,36 +282,6 @@ G4LogicalVolume* Minos::BuildWindow0(){ } return logicWindow0; } -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - -G4LogicalVolume* Minos::BuildWindow1(){ - if(!logicWindow1){ - solidWindow1 = new G4Tubs("WindowEntrance", //its name - 0.,TargetRadius+WindowThickness,WindowThickness,0,360.); - - logicWindow1 = new G4LogicalVolume(solidWindow1, //its solid - WindowMaterial, //its material - "WindowEntrance"); //name - logicWindow1->SetVisAttributes(m_VisTargetCell); - } - return logicWindow1; -} -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -G4LogicalVolume* Minos::BuildWindow2(){ - if(!logicWindow2){ - solidWindow2 = new G4Tubs("WindowOutcoming", //its name - 0.,TargetRadius+WindowThickness,WindowThickness,0,360.); - - logicWindow2 = new G4LogicalVolume(solidWindow2, //its solid - WindowMaterial, //its material - "WindowOutcoming"); //name - logicWindow2->SetVisAttributes(m_VisTargetCell); - } - return logicWindow2; -} - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -559,15 +300,15 @@ void Minos::ReadConfiguration(NPL::InputParser parser){ if(blocks[i]->HasTokenList(cart)){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Minos " << i+1 << endl; - - G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); - TargetLength = blocks[i]->GetDouble("TargetLength","mm"); - G4String TargetMaterialname = blocks[i]->GetString("TargetMaterial"); - G4String CellMaterial = blocks[i]->GetString("CellMaterial"); - TPCOnly = blocks[i]->GetInt("TPCOnly"); - AddDetector(Pos,TargetLength,TargetMaterialname, CellMaterial, TPCOnly); - /* AddDetector(Pos,TargetLength, TPCOnly); */ - + + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); + TargetLength = blocks[i]->GetDouble("TargetLength","mm"); + G4String TargetMaterialname = blocks[i]->GetString("TargetMaterial"); + G4String CellMaterial = blocks[i]->GetString("CellMaterial"); + TPCOnly = blocks[i]->GetInt("TPCOnly"); + AddDetector(Pos,TargetLength,TargetMaterialname, CellMaterial, TPCOnly); + /* AddDetector(Pos,TargetLength, TPCOnly); */ + } else{ cout << "ERROR: check your input file formatting " << endl; @@ -585,22 +326,40 @@ void Minos::ConstructDetector(G4LogicalVolume* world){ TargetLength = m_TargetLength[i]; TPCOnly = m_TPCOnly[i]; - DefineMaterials(); - - SetTargetMaterial(m_TargetMaterial[i]); - SetChamberMaterial("Inox"); - SetTPCMaterial("mix"); - SetWindowMaterial(m_CellMaterial[i]); - SetKaptonMaterial("Kapton"); - SetInnerRohacellMaterial("Rohacell"); - SetOuterRohacellMaterial("Rohacell"); + /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("LH2"); + WindowMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + KaptonMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Kapton"); + RohacellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Rohacell"); + TPCMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("mixMINOS"); + + /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* WindowMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* KaptonMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* RohacellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* TPCMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("mixMINOS"); */ + + ///////// Drift properties + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddConstProperty("DE_PAIRENERGY",30*eV); + MPT->AddConstProperty("DE_ABSLENGTH",10*pc); + MPT->AddConstProperty("DE_DRIFTSPEED",3.475*cm/microsecond); + MPT->AddConstProperty("DE_TRANSVERSALSPREAD",14e-5*mm2/ns); + MPT->AddConstProperty("DE_LONGITUDINALSPREAD",14e-5*mm2/ns); + + /* MPT->AddConstProperty("DE_TRANSVERSALSPREAD",0*mm2/ns); */ + /* MPT->AddConstProperty("DE_LONGITUDINALSPREAD",0*mm2/ns); */ + + TPCMaterial->SetMaterialPropertiesTable(MPT); G4ThreeVector Det_pos = m_POS[i] ; - + double MinosX = Det_pos.x(); double MinosY= Det_pos.y(); double MinosZ = Det_pos.z() + m_TargetLength[i]/2. ; - + new G4PVPlacement(0,//its name G4ThreeVector(0,0,+ChamberLength/2 ), /* G4ThreeVector(wX,wY, wZ + ChamberLength - m_TargetLength[i]-WindowThickness*2. - 5*mm ), // Z positioning putting TPC beginn and Target beginning w/ difference of 5mm */ @@ -610,7 +369,7 @@ void Minos::ConstructDetector(G4LogicalVolume* world){ false, //no boolean operation 0); //copy number -//////// ELECTRIC FIELD + //////// ELECTRIC FIELD G4ElectricField* field = new G4UniformElectricField(G4ThreeVector(0.0,0.0,200*volt/cm)); // Create an equation of motion for this field @@ -630,95 +389,87 @@ void Minos::ConstructDetector(G4LogicalVolume* world){ FieldManager->SetChordFinder( ChordFinder ); G4Material* Cu - = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); - - ///////// CONSTRUCT PADS using parametrized volumes or replica (uncomment the correct section) - + = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); + + ///////// CONSTRUCT PADS using parametrized volumes or replica (uncomment the correct section) + //// Using REPLICA // Construct Pads ring by ring for (int RingNbr = 0; RingNbr < 18; RingNbr++){ - int PadsPerRing[18]={144,152,156,164,172,176,184,192,196,204,212,216,224,228,236,244,248,256}; - /* G4double InnerRadius = (45.2+RingNbr*2.1+0.02)*mm;// 0.02 mm between each ring */ - G4double InnerRadius = (45.75+RingNbr*2.1)*mm; - G4double OuterRadius = (47.75+RingNbr*2.1)*mm; - - //Volume where are placed replica pads - G4VSolid* AnodeRing = new G4Tubs("ring",InnerRadius,OuterRadius, - 0.01*mm,0.,360*deg); - G4LogicalVolume * AnodeRing_log = new G4LogicalVolume(AnodeRing, - TPCMaterial, "ringL", 0, 0, 0); - - {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); + int PadsPerRing[18]={144,152,156,164,172,176,184,192,196,204,212,216,224,228,236,244,248,256}; + /* G4double InnerRadius = (45.2+RingNbr*2.1+0.02)*mm;// 0.02 mm between each ring */ + G4double InnerRadius = (45.75+RingNbr*2.1)*mm; + G4double OuterRadius = (47.75+RingNbr*2.1)*mm; + + //Volume where are placed replica pads + G4VSolid* AnodeRing = new G4Tubs("ring",InnerRadius,OuterRadius, + 0.01*mm,0.,360*deg); + G4LogicalVolume * AnodeRing_log = new G4LogicalVolume(AnodeRing, + /* mix, "ringL", 0, 0, 0); */ + TPCMaterial, "ringL", 0, 0, 0); + + {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); AnodeRing_log->SetVisAttributes(atb);} - new G4PVPlacement(0,G4ThreeVector(0,0,-ChamberLength/2+0.01*mm), - AnodeRing_log,"ring", logicTPC, false, RingNbr); + new G4PVPlacement(0,G4ThreeVector(0,0,-ChamberLength/2+0.01*mm), + AnodeRing_log,"ring", logicTPC, false, RingNbr); + + G4double Pad_dPhi = (360./(PadsPerRing[RingNbr]+1))*deg; // longitudinal component of Pad + G4double Pad_shift = (360./PadsPerRing[RingNbr])*deg; // dPhi between each Pads - G4double Pad_dPhi = (360./(PadsPerRing[RingNbr]+1))*deg; // longitudinal component of Pad - G4double Pad_shift = (360./PadsPerRing[RingNbr])*deg; // dPhi between each Pads + G4VSolid* Pad = new G4Tubs("div_ring", InnerRadius, OuterRadius, + 0.01*mm,0, Pad_dPhi); - G4VSolid* Pad = new G4Tubs("div_ring", InnerRadius, OuterRadius, - 0.01*mm,0, Pad_dPhi); - - G4LogicalVolume* Pad_log = new G4LogicalVolume(Pad, - Cu,"div_ringL",0,0,0); - - {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); + G4LogicalVolume* Pad_log = new G4LogicalVolume(Pad, + Cu,"div_ringL",0,0,0); + + {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); Pad_log->SetVisAttributes(atb);} - Pad_log->SetSensitiveDetector(m_MinosPadScorer); - - new G4PVReplica("div_ring_phys", Pad_log, - AnodeRing_log, kPhi, PadsPerRing[RingNbr],Pad_shift ,0); - + Pad_log->SetSensitiveDetector(m_MinosPadScorer); + + new G4PVReplica("div_ring_phys", Pad_log, + AnodeRing_log, kPhi, PadsPerRing[RingNbr],Pad_shift ,0); } - -////////////////////////////////////// - + + ////////////////////////////////////// + new G4PVPlacement(0, //its name G4ThreeVector(0,0,0), //at (0,0,0) - BuildOuterRohacell(), //its logical volume - "Rohacell", //its name + BuildInnerRohacell(), //its logical volume + "InnerRohacell", //its name logicTPC, //its mother volume false, //no boolean operation 0); //copy number - //check the order and positioning of kapton , chamber and rohacell from pag 16 of Thesis Clementine - - new G4PVPlacement(0, G4ThreeVector(0,0,0), //at (0,0,0) - BuildChamber(), //its logical volume - "Chamber", //its name - logicOuterRohacell, //its mother volume + new G4PVPlacement(0, //its name + G4ThreeVector(0,0,0), //at (0,0,0) + BuildOuterRohacell(), //its logical volume + "OuterRohacell", //its name + logicTPC, //its mother volume + /* logicTPC, //its mother volume */ false, //no boolean operation 0); //copy number new G4PVPlacement(0, G4ThreeVector(0,0,0), //at (0,0,0) BuildKapton(), //its logical volume - "Kapton", //its name - logicOuterRohacell, //its mother volume - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildOuterOuterRohacell(), //its logical volume - "Rohacell"/*"OuterRohacell"*/, //its name - logicTPC/*world*/, //its mother volume + "InnerKapton", //its name + logicTPC, //its mother volume false, //no boolean operation 0); //copy number new G4PVPlacement(0, //its name G4ThreeVector(0,0,0), //at (0,0,0) BuildOuterKapton(), //its logical volume - "Kapton", //its name - logicOuterRohacell, //its mother volume + "OuterKapton", //its name + logicTPC, //its mother volume false, //no boolean operation 0); //copy number if(TPCOnly!=1){ new G4PVPlacement(0, //its name - G4ThreeVector(MinosX,MinosY, MinosZ), //at (0,0,0) + G4ThreeVector(MinosX,MinosY,MinosZ), //at (0,0,0) BuildWindow0(), //its logical volume "WindowTube", //its name world, //its mother volume @@ -738,7 +489,7 @@ void Minos::ConstructDetector(G4LogicalVolume* world){ m_ReactionRegion -> AddRootLogicalVolume(logicTarget); m_ReactionRegion->SetUserLimits(new G4UserLimits(1.2*mm)); //??? } - + G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); unsigned int size = m_ReactionModel.size(); for(unsigned int o = 0 ; o < size ; o++){ @@ -753,7 +504,7 @@ void Minos::ConstructDetector(G4LogicalVolume* world){ m_ReactionModel.push_back(fsm); } } - + // Visualization attributes world->SetVisAttributes (G4VisAttributes::Invisible); @@ -777,21 +528,23 @@ void Minos::InitializeRootOutput(){ void Minos::ReadSensitive(const G4Event* ){ m_Event->Clear(); -/////////// -// DriftElectron scorer + /////////// + // DriftElectron scorer CylinderTPCScorers::PS_TPCAnode* Scorer2= (CylinderTPCScorers::PS_TPCAnode*) m_MinosPadScorer->GetPrimitive(0); - unsigned int size2 = Scorer2->GetMult(); + unsigned int size2 = Scorer2->GetMult(); for(unsigned int i = 0 ; i < size2 ; i++){ - + int Pad = Scorer2->GetPad(i); double X = Scorer2->GetX(i); double Y = Scorer2->GetY(i); - + m_Event->SetCharge(Pad,X,Y); - /* m_Event->AddChargePoint(Scorer2->GetQ(i), Scorer2->GetT(i)); */ - + //m_Event->AddChargePoint(Scorer2->GetQ(i), Scorer2->GetT(i)); + SimulateGainAndDigitizer(Scorer2->GetQ(i), Scorer2->GetT(i)); + + /* m_Event->AddChargePoint(Scorer2->GetQ(i),Scorer2->GetT(i)); */ } } @@ -800,81 +553,87 @@ void Minos::SimulateGainAndDigitizer(vector<double> rawQ, vector<double> rawT){ Charge2.clear(); Time.clear(); - + Raw_Signal->Reset(); Elec_Signal->Reset(); - - // Reallocate electrons from each pack - + // Add white noise; - for( int bin = 0 ; bin < Elec_Signal->GetNbinsX() ; bin++) - Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)); - - for (unsigned int j = 1; j < rawQ.size()-1; j++){ - time = (rawT[j+1]-rawT[j-1])/rawQ[0]; - - for ( int k = -rawQ[0]/2; k < (rawQ[0]/2); k++){ - Raw_Signal->Fill((rawT[j]+k*time)/30.); + /* for( int bin = 0 ; bin < Elec_Signal->GetNbinsX() ; bin++) */ + /* Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)); */ + + // Reallocate electrons from each pack + /* if (rawQ.sze()==1) { */ + /* for ( int j = 0; j < rawQ[0]; j++){ */ + /* Raw_Signal->Fill(rawT[0]/30.); */ + /* } */ + /* } */ + /* else{ */ + /* for ( int j = 1; j < rawQ.size()-1; j++){ */ + /* time = (rawT[j+1]-rawT[j-1])/rawQ[j]; */ + /* for ( int k = -rawQ[0]/2; k < (rawQ[0]/2); k++){ */ + /* Raw_Signal->Fill((rawT[j]+k*time)/30.); */ + /* } */ + /* } */ + /* } */ + + for ( unsigned int j = 0; j < rawQ.size(); j++){ + for ( int i = 0 ; i < rawQ[j]; i++ ){ + Raw_Signal->Fill((rawT[j])/30.); } } - - // Application of the electronic reponse function - + // Application of the electronic reponse function for ( int x=0; x < Raw_Signal->GetNbinsX(); x++){ + if(Raw_Signal->GetBinContent(x) < 0.5) continue; - else { - start = Raw_Signal->GetBinCenter(x); - end = Raw_Signal->GetBinCenter(x)+1200/30.; - /* DriftTime = Raw_Signal->GetBinCenter(x); */ - - fa1->SetRange(start, end); - fa1->SetParameter(0,1500); - fa1->SetParameter(1,start); - fa1->SetParameter(2,450/30.); - /* Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)) */ - /* for (int p=0; p< 0; p++) */ - for (int p=0; p< Raw_Signal->GetBinContent(x)*1500; p++) - Elec_Signal->Fill(fa1->GetRandom()); - - } - } - + else{ + start = Raw_Signal->GetBinCenter(x); + end = Raw_Signal->GetBinCenter(x)+1200/30.; + // DriftTime = Raw_Signal->GetBinCenter(x); + fa1->SetRange(start, end); + fa1->SetParameter(0,1500); + fa1->SetParameter(1,start); + fa1->SetParameter(2,450/30.); + // Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)) + // for (int p=0; p< 0; p++) + for (int p=0; p< Raw_Signal->GetBinContent(x)*1500; p++) + Elec_Signal->Fill(fa1->GetRandom()); + } + } for ( int bin=0; bin < Elec_Signal->GetNbinsX(); bin++){ Charge2.push_back(Elec_Signal->GetBinContent(bin)); Time.push_back(Elec_Signal->GetBinCenter(bin)); - } - + m_Event->AddChargePoint(Charge2,Time); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //////////////////////////////////////////////////////////////// - void Minos::InitializeScorers() { - // This check is necessary in case the geometry is reloaded - bool already_exist = false; - bool already_exist2 = false; - bool already_exist3 = false; - - m_MinosPadScorer = CheckScorer("MinosPadScorer",already_exist3) ; - - if(already_exist && already_exist2 && already_exist3 ) - return ; - - // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); - - G4VPrimitiveScorer* DriftElectronMinosTPCScorer= new CylinderTPCScorers::PS_TPCAnode("DriftElectronsScore",level, 0) ; - - //and register it to the multifunctionnal detector - m_MinosPadScorer->RegisterPrimitive(DriftElectronMinosTPCScorer); - +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void Minos::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + bool already_exist2 = false; + bool already_exist3 = false; + + m_MinosPadScorer = CheckScorer("MinosPadScorer",already_exist3) ; + + if(already_exist && already_exist2 && already_exist3 ) + return ; + + // Otherwise the scorer is initialised + vector<int> level; level.push_back(0); + + G4VPrimitiveScorer* DriftElectronMinosTPCScorer= new CylinderTPCScorers::PS_TPCAnode("DriftElectronsScore",level, 0) ; + + //and register it to the multifunctionnal detector + m_MinosPadScorer->RegisterPrimitive(DriftElectronMinosTPCScorer); + G4VPrimitiveScorer* PadScorer= new CylinderTPCScorers::PS_TPCAnode("MinosTPCAnode",level, 0); m_MinosPadScorer->RegisterPrimitive(PadScorer); - + G4SDManager::GetSDMpointer()->AddNewDetector(m_MinosPadScorer) ; } diff --git a/NPSimulation/Detectors/Minos/Minos.hh b/NPSimulation/Detectors/Minos/Minos.hh index 5c5db0349e5335049833b53a41236d7a513a6233..71ca4078b5e99e9a2fd74708da22646b7250eb62 100644 --- a/NPSimulation/Detectors/Minos/Minos.hh +++ b/NPSimulation/Detectors/Minos/Minos.hh @@ -65,21 +65,12 @@ class Minos : public NPS::VDetector{ void DefineMaterials(); public: - void SetTargetMaterial(G4String materialChoice); - void SetChamberMaterial(G4String materialChoice); - void SetTPCMaterial(G4String materialChoice); - void SetWindowMaterial(G4String materialChoice); - void SetInnerRohacellMaterial(G4String materialChoice); - void SetOuterRohacellMaterial(G4String materialChoice); - void SetKaptonMaterial(G4String materialChoice); - G4LogicalVolume* BuildSquareDetector(); G4LogicalVolume* BuildCylindricalDetector(); G4LogicalVolume* BuildTarget(); G4LogicalVolume* BuildChamber(); G4LogicalVolume* BuildInnerRohacell(); G4LogicalVolume* BuildOuterRohacell(); - G4LogicalVolume* BuildOuterOuterRohacell(); G4LogicalVolume* BuildKapton(); G4LogicalVolume* BuildOuterKapton(); G4LogicalVolume* BuildTPC(); @@ -97,12 +88,13 @@ class Minos : public NPS::VDetector{ G4Material* TargetMaterial; G4Material* WindowMaterial; G4Material* ChamberMaterial; - G4Material* InnerRohacellMaterial; - G4Material* OuterRohacellMaterial; + G4Material* RohacellMaterial; G4Material* KaptonMaterial; G4Material* TPCMaterial; G4Material* defaultMaterial; - + G4Material* Mylar; + + G4LogicalVolume* m_SquareDetector; G4LogicalVolume* m_CylindricalDetector; @@ -123,21 +115,13 @@ class Minos : public NPS::VDetector{ G4LogicalVolume* logicWindow0; // G4VPhysicalVolume* physiWindow0; - G4Tubs* solidWindow1; - G4LogicalVolume* logicWindow1; - // G4VPhysicalVolume* physiWindow1; - - G4Tubs* solidWindow2; - G4LogicalVolume* logicWindow2; - // G4VPhysicalVolume* physiWindow2; - - G4Tubs* solidInnerRohacell; - G4LogicalVolume* logicInnerRohacell; + G4Tubs* solidRohacell; + G4LogicalVolume* logicRohacell; // G4VPhysicalVolume* physiInnerRohacell; - - G4Tubs* solidOuterRohacell; - G4LogicalVolume* logicOuterRohacell; - // G4VPhysicalVolume* physiOuterRohacell; + + /* G4Tubs* solidOuterRohacell; */ + /* G4LogicalVolume* logicOuterRohacell; */ + /* // G4VPhysicalVolume* physiOuterRohacell; */ G4Tubs* solidKapton; G4LogicalVolume* logicKapton; @@ -203,9 +187,7 @@ class Minos : public NPS::VDetector{ G4VisAttributes* m_VisTarget; G4VisAttributes* m_VissimpleBox; G4VisAttributes* m_VisTPC; - G4VisAttributes* m_VisInnerRohacell; - G4VisAttributes* m_VisOuterRohacell; - G4VisAttributes* m_VisOuterOuterRohacell; + G4VisAttributes* m_VisRohacell; G4VisAttributes* m_VisKapton; G4VisAttributes* m_VisTargetCell; G4VisAttributes* m_VisOuterKapton; diff --git a/NPSimulation/Detectors/Mugast/Mugast.cc b/NPSimulation/Detectors/Mugast/Mugast.cc index b34d2eed711fdd14fc2a09653f860d9925aa26fa..6efd81e8ba5b9b6a76eb3041e2a35b917f036412 100644 --- a/NPSimulation/Detectors/Mugast/Mugast.cc +++ b/NPSimulation/Detectors/Mugast/Mugast.cc @@ -65,14 +65,14 @@ namespace Mugast_NS{ // Resolution const G4double SigmaTime = 0.212765957 ;// = 500ps const G4double SigmaEnergy = 0.019 ;// - const G4double TimeOffset = 500 ;// 500 ns stop +// const G4double TimeOffset = 500 ;// 500 ns stop // Threshold const G4double EnergyThreshold = 1 * MeV; // Geometry - const G4double AluStripThickness = 0.4*micrometer ; - const G4double SiliconThickness = 3000*micrometer ; + //const G4double AluStripThickness = 0.4*micrometer ; + const G4double SiliconThickness = 300*micrometer ; // Square @@ -102,7 +102,7 @@ namespace Mugast_NS{ const G4double PCBPointsX[8]={-40,40,60,60,40,-40,-60,-60}; const G4double PCBPointsY[8]={60,60,40,-40,-60,-60,-40,40}; const G4double PCBThickness=3.2*mm; - const G4double PCBInnerRadius=0*mm; + //const G4double PCBInnerRadius=0*mm; @@ -230,6 +230,7 @@ G4LogicalVolume* Mugast::BuildTrapezoidDetector(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4LogicalVolume* Mugast::BuildAnnularDetector(){ + if(!m_AnnularDetector){ G4Material* Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -382,7 +383,6 @@ G4LogicalVolume* Mugast::BuildAnnularDetector(){ // Set Silicon strip sensible logicActiveWafer->SetSensitiveDetector(m_AnnularScorer); } - return m_AnnularDetector; } @@ -644,8 +644,8 @@ void Mugast::ReadSensitive(const G4Event* ){ if(Energy>EnergyThreshold){ double Time = RandGauss::shoot(AnnularScorer->GetTimeRing(i), SigmaTime); - int DetNbr = AnnularScorer->GetDetectorRing(i); - int StripFront = AnnularScorer->GetStripRing(i); + unsigned int DetNbr = AnnularScorer->GetDetectorRing(i); + unsigned int StripFront = AnnularScorer->GetStripRing(i); // Check for associated Quadrant strip int StripQuadrant = 0; diff --git a/NPSimulation/Detectors/PISTA/CMakeLists.txt b/NPSimulation/Detectors/PISTA/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..475afe7666c80dcdfd88a6916cc4cc8e12a4dfaf --- /dev/null +++ b/NPSimulation/Detectors/PISTA/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSPISTA SHARED PISTA.cc) +target_link_libraries(NPSPISTA NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPPISTA) diff --git a/NPSimulation/Detectors/PISTA/PISTA.cc b/NPSimulation/Detectors/PISTA/PISTA.cc new file mode 100644 index 0000000000000000000000000000000000000000..420612ff28788053c7732d3c59f08ae9dadc0567 --- /dev/null +++ b/NPSimulation/Detectors/PISTA/PISTA.cc @@ -0,0 +1,390 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe PISTA simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Tubs.hh" +#include "G4Trap.hh" +#include "G4Box.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4Material.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" + +// NPTool header +#include "PISTA.hh" +#include "DSSDScorers.hh" +#include "InteractionScorers.hh" +#include "RootOutput.h" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" +#include "NPOptionManager.h" +#include "NPSHitsMap.hh" +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace PISTA_NS{ + // Energy and time Resolution + const double EnergyThreshold = 0.1*MeV; + const double ResoTime = 0.2*ns ; + const double ResoEnergy = 0.015*MeV ; + + // Trapezoid dimension + //const double TrapezoidBaseLarge = 95*mm; + const double TrapezoidBaseLarge = 78.1*mm; + //const double TrapezoidBaseSmall = 45*mm; + const double TrapezoidBaseSmall = 43.3*mm; + //const double TrapezoidHeight = 118*mm; + const double TrapezoidHeight = 61.8*mm; + const double TrapezoidLength = 1*cm; + const double FirstStageThickness = 100*um; + const double SecondStageThickness = 1*mm; + const double DistanceBetweenSi = 7*mm; + //const double FirstStageNbrOfStrips = 128; + //const double SecondStageNbrOfStrips = 16; +} +using namespace PISTA_NS; +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// PISTA Specific Method +PISTA::PISTA(){ + m_Event = new TPISTAData() ; + m_FirstStageScorer = 0; + m_SecondStageScorer = 0; + m_TrapezoidDetector = 0; +} + +PISTA::~PISTA(){ +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PISTA::AddDetector(G4ThreeVector POS){ + // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 + m_R.push_back(POS.mag()); + m_Theta.push_back(POS.theta()); + m_Phi.push_back(POS.phi()); +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PISTA::AddDetector(double R, double Theta, double Phi){ + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* PISTA::BuildTrapezoidDetector(){ + if(!m_TrapezoidDetector){ + // Definittion of the volume containing the sensitive detectors + G4Trap* solidTrapezoid = new G4Trap("PISTA", + TrapezoidLength*0.5, 0*deg, 0*deg, + TrapezoidHeight*0.5, TrapezoidBaseLarge*0.5, TrapezoidBaseSmall*0.5, 0*deg, + TrapezoidHeight*0.5, TrapezoidBaseLarge*0.5, TrapezoidBaseSmall*0.5, 0*deg); + G4LogicalVolume* logicTrapezoid = new G4LogicalVolume(solidTrapezoid, + MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), + "PISTA", + 0,0,0); + + G4VisAttributes* TrapezoidVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + TrapezoidVisAtt->SetForceWireframe(true); + logicTrapezoid->SetVisAttributes(TrapezoidVisAtt); + + // First stage silicon detector + G4ThreeVector positionFirstStage = G4ThreeVector(0,0,-4*mm); + + G4Trap* solidFirstStage = new G4Trap("solidFirstSatge", + FirstStageThickness*0.5, 0*deg, 0*deg, + TrapezoidHeight*0.5, TrapezoidBaseLarge*0.5, TrapezoidBaseSmall*0.5, 0*deg, + TrapezoidHeight*0.5, TrapezoidBaseLarge*0.5, TrapezoidBaseSmall*0.5, 0*deg); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, + MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), + "logicFirstStage", + 0,0,0); + new G4PVPlacement(0, + positionFirstStage, + logicFirstStage, + "PISTA_FirstStage", + logicTrapezoid, + false, + 0); + // Set First Stage sensitive + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + // Visualisation of First Stage strips + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3,0.3,0.3)); + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + + ////// + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0,0,-0.5*TrapezoidLength+DistanceBetweenSi); + + G4Trap* solidSecondStage = new G4Trap("solidSecondSatge", + SecondStageThickness*0.5, 0*deg, 0*deg, + TrapezoidHeight*0.5, TrapezoidBaseLarge*0.5, TrapezoidBaseSmall*0.5, 0*deg, + TrapezoidHeight*0.5, TrapezoidBaseLarge*0.5, TrapezoidBaseSmall*0.5, 0*deg); + G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, + MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), + "logicSecondStage", + 0,0,0); + new G4PVPlacement(0, + positionSecondStage, + logicSecondStage, + "PISTA_SecondStage", + logicTrapezoid, + false, + 0); + // Set Second Stage sensitive + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + // Visualisation of Second Stage strips + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.4,0.5,0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + + + m_TrapezoidDetector = logicTrapezoid; + } + return m_TrapezoidDetector; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void PISTA::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("PISTA"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS"}; + vector<string> sphe = {"R","Theta","Phi"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// PISTA " << i+1 << endl; + + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); + AddDetector(Pos); + } + else if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// PISTA " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + AddDetector(R,Theta,Phi); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void PISTA::ConstructDetector(G4LogicalVolume* world){ + for (unsigned short i = 0 ; i < m_R.size() ; i++) { + + G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; + G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; + G4double wZ = TrapezoidHeight*0.5 + m_R[i] * cos(m_Theta[i] ) ; + G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; + // So the face of the detector is at R instead of the middle + Det_pos+=Det_pos.unit()*PISTA_NS::TrapezoidLength*0.5; + // Building Detector reference frame + G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]); + G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]); + G4double kk = -sin(m_Theta[i]); + G4ThreeVector Y(ii,jj,kk); + G4ThreeVector w = Det_pos.unit(); + G4ThreeVector u = w.cross(Y); + G4ThreeVector v = w.cross(u); + v = v.unit(); + u = u.unit(); + + G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); + + new G4PVPlacement(G4Transform3D(*Rot,Det_pos), + BuildTrapezoidDetector(), + "PISTA",world,false,i+1); + + } +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void PISTA::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("PISTA")){ + pTree->Branch("PISTA", "TPISTAData", &m_Event) ; + } + pTree->SetBranchAddress("PISTA", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void PISTA::ReadSensitive(const G4Event* ){ + m_Event->Clear(); + + /////////// + // First Stage scorer + DSSDScorers::PS_Rectangle* FirstStageScorer= (DSSDScorers::PS_Rectangle*) m_FirstStageScorer->GetPrimitive(0); + + unsigned int sizeFront = FirstStageScorer->GetLengthMult(); + for(unsigned int i = 0 ; i < sizeFront ; i++){ + double Energy = RandGauss::shoot(FirstStageScorer->GetEnergyLength(i), ResoEnergy); + if(Energy>EnergyThreshold){ + double Time = RandGauss::shoot(FirstStageScorer->GetTimeLength(i), ResoTime); + int DetNbr = FirstStageScorer->GetDetectorLength(i); + int StripFront = FirstStageScorer->GetStripLength(i); + m_Event->SetFirstStageXE(DetNbr, StripFront, Energy); + m_Event->SetFirstStageXT(DetNbr, StripFront, Time); + } + } + unsigned int sizeBack = FirstStageScorer->GetWidthMult(); + for(unsigned int i = 0 ; i < sizeBack ; i++){ + double Energy = RandGauss::shoot(FirstStageScorer->GetEnergyWidth(i), ResoEnergy); + if(Energy>EnergyThreshold){ + double Time = RandGauss::shoot(FirstStageScorer->GetTimeWidth(i), ResoTime); + int DetNbr = FirstStageScorer->GetDetectorWidth(i); + int StripFront = FirstStageScorer->GetStripWidth(i); + m_Event->SetFirstStageYE(DetNbr, StripFront, Energy); + m_Event->SetFirstStageYT(DetNbr, StripFront, Time); + } + } + FirstStageScorer->clear(); + + /////////// + // Second Stage scorer + DSSDScorers::PS_Rectangle* SecondStageScorer= (DSSDScorers::PS_Rectangle*) m_SecondStageScorer->GetPrimitive(0); + + unsigned int sizeFrontSecondStage = SecondStageScorer->GetLengthMult(); + for(unsigned int i = 0 ; i < sizeFrontSecondStage ; i++){ + double Energy = RandGauss::shoot(SecondStageScorer->GetEnergyLength(i), ResoEnergy); + if(Energy>EnergyThreshold){ + double Time = RandGauss::shoot(SecondStageScorer->GetTimeLength(i), ResoTime); + int DetNbr = SecondStageScorer->GetDetectorLength(i); + int StripFront = SecondStageScorer->GetStripLength(i); + m_Event->SetSecondStageXE(DetNbr, StripFront, Energy); + m_Event->SetSecondStageXT(DetNbr, StripFront, Time); + } + } + unsigned int sizeBackSecondStage = SecondStageScorer->GetWidthMult(); + for(unsigned int i = 0 ; i < sizeBackSecondStage ; i++){ + double Energy = RandGauss::shoot(SecondStageScorer->GetEnergyWidth(i), ResoEnergy); + if(Energy>EnergyThreshold){ + double Time = RandGauss::shoot(SecondStageScorer->GetTimeWidth(i), ResoTime); + int DetNbr = SecondStageScorer->GetDetectorWidth(i); + int StripFront = SecondStageScorer->GetStripWidth(i); + m_Event->SetSecondStageYE(DetNbr, StripFront, Energy); + m_Event->SetSecondStageYT(DetNbr, StripFront, Time); + } + } + SecondStageScorer->clear(); + + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void PISTA::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_FirstStageScorer = CheckScorer("FirstStageScorer",already_exist) ; + m_SecondStageScorer = CheckScorer("SecondStageScorer",already_exist) ; + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + G4VPrimitiveScorer* FirstStageScorer = new DSSDScorers::PS_Rectangle("FirstStageScorer",1, + TrapezoidBaseLarge, + TrapezoidHeight, + 128,128); + G4VPrimitiveScorer* SecondStageScorer = new DSSDScorers::PS_Rectangle("SecondStageScorer",1, + TrapezoidBaseLarge, + TrapezoidHeight, + 16,16); + + G4VPrimitiveScorer* InteractionFirstStage = new InteractionScorers::PS_Interactions("InteractionFirstStage",ms_InterCoord,0); + G4VPrimitiveScorer* InteractionSecondStage = new InteractionScorers::PS_Interactions("InteractionSecondStage",ms_InterCoord,0); + + // Register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(FirstStageScorer); + m_FirstStageScorer->RegisterPrimitive(InteractionFirstStage); + m_SecondStageScorer->RegisterPrimitive(SecondStageScorer); + m_SecondStageScorer->RegisterPrimitive(InteractionSecondStage); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* PISTA::Construct(){ + return (NPS::VDetector*) new PISTA(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_PISTA{ + public: + proxy_nps_PISTA(){ + NPS::DetectorFactory::getInstance()->AddToken("PISTA","PISTA"); + NPS::DetectorFactory::getInstance()->AddDetector("PISTA",PISTA::Construct); + } + }; + + proxy_nps_PISTA p_nps_PISTA; +} diff --git a/NPSimulation/Detectors/PISTA/PISTA.hh b/NPSimulation/Detectors/PISTA/PISTA.hh new file mode 100644 index 0000000000000000000000000000000000000000..3bb2ec083546e227e033692d3a2440851917b0d4 --- /dev/null +++ b/NPSimulation/Detectors/PISTA/PISTA.hh @@ -0,0 +1,112 @@ +#ifndef PISTA_h +#define PISTA_h 1 +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : May 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe PISTA simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ header +#include <string> +#include <vector> +using namespace std; + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool header +#include "NPSVDetector.hh" +#include "TPISTAData.h" +#include "NPInputParser.h" + +class PISTA : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + PISTA() ; + virtual ~PISTA() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + // Cartesian + void AddDetector(G4ThreeVector POS); + // Spherical + void AddDetector(double R,double Theta,double Phi); + + + G4LogicalVolume* BuildTrapezoidDetector(); + + private: + G4LogicalVolume* m_TrapezoidDetector; + + //////////////////////////////////////////////////// + ////// Inherite from NPS::VDetector class ///////// + //////////////////////////////////////////////////// + public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + public: // Scorer + // Initialize all Scorer used by the MUST2Array + void InitializeScorers() ; + + // Associated Scorer + G4MultiFunctionalDetector* m_FirstStageScorer ; + G4MultiFunctionalDetector* m_SecondStageScorer ; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TPISTAData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: // Geometry + // Detector Coordinate + vector<double> m_R; + vector<double> m_Theta; + vector<double> m_Phi; + + // Visualisation Attribute + //G4VisAttributes* m_VisTrap; + + // Needed for dynamic loading of the library + public: + static NPS::VDetector* Construct(); +}; +#endif diff --git a/NPSimulation/Detectors/Scone/CMakeLists.txt b/NPSimulation/Detectors/Scone/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..57546ae55c68bf105cd552fddac5c375d4f1393b --- /dev/null +++ b/NPSimulation/Detectors/Scone/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSScone SHARED Scone.cc) +target_link_libraries(NPSScone NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPScone) diff --git a/NPSimulation/Detectors/Scone/Scone.cc b/NPSimulation/Detectors/Scone/Scone.cc new file mode 100644 index 0000000000000000000000000000000000000000..2712b4c76147992b5f44cb21b8163424f71d59a0 --- /dev/null +++ b/NPSimulation/Detectors/Scone/Scone.cc @@ -0,0 +1,515 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe Scone simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +#include <iostream> +#include <string> +//G4 Geometry object +#include "G4Tubs.hh" +#include "G4Box.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4Material.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4SubtractionSolid.hh" + +// NPTool header +#include "Scone.hh" +#include "CalorimeterScorers.hh" +#include "InteractionScorers.hh" +#include "RootOutput.h" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" +#include "NPOptionManager.h" +#include "NPSHitsMap.hh" +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace Scone_NS{ + // Energy and time Resolution + const double EnergyThreshold = 0.*MeV; + const double ResoTime = 0.5*ns ; + const double ResoEnergy = 0.001*MeV ; + const double XSection = 25.1*mm ; + const double YSection = 25.6*mm ; + const double LengthR1 = 1000*mm ; + const double LengthR2 = 500*mm ; + const double Length2x2 = 400*mm ; + const double GdThickness = 25*um ; + const double DistanceBetweenBar = 1*mm ; + const string Material = "EJ200"; +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Scone Specific Method +Scone::Scone(){ + InitializeMaterial(); + m_Event = new TSconeData() ; + m_SconeScorer = 0; + + m_SquareDetector = 0; + + m_BuildRing1 = 1; + m_BuildRing2 = 1; + + m_NumberOfInnerDetector = 16; + m_NumberOfRing1Detector = 8; + m_NumberOfRing2Detector = 16; + + m_Assembly = 0; + + // RGB Color + Transparency + m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_Vis2x2 = new G4VisAttributes(G4Colour(0, 0.5, 0.6, 1.0)); + m_Vis6x6R1 = new G4VisAttributes(G4Colour(0.2, 1, 1, 1)); + m_Vis6x6R2 = new G4VisAttributes(G4Colour(0.2, 0.8, 0.6, 1)); + m_VisGd = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 1)); +} + +Scone::~Scone(){ +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Scone::AddDetector(G4ThreeVector POS){ + // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 + m_R.push_back(POS.mag()); + m_Theta.push_back(POS.theta()); + m_Phi.push_back(POS.phi()); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* Scone::Build2x2Assembly(int DetNumber){ + + G4String Name = "2x2block_" + to_string(DetNumber); + + //--- Full assembly definition ---// + double Xsize = 2*Scone_NS::XSection + 2*2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar; + double Ysize = 2*Scone_NS::YSection + 2*2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar; + double Zsize = Scone_NS::Length2x2; + + G4Box* solidMotherVolume = new G4Box("2x2block", 0.5*Xsize, 0.5*Ysize, 0.5*Zsize); + m_2x2Assembly = new G4LogicalVolume(solidMotherVolume, m_MaterialVaccuum, Name, 0, 0, 0); + + G4VisAttributes * MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); + MotherVolumeVisAtt->SetForceWireframe(true); + //m_2x2Assembly->SetVisAttributes(G4VisAttributes::Invisible); + m_2x2Assembly->SetVisAttributes(MotherVolumeVisAtt); + + //--- One bar definitation ---// + G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5, + Scone_NS::YSection*0.5,Scone_NS::Length2x2*0.5); + G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material); + + m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box_",0,0,0); + m_SquareDetector->SetVisAttributes(m_Vis2x2); + m_SquareDetector->SetSensitiveDetector(m_SconeScorer); + + //--- Gd Layer around the plastic bar ---// + G4Material* Gd_Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Gd"); + G4Box* box_tmp = new G4Box("Box_tmp",(Scone_NS::XSection+Scone_NS::GdThickness)*0.5, (Scone_NS::YSection+Scone_NS::GdThickness)*0.5, Scone_NS::Length2x2*0.49); + G4VSolid* Gd_layer = (G4VSolid*) new G4SubtractionSolid("Gd_layer", box_tmp, box,0,G4ThreeVector(0,0,0)); + + G4LogicalVolume* Gd_layer_volume = new G4LogicalVolume(Gd_layer, Gd_Material,"Gd_layer_volume",0,0,0); + Gd_layer_volume->SetVisAttributes(m_VisGd); + + double posX = 0; + double posY = 0; + double posX_orig = -0.5*(Scone_NS::XSection + Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar); + double posY_orig = -0.5*(Scone_NS::YSection + Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar); + double BarNumber = 0; + G4ThreeVector Tv; + Tv.setX(0); Tv.setY(0); Tv.setZ(0); + for(int i=0; i<2; i++){ + for(int j=0; j<2; j++){ + BarNumber++; + + posX= posX_orig+i*(Scone_NS::XSection + 2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar); + posY= posY_orig+j*(Scone_NS::YSection + 2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar); + Tv.setX(posX); + Tv.setY(posY); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + Tv, + m_SquareDetector,"PlasticBar", + m_2x2Assembly, false, BarNumber); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + Tv, + Gd_layer_volume,"GdLayer", + m_2x2Assembly, false, 0); + } + } + return m_2x2Assembly; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* Scone::Build6x6Assembly(int DetNumber, double plastic_length){ + + G4String Name = "6x6block_" + to_string(DetNumber); + + //--- Full assembly definition ---// + double Xsize = 6*Scone_NS::XSection + 6*2*Scone_NS::GdThickness + 5*Scone_NS::DistanceBetweenBar; + double Ysize = 6*Scone_NS::YSection + 6*2*Scone_NS::GdThickness + 5*Scone_NS::DistanceBetweenBar; + double Zsize = plastic_length; + + G4Box* solidMotherVolume = new G4Box("6x6block", 0.5*Xsize, 0.5*Ysize, 0.5*Zsize); + m_6x6Assembly = new G4LogicalVolume(solidMotherVolume, m_MaterialVaccuum, Name, 0, 0, 0); + + G4VisAttributes * MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); + MotherVolumeVisAtt->SetForceWireframe(true); + m_6x6Assembly->SetVisAttributes(MotherVolumeVisAtt); + + //--- One bar definitation ---// + G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5, + Scone_NS::YSection*0.5,plastic_length*0.5); + G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material); + m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0); + if(plastic_length == Scone_NS::LengthR2) + m_SquareDetector->SetVisAttributes(m_Vis6x6R2); + else + m_SquareDetector->SetVisAttributes(m_Vis6x6R1); + m_SquareDetector->SetSensitiveDetector(m_SconeScorer); + + //--- Gd Layer around the plastic bar ---// + G4Material* Gd_Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Gd"); + G4Box* box_tmp = new G4Box("Box_tmp",(Scone_NS::XSection+Scone_NS::GdThickness)*0.5, (Scone_NS::YSection+Scone_NS::GdThickness)*0.5, plastic_length*0.49); + G4VSolid* Gd_layer = (G4VSolid*) new G4SubtractionSolid("Gd_layer",box_tmp,box,0,G4ThreeVector(0,0,0)); + + G4LogicalVolume* Gd_layer_volume = new G4LogicalVolume(Gd_layer, Gd_Material,"Gd_layer_volume",0,0,0); + Gd_layer_volume->SetVisAttributes(m_VisGd); + + + double posX = 0; + double posY = 0; + double posX_orig=-2.5*Scone_NS::XSection-4.5*Scone_NS::GdThickness-2.5*Scone_NS::DistanceBetweenBar; + double posY_orig=-2.5*Scone_NS::YSection-4.5*Scone_NS::GdThickness-2.5*Scone_NS::DistanceBetweenBar; + double BarNumber = 0; + G4ThreeVector Tv; + Tv.setX(0); Tv.setY(0); Tv.setZ(0); + for(int i=0; i<6; i++){ + for(int j=0; j<6; j++){ + BarNumber++; + + posX= posX_orig+i*(Scone_NS::XSection + 2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar); + posY= posY_orig+j*(Scone_NS::YSection + 2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar); + Tv.setX(posX); + Tv.setY(posY); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + Tv, + m_SquareDetector,"PlasticBar", + m_6x6Assembly, false, BarNumber); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + Tv, + Gd_layer_volume,"GdLayer", + m_6x6Assembly, false, 0); + } + } + return m_6x6Assembly; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* Scone::BuildSquareDetector(){ + if(!m_SquareDetector){ + G4Box* box = new G4Box("Scone_Box",Scone_NS::XSection*0.5, + Scone_NS::YSection*0.5,Scone_NS::LengthR1*0.5); + + G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Scone_NS::Material); + m_SquareDetector = new G4LogicalVolume(box,DetectorMaterial,"logic_Scone_Box",0,0,0); + m_SquareDetector->SetVisAttributes(m_VisSquare); + m_SquareDetector->SetSensitiveDetector(m_SconeScorer); + } + return m_SquareDetector; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in Detecor +void Scone::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Scone"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS","Ring1","Ring2"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Scone " << i+1 << endl; + + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); + m_BuildRing1 = blocks[i]->GetInt("Ring1"); + m_BuildRing2 = blocks[i]->GetInt("Ring2"); + AddDetector(Pos); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Scone::ConstructDetector(G4LogicalVolume* world){ + Build2x2Block(world); + + if(m_BuildRing1==1) + BuildRing1(world); + + if(m_BuildRing2==1) + BuildRing2(world); +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Scone::Build2x2Block(G4LogicalVolume* world){ + + G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0); + double posX_orig = 0; + double posX_neg = posX_orig - 2*(Scone_NS::XSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + double posX_pos = posX_orig + 2*(Scone_NS::XSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + double posY_orig = 0; + double posY_neg = posY_orig - 2*(Scone_NS::YSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + double posY_pos = posY_orig + 2*(Scone_NS::YSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + + double posX[16] = {posX_orig, posX_orig, posX_neg, posX_neg, posX_neg, posX_pos, posX_pos, posX_pos, posX_orig, posX_orig, posX_neg, posX_neg, posX_neg, posX_pos, posX_pos, posX_pos}; + double posY[16] = {posY_neg, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_orig, posY_pos}; + double posZ[16] = {-300,-300,-300,-300,-300,-300,-300,-300,300,300,300,300,300,300,300,300}; + + G4ThreeVector Det_pos; + + for(int i=0; i<m_NumberOfInnerDetector; i++){ + m_Assembly++; + G4String Name = "2x2block_" + to_string(m_Assembly); + Det_pos = G4ThreeVector(posX[i], posY[i], posZ[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), + Build2x2Assembly(m_Assembly), + Name, world, + false, m_Assembly); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Scone::BuildRing1(G4LogicalVolume* world){ + G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0); + double posX_orig = 0; + double posX_neg = posX_orig - 6*(Scone_NS::XSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + double posX_pos = posX_orig + 6*(Scone_NS::XSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + double posY_orig = 0; + double posY_neg = posY_orig - 6*(Scone_NS::YSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + double posY_pos = posY_orig + 6*(Scone_NS::YSection + Scone_NS::DistanceBetweenBar + 2*Scone_NS::GdThickness); + + double posX[8] = {posX_orig, posX_orig, posX_neg, posX_neg, posX_neg, posX_pos, posX_pos, posX_pos}; + double posY[8] = {posY_neg, posY_pos, posY_neg, posY_orig, posY_pos, posY_neg, posY_orig, posY_pos}; + double posZ[8] = {0,0,0,0,0,0,0,0}; + + G4ThreeVector Det_pos; + + for(int i=0; i<m_NumberOfRing1Detector; i++) + { + m_Assembly++; + G4String Name = "6x6block_Ring1_" + to_string(m_Assembly); + Det_pos = G4ThreeVector(posX[i], posY[i], posZ[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), + Build6x6Assembly(m_Assembly, Scone_NS::LengthR1), + Name, world, + false, m_Assembly); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Scone::BuildRing2(G4LogicalVolume* world){ + G4RotationMatrix* Rot = new G4RotationMatrix(0,0,0); + double shiftX = Scone_NS::XSection + 2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar; + double shiftY = Scone_NS::YSection + 2*Scone_NS::GdThickness + Scone_NS::DistanceBetweenBar; + double posX_orig = 0; + double posX_left = posX_orig - 12*shiftX; + double posX_right = posX_orig + 12*shiftX; + double posY_orig = 0; + double posY_down = posY_orig - 12*shiftY; + double posY_up = posY_orig + 12*shiftY; + + double posX[16]; + posX[0]= posX_left; + posX[1]= posX_left; + posX[2]= posX_left; + posX[3]= posX_left; + posX[4]= posX_left; + posX[5]= posX_right; + posX[6]= posX_right; + posX[7]= posX_right; + posX[8]= posX_right; + posX[9]= posX_right; + posX[10]= posX_left+6*shiftX; + posX[11]= posX_left+12*shiftX; + posX[12]= posX_left+18*shiftX; + posX[13]= posX_left+6*shiftX; + posX[14]= posX_left+12*shiftX; + posX[15]= posX_left+18*shiftX; + + double posY[16]; + posY[0]= posY_down; + posY[1]= posY_down+6*shiftY; + posY[2]= posY_down+12*shiftY; + posY[3]= posY_down+18*shiftY; + posY[4]= posY_down+24*shiftY; + posY[5]= posY_down; + posY[6]= posY_down+6*shiftY; + posY[7]= posY_down+12*shiftY; + posY[8]= posY_down+18*shiftY; + posY[9]= posY_down+24*shiftY; + posY[10]= posY_down; + posY[11]= posY_down; + posY[12]= posY_down; + posY[13]= posY_up; + posY[14]= posY_up; + posY[15]= posY_up; + + G4ThreeVector Det_pos; + G4String Name; + for(int i=0; i<m_NumberOfRing2Detector; i++) + { + m_Assembly++; + Name = "6x6block_Ring2_" + to_string(m_Assembly); + Det_pos = G4ThreeVector(posX[i], posY[i], 0); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), + Build6x6Assembly(m_Assembly, Scone_NS::LengthR2), + Name, world, + false, m_Assembly); + } +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void Scone::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("Scone")){ + pTree->Branch("Scone", "TSconeData", &m_Event) ; + } + pTree->SetBranchAddress("Scone", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void Scone::ReadSensitive(const G4Event* ){ + m_Event->Clear(); + + /////////// + // Calorimeter scorer + CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_SconeScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for(unsigned int i = 0 ; i < size ; i++){ + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Scone_NS::ResoEnergy); + if(Energy>Scone_NS::EnergyThreshold){ + double Time = RandGauss::shoot(Scorer->GetTime(i),Scone_NS::ResoTime); + int DetectorNbr = level[0]; + int PlasticNbr = level[1]; + m_Event->SetEnergy(DetectorNbr,PlasticNbr,Energy); + m_Event->SetTime(DetectorNbr,PlasticNbr,Time); + } + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void Scone::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_SconeScorer = CheckScorer("SconeScorer",already_exist) ; + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + vector<int> level; + level.push_back(1); + level.push_back(0); + //G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; + G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level) ; + G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; + //and register it to the multifunctionnal detector + m_SconeScorer->RegisterPrimitive(Calorimeter); + m_SconeScorer->RegisterPrimitive(Interaction); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SconeScorer) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Scone::InitializeMaterial(){ + m_MaterialVaccuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* Scone::Construct(){ + return (NPS::VDetector*) new Scone(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_Scone{ + public: + proxy_nps_Scone(){ + NPS::DetectorFactory::getInstance()->AddToken("Scone","Scone"); + NPS::DetectorFactory::getInstance()->AddDetector("Scone",Scone::Construct); + } + }; + + proxy_nps_Scone p_nps_Scone; +} diff --git a/NPSimulation/Detectors/Scone/Scone.hh b/NPSimulation/Detectors/Scone/Scone.hh new file mode 100644 index 0000000000000000000000000000000000000000..bff46af618b38fa7b5c6c42baf4504719ab48e51 --- /dev/null +++ b/NPSimulation/Detectors/Scone/Scone.hh @@ -0,0 +1,135 @@ +#ifndef Scone_h +#define Scone_h 1 +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr * + * * + * Creation Date : March 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe Scone simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ header +#include <string> +#include <vector> +using namespace std; + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4AssemblyVolume.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool header +#include "NPSVDetector.hh" +#include "TSconeData.h" +#include "NPInputParser.h" + +class Scone : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + Scone() ; + virtual ~Scone() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + void AddDetector(G4ThreeVector POS); + + G4LogicalVolume* Build2x2Assembly(int DetNumber); + G4LogicalVolume* Build6x6Assembly(int DetNumber, double plastic_length); + G4LogicalVolume* BuildSquareDetector(); + + void Build2x2Block(G4LogicalVolume* world); + void BuildRing1(G4LogicalVolume* world); + void BuildRing2(G4LogicalVolume* world); + + private: + G4LogicalVolume* m_2x2Assembly; + G4LogicalVolume* m_6x6Assembly; + G4LogicalVolume* m_SquareDetector; + + //////////////////////////////////////////////////// + ////// Inherite from NPS::VDetector class ///////// + //////////////////////////////////////////////////// + public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + public: // Scorer + // Initialize all Scorer used by the MUST2Array + void InitializeScorers() ; + + // Associated Scorer + G4MultiFunctionalDetector* m_SconeScorer ; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TSconeData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: // Geometry + // Detector Coordinate + vector<double> m_R; + vector<double> m_Theta; + vector<double> m_Phi; + + int m_BuildRing1; + int m_BuildRing2; + int m_NumberOfInnerDetector; + int m_NumberOfRing1Detector; + int m_NumberOfRing2Detector; + int m_Assembly; + + private: // Initalise material used in detector definition + void InitializeMaterial(); + G4Material* m_MaterialVaccuum; + + + // Shape type + vector<string> m_Shape ; + + // Visualisation Attribute + G4VisAttributes* m_VisSquare; + G4VisAttributes* m_Vis2x2; + G4VisAttributes* m_Vis6x6R1; + G4VisAttributes* m_Vis6x6R2; + G4VisAttributes* m_VisGd; + + // Needed for dynamic loading of the library + public: + static NPS::VDetector* Construct(); +}; +#endif diff --git a/NPSimulation/Detectors/TACTIC/18Ne21Na.reaction b/NPSimulation/Detectors/TACTIC/18Ne21Na.reaction new file mode 100644 index 0000000000000000000000000000000000000000..f5dd72e2c15e8751e768224de2f6ffba58d92a32 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/18Ne21Na.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% Reaction file for 18Ne(alpha,p)21Na reaction %%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 18Ne + Energy= 50 MeV + SigmaEnergy= 0 MeV + SigmaX= 1 mm + SigmaY= 1 mm + SigmaThetaX= 0 deg + SigmaPhiY= 0 deg + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 0 mm + MeanY= 0 mm + +TwoBodyReaction + Beam= 18Ne + Target= 4He + Light= 1H + Heavy= 21Na + ExcitationEnergyHeavy= 0.0 + ExcitationEnergyLight= 0.0 + CrossSectionPath= flat.txt CS + ShootLight= 1 + ShootHeavy= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/NPSimulation/Detectors/TACTIC/18Ne4He_scat.reaction b/NPSimulation/Detectors/TACTIC/18Ne4He_scat.reaction new file mode 100644 index 0000000000000000000000000000000000000000..e7bb1cddc0dfe42d07cfbc50b8e2142d515281db --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/18Ne4He_scat.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% Reaction file for 18Ne4He elastic scattering %%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 18Ne + Energy= 15 MeV + SigmaEnergy= 0 MeV + SigmaX= 1 mm + SigmaY= 1 mm + SigmaThetaX= 0 deg + SigmaPhiY= 0 deg + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 0 mm + MeanY= 0 mm + +TwoBodyReaction + Beam= 18Ne + Target= 4He + Light= 4He + Heavy= 18Ne + ExcitationEnergyHeavy= 0.0 + ExcitationEnergyLight= 0.0 + CrossSectionPath= flat.txt CS + ShootLight= 1 + ShootHeavy= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/NPSimulation/Detectors/TACTIC/8Li11B.reaction b/NPSimulation/Detectors/TACTIC/8Li11B.reaction new file mode 100644 index 0000000000000000000000000000000000000000..5b5e226ee18e7bac48a5f4c32cd0c1eb50f49cf5 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/8Li11B.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% Reaction file for 18Ne(alpha,p)21Na reaction %%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 8Li + Energy= 15 MeV + SigmaEnergy= 0 MeV + SigmaX= 1 mm + SigmaY= 1 mm + SigmaThetaX= 0 deg + SigmaPhiY= 0 deg + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 0 mm + MeanY= 0 mm + +TwoBodyReaction + Beam= 8Li + Target= 4He + Light= neutron + Heavy= 11B + ExcitationEnergyHeavy= 0.0 + ExcitationEnergyLight= 0.0 + CrossSectionPath= flat.txt CS + ShootLight= 1 + ShootHeavy= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/NPSimulation/Detectors/TACTIC/8Li4He_scat.reaction b/NPSimulation/Detectors/TACTIC/8Li4He_scat.reaction new file mode 100644 index 0000000000000000000000000000000000000000..ec9a2bba6ebb8b1a09e868735426427b61efc21d --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/8Li4He_scat.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% Reaction file for 8Li11B scat %%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 8Li + Energy= 15 MeV + SigmaEnergy= 0 MeV + SigmaX= 1 mm + SigmaY= 1 mm + SigmaThetaX= 0 deg + SigmaPhiY= 0 deg + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 0 mm + MeanY= 0 mm + +TwoBodyReaction + Beam= 8Li + Target= 4He + Light= 4He + Heavy= 8Li + ExcitationEnergyHeavy= 0.0 + ExcitationEnergyLight= 0.0 + CrossSectionPath= flat.txt CS + ShootLight= 1 + ShootHeavy= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/NPSimulation/Detectors/TACTIC/CMakeLists.txt b/NPSimulation/Detectors/TACTIC/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0f45c9906bb8931667f8aaf54c2289da1dc66a2d --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSTACTIC SHARED TACTIC.cc TACTICScorer.cc) +target_link_libraries(NPSTACTIC NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPTACTIC) diff --git a/NPSimulation/Detectors/TACTIC/README b/NPSimulation/Detectors/TACTIC/README new file mode 100644 index 0000000000000000000000000000000000000000..ed14cbab0992b9301c96d58323ebb826eb59747a --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/README @@ -0,0 +1,51 @@ +out.dat contains the latest setp information after the particle in question has traversed the length of a strip (~4mm) for step size of (~0.1mm) + +The coloumn headings of out.dat are: + +Event ID +Track ID +Particle ID (see below for index list) +Time +Kinetic Energy +Ionization Energy Deposit (Accumilated during the particles traversal across the strip length) +Pad Number +z Position +R Position +Vertex Position +Vertex Kinetic Energy +Vertex Theta +Track Length + +(If there has not been a vertex during the step then the vertex information given is taken from the last vertex position) + +Particle Index list: + +0 Ne18 +1 Na21 +2 proton +3 alpha +4 Li8 +5 B11 +6 neutron (athough the chances of neutron scattering are almost negligable) + +The simulation is only currently set up for a Ne18 or Li8 beam. To include different beam species the species should be added to the partilce index list in TACTICScorer.cc + +To run: + +npsimulation -D TACTIC.detector -E 18Ne21Na.reaction + +for batch mode edit run.mac and run: npsimulation -D TACTIC.detector -E 18Ne21Na.reaction -B run.mac + +TACTIC.detector is the detector config file, the gas can be changed here between He/CO2 and P10 and the pressure, temperature etc. can be changed. If using P10 set P10 gas fraction to 100 and set another gas fration (CO2 for example) to zero (i.e the code looks for two gases). + +18Ne21Na_reaction is the reaction file. The beam energy, spread, etc. can be changed here. Other reactions currently available are: + +18Ne4He_scat.reaction +8Li11B.reaction +8Li4He_scat.reaction + +Other reaction files can be created but the particles involved will need to be added to the particle index in TACTICScorer.cc . + +The reactions are currently isotropic in both angle and energy distribution. + +IMPORTANT: The output will continue to append to out.dat so when starting a new run either delete or move the existing out.dat if you do not wish to append to the existing data file. diff --git a/NPSimulation/Detectors/TACTIC/TACTIC.cc b/NPSimulation/Detectors/TACTIC/TACTIC.cc new file mode 100644 index 0000000000000000000000000000000000000000..554933ba1556421c148a06ce79bafa46bfc6f35c --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/TACTIC.cc @@ -0,0 +1,375 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: Warren.Lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TACTIC simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Tubs.hh" +#include "G4Box.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4Material.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4THitsMap.hh" +#include "G4SDParticleFilter.hh" + +// NPTool header +#include "TACTIC.hh" +#include "TACTICScorer.hh" + +#include "RootOutput.h" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" +#include "NPOptionManager.h" +#include "NPSHitsMap.hh" +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace TACTIC_NS{ + // Energy and time Resolution + + //const double EnergyThreshold = 0.01*MeV; + //const double ResoTime = 17.*ns ; + //const double ResoEnergy = 1.0*MeV ; + const double cathode_radius = 12.*mm; + const double drift_radius = 50.*mm; + const double anode_radius = 51.*mm; + const double active_length = 251.9*mm; + const double window_pos = 104.*mm; //from centre of TACTIC from https://elog.triumf.ca/Tactic/Documentation/18 + const double window_radius = 12.*mm; //guess + const double window_width = 1.5e-03*mm; + const double vacuum_pos = (active_length/2. + window_pos + window_width/2.)/2.*mm; + const double vacuum_width = active_length/2. - window_pos - window_width/2.*mm; + const G4int NumberOfStrips = 60; + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// TACTIC Specific Method +TACTIC::TACTIC(){ + m_Event = new TTACTICData() ; + m_Scorer = 0; + m_CylindricalDetector = 0; + + m_ReactionRegion = NULL; + // RGB Color + Transparency + + m_VisChamber = new G4VisAttributes(G4Colour(1., 1., 1., 1.0)); + m_VisWindows = new G4VisAttributes(G4Colour(1, 1, 1, 1.0)); + m_VisGas = new G4VisAttributes(G4Colour(1, 1, 1, 0.1)); + m_VisVacuum = new G4VisAttributes(G4Colour(1,1,1,1.)); + + m_VisChamber->SetForceWireframe(true); + m_VisVacuum->SetForceWireframe(true); +} + +TACTIC::~TACTIC(){ +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TACTIC::AddDetector(G4ThreeVector POS, string Shape){ + // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 + m_R.push_back(POS.mag()); + m_Theta.push_back(POS.theta()); + m_Phi.push_back(POS.phi()); + m_Shape.push_back(Shape); +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TACTIC::AddDetector(double R, double Theta, double Phi, string Shape){ + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_Shape.push_back(Shape); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4LogicalVolume* TACTIC::BuildCylindricalDetector(){ + if(!m_CylindricalDetector){ + + G4Material* Cu = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); + G4Material* Mylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + + unsigned const int NumberOfGasMix = m_GasMaterial.size(); + + double density=0; + vector<G4Material*> GasComponent; + + for(unsigned int i=0; i<NumberOfGasMix; i++){ + if(m_GasMaterial[i] == "CO2") GasComponent.push_back(MaterialManager::getInstance()->GetGasFromLibrary(m_GasMaterial[i], 1.0/bar, m_Temperature)); + else GasComponent.push_back(MaterialManager::getInstance()->GetMaterialFromLibrary(m_GasMaterial[i])); + } + + for(unsigned int i=0; i<NumberOfGasMix; i++){ + density += ((double)m_GasFraction[i]/100)*GasComponent[i]->GetDensity()*(m_Pressure/bar)/(GasComponent[i]->GetPressure()/bar); + // p2 = p1*(P2/P1) //e.g. p2 = p1*(0.5/1) p scales with P, T=const + } + + G4Material* TACTIC_gas = new G4Material("TACTIC_gas", density, NumberOfGasMix, kStateGas, m_Temperature, m_Pressure); + + for(unsigned int i=0; i<NumberOfGasMix; i++) TACTIC_gas->AddMaterial(GasComponent[i], (double)m_GasFraction[i]/100); + + cout << TACTIC_gas << endl; + + G4Tubs* anode = new G4Tubs("anode",0,TACTIC_NS::anode_radius,TACTIC_NS::active_length*0.5,0,360*deg); + G4Tubs* gas_volume = new G4Tubs("gas_volume",0,TACTIC_NS::drift_radius,TACTIC_NS::active_length*0.5,0,360*deg); + G4Tubs* window = new G4Tubs("window",0,TACTIC_NS::window_radius,TACTIC_NS::window_width*0.5,0,360*deg); + G4Tubs* vacuum = new G4Tubs("vacuum",0,TACTIC_NS::window_radius,TACTIC_NS::vacuum_width*0.5,0,360*deg); + + m_CylindricalDetector = new G4LogicalVolume(anode, Cu, "anode_log",0,0,0); + gas_volume_log = new G4LogicalVolume(gas_volume, TACTIC_gas, "gas_volume_log",0,0,0); + window_log = new G4LogicalVolume(window, Mylar, "window_log",0,0,0); + vacuum_log = new G4LogicalVolume(vacuum, Vacuum, "vacuum_log",0,0,0); + + new G4PVPlacement(0,G4ThreeVector(0,0,0),gas_volume_log,"gas_volume_phys",m_CylindricalDetector,false,0); + new G4PVPlacement(0,G4ThreeVector(0,0,TACTIC_NS::window_pos),window_log,"window_phys",gas_volume_log,false,0); + new G4PVPlacement(0,G4ThreeVector(0,0,-TACTIC_NS::window_pos),window_log,"window_phys",gas_volume_log,false,0); + new G4PVPlacement(0,G4ThreeVector(0,0,TACTIC_NS::vacuum_pos),vacuum_log,"vacuum_phys",gas_volume_log,false,0); + new G4PVPlacement(0,G4ThreeVector(0,0,-TACTIC_NS::vacuum_pos),vacuum_log,"vacuum_phys",gas_volume_log,false,0); + + gas_volume_log->SetVisAttributes(m_VisGas); + window_log->SetVisAttributes(m_VisWindows); + vacuum_log->SetVisAttributes(m_VisVacuum); + m_CylindricalDetector->SetVisAttributes(m_VisChamber); + + G4UserLimits *gas_volume_step = new G4UserLimits(); + G4double maxStep = 0.1*mm; + gas_volume_step->SetMaxAllowedStep(maxStep); + gas_volume_log->SetUserLimits(gas_volume_step); + + gas_volume_log->SetSensitiveDetector(m_Scorer); + } + return m_CylindricalDetector; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void TACTIC::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("TACTIC"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS","Shape","GasMaterial_1","GasMaterial_2","GasFraction_1","GasFraction_2","Temperature","Pressure"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TACTIC " << i+1 << endl; + + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm")); + string Shape = blocks[i]->GetString("Shape"); + m_GasMaterial.push_back(blocks[i]->GetString("GasMaterial_1")); + m_GasMaterial.push_back(blocks[i]->GetString("GasMaterial_2")); + m_GasFraction.push_back(blocks[i]->GetInt("GasFraction_1")); + m_GasFraction.push_back(blocks[i]->GetInt("GasFraction_2")); + m_Temperature = blocks[i]->GetDouble("Temperature","kelvin"); + m_Pressure = blocks[i]->GetDouble("Pressure","bar"); + AddDetector(Pos,Shape); + } + + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void TACTIC::ConstructDetector(G4LogicalVolume* world){ + for (unsigned short i = 0 ; i < m_R.size() ; i++) { + + G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; + G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; + G4double wZ = m_R[i] * cos(m_Theta[i] ) ; + G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; + // So the face of the detector is at R instead of the middle + Det_pos+=Det_pos.unit()*TACTIC_NS::active_length*0.5; + // Building Detector reference frame + G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]); + G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]); + G4double kk = -sin(m_Theta[i]); + G4ThreeVector Y(ii,jj,kk); + G4ThreeVector w = Det_pos.unit(); + G4ThreeVector u = w.cross(Y); + G4ThreeVector v = w.cross(u); + v = v.unit(); + u = u.unit(); + + G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); + new G4PVPlacement(G4Transform3D(*Rot,Det_pos),BuildCylindricalDetector(),"TACTIC",world,false,i+1); + + if(!m_ReactionRegion){ + G4ProductionCuts* ecut = new G4ProductionCuts(); + ecut->SetProductionCut(1000,"e-"); //I think lowest is 900 eV for delta electron production, this is 1000 MeV to cut all electrons produced this way + m_ReactionRegion= new G4Region("NPSimulationProcess"); + m_ReactionRegion->SetProductionCuts(ecut); + m_ReactionRegion->AddRootLogicalVolume(gas_volume_log); + } + + G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); + unsigned int size = m_ReactionModel.size(); + for(unsigned int i = 0 ; i < size ; i++){ + mng->RemoveFastSimulationModel(m_ReactionModel[i]); + } + m_ReactionModel.clear(); + + G4VFastSimulationModel* fsm; + fsm = new NPS::BeamReaction("BeamReaction",m_ReactionRegion); + m_ReactionModel.push_back(fsm); + + } +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void TACTIC::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("TACTIC")){ + pTree->Branch("TACTIC", "TTACTICData", &m_Event) ; + } + pTree->SetBranchAddress("TACTIC", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void TACTIC::ReadSensitive(const G4Event* event ){ + m_Event->Clear(); + + ofstream file; + + G4THitsMap<G4double*>* BeamHitMap; + std::map<G4int, G4double**>::iterator Beam_itr; + G4int BeamCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TACTICScorer/BeamScorer"); + BeamHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(BeamCollectionID)); + + file.open("/Users/warren/nptool/NPSimulation/Detectors/TACTIC/out.dat",std::ios::app); + + for (Beam_itr = BeamHitMap->GetMap()->begin(); Beam_itr != BeamHitMap->GetMap()->end(); Beam_itr++) { + G4double* Info = *(Beam_itr->second); + //file << floor(((Info[3]+TACTIC_NS::active_length*0.5)/(TACTIC_NS::active_length/TACTIC_NS::NumberOfStrips))) << "\t"; // To get PAD number + file << event->GetEventID() << "\t"; + for(int s = 0; s<12; s++) { + if(s==11) file << Info[s] << endl; + else file << Info[s] << "\t"; + } + } + + BeamHitMap->clear(); + + G4THitsMap<G4double*>* EjectHitMap; + std::map<G4int, G4double**>::iterator Eject_itr; + G4int EjectCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TACTICScorer/EjectScorer"); + EjectHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(EjectCollectionID)); + + for (Eject_itr = EjectHitMap->GetMap()->begin(); Eject_itr != EjectHitMap->GetMap()->end(); Eject_itr++) { + G4double* Info = *(Eject_itr->second); + //file << floor(((Info[3]+TACTIC_NS::active_length*0.5)/(TACTIC_NS::active_length/TACTIC_NS::NumberOfStrips))) << "\t"; // To get PAD number + file << event->GetEventID() << "\t"; + for(int s = 0; s<12; s++) { + if(s==11) file << Info[s] << endl; + else file << Info[s] << "\t"; + } + } + + EjectHitMap->clear(); + + file.close(); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void TACTIC::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_Scorer = CheckScorer("TACTICScorer",already_exist) ; + if(already_exist) + return ; + + // Otherwise the scorer is initialised + G4VPrimitiveScorer* EjectScorer = new TACTICScorer::Gas_Scorer("EjectScorer",1,TACTIC_NS::active_length,(int)TACTIC_NS::NumberOfStrips); + G4VPrimitiveScorer* BeamScorer = new TACTICScorer::Gas_Scorer("BeamScorer",1,TACTIC_NS::active_length,(int)TACTIC_NS::NumberOfStrips); + G4SDParticleFilter* EjectFilter = new G4SDParticleFilter("EjectFilter","proton"); + G4SDParticleFilter* BeamFilter = new G4SDParticleFilter("BeamFilter"); + BeamFilter->addIon(11,21); + BeamFilter->addIon(10,18); + EjectScorer->SetFilter(EjectFilter); + BeamScorer->SetFilter(BeamFilter); + + m_Scorer->RegisterPrimitive(BeamScorer); + m_Scorer->RegisterPrimitive(EjectScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* TACTIC::Construct(){ + return (NPS::VDetector*) new TACTIC(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_TACTIC{ + public: + proxy_nps_TACTIC(){ + NPS::DetectorFactory::getInstance()->AddToken("TACTIC","TACTIC"); + NPS::DetectorFactory::getInstance()->AddDetector("TACTIC",TACTIC::Construct); + } + }; + + proxy_nps_TACTIC p_nps_TACTIC; +} diff --git a/NPSimulation/Detectors/TACTIC/TACTIC.detector b/NPSimulation/Detectors/TACTIC/TACTIC.detector new file mode 100644 index 0000000000000000000000000000000000000000..36ef031cecae6c257cc5afbe45586263a489b224 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/TACTIC.detector @@ -0,0 +1,12 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TACTIC + POS= 0 0 0 mm + Shape= Cylindrical +% GasMaterial_1 = P10_1atm + GasMaterial_1 = He_gas + GasMaterial_2 = CO2 + GasFraction_1 = 90 + GasFraction_2 = 10 + Temperature = 293.15 kelvin + Pressure = 0.5 bar +% Pressure = 1.0 bar diff --git a/NPSimulation/Detectors/TACTIC/TACTIC.hh b/NPSimulation/Detectors/TACTIC/TACTIC.hh new file mode 100644 index 0000000000000000000000000000000000000000..d48efb75596010adbb35d83b5929a9f2b21f1d80 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/TACTIC.hh @@ -0,0 +1,134 @@ +#ifndef TACTIC_h +#define TACTIC_h 1 +/***************************************************************************** + * Copyright (C) 2009-2020 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Warren Lynch contact address: Warren.Lynch@york.ac.uk * + * * + * Creation Date : June 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TACTIC simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ header +#include <string> +#include <vector> +using namespace std; + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4MultiFunctionalDetector.hh" +#include "G4UserLimits.hh" +#include "G4VFastSimulationModel.hh" +#include "G4FastSimulationManager.hh" + +// NPTool header +#include "NPSVDetector.hh" +#include "TTACTICData.h" +#include "NPInputParser.h" +#include "Decay.hh" +#include "BeamReaction.hh" + +class TACTIC : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + TACTIC() ; + virtual ~TACTIC() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // Cartesian + void AddDetector(G4ThreeVector POS, string Shape); + // Spherical + void AddDetector(double R,double Theta,double Phi,string Shape); + + G4LogicalVolume* BuildCylindricalDetector(); + +private: + G4LogicalVolume* m_CylindricalDetector; + G4LogicalVolume* gas_volume_log; + G4LogicalVolume* window_log; + G4LogicalVolume* vacuum_log; + //////////////////////////////////////////////////// + ////// Inherite from NPS::VDetector class ///////// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + +public: // Scorer + // Initialize all Scorer used by the MUST2Array + void InitializeScorers() ; + + // Associated Scorer + G4MultiFunctionalDetector* m_Scorer ; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// +private: + TTACTICData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: // Geometry + // Detector Coordinate + vector<double> m_R; + vector<double> m_Theta; + vector<double> m_Phi; + + vector<string> m_GasMaterial; + vector<int> m_GasFraction; + + double m_Pressure; + double m_Temperature; + // Shape type + vector<string> m_Shape ; + + // Visualisation Attribute + G4VisAttributes* m_VisChamber; + G4VisAttributes* m_VisWindows; + G4VisAttributes* m_VisGas; + G4VisAttributes* m_VisVacuum; + +private: + // Region were reaction can occure: + G4Region* m_ReactionRegion; + vector<G4VFastSimulationModel*> m_ReactionModel; + + // Needed for dynamic loading of the library +public: + static NPS::VDetector* Construct(); +}; + +#endif diff --git a/NPSimulation/Detectors/TACTIC/TACTICScorer.cc b/NPSimulation/Detectors/TACTIC/TACTICScorer.cc new file mode 100644 index 0000000000000000000000000000000000000000..9265e9e3df6c24c16af3629708ad0e170cb841d5 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/TACTICScorer.cc @@ -0,0 +1,95 @@ +#include "TACTICScorer.hh" +#include "G4UnitsTable.hh" +using namespace TACTICScorer; + +Gas_Scorer::Gas_Scorer(G4String name,G4int Level,G4double ScorerLength,G4int NumberOfSegments, G4int depth) //what do level and depth do? +:G4VPrimitiveScorer(name, depth),HCID(-1){ + m_ScorerLength = ScorerLength; + m_NumberOfSegments = NumberOfSegments; + m_SegmentLength = m_ScorerLength / m_NumberOfSegments; + m_Level = Level; + + m_Position = G4ThreeVector(-1000,-1000,-1000); + m_SegmentNumber = -1; + m_Index = -1; +} + +Gas_Scorer::~Gas_Scorer(){} + +G4bool Gas_Scorer::ProcessHits(G4Step* aStep, G4TouchableHistory*){ + + G4double* Infos = new G4double[12]; + m_Position = aStep->GetPreStepPoint()->GetPosition(); + + Infos[0] = aStep->GetTrack()->GetTrackID(); + + Infos[1] = -1.; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "Ne18") Infos[1] = 0.; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "Na21") Infos[1] = 1.; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton") Infos[1] = 2.; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "alpha") Infos[1] = 3.; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "Li8") Infos[1] = 4.; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "B11") Infos[1] = 5; + if (aStep->GetTrack()->GetDefinition()->GetParticleName() == "neutron") Infos[1] = 6; + + Infos[2] = aStep->GetPreStepPoint()->GetGlobalTime(); + Infos[3] = aStep->GetPreStepPoint()->GetKineticEnergy(); + Infos[4] = aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit(); + + m_SegmentNumber = (int)((m_Position.z() + m_ScorerLength / 2.) / m_SegmentLength ) + 1; //Pad number + Infos[5] = m_SegmentNumber; + Infos[6] = m_Position.z(); + Infos[7] = pow(pow(m_Position.x(),2) + pow(m_Position.y(),2),0.5); //R + Infos[8] = aStep->GetTrack()->GetVertexPosition()[2]; + Infos[9] = aStep->GetTrack()->GetVertexKineticEnergy(); + G4ThreeVector p_vec = aStep->GetTrack()->GetVertexMomentumDirection(); + Infos[10] = acos(p_vec[2]/pow(pow(p_vec[0],2)+pow(p_vec[1],2)+pow(p_vec[2],2),0.5))/deg; //angle relative to z axis (theta); + Infos[11] = aStep->GetTrack()->GetTrackLength(); + + m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); + m_Index = m_DetectorNumber * 1e3 + m_SegmentNumber * 1e6; + + map<G4int, G4double**>::iterator it; + it= EvtMap->GetMap()->find(m_Index); + if(it!=EvtMap->GetMap()->end()){ //accumulate ionisation energy deposit + G4double* dummy = *(it->second); + Infos[4]+=dummy[4]; + delete dummy; + } + + EvtMap->set(m_Index, Infos); + + return TRUE; + +} + +void Gas_Scorer::Initialize(G4HCofThisEvent* HCE){ + EvtMap = new NPS::HitsMap<G4double*>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void Gas_Scorer::EndOfEvent(G4HCofThisEvent*){} + +void Gas_Scorer::clear(){ + std::map<G4int, G4double**>::iterator MapIterator; + for (MapIterator = EvtMap->GetMap()->begin() ; MapIterator != EvtMap->GetMap()->end() ; MapIterator++){ + delete *(MapIterator->second); + } + + EvtMap->clear(); +} + + +void Gas_Scorer::DrawAll(){} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void Gas_Scorer::PrintAll(){ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + diff --git a/NPSimulation/Detectors/TACTIC/TACTICScorer.hh b/NPSimulation/Detectors/TACTIC/TACTICScorer.hh new file mode 100644 index 0000000000000000000000000000000000000000..dfe7a0305ed7e4d0dfb3d64d3fcdc738bb6c76f3 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/TACTICScorer.hh @@ -0,0 +1,55 @@ +#ifndef TACTICScorer_h +#define TACTICScorer_h 1 + +#include "G4VPrimitiveScorer.hh" +#include "NPSHitsMap.hh" +#include <map> + +using namespace std; +using namespace CLHEP; + +namespace TACTICScorer { + + class Gas_Scorer : public G4VPrimitiveScorer{ + + public: + Gas_Scorer(G4String name, + G4int Level, + G4double ScorerLength, + G4int NumberOfSegments, + G4int depth=0); + ~Gas_Scorer(); + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); + + private: // Geometry of the detector + G4double m_ScorerLength; + G4int m_NumberOfSegments; + G4double m_SegmentLength; + // Level at which to find the copy number linked to the detector number + G4int m_Level; + + private: // inherited from G4VPrimitiveScorer + G4int HCID; + NPS::HitsMap<G4double*>* EvtMap; + + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector m_Position ; + G4int m_DetectorNumber ; + G4int m_SegmentNumber ; + G4long m_Index ; + + }; + +} + +#endif diff --git a/NPSimulation/Detectors/TACTIC/run.mac b/NPSimulation/Detectors/TACTIC/run.mac new file mode 100644 index 0000000000000000000000000000000000000000..9cf95ba556fcbf624dcfe4319eaf892c49289489 --- /dev/null +++ b/NPSimulation/Detectors/TACTIC/run.mac @@ -0,0 +1,2 @@ +/run/beamOn 100 +/exit \ No newline at end of file diff --git a/NPSimulation/Detectors/TNT/TNT.cc b/NPSimulation/Detectors/TNT/TNT.cc index 6c99830f65ac817bc87a3ebd2ef4dd6e63881d35..d428cf2775af92b05bfd042db877f98b75deb039 100644 --- a/NPSimulation/Detectors/TNT/TNT.cc +++ b/NPSimulation/Detectors/TNT/TNT.cc @@ -61,8 +61,8 @@ using namespace CLHEP; namespace TNT_NS{ // Energy and time Resolution const double EnergyThreshold = 0.1*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 1.0*MeV ; + //const double ResoTime = 4.5*ns ; +// const double ResoEnergy = 1.0*MeV ; const double Radius = 50*mm ; // const string Material = "para-Terphenyl_Scintillator"; //const string Material = "BC400"; diff --git a/NPSimulation/Detectors/Tiara/Tiara.cc b/NPSimulation/Detectors/Tiara/Tiara.cc index 0811b04426f20491980454b81f1f54a0184de005..70a986d7c8eb1bd6748990193c5797067c165a9a 100644 --- a/NPSimulation/Detectors/Tiara/Tiara.cc +++ b/NPSimulation/Detectors/Tiara/Tiara.cc @@ -117,8 +117,8 @@ void Tiara::ReadConfiguration(NPL::InputParser parser){ blocks.clear(); //by Shuya 180426 - blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); - //blocks = parser.GetAllBlocksWithToken("HyballWedge"); + // blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); + blocks = parser.GetAllBlocksWithTokenAndValue("Tiara","Hyball"); if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; diff --git a/NPSimulation/Detectors/beam_dump/beam_dump.cc b/NPSimulation/Detectors/beam_dump/beam_dump.cc index aa1460dda104d8663db6b37f1d09a98f8ce31b9d..674882e5a3b0b0e5795e7e8fdc3b9dae18f10381 100755 --- a/NPSimulation/Detectors/beam_dump/beam_dump.cc +++ b/NPSimulation/Detectors/beam_dump/beam_dump.cc @@ -1,18 +1,18 @@ /***************************************************************************** - * Copyright (C) 2009-2017 this file is part of the NPTool Project * + * Copyright (C) 2009-2017 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: valerian contact address: girardalcindor@ganil.fr * + * Original Author: valerian contact address: girardalcindor@ganil.fr * * * - * Creation Date : November 2017 * + * Creation Date : November 2017 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class describe beam_dump simulation * + * This class describe beam_dump simulation * * * *---------------------------------------------------------------------------* * Comment: * @@ -59,8 +59,8 @@ namespace beam_dump_NS{ const double EnergyThreshold = 0.0*MeV; const double ResoTime = 0.0*ns ; const double ResoEnergy = 0.0*MeV ; - const double Radius = 20*cm ; - const double Width = 10*cm ; + //const double Radius = 20*cm ; + //const double Width = 10*cm ; // const double Thickness = 34*um ; } diff --git a/NPSimulation/EventGenerator/EventGeneratorIsotropic.cc b/NPSimulation/EventGenerator/EventGeneratorIsotropic.cc index 3ce77203fc9ec5025fc956aebeb814e17e5f397e..4b5059ff9c5e4c356414033a363abcf1be9dd75a 100644 --- a/NPSimulation/EventGenerator/EventGeneratorIsotropic.cc +++ b/NPSimulation/EventGenerator/EventGeneratorIsotropic.cc @@ -38,10 +38,11 @@ #include "NPOptionManager.h" using namespace CLHEP; + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... EventGeneratorIsotropic::EventGeneratorIsotropic(){ m_ParticleStack = ParticleStack::getInstance(); - event_ID=0; + event_ID=0; } @@ -55,6 +56,7 @@ EventGeneratorIsotropic::~EventGeneratorIsotropic(){ EventGeneratorIsotropic::SourceParameters::SourceParameters(){ m_EnergyLow = 0 ; m_EnergyHigh = 0 ; + m_EnergyDistribution = "flat"; m_x0 = 0 ; m_y0 = 0 ; m_z0 = 0 ; @@ -66,18 +68,20 @@ EventGeneratorIsotropic::SourceParameters::SourceParameters(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventGeneratorIsotropic::ReadConfiguration(NPL::InputParser parser){ vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Isotropic"); - m_Parameters.reserve(blocks.size()); + m_Parameters.reserve(blocks.size()); if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "\033[1;35m//// Isotropic reaction found " << endl; - + vector<string> token = {"EnergyLow","EnergyHigh","HalfOpenAngleMin","HalfOpenAngleMax","x0","y0","z0","Particle"}; for(unsigned int i = 0 ; i < blocks.size() ; i++){ if(blocks[i]->HasTokenList(token)){ - m_Parameters.push_back(SourceParameters()); - const vector<SourceParameters>::reverse_iterator it = m_Parameters.rbegin(); - + m_Parameters.push_back(SourceParameters()); + const vector<SourceParameters>::reverse_iterator it = m_Parameters.rbegin(); + it->m_EnergyLow =blocks[i]->GetDouble("EnergyLow","MeV"); it->m_EnergyHigh =blocks[i]->GetDouble("EnergyHigh","MeV"); + if(blocks[i]->HasToken("EnergyDistribution")) + it->m_EnergyDistribution=blocks[i]->GetString("EnergyDistribution"); it->m_HalfOpenAngleMin =blocks[i]->GetDouble("HalfOpenAngleMin","deg"); it->m_HalfOpenAngleMax =blocks[i]->GetDouble("HalfOpenAngleMax","deg"); it->m_x0 =blocks[i]->GetDouble("x0","mm"); @@ -94,13 +98,12 @@ void EventGeneratorIsotropic::ReadConfiguration(NPL::InputParser parser){ else if(particleName[j]=="mu+") { it->m_particleName.push_back("mu+") ;} else if(particleName[j]=="mu-") { it->m_particleName.push_back("mu-") ;} else if(particleName[j]=="neutron") {it->m_particleName.push_back("neutron") ;} - else if(particleName[j]=="electron" || particleName[j]=="e-") {it->m_particleName.push_back("e-") ;} else it->m_particleName.push_back(particleName[j]); } if(blocks[i]->HasToken("ExcitationEnergy")) it->m_ExcitationEnergy =blocks[i]->GetVectorDouble("ExcitationEnergy","MeV"); - + if(blocks[i]->HasToken("SigmaX")) it->m_SigmaX=blocks[i]->GetDouble("SigmaX","mm"); if(blocks[i]->HasToken("SigmaY")) @@ -112,27 +115,35 @@ void EventGeneratorIsotropic::ReadConfiguration(NPL::InputParser parser){ cout << "ERROR: check your input file formatting \033[0m" << endl; exit(1); } - } - - for(auto& par : m_Parameters) { - if(par.m_ExcitationEnergy.size()==0) - par.m_ExcitationEnergy.resize(par.m_particleName.size(),0); - if(par.m_Multiplicty.size()==0) - par.m_Multiplicty.resize(par.m_particleName.size(),1); - } + } + for(auto& par : m_Parameters) { + if(par.m_ExcitationEnergy.size()==0) + par.m_ExcitationEnergy.resize(par.m_particleName.size(),0); + if(par.m_Multiplicty.size()==0) + par.m_Multiplicty.resize(par.m_particleName.size(),1); + + if(par.m_EnergyDistribution!="flat"){ + if(par.m_EnergyDistribution=="Watt"){ + fEnergyDist = new TF1("fWatt","0.4865*TMath::SinH(sqrt(2*x))*TMath::Exp(-x)",par.m_EnergyLow,par.m_EnergyHigh); + } + else{ + fEnergyDist = new TF1("fDist", par.m_EnergyDistribution, par.m_EnergyLow, par.m_EnergyHigh); + } + + } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void EventGeneratorIsotropic::GenerateEvent(G4Event*){ - for(auto& par : m_Parameters) { + for(auto& par : m_Parameters) { for(unsigned int p=0; p<par.m_particleName.size(); p++){ for(int i=0; i<par.m_Multiplicty[p]; i++){ par.m_particle=NULL; if(par.m_particle==NULL){ - if(par.m_particleName[p]=="gamma" || par.m_particleName[p]=="neutron" || par.m_particleName[p]=="opticalphoton" || par.m_particleName[p]=="mu+" - || par.m_particleName[p]=="mu-" || par.m_particleName[p]=="e-"){ + if(par.m_particleName[p]=="gamma" || par.m_particleName[p]=="neutron" || par.m_particleName[p]=="opticalphoton" || par.m_particleName[p]=="mu+" || par.m_particleName[p]=="mu-"){ par.m_particle = G4ParticleTable::GetParticleTable()->FindParticle(par.m_particleName[p].c_str()); } else{ @@ -148,9 +159,18 @@ void EventGeneratorIsotropic::GenerateEvent(G4Event*){ G4double cos_theta = cos_theta_min + (cos_theta_max - cos_theta_min) * RandFlat::shoot(); G4double theta = acos(cos_theta) ; G4double phi = RandFlat::shoot() * 2 * pi ; - G4double particle_energy = par.m_EnergyLow + RandFlat::shoot() * (par.m_EnergyHigh - par.m_EnergyLow) ; + G4double particle_energy; + if(par.m_EnergyDistribution=="flat"){ + particle_energy = par.m_EnergyLow + RandFlat::shoot() * (par.m_EnergyHigh - par.m_EnergyLow) ; event_ID++; - + } + else if(par.m_EnergyDistribution=="Watt"){ + particle_energy = fEnergyDist->GetRandom(); + } + else{ + particle_energy = fEnergyDist->GetRandom(); + } + // Direction of particle, energy and laboratory angle G4double momentum_x = sin(theta) * cos(phi) ; @@ -167,11 +187,11 @@ void EventGeneratorIsotropic::GenerateEvent(G4Event*){ } } } - + } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - void EventGeneratorIsotropic::InitializeRootOutput(){ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void EventGeneratorIsotropic::InitializeRootOutput(){ - } +} diff --git a/NPSimulation/EventGenerator/EventGeneratorIsotropic.hh b/NPSimulation/EventGenerator/EventGeneratorIsotropic.hh index c3e18be43be694fcac32223b72165e3897e9627f..b6c2db9a4a19ee7b83606fc8d9a342b59cae52d9 100644 --- a/NPSimulation/EventGenerator/EventGeneratorIsotropic.hh +++ b/NPSimulation/EventGenerator/EventGeneratorIsotropic.hh @@ -35,6 +35,11 @@ using namespace CLHEP; #include "VEventGenerator.hh" #include "ParticleStack.hh" #include "NPInputParser.h" + +// ROOT headers +#include "TString.h" +#include "TF1.h" + class EventGeneratorIsotropic : public NPS::VEventGenerator{ public: // Constructor and destructor EventGeneratorIsotropic() ; @@ -51,6 +56,7 @@ private: // Source parameter from input file SourceParameters() ; G4double m_EnergyLow ; // Lower limit of energy range G4double m_EnergyHigh ; // Upper limit of energy range + TString m_EnergyDistribution; G4double m_HalfOpenAngleMin ; // Min Half open angle of the source G4double m_HalfOpenAngleMax ; // Max Half open angle of the source G4double m_x0 ; // Vertex Position X @@ -65,6 +71,6 @@ private: // Source parameter from input file }; vector<SourceParameters> m_Parameters ; ParticleStack* m_ParticleStack ; - + TF1* fEnergyDist; }; #endif diff --git a/NPSimulation/Process/BeamReaction.cc b/NPSimulation/Process/BeamReaction.cc index 5a94c3020a0e63b004ac278a9c5469f4e5780139..bd5ca564c68bca9f1760d613b67e83c6514db5a5 100644 --- a/NPSimulation/Process/BeamReaction.cc +++ b/NPSimulation/Process/BeamReaction.cc @@ -38,6 +38,8 @@ NPS::BeamReaction::BeamReaction(G4String modelName, G4Region* envelope) ReadConfiguration(); m_PreviousEnergy = 0; m_PreviousLength = 0; + m_PreviousDirection.set(0,0,0); + m_shoot=false; } //////////////////////////////////////////////////////////////////////////////// @@ -58,25 +60,46 @@ void NPS::BeamReaction::AttachReactionConditions() { //////////////////////////////////////////////////////////////////////////////// void NPS::BeamReaction::ReadConfiguration() { NPL::InputParser input(NPOptionManager::getInstance()->GetReactionFile()); - m_Reaction.ReadConfigurationFile(input); - m_BeamName = NPL::ChangeNameToG4Standard(m_Reaction.GetNucleus1()->GetName()); - - if (m_Reaction.GetNucleus3()->GetName() != "") { - m_active = true; - m_ReactionConditions = new TReactionConditions(); - AttachReactionConditions(); - if (!RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) - RootOutput::getInstance()->GetTree()->Branch( - "ReactionConditions", "TReactionConditions", &m_ReactionConditions); - - } else { - m_active = false; + + //vector<NPL::InputBlock*> blocks; + //blocks = input.GetAllBlocksWithToken("TwoBodyReaction"); + //if(blocks.size()>0) m_ReactionType ="TwoBodyReaction"; + // + //blocks = input.GetAllBlocksWithToken("QFSReaction"); + //if(blocks.size()>0) m_ReactionType ="QFSReaction"; + + if(input.GetAllBlocksWithToken("TwoBodyReaction").size()>0) m_ReactionType ="TwoBodyReaction"; + if(input.GetAllBlocksWithToken("QFSReaction").size()>0) m_ReactionType ="QFSReaction"; + + + if (m_ReactionType=="TwoBodyReaction" ) { + m_Reaction.ReadConfigurationFile(input); + m_BeamName = NPL::ChangeNameToG4Standard(m_Reaction.GetNucleus1()->GetName()); + if(m_Reaction.GetNucleus3()->GetName() != ""){ + m_active = true; + m_ReactionConditions = new TReactionConditions(); + AttachReactionConditions(); + if (!RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) + RootOutput::getInstance()->GetTree()->Branch( + "ReactionConditions", "TReactionConditions", &m_ReactionConditions); + } + } else if (m_ReactionType=="QFSReaction") { + m_QFS.ReadConfigurationFile(input); + m_BeamName = NPL::ChangeNameToG4Standard(m_QFS.GetNucleusA()->GetName()); + m_active = true; + m_ReactionConditions = new TReactionConditions(); + AttachReactionConditions(); + if (!RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) + RootOutput::getInstance()->GetTree()->Branch( + "ReactionConditions", "TReactionConditions", &m_ReactionConditions); + } + else { + m_active = false; } } //////////////////////////////////////////////////////////////////////////////// -G4bool -NPS::BeamReaction::IsApplicable(const G4ParticleDefinition& particleType) { +G4bool NPS::BeamReaction::IsApplicable(const G4ParticleDefinition& particleType) { if (!m_active) return false; @@ -90,7 +113,8 @@ NPS::BeamReaction::IsApplicable(const G4ParticleDefinition& particleType) { //////////////////////////////////////////////////////////////////////////////// G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { - static bool shoot = false; + + //cout<< "--------- MODEL TRIG ---------"<<endl; static double rand = 0; const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack(); G4ThreeVector V = PrimaryTrack->GetMomentum().unit(); @@ -103,31 +127,40 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { double out = solid->DistanceToOut(P, -V); double ratio = in / (out + in); - // m_StepSize = m_StepSize/100000.; + m_Parent_ID = PrimaryTrack->GetParentID(); + // process reserved to the beam + if(m_Parent_ID!=0) + return false; - if (out == 0) { // first step of current event + if(!m_shoot){ rand = G4RandFlat::shoot(); m_PreviousLength = m_StepSize; m_PreviousEnergy = PrimaryTrack->GetKineticEnergy(); + m_PreviousDirection = PrimaryTrack->GetMomentumDirection(); + // Clear Previous Event m_ReactionConditions->Clear(); - shoot = true; + m_shoot=true; } - - else if (in == 0) { // last step + else if (((in-m_StepSize) <= 1E-20) && m_shoot) { // last step return true; } + // If the condition is met, the event is generated if (ratio < rand) { - // Reset the static for next event - // shoot = false; - if (shoot && m_Reaction.IsAllowed(PrimaryTrack->GetKineticEnergy())) { - shoot = false; - return true; - } else { - return false; + // Reset the static for next event + if(m_ReactionType=="QFSReaction"){ + if ( m_shoot && m_QFS.IsAllowed() ) { + return true; + } + } + + else if(m_ReactionType=="TwoBodyReaction"){ + if ( m_shoot && m_Reaction.IsAllowed(PrimaryTrack->GetKineticEnergy()) ) { + return true; + } } } @@ -136,6 +169,7 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { if (!PrimaryTrack->GetStep()->IsLastStepInVolume()) { m_PreviousLength = PrimaryTrack->GetStep()->GetStepLength(); m_PreviousEnergy = PrimaryTrack->GetKineticEnergy(); + m_PreviousDirection = PrimaryTrack->GetMomentumDirection(); } return false; @@ -143,207 +177,404 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { //////////////////////////////////////////////////////////////////////////////// void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, - G4FastStep& fastStep) { - - // Get the track info - const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack(); - G4ThreeVector pdirection = PrimaryTrack->GetMomentum().unit(); - G4ThreeVector localdir = fastTrack.GetPrimaryTrackLocalDirection(); - - G4ThreeVector worldPosition = PrimaryTrack->GetPosition(); - G4ThreeVector localPosition = fastTrack.GetPrimaryTrackLocalPosition(); - - double energy = PrimaryTrack->GetKineticEnergy(); - double time = PrimaryTrack->GetGlobalTime(); - - // Randomize within the step - // Assume energy loss is linear within the step - // Assume no scattering - double rand = G4RandFlat::shoot(); - double length = rand * (m_PreviousLength); - energy -= (1 - rand) * (m_PreviousEnergy - energy); - G4ThreeVector ldir = pdirection; - ldir *= length; - localPosition = localPosition - ldir; - // Set the end of the step conditions - fastStep.SetPrimaryTrackFinalKineticEnergyAndDirection(0, pdirection); - fastStep.SetPrimaryTrackFinalPosition(worldPosition); - fastStep.SetTotalEnergyDeposited(0); - fastStep.SetPrimaryTrackFinalTime(time); - fastStep.KillPrimaryTrack(); - fastStep.SetPrimaryTrackPathLength(0.0); - - ///////////////////////////////////////////////// - //////Define the kind of particle to shoot//////// - ////////////////////////////////////////////////// - - // Nucleus 3 - int LightZ = m_Reaction.GetNucleus3()->GetZ(); - int LightA = m_Reaction.GetNucleus3()->GetA(); - static G4IonTable* IonTable - = G4ParticleTable::GetParticleTable()->GetIonTable(); - - G4ParticleDefinition* LightName; - - if (LightZ == 0 && LightA == 1) // neutron is special case - { - LightName = G4Neutron::Definition(); - } else { - if (m_Reaction.GetUseExInGeant4()) - LightName - = IonTable->GetIon(LightZ, LightA, m_Reaction.GetExcitation3() * MeV); - else - LightName = IonTable->GetIon(LightZ, LightA); - } - - // Nucleus 4 - G4int HeavyZ = m_Reaction.GetNucleus4()->GetZ(); - G4int HeavyA = m_Reaction.GetNucleus4()->GetA(); - - // Generate the excitation energy if a distribution is given - m_Reaction.ShootRandomExcitationEnergy(); - - // Use to clean up the IonTable in case of the Ex changing at every event - G4ParticleDefinition* HeavyName; - - if (m_Reaction.GetUseExInGeant4()) - HeavyName - = IonTable->GetIon(HeavyZ, HeavyA, m_Reaction.GetExcitation4() * MeV); - else - HeavyName = IonTable->GetIon(HeavyZ, HeavyA); - - // Set the Energy of the reaction - m_Reaction.SetBeamEnergy(energy); - - double Beam_theta = pdirection.theta(); - double Beam_phi = pdirection.phi(); - - /////////////////////////// - ///// Beam Parameters ///// - /////////////////////////// - m_ReactionConditions->SetBeamParticleName( - PrimaryTrack->GetParticleDefinition()->GetParticleName()); - - m_ReactionConditions->SetBeamReactionEnergy(energy); - m_ReactionConditions->SetVertexPositionX(localPosition.x()); - m_ReactionConditions->SetVertexPositionY(localPosition.y()); - m_ReactionConditions->SetVertexPositionZ(localPosition.z()); - - G4ThreeVector U(1, 0, 0); - G4ThreeVector V(0, 1, 0); - G4ThreeVector ZZ(0, 0, 1); - m_ReactionConditions->SetBeamEmittanceTheta( - PrimaryTrack->GetMomentumDirection().theta() / deg); - m_ReactionConditions->SetBeamEmittancePhi( - PrimaryTrack->GetMomentumDirection().phi() / deg); - m_ReactionConditions->SetBeamEmittanceThetaX( - PrimaryTrack->GetMomentumDirection().angle(U) / deg); - m_ReactionConditions->SetBeamEmittancePhiY( - PrimaryTrack->GetMomentumDirection().angle(V) / deg); + G4FastStep& fastStep) { + + m_shoot=false; + + // Get the track info + const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack(); + G4ThreeVector pdirection = PrimaryTrack->GetMomentum().unit(); + G4ThreeVector localdir = fastTrack.GetPrimaryTrackLocalDirection(); + + G4ThreeVector worldPosition = PrimaryTrack->GetPosition(); + G4ThreeVector localPosition = fastTrack.GetPrimaryTrackLocalPosition(); + + double energy = PrimaryTrack->GetKineticEnergy(); + double time = PrimaryTrack->GetGlobalTime(); + + // Randomize vertex and energy within the step + // convention: go backward from end point in the step to vertex + // Assume energy loss is linear within the step + // rand = 0 beginning of step + // rand = 1 end of step + // Assume no scattering + double rand = G4RandFlat::shoot(); + double length = (1-rand) * (m_PreviousLength); + double reac_energy = energy + (1-rand) * (m_PreviousEnergy - energy); + G4ThreeVector ldir = m_PreviousDirection; + ldir *= length; + localPosition = localPosition - ldir; + + // Set the end of the step conditions + fastStep.SetPrimaryTrackFinalKineticEnergyAndDirection(0, pdirection); + fastStep.SetPrimaryTrackFinalPosition(worldPosition); + fastStep.SetTotalEnergyDeposited(0); + fastStep.SetPrimaryTrackFinalTime(time); + fastStep.KillPrimaryTrack(); + fastStep.SetPrimaryTrackPathLength(0.0); + + + if (m_ReactionType=="TwoBodyReaction" ) { + + /////////////////////////////// + // Two-Body Reaction Case ///// + /////////////////////////////// + + //////Define the kind of particle to shoot//////// + // Nucleus 3 + int LightZ = m_Reaction.GetNucleus3()->GetZ(); + int LightA = m_Reaction.GetNucleus3()->GetA(); + static G4IonTable* IonTable + = G4ParticleTable::GetParticleTable()->GetIonTable(); + + G4ParticleDefinition* LightName; + + if (LightZ == 0 && LightA == 1) // neutron is special case + { + LightName = G4Neutron::Definition(); + } else { + if (m_Reaction.GetUseExInGeant4()) + LightName + = IonTable->GetIon(LightZ, LightA, m_Reaction.GetExcitation3() * MeV); + else + LightName = IonTable->GetIon(LightZ, LightA); + } + + // Nucleus 4 + G4int HeavyZ = m_Reaction.GetNucleus4()->GetZ(); + G4int HeavyA = m_Reaction.GetNucleus4()->GetA(); + + // Generate the excitation energy if a distribution is given + m_Reaction.ShootRandomExcitationEnergy(); + + // Use to clean up the IonTable in case of the Ex changing at every event + G4ParticleDefinition* HeavyName; + + if (m_Reaction.GetUseExInGeant4()) + HeavyName + = IonTable->GetIon(HeavyZ, HeavyA, m_Reaction.GetExcitation4() * MeV); + else + HeavyName = IonTable->GetIon(HeavyZ, HeavyA); + + // Set the Energy of the reaction + m_Reaction.SetBeamEnergy(reac_energy); + + double Beam_theta = pdirection.theta(); + double Beam_phi = pdirection.phi(); + + /////////////////////////// + ///// Beam Parameters ///// + /////////////////////////// + m_ReactionConditions->SetBeamParticleName( + PrimaryTrack->GetParticleDefinition()->GetParticleName()); + + m_ReactionConditions->SetBeamReactionEnergy(reac_energy); + m_ReactionConditions->SetVertexPositionX(localPosition.x()); + m_ReactionConditions->SetVertexPositionY(localPosition.y()); + m_ReactionConditions->SetVertexPositionZ(localPosition.z()); + + G4ThreeVector U(1, 0, 0); + G4ThreeVector V(0, 1, 0); + G4ThreeVector ZZ(0, 0, 1); + m_ReactionConditions->SetBeamEmittanceTheta( + PrimaryTrack->GetMomentumDirection().theta() / deg); + m_ReactionConditions->SetBeamEmittancePhi( + PrimaryTrack->GetMomentumDirection().phi() / deg); + m_ReactionConditions->SetBeamEmittanceThetaX( + PrimaryTrack->GetMomentumDirection().angle(U) / deg); + m_ReactionConditions->SetBeamEmittancePhiY( + PrimaryTrack->GetMomentumDirection().angle(V) / deg); + + ////////////////////////////////////////////////////////// + ///// Build rotation matrix to go from the incident ////// + ///// beam frame to the "world" frame ////// + ////////////////////////////////////////////////////////// + + + // G4ThreeVector col1(cos(Beam_theta) * cos(Beam_phi), + // cos(Beam_theta) * sin(Beam_phi), + // -sin(Beam_theta)); + // G4ThreeVector col2(-sin(Beam_phi), + // cos(Beam_phi), + // 0); + // G4ThreeVector col3(sin(Beam_theta) * cos(Beam_phi), + // sin(Beam_theta) * sin(Beam_phi), + // cos(Beam_theta)); + // G4RotationMatrix BeamToWorld(col1, col2, col3); + + ///////////////////////////////////////////////////////////////// + ///// Angles for emitted particles following Cross Section ////// + ///// Angles are in the beam frame ////// + ///////////////////////////////////////////////////////////////// + + // Angles + // Shoot and Set a Random ThetaCM + m_Reaction.ShootRandomThetaCM(); + double phi = G4RandFlat::shoot() * 2. * pi; + + ////////////////////////////////////////////////// + ///// Momentum and angles from kinematics ///// + ///// Angles are in the beam frame ///// + ////////////////////////////////////////////////// + // Variable where to store results + double Theta3, Energy3, Theta4, Energy4; + + // Compute Kinematic using previously defined ThetaCM + m_Reaction.KineRelativistic(Theta3, Energy3, Theta4, Energy4); + // Momentum in beam frame for light particle + G4ThreeVector momentum_kine3_beam(sin(Theta3) * cos(phi), + sin(Theta3) * sin(phi), cos(Theta3)); + // Momentum in World frame //to go from the incident beam frame to the "world" + // frame + G4ThreeVector momentum_kine3_world = momentum_kine3_beam; + momentum_kine3_world.rotate(Beam_theta, + V); // rotation of Beam_theta on Y axis + momentum_kine3_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis + + // Momentum in beam frame for heavy particle + G4ThreeVector momentum_kine4_beam(sin(Theta4) * cos(phi + pi), + sin(Theta4) * sin(phi + pi), cos(Theta4)); + // Momentum in World frame + G4ThreeVector momentum_kine4_world = momentum_kine4_beam; + momentum_kine4_world.rotate(Beam_theta, + V); // rotation of Beam_theta on Y axis + momentum_kine4_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis + + // Emitt secondary + if (m_Reaction.GetShoot3()) { + G4DynamicParticle particle3(LightName, momentum_kine3_world, Energy3); + fastStep.CreateSecondaryTrack(particle3, localPosition, time); + } + + if (m_Reaction.GetShoot4()) { + G4DynamicParticle particle4(HeavyName, momentum_kine4_world, Energy4); + fastStep.CreateSecondaryTrack(particle4, localPosition, time); + } + + // Reinit for next event + m_PreviousEnergy = 0; + m_PreviousLength = 0; + m_PreviousDirection.set(0,0,0); + + /////////////////////////////////////// + ///// Emitted particle Parameters ///// + /////////////////////////////////////// + // Names 3 and 4// + m_ReactionConditions->SetParticleName(LightName->GetParticleName()); + m_ReactionConditions->SetParticleName(HeavyName->GetParticleName()); + // Angle 3 and 4 // + m_ReactionConditions->SetTheta(Theta3 / deg); + m_ReactionConditions->SetTheta(Theta4 / deg); + + m_ReactionConditions->SetPhi(phi / deg); + if ((phi + pi) / deg > 360) + m_ReactionConditions->SetPhi((phi - pi) / deg); + else + m_ReactionConditions->SetPhi((phi + pi) / deg); + + // Energy 3 and 4 // + m_ReactionConditions->SetKineticEnergy(Energy3); + m_ReactionConditions->SetKineticEnergy(Energy4); + // ThetaCM and Ex// + m_ReactionConditions->SetThetaCM(m_Reaction.GetThetaCM() / deg); + m_ReactionConditions->SetExcitationEnergy3(m_Reaction.GetExcitation3()); + m_ReactionConditions->SetExcitationEnergy4(m_Reaction.GetExcitation4()); + // Momuntum X 3 and 4 // + m_ReactionConditions->SetMomentumDirectionX(momentum_kine3_world.x()); + m_ReactionConditions->SetMomentumDirectionX(momentum_kine4_world.x()); + // Momuntum Y 3 and 4 // + m_ReactionConditions->SetMomentumDirectionY(momentum_kine3_world.y()); + m_ReactionConditions->SetMomentumDirectionY(momentum_kine4_world.y()); + // Momuntum Z 3 and 4 // + m_ReactionConditions->SetMomentumDirectionZ(momentum_kine3_world.z()); + m_ReactionConditions->SetMomentumDirectionZ(momentum_kine4_world.z()); + + }// end if TwoBodyReaction + + else if (m_ReactionType=="QFSReaction" ) { + + //////Define the kind of particle to shoot//////// + // A --> T ==> B + (c -> T) => B + 1 + 2 + + int Light1_Z = m_QFS.GetNucleus1()->GetZ(); + int Light1_A = m_QFS.GetNucleus1()->GetA(); + int Light2_Z = m_QFS.GetNucleus2()->GetZ(); + int Light2_A = m_QFS.GetNucleus2()->GetA(); + + static G4IonTable* IonTable + = G4ParticleTable::GetParticleTable()->GetIonTable(); + + G4ParticleDefinition* Light1Name; + G4ParticleDefinition* Light2Name; + + if (Light1_Z == 0 && Light1_A == 1) // neutron is special case + { + Light1Name = G4Neutron::Definition(); + } else { + Light1Name = IonTable->GetIon(Light1_Z, Light1_A); + } + + if (Light2_Z == 0 && Light2_A == 1) // neutron is special case + { + Light2Name = G4Neutron::Definition(); + } else { + Light2Name = IonTable->GetIon(Light2_Z, Light2_A); + } + + // Nucleus B + G4int Heavy_Z = m_QFS.GetNucleusB()->GetZ(); + G4int Heavy_A = m_QFS.GetNucleusB()->GetA(); + + G4ParticleDefinition* HeavyName; + HeavyName = IonTable->GetIon(Heavy_Z, Heavy_A); + + // Set the Energy of the reaction + m_QFS.SetBeamEnergy(reac_energy); + + double Beam_theta = pdirection.theta(); + double Beam_phi = pdirection.phi(); + + + ///////////////////////////////////////////////////////////////// + ///// Angles for emitted particles following Cross Section ////// + ///// Angles are in the beam frame ////// + ///////////////////////////////////////////////////////////////// + + // Shoot and Set a Random ThetaCM + double theta = G4RandFlat::shoot() * pi; + double phi = G4RandFlat::shoot() * 2. * pi - pi; //rand in [-pi,pi] + m_QFS.SetThetaCM(theta); + m_QFS.SetPhiCM(phi); + + // Shoot and set internal momentum for the removed cluster + // if a momentum Sigma is given then shoot in 3 indep. Gaussians + // if input files are given for distributions use them instead + m_QFS.ShootInternalMomentum(); + + ////////////////////////////////////////////////// + ///// Momentum and angles from kinematics ///// + ////////////////////////////////////////////////// + // Variable where to store results + double Theta1, Phi1, TKE1, Theta2, Phi2, TKE2, ThetaB, PhiB, TKEB; + + // Compute Kinematic using previously defined ThetaCM + m_QFS.KineRelativistic(Theta1, Phi1, TKE1, Theta2, Phi2, TKE2); + + G4ThreeVector U(1, 0, 0); + G4ThreeVector V(0, 1, 0); + G4ThreeVector ZZ(0, 0, 1); + + // Momentum in beam and world frame for light particle 1 + G4ThreeVector momentum_kine1_beam(sin(Theta1) * cos(Phi1), + sin(Theta1) * sin(Phi1), cos(Theta1)); + G4ThreeVector momentum_kine1_world = momentum_kine1_beam; + momentum_kine1_world.rotate(Beam_theta, V); // rotation of Beam_theta on Y axis + momentum_kine1_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis + + // Momentum in beam and world frame for light particle 2 + G4ThreeVector momentum_kine2_beam(sin(Theta2) * cos(Phi2), + sin(Theta2) * sin(Phi2), cos(Theta2)); + G4ThreeVector momentum_kine2_world = momentum_kine2_beam; + momentum_kine2_world.rotate(Beam_theta, V); // rotation of Beam_theta on Y axis + momentum_kine2_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis + + // Momentum in beam and world frame for heavy residual + // + //G4ThreeVector momentum_kineB_beam(sin(ThetaB) * cos(PhiB + pi), + // sin(ThetaB) * sin(PhiB + pi), cos(ThetaB)); + //G4ThreeVector momentum_kineB_world = momentum_kineB_beam; + //momentum_kineB_world.rotate(Beam_theta, V); // rotation of Beam_theta on Y axis + //momentum_kineB_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis + + TLorentzVector* P_A = m_QFS.GetEnergyImpulsionLab_A(); + TLorentzVector* P_B = m_QFS.GetEnergyImpulsionLab_B(); + + G4ThreeVector momentum_kineB_beam( P_B->Px(), P_B->Py(), P_B->Pz() ); + momentum_kineB_beam = momentum_kineB_beam.unit(); + TKEB = m_QFS.GetEnergyImpulsionLab_B()->Energy() - m_QFS.GetNucleusB()->Mass(); + G4ThreeVector momentum_kineB_world = momentum_kineB_beam; + momentum_kineB_world.rotate(Beam_theta, V); // rotation of Beam_theta on Y axis + momentum_kineB_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis + + ThetaB = P_B->Angle(P_A->Vect()); + if (ThetaB < 0) ThetaB += M_PI; + PhiB = M_PI + P_B->Vect().Phi(); + if (fabs(PhiB) < 1e-6) PhiB = 0; - ////////////////////////////////////////////////////////// - ///// Build rotation matrix to go from the incident ////// - ///// beam frame to the "world" frame ////// - ////////////////////////////////////////////////////////// - - /* - - G4ThreeVector col1(cos(Beam_theta) * cos(Beam_phi), - cos(Beam_theta) * sin(Beam_phi), - -sin(Beam_theta)); - G4ThreeVector col2(-sin(Beam_phi), - cos(Beam_phi), - 0); - G4ThreeVector col3(sin(Beam_theta) * cos(Beam_phi), - sin(Beam_theta) * sin(Beam_phi), - cos(Beam_theta)); - G4RotationMatrix BeamToWorld(col1, col2, col3); - - */ - - ///////////////////////////////////////////////////////////////// - ///// Angles for emitted particles following Cross Section ////// - ///// Angles are in the beam frame ////// - ///////////////////////////////////////////////////////////////// - - // Angles - // Shoot and Set a Random ThetaCM - m_Reaction.ShootRandomThetaCM(); - double phi = RandFlat::shoot() * 2. * pi; - - ////////////////////////////////////////////////// - ///// Momentum and angles from kinematics ///// - ///// Angles are in the beam frame ///// - ////////////////////////////////////////////////// - // Variable where to store results - double Theta3, Energy3, Theta4, Energy4; - - // Compute Kinematic using previously defined ThetaCM - m_Reaction.KineRelativistic(Theta3, Energy3, Theta4, Energy4); - // Momentum in beam frame for light particle - G4ThreeVector momentum_kine3_beam(sin(Theta3) * cos(phi), - sin(Theta3) * sin(phi), cos(Theta3)); - // Momentum in World frame //to go from the incident beam frame to the "world" - // frame - G4ThreeVector momentum_kine3_world = /*BeamToWorld */ momentum_kine3_beam; - momentum_kine3_world.rotate(Beam_theta, - V); // rotation of Beam_theta on Y axis - momentum_kine3_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis - - // Momentum in beam frame for heavy particle - G4ThreeVector momentum_kine4_beam(sin(Theta4) * cos(phi + pi), - sin(Theta4) * sin(phi + pi), cos(Theta4)); - // Momentum in World frame - G4ThreeVector momentum_kine4_world = /*BeamToWorld */ momentum_kine4_beam; - momentum_kine4_world.rotate(Beam_theta, - V); // rotation of Beam_theta on Y axis - momentum_kine4_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis - - // Emitt secondary - if (m_Reaction.GetShoot3()) { - G4DynamicParticle particle3(LightName, momentum_kine3_world, Energy3); - fastStep.CreateSecondaryTrack(particle3, localPosition, time); - } + + // Emitt secondary + if (m_QFS.GetShoot1()) { + G4DynamicParticle particle1(Light1Name, momentum_kine1_world, TKE1); + fastStep.CreateSecondaryTrack(particle1, localPosition, time); + } + + if (m_QFS.GetShoot2()) { + G4DynamicParticle particle2(Light2Name, momentum_kine2_world, TKE2); + fastStep.CreateSecondaryTrack(particle2, localPosition, time); + } + if (m_QFS.GetShootB()) { + G4DynamicParticle particleB(HeavyName, momentum_kineB_world, TKEB); + fastStep.CreateSecondaryTrack(particleB, localPosition, time); + } + + // Reinit for next event + m_PreviousEnergy = 0; + m_PreviousLength = 0; + m_PreviousDirection.set(0,0,0); + + + /////////////////////////////////// + ///// Reaction Condition Save ///// + /////////////////////////////////// + m_ReactionConditions->SetBeamParticleName( + PrimaryTrack->GetParticleDefinition()->GetParticleName()); + m_ReactionConditions->SetBeamReactionEnergy(reac_energy); + m_ReactionConditions->SetVertexPositionX(localPosition.x()); + m_ReactionConditions->SetVertexPositionY(localPosition.y()); + m_ReactionConditions->SetVertexPositionZ(localPosition.z()); + m_ReactionConditions->SetBeamEmittanceTheta( + PrimaryTrack->GetMomentumDirection().theta() / deg); + m_ReactionConditions->SetBeamEmittancePhi( + PrimaryTrack->GetMomentumDirection().phi() / deg); + m_ReactionConditions->SetBeamEmittanceThetaX( + PrimaryTrack->GetMomentumDirection().angle(U) / deg); + m_ReactionConditions->SetBeamEmittancePhiY( + PrimaryTrack->GetMomentumDirection().angle(V) / deg); + + // Names 1,2 and B// + m_ReactionConditions->SetParticleName(Light1Name->GetParticleName()); + m_ReactionConditions->SetParticleName(Light2Name->GetParticleName()); + m_ReactionConditions->SetParticleName(HeavyName->GetParticleName()); + // Angle 1,2 and B // + m_ReactionConditions->SetTheta(Theta1 / deg); + m_ReactionConditions->SetTheta(Theta2 / deg); + m_ReactionConditions->SetTheta(ThetaB / deg); + m_ReactionConditions->SetPhi(Phi1 / deg); + m_ReactionConditions->SetPhi(Phi2 / deg); + m_ReactionConditions->SetPhi(PhiB / deg); + // Energy 1,2 and B // + m_ReactionConditions->SetKineticEnergy(TKE1); + m_ReactionConditions->SetKineticEnergy(TKE2); + m_ReactionConditions->SetKineticEnergy(TKEB); + // ThetaCM, Ex and Internal Momentum of removed cluster// + m_ReactionConditions->SetThetaCM(m_QFS.GetThetaCM() / deg); + m_ReactionConditions->SetInternalMomentum(m_QFS.GetInternalMomentum()); + //m_ReactionConditions->SetExcitationEnergy3(m_QFS.GetExcitation3()); + //m_ReactionConditions->SetExcitationEnergy4(m_QFS.GetExcitation4()); + // Momuntum X 3 and 4 // + m_ReactionConditions->SetMomentumDirectionX(momentum_kine1_world.x()); + m_ReactionConditions->SetMomentumDirectionX(momentum_kine2_world.x()); + m_ReactionConditions->SetMomentumDirectionX(momentum_kineB_world.x()); + // Momuntum Y 3 and 4 // + m_ReactionConditions->SetMomentumDirectionY(momentum_kine1_world.y()); + m_ReactionConditions->SetMomentumDirectionY(momentum_kine2_world.y()); + m_ReactionConditions->SetMomentumDirectionY(momentum_kineB_world.y()); + // Momuntum Z 3 and 4 // + m_ReactionConditions->SetMomentumDirectionZ(momentum_kine1_world.z()); + m_ReactionConditions->SetMomentumDirectionZ(momentum_kine2_world.z()); + m_ReactionConditions->SetMomentumDirectionZ(momentum_kineB_world.z()); - if (m_Reaction.GetShoot4()) { - G4DynamicParticle particle4(HeavyName, momentum_kine4_world, Energy4); - fastStep.CreateSecondaryTrack(particle4, localPosition, time); - } - // Reinit for next event - m_PreviousEnergy = 0; - m_PreviousLength = 0; - /////////////////////////////////////// - ///// Emitted particle Parameters ///// - /////////////////////////////////////// - // Names 3 and 4// - m_ReactionConditions->SetParticleName(LightName->GetParticleName()); - m_ReactionConditions->SetParticleName(HeavyName->GetParticleName()); - // Angle 3 and 4 // - m_ReactionConditions->SetTheta(Theta3 / deg); - m_ReactionConditions->SetTheta(Theta4 / deg); - - m_ReactionConditions->SetPhi(phi / deg); - if ((phi + pi) / deg > 360) - m_ReactionConditions->SetPhi((phi - pi) / deg); - else - m_ReactionConditions->SetPhi((phi + pi) / deg); - - // Energy 3 and 4 // - m_ReactionConditions->SetKineticEnergy(Energy3); - m_ReactionConditions->SetKineticEnergy(Energy4); - // ThetaCM and Ex// - m_ReactionConditions->SetThetaCM(m_Reaction.GetThetaCM() / deg); - m_ReactionConditions->SetExcitationEnergy3(m_Reaction.GetExcitation3()); - m_ReactionConditions->SetExcitationEnergy4(m_Reaction.GetExcitation4()); - // Momuntum X 3 and 4 // - m_ReactionConditions->SetMomentumDirectionX(momentum_kine3_world.x()); - m_ReactionConditions->SetMomentumDirectionX(momentum_kine4_world.x()); - // Momuntum Y 3 and 4 // - m_ReactionConditions->SetMomentumDirectionY(momentum_kine3_world.y()); - m_ReactionConditions->SetMomentumDirectionY(momentum_kine4_world.y()); - // Momuntum Z 3 and 4 // - m_ReactionConditions->SetMomentumDirectionZ(momentum_kine3_world.z()); - m_ReactionConditions->SetMomentumDirectionZ(momentum_kine4_world.z()); + } } diff --git a/NPSimulation/Process/BeamReaction.hh b/NPSimulation/Process/BeamReaction.hh index cb81602f18eb28cde9f4fcbd6af5d146f307e288..7f1f519eeac54bb0102f70d5e235e4b863f84c78 100644 --- a/NPSimulation/Process/BeamReaction.hh +++ b/NPSimulation/Process/BeamReaction.hh @@ -27,6 +27,7 @@ #include "G4VFastSimulationModel.hh" #include "PhysicsList.hh" #include "NPReaction.h" +#include "NPQFS.h" #include "TReactionConditions.h" class G4VPhysicalVolume; namespace NPS{ @@ -44,11 +45,16 @@ namespace NPS{ private: NPL::Reaction m_Reaction; + NPL::QFS m_QFS; string m_BeamName; + string m_ReactionType; double m_PreviousEnergy; double m_PreviousLength; + G4ThreeVector m_PreviousDirection; bool m_active;// is the process active + bool m_shoot; double m_StepSize; + int m_Parent_ID; private: TReactionConditions* m_ReactionConditions; diff --git a/NPSimulation/Process/CMakeLists.txt b/NPSimulation/Process/CMakeLists.txt index acf8bfe4882ae3352708ba311257e88bbb51de8d..2f9dfe901fb7b2f43bba7fa149cd3c290fc15f4d 100644 --- a/NPSimulation/Process/CMakeLists.txt +++ b/NPSimulation/Process/CMakeLists.txt @@ -1,2 +1,16 @@ + +if(Geant4_VERSION_MAJOR GREATER_EQUAL 10) + if(Geant4_VERSION_MINOR GREATER_EQUAL 5) + + message("Compiling with NeutronHPphysics") +add_library(NPSProcess SHARED Decay.cc BeamReaction.cc FastDriftElectron.cc NPIonIonInelasticPhysic.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc NeutronHPphysics.cc NeutronHPMessenger.cc) + add_definitions(-DUSE_NEUTRONHP) + else () + + message("Compiling WITHOUT NeutronHPphysics, install geant4 10.5 or greater for this physics list") add_library(NPSProcess SHARED Decay.cc BeamReaction.cc FastDriftElectron.cc NPIonIonInelasticPhysic.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc) + endif() + endif() + + target_link_libraries(NPSProcess ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPInitialConditions -lNPInteractionCoordinates -lNPReactionConditions) diff --git a/NPSimulation/Process/Decay.cc b/NPSimulation/Process/Decay.cc index 442d98b6819d69154e36a921163f64e6dd17ff8a..30c82cdd4cfc5a142ba3456f28abc6608a4567b1 100644 --- a/NPSimulation/Process/Decay.cc +++ b/NPSimulation/Process/Decay.cc @@ -61,8 +61,12 @@ void Decay::ReadConfiguration(){ m_Decay.ReadConfiguration(input); std::set<std::string> Mother = m_Decay.GetAllMotherName(); std::set<std::string>::iterator it ; - for(it = Mother.begin() ; it != Mother.end() ; it++) + for(it = Mother.begin() ; it != Mother.end() ; it++){ + // ground state name, e.g. deuteron m_MotherName.insert(NPL::ChangeNameToG4Standard(*it)); + // excited state name e.g. H2 + m_MotherName.insert(NPL::ChangeNameToG4Standard(*it,true)); + } } //////////////////////////////////////////////////////////////////////////////// @@ -130,6 +134,7 @@ void Decay::DoIt(const G4FastTrack& fastTrack,G4FastStep& fastStep){ G4ParticleDefinition* DaughterDef; unsigned int size = Daughter.size(); + if(size == 0) return; for(unsigned int i = 0 ; i < size ; i++){ diff --git a/NPSimulation/Process/NPIonIonInelasticPhysic.cc b/NPSimulation/Process/NPIonIonInelasticPhysic.cc index 3aaddd6206c910eff79ada760d2ce8175cdc66f8..31f96dfce4f6fcee5195e0efe6daa194d85969d3 100755 --- a/NPSimulation/Process/NPIonIonInelasticPhysic.cc +++ b/NPSimulation/Process/NPIonIonInelasticPhysic.cc @@ -164,7 +164,7 @@ void NPIonIonInelasticPhysic::ConstructProcess() G4DynamicParticle* dp = new G4DynamicParticle(particle,G4ThreeVector(0,0,1),energy*MeV); //G4Element* element = new G4Element("Sn","Sn",1); - //G4Isotope *isotope = new G4Isotope("Sn",50,70,120*g/mole); + //G4Isotope *isotope = new G4Isotope("Sn",50,70,120*g/mole); //element->AddIsotope(isotope,1); // Glauber-Gribov //cout << energy << " " << GlauberGribovCrossSection->GetInelasticIsotopeCrossSection(particle,energy*MeV,Z,A)/barn << endl; diff --git a/NPSimulation/Process/NeutronHPMessenger.cc b/NPSimulation/Process/NeutronHPMessenger.cc new file mode 100644 index 0000000000000000000000000000000000000000..89fe3646d0662bad2dbf75340207e910384c63ea --- /dev/null +++ b/NPSimulation/Process/NeutronHPMessenger.cc @@ -0,0 +1,71 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file NeutronHPMessenger.cc +/// \brief Implementation of the NeutronHPMessenger class +// +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "NeutronHPMessenger.hh" + +#include "NeutronHPphysics.hh" + +#include "G4UIdirectory.hh" +#include "G4UIcmdWithABool.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPMessenger::NeutronHPMessenger(NeutronHPphysics* phys) +:G4UImessenger(),fNeutronPhysics(phys), + fPhysDir(0), fThermalCmd(0) +{ + fPhysDir = new G4UIdirectory("/testhadr/phys/"); + fPhysDir->SetGuidance("physics list commands"); + + fThermalCmd = new G4UIcmdWithABool("/testhadr/phys/thermalScattering",this); + fThermalCmd->SetGuidance("set thermal scattering model"); + fThermalCmd->SetParameterName("thermal",false); + fThermalCmd->AvailableForStates(G4State_PreInit); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPMessenger::~NeutronHPMessenger() +{ + delete fThermalCmd; + delete fPhysDir; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void NeutronHPMessenger::SetNewValue(G4UIcommand* command, G4String newValue) +{ + if (command == fThermalCmd) + {fNeutronPhysics->SetThermalPhysics(fThermalCmd->GetNewBoolValue(newValue));} +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Process/NeutronHPMessenger.hh b/NPSimulation/Process/NeutronHPMessenger.hh new file mode 100644 index 0000000000000000000000000000000000000000..8577c39f7843b6a965179c89e0b2ac2b9308d380 --- /dev/null +++ b/NPSimulation/Process/NeutronHPMessenger.hh @@ -0,0 +1,62 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file NeutronHPMessenger.hh +/// \brief Definition of the NeutronHPMessenger class +// +// +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef NeutronHPMessenger_h +#define NeutronHPMessenger_h 1 + +#include "globals.hh" +#include "G4UImessenger.hh" + +class NeutronHPphysics; +class G4UIdirectory; +class G4UIcmdWithABool; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class NeutronHPMessenger: public G4UImessenger +{ + public: + NeutronHPMessenger(NeutronHPphysics*); + ~NeutronHPMessenger(); + + virtual void SetNewValue(G4UIcommand*, G4String); + + private: + NeutronHPphysics* fNeutronPhysics; + + G4UIdirectory* fPhysDir; + G4UIcmdWithABool* fThermalCmd; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif diff --git a/NPSimulation/Process/NeutronHPphysics.cc b/NPSimulation/Process/NeutronHPphysics.cc new file mode 100644 index 0000000000000000000000000000000000000000..91f61a45eaaa34f187540bcb647b25f6effb138e --- /dev/null +++ b/NPSimulation/Process/NeutronHPphysics.cc @@ -0,0 +1,210 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file NeutronHPphysics.cc +/// \brief Implementation of the NeutronHPphysics class +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "NeutronHPphysics.hh" + +#include "NeutronHPMessenger.hh" + +#include "G4ParticleDefinition.hh" +#include "G4ProcessManager.hh" +#include "G4ProcessTable.hh" + +// Processes + +#include "G4HadronElasticProcess.hh" +#include "G4ParticleHPElasticData.hh" +#include "G4ParticleHPThermalScatteringData.hh" +#include "G4ParticleHPElastic.hh" +#include "G4ParticleHPThermalScattering.hh" + +#include "G4NeutronInelasticProcess.hh" +#include "G4ParticleHPInelasticData.hh" +#include "G4ParticleHPInelastic.hh" + +#include "G4HadronCaptureProcess.hh" +#include "G4ParticleHPCaptureData.hh" +#include "G4ParticleHPCapture.hh" + +#include "G4HadronFissionProcess.hh" +#include "G4ParticleHPFissionData.hh" +#include "G4ParticleHPFission.hh" + +#include "G4SystemOfUnits.hh" + +#include "G4DynamicParticle.hh" +#include "G4Element.hh" +#include "G4Material.hh" +#include "G4Isotope.hh" +#include "G4HadronicProcessStore.hh" +#include "G4NistManager.hh" + +using namespace std; +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPphysics::NeutronHPphysics(const G4String& name) + : G4VPhysicsConstructor(name), fThermal(true), fNeutronMessenger(0) +{ + fNeutronMessenger = new NeutronHPMessenger(this); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +NeutronHPphysics::~NeutronHPphysics() +{ + delete fNeutronMessenger; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void NeutronHPphysics::ConstructProcess() +{ + G4ParticleDefinition* neutron = G4Neutron::Neutron(); + G4ProcessManager* pManager = neutron->GetProcessManager(); + + // delete all neutron processes if already registered + // + G4VProcess* process = 0; + process = pManager->GetProcess("hadElastic"); + if (process) pManager->RemoveProcess(process); + // + process = pManager->GetProcess("neutronInelastic"); + if (process) pManager->RemoveProcess(process); + // + process = pManager->GetProcess("nCapture"); + if (process) pManager->RemoveProcess(process); + // + process = pManager->GetProcess("nFission"); + if (process) pManager->RemoveProcess(process); + + // (re) create process: elastic + // + G4HadronElasticProcess* process1 = new G4HadronElasticProcess(); + pManager->AddDiscreteProcess(process1); + // + // model1a + G4ParticleHPElastic* model1a = new G4ParticleHPElastic(); + process1->RegisterMe(model1a); + process1->AddDataSet(new G4ParticleHPElasticData()); + + //--- test ---// + /* G4ParticleHPElasticData* dataSet1 = new G4ParticleHPElasticData(); + dataSet1->BuildPhysicsTable(*G4Neutron::Neutron()); + dataSet1->DumpPhysicsTable(*G4Neutron::Neutron()); + + G4ParticleDefinition* particle; + particle = G4Neutron::Neutron(); + G4Element* element = new G4Element("C","C",1); + G4Isotope* isotope = new G4Isotope("C",6,12); + element->AddIsotope(isotope,1); + G4Material* mat = new G4Material("C",2.26*g/cm3,1); + mat->AddElement(element,1); + + for(int i=0; i<20; i++){ + double energy = (1+i)*MeV; + G4DynamicParticle *dn = new G4DynamicParticle(particle,G4ThreeVector(0,0,1), energy); + cout << "--- " << energy << " is ok? ---" << endl; + cout << dn->GetKineticEnergy() << endl; + cout << dn->GetMomentum() << endl; + cout << dataSet1->IsIsoApplicable(dn, 6, 12, element, mat) << endl; + + //cout << dataSet1->GetCrossSection(dn,element,273) << endl; + } +*/ + + // + // model1b + if (fThermal) { + model1a->SetMinEnergy(4*eV); + G4ParticleHPThermalScattering* model1b = new G4ParticleHPThermalScattering(); + process1->RegisterMe(model1b); + process1->AddDataSet(new G4ParticleHPThermalScatteringData()); + } + + // (re) create process: inelastic + // + G4NeutronInelasticProcess* process2 = new G4NeutronInelasticProcess(); + pManager->AddDiscreteProcess(process2); + // + // cross section data set + G4ParticleHPInelasticData* dataSet2 = new G4ParticleHPInelasticData(); + process2->AddDataSet(dataSet2); + // + // models + G4ParticleHPInelastic* model2 = new G4ParticleHPInelastic(); + process2->RegisterMe(model2); + + // (re) create process: nCapture + // + G4HadronCaptureProcess* process3 = new G4HadronCaptureProcess(); + pManager->AddDiscreteProcess(process3); + // + // cross section data set + G4ParticleHPCaptureData* dataSet3 = new G4ParticleHPCaptureData(); + process3->AddDataSet(dataSet3); + //dataSet3->BuildPhysicsTable(*G4Neutron::Neutron()); + //dataSet3->DumpPhysicsTable(*G4Neutron::Neutron()); + // + // models + G4ParticleHPCapture* model3 = new G4ParticleHPCapture(); + process3->RegisterMe(model3); + + //--- test ---// + /*G4ParticleDefinition* particle; + particle = G4Neutron::Neutron(); + for(int i=0; i<100; i++){ + double energy = (1+i)*1e-3*eV; + G4DynamicParticle *dn = new G4DynamicParticle(particle,G4ThreeVector(0,0,1), energy); + G4Element* element = new G4Element("C","C",1); + G4Isotope* isotope = new G4Isotope("C",6,12); + element->AddIsotope(isotope,1); + G4Material* mat = new G4Material("C",2.26*g/cm3,1); + mat->AddElement(element,1); + cout << "--- " << energy << " is ok? ---" << endl; + cout << dataSet3->IsIsoApplicable(dn, 6, 12, element, mat) << endl; + //cout << dataSet3->GetCrossSection(dn,element,12) << endl; + }*/ + + // (re) create process: nFission + // + G4HadronFissionProcess* process4 = new G4HadronFissionProcess(); + pManager->AddDiscreteProcess(process4); + // + // cross section data set + G4ParticleHPFissionData* dataSet4 = new G4ParticleHPFissionData(); + process4->AddDataSet(dataSet4); + // + // models + G4ParticleHPFission* model4 = new G4ParticleHPFission(); + process4->RegisterMe(model4); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Process/NeutronHPphysics.hh b/NPSimulation/Process/NeutronHPphysics.hh new file mode 100644 index 0000000000000000000000000000000000000000..fad49bba6616bc93d54d9af1d721496392cc9051 --- /dev/null +++ b/NPSimulation/Process/NeutronHPphysics.hh @@ -0,0 +1,64 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +/// \file NeutronHPphysics.hh +/// \brief Definition of the NeutronHPphysics class +// +// + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#ifndef NeutronHPphysics_h +#define NeutronHPphysics_h 1 + +#include "globals.hh" +#include "G4VPhysicsConstructor.hh" + +class NeutronHPMessenger; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class NeutronHPphysics : public G4VPhysicsConstructor +{ + public: + NeutronHPphysics(const G4String& name="neutron"); + ~NeutronHPphysics(); + + public: + virtual void ConstructParticle() { }; + virtual void ConstructProcess(); + + public: + void SetThermalPhysics(G4bool flag) {fThermal = flag;}; + + private: + G4bool fThermal; + NeutronHPMessenger* fNeutronMessenger; +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/NPSimulation/Process/PhysicsList.cc b/NPSimulation/Process/PhysicsList.cc index fd89a2f8766854acb7bdeb0a57a17ad9014feb02..84219207d2ac090f6adc2cc775fce6d80973d1c1 100644 --- a/NPSimulation/Process/PhysicsList.cc +++ b/NPSimulation/Process/PhysicsList.cc @@ -54,7 +54,9 @@ #include "G4PAIPhotModel.hh" #include "G4RadioactiveDecay.hh" #include "menate_R.hh" - +#ifdef USE_NEUTRONHP +#include "NeutronHPphysics.hh" +#endif ///////////////////////////////////////////////////////////////////////////// PhysicsList::PhysicsList() : G4VUserPhysicsList(){ @@ -141,6 +143,12 @@ PhysicsList::PhysicsList() : G4VUserPhysicsList(){ cout << "//// Using NPIonIonInelasticPhysic Physics List ////" << endl; } +#ifdef USE_NEUTRONHP + if(m_NeutronHP){ + m_PhysList["NeutronHPphysics"] = new NeutronHPphysics("neutronHP"); + cout << "//// Using NeutronHPPhysics ////" << endl; + } +#endif if(m_StoppingPhysics){ m_PhysList["StoppingPhysics"]=new G4StoppingPhysics(); cout << "//// Using G4StoppingPhysics Physics List ////" << endl; @@ -161,6 +169,12 @@ PhysicsList::PhysicsList() : G4VUserPhysicsList(){ std::cout << "\r\032[1;31m Warning: physics list HadronPhysicsQGSP_BIC_HP require Geant4 10, process not activated \033[0m" <<std::endl; #endif } + + if(m_HadronPhysicsQGSP_BERT_HP){ + m_PhysList["HadronPhysicsQGSP_BERT_HP"] = new G4HadronPhysicsQGSP_BERT_HP(); + cout << "//// Using QGSP_BERT_HP Physics List ////" << endl; + } + // Optical Photon for scintillator simulation if(m_OpticalPhysics){ opticalPhysicsList = new G4OpticalPhysics(0); @@ -219,6 +233,7 @@ void PhysicsList::ReadConfiguration(std::string filename){ m_OpticalPhysics = 0; m_DriftElectronPhysics = 0; m_HadronPhysicsQGSP_BIC_HP = 0; + m_HadronPhysicsQGSP_BERT_HP = 0; m_HadronPhysicsINCLXX = 0; m_Decay = 0; m_IonGasModels = 0; @@ -226,6 +241,8 @@ void PhysicsList::ReadConfiguration(std::string filename){ m_pai_photon= 0; m_Menate_R = 0; + m_NeutronHP = 0; + std::ifstream file(filename.c_str()); if(!file.is_open()){ std::cout << "WARNING: Could not find Physics List option file " << filename << " | Using default Physics List" << std::endl; @@ -259,6 +276,8 @@ void PhysicsList::ReadConfiguration(std::string filename){ m_DriftElectronPhysics= value; else if (name == "HadronPhysicsQGSP_BIC_HP") m_HadronPhysicsQGSP_BIC_HP= value; + else if (name == "HadronPhysicsQGSP_BERT_HP") + m_HadronPhysicsQGSP_BERT_HP= value; else if (name == "HadronPhysicsINCLXX") m_HadronPhysicsINCLXX= value; else if (name == "Decay") @@ -271,13 +290,15 @@ void PhysicsList::ReadConfiguration(std::string filename){ m_pai_photon = value; else if (name == "Menate_R") m_Menate_R = value; + else if (name == "NeutronHP") + m_NeutronHP = value; else std::cout <<"WARNING: Physics List Token '" << name << "' unknown. Token is ignored." << std::endl; } // Most special process need decay to be activated if( (m_IonBinaryCascadePhysics || m_EmExtraPhysics || m_HadronElasticPhysics || m_NPIonInelasticPhysics - || m_StoppingPhysics || m_HadronPhysicsQGSP_BIC_HP || m_HadronPhysicsINCLXX) && !m_Decay){ + || m_StoppingPhysics || m_HadronPhysicsQGSP_BIC_HP || m_HadronPhysicsQGSP_BERT_HP || m_HadronPhysicsINCLXX) && !m_Decay){ m_Decay = true; std::cout << "Information: Selected process require Decay to be activated." << std::endl; } @@ -519,6 +540,9 @@ void PhysicsList::SetCuts(){ // Special Cut for optical photon to be emmitted SetCutsWithDefault(); + + if(m_NeutronHP) + SetCutValue(0*mm,"proton"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/NPSimulation/Process/PhysicsList.hh b/NPSimulation/Process/PhysicsList.hh index 791e3d6242bfbe974b7e815c9042955c24888c70..23823327e0a8be0b49c7d383b18fa8d1147c019e 100644 --- a/NPSimulation/Process/PhysicsList.hh +++ b/NPSimulation/Process/PhysicsList.hh @@ -66,6 +66,7 @@ #include "G4IonINCLXXPhysics.hh" #if NPS_GEANT4_VERSION_MAJOR > 9 #include "G4HadronPhysicsQGSP_BIC_HP.hh" +#include "G4HadronPhysicsQGSP_BERT_HP.hh" #endif #include "G4HadronPhysicsQGSP_BIC.hh" #include "G4HadronPhysicsQGSP_BERT.hh" @@ -112,12 +113,14 @@ class PhysicsList: public G4VUserPhysicsList{ double m_OpticalPhysics; double m_DriftElectronPhysics; double m_HadronPhysicsQGSP_BIC_HP; + double m_HadronPhysicsQGSP_BERT_HP; double m_HadronPhysicsINCLXX; double m_Decay; double m_IonGasModels; double m_pai; double m_pai_photon; - double m_Menate_R; + double m_Menate_R; + double m_NeutronHP; }; diff --git a/NPSimulation/Scorers/CalorimeterScorers.hh b/NPSimulation/Scorers/CalorimeterScorers.hh index 8525e52951cdeaa53f53c005d4fccb8f9f151c33..f4565637a54556630f4397ca0cd2bf0963779f52 100644 --- a/NPSimulation/Scorers/CalorimeterScorers.hh +++ b/NPSimulation/Scorers/CalorimeterScorers.hh @@ -106,7 +106,6 @@ namespace CalorimeterScorers { // Give the list of the nesting level at which the copy number should be return. // 0 is the lowest level possible (the actual volume copy number in which the interaction happen) vector<G4int> m_NestingLevel; - G4int m_Index; private: CalorimeterDataVector m_Data; diff --git a/NPSimulation/Scorers/CylinderTPCScorers.hh b/NPSimulation/Scorers/CylinderTPCScorers.hh index 14463f091c2644e94d6e7b00ab5224841a10862c..1f9434d196fdc7ab05f265c9f38eb07ddb0f24ae 100644 --- a/NPSimulation/Scorers/CylinderTPCScorers.hh +++ b/NPSimulation/Scorers/CylinderTPCScorers.hh @@ -125,7 +125,6 @@ namespace CylinderTPCScorers{ private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) vector<G4int> m_NestingLevel; - unsigned int m_Level; double t_Charge; double t_DriftTime; unsigned int t_Pad; diff --git a/NPSimulation/Scorers/DSSDScorers.hh b/NPSimulation/Scorers/DSSDScorers.hh index 3447ed112e7dec4e9ec6f03b6689ba64d9ec2330..326c334b3769d0fe9f98328127d86365f530d9dd 100644 --- a/NPSimulation/Scorers/DSSDScorers.hh +++ b/NPSimulation/Scorers/DSSDScorers.hh @@ -131,7 +131,6 @@ namespace DSSDScorers { private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) G4ThreeVector t_Position; - unsigned int t_Index; double t_Energy; double t_Time; unsigned int t_DetectorNbr; @@ -190,7 +189,6 @@ namespace DSSDScorers { DSSDDataVector m_HitWidth; private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) G4ThreeVector t_Position; - unsigned int t_Index; double t_Energy; double t_Time; unsigned int t_DetectorNumber; @@ -257,7 +255,6 @@ namespace DSSDScorers { private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) G4ThreeVector t_Position; - unsigned int t_Index; double t_Energy; double t_Time; unsigned int t_DetectorNumber; @@ -333,7 +330,6 @@ namespace DSSDScorers { double t_Time; unsigned int t_DetectorNumber; unsigned int t_StripWidthNumber; - unsigned int t_Index; public: inline unsigned int GetUpMult() {return m_HitUp.size();}; inline unsigned int GetStripUp(const unsigned int& i){return m_HitUp[i]->GetStrip();}; diff --git a/NPSimulation/Scorers/DriftChamberScorers.hh b/NPSimulation/Scorers/DriftChamberScorers.hh index 2c0c7c6755cef1b49481743310855f1e4ccb8e13..aa966d0bcc2b0857bd04c0822eda29ecff9cb813 100644 --- a/NPSimulation/Scorers/DriftChamberScorers.hh +++ b/NPSimulation/Scorers/DriftChamberScorers.hh @@ -120,14 +120,12 @@ namespace DriftChamberScorers { private: vector<G4int> m_NestingLevel; - G4int m_Index; private: // Needed for intermediate calculation (avoid multiple instantiation // in Processing Hit) DCDataVector m_Data; vector<unsigned int> t_Level; - unsigned int t_Detector; G4ThreeVector m_Dir; double m_DriftSpeed; double t_preout; diff --git a/NPSimulation/Simulation.cc b/NPSimulation/Simulation.cc index 9c4f542b79178f72af0684da75eed06aa5ff56f3..a8e1345365f59cfdb3e3f88efdc0b6b669e1fd4f 100644 --- a/NPSimulation/Simulation.cc +++ b/NPSimulation/Simulation.cc @@ -27,6 +27,10 @@ // G4 General Source #include "SteppingVerbose.hh" +#include "Randomize.hh" + +// Root +#include "TRandom.h" // NPS headers #include "EventAction.hh" @@ -59,6 +63,17 @@ int main(int argc, char** argv){ // case when input files are here G4String EventGeneratorFileName = OptionManager->GetReactionFile(); G4String DetectorFileName = OptionManager->GetDetectorFile(); + + + // initialize the state of the root and geant4 random generator + if(OptionManager->GetRandomSeed()>0){ + std::cout << " Seeds for random generators set to: " << OptionManager->GetRandomSeed() << std::endl; + gRandom->SetSeed(OptionManager->GetRandomSeed()); + CLHEP::HepRandom::setTheSeed(OptionManager->GetRandomSeed(),3); + } + + + // my Verbose output class G4VSteppingVerbose::SetInstance(new SteppingVerbose); @@ -115,32 +130,32 @@ int main(int argc, char** argv){ G4VisManager* visManager=NULL; - if(!OptionManager->GetG4BatchMode()){ + #ifdef G4UI_USE + if(!OptionManager->GetG4BatchMode()){ string Path_Macro = getenv("NPTOOL"); Path_Macro+="/NPSimulation/ressources/macro/"; UImanager->ApplyCommand("/control/execute " +Path_Macro+"verbose.mac"); -#ifdef G4VIS_USE + #ifdef G4VIS_USE UImanager->ApplyCommand("/control/execute " +Path_Macro+"aliases.mac"); visManager = new G4VisExecutive("Quiet"); visManager->Initialize(); UImanager->ApplyCommand("/control/execute " +Path_Macro+"vis.mac"); -#endif + #endif if (ui->IsGUI()){ UImanager->ApplyCommand("/control/execute " +Path_Macro+"gui.mac"); } -#ifdef __APPLE__ + #ifdef __APPLE__ string command= "osascript "; command+= getenv("NPTOOL"); command+="/NPSimulation/ressources/scripts/bringtofront.osa & "; int res =system(command.c_str()); res =0; - -#endif + #endif } else{// if batch mode do not accumulate any track - UImanager->ApplyCommand("/vis/scene/endOfEventAction accumulate 0"); + UImanager->ApplyCommand("/vis/scene/endOfEventAction accumulate 0"); } // Execute user macro if(!OptionManager->IsDefault("G4MacroPath")){ @@ -163,9 +178,22 @@ int main(int argc, char** argv){ /////////////////////////////////////////////////////////////// ////////////////////// Job termination //////////////////////// /////////////////////////////////////////////////////////////// + // Save the Geant4 random generator internal generator state in a TASCII + // file store with the root output + std::ofstream file(".geant4_random_state"); + CLHEP::HepRandom::saveFullState(file); + file.close(); + TAsciiFile* aFile = new TAsciiFile(); + aFile->SetNameTitle("G4RandomFinalState",".geant4_random_state"); + aFile->Append(".geant4_random_state"); + RootOutput::getInstance()->GetFile()->cd(); + aFile->Write(0,TAsciiFile::kOverwrite); + int dummy=0; + dummy= system("rm .geant4_random_state"); // delete primary; delete detector; delete runManager; + RootOutput::getInstance()->Destroy(); return 0; } diff --git a/Projects/ChiNu/Analysis.cxx b/Projects/ChiNu/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..be359e9223a11e235eb1eb0000740d856e20cb67 --- /dev/null +++ b/Projects/ChiNu/Analysis.cxx @@ -0,0 +1,131 @@ +/***************************************************************************** + * Copyright (C) 2009-2014 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : march 2025 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +#include"NPOptionManager.h" +#include"RootOutput.h" +#include"RootInput.h" +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + m_ChiNu= (TChiNuPhysics*) m_DetectorManager->GetDetector("ChiNu"); + InitialConditions = new TInitialConditions(); + InteractionCoordinates = new TInteractionCoordinates(); + + InitInputBranch(); + InitOutputBranch(); + + neutron = new NPL::Nucleus("1n"); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + ReInitValue(); + Einit = InitialConditions->GetKineticEnergy(0); + + double Xtarget = InitialConditions->GetIncidentPositionX(); + double Ytarget = InitialConditions->GetIncidentPositionY(); + double Ztarget = InitialConditions->GetIncidentPositionZ(); + TVector3 TargetPos = TVector3(Xtarget,Ytarget,Ztarget); + + for(int i=0; i<m_ChiNu->Energy.size(); i++){ + if(m_ChiNu->Energy.size()>0){ + double Rdet, R; + Rdet = m_ChiNu->GetDetectorPosition(m_ChiNu->DetectorNumber[i]); + TVector3 DetPos = m_ChiNu->GetVectorDetectorPosition(m_ChiNu->DetectorNumber[i]); + TVector3 HitPos = DetPos-TargetPos; + R= HitPos.Mag()*1e-3; + Distance.push_back(R); + Det.push_back(m_ChiNu->DetectorNumber[i]); + T.push_back(m_ChiNu->Time[i]); + neutron->SetTimeOfFlight(m_ChiNu->Time[i]*1e-9/R); + E.push_back(m_ChiNu->Energy[i]); + Elab.push_back(neutron->GetEnergy()); + } + } + + + +} + +/////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch() { + RootOutput::getInstance()->GetTree()->Branch("Einit",&Einit,"Einit/D"); + RootOutput::getInstance()->GetTree()->Branch("Elab",&Elab); + RootOutput::getInstance()->GetTree()->Branch("E",&E); + RootOutput::getInstance()->GetTree()->Branch("T",&T); + RootOutput::getInstance()->GetTree()->Branch("Distance",&Distance); + RootOutput::getInstance()->GetTree()->Branch("Det",&Det); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch(){ + RootInput:: getInstance()->GetChain()->SetBranchStatus("InitialConditions",true ); + RootInput:: getInstance()->GetChain()->SetBranchStatus("fIC_*",true ); + RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&InitialConditions); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue(){ + Einit = -100; + Elab.clear(); + E.clear(); + T.clear(); + Distance.clear(); + Det.clear(); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } +}; + +proxy p; +} + diff --git a/Projects/ChiNu/Analysis.h b/Projects/ChiNu/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..20a13db1427585cb46a1b2c9cc97eeb7f301275b --- /dev/null +++ b/Projects/ChiNu/Analysis.h @@ -0,0 +1,60 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2014 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : march 2025 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "NPVAnalysis.h" +#include "TChiNuPhysics.h" +#include "TInitialConditions.h" +#include "TInteractionCoordinates.h" +#include "NPNucleus.h" + +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + void InitOutputBranch(); + void InitInputBranch(); + void ReInitValue(); + static NPL::VAnalysis* Construct(); + +private: + double Einit; + vector<double> Elab; + vector<double> E; + vector<double> T; + vector<double> Distance; + vector<int> Det; + + private: + TChiNuPhysics* m_ChiNu; + TInitialConditions* InitialConditions; + TInteractionCoordinates* InteractionCoordinates; + + NPL::Nucleus* neutron; + +}; +#endif diff --git a/Projects/ChiNu/CMakeLists.txt b/Projects/ChiNu/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/ChiNu/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/ChiNu/ChiNu.detector b/Projects/ChiNu/ChiNu.detector new file mode 100644 index 0000000000000000000000000000000000000000..e3dc317cfd3c66051de7c31a390462c5bbfef330 --- /dev/null +++ b/Projects/ChiNu/ChiNu.detector @@ -0,0 +1,353 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Target +% THICKNESS= 10 micrometer +% RADIUS= 20 mm +% MATERIAL= CD2 +% ANGLE= 0 deg +% X= 0 mm +% Y= 0 mm +% Z= 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LI +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 150 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 135 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 120 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 105 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 90 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 75 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 60 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 45 deg + PHI= 0 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 30 deg + PHI= 0 deg + LeadShield= 1 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LII +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 150 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 135 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 120 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 105 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 90 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 75 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 60 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 45 deg + PHI= 30 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 30 deg + PHI= 30 deg + LeadShield= 1 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LIII +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 150 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 135 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 120 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 105 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 90 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 75 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 60 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 45 deg + PHI= 60 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 30 deg + PHI= 60 deg + LeadShield= 1 + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% RI +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 150 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 135 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 120 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 105 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 90 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 75 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 60 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 45 deg + PHI= 180 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 30 deg + PHI= 180 deg + LeadShield= 1 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% RII +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 150 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 135 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 120 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 105 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 90 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 75 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 60 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 45 deg + PHI= 150 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 30 deg + PHI= 150 deg + LeadShield= 1 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% RIII +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 150 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 135 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 120 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 105 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 90 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 75 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 60 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 45 deg + PHI= 120 deg + LeadShield= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ChiNu + R= 1000 mm + THETA= 30 deg + PHI= 120 deg + LeadShield= 1 + diff --git a/Projects/Dali/Dali.detector b/Projects/Dali/Dali.detector index 36f67955030657bfdfbb0f76cf478a7d4f499868..b865ae2073e3e6fbf4cf0a92fc07e1d6e3282655 100644 --- a/Projects/Dali/Dali.detector +++ b/Projects/Dali/Dali.detector @@ -1,97 +1,78 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Target - THICKNESS= 20 mm - RADIUS= 20 mm - MATERIAL= CD2 - ANGLE= 0 deg - X= 0 mm - Y= 0 mm - Z= 220 mm -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 240 deg - Zeta = -90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 298,28 mm + Ring = 1 + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 180 deg - Zeta = -90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 298,28 mm + Ring = 1 + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali - R = 212.4 mm + R= 212.4 mm Alpha = 120 deg - Zeta = -90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 298,28 mm + Ring = 1 + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 60 deg - Zeta = -90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 298,28 mm + Ring = 1 + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 0 deg - Zeta = -90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 298,28 mm + Ring = 1 + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = -60 deg - Zeta = -90.03 mm - Shape = Square - Material = NaI_Tl - - - + Zeta = 298,28 mm + Ring = 1 + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 240 deg - Zeta = 90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 469.28 mm + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 180 deg - Zeta = 90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 469.28 mm + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 120 deg - Zeta = 90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 469.28 mm + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 60 deg - Zeta = 90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 469.28 mm + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = 0 deg - Zeta = 90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 469.28 mm + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dali R = 212.4 mm Alpha = -60 deg - Zeta = 90.03 mm - Shape = Square - Material = NaI_Tl + Zeta = 469.28 mm + Material = NaI(Tl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Projects/Dali/DaliMinos.detector b/Projects/Dali/DaliMinos.detector old mode 100644 new mode 100755 diff --git a/Projects/Dali/PhysicsListOption.txt b/Projects/Dali/PhysicsListOption.txt index a8991fd396fd70fc80b1cdcb14efc5fec098c56e..55051b2daa3ff7d02c80ce05ada9b18aae3fecb9 100644 --- a/Projects/Dali/PhysicsListOption.txt +++ b/Projects/Dali/PhysicsListOption.txt @@ -1,7 +1,7 @@ EmPhysicsList Option4 DefaultCutOff 10000 IonBinaryCascadePhysics 0 -DriftElectronPhysics 1 +DriftElectronPhysics 1 NPIonInelasticPhysics 0 EmExtraPhysics 0 HadronElasticPhysics 0 diff --git a/Projects/MUGAST/Analysis.cxx b/Projects/MUGAST/Analysis.cxx index 30a945f89890ce68e04369fe619584f5a2e6eb3e..4c86b827c1cfcf406fa6e03d761020e8e296ec9c 100644 --- a/Projects/MUGAST/Analysis.cxx +++ b/Projects/MUGAST/Analysis.cxx @@ -36,16 +36,29 @@ Analysis::~Analysis(){ //////////////////////////////////////////////////////////////////////////////// void Analysis::Init() { - + if(NPOptionManager::getInstance()->HasDefinition("simulation")){ + cout << "Considering input data as simulation" << endl; + simulation=true; + } + else{ + cout << "Considering input data as real" << endl; + simulation=false; + } agata_zShift=51*mm; // initialize input and output branches + if(simulation){ + Initial = new TInitialConditions(); + ReactionConditions = new TReactionConditions(); + } + InitOutputBranch(); InitInputBranch(); // get MUST2 and Gaspard objects M2 = (TMust2Physics*) m_DetectorManager -> GetDetector("M2Telescope"); MG = (TMugastPhysics*) m_DetectorManager -> GetDetector("Mugast"); - CATS = (TCATSPhysics*) m_DetectorManager->GetDetector("CATSDetector"); + if(!simulation) + CATS = (TCATSPhysics*) m_DetectorManager->GetDetector("CATSDetector"); // get reaction information reaction.ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()); @@ -65,7 +78,12 @@ void Analysis::Init() { LightSi = NPL::EnergyLoss(light+"_Si.G4table","G4Table",100); BeamCD2 = NPL::EnergyLoss(beam+"_"+TargetMaterial+".G4table","G4Table",100); + FinalBeamEnergy = BeamCD2.Slow(OriginalBeamEnergy,TargetThickness*0.5,0); + cout << "Original beam energy: " << OriginalBeamEnergy << " MeV Mid-target beam energy: " << FinalBeamEnergy << "MeV " << endl; + reaction.SetBeamEnergy(FinalBeamEnergy); + if(WindowsThickness){ + cout << "Cryogenic target with windows" << endl; BeamWindow= new NPL::EnergyLoss(beam+"_"+WindowsMaterial+".G4table","G4Table",100); LightWindow= new NPL::EnergyLoss(light+"_"+WindowsMaterial+".G4table","G4Table",100); } @@ -97,10 +115,20 @@ void Analysis::Init() { void Analysis::TreatEvent() { // Reinitiate calculated variable ReInitValue(); - double XTarget = CATS->GetPositionOnTarget().X(); - double YTarget = CATS->GetPositionOnTarget().Y(); - TVector3 BeamDirection = CATS->GetBeamDirection(); - + double XTarget, YTarget; + TVector3 BeamDirection; + if(!simulation){ + XTarget = CATS->GetPositionOnTarget().X(); + YTarget = CATS->GetPositionOnTarget().Y(); + BeamDirection = CATS->GetBeamDirection(); + } + else{ + XTarget = 0; + YTarget = 0; + BeamDirection = TVector3(0,0,1); + OriginalELab = ReactionConditions->GetKineticEnergy(0); + OriginalThetaLab = ReactionConditions->GetTheta(0); + } BeamImpact = TVector3(XTarget,YTarget,0); // determine beam energy for a randomized interaction point in target // 1% FWHM randominastion (E/100)/2.35 @@ -151,7 +179,7 @@ void Analysis::TreatEvent() { // Evaluate energy using the thickness ELab = LightAl.EvaluateInitialEnergy( Energy ,0.4*micrometer , ThetaM2Surface); // Target Correction - ELab = LightTarget.EvaluateInitialEnergy( ELab ,TargetThickness/2., ThetaNormalTarget); + ELab = LightTarget.EvaluateInitialEnergy( ELab ,TargetThickness*0.5, ThetaNormalTarget); if(LightWindow) ELab = LightWindow->EvaluateInitialEnergy( ELab ,WindowsThickness, ThetaNormalTarget); @@ -192,8 +220,10 @@ void Analysis::TreatEvent() { // Part 2 : Impact Energy Energy = ELab = 0; Energy = MG->GetEnergyDeposit(countMugast); + + // ELab = LightAl.EvaluateInitialEnergy( Energy ,0.4*micrometer , ThetaMGSurface); // Target Correction - ELab = LightTarget.EvaluateInitialEnergy( Energy ,TargetThickness*0.5, ThetaNormalTarget); + ELab = LightTarget.EvaluateInitialEnergy( Energy,TargetThickness*0.5, ThetaNormalTarget); if(LightWindow) ELab = LightWindow->EvaluateInitialEnergy( ELab ,WindowsThickness, ThetaNormalTarget); @@ -207,7 +237,7 @@ void Analysis::TreatEvent() { ThetaLab=ThetaLab/deg; }//end loop Mugast - + //////////////////////////////////////////////////////////////////////////// ///////////////////////////////// LOOP on AGATA //////////////////////////// //////////////////////////////////////////////////////////////////////////// @@ -230,7 +260,7 @@ void Analysis::TreatEvent() { GammaLV.Boost(-beta); // Get EDC EDC=GammaLV.Energy(); - } + } } @@ -271,6 +301,10 @@ void Analysis::InitOutputBranch() { RootOutput::getInstance()->GetTree()->Branch("coreTS",coreTS,"coreTS[nbCores]/l"); RootOutput::getInstance()->GetTree()->Branch("coreE0",coreE0,"coreE0[nbCores]/F"); // + if(simulation){ + RootOutput::getInstance()->GetTree()->Branch("OriginalELab",&OriginalELab,"OriginalELab/D"); + RootOutput::getInstance()->GetTree()->Branch("OriginalThetaLab",&OriginalThetaLab,"OriginalThetaLab/D"); + } } @@ -292,6 +326,14 @@ void Analysis::InitInputBranch(){ RootInput::getInstance()->GetChain()->SetBranchAddress("coreId",coreId); RootInput::getInstance()->GetChain()->SetBranchAddress("coreTS",coreTS); RootInput::getInstance()->GetChain()->SetBranchAddress("coreE0",coreE0); + if(simulation){ + RootInput:: getInstance()->GetChain()->SetBranchStatus("InitialConditions",true ); + RootInput:: getInstance()->GetChain()->SetBranchStatus("fIC_*",true ); + RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial); + RootInput:: getInstance()->GetChain()->SetBranchStatus("ReactionConditions",true ); + RootInput:: getInstance()->GetChain()->SetBranchStatus("fRC_*",true ); + RootInput:: getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&ReactionConditions); + } } //////////////////////////////////////////////////////////////////////////////// void Analysis::ReInitValue(){ @@ -318,13 +360,13 @@ NPL::VAnalysis* Analysis::Construct(){ // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// extern "C"{ -class proxy_analysis{ - public: - proxy_analysis(){ - NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); - } -}; - -proxy_analysis p_analysis; + class proxy_analysis{ + public: + proxy_analysis(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } + }; + + proxy_analysis p_analysis; } diff --git a/Projects/MUGAST/Analysis.h b/Projects/MUGAST/Analysis.h index 65afe5a68a47d6a182d3eec4e2c572a06cf397d9..d744d46d109f016347fcacf491244a2e97ef677f 100644 --- a/Projects/MUGAST/Analysis.h +++ b/Projects/MUGAST/Analysis.h @@ -26,6 +26,8 @@ #include"NPReaction.h" #include"RootOutput.h" #include"RootInput.h" +#include "TInitialConditions.h" +#include "TReactionConditions.h" #include "TMust2Physics.h" #include "TMugastPhysics.h" #include "TCATSPhysics.h" @@ -54,6 +56,9 @@ class Analysis: public NPL::VAnalysis{ double ELab; double ThetaLab; double ThetaCM; + double OriginalELab; + double OriginalThetaLab; + NPL::Reaction reaction; // Energy loss table: the G4Table are generated by the simulation NPL::EnergyLoss LightTarget; @@ -111,6 +116,8 @@ class Analysis: public NPL::VAnalysis{ TMust2Physics* M2; TMugastPhysics* MG; TCATSPhysics* CATS; - + bool simulation; + TInitialConditions* Initial; + TReactionConditions* ReactionConditions; }; #endif diff --git a/Projects/MUGAST/ShowResults.C b/Projects/MUGAST/ShowResults.C index 15bbb392d6d5d8e7e89d891a12b6c2b7c49dec2d..d5fe10231893ad266a0be132da88934b6f6ef3b5 100644 --- a/Projects/MUGAST/ShowResults.C +++ b/Projects/MUGAST/ShowResults.C @@ -53,66 +53,54 @@ using namespace std; using namespace NPL; void ShowResults(){ - // get tree - TFile *f = new TFile("../../Outputs/Analysis/PhysicsTree.root"); - TTree *t = (TTree*) f->Get("PhysicsTree"); + // get tree + TFile* f = new TFile("../../Outputs/Analysis/PhysicsTree.root"); + TTree* t = (TTree*) f->Get("PhysicsTree"); - // draw kinematic information - // canvas - TCanvas *c1 = new TCanvas("c1", "kinematic information", 600, 600); - c1->Draw(); - // kinematic line - TH2F *hk = new TH2F("hk", "hk", 180, 0, 180, 200, 0, 60); - hk->GetXaxis()->SetTitle("#Theta_{lab} (deg)"); - hk->GetYaxis()->SetTitle("E_{p} (MeV)"); - cout << "counts " << t->Draw("ELab:ThetaLab>>hk","Ex>0&&Ex<6","colz") << endl; - NPL::Reaction* reaction = new NPL::Reaction(); - reaction->ReadConfigurationFile("28Mg.reaction"); - reaction->GetKinematicLine3()->Draw("c"); + // draw kinematic information + // canvas + TCanvas *c1 = new TCanvas("c1", "Results", 1000, 1000); + c1->Divide(2,2); + c1->cd(1); + // kinematic line + TH2F* hk = new TH2F("hk", "hk", 180*3, 0, 180, 1000, 0, 60); + t->Draw("ELab:ThetaLab>>hk","","col"); + hk->GetXaxis()->SetTitle("#Theta_{lab} (deg)"); + hk->GetYaxis()->SetTitle("E_{p} (MeV)"); + NPL::Reaction* reaction = new NPL::Reaction(); + reaction->ReadConfigurationFile("16Odp17O_870keV_12.reaction"); + reaction->GetKinematicLine3()->Draw("c"); - new TCanvas(); + c1->cd(2); + TH1F* hEx = new TH1F("hEx", "hEx",1000, -1, 5); + t->Draw("Ex>>hEx","ThetaLab>100 && ThetaLab<156","col"); + hEx->GetXaxis()->SetTitle("Ex (MeV)"); + hEx->GetYaxis()->SetTitle("counts/100 keV"); + + c1->cd(3); TH1F *hCM = new TH1F("hCM", "hCM", 36, 0, 180); - t->Draw("ThetaCM>>hCM","Ex>0&&Ex<6","",2900); + t->Draw("ThetaCM>>hCM","Ex>0&&Ex<6",""); for(int i = 0 ; i < hCM->GetNbinsX();i++){ if(hCM->GetBinCenter(i)==37.5 || hCM->GetBinCenter(i)==97.5|| hCM->GetBinCenter(i)==167.5|| hCM->GetBinCenter(i)==42.5){ hCM->SetBinContent(i,0); - - } - + } - gPad->SetLogy(); + } - TFile* file= new TFile("effMUGAST.root"); - TH1* hOmega = (TH1*)file->FindObjectAny("hDetecThetaCM"); - hOmega->Rebin(5); - hCM->Sumw2(); - hCM->Divide(hOmega); - TGraph* g= new TGraph("22.jjj"); - g->Draw("c"); - hCM->Scale(g->Eval(32.5)/hCM->GetBinContent(hCM->FindBin(32.5))); - TGraph* g2= new TGraph("22.l2"); - g2->Draw("c"); - TGraph* g3= new TGraph("22.l3"); - g3->Draw("c"); + + TCanvas *c2 = new TCanvas("c2", "Control", 1000, 1000); + c2->Divide(2,2); + c2->cd(1); + TH1F* hcT = new TH1F("hcT", "hcT", 180*3, -1,1); + t->Draw("ThetaLab-OriginalThetaLab>>hcT","","col"); + TLine* lT = new TLine(0,0,180,180); + //lT->Draw(); + c2->cd(2); + TH1F* hcE = new TH1F("hcE", "hcE", 1000, -1, 1); + t->Draw("ELab-OriginalELab>>hcE","","col"); + TLine* lE = new TLine(0,0,60,60); + //lE->Draw(); } - -void CountingRates(Double_t ibeam = 1e5, Double_t ubt = 30){ - // load event generator file - NPL::Reaction* reaction = new NPL::Reaction(); - reaction->ReadConfigurationFile("28Mg.reaction"); -// reaction->ReadConfigurationFile("11Be_d3He.reaction"); - // get angular distribution - TH1F *dsig = reaction->GetCrossSectionHist(); - dsig->Draw(); - // calculate total cross section - Double_t stot = reaction->GetTotalCrossSection(); - cout << "total cross section = " << reaction->GetTotalCrossSection() << " mb" << endl; - - // get target thickness -// NPL::DetectorManager* myDetector = new NPL::DetectorManager(); -// myDetector->ReadConfigurationFile("MUGAST_Manu.detector"); - -} diff --git a/Projects/Minos/PhysicsListOption.txt b/Projects/Minos/PhysicsListOption.txt index 5e948e6061566e703143f8c5a86e4ee5ff6d7f76..68f97e860e04654d462d3f6e1888f1ab694af8de 100644 --- a/Projects/Minos/PhysicsListOption.txt +++ b/Projects/Minos/PhysicsListOption.txt @@ -1,5 +1,5 @@ EmPhysicsList Option4 -DriftElectronPhysics 1 +DriftElectronPhysics 0 DefaultCutOff 1e9 IonBinaryCascadePhysics 0 NPIonInelasticPhysics 0 diff --git a/Projects/Nebula/Nebula.detector b/Projects/Nebula/Nebula.detector index 7bb9d72bebbcf9119852278c3f165f90b8dccc9c..776b850b709616f294bad3e2fb95df2c9a2e0aae 100644 --- a/Projects/Nebula/Nebula.detector +++ b/Projects/Nebula/Nebula.detector @@ -20,4 +20,14 @@ Nebula Veto= 0 Frame= 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - +%%%%%%% Telescope 1 %%%%%%% +M2Telescope + X1_Y1= -50.23 50.23 365 mm + X1_Y128= -50.23 -50.23 365 mm + X128_Y128= 50.23 -50.23 365 mm + X128_Y1= 50.23 50.23 365 mm + SI= 1 + SILI= 0 + CSI= 1 + VIS= all + diff --git a/Projects/PISTA/Analysis.cxx b/Projects/PISTA/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e01382896d6ca5ed8be1a5efe048d68754402ff9 --- /dev/null +++ b/Projects/PISTA/Analysis.cxx @@ -0,0 +1,180 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe PISTA analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +#include"NPOptionManager.h" +#include"RootOutput.h" +#include"RootInput.h" +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + PISTA= (TPISTAPhysics*) m_DetectorManager->GetDetector("PISTA"); + InitialConditions = new TInitialConditions(); + ReactionConditions = new TReactionConditions(); + InteractionCoordinates = new TInteractionCoordinates(); + InitOutputBranch(); + InitInputBranch(); + Rand = TRandom3(); + + TargetThickness = m_DetectorManager->GetTargetThickness(); + + Transfer = new NPL::Reaction("238U(12C,10Be)240Pu@1428"); + + // Energy loss table + Be10C = EnergyLoss("EnergyLossTable/Be10_C.G4table","G4Table",100); + U238C = EnergyLoss("EnergyLossTable/U238_C.G4table","G4Table",100); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + ReInitValue(); + + OriginalThetaLab = ReactionConditions->GetTheta(0); + OriginalElab = ReactionConditions->GetKineticEnergy(0); + OriginalBeamEnergy = ReactionConditions->GetBeamEnergy(); + + int mult = InteractionCoordinates->GetDetectedMultiplicity(); + if(mult>0){ + for(int i=0; i<mult; i++){ + double Xpista = InteractionCoordinates->GetDetectedPositionX(i); + double Ypista = InteractionCoordinates->GetDetectedPositionY(i); + double Zpista = InteractionCoordinates->GetDetectedPositionZ(i); + R = sqrt(Xpista*Xpista + Ypista*Ypista + Zpista*Zpista); + } + } + XTarget = InitialConditions->GetIncidentPositionX(); + YTarget = InitialConditions->GetIncidentPositionY(); + ZTarget = InitialConditions->GetIncidentPositionZ(); + + TVector3 BeamDirection = InitialConditions->GetBeamDirection(); + TVector3 BeamPosition(XTarget,YTarget,ZTarget); + //TVector3 PositionOnTarget(0,0,0); + TVector3 PositionOnTarget(Rand.Gaus(XTarget, 0.6/2.35), Rand.Gaus(YTarget, 0.6/2.35), 0); + + BeamEnergy = 1428.;//InitialConditions->GetIncidentInitialKineticEnergy(); + BeamEnergy = U238C.Slow(BeamEnergy,TargetThickness*0.5,0); + + Transfer->SetBeamEnergy(BeamEnergy); + + for(unsigned int i = 0; i<PISTA->EventMultiplicity; i++){ + if(PISTA->E.size()>0){ + double Energy = PISTA->DE[i] + PISTA->E[i]; + TVector3 HitDirection = PISTA->GetPositionOfInteraction(i)-PositionOnTarget; + //ThetaLab = HitDirection.Angle(BeamDirection); + ThetaLab = HitDirection.Angle(TVector3(0,0,1)); + + ThetaDetectorSurface = HitDirection.Angle(-PISTA->GetDetectorNormal(i)); + ThetaNormalTarget = HitDirection.Angle(TVector3(0,0,1)); + + Elab = Be10C.EvaluateInitialEnergy(Energy,TargetThickness*0.5,ThetaNormalTarget); + + OptimumEx = Transfer->ReconstructRelativistic(OriginalElab, OriginalThetaLab*deg); + Ex = Transfer->ReconstructRelativistic(Elab, ThetaLab); + ThetaCM = Transfer->EnergyLabToThetaCM(Elab, ThetaLab)/deg; + ThetaLab = ThetaLab/deg; + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch(){ + RootOutput::getInstance()->GetTree()->Branch("OriginalBeamEnergy",&OriginalBeamEnergy,"OriginalBeamEnergy/D"); + RootOutput::getInstance()->GetTree()->Branch("BeamEnergy",&BeamEnergy,"BeamEnergy/D"); + RootOutput::getInstance()->GetTree()->Branch("XTarget",&XTarget,"XTarget/D"); + RootOutput::getInstance()->GetTree()->Branch("YTarget",&YTarget,"YTarget/D"); + RootOutput::getInstance()->GetTree()->Branch("ZTarget",&ZTarget,"ZTarget/D"); + RootOutput::getInstance()->GetTree()->Branch("OptimumEx",&OptimumEx,"OptimumEx/D"); + RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex,"Ex/D"); + RootOutput::getInstance()->GetTree()->Branch("Elab",&Elab,"Elab/D"); + RootOutput::getInstance()->GetTree()->Branch("OriginalElab",&OriginalElab,"OriginalElab/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D"); + RootOutput::getInstance()->GetTree()->Branch("OriginalThetaLab",&OriginalThetaLab,"OriginalThetaLab/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM,"ThetaCM/D"); + RootOutput::getInstance()->GetTree()->Branch("R",&R,"R/D"); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch(){ + RootInput::getInstance()->GetChain()->SetBranchStatus("InitialConditions",true); + RootInput::getInstance()->GetChain()->SetBranchStatus("fIC_*",true); + RootInput::getInstance()->GetChain()->SetBranchAddress("InitialConditions",&InitialConditions); + RootInput::getInstance()->GetChain()->SetBranchStatus("ReactionConditions",true); + RootInput::getInstance()->GetChain()->SetBranchStatus("fRC_*",true); + RootInput::getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&ReactionConditions); + RootInput::getInstance()->GetChain()->SetBranchStatus("InteractionCoordinates",true); + RootInput::getInstance()->GetChain()->SetBranchStatus("fDetected_*",true); + RootInput::getInstance()->GetChain()->SetBranchAddress("InteractionCoordinates",&InteractionCoordinates); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue(){ + OriginalBeamEnergy = -1000; + BeamEnergy = -1000; + OptimumEx = -1000; + Ex = -1000; + Elab = -1000; + OriginalElab = -1000; + OriginalThetaLab = -1000; + ThetaLab = -1000; + ThetaCM = -1000; + XTarget = -1000; + YTarget = -1000; + ZTarget = -1000; + OriginalThetaLab = -1000; + R = -1000; +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ + class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } + }; + + proxy p; +} + diff --git a/Projects/PISTA/Analysis.h b/Projects/PISTA/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..f5b182ca138522491ca781ec07f754d1b87583af --- /dev/null +++ b/Projects/PISTA/Analysis.h @@ -0,0 +1,78 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe PISTA analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include "NPVAnalysis.h" +#include "TPISTAPhysics.h" +#include "TInitialConditions.h" +#include "TReactionConditions.h" +#include "TInteractionCoordinates.h" +#include "NPEnergyLoss.h" +#include "NPReaction.h" +#include "TRandom3.h" +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + void InitOutputBranch(); + void InitInputBranch(); + void ReInitValue(); + + static NPL::VAnalysis* Construct(); + + private: + double OriginalBeamEnergy; + double BeamEnergy; + double R; + double XTarget; + double YTarget; + double ZTarget; + double OriginalElab; + double Elab; + double ThetaLab; + double ThetaCM; + double OptimumEx; + double Ex; + double OriginalThetaLab; + NPL::Reaction* Transfer; + + TRandom3 Rand; + double ThetaNormalTarget; + double ThetaDetectorSurface; + double TargetThickness; + + NPL::EnergyLoss Be10C; + NPL::EnergyLoss U238C; + + private: + TPISTAPhysics* PISTA; + TInteractionCoordinates* InteractionCoordinates; + TInitialConditions* InitialConditions; + TReactionConditions* ReactionConditions; + +}; +#endif diff --git a/Projects/PISTA/CMakeLists.txt b/Projects/PISTA/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/PISTA/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/PISTA/PISTA.detector b/Projects/PISTA/PISTA.detector new file mode 100644 index 0000000000000000000000000000000000000000..d815893669198c4db742f88ce2ee87578f35b6b1 --- /dev/null +++ b/Projects/PISTA/PISTA.detector @@ -0,0 +1,51 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Target + THICKNESS= 0.22 micrometer + RADIUS= 20 mm + MATERIAL= C + ANGLE= 0 deg + X= 0 mm + Y= 0 mm + Z= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 315 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 270 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 225 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 180 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 135 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 90 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 45 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PISTA + R= 85 mm + THETA= 60 deg + PHI= 0 deg +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/Projects/Scone/Analysis.cxx b/Projects/Scone/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c7210aba98a828545e57fd494f1091b8ddc22a07 --- /dev/null +++ b/Projects/Scone/Analysis.cxx @@ -0,0 +1,161 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe Scone analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +#include"RootInput.h" +#include"RootOutput.h" + +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + Scone= (TSconePhysics*) m_DetectorManager->GetDetector("Scone"); + InitialConditions = new TInitialConditions(); + + m_DetectedNeutron = 0; + + InitInputBranch(); + InitOutputBranch(); + + m_entries = RootInput::getInstance()->GetChain()->GetEntries(); + + E_init = 0; + E_new = 0; + new_energy = false; + + vE_init.clear(); + vDetectedNeutron.clear(); +} + + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + ReInitValue(); + + if(InitialConditions->GetParticleMultiplicity()>0){ + E_init = InitialConditions->GetKineticEnergy(0); + } + + if(E_new == E_init) new_energy = false; + if(E_new != E_init){ + E_new = E_init; + vE_init.push_back(E_new); + new_energy = true; + } + + + if(new_energy == true){ + if(m_DetectedNeutron!=0) vDetectedNeutron.push_back(m_DetectedNeutron); + m_DetectedNeutron = 0; + } + + E_sum = 0; + if(Scone->Energy.size()>0){ + for(int i=0; i<Scone->Energy.size(); i++){ + if(Scone->Energy[i]>E_max) E_max = Scone->Energy[i]; + if(Scone->Time[i]>Time_max) Time_max = Scone->Time[i]; + E_sum += Scone->Energy[i]; + } + } + E_sum = E_sum - E_init; + //if(Time_max>50) m_DetectedNeutron++; + if(Time_max>50 && E_sum>0) m_DetectedNeutron++; +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue(){ + E_init = -10000; + E_max = -10000; + Time_max = -10000; +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch() +{ + RootOutput::getInstance()->GetTree()->Branch("E_init",&E_init,"E_init/D"); + RootOutput::getInstance()->GetTree()->Branch("E_max",&E_max,"E_max/D"); + RootOutput::getInstance()->GetTree()->Branch("E_sum",&E_sum,"E_sum/D"); + RootOutput::getInstance()->GetTree()->Branch("Time_max",&Time_max,"Time_max/D"); +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch(){ + RootInput::getInstance()->GetChain()->SetBranchStatus("InitialConditions",true); + RootInput::getInstance()->GetChain()->SetBranchStatus("fIC_*",true); + RootInput::getInstance()->GetChain()->SetBranchAddress("InitialConditions",&InitialConditions); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ + // For last energy // + vDetectedNeutron.push_back(m_DetectedNeutron); + + cout << "Number of Init energy treated: " << vE_init.size() << endl; + cout << "With initial energy: " << endl; + for(int i=0; i< vE_init.size(); i++) + cout << "* " << vE_init[i] << endl; + + cout << "Size of vDetectedNeutron: " << vDetectedNeutron.size() << endl; + cout << "DetectedNeutron: " << endl; + + ofstream ofile; + ofile.open("macro/eff_scone_natGd25um.txt"); + //ofile.open("macro/eff_scone_menate.txt"); + for(int i=0; i< vDetectedNeutron.size(); i++){ + //cout << "* " << vE_init[i] << " / " << vDetectedNeutron[i]/vDetectedNeutron[0]*99.4 << endl; + cout << "* " << vE_init[i] << " / " << vDetectedNeutron[i]/1e5*100 << endl; + //ofile << vE_init[i] << " " << vDetectedNeutron[i]/vDetectedNeutron[0]*99.4 << endl; + ofile << vE_init[i] << " " << vDetectedNeutron[i]/1e5*100 << endl; + } + ofile.close(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ + class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } + }; + + proxy p; +} + diff --git a/Projects/Scone/Analysis.h b/Projects/Scone/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..75b2b54823a892ef65899da893c3f2be5f4756dd --- /dev/null +++ b/Projects/Scone/Analysis.h @@ -0,0 +1,66 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe Scone analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include"NPVAnalysis.h" +#include"TSconePhysics.h" +#include"TInitialConditions.h" +#include"TInteractionCoordinates.h" + +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + void InitInputBranch(); + void InitOutputBranch(); + void ReInitValue(); + + static NPL::VAnalysis* Construct(); + + private: + double Time_max; + double E_init; + double E_max; + double E_sum; + + private: + TSconePhysics* Scone; + TInitialConditions* InitialConditions; + + private: + double m_DetectedNeutron; + int m_entries; + vector<double> vDetectedNeutron; + + private: + bool new_energy; + double E_new; + vector<double> vE_init; + +}; + +#endif diff --git a/Projects/Scone/CMakeLists.txt b/Projects/Scone/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/Scone/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/Scone/Scone.detector b/Projects/Scone/Scone.detector new file mode 100644 index 0000000000000000000000000000000000000000..1cd3e5c14e1124a11040186e63ce7ac607c9804b --- /dev/null +++ b/Projects/Scone/Scone.detector @@ -0,0 +1,16 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Target +% THICKNESS= 10 micrometer +% RADIUS= 10 mm +% MATERIAL= CD2 +% ANGLE= 0 deg +% X= 0 mm +% Y= 0 mm +% Z= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Scone + POS= 0 0 0 mm + Ring1= 1 + Ring2= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/Projects/TACTIC/Analysis.cxx b/Projects/TACTIC/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..08fbb0f61c06d42fc8eb8e790dc2bb71fd0ee627 --- /dev/null +++ b/Projects/TACTIC/Analysis.cxx @@ -0,0 +1,68 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TACTIC analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + TACTIC= (TTACTICPhysicsPhysics*) m_DetectorManager->GetDetector("TACTIC"); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } +}; + +proxy p; +} + diff --git a/Projects/TACTIC/Analysis.h b/Projects/TACTIC/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..eda0a4f8d513a9ffac10ba5281229e8ba67e3f0e --- /dev/null +++ b/Projects/TACTIC/Analysis.h @@ -0,0 +1,42 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TACTIC analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include"NPVAnalysis.h" +#include"TTACTICPhysics.h" +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + + static NPL::VAnalysis* Construct(); + + private: + TTACTICPhysics* TACTIC; + +}; +#endif diff --git a/Projects/TACTIC/CMakeLists.txt b/Projects/TACTIC/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/TACTIC/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/TACTIC/TACTIC.detector b/Projects/TACTIC/TACTIC.detector new file mode 100644 index 0000000000000000000000000000000000000000..d9a48d30026cfb6f32bcd0f2550b5d688b258413 --- /dev/null +++ b/Projects/TACTIC/TACTIC.detector @@ -0,0 +1,25 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Target + THICKNESS= 10 micrometer + RADIUS= 20 mm + MATERIAL= CD2 + ANGLE= 0 deg + X= 0 mm + Y= 0 mm + Z= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TACTIC + POS= 0 0 350 mm + Shape= Square +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TACTIC + POS = 35 35 35 cm + Shape= Square +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TACTIC + R= 350 mm + THETA= 90 deg + PHI= 63 deg + Shape= Cylindrical +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +