diff --git a/NPAnalysis/10He_Riken/src/Analysis.cc b/NPAnalysis/10He_Riken/src/Analysis.cc index 2792d41bf03fdd1e5f386eb50af1f78138773545..283525a783dccb584090849b8c6225093350134c 100644 --- a/NPAnalysis/10He_Riken/src/Analysis.cc +++ b/NPAnalysis/10He_Riken/src/Analysis.cc @@ -5,9 +5,9 @@ int main(int argc,char** argv) { NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv) ; - string detectorfileName = myOptionManager->GetDetectorFilePath() ; - string calibrationfileName = myOptionManager->GetCalibrationFilePath() ; - string runToReadfileName = myOptionManager->GetRunToReadFilePath() ; + string detectorfileName = myOptionManager->GetDetectorFile() ; + string calibrationfileName = myOptionManager->GetCalibrationFile() ; + string runToReadfileName = myOptionManager->GetRunToReadFile() ; // First of All instantiate RootInput and Output // Detector will be attached later diff --git a/NPAnalysis/Gaspard/src/Analysis.cc b/NPAnalysis/Gaspard/src/Analysis.cc index 06e4f59374c568944e94612eefdc4c45f89f09d6..9289bfaea409098eca6a803fd17e1abc1e70d9ff 100644 --- a/NPAnalysis/Gaspard/src/Analysis.cc +++ b/NPAnalysis/Gaspard/src/Analysis.cc @@ -7,34 +7,16 @@ int main(int argc,char** argv) { // command line parsing NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); - string reactionfileName = myOptionManager->GetReactionFilePath(); - string detectorfileName = myOptionManager->GetDetectorFilePath(); - string calibrationfileName = myOptionManager->GetCalibrationFilePath(); - string runToReadfileName = myOptionManager->GetRunToReadFilePath(); - string OutputfileName = myOptionManager->GetOutputFilePath(); + string reactionfileName = myOptionManager->GetReactionFile(); + string detectorfileName = myOptionManager->GetDetectorFile(); + string calibrationfileName = myOptionManager->GetCalibrationFile(); + string runToReadfileName = myOptionManager->GetRunToReadFile(); + string OutputfileName = myOptionManager->GetOutputFile(); // Instantiate RootInput and RootOutput singleton classes RootInput:: getInstance(runToReadfileName); // RootOutput::getInstance("Analysis/"+OutputfileName, "AnalyzedTree") ; RootOutput::getInstance("Analysis/Gaspard_AnalyzedData", "AnalyzedTree"); - // store configuration files - TString GlobalPath = getenv("NPTOOL"); - // event generator file - TString PathEG = GlobalPath + "/Inputs/EventGenerator/"; - TString EGFileName = PathEG + reactionfileName; - TAsciiFile *asciiFileEG = RootOutput::getInstance()->GetAsciiFileEventGenerator(); - asciiFileEG->SetNameTitle("EventGenerator", "EventGenerator input file"); - asciiFileEG->Append(EGFileName); - // detector configuration file - TString PathDC = GlobalPath + "/Inputs/DetectorConfiguration/"; - TString DCFileName = PathDC + detectorfileName; - TAsciiFile *asciiFileDC = RootOutput::getInstance()->GetAsciiFileDetectorConfiguration(); - asciiFileDC->SetNameTitle("DetectorConfiguration", "DetectorConfiguration input file"); - asciiFileDC->Append(DCFileName); - // detector configuration file - TAsciiFile *asciiFileRF = RootOutput::getInstance()->GetAsciiFileRunToTreat(); - asciiFileRF->SetNameTitle("RunToTreat", "RunToTreat input file"); - asciiFileRF->Append(runToReadfileName.data()); // Initialize the reaction NPL::Reaction* myReaction = new Reaction(); diff --git a/NPAnalysis/Hyde/Makefile b/NPAnalysis/Hyde/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..215794b2868b46e37601e95c6dedb6b1f84d7c11 --- /dev/null +++ b/NPAnalysis/Hyde/Makefile @@ -0,0 +1,10 @@ + +Analyse: + make -C ./src + +clean: + make clean -C ./src + +distclean: + make clean -C ./src + rm Analysis diff --git a/NPAnalysis/Hyde/RunToTreat.txt b/NPAnalysis/Hyde/RunToTreat.txt new file mode 100644 index 0000000000000000000000000000000000000000..c4154eda3701c52a44f90861999892b87872b7e4 --- /dev/null +++ b/NPAnalysis/Hyde/RunToTreat.txt @@ -0,0 +1,7 @@ +TTreeName + SimulatedTree +RootFileName + ../../Outputs/Simulation/myResult.root +% ../../Outputs/Simulation/134Snpt_1h9_10MeVA_T0_B0_E0_S2mm.root +% ../../Outputs/Simulation/132Sndp_3p3_10MeVA_T0_B1_E0_S05mm.root +% ../../Outputs/Simulation/134Snpt_1h9_10MeVA_T1_B1_E0_S05mm.root diff --git a/NPAnalysis/Hyde/include/ObjectManager.hh b/NPAnalysis/Hyde/include/ObjectManager.hh new file mode 100644 index 0000000000000000000000000000000000000000..c2dceafe3fb0c28e8ee6e93e40dd6de47f7791fa --- /dev/null +++ b/NPAnalysis/Hyde/include/ObjectManager.hh @@ -0,0 +1,125 @@ +// You can use this file to declare your spectra, file, energy loss , ... and whatever you want. +// This way you can remove all unnecessary declaration in the main programm. +// In order to help debugging and organizing we use Name Space. + +///////////////////////////////////////////////////////////////////////////////////////////////// +// -------------------------------------- VARIOUS INCLUDE --------------------------------------- + +// NPA +#include "DetectorManager.h" +#include "NPOptionManager.h" +#include "GaspardTracker.h" + +// STL C++ +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <cmath> +#include <cstdlib> + +// ROOT +#include <TROOT.h> +#include <TChain.h> +#include <TFile.h> +#include <TLeaf.h> +#include <TVector3.h> +#include <TRandom3.h> + +// NPL +#include "TMust2Data.h" +#include "TMust2Physics.h" +#include "NPReaction.h" +#include "RootInput.h" +#include "RootOutput.h" +#include "TInteractionCoordinates.h" +#include "TInitialConditions.h" + +// Use CLHEP System of unit and Physical Constant +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "CLHEP/Units/PhysicalConstants.h" + + +// ---------------------------------------------------------------------------------------------- +double ThetaCalculation (TVector3 A , TVector3 B) ; +///////////////////////////////////////////////////////////////////////////////////////////////// +// ----------------------------------- DOUBLE, INT, BOOL AND MORE ------------------------------- +namespace VARIABLE + { + // Declare your Variable here: + + double X1,Y1,Z1 ; + int N1,N2 = 0 ; + bool check= false ; + + // A Usefull Simple Random Generator + TRandom Rand; + } + +using namespace VARIABLE ; +// ---------------------------------------------------------------------------------------------- + + + +///////////////////////////////////////////////////////////////////////////////////////////////// +// -----------------------------------GRAPH------------------------------------------------------ +#include <TObject.h> +#include <TH1.h> +#include <TH1F.h> +#include <TH2.h> +#include <TH2F.h> +#include <TGraph2D.h> + +namespace GRAPH + { + // Declare your Spectra here: + + TH1F *myHist1D = new TH1F("Hist1D","Histogramm 1D ; x ; count", 1000 , -5 , 5 ) ; + + TH2F *myHist2D = new TH2F("Hist2D","Histogramm 2D ; x ; y ", 128 , 1 , 128 , 128 , 1 , 128 ) ; + + } + +using namespace GRAPH ; +// -------------------------------------------------------------------------------------------- + + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// -----------------------------------CUT------------------------------------------------------ +#include <TCutG.h> +namespace CUT + { + // Declare your Cut here: + + } + +using namespace CUT ; +// -------------------------------------------------------------------------------------------- + + + +//////////////////////////////////////////////////////////////////////////////////////////////// +// -----------------------------------ENERGY LOSS---------------------------------------------- +#include "NPEnergyLoss.h" +using namespace NPL ; +namespace ENERGYLOSS +{ + // Declare your Energy loss here +// EnergyLoss LightTargetCD2 = EnergyLoss("proton_cd2.txt", 100, 1, 1); // LISE++ + // For 132Sn(d,p) + EnergyLoss LightTarget = EnergyLoss("proton_CD2.G4table", "G4Table", 1000); // G4 + EnergyLoss BeamTarget = EnergyLoss("Sn132[0.0]_CD2.G4table", "G4Table", 1000); // G4 + // For 134Sn(p,t) +// EnergyLoss LightTarget = EnergyLoss("triton_CH2.G4table", "G4Table", 1000); // G4 +// EnergyLoss BeamTarget = EnergyLoss("Sn134[0.0]_CH2.G4table", "G4Table", 1000); // G4 + // For 132Sn(d,t) +// EnergyLoss LightTarget = EnergyLoss("triton_CD2.G4table", "G4Table", 1000); // G4 +// EnergyLoss BeamTarget = EnergyLoss("Sn132[0.0]_CD2.G4table", "G4Table", 1000); // G4 +} + +using namespace ENERGYLOSS ; +// ---------------------------------------------------------------------------------------------- +///////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/NPAnalysis/Hyde/macros/DisplayInputCrossSection.C b/NPAnalysis/Hyde/macros/DisplayInputCrossSection.C new file mode 100644 index 0000000000000000000000000000000000000000..8f2725bdee1df41051f6b461059aaa6e9f27d5b6 --- /dev/null +++ b/NPAnalysis/Hyde/macros/DisplayInputCrossSection.C @@ -0,0 +1,148 @@ +void DisplayInputCrossSection() +{ + // Path to cross-section files + TString path = gSystem->Getenv("NPTOOL"); + path += "/Inputs/CrossSection/"; + + // Read cross-sections 132Sn(d,p) +/* TGraph *gr1 = new TGraph(path + "132Sndp_5A_MeV_3p3_ZR_FRC.lis"); + TGraph *gr2 = new TGraph(path + "132Sndp_5A_MeV_2f7_ZR_FRC.lis"); + TGraph *gr3 = new TGraph(path + "132Sndp_10A_MeV_3p3_ZR_FRC.lis"); + TGraph *gr4 = new TGraph(path + "132Sndp_10A_MeV_2f7_ZR_FRC.lis");*/ + // Jacques + TGraph *gr1 = ReadCrossSection("132Sndp_5A_MeV_3p3_ZR_FRC.lis"); + TGraph *gr2 = ReadCrossSection("132Sndp_5A_MeV_2f7_ZR_FRC.lis"); + TGraph *gr3 = ReadCrossSection("132Sndp_10A_MeV_3p3_ZR_FRC.lis"); + TGraph *gr4 = ReadCrossSection("132Sndp_10A_MeV_2f7_ZR_FRC.lis"); + // Didier + TGraph *gr5 = new TGraph(path + "sn132dp_gs_10AMeV.txt"); + + // Read cross-section 134Sn(p,t) + // Didier + TGraph *grpt1 = ReadCrossSectionPT("CS_Ep10MeV_sn134pt_gs_1h9demi.dat"); + TGraph *grpt2 = ReadCrossSectionPT("CS_Ep15MeV_sn134pt_gs_1h9demi.dat"); + TGraph *grpt3 = ReadCrossSectionPT("CS_Ep20MeV_sn134pt_gs_1h9demi.dat"); + + // Read cross-section 132Sn(d,d) + // Angel + TGraph *grdd = new TGraph(path + "132Sndd_10A_MeV_ruth.dat"); + TGraph *grpp = new TGraph(path + "132Snpp_10A_MeV_ruth.dat"); + + // Draw cross-sections + TCanvas *can = new TCanvas("can"); + can->SetLogy(); + can->Draw(); +// TH2F *hframe = new TH2F("hframe", "^{2}H(^{132}Sn,p)^{133}Sn", 180, 0, 180, 100, 1e-2, 100); +// TH2F *hframe = new TH2F("hframe", "", 180, 0, 180, 100, 1e-2, 100); +// TH2F *hframe = new TH2F("hframe", "^{1}H(^{134}Sn,t)^{132}Sn_{g.s.}", 180, 0, 180, 100, 1e-8, 1e-5); +// TH2F *hframe = new TH2F("hframe", "", 180, 0, 180, 100, 1e-8, 1e-5); + TH2F *hframe = new TH2F("hframe", "", 180, 0, 180, 100, 1e-3, 10); + hframe->Draw(); + hframe->SetXTitle("#Theta_{c.m.} [deg]"); +// hframe->SetYTitle("d#sigma/d#Omega [mb/sr]"); + hframe->SetYTitle("d#sigma/d#Omega / (d#sigma/d#Omega)_{R}"); +// hframe->SetYTitle("#propto d#sigma/d#Omega"); +/* grpt1->SetLineColor(kRed); grpt1->Draw("l"); + grpt2->SetLineColor(kMagenta); grpt2->Draw("l"); + grpt3->SetLineColor(kBlue); grpt3->Draw("l");*/ +/* gr1->SetLineColor(kRed); gr1->SetLineStyle(2); gr1->Draw("l"); + gr2->SetLineColor(kRed); gr2->Draw("l"); + gr3->SetLineColor(kBlue); gr3->SetLineStyle(2); gr3->Draw("l"); + gr4->SetLineColor(kBlue); gr4->Draw("l");*/ +// gr5->Draw("l"); +// grdd->Draw("l"); + grpp->Draw("l"); + + // TLegend + TLegend *leg = new TLegend(0.50, 0.64, 0.82, 0.84); +// leg->AddEntry(grdd, "10 MeV/u", "l"); + leg->AddEntry(grpp, "10 MeV/u", "l"); +/* TLegend *leg = new TLegend(0.50, 0.64, 0.82, 0.84); + leg->AddEntry(grpt1, "1h9/2 10 MeV/u", "l"); + leg->AddEntry(grpt2, "1h9/2 15 MeV/u", "l"); + leg->AddEntry(grpt3, "1h9/2 20 MeV/u", "l");*/ +/* TLegend *leg = new TLegend(0.16, 0.17, 0.48, 0.37); + leg->AddEntry(gr1, "3p3/2 5 MeV/u", "l"); + leg->AddEntry(gr2, "2f7/2 5 MeV/u", "l"); + leg->AddEntry(gr3, "3p3/2 10 MeV/u", "l"); + leg->AddEntry(gr4, "2f7/2 10 MeV/u", "l");*/ + leg->SetBorderSize(1); + leg->Draw(); + +/* TMultiGraph *mgr = new TMultiGraph(); + mgr->Add(gr1, "lp"); + mgr->Add(gr2, "lp"); + mgr->Add(gr3, "lp"); + mgr->Add(gr4, "lp"); + mgr->Draw("a*");*/ +// gr1->Draw("alp"); +} + + + +TGraph* ReadCrossSection(const char* fname) +{ + // Path to cross-section files + TString path = gSystem->Getenv("NPTOOL"); + path += "/Inputs/CrossSection/"; + + // Open file + ifstream fich; + fich.open(path + fname); + if (!fich) cout << "Probleme d'ouverture dans le fichier " << fname << endl; + + // Read file + Double_t angle, sigma; + Int_t nlines = 0; + TGraph *gr = new TGraph(); + while (fich >> angle >> sigma) { + gr->SetPoint(nlines++, angle, sigma * 15); // 15: fm^2 -> mb + D0^2 + } + + // Close file + fich.close(); + + // TGraph name + gr->SetTitle(fname); + + // test pour savoir si on a bien rempli le TGraph + if (gr->GetN() == 0) + cout << "Mauvaise lecture du fichier --> probablement mauvais format" << endl; + + return gr; +} + + + +TGraph* ReadCrossSectionPT(const char* fname) +{ + // Path to cross-section files + TString path = gSystem->Getenv("NPTOOL"); + path += "/Inputs/CrossSection/"; + + // Open file + ifstream fich; + fich.open(path + fname); + if (!fich) cout << "Probleme d'ouverture dans le fichier " << fname << endl; + + // Read file + Double_t angle, sigma, dum; + Int_t nlines = 0; + TGraph *gr = new TGraph(); +// while (fich >> angle >> sigma >> dum >> dum >> dum >> dum >> dum >> dum >> dum >> dum >> dum) { + while (fich >> angle >> sigma) { + gr->SetPoint(nlines++, angle, sigma); + } + + // Close file + fich.close(); + + // TGraph name + gr->SetTitle(fname); + + // test pour savoir si on a bien rempli le TGraph + if (gr->GetN() == 0) + cout << "Mauvaise lecture du fichier --> probablement mauvais format" << endl; + + return gr; +} diff --git a/NPAnalysis/Hyde/src/Analysis.cc b/NPAnalysis/Hyde/src/Analysis.cc new file mode 100644 index 0000000000000000000000000000000000000000..e77ab008f30204e31a6cc2b816c6b7871f767a61 --- /dev/null +++ b/NPAnalysis/Hyde/src/Analysis.cc @@ -0,0 +1,188 @@ +#include "ObjectManager.hh" + +using namespace std; + + +int main(int argc,char** argv) +{ + // command line parsing + NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); + string reactionfileName = myOptionManager->GetReactionFile(); + string detectorfileName = myOptionManager->GetDetectorFile(); + string calibrationfileName = myOptionManager->GetCalibrationFile(); + string runToReadfileName = myOptionManager->GetRunToReadFile(); + string OutputfileName = myOptionManager->GetOutputFile(); + + // Instantiate RootInput and RootOutput singleton classes + RootInput:: getInstance(runToReadfileName); + RootOutput::getInstance("Analysis/Gaspard_AnalyzedData", "AnalyzedTree"); + + // Initialize the reaction + NPL::Reaction* myReaction = new Reaction(); + myReaction->ReadConfigurationFile(reactionfileName); + + // Initialize the detector + NPA::DetectorManager* myDetector = new DetectorManager; + myDetector->ReadConfigurationFile(detectorfileName); + + // Calculate beam energy at target middle + // Get nominal beam energy + Double_t BeamEnergyNominal = myReaction->GetBeamEnergy() * MeV; + cout << BeamEnergyNominal << endl; + // Slow beam at target middle + Double_t BeamEnergy = BeamEnergyNominal - BeamTarget.Slow(BeamEnergyNominal, myDetector->GetTargetThickness()/2 * micrometer, 0); +// Double_t BeamEnergy = 1293.56 * MeV; + cout << BeamEnergy << endl; + // Set energy beam at target middle + myReaction->SetBeamEnergy(BeamEnergy); + + // Print target thickness + cout << myDetector->GetTargetThickness() << endl; + + // Attach more branch to the output + double Ex = 0 ; double ExNoStrips = 0 ; double EE = 0 ; double TT = 0 ; double X = 0 ; double Y = 0 ; int det ; + RootOutput::getInstance()->GetTree()->Branch("ExcitationEnergy",&Ex,"Ex/D") ; + RootOutput::getInstance()->GetTree()->Branch("ExcitationEnergyNoStrips",&ExNoStrips,"ExNoStrips/D") ; + RootOutput::getInstance()->GetTree()->Branch("E",&EE,"EE/D") ; + RootOutput::getInstance()->GetTree()->Branch("A",&TT,"TT/D") ; + RootOutput::getInstance()->GetTree()->Branch("X",&X,"X/D") ; + RootOutput::getInstance()->GetTree()->Branch("Y",&Y,"Y/D") ; + + // Get GaspardTracker pointer + GaspardTracker* GPDTrack = (GaspardTracker*) myDetector->m_Detector["GASPARD"]; + + // Get the input TChain and treat it + TChain* chain = RootInput:: getInstance() -> GetChain(); + + // Connect TInitialConditions branch + TInitialConditions *initCond = 0; + chain->SetBranchAddress("InitialConditions", &initCond); + chain->SetBranchStatus("InitialConditions", 1); + + // Connect TInteractionCoordinates branch + TInteractionCoordinates *interCoord = 0; + chain->SetBranchAddress("InteractionCoordinates", &interCoord); + chain->SetBranchStatus("InteractionCoordinates", 0); + + // Analysis is here! + int nentries = chain->GetEntries(); + cout << "Number of entries to be analysed: " << nentries << endl; + + // Default initialization + double XTarget = 0; + double YTarget = 0; + double BeamTheta = 0; + double BeamPhi = 0; + + // random generator + TRandom3 *gene = new TRandom3(); + + // Loop on all events + for (int i = 0; i < nentries; i ++) { + if (i%10000 == 0 && i!=0) cout << "\r" << i << " analyzed events" << flush; + chain -> GetEntry(i); + + // Treat Gaspard event + myDetector->ClearEventPhysics(); + myDetector->BuildPhysicalEvent(); + + // Get total energy + double E = GPDTrack->GetEnergyDeposit(); + + // if there is a hit in the detector array, treat it. + double Theta, ThetaStrip, angle, ThetaCM; + double DetecX, DetecY, DetecZ; + double r; + TVector3 A; + if (E > -1000) { + // Get c.m. angle + ThetaCM = initCond->GetICEmittedAngleThetaCM(0) * deg; + + // Get exact scattering angle from TInteractionCoordinates object +// Theta = interCoord->GetDetectedAngleTheta(0) * deg; + DetecX = interCoord->GetDetectedPositionX(0); + DetecY = interCoord->GetDetectedPositionY(0); + DetecZ = interCoord->GetDetectedPositionZ(0); + TVector3 Detec(DetecX, DetecY, DetecZ); + + // Get interaction position in detector + // This takes into account the strips + A = GPDTrack->GetPositionOfInteraction(); + + // Get beam interaction coordinates on target (from initial condition) + XTarget = initCond->GetICPositionX(0); + YTarget = initCond->GetICPositionY(0); +// cout << XTarget << " " << YTarget << endl; + BeamTheta = initCond->GetICIncidentAngleTheta(0)*deg; + BeamPhi = initCond->GetICIncidentAnglePhi(0)*deg; + TVector3 BeamDirection = TVector3(cos(BeamPhi)*sin(BeamTheta), sin(BeamPhi)*sin(BeamTheta), cos(BeamTheta)); +// cout << BeamDirection.X() << " " << BeamDirection.Y() << " " << BeamDirection.Z() << endl; + + // Hit direction taking into account beam position on target + TVector3 HitDirection = A - TVector3(XTarget, YTarget, 0); +// cout << "A: " << A.X() << " " << A.Y() << " " << A.Z() << endl; +// cout << "HitDirection: " << HitDirection.X() << " " << HitDirection.Y() << " " << HitDirection.Z() << endl; + + // Calculate scattering angle w.r.t. optical beam axis (do not take into account beam position on target) + ThetaStrip = ThetaCalculation(A, TVector3(0,0,1)); + Theta = ThetaCalculation(Detec, TVector3(0, 0, 1)); + // Calculate scattering angle w.r.t. beam (ideal case) +// ThetaStrip = ThetaCalculation(HitDirection, BeamDirection); +// Theta = ThetaCalculation(Detec - TVector3(XTarget, YTarget, 0), BeamDirection); + // Calculate scattering angle w.r.t. beam (finite spatial resolution) +/* double resol = 800; // in micrometer + angle = gene->Rndm() * 2*3.14; + r = fabs(gene->Gaus(0, resol)) * micrometer; + ThetaStrip = ThetaCalculation(A - TVector3(XTarget + r*cos(angle), YTarget + r*sin(angle), 0), BeamDirection); + Theta = ThetaCalculation(Detec - TVector3(XTarget + r*cos(angle), YTarget + r*sin(angle), 0), BeamDirection); +*/ + // Correct for energy loss in the target + E = LightTarget.EvaluateInitialEnergy(E, myDetector->GetTargetThickness()/2 * micrometer, ThetaStrip); + + // Calculate excitation energy +// if (Theta/deg > 150 && Theta/deg < 180) { +// if (Theta/deg < 60 && ThetaCM/deg < 90) { +// if (Theta/deg > 35 && Theta/deg < 45 && E/MeV < 17) { +// if (Theta/deg < 45) { + if (E/MeV < 38) { +// if (Theta/deg > 90) { + ExNoStrips = myReaction->ReconstructRelativistic(E, Theta / rad); + Ex = myReaction->ReconstructRelativistic(E, ThetaStrip); + } + else { + Ex = -200; + ExNoStrips = -200; + } + } + else { + Ex = -100; + ExNoStrips = -100; + } + + EE = E ; TT = ThetaStrip/deg; + if (E>-1000) { + X = A . X(); + Y = A . Y(); + } + else { + X = -1000 ; Y = -1000; + } + + // Fill output tree + RootOutput::getInstance()->GetTree()->Fill(); + } + + // delete singleton classes + RootOutput::getInstance()->Destroy(); + RootInput::getInstance()->Destroy(); + + return 0; +} + + +double ThetaCalculation (TVector3 A , TVector3 B) +{ + double Theta = acos( (A.Dot(B)) / (A.Mag()*B.Mag()) ); + return Theta ; +} + diff --git a/NPAnalysis/Hyde/src/GNUmakefile b/NPAnalysis/Hyde/src/GNUmakefile new file mode 100644 index 0000000000000000000000000000000000000000..28c404622cec4d40b2e93aa0009fc4fc4fa97d26 --- /dev/null +++ b/NPAnalysis/Hyde/src/GNUmakefile @@ -0,0 +1,42 @@ +###Make file made by Adrien MATTA/ Institut de Physique Nucleaire d'Orsay IPNO### +# Made to compile the ROOT Analyser for MUST2 experiment + +CPP=g++ +EXEC=Analysis + +# local includes +NPAINCLUDES = ../include + +# ROOT includes +CXXFLAGS += `root-config --cflags` + +# CLHEP includes +CXXFLAGS += -I$(CLHEP_INCLUDE_DIR) +CXXFLAGS += -I$(NPAINCLUDES) +CXXFLAGS += -I$(NPLIB)/include + +LDFLAGS = `root-config --libs` -lMathMore +LDFLAGS+= `$(NPLIB)/liblist` +LDFLAGS+= -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) + +SRC= $(wildcard *.cc) +INC= $(wildcard $(NPAINCLUDES)/*.hh) +OBJ=$(SRC:.cc=.o) + +#all:$(EXEC) +# @$(CPP) -o $@ -c $< $(CXXFLAGS) + +Analysis:$(OBJ) $(INC) + @$(CPP) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) + mv Analysis ../Analysis + +%.o: %.cc + @$(CPP) $(CXXFLAGS) -o $@ -c $< + +.PHONY: clean mrproper + +clean: + rm -rf *.o + +mrproper: clean + rm -rf $(EXEC) diff --git a/NPAnalysis/Paris/src/Analysis.cc b/NPAnalysis/Paris/src/Analysis.cc index 9114a85f91c48beef3ad6f17de987bfec8bd27b7..a7a44608a0cf99cdec9cb0aeac7cccb4359c0732 100644 --- a/NPAnalysis/Paris/src/Analysis.cc +++ b/NPAnalysis/Paris/src/Analysis.cc @@ -8,9 +8,9 @@ int main(int argc,char** argv) { NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv) ; - string detectorfileName = myOptionManager->GetDetectorFilePath() ; - string reactionfileName = myOptionManager->GetCalibrationFilePath() ; - string runToReadfileName = myOptionManager->GetRunToReadFilePath() ; + string detectorfileName = myOptionManager->GetDetectorFile() ; + string reactionfileName = myOptionManager->GetCalibrationFile() ; + string runToReadfileName = myOptionManager->GetRunToReadFile() ; // Instantiate RootInput and RootOutput singleton classes RootInput:: getInstance(runToReadfileName); diff --git a/NPAnalysis/W1/src/Analysis.cc b/NPAnalysis/W1/src/Analysis.cc index d1b7d0a8f0f4e9f8257cb6ed72c373b4500ea09e..532dd5012a40f6735abaaf36b55f6885e250682d 100644 --- a/NPAnalysis/W1/src/Analysis.cc +++ b/NPAnalysis/W1/src/Analysis.cc @@ -7,11 +7,11 @@ int main(int argc,char** argv) { // command line parsing NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); - string reactionfileName = myOptionManager->GetReactionFilePath(); - string detectorfileName = myOptionManager->GetDetectorFilePath(); - string calibrationfileName = myOptionManager->GetCalibrationFilePath(); - string runToReadfileName = myOptionManager->GetRunToReadFilePath(); - string OutputfileName = myOptionManager->GetOutputFilePath(); + string reactionfileName = myOptionManager->GetReactionFile(); + string detectorfileName = myOptionManager->GetDetectorFile(); + string calibrationfileName = myOptionManager->GetCalibrationFile(); + string runToReadfileName = myOptionManager->GetRunToReadFile(); + string OutputfileName = myOptionManager->GetOutputFile(); // Instantiate RootInput and RootOutput singleton classes RootInput:: getInstance(runToReadfileName); diff --git a/NPAnalysis/e530/src/Analysis.cc b/NPAnalysis/e530/src/Analysis.cc index b5b310a87367047487e9bbbaa95525c9afeba6c1..3341fabd5c395d5f5af62e923b9427f60d367c92 100644 --- a/NPAnalysis/e530/src/Analysis.cc +++ b/NPAnalysis/e530/src/Analysis.cc @@ -5,10 +5,10 @@ using namespace std; int main(int argc,char** argv) { NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv) ; - string detectorfileName = myOptionManager->GetDetectorFilePath() ; - string reactionfileName = myOptionManager->GetCalibrationFilePath() ; - string calibrationfileName = myOptionManager->GetCalibrationFilePath() ; - string runToTreatFileName = myOptionManager->GetRunToReadFilePath() ; + string detectorfileName = myOptionManager->GetDetectorFile() ; + string reactionfileName = myOptionManager->GetCalibrationFile() ; + string calibrationfileName = myOptionManager->GetCalibrationFile() ; + string runToTreatFileName = myOptionManager->GetRunToReadFile() ; ///////////////////////////////////////////////////////////////////////////////////////////////////// // First of All instantiate RootInput and Output diff --git a/NPAnalysis/must2/src/Analysis.cc b/NPAnalysis/must2/src/Analysis.cc index 8e030f477f61fdcc461792bd1670004fe360cdbf..f29486ec0fa83e2c29691dedfb56cbe1da63315b 100644 --- a/NPAnalysis/must2/src/Analysis.cc +++ b/NPAnalysis/must2/src/Analysis.cc @@ -10,11 +10,11 @@ int main(int argc,char** argv) { // command line parsing NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); - string reactionfileName = myOptionManager->GetReactionFilePath(); - string detectorfileName = myOptionManager->GetDetectorFilePath(); - string calibrationfileName = myOptionManager->GetCalibrationFilePath(); - string runToReadfileName = myOptionManager->GetRunToReadFilePath(); - string OutputfileName = myOptionManager->GetOutputFilePath(); + string reactionfileName = myOptionManager->GetReactionFile(); + string detectorfileName = myOptionManager->GetDetectorFile(); + string calibrationfileName = myOptionManager->GetCalibrationFile(); + string runToReadfileName = myOptionManager->GetRunToReadFile(); + string OutputfileName = myOptionManager->GetOutputFile(); ///////////////////////////////////////////////////////////////////////////////////////////////////// // First of All instantiate RootInput and Output diff --git a/NPLib/HYDE/HydeTracker.cxx b/NPLib/HYDE/HydeTracker.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3b7192dc83ad6f6ca47880da1621847620ef7ffc --- /dev/null +++ b/NPLib/HYDE/HydeTracker.cxx @@ -0,0 +1,893 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 31/08/09 * + * Last update : 10/09/09 * + *---------------------------------------------------------------------------* + * Decription: This class is mainly an interface to the * + * THydeTrackerPhysics class and it deals with the geometrical* + * correspondance between strip number and absolute coordinates * + * (X, Y, Z) of interaction. * + *---------------------------------------------------------------------------* + * Comment: * + * + 10/09/09: Add support for Square and DummyShape shapes * + * (N. de Sereville) * + * * + * * + *****************************************************************************/ + +#include "HydeTracker.h" + +// C++ headers +#include <iostream> +#include <fstream> +#include <string> +#include <cmath> +#include <stdlib.h> + +// NPL headers +#include "RootInput.h" +#include "RootOutput.h" + +// ROOT headers +#include "TChain.h" + +using namespace std ; + +// Default Constructor + +HydeTracker::HydeTracker() +{ + m_NumberOfModule = 0; + m_EventData = new THydeTrackerData(); + m_EventPhysics = new THydeTrackerPhysics(); +} + + + +HydeTracker::~HydeTracker() +{ + m_NumberOfModule = 0; + delete m_EventData; + delete m_EventPhysics; +} + + + +// Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token +void HydeTracker::ReadConfiguration(string Path) +{ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + TVector3 A, B, C, D; + double Theta = 0, Phi = 0, R = 0, beta_u = 0 , beta_v = 0 , beta_w = 0; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + bool check_beta = false; + + bool ReadingStatus = false; + + bool isSquare = false; + bool isDummyShape = false; + bool isTrapezoid = false; + bool isAnnular = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + + // If line is a HydeXXX bloc, reading toggle to true + // and toggle to true flags indicating which shape is treated. + if (LineBuffer.compare(0, 9, "HYDSquare") == 0 || + LineBuffer.compare(0, 12, "HYDTrapezoid") == 0 || + LineBuffer.compare(0, 10, "HYDAnnular") == 0 || + LineBuffer.compare(0, 13, "HYDDummyShape") == 0) { + cout << "///////////////////////" << endl; + cout << "Module found:" << endl; + + if (LineBuffer.compare(0, 9, "HYDSquare") == 0) isSquare = true; + if (LineBuffer.compare(0, 13, "HYDDummyShape") == 0) isDummyShape = true; + if (LineBuffer.compare(0, 12, "HYDTrapezoid") == 0) isTrapezoid = true; + if (LineBuffer.compare(0, 10, "HYDAnnular") == 0) isAnnular = true; + ReadingStatus = true; + } + // Else don't toggle to Reading Block Status + else ReadingStatus = false; + + // Reading Block + while (ReadingStatus) { + if (isSquare) { // square shape + ConfigFile >> DataBuffer ; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n' ); + } + // Finding another telescope (safety), toggle out + else if (DataBuffer.compare(0, 9, "HYDSquare") == 0) { + cout << "WARNING: Another Module is find before standard sequence of Token, Error may occured in Telecope definition" << endl; + ReadingStatus = false; + } + + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az ; + + A = TVector3(Ax, Ay, Az); + cout << "X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl; + } + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz ; + + B = TVector3(Bx, By, Bz); + cout << "X128 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl; + } + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz ; + + C = TVector3(Cx, Cy, Cz); + cout << "X1 Y128 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl; + } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz ; + + D = TVector3(Dx, Dy, Dz); + cout << "X128 Y128 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl; + } // End Position Method + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta ; + cout << "Theta: " << Theta << endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi ; + cout << "Phi: " << Phi << endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R ; + cout << "R: " << R << endl; + } + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + check_beta = true; + ConfigFile >> DataBuffer ; + beta_u = atof(DataBuffer.c_str()) ; + beta_u = beta_u ; + ConfigFile >> DataBuffer ; + beta_v = atof(DataBuffer.c_str()) ; + beta_v = beta_v ; + ConfigFile >> DataBuffer ; + beta_w = atof(DataBuffer.c_str()) ; + beta_w = beta_w ; + cout << "Beta: " << beta_u << " " << beta_v << " " << beta_w << endl ; + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + if ( (check_A && check_B && check_C && check_D) || (check_Theta && check_Phi && check_R && check_beta) ) { + ReadingStatus = false; + + // Add The previously define telescope + // With position method + if ( check_A && check_B && check_C && check_D ) { + AddModuleSquare(A , + B , + C , + D ) ; + } + + // with angle method + else if ( check_Theta && check_Phi && check_R && check_beta ) { + AddModuleSquare(Theta , + Phi , + R , + beta_u , + beta_v , + beta_w ); + } + + // reset boolean flag for point positioning + check_A = false; + check_B = false; + check_C = false; + check_D = false; + + // reset boolean flag for angle positioning + check_Theta = false; + check_Phi = false; + check_R = false; + check_beta = false; + + // reset boolean flag for shape determination + isSquare = false; + isDummyShape = false; + isTrapezoid = false; + isAnnular = false; + } // end test for adding a module + } // end test for Square shape + + else if (isDummyShape) { // dummyshape shape + ConfigFile >> DataBuffer ; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n' ); + } + // Finding another telescope (safety), toggle out + else if (DataBuffer.compare(0, 13, "HYDDummyShape") == 0) { + cout << "WARNING: Another Module is find before standard sequence of Token, Error may occured in Telecope definition" << endl; + ReadingStatus = false; + } + + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az ; + + A = TVector3(Ax, Ay, Az); + cout << "X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl; + } + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz ; + + B = TVector3(Bx, By, Bz); + cout << "X128 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl; + } + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz ; + + C = TVector3(Cx, Cy, Cz); + cout << "X1 Y128 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl; + } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz ; + + D = TVector3(Dx, Dy, Dz); + cout << "X128 Y128 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl; + } // End Position Method + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta ; + cout << "Theta: " << Theta << endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi ; + cout << "Phi: " << Phi << endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R ; + cout << "R: " << R << endl; + } + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + check_beta = true; + ConfigFile >> DataBuffer ; + beta_u = atof(DataBuffer.c_str()) ; + beta_u = beta_u ; + ConfigFile >> DataBuffer ; + beta_v = atof(DataBuffer.c_str()) ; + beta_v = beta_v ; + ConfigFile >> DataBuffer ; + beta_w = atof(DataBuffer.c_str()) ; + beta_w = beta_w ; + cout << "Beta: " << beta_u << " " << beta_v << " " << beta_w << endl ; + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + if ( (check_A && check_B && check_C && check_D) || (check_Theta && check_Phi && check_R && check_beta) ) { + ReadingStatus = false; + + // Add The previously define telescope + // With position method + if ( check_A && check_B && check_C && check_D ) { + AddModuleDummyShape(A , + B , + C , + D ) ; + } + + // with angle method + else if ( check_Theta && check_Phi && check_R && check_beta ) { + AddModuleDummyShape(Theta, + Phi, + R, + beta_u, + beta_v, + beta_w); + } + + // reset boolean flag for point positioning + check_A = false; + check_B = false; + check_C = false; + check_D = false; + + // reset boolean flag for angle positioning + check_Theta = false; + check_Phi = false; + check_R = false; + check_beta = false; + + // reset boolean flag for shape determination + isSquare = false; + isDummyShape = false; + isTrapezoid = false; + isAnnular = false; + } // end test for adding a module + } // end test for DummyShape shape + + else if (isTrapezoid) { // trapezoid shape + cout << "Trapezoid treatment not implemented yet!" << endl; + } // end test for Trapezoid shape + + else if (isAnnular) { // annular shape + cout << "Annular treatment not implemented yet!" << endl; + } // end test for Annular shape + + } // end while for reading block + } // end while for reading file + + cout << endl << "/////////////////////////////" << endl<<endl; +} + + +// Read stream at Path and pick-up calibration parameter using Token +// If argument is "Simulation" no change calibration is loaded +void HydeTracker::ReadCalibrationFile(string Path) +{ + // Order of Polynom function used for calibration + int Calibration_Si_E_Order; + int Calibration_Si_T_Order; + int Calibration_SiLi_E_Order; + int Calibration_CsI_E_Order; + + // Calibration_Si_X_E[DetectorNumber][StripNumber][Order of Coeff] + vector< vector< vector< double > > > Calibration_Si_X_E ; + vector< vector< vector< double > > > Calibration_Si_X_T ; + vector< vector< vector< double > > > Calibration_Si_Y_E ; + vector< vector< vector< double > > > Calibration_Si_Y_T ; + + // Calibration_SiLi_E[DetectorNumber][PadNumber][Order of Coeff] + vector< vector< vector< double > > > Calibration_SiLi_E ; + + // Calibration_SiLi_E[DetectorNumber][CrystalNumber][Order of Coeff] + vector< vector< vector< double > > > Calibration_CsI_E ; + + if (Path == "Simulation") { // Simulation case: data already calibrated + Calibration_Si_E_Order = 1; + Calibration_Si_T_Order = 1; + Calibration_SiLi_E_Order = 1; + Calibration_CsI_E_Order = 1; + + vector<double> Coef; + // Order 0 Order 1 + Coef.push_back(0) ; Coef.push_back(1) ; + + vector< vector<double> > StripLine ; + StripLine.resize( 128 , Coef) ; + + Calibration_Si_X_E.resize( m_NumberOfModule , StripLine) ; + Calibration_Si_X_T.resize( m_NumberOfModule , StripLine) ; + Calibration_Si_Y_E.resize( m_NumberOfModule , StripLine) ; + Calibration_Si_Y_T.resize( m_NumberOfModule , StripLine) ; + + Calibration_SiLi_E.resize( m_NumberOfModule , StripLine) ; + Calibration_CsI_E .resize( m_NumberOfModule , StripLine) ; + } + else { + } +} + + + +// Activated associated Branches and link it to the private member DetectorData address +// In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated +void HydeTracker::InitializeRootInput() +{ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("HYDE", true); + inputChain->SetBranchStatus("fHYD*", true); + inputChain->SetBranchAddress("HYDE", &m_EventData); +} + + + +// Create associated branches and associated private member DetectorPhysics address +void HydeTracker::InitializeRootOutput() +{ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("HYDE", "THydeTrackerPhysics", &m_EventPhysics); +} + + + +// This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract physical parameter. +void HydeTracker::BuildPhysicalEvent() +{ + m_EventPhysics -> BuildPhysicalEvent(m_EventData); +} + + + +// Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...). +// This method aimed to be used for analysis performed during experiment, when speed is requiered. +// NB: This method can eventually be the same as BuildPhysicalEvent. +void HydeTracker::BuildSimplePhysicalEvent() +{ + m_EventPhysics -> BuildSimplePhysicalEvent(m_EventData); +} + + + +void HydeTracker::AddModuleSquare(TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128) +{ + m_NumberOfModule++; + + // remove warning using C_X128_Y128 + C_X128_Y128.Unit(); + + // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U = C_X128_Y1 - C_X1_Y1; + U = U.Unit(); + + // Vector V on Module Face (parallele to X Strip) + TVector3 V = C_X1_Y128 - C_X1_Y1; + V = V.Unit(); + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0,0,0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + // Geometry Parameter + double Face = 98; // mm + double NumberOfStrip = 128; + double StripPitch = Face/NumberOfStrip; // mm + + // Buffer object to fill Position Array + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector< vector< double > > OneModuleStripPositionX; + vector< vector< double > > OneModuleStripPositionY; + vector< vector< double > > OneModuleStripPositionZ; + + // Moving StripCenter to 1.1 corner: + Strip_1_1 = C_X1_Y1 + (U+V) * (StripPitch/2.); + + for (int i = 0; i < NumberOfStrip; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < NumberOfStrip; j++) { + StripCenter = Strip_1_1 + StripPitch*( i*U + j*V ); +// StripCenter += -TargetPosition; + + lineX.push_back( StripCenter.X() ); + lineY.push_back( StripCenter.Y() ); + lineZ.push_back( StripCenter.Z() ); + } + + OneModuleStripPositionX.push_back(lineX); + OneModuleStripPositionY.push_back(lineY); + OneModuleStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back( OneModuleStripPositionX ); + m_StripPositionY.push_back( OneModuleStripPositionY ); + m_StripPositionZ.push_back( OneModuleStripPositionZ ); +} + + + +void HydeTracker::AddModuleSquare(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w) +{ + m_NumberOfModule++; + + // convert from degree to radian: + double Pi = 3.141592654; + theta = theta * Pi/180. ; + phi = phi * Pi/180. ; + + // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U ; + // Vector V on Module Face (parallele to X Strip) + TVector3 V ; + // Vector W normal to Module Face (pointing CsI) + TVector3 W ; + // Vector position of Module Face center + TVector3 C ; + + C = TVector3(distance * sin(theta) * cos(phi), + distance * sin(theta) * sin(phi), + distance * cos(theta)); + + TVector3 YperpC = TVector3( cos(theta) * cos(phi), + cos(theta) * sin(phi), + -sin(theta)); + + W = C.Unit(); + U = W.Cross(YperpC); + V = W.Cross(U); + + U = U.Unit(); + V = V.Unit(); + + U.Rotate( beta_u * Pi/180. , U ) ; + V.Rotate( beta_u * Pi/180. , U ) ; + + U.Rotate( beta_v * Pi/180. , V ) ; + V.Rotate( beta_v * Pi/180. , V ) ; + + U.Rotate( beta_w * Pi/180. , W ) ; + V.Rotate( beta_w * Pi/180. , W ) ; + + double Face = 98; // mm + //double NumberOfStrip = 25; angelmsb + double NumberOfStrip = 25; + double StripPitch = Face/NumberOfStrip; // mm + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector< vector< double > > OneModuleStripPositionX; + vector< vector< double > > OneModuleStripPositionY; + vector< vector< double > > OneModuleStripPositionZ; + + double X, Y, Z; + + // Moving C to the 1.1 corner: + C.SetX( C.X() - ( Face/2 - StripPitch/2 ) * ( V.X() + U.X() ) ) ; + C.SetY( C.Y() - ( Face/2 - StripPitch/2 ) * ( V.Y() + U.Y() ) ) ; + C.SetZ( C.Z() - ( Face/2 - StripPitch/2 ) * ( V.Z() + U.Z() ) ) ; + + for (int i = 0; i < NumberOfStrip; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < NumberOfStrip; j++) { + X = C.X() + StripPitch * ( U.X()*i + V.X()*j ); + Y = C.Y() + StripPitch * ( U.Y()*i + V.Y()*j ); + Z = C.Z() + StripPitch * ( U.Z()*i + V.Z()*j ); + + lineX.push_back(X); + lineY.push_back(Y); + lineZ.push_back(Z); + } + + OneModuleStripPositionX.push_back(lineX); + OneModuleStripPositionY.push_back(lineY); + OneModuleStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back( OneModuleStripPositionX ); + m_StripPositionY.push_back( OneModuleStripPositionY ); + m_StripPositionZ.push_back( OneModuleStripPositionZ ); +} + + + +void HydeTracker::AddModuleDummyShape(TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128) +{ + m_NumberOfModule++; + + // remove warning using C_X128_Y128 + C_X128_Y128.Unit(); + + // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U = C_X128_Y1 - C_X1_Y1; + U = U.Unit(); + + // Vector V on Module Face (parallele to X Strip) + TVector3 V = C_X1_Y128 - C_X1_Y1; + V = V.Unit(); + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0,0,0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + // Geometry Parameter + double Face = 50; // mm + double NumberOfStrip = 128; + double StripPitch = Face/NumberOfStrip; // mm + + // Buffer object to fill Position Array + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector< vector< double > > OneModuleStripPositionX; + vector< vector< double > > OneModuleStripPositionY; + vector< vector< double > > OneModuleStripPositionZ; + + // Moving StripCenter to 1.1 corner: + Strip_1_1 = C_X1_Y1 + (U+V) * (StripPitch/2.); + + for (int i = 0; i < NumberOfStrip; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < NumberOfStrip; j++) { + StripCenter = Strip_1_1 + StripPitch*( i*U + j*V ); +// StripCenter += -TargetPosition; + + lineX.push_back( StripCenter.X() ); + lineY.push_back( StripCenter.Y() ); + lineZ.push_back( StripCenter.Z() ); + } + + OneModuleStripPositionX.push_back(lineX); + OneModuleStripPositionY.push_back(lineY); + OneModuleStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back( OneModuleStripPositionX ); + m_StripPositionY.push_back( OneModuleStripPositionY ); + m_StripPositionZ.push_back( OneModuleStripPositionZ ); +} + + + +void HydeTracker::AddModuleDummyShape(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w) +{ + m_NumberOfModule++; + + // convert from degree to radian: + double Pi = 3.141592654; + theta = theta * Pi/180. ; + phi = phi * Pi/180. ; + + // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U ; + // Vector V on Module Face (parallele to X Strip) + TVector3 V ; + // Vector W normal to Module Face (pointing CsI) + TVector3 W ; + // Vector position of Module Face center + TVector3 C ; + + C = TVector3(distance * sin(theta) * cos(phi), + distance * sin(theta) * sin(phi), + distance * cos(theta)); + + TVector3 YperpW = TVector3( cos(theta) * cos(phi), + cos(theta) * sin(phi), + -sin(theta)); + + W = C.Unit(); + U = W.Cross(YperpW); + V = W.Cross(U); + + U = U.Unit(); + V = V.Unit(); + + U.Rotate( beta_u * Pi/180. , U ) ; + V.Rotate( beta_u * Pi/180. , U ) ; + + U.Rotate( beta_v * Pi/180. , V ) ; + V.Rotate( beta_v * Pi/180. , V ) ; + + U.Rotate( beta_w * Pi/180. , W ) ; + V.Rotate( beta_w * Pi/180. , W ) ; + + double Face = 50; // mm + double NumberOfStrip = 100; + double StripPitch = Face/NumberOfStrip; // mm + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector< vector< double > > OneModuleStripPositionX; + vector< vector< double > > OneModuleStripPositionY; + vector< vector< double > > OneModuleStripPositionZ; + + double X, Y, Z; + + // Moving C to the 1.1 corner: + C.SetX( C.X() - ( Face/2 - StripPitch/2 ) * ( V.X() + U.X() ) ) ; + C.SetY( C.Y() - ( Face/2 - StripPitch/2 ) * ( V.Y() + U.Y() ) ) ; + C.SetZ( C.Z() - ( Face/2 - StripPitch/2 ) * ( V.Z() + U.Z() ) ) ; + + for (int i = 0; i < NumberOfStrip; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < NumberOfStrip; j++) { + X = C.X() + StripPitch * ( U.X()*i + V.X()*j ); + Y = C.Y() + StripPitch * ( U.Y()*i + V.Y()*j ); + Z = C.Z() + StripPitch * ( U.Z()*i + V.Z()*j ); + + lineX.push_back(X); + lineY.push_back(Y); + lineZ.push_back(Z); + } + + OneModuleStripPositionX.push_back(lineX); + OneModuleStripPositionY.push_back(lineY); + OneModuleStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back( OneModuleStripPositionX ); + m_StripPositionY.push_back( OneModuleStripPositionY ); + m_StripPositionZ.push_back( OneModuleStripPositionZ ); +} + + + +double HydeTracker::GetEnergyDeposit() +{ + if (m_EventPhysics->TotalEnergy.size() > 0) + return m_EventPhysics->TotalEnergy[0]; + else + return -1000; +} + + + +TVector3 HydeTracker::GetPositionOfInteraction() +{ + TVector3 Position = TVector3(-1000,-1000,-1000); + + if (m_EventPhysics->ModuleNumber.size() == 1) { + Position = TVector3(GetStripPositionX(m_EventPhysics->ModuleNumber[0], m_EventPhysics->FirstStage_X[0], m_EventPhysics->FirstStage_Y[0]), + GetStripPositionY(m_EventPhysics->ModuleNumber[0], m_EventPhysics->FirstStage_X[0], m_EventPhysics->FirstStage_Y[0]), + GetStripPositionZ(m_EventPhysics->ModuleNumber[0], m_EventPhysics->FirstStage_X[0], m_EventPhysics->FirstStage_Y[0])); + } + + return(Position); +} + + + +void HydeTracker::Print() +{ + cout << "Number of Modules: " << m_NumberOfModule << endl; + + for (int f = 0; f < m_NumberOfModule; f++) { + cout << "Module " << f+1 << endl; + + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 128; j++) { + cout << i+1 << " "<< j+1 << " " + << m_StripPositionX[f][i][j] << " " + << m_StripPositionY[f][i][j] << " " + << m_StripPositionZ[f][i][j] << " " + << endl ; + } + } + } +} diff --git a/NPLib/HYDE/HydeTracker.h b/NPLib/HYDE/HydeTracker.h new file mode 100644 index 0000000000000000000000000000000000000000..b9668e494354c72b274d843c7f61da883c1212aa --- /dev/null +++ b/NPLib/HYDE/HydeTracker.h @@ -0,0 +1,141 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 31/08/09 * + * Last update : 10/09/09 * + *---------------------------------------------------------------------------* + * Decription: This class is mainly an interface to the * + * THydeTrackerPhysics class and it deals with the geometrical* + * correspondance between strip number and absolute coordinates * + * (X, Y, Z) of interaction. * + *---------------------------------------------------------------------------* + * Comment: * + * + 10/09/09: Add support for Square and DummyShape shapes * + * (N. de Sereville) * + * * + * * + *****************************************************************************/ + +#ifndef HydeTracker_H + +// NPL +#include "../include/VDetector.h" +#include "THydeTrackerData.h" +#include "THydeTrackerPhysics.h" + +// Root +#include "TVector3.h" + +class HydeTracker : public NPA::VDetector +{ +public: + HydeTracker(); + virtual ~HydeTracker(); + +public: + ///////////////////////////////////// + // Innherited from VDetector Class // + ///////////////////////////////////// + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(string); + + // Read stream at CalibFile and pick-up calibration parameter using Token + // If argument is "Simulation" no change calibration is loaded + void ReadCalibrationFile(string); + + // Activated associated Branches and link it to the private member DetectorData address + // In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated + void InitializeRootInput(); + + // Create associated branches and associated private member DetectorPhysics address + void InitializeRootOutput(); + + // This method is called at each event read from the Input Tree. + // The aim is to build treat Raw dat in order to extract physical parameter. + void BuildPhysicalEvent(); + + // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...). + // This method aimed to be used for analysis performed during experiment, when speed is requiered. + // NB: This method can eventually be the same as BuildPhysicalEvent. + void BuildSimplePhysicalEvent(); + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() {m_EventPhysics->Clear();} + void ClearEventData() {m_EventData->Clear();} + + +public: + //////////////////////////////// + // Specific to HydeTracker // + //////////////////////////////// + // Case of a Square module + // Add a Module using Corner Coordinate information + void AddModuleSquare(TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128); + + // Add a Module using R Theta Phi of Si center information + void AddModuleSquare(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w); + + // Case of a DummyShape module + // Add a Module using Corner Coordinate information + void AddModuleDummyShape(TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128); + + // Add a Module using R Theta Phi of Si center information + void AddModuleDummyShape(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w); + + // Getters to retrieve the (X,Y,Z) coordinates of a pixel defined by strips (X,Y) + double GetStripPositionX(int N ,int X ,int Y) { return m_StripPositionX[N-1][X-1][Y-1]; } + double GetStripPositionY(int N ,int X ,int Y) { return m_StripPositionY[N-1][X-1][Y-1]; } + double GetStripPositionZ(int N ,int X ,int Y) { return m_StripPositionZ[N-1][X-1][Y-1]; } + double GetNumberOfModule() { return m_NumberOfModule; } + + // Get Root input and output objects + THydeTrackerData* GetEventData() {return m_EventData;} + THydeTrackerPhysics* GetEventPhysics() {return m_EventPhysics;} + + // To be called after a build Physical Event + double GetEnergyDeposit(); + TVector3 GetPositionOfInteraction(); + + void Print(); + + +private: + //////////////////////////////////////// + // Root Input and Output tree classes // + //////////////////////////////////////// + THydeTrackerData* m_EventData; + THydeTrackerPhysics* m_EventPhysics; + + +private: + // Spatial Position of Strip Calculated on basis of detector position + int m_NumberOfModule; + vector< vector < vector < double > > > m_StripPositionX; + vector< vector < vector < double > > > m_StripPositionY; + vector< vector < vector < double > > > m_StripPositionZ; +}; + +#endif diff --git a/NPLib/HYDE/Makefile b/NPLib/HYDE/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e08dc60e88751c2e8a71d9e0b1dfa686e9ffae38 --- /dev/null +++ b/NPLib/HYDE/Makefile @@ -0,0 +1,44 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libHydeData.so libHydePhysics.so +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## Hyde ## +libHydeData.so: THydeTrackerData.o THydeTrackerDataDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THydeTrackerDataDict.cxx: THydeTrackerData.h + rootcint -f $@ -c $^ + +libHydePhysics.so: HydeTracker.o THydeTrackerPhysics.o THydeTrackerPhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THydeTrackerPhysicsDict.cxx: THydeTrackerPhysics.h + rootcint -f $@ -c $^ + + + +# dependances +HydeTracker.o: HydeTracker.cxx HydeTracker.h +THydeTrackerData.o: THydeTrackerData.cxx THydeTrackerData.h +THydeTrackerPhysics.o: THydeTrackerPhysics.cxx THydeTrackerPhysics.h +####################################### + +############# Clean and More ########## +clean: + @rm -f core *~ *.o *Dict* + +distclean: + make clean; rm -f *.so + +.SUFFIXES: .$(SrcSuf) + +### + +.$(SrcSuf).$(ObjSuf): + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< + + diff --git a/NPLib/HYDE/THydeTrackerData.cxx b/NPLib/HYDE/THydeTrackerData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cd0e27100df0b365eb0c268e3b60a999d4794b3c --- /dev/null +++ b/NPLib/HYDE/THydeTrackerData.cxx @@ -0,0 +1,133 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class stores the results of the G4 simulation for the * + * tracker part of the Hyde detector. * + * The format mimics what was used for the GANIL experiments * + * after conversion of the raw data with GRU. Ask * + * N. de Sereville for more informations. * + * This class derives from TObject (ROOT) and its aim is to be * + * stored in the output TTree of the G4 simulation * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include <iostream> +using namespace std; + +#include "THydeTrackerData.h" + +ClassImp(THydeTrackerData) + +THydeTrackerData::THydeTrackerData() +{ + // Default constructor + + Clear(); +} + + + +THydeTrackerData::~THydeTrackerData() +{ +} + + + +void THydeTrackerData::Clear() +{ + // DSSD + // (X,E) + fHYDTrk_FirstStage_FrontE_DetectorNbr.clear(); + fHYDTrk_FirstStage_FrontE_StripNbr.clear() ; + fHYDTrk_FirstStage_FrontE_Energy.clear() ; + // (X,T) + fHYDTrk_FirstStage_FrontT_DetectorNbr.clear() ; + fHYDTrk_FirstStage_FrontT_StripNbr.clear() ; + fHYDTrk_FirstStage_FrontT_Time.clear() ; + // (Y,E) + fHYDTrk_FirstStage_BackE_DetectorNbr.clear() ; + fHYDTrk_FirstStage_BackE_StripNbr.clear() ; + fHYDTrk_FirstStage_BackE_Energy.clear() ; + // (Y,T) + fHYDTrk_FirstStage_BackT_DetectorNbr.clear() ; + fHYDTrk_FirstStage_BackT_StripNbr.clear() ; + fHYDTrk_FirstStage_BackT_Time.clear() ; + + // Second Stage + // E + fHYDTrk_SecondStage_E_DetectorNbr.clear() ; + fHYDTrk_SecondStage_E_PadNbr.clear() ; + fHYDTrk_SecondStage_E_Energy.clear() ; + // T + fHYDTrk_SecondStage_T_DetectorNbr.clear() ; + fHYDTrk_SecondStage_T_PadNbr.clear() ; + fHYDTrk_SecondStage_T_Time.clear() ; + + // Third Stage + // E + fHYDTrk_ThirdStage_E_DetectorNbr.clear() ; + fHYDTrk_ThirdStage_E_PadNbr.clear() ; + fHYDTrk_ThirdStage_E_Energy.clear() ; + // T + fHYDTrk_ThirdStage_T_DetectorNbr.clear() ; + fHYDTrk_ThirdStage_T_PadNbr.clear() ; + fHYDTrk_ThirdStage_T_Time.clear() ; +} + + + +void THydeTrackerData::Dump() const +{ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event XXXXXXXXXXXXXXXXX" << endl; + + // DSSD + // (X,E) + cout << "HYDTrk_FirstStage_FrontE_Mult = " << fHYDTrk_FirstStage_FrontE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_FirstStage_FrontE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYDTrk_FirstStage_FrontE_DetectorNbr[i] << " Strip: " << fHYDTrk_FirstStage_FrontE_StripNbr[i] << " Energy: " << fHYDTrk_FirstStage_FrontE_Energy[i] << endl; + // (X,T) + cout << "HYDTrk_FirstStage_FrontT_Mult = " << fHYDTrk_FirstStage_FrontT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_FirstStage_FrontT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYDTrk_FirstStage_FrontT_DetectorNbr[i] << " Strip: " << fHYDTrk_FirstStage_FrontT_StripNbr[i] << " Time: " << fHYDTrk_FirstStage_FrontT_Time[i] << endl; + // (Y,E) + cout << "HYDTrk_FirstStage_BackE_Mult = " << fHYDTrk_FirstStage_BackE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_FirstStage_BackE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYDTrk_FirstStage_BackE_DetectorNbr[i] << " Strip: " << fHYDTrk_FirstStage_BackE_StripNbr[i] << " Energy: " << fHYDTrk_FirstStage_BackE_Energy[i] << endl; + // (Y,T) + cout << "HYDTrk_FirstStage_BackT_Mult = " << fHYDTrk_FirstStage_BackT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_FirstStage_BackT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYDTrk_FirstStage_BackT_DetectorNbr[i] << " Strip: " << fHYDTrk_FirstStage_BackT_StripNbr[i] << " Time: " << fHYDTrk_FirstStage_BackT_Time[i] << endl; + + // Second Stage + // Energy + cout << "HYDTrk_SecondStage_E_Mult = " << fHYDTrk_SecondStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_SecondStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYDTrk_SecondStage_E_DetectorNbr[i] << " Pad: " << fHYDTrk_SecondStage_E_PadNbr[i] << " Energy: " << fHYDTrk_SecondStage_E_Energy[i] << endl; + // Time + cout << "HYDTrk_SecondStage_T_Mult = " << fHYDTrk_SecondStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_SecondStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYDTrk_SecondStage_T_DetectorNbr[i] << " Pad: " << fHYDTrk_SecondStage_T_PadNbr[i] << " Time: " << fHYDTrk_SecondStage_T_Time[i] << endl; + + // Third Stage + // Energy + cout << "HYDTrk_ThirdStage_E_Mult = " << fHYDTrk_ThirdStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_ThirdStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYDTrk_ThirdStage_E_DetectorNbr[i] << " Pad: " << fHYDTrk_ThirdStage_E_PadNbr[i] << " Energy: " << fHYDTrk_ThirdStage_E_Energy[i] << endl; + // Time + cout << "HYDTrk_ThirdStage_T_Mult = " << fHYDTrk_ThirdStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYDTrk_ThirdStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYDTrk_ThirdStage_T_DetectorNbr[i] << " Pad: " << fHYDTrk_ThirdStage_T_PadNbr[i] << " Time: " << fHYDTrk_ThirdStage_T_Time[i] << endl; +} diff --git a/NPLib/HYDE/THydeTrackerData.h b/NPLib/HYDE/THydeTrackerData.h new file mode 100644 index 0000000000000000000000000000000000000000..708fd4e32bdac8acca7fcbad787ff393a791e73c --- /dev/null +++ b/NPLib/HYDE/THydeTrackerData.h @@ -0,0 +1,291 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class stores the results of the G4 simulation for the * + * tracker part of the Hyde detector. * + * The format mimics what was used for the GANIL experiments * + * after conversion of the raw data with GRU. Ask * + * N. de Sereville for more informations. * + * This class derives from TObject (ROOT) and its aim is to be * + * stored in the output TTree of the G4 simulation * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef __HYDETRACKERDATA__ +#define __HYDETRACKERDATA__ + +#include <vector> +#include "TObject.h" + +using namespace std ; + +class THydeTrackerData : public TObject +{ +protected: + // First Stage + // Double Sided Silicon Detector + // Front + // Energy + vector<UShort_t> fHYDTrk_FirstStage_FrontE_DetectorNbr; + vector<UShort_t> fHYDTrk_FirstStage_FrontE_StripNbr; + vector<Double_t> fHYDTrk_FirstStage_FrontE_Energy; + // Time + vector<UShort_t> fHYDTrk_FirstStage_FrontT_DetectorNbr; + vector<UShort_t> fHYDTrk_FirstStage_FrontT_StripNbr; + vector<Double_t> fHYDTrk_FirstStage_FrontT_Time; + // Back + // Energy + vector<UShort_t> fHYDTrk_FirstStage_BackE_DetectorNbr; + vector<UShort_t> fHYDTrk_FirstStage_BackE_StripNbr; + vector<Double_t> fHYDTrk_FirstStage_BackE_Energy; + // Time + vector<UShort_t> fHYDTrk_FirstStage_BackT_DetectorNbr; + vector<UShort_t> fHYDTrk_FirstStage_BackT_StripNbr; + vector<Double_t> fHYDTrk_FirstStage_BackT_Time; + + // Second Stage + // Energy + vector<UShort_t> fHYDTrk_SecondStage_E_DetectorNbr; + vector<UShort_t> fHYDTrk_SecondStage_E_PadNbr; + vector<Double_t> fHYDTrk_SecondStage_E_Energy; + // Time + vector<UShort_t> fHYDTrk_SecondStage_T_DetectorNbr; + vector<UShort_t> fHYDTrk_SecondStage_T_PadNbr; + vector<Double_t> fHYDTrk_SecondStage_T_Time; + + // Third Stage + // Energy + vector<UShort_t> fHYDTrk_ThirdStage_E_DetectorNbr; + vector<UShort_t> fHYDTrk_ThirdStage_E_PadNbr; + vector<Double_t> fHYDTrk_ThirdStage_E_Energy; + // Time + vector<UShort_t> fHYDTrk_ThirdStage_T_DetectorNbr; + vector<UShort_t> fHYDTrk_ThirdStage_T_PadNbr; + vector<Double_t> fHYDTrk_ThirdStage_T_Time; + + +public: + THydeTrackerData(); + virtual ~THydeTrackerData(); + + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + ///////////////////// SETTERS //////////////////////// + // DSSD + // (Front, E) + void SetHYDTrkFirstStageFrontEDetectorNbr(UShort_t DetNbr) { + fHYDTrk_FirstStage_FrontE_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkFirstStageFrontEStripNbr(UShort_t StripNbr) { + fHYDTrk_FirstStage_FrontE_StripNbr.push_back(StripNbr); + } + void SetHYDTrkFirstStageFrontEEnergy(Double_t Energy) { + fHYDTrk_FirstStage_FrontE_Energy.push_back(Energy); + } + // (Front, T) + void SetHYDTrkFirstStageFrontTDetectorNbr(UShort_t DetNbr) { + fHYDTrk_FirstStage_FrontT_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkFirstStageFrontTStripNbr(UShort_t StripNbr) { + fHYDTrk_FirstStage_FrontT_StripNbr.push_back(StripNbr); + } + void SetHYDTrkFirstStageFrontTTime(Double_t Time) { + fHYDTrk_FirstStage_FrontT_Time.push_back(Time); + } + + // (Back, E) + void SetHYDTrkFirstStageBackEDetectorNbr(UShort_t DetNbr) { + fHYDTrk_FirstStage_BackE_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkFirstStageBackEStripNbr(UShort_t StripNbr) { + fHYDTrk_FirstStage_BackE_StripNbr.push_back(StripNbr); + } + void SetHYDTrkFirstStageBackEEnergy(Double_t Energy) { + fHYDTrk_FirstStage_BackE_Energy.push_back(Energy); + } + // (Back, T) + void SetHYDTrkFirstStageBackTDetectorNbr(UShort_t DetNbr) { + fHYDTrk_FirstStage_BackT_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkFirstStageBackTStripNbr(UShort_t StripNbr) { + fHYDTrk_FirstStage_BackT_StripNbr.push_back(StripNbr); + } + void SetHYDTrkFirstStageBackTTime(Double_t Time) { + fHYDTrk_FirstStage_BackT_Time.push_back(Time); + } + + // Second Stage + // (E) + void SetHYDTrkSecondStageEDetectorNbr(UShort_t DetNbr) { + fHYDTrk_SecondStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkSecondStageEPadNbr(UShort_t PadNbr) { + fHYDTrk_SecondStage_E_PadNbr.push_back(PadNbr); + } + void SetHYDTrkSecondStageEEnergy(Double_t Energy) { + fHYDTrk_SecondStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYDTrkSecondStageTDetectorNbr(UShort_t DetNbr) { + fHYDTrk_SecondStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkSecondStageTPadNbr(UShort_t PadNbr) { + fHYDTrk_SecondStage_T_PadNbr.push_back(PadNbr); + } + void SetHYDTrkSecondStageTTime(Double_t Time) { + fHYDTrk_SecondStage_T_Time.push_back(Time); + } + + // Third Stage + // (E) + void SetHYDTrkThirdStageEDetectorNbr(UShort_t DetNbr) { + fHYDTrk_ThirdStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkThirdStageEPadNbr(UShort_t PadNbr) { + fHYDTrk_ThirdStage_E_PadNbr.push_back(PadNbr); + } + void SetHYDTrkThirdStageEEnergy(Double_t Energy) { + fHYDTrk_ThirdStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYDTrkThirdStageTDetectorNbr(UShort_t DetNbr) { + fHYDTrk_ThirdStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYDTrkThirdStageTPadNbr(UShort_t PadNbr) { + fHYDTrk_ThirdStage_T_PadNbr.push_back(PadNbr); + } + void SetHYDTrkThirdStageTTime(Double_t Time) { + fHYDTrk_ThirdStage_T_Time.push_back(Time); + } + + + ///////////////////// GETTERS //////////////////////// + // DSSD + // (Front, E) + UShort_t GetHYDTrkFirstStageFrontEMult() { + return fHYDTrk_FirstStage_FrontE_DetectorNbr.size(); + } + UShort_t GetHYDTrkFirstStageFrontEDetectorNbr(Int_t i) { + return fHYDTrk_FirstStage_FrontE_DetectorNbr.at(i); + } + UShort_t GetHYDTrkFirstStageFrontEStripNbr(Int_t i) { + return fHYDTrk_FirstStage_FrontE_StripNbr.at(i); + } + Double_t GetHYDTrkFirstStageFrontEEnergy(Int_t i) { + return fHYDTrk_FirstStage_FrontE_Energy.at(i); + } + // (Front, T) + UShort_t GetHYDTrkFirstStageFrontTMult() { + return fHYDTrk_FirstStage_FrontT_DetectorNbr.size(); + } + UShort_t GetHYDTrkFirstStageFrontTDetectorNbr(Int_t i) { + return fHYDTrk_FirstStage_FrontT_DetectorNbr.at(i); + } + UShort_t GetHYDTrkFirstStageFrontTStripNbr(Int_t i) { + return fHYDTrk_FirstStage_FrontT_StripNbr.at(i); + } + Double_t GetHYDTrkFirstStageFrontTTnergy(Int_t i) { + return fHYDTrk_FirstStage_FrontT_Time.at(i); + } + // (Back, E) + UShort_t GetHYDTrkFirstStageBackEMult() { + return fHYDTrk_FirstStage_BackE_DetectorNbr.size(); + } + UShort_t GetHYDTrkFirstStageBackEDetectorNbr(Int_t i) { + return fHYDTrk_FirstStage_BackE_DetectorNbr.at(i); + } + UShort_t GetHYDTrkFirstStageBackEStripNbr(Int_t i) { + return fHYDTrk_FirstStage_BackE_StripNbr.at(i); + } + Double_t GetHYDTrkFirstStageBackEEnergy(Int_t i) { + return fHYDTrk_FirstStage_BackE_Energy.at(i); + } + // (Back, T) + UShort_t GetHYDTrkFirstStageBackTMult() { + return fHYDTrk_FirstStage_BackT_DetectorNbr.size(); + } + UShort_t GetHYDTrkFirstStageBackTDetectorNbr(Int_t i) { + return fHYDTrk_FirstStage_BackT_DetectorNbr.at(i); + } + UShort_t GetHYDTrkFirstStageBackTStripNbr(Int_t i) { + return fHYDTrk_FirstStage_BackT_StripNbr.at(i); + } + Double_t GetHYDTrkFirstStageBackTTnergy(Int_t i) { + return fHYDTrk_FirstStage_BackT_Time.at(i); + } + + // Second Stage + // (E) + UShort_t GetHYDTrkSecondStageEMult() { + return fHYDTrk_SecondStage_E_DetectorNbr.size(); + } + UShort_t GetHYDTrkSecondStageEDetectorNbr(Int_t i) { + return fHYDTrk_SecondStage_E_DetectorNbr.at(i); + } + UShort_t GetHYDTrkSecondStageEPadNbr(Int_t i) { + return fHYDTrk_SecondStage_E_PadNbr.at(i); + } + Double_t GetHYDTrkSecondStageEEnergy(Int_t i) { + return fHYDTrk_SecondStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYDTrkSecondStageTMult() { + return fHYDTrk_SecondStage_T_DetectorNbr.size(); + } + UShort_t GetHYDTrkSecondStageTDetectorNbr(Int_t i) { + return fHYDTrk_SecondStage_T_DetectorNbr.at(i); + } + UShort_t GetHYDTrkSecondStageTPadNbr(Int_t i) { + return fHYDTrk_SecondStage_T_PadNbr.at(i); + } + Double_t GetHYDTrkSecondStageTTime(Int_t i) { + return fHYDTrk_SecondStage_T_Time.at(i); + } + + // Third Stage + // (E) + UShort_t GetHYDTrkThirdStageEMult() { + return fHYDTrk_ThirdStage_E_DetectorNbr.size(); + } + UShort_t GetHYDTrkThirdStageEDetectorNbr(Int_t i) { + return fHYDTrk_ThirdStage_E_DetectorNbr.at(i); + } + UShort_t GetHYDTrkThirdStageEPadNbr(Int_t i) { + return fHYDTrk_ThirdStage_E_PadNbr.at(i); + } + Double_t GetHYDTrkThirdStageEEnergy(Int_t i) { + return fHYDTrk_ThirdStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYDTrkThirdStageTMult() { + return fHYDTrk_ThirdStage_T_DetectorNbr.size(); + } + UShort_t GetHYDTrkThirdStageTDetectorNbr(Int_t i) { + return fHYDTrk_ThirdStage_T_DetectorNbr.at(i); + } + UShort_t GetHYDTrkThirdStageTPadNbr(Int_t i) { + return fHYDTrk_ThirdStage_T_PadNbr.at(i); + } + Double_t GetHYDTrkThirdStageTTime(Int_t i) { + return fHYDTrk_ThirdStage_T_Time.at(i); + } + + ClassDef(THydeTrackerData, 1) // HydeTrackerData structure +}; + +#endif diff --git a/NPLib/HYDE/THydeTrackerPhysics.cxx b/NPLib/HYDE/THydeTrackerPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5fa21121aec4aa3d56efb28fee5858012fb10061 --- /dev/null +++ b/NPLib/HYDE/THydeTrackerPhysics.cxx @@ -0,0 +1,207 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 31/08/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class stores the physical results after NPAnalysis is run* + * for the tracker part of the Hyde detector. * + * This class derives from TObject (ROOT) and its aim is to be * + * stored in the output TTree of NPAnalysis. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "THydeTrackerPhysics.h" +#include <iostream> +#include <cstdlib> + + +ClassImp(THydeTrackerPhysics) + + +THydeTrackerPhysics::THydeTrackerPhysics() +{ + EventMultiplicity = 0; +} + + + +THydeTrackerPhysics::~THydeTrackerPhysics() +{ + Clear(); +} + + + +void THydeTrackerPhysics::BuildSimplePhysicalEvent(THydeTrackerData* Data) +{ + BuildPhysicalEvent(Data); +} + + + +void THydeTrackerPhysics::BuildPhysicalEvent(THydeTrackerData* Data) +{ + // indexes for each kind of detector + // this should follow the indexes given in NPSimulation + // 0: Square + // 100: Trapezoid + // 200: Annular + // 1000: DummyShape + const int dim = 4; + int index[dim] = {0, 100, 200, 1000}; + + // Check + bool Check_FirstStage = false ;bool Check_SecondStage = false ; bool Check_ThirdStage = false ; + + // Thresholds +/* + double FirstStage_Front_E_Threshold = 0; double FirstStage_Front_T_Threshold = 0; + double FirstStage_Back_E_Threshold = 0; double FirstStage_Back_T_Threshold = 0; + double SecondStage_E_Threshold = 0; double SecondStage_T_Threshold = 0; + double ThirdStage_E_Threshold = 0; double ThirdStage_T_Threshold = 0; +*/ + // calculate multipicity in the first stage + int multXE = Data->GetHYDTrkFirstStageFrontEMult(); + int multYE = Data->GetHYDTrkFirstStageBackEMult(); + int multXT = Data->GetHYDTrkFirstStageFrontTMult(); + int multYT = Data->GetHYDTrkFirstStageBackTMult(); + // calculate multiplicity of 2nd and third stages + int mult2E = Data->GetHYDTrkSecondStageEMult(); + int mult2T = Data->GetHYDTrkSecondStageTMult(); + int mult3E = Data->GetHYDTrkThirdStageEMult(); + int mult3T = Data->GetHYDTrkThirdStageTMult(); + + // Deal with multiplicity 1 for the first layer + if (multXE==1 && multYE==1 && multXT==1 && multYT==1) { + // calculate detector number + int det_ref = Data->GetHYDTrkFirstStageFrontEDetectorNbr(0); + int detecXE = Data->GetHYDTrkFirstStageFrontEDetectorNbr(0) / det_ref; + int detecXT = Data->GetHYDTrkFirstStageFrontTDetectorNbr(0) / det_ref; + int detecYE = Data->GetHYDTrkFirstStageBackEDetectorNbr(0) / det_ref; + int detecYT = Data->GetHYDTrkFirstStageBackTDetectorNbr(0) / det_ref; + // convert detector number in order to it begins at 0 + // this is needed to access the strip position information + // WARNING: this method may not work for an heteregneous detector + // configuration, e.g. Trapezoid + Annular + int good_index = -100; + int diff_ref = 10000; + for (int i = 0; i < dim; i++) { + int diff = abs(det_ref - index[i]); + if (diff < diff_ref) { + diff_ref = diff; + good_index = i; + } + } + det_ref -= index[good_index]; + + // case of same detector + if (detecXE*detecXT*detecYE*detecYT == 1) { + // store module number + ModuleNumber.push_back(det_ref); + // calculate strip number + int stripXE = Data->GetHYDTrkFirstStageFrontEStripNbr(0); + int stripXT = Data->GetHYDTrkFirstStageFrontTStripNbr(0); + int stripYE = Data->GetHYDTrkFirstStageBackEStripNbr(0); + int stripYT = Data->GetHYDTrkFirstStageBackTStripNbr(0); + + // case of same strips on X and Y + if (stripXE == stripXT && stripYE == stripYT) { // here we have a good strip event + // various + Check_FirstStage = true; + EventMultiplicity = 1; + // store strip ID + FirstStage_X.push_back(stripXE); + FirstStage_Y.push_back(stripYE); + // get energy from strips and store it + double EnergyStripFront = Data->GetHYDTrkFirstStageFrontEEnergy(0); +// double EnergyStripBack = Data->GetHYDTrkFirstStageBackEEnergy(0); +// double EnergyStrip = 0.5 * (EnergyStripFront + EnergyStripBack); + double EnergyStrip = EnergyStripFront; +// if (EnergyStripBack > EnergyStrip) EnergyStrip = EnergyStripBack; + FirstStage_E.push_back(EnergyStrip); + double EnergyTot = EnergyStrip; + // get time from strips and store it + double TimeStripFront = Data->GetHYDTrkFirstStageFrontEEnergy(0); + double TimeStripBack = Data->GetHYDTrkFirstStageBackEEnergy(0); + double TimeStrip = 0.5 * (TimeStripFront + TimeStripBack); +// double TimeStrip = TimeStripFront; +// if (TimeStripBack > TimeStrip) TimeStrip = TimeStripBack; + FirstStage_T.push_back(TimeStrip); + + // check if we have a 2nd stage event + if (mult2E==1 && mult2T==1) { + Check_SecondStage = true; + double EnergySecond = Data->GetHYDTrkSecondStageEEnergy(0); + SecondStage_E.push_back(EnergySecond); + EnergyTot += EnergySecond; + } + else if (mult2E>1 || mult2T>1) { + cout << "Warning: multiplicity in second stage greater than in firststage" << endl; + } + // check if we have a third stage event + if (mult3E==1 && mult3T==1) { + Check_ThirdStage = true; + double EnergyThird = Data->GetHYDTrkThirdStageEEnergy(0); + ThirdStage_E.push_back(EnergyThird); + EnergyTot += EnergyThird; + } + else if (mult3E>1 || mult3T>1) { + cout << "Warning: multiplicity in third stage greater than in firststage" << endl; + } + + // Fill total energy + TotalEnergy.push_back(EnergyTot); + } + else { + cout << "Not same strips" << endl; + } + } + else { + cout << "Not same detector" << endl; + } + } + else { +/* cout << "Multiplicity is not one, it is: " << endl; + cout << "\tmultXE: " << multXE << endl; + cout << "\tmultXT: " << multXT << endl; + cout << "\tmultYE: " << multYE << endl; + cout << "\tmultYT: " << multYT << endl;*/ + } +} + + + +void THydeTrackerPhysics::Clear() +{ + EventMultiplicity= 0; + ModuleNumber.clear(); + EventType.clear(); + TotalEnergy.clear(); + + // Si X + FirstStage_E.clear(); + FirstStage_T.clear(); + FirstStage_X.clear(); + FirstStage_Y.clear(); + + // Si(Li) + SecondStage_E.clear(); + SecondStage_T.clear(); + SecondStage_N.clear(); + + // CsI + ThirdStage_E.clear(); + ThirdStage_T.clear(); + ThirdStage_N.clear(); +} diff --git a/NPLib/HYDE/THydeTrackerPhysics.h b/NPLib/HYDE/THydeTrackerPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..37baa79b55bbe0c3a77014dd2e0584f0ce7ab1b3 --- /dev/null +++ b/NPLib/HYDE/THydeTrackerPhysics.h @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 31/08/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class stores the physical results after NPAnalysis is run* + * for the tracker part of the Hyde detector. * + * This class derives from TObject (ROOT) and its aim is to be * + * stored in the output TTree of NPAnalysis. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef THYDETRACKERPHYSICS_H +#define THYDETRACKERPHYSICS_H + +#include <vector> +#include "TObject.h" +#include "THydeTrackerData.h" +#include <cstdlib> + +using namespace std ; + +class THydeTrackerPhysics : public TObject +{ +public: + THydeTrackerPhysics(); + ~THydeTrackerPhysics(); + +public: + void Clear(); + void Clear(const Option_t*) {}; + void BuildPhysicalEvent(THydeTrackerData* Data); + void BuildSimplePhysicalEvent(THydeTrackerData* Data); + +public: + // Provide Physical Multiplicity + Int_t EventMultiplicity; + + // Provide a Classification of Event + vector<int> EventType; + + // Telescope + vector<int> ModuleNumber; + + // FirstStage + vector<double> FirstStage_E; + vector<double> FirstStage_T; + vector<int> FirstStage_X; + vector<int> FirstStage_Y; + + // SecondStage + vector<double> SecondStage_E; + vector<double> SecondStage_T; + vector<int> SecondStage_N; + + // ThirdStage + vector<double> ThirdStage_E; + vector<double> ThirdStage_T; + vector<int> ThirdStage_N; + + // Physical Value + vector<double> TotalEnergy; + + ClassDef(THydeTrackerPhysics,1) // HydeTrackerPHysics structure +}; + +#endif diff --git a/NPLib/IORoot/RootInput.h b/NPLib/IORoot/RootInput.h index 4bda2c705cfd22dcde42c0caf1a40db9176d3697..8d0fb023a2ccd542d661d63451585ff6e3314720 100644 --- a/NPLib/IORoot/RootInput.h +++ b/NPLib/IORoot/RootInput.h @@ -65,7 +65,7 @@ private: public: // Return the private chain - TChain* GetChain() {return pRootChain;}; + TChain* GetChain() {return pRootChain;} // Add a Friend chain to the input chain void AddFriendChain(string RunToAdd); diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx index 41f5f05abfed851d26774266fb1079de1a230189..4b62e2a520f96d75d6149d5eb80f20f4d44255c2 100644 --- a/NPLib/VDetector/DetectorManager.cxx +++ b/NPLib/VDetector/DetectorManager.cxx @@ -6,15 +6,16 @@ #include <cstdlib> // Detector -#include "../MUST2/TMust2Physics.h" -#include "../SSSD/TSSSDPhysics.h" -#include "../Plastic/TPlasticPhysics.h" -#include "../GASPARD/GaspardTracker.h" -#include "../Paris/Paris.h" -#include "../W1/TW1Physics.h" -#include "../Shield/Shield.h" -#include "../Tools/NPOptionManager.h" -#include "../IORoot/RootInput.h" +#include "TMust2Physics.h" +#include "TSSSDPhysics.h" +#include "TPlasticPhysics.h" +#include "GaspardTracker.h" +#include "HydeTracker.h" +#include "Paris.h" +#include "TW1Physics.h" +#include "Shield.h" +#include "NPOptionManager.h" +#include "RootInput.h" ///////////////////////////////////////////////////////////////////////////////////////////////// // Default Constructor DetectorManager::DetectorManager() @@ -45,6 +46,7 @@ void DetectorManager::ReadConfigurationFile(string Path) bool ScintillatorPlastic = false; bool GeneralTarget = false; bool GPDTracker = false; + bool HYDTracker = false; bool ParisDet = false; bool ShieldDet = false; bool W1 = false; @@ -99,6 +101,24 @@ void DetectorManager::ReadConfigurationFile(string Path) AddDetector("GASPARD", myDetector); } //////////////////////////////////////////// + //////////// Search for Hyde //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 11, "HydeTracker") == 0 && HYDTracker == false) { + HYDTracker = true ; + cout << "//////// Hyde Tracker ////////" << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new HydeTracker(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("HYDE", myDetector); + } + //////////////////////////////////////////// ///////////// Search for Paris ///////////// //////////////////////////////////////////// else if (LineBuffer.compare(0, 5, "Paris") == 0 && ParisDet == false) { diff --git a/NPSimulation/include/HydeScorers.hh b/NPSimulation/include/HydeScorers.hh new file mode 100644 index 0000000000000000000000000000000000000000..5246d3f6b33f2678385f5f11e14e171fd538a609 --- /dev/null +++ b/NPSimulation/include/HydeScorers.hh @@ -0,0 +1,299 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 11/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class holds all the scorers needed by the * + * HydeTracker*** objects. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HYDScorer_h +#define HYDScorer_h 1 + +#include "G4VPrimitiveScorer.hh" +#include "G4THitsMap.hh" + +namespace HYDSCORERS +{ + +class HYDScorerFirstStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYDScorerFirstStageEnergy(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerSecondStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYDScorerSecondStageEnergy(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerThirdStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYDScorerThirdStageEnergy(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + + +class HYDScorerFirstStageFrontStripDummyShape : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageFrontStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageFrontStripDummyShape(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageBackStripDummyShape : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageBackStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageBackStripDummyShape(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageFrontStripSquare : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageFrontStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageFrontStripSquare(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageBackStripSquare : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageBackStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageBackStripSquare(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageFrontStripTrapezoid : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageFrontStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageFrontStripTrapezoid(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageBackStripTrapezoid : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageBackStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageBackStripTrapezoid(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageFrontStripAnnular : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageFrontStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageFrontStripAnnular(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4double m_StripPlaneSize; + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + + + +class HYDScorerFirstStageBackStripAnnular : public G4VPrimitiveScorer +{ +public: // with description + HYDScorerFirstStageBackStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, G4int NumberOfStrip = 128); + virtual ~HYDScorerFirstStageBackStripAnnular(); + +protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + +public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void Clear(); + virtual void DrawAll(); + virtual void PrintAll(); + +private: + G4double m_StripPlaneSize; + G4int m_NumberOfStrip ; + G4int HCID; + G4THitsMap<G4double>* EvtMap; +}; + +} + +using namespace HYDSCORERS; +#endif diff --git a/NPSimulation/include/HydeTracker.hh b/NPSimulation/include/HydeTracker.hh new file mode 100644 index 0000000000000000000000000000000000000000..a8ad82ca259fbf63d720931db19b03b478379c13 --- /dev/null +++ b/NPSimulation/include/HydeTracker.hh @@ -0,0 +1,73 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class manages different shapes of module for the Hyde * + * tracker. It allows to have Hyde geometries with an * + * heterogeneous set of modules * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HydeTracker_h +#define HydeTracker_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "VDetector.hh" +#include "HydeTrackerModule.hh" + +using namespace std; + + + +class HydeTracker : public VDetector +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + HydeTracker(); + virtual ~HydeTracker(); + + //////////////////////////////////////////////////// + ///////// Inherite from VDetector class /////////// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path); + + // 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: + // Initialize all scorers necessary for each detector + void InitializeScorers(); + +private: + vector<HydeTrackerModule*> m_Modules; +}; +#endif diff --git a/NPSimulation/include/HydeTrackerAnnular.hh b/NPSimulation/include/HydeTrackerAnnular.hh new file mode 100644 index 0000000000000000000000000000000000000000..47710424818090696a4f53677e622415ea64c2e3 --- /dev/null +++ b/NPSimulation/include/HydeTrackerAnnular.hh @@ -0,0 +1,158 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a module of annular shape for the Hyde tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HydeTrackerAnnular_h +#define HydeTrackerAnnular_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "HydeTrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class HydeTrackerAnnular : public HydeTrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + HydeTrackerAnnular(); + virtual ~HydeTrackerAnnular(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4double PosZ, + G4double Rmin, + G4double Rmax, + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from HydeTrackerModule class ///// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path); + + // 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from HydeTrackerModule + // This is mandatory since the HydeTracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // Used for "By Point Definition" + vector<G4double> m_PosZ; + vector<G4double> m_Rmin; + vector<G4double> m_Rmax; + + // for debugging purpose + G4ThreeVector MMpos; + G4ThreeVector MMu; + G4ThreeVector MMv; + G4ThreeVector MMw; + G4ThreeVector CT; +}; + + + +namespace HYDANNULAR +{ + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0 ;// = 52keV of Resolution // Unit is MeV/2.35 +// const G4double ResoFirstStage = 0.022 ;// = 52keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.055 ;// = 130 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0 ;// = 100 keV of resolution // Unit is MeV/2.35 +// const G4double ResoThirdStage = 0.043 ;// = 100 kev of resolution // Unit is MeV/2.35 + const G4double ResoTimeGpd = 0.212765957 ;// = 500ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979 ;// = 250ps // Unit is ns/2.35 + + // Geometry + const G4double Rmin = 15*mm; + const G4double Rmax = 55*mm; + const G4double Length = 10*mm; + + // First stage +// const G4double AluStripThickness = 0.00000001*micrometer; + const G4double AluStripThickness = 0.4*micrometer; + const G4double FirstStageThickness = 300*micrometer; + const G4double FirstStageRmin = 16*mm; + const G4double FirstStageRmax = 52*mm; +// const G4double VacBoxThickness = 3*cm ; + const G4double VacBoxThickness = 0.4*cm; + + // Third stage + const G4double MylarCsIThickness = 3*micrometer; + const G4double ThirdStageThickness = 1.5*mm; + + // Starting at the front and going in direction of third stage + const G4double AluStripFront_PosZ = Length* -0.5 + 0.5*AluStripThickness ; + const G4double Silicon_PosZ = AluStripFront_PosZ + 0.5*AluStripThickness + 0.5*FirstStageThickness ; + const G4double AluStripBack_PosZ = Silicon_PosZ + 0.5*FirstStageThickness + 0.5*AluStripThickness ; + const G4double VacBox_PosZ = AluStripBack_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness ; + const G4double ThirdStage_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*ThirdStageThickness ; +} + +#endif diff --git a/NPSimulation/include/HydeTrackerDummyShape.hh b/NPSimulation/include/HydeTrackerDummyShape.hh new file mode 100644 index 0000000000000000000000000000000000000000..f05f63d9c113dd39c2fad62f372a98908dde1625 --- /dev/null +++ b/NPSimulation/include/HydeTrackerDummyShape.hh @@ -0,0 +1,195 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 03/09/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a dummy module for the Hyde tracker * + * The goal of this class is to be a starting point to create a * + * new shape to be added to the Hyde tracker. * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HydeTrackerDummyShape_h +#define HydeTrackerDummyShape_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "HydeTrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class HydeTrackerDummyShape : public HydeTrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + HydeTrackerDummyShape(); + virtual ~HydeTrackerDummyShape(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // By Angle Method + void AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from HydeTrackerModule class ///// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path); + + // 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from HydeTrackerModule + // This is mandatory since the HydeTracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | +}; + + + +namespace HYDDUMMYSHAPE +{ + // Resolution +// const G4double ResoFirstStage = 0; // = 50 keV of Resolution // Unit is MeV/2.35 + //const G4double ResoFirstStage = 0.0213; // = 50 keV of Resolution // Unit is MeV/2.35 + const G4double ResoFirstStage = 0.0426; // = 100 keV of Resolution // Unit is MeV/2.35 + //const G4double ResoSecondStage = 0.00426426; // = 100 keV of resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.0128; // = 30 keV of resolution // Unit is MeV/2.35 + //const G4double ResoThirdStage = 0.0426; // = 100 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.0128; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeGpd = 0.212765957;// = 500ps // Unit is ns/2.35 + + // Geometry for the mother volume containing the different layers of your dummy shape module + const G4double FaceFront = 5.1*cm; + const G4double FaceBack = 5.1*cm; + const G4double Length = 1.5*cm; + const G4double InterStageDistance = 7*mm; + // for testing the excitation energy reconstruction +// const G4double Length = 4*cm; +// const G4double InterStageDistance = 15*mm; + + // First stage + const G4double FirstStageFace = 5.0*cm; + //const G4double FirstStageThickness = 300*micrometer; + //const G4double FirstStageThickness = 20*micrometer; + const G4double FirstStageThickness = 100*micrometer; +// const G4double FirstStageThickness = 2*mm; + // for testing the excitation energy reconstruction +// const G4double FirstStageThickness = 1.3*cm; +// const G4int NumberOfStrips = 10; // 5 mm strip pitch +// const G4int NumberOfStrips = 16; // 3.125 mm strip pitch +// const G4int NumberOfStrips = 25; // 2 mm strip pitch +// const G4int NumberOfStrips = 50; // 1 mm strip pitch +// const G4int NumberOfStrips = 64; // 0.781 mm strip pitch +// const G4int NumberOfStrips = 100; // 0.5 mm strip pitch + const G4int NumberOfStrips = 128; // 0.391 mm strip pitch +// const G4int NumberOfStrips = 500; // 0.1 mm strip pitch + + // Second stage + const G4double SecondStageFace = FirstStageFace; + //const G4double SecondStageThickness = 1.5*mm; + const G4double SecondStageThickness = 100*micrometer; + + // Third stage + const G4double ThirdStageFace = FirstStageFace; + //const G4double ThirdStageThickness = 1.5*mm; + const G4double ThirdStageThickness = 10*mm; + + // Starting at the front of the first stage and going to the third stage + const G4double FirstStage_PosZ = Length* -0.5 + 0.5*FirstStageThickness; + const G4double SecondStage_PosZ = Length* -0.5 + 0.5*SecondStageThickness + 1*InterStageDistance; + const G4double ThirdStage_PosZ = Length* -0.5 + 0.5*ThirdStageThickness + 2*InterStageDistance; +} + +#endif diff --git a/NPSimulation/include/HydeTrackerModule.hh b/NPSimulation/include/HydeTrackerModule.hh new file mode 100644 index 0000000000000000000000000000000000000000..217572af03d1cc3d9dcdcf12e0cd91e64c3c0210 --- /dev/null +++ b/NPSimulation/include/HydeTrackerModule.hh @@ -0,0 +1,102 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class is an Abstract Base Class (ABC) from which should * + * derive all different modules from the Hyde tracker. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HydeTrackerModule_h +#define HydeTrackerModule_h 1 + +// C++ headers +#include <string> +#include <vector> + +// G4 headers +#include "G4LogicalVolume.hh" +#include "G4Event.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool - ROOT headers +#include "TInteractionCoordinates.h" +#include "THydeTrackerData.h" + +using namespace std; + + + +class HydeTrackerModule +{ +public: + HydeTrackerModule(); + virtual ~HydeTrackerModule(); + +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + virtual void ReadConfiguration(string Path) = 0; + + // Construct detector and inialise sensitive part. + virtual void ConstructDetector(G4LogicalVolume* world) = 0; + + // Read sensitive part of a the HydeTrackerModule detector and fill the Root tree. + virtual void ReadSensitive(const G4Event* event) = 0; + + // Add Detector branch to the ROOT output tree + virtual void InitializeRootOutput(); + + // Initialize all scorers necessary for each detector + virtual void InitializeScorers() = 0; + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from HydeTrackerModule + // This is mandatory since the HydeTracker*** does not derive from VDetector + virtual void SetInterCoordPointer(TInteractionCoordinates* interCoord) = 0; + virtual TInteractionCoordinates* GetInterCoordPointer() = 0; + + // Initialize the Index map for the different modules of Hyde + void InitializeIndex(); + +public: + THydeTrackerData* GetEventPointer() {return ms_Event;}; + +protected: + // Class to store the result of simulation + static THydeTrackerData* ms_Event; + + // Set to true if you want this stage on you telescope + vector<bool> m_wFirstStage; + vector<bool> m_wSecondStage; + vector<bool> m_wThirdStage; + + // Set to true if you want to see Telescope Frame in your visualisation + bool m_non_sensitive_part_visiualisation; + +protected: + // First stage Associate Scorer + G4MultiFunctionalDetector* m_FirstStageScorer; + + // Second stage Associate Scorer + G4MultiFunctionalDetector* m_SecondStageScorer; + + // Third stage Associate Scorer + G4MultiFunctionalDetector* m_ThirdStageScorer; + +protected: + map<string, int> m_index; +}; + +#endif diff --git a/NPSimulation/include/HydeTrackerSquare.hh b/NPSimulation/include/HydeTrackerSquare.hh new file mode 100644 index 0000000000000000000000000000000000000000..43574df26bb431670c8ffb2394d2d27a99f70d8e --- /dev/null +++ b/NPSimulation/include/HydeTrackerSquare.hh @@ -0,0 +1,192 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a module of square shape for the Hyde tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HydeTrackerSquare_h +#define HydeTrackerSquare_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "HydeTrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class HydeTrackerSquare : public HydeTrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + HydeTrackerSquare(); + virtual ~HydeTrackerSquare(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // By Angle Method + void AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from HydeTrackerModule class ///// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path); + + // 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from HydeTrackerModule + // This is mandatory since the HydeTracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | + + // for debugging purpose + G4ThreeVector MMpos; + G4ThreeVector MMu; + G4ThreeVector MMv; + G4ThreeVector MMw; + G4ThreeVector CT; +}; + + + +namespace HYDSQUARE +{ + // Resolution + const G4double ResoFirstStage = 0 ;// = 52keV of Resolution // Unit is MeV/2.35 +// const G4double ResoFirstStage = 0.022 ;// = 52keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.055 ;// = 130 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0 ;// = 100 keV of resolution // Unit is MeV/2.35 +// const G4double ResoThirdStage = 0.043 ;// = 100 kev of resolution // Unit is MeV/2.35 + const G4double ResoTimeGpd = 0.212765957 ;// = 500ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979 ;// = 250ps // Unit is ns/2.35 + + // Geometry + const G4double FaceFront = 11.*cm ; + const G4double FaceBack = 16.5*cm ; +// const G4double Length = 7.2*cm ; + const G4double Length = 2.0*cm ; + + // First stage +// const G4double AluStripThickness = 0.00000001*micrometer; + const G4double AluStripThickness = 0.4*micrometer ; + const G4double SiliconThickness = 300*micrometer ; + const G4double SiliconFace = 98*mm ; +// const G4double VacBoxThickness = 3*cm ; + const G4double VacBoxThickness = 0.5*cm ; + const G4int NumberOfStrips = 128; + + // Second stage + const G4double SiLiThickness = 5.1*mm ; // Must be checked + const G4double SiLiFaceX = 48.25*mm ; + const G4double SiLiFaceY = 92*mm ; + + // Third stage + const G4double MylarCsIThickness = 3*micrometer; +// const G4double ThirdStageThickness = 1.5*mm; + const G4double ThirdStageThickness = 8.5*mm; + const G4double ThirdStageFaceFront = FaceFront; + const G4double ThirdStageFaceBack = FaceBack; + + // Starting at the front and going to CsI + const G4double AluStripFront_PosZ = Length* -0.5 + 0.5*AluStripThickness ; + const G4double Silicon_PosZ = AluStripFront_PosZ + 0.5*AluStripThickness + 0.5*SiliconThickness ; + const G4double AluStripBack_PosZ = Silicon_PosZ + 0.5*SiliconThickness + 0.5*AluStripThickness ; + const G4double VacBox_PosZ = AluStripBack_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness ; + const G4double ThirdStage_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*ThirdStageThickness ; +} + +#endif diff --git a/NPSimulation/include/HydeTrackerTrapezoid.hh b/NPSimulation/include/HydeTrackerTrapezoid.hh new file mode 100644 index 0000000000000000000000000000000000000000..535a94024c593644b4b6b60e16ddacb6f661b19a --- /dev/null +++ b/NPSimulation/include/HydeTrackerTrapezoid.hh @@ -0,0 +1,195 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define a module of trapezoidal shape for the Hyde tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HydeTrackerTrapezoid_h +#define HydeTrackerTrapezoid_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "HydeTrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class HydeTrackerTrapezoid : public HydeTrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + HydeTrackerTrapezoid(); + virtual ~HydeTrackerTrapezoid(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddModule(G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // By Angle Method + void AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from HydeTrackerModule class ///// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(string Path); + + // 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(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + // Give the static TInteractionCoordinates from VDetector to the classes + // deriving from HydeTrackerModule + // This is mandatory since the HydeTracker*** does not derive from VDetector + void SetInterCoordPointer(TInteractionCoordinates* interCoord); + TInteractionCoordinates* GetInterCoordPointer() {return ms_InterCoord;}; + + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // Interaction Coordinates coming from VDetector through the + // SetInteractionCoordinatesPointer method + TInteractionCoordinates* ms_InterCoord; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | + + // for debugging purpose + G4ThreeVector MMpos; + G4ThreeVector MMu; + G4ThreeVector MMv; + G4ThreeVector MMw; + G4ThreeVector CT; +}; + + + +namespace HYDTRAP +{ + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0 ;// = 52keV of Resolution // Unit is MeV/2.35 +// const G4double ResoFirstStage = 0.022 ;// = 52keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.055 ;// = 130 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0 ;// = 100 keV of resolution // Unit is MeV/2.35 +// const G4double ResoThirdStage = 0.043 ;// = 100 kev of resolution // Unit is MeV/2.35 + const G4double ResoTimeGpd = 0.212765957 ;// = 500ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979 ;// = 250ps // Unit is ns/2.35 + + // Geometry + const G4double Height = 90*mm; + const G4double BaseLarge = 85*mm; + const G4double BaseSmall = 35*mm; + const G4double Length = 20*mm; + + // First stage +// const G4double AluStripThickness = 0.00000001*micrometer; + const G4double AluStripThickness = 0.4*micrometer; + const G4double FirstStageThickness = 300*micrometer; + const G4double FirstStageHeight = 81*mm; + const G4double FirstStageBaseLarge = 78*mm; + const G4double FirstStageBaseSmall = 29*mm; +// const G4double VacBoxThickness = 3*cm ; + const G4double VacBoxThickness = 0.5*cm; + const G4int NumberOfStripsX = 128; + const G4int NumberOfStripsY = 128; + + // Second stage + const G4double SiLiThickness = 5.1*mm ; // Must be checked + const G4double SiLiFaceX = 48.25*mm ; + const G4double SiLiFaceY = 92*mm ; + + // Third stage + const G4double MylarCsIThickness = 3*micrometer; +// const G4double ThirdStageThickness = 1.5*mm; + const G4double ThirdStageThickness = 8.5*mm; +// const G4double ThirdStageFaceFront = FaceFront; +// const G4double ThirdStageFaceBack = FaceBack; + + // Starting at the front and going to CsI + const G4double AluStripFront_PosZ = Length* -0.5 + 0.5*AluStripThickness ; + const G4double Silicon_PosZ = AluStripFront_PosZ + 0.5*AluStripThickness + 0.5*FirstStageThickness ; + const G4double AluStripBack_PosZ = Silicon_PosZ + 0.5*FirstStageThickness + 0.5*AluStripThickness ; + const G4double VacBox_PosZ = AluStripBack_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness ; + const G4double ThirdStage_PosZ = VacBox_PosZ + 0.5*VacBoxThickness + 0.5*ThirdStageThickness ; +} + +#endif diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc index cf656e3bcabe9be17186ab36a108ba0eaba588e1..cd892fa83e096eaf9ff3397a8e85e2775085a02d 100644 --- a/NPSimulation/src/DetectorConstruction.cc +++ b/NPSimulation/src/DetectorConstruction.cc @@ -43,6 +43,7 @@ #include "DummyDetector.hh" #include "MUST2Array.hh" #include "GaspardTracker.hh" +#include "HydeTracker.hh" #include "AnnularS1.hh" #include "Target.hh" #include "Chamber.hh" @@ -163,6 +164,7 @@ void DetectorConstruction::ReadConfigurationFile(string Path) bool cGeneralTarget = false; bool cGeneralChamber = false; bool cGPDTracker = false; // Gaspard Tracker + bool cHYDTracker = false; // Hyde detector bool cS1 = false; bool cPlastic = false; bool cDummy = false; @@ -226,6 +228,26 @@ void DetectorConstruction::ReadConfigurationFile(string Path) } + //////////////////////////////////////////// + //////////// Search for Hyde //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 11, "HydeTracker") == 0 && cHYDTracker == false) { + cHYDTracker = true ; + G4cout << "//////// Hyde Tracker ////////" << G4endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new HydeTracker() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; + } + + //////////////////////////////////////////// //////////// Search for paris //////////// //////////////////////////////////////////// diff --git a/NPSimulation/src/HydeScorers.cc b/NPSimulation/src/HydeScorers.cc new file mode 100644 index 0000000000000000000000000000000000000000..5d84ed4381c26af3d5fc8d9d9c562303bcbe9c20 --- /dev/null +++ b/NPSimulation/src/HydeScorers.cc @@ -0,0 +1,762 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 11/07/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class holds all the scorers needed by the * + * HydeTracker*** objects. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// G4 headers +#include "G4UnitsTable.hh" + +// NPTool headers +#include "GeneralScorers.hh" +#include "HydeScorers.hh" + +#include "HydeTrackerDummyShape.hh" +#include "HydeTrackerSquare.hh" +#include "HydeTrackerTrapezoid.hh" +#include "HydeTrackerAnnular.hh" +using namespace HYDSQUARE; +using namespace HYDTRAP; +using namespace HYDANNULAR; +using namespace HYDDUMMYSHAPE; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Added by Adrien MATTA: +// Those Scorer use TrackID as map index. This way ones can rebuild energy deposit, +// time of flight or position,... particle by particle for each event. Because standard +// scorer provide by G4 don't work this way but using a global ID for each event you should +// not use those scorer with some G4 provided ones or being very carefull doing so. + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Energy Scorer (deal with multiple particle hit) +HYDScorerFirstStageEnergy::HYDScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYDScorerFirstStageEnergy::~HYDScorerFirstStageEnergy() +{ +} + +G4bool HYDScorerFirstStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYDScorerFirstStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageEnergy::DrawAll() +{ +} + +void HYDScorerFirstStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// SecondStage Energy Scorer (deal with multiple particle hit) +HYDScorerSecondStageEnergy::HYDScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYDScorerSecondStageEnergy::~HYDScorerSecondStageEnergy() +{ +} + +G4bool HYDScorerSecondStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYDScorerSecondStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerSecondStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerSecondStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerSecondStageEnergy::DrawAll() +{ +} + +void HYDScorerSecondStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// ThirdStage Energy Scorer (deal with multiple particle hit) +HYDScorerThirdStageEnergy::HYDScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYDScorerThirdStageEnergy::~HYDScorerThirdStageEnergy() +{ +} + +G4bool HYDScorerThirdStageEnergy::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, m_VolumeName); + + // get energy + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->add(DetNbr + index, edep); + return TRUE; +} + +void HYDScorerThirdStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerThirdStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerThirdStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerThirdStageEnergy::DrawAll() +{ +} + +void HYDScorerThirdStageEnergy::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; + G4cout << " PrimitiveScorer " << GetName() << G4endl; + G4cout << " Number of entries " << EvtMap->entries() << G4endl; + std::map<G4int, G4double*>::iterator itr = EvtMap->GetMap()->begin(); + for (; itr != EvtMap->GetMap()->end(); itr++) { + G4cout << " copy no.: " << itr->first + << " energy deposit: " << G4BestUnit(*(itr->second), "Energy") + << G4endl; + } +} + + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for DummyShape geometry +HYDScorerFirstStageFrontStripDummyShape::HYDScorerFirstStageFrontStripDummyShape(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYDScorerFirstStageFrontStripDummyShape::~HYDScorerFirstStageFrontStripDummyShape() +{ +} + +G4bool HYDScorerFirstStageFrontStripDummyShape::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDDummyShape"); + + // get front strip number + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYDDUMMYSHAPE::FirstStageFace / m_NumberOfStrip; + + G4double temp = (POS(0) + HYDDUMMYSHAPE::FirstStageFace / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + + //Rare case where particle is close to edge of silicon plan + if (X == m_NumberOfStrip+1) X = m_NumberOfStrip; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYDScorerFirstStageFrontStripDummyShape::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageFrontStripDummyShape::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageFrontStripDummyShape::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageFrontStripDummyShape::DrawAll() +{ +} + +void HYDScorerFirstStageFrontStripDummyShape::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for DummyShape geometry +HYDScorerFirstStageBackStripDummyShape::HYDScorerFirstStageBackStripDummyShape(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYDScorerFirstStageBackStripDummyShape::~HYDScorerFirstStageBackStripDummyShape() +{ +} + +G4bool HYDScorerFirstStageBackStripDummyShape::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDDummyShape"); + + // get back strip number + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYDDUMMYSHAPE::FirstStageFace / m_NumberOfStrip; + + G4double temp = (POS(1) + HYDDUMMYSHAPE::FirstStageFace / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + //Rare case where particle is close to edge of silicon plan + if (X == m_NumberOfStrip+1) X = m_NumberOfStrip; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYDScorerFirstStageBackStripDummyShape::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageBackStripDummyShape::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageBackStripDummyShape::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageBackStripDummyShape::DrawAll() +{ +} + +void HYDScorerFirstStageBackStripDummyShape::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for Square geometry +HYDScorerFirstStageFrontStripSquare::HYDScorerFirstStageFrontStripSquare(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYDScorerFirstStageFrontStripSquare::~HYDScorerFirstStageFrontStripSquare() +{ +} + +G4bool HYDScorerFirstStageFrontStripSquare::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDSquare"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYDSQUARE::SiliconFace / m_NumberOfStrip; + + G4double temp = (POS(0) + HYDSQUARE::SiliconFace / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + //Rare case where particle is close to edge of silicon plan + if (X == 129) X = 128; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYDScorerFirstStageFrontStripSquare::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageFrontStripSquare::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageFrontStripSquare::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageFrontStripSquare::DrawAll() +{ +} + +void HYDScorerFirstStageFrontStripSquare::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for Square geometry +HYDScorerFirstStageBackStripSquare::HYDScorerFirstStageBackStripSquare(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYDScorerFirstStageBackStripSquare::~HYDScorerFirstStageBackStripSquare() +{ +} + +G4bool HYDScorerFirstStageBackStripSquare::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDSquare"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYDSQUARE::SiliconFace / m_NumberOfStrip; + + G4double temp = (POS(1) + HYDSQUARE::SiliconFace / 2.) / StripPitch ; + G4int temp2 = temp ; + G4double Y = temp2 + 1 ; + //Rare case where particle is close to edge of silicon plan + if (Y == 129) Y = 128; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYDScorerFirstStageBackStripSquare::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageBackStripSquare::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageBackStripSquare::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageBackStripSquare::DrawAll() +{ +} + +void HYDScorerFirstStageBackStripSquare::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for Trapezoid geometry +HYDScorerFirstStageFrontStripTrapezoid::HYDScorerFirstStageFrontStripTrapezoid(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYDScorerFirstStageFrontStripTrapezoid::~HYDScorerFirstStageFrontStripTrapezoid() +{ +} + +G4bool HYDScorerFirstStageFrontStripTrapezoid::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDTrapezoid"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYDTRAP::FirstStageBaseLarge / m_NumberOfStrip; + + G4double temp = (POS(0) + HYDTRAP::FirstStageBaseLarge / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + //Rare case where particle is close to edge of silicon plan + if (X == 129) X = 128; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYDScorerFirstStageFrontStripTrapezoid::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageFrontStripTrapezoid::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageFrontStripTrapezoid::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageFrontStripTrapezoid::DrawAll() +{ +} + +void HYDScorerFirstStageFrontStripTrapezoid::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for Trapezoid geometry +HYDScorerFirstStageBackStripTrapezoid::HYDScorerFirstStageBackStripTrapezoid(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYDScorerFirstStageBackStripTrapezoid::~HYDScorerFirstStageBackStripTrapezoid() +{ +} + +G4bool HYDScorerFirstStageBackStripTrapezoid::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDTrapezoid"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYDTRAP::FirstStageHeight / m_NumberOfStrip; + + G4double temp = (POS(1) + HYDTRAP::FirstStageHeight / 2.) / StripPitch ; + G4int temp2 = temp ; + G4double Y = temp2 + 1 ; + //Rare case where particle is close to edge of silicon plan + if (Y == 129) Y = 128; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYDScorerFirstStageBackStripTrapezoid::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageBackStripTrapezoid::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageBackStripTrapezoid::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageBackStripTrapezoid::DrawAll() +{ +} + +void HYDScorerFirstStageBackStripTrapezoid::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Front Strip position Scorer for Annular geometry +HYDScorerFirstStageFrontStripAnnular::HYDScorerFirstStageFrontStripAnnular(G4String name, G4int depth, G4double StripPlaneSize, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_StripPlaneSize = StripPlaneSize ; + m_NumberOfStrip = NumberOfStrip ; +} + +HYDScorerFirstStageFrontStripAnnular::~HYDScorerFirstStageFrontStripAnnular() +{ +} + +G4bool HYDScorerFirstStageFrontStripAnnular::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDAnnular"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = m_StripPlaneSize / m_NumberOfStrip; + + G4double temp = (POS(0) + m_StripPlaneSize / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + //Rare case where particle is close to edge of silicon plan + if (X == 129) X = 128; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYDScorerFirstStageFrontStripAnnular::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageFrontStripAnnular::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageFrontStripAnnular::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageFrontStripAnnular::DrawAll() +{ +} + +void HYDScorerFirstStageFrontStripAnnular::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// FirstStage Back Strip position Scorer for Annular geometry +HYDScorerFirstStageBackStripAnnular::HYDScorerFirstStageBackStripAnnular(G4String name, G4int depth, G4double StripPlaneSize, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_StripPlaneSize = StripPlaneSize ; + m_NumberOfStrip = NumberOfStrip ; +} + +HYDScorerFirstStageBackStripAnnular::~HYDScorerFirstStageBackStripAnnular() +{ +} + +G4bool HYDScorerFirstStageBackStripAnnular::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYDAnnular"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = m_StripPlaneSize / m_NumberOfStrip; + + G4double temp = (POS(1) + m_StripPlaneSize / 2.) / StripPitch ; + G4int temp2 = temp ; + G4double Y = temp2 + 1 ; + //Rare case where particle is close to edge of silicon plan + if (Y == 129) Y = 128; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYDScorerFirstStageBackStripAnnular::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYDScorerFirstStageBackStripAnnular::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYDScorerFirstStageBackStripAnnular::Clear() +{ + EvtMap->clear(); +} + +void HYDScorerFirstStageBackStripAnnular::DrawAll() +{ +} + +void HYDScorerFirstStageBackStripAnnular::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} diff --git a/NPSimulation/src/HydeTracker.cc b/NPSimulation/src/HydeTracker.cc new file mode 100644 index 0000000000000000000000000000000000000000..8c83646cdbf8a4fb5f3508dbf75d5dde8edcd02e --- /dev/null +++ b/NPSimulation/src/HydeTracker.cc @@ -0,0 +1,191 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class manages different shapes of module for the Hyde * + * tracker. It allows to have Hyde geometries with an * + * heterogeneous set of modules * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <fstream> +#include <sstream> +#include <string> +#include <cmath> + +// NPTool headers +#include "HydeTracker.hh" +#include "HydeTrackerSquare.hh" +#include "HydeTrackerTrapezoid.hh" +#include "HydeTrackerAnnular.hh" +#include "HydeTrackerDummyShape.hh" + +using namespace std; + + +HydeTracker::HydeTracker() +{ +} + + + +HydeTracker::~HydeTracker() +{ +} + + + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void HydeTracker::ReadConfiguration(string Path) +{ + // open configuration file + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + bool HYDTrkSquare = false; + bool HYDTrkTrapezoid = false; + bool HYDTrkAnnular = false; + bool HYDTrkDummyShape = false; + + string LineBuffer; + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 9, "HYDSquare") == 0 && HYDTrkSquare == false) { + HYDTrkSquare = true; + + // instantiate a new "detector" corresponding to the Square elements + HydeTrackerModule* myDetector = new HydeTrackerSquare(); + + // read part of the configuration file corresponding to square elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store HydeTrackerSquare "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 12, "HYDTrapezoid") == 0 && HYDTrkTrapezoid == false) { + HYDTrkTrapezoid = true; + + // instantiate a new "detector" corresponding to the Trapezoid elements + HydeTrackerModule* myDetector = new HydeTrackerTrapezoid(); + + // read part of the configuration file corresponding to trapezoid elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store HydeTrackerTrapezoid "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 10, "HYDAnnular") == 0 && HYDTrkAnnular == false) { + HYDTrkAnnular = true; + + // instantiate a new "detector" corresponding to the Trapezoid elements + HydeTrackerModule* myDetector = new HydeTrackerAnnular(); + + // read part of the configuration file corresponding to trapezoid elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store HydeTrackerTrapezoid "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 13, "HYDDummyShape") == 0 && HYDTrkDummyShape == false) { + HYDTrkDummyShape = true; + + // instantiate a new "detector" corresponding to the Shape elements + // The HydeTrackerSquare class should be replaced by the + // HydeTrackerShape class you need to define + HydeTrackerModule* myDetector = new HydeTrackerDummyShape(); + + // read part of the configuration file corresponding to shape elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // ms_InterCoord comes from VDetector + myDetector->SetInterCoordPointer(ms_InterCoord); + + // store HydeTrackerShape "detector" + m_Modules.push_back(myDetector); + } + } +} + + + +// Construct detector and initialize sensitive part. +// Called After DetecorConstruction::AddDetector Method +void HydeTracker::ConstructDetector(G4LogicalVolume* world) +{ + // loop on sub-detectors belonging to HydeTracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ConstructDetector(world); +} + + + +// Connect the HydeTrackingData class to the output TTree +// of the simulation +void HydeTracker::InitializeRootOutput() +{ + // loop on sub-detectors belonging to HydeTracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->InitializeRootOutput(); +} + + + +// Initialize all scorers necessary for each detector +void HydeTracker::InitializeScorers() +{ + // loop on sub-detectors belonging to HydeTracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->InitializeScorers(); +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAction +void HydeTracker::ReadSensitive(const G4Event* event) +{ + // Before looping on each sub-detector, clear the static variable + // ms_InterCoord + // This is done on the first element of the m_Modules vector. + // This should be done here since this variable (of type TIneractionCoordinates) + // deals with multiplicity of events > 1. + m_Modules[0]->GetInterCoordPointer()->Clear(); + + // We do the same for the static variable ms_Event + m_Modules[0]->GetEventPointer()->Clear(); + + // loop on sub-detectors belonging to HydeTracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ReadSensitive(event); +} diff --git a/NPSimulation/src/HydeTrackerAnnular.cc b/NPSimulation/src/HydeTrackerAnnular.cc new file mode 100644 index 0000000000000000000000000000000000000000..bd4603eb7dcdb5570467ba5ec6eb7613b75b63fa --- /dev/null +++ b/NPSimulation/src/HydeTrackerAnnular.cc @@ -0,0 +1,806 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a module of annular shape for the Hyde tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Box.hh" +#include "G4Tubs.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "HydeTrackerAnnular.hh" +#include "GeneralScorers.hh" +#include "HydeScorers.hh" +#include "THydeTrackerData.h" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYDANNULAR; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerAnnular::HydeTrackerAnnular() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerAnnular::~HydeTrackerAnnular() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerAnnular::AddModule(G4double PosZ, + G4double Rmin, + G4double Rmax, + bool wFirstStage, + bool wSecondStage, + bool wThirdStage) +{ + m_PosZ.push_back(PosZ); + m_Rmin.push_back(Rmin); + m_Rmax.push_back(Rmax); + + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + G4LogicalVolume* world) +{ + G4double NbrTelescopes = TelescopeNumber ; + G4String DetectorNumber ; + ostringstream Number ; + Number << NbrTelescopes ; + DetectorNumber = Number.str() ; + + //////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol ; + G4double density = 0. , a = 0, z = 0 ; + G4int ncomponents = 0, natoms = 0 ; + + 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.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + G4Element* I = new G4Element("Iode" , symbol = "I" , z = 53 , a = 126.9 * g / mole); + G4Element* Cs = new G4Element("Cesium" , symbol = "Cs" , z = 55 , a = 132.9 * g / mole); + + G4Element* Co = new G4Element("Cobalt" , symbol = "Co" , z = 27 , a = 58.933 * g / mole); + G4Element* Cr = new G4Element("Cromium" , symbol = "Cr" , z = 24 , a = 51.996 * g / mole); + G4Element* Ni = new G4Element("Nickel" , symbol = "Ni" , z = 28 , a = 58.69 * g / mole); + G4Element* Fe = new G4Element("Iron" , symbol = "Fe" , z = 26 , a = 55.847 * g / mole); + G4Element* W = new G4Element("Tungsten" , symbol = "W" , z = 74 , a = 183.5 * g / mole); + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Al +// density = 2.702 * g / cm3; +// a = 26.98 * g / mole; +// G4Material* Aluminium = new G4Material("Aluminium", z = 13., a, density); + + // Iron +// density = 7.874 * g / cm3; +// a = 55.847 * g / mole; +// G4Material* Iron = new G4Material("Iron", z = 26., a, density); + + // CsI + density = 4.51 * g / cm3; + G4Material* CsI = new G4Material("CsI", density, ncomponents = 2); + CsI->AddElement(Cs , natoms = 1); + CsI->AddElement(I , natoms = 1); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + // Mylar + density = 1.397 * g / cm3; + G4Material* Myl = new G4Material("Mylar", density, ncomponents = 3); + Myl->AddElement(C, natoms = 10); + Myl->AddElement(H, natoms = 8); + Myl->AddElement(O, natoms = 4); + + // Havar + G4Material* Harvar = new G4Material("Havar", 8.3*g / cm3, 5); + Harvar->AddElement(Co , 42); + Harvar->AddElement(Cr , 20); + Harvar->AddElement(Ni , 13); + Harvar->AddElement(Fe , 19); + Harvar->AddElement(W , 1); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". + // If don't you will have a Warning unused variable 'myPVP' + G4PVPlacement* PVPBuffer ; + + // Name of the module + G4String Name = "HYDAnnular" + DetectorNumber; + + // Definition of the volume containing the sensitive detector + G4Tubs* solidMM = new G4Tubs(Name, + Rmin, + Rmax, + Length/2, + 0*deg, + 360*deg); + +// G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, Iron, Name, 0, 0, 0); + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, Vacuum, Name, 0, 0, 0); + + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , + logicMM , + Name , + world , + false , + 0); + + logicMM->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicMM->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Definition of a vaccuum volume + G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); + + G4Tubs* solidVacBox = new G4Tubs("solidVacBox", + FirstStageRmin, + FirstStageRmax, + VacBoxThickness/2, + 0*deg, + 360*deg); + + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, Vacuum, "logicVacBox", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetectorNumber + "VacBox", logicMM, false, 0); + + logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); + + // Add a degrader plate between Si and CsI: + /* + G4Box* Degrader = new G4Box("Degrader" , 50*mm , 50*mm , 0.1*mm ); + G4LogicalVolume* logicDegrader = new G4LogicalVolume( Degrader , Harvar, "logicDegrader",0,0,0); + PVPBuffer = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicDegrader,"Degrader",logicVacBox,false,0) ; + */ + + //Place two marker to identify the u and v axis on silicon face: + //marker are placed a bit before the silicon itself so they don't perturbate simulation + //Uncomment to help debugging or if you want to understand the way the code work. + //I should recommand to Comment it during simulation to avoid perturbation of simulation + //Remember G4 is limitationg step on geometry constraints. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "logicMarkerU",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; + + G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "logicMarkerV",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; + + G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green + logicMarkerV->SetVisAttributes(MarkerVVisAtt); + */ + + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); + + G4Tubs* solidAluStrip = new G4Tubs("AluBox", + FirstStageRmin, + FirstStageRmax, + AluStripThickness/2, + 0*deg, + 360*deg); + +// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Vacuum, "logicAluStrip", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetectorNumber + "AluStripFront", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetectorNumber + "AluStripBack", logicMM, false, 0); + + logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + + G4Tubs* solidSilicon = new G4Tubs("solidSilicon", + FirstStageRmin, + FirstStageRmax, + FirstStageThickness/2, + 0*deg, + 360*deg); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, Silicon, "logicSilicon", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, 0); + + // Set First Stage sensible + logicSilicon->SetSensitiveDetector(m_FirstStageScorer); + + ///Visualisation of Silicon Strip +// G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)) ; + logicSilicon->SetVisAttributes(SiliconVisAtt) ; + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Tubs* solidThirdStage = new G4Tubs("solidThirdStage", + FirstStageRmin, + FirstStageRmax, + ThirdStageThickness/2, + 0*deg, + 360*deg); + + G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); + + ///Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.)) ; + logicThirdStage->SetVisAttributes(ThirdStageVisAtt) ; +// logicThirdStage->SetVisAttributes(G4VisAttributes::Invisible); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void HydeTrackerAnnular::ReadConfiguration(string Path) +{ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + G4double Z = 0, Rmin = 0, Rmax = 0; + int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0; + + + bool ReadingStatus = false ; + bool check_Z = false ; + bool check_Rmin = false ; + bool check_Rmax = false ; + bool check_FirstStage = false ; + bool check_SecondStage = false ; + bool check_ThirdStage = false ; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 10, "HYDAnnular") == 0) { + G4cout << "///" << G4endl ; + G4cout << "Annular element found: " << G4endl ; + ReadingStatus = true ;} + + while(ReadingStatus){ + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} + + + + //Position method + else if (DataBuffer.compare(0, 2, "Z=") == 0) { + check_Z = true; + ConfigFile >> DataBuffer ; + Z = atof(DataBuffer.c_str()) ; + Z = Z * mm; + cout << "Z: " << Z / mm << endl; + } + + //Position method + else if (DataBuffer.compare(0, 5, "RMIN=") == 0) { + check_Rmin = true; + ConfigFile >> DataBuffer ; + Rmin = atof(DataBuffer.c_str()) ; + Rmin = Rmin * mm; + cout << "Rmin: " << Rmin / mm << endl; + } + + //Position method + else if (DataBuffer.compare(0, 5, "RMAX=") == 0) { + check_Rmax = true; + ConfigFile >> DataBuffer ; + Rmax = atof(DataBuffer.c_str()) ; + Rmax = Rmax * mm; + cout << "Rmax: " << Rmax / mm << endl; + } + + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true ; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true ; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true ; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; + } + + else { + G4cout << "WARNIG: Wrong Token Sequence, HydeTrackerAnnular: Annular Element not added" << G4endl; + } + + if (check_Z && check_Rmin && check_Rmax && check_FirstStage && check_SecondStage && check_ThirdStage) { + + ReadingStatus = false ; + check_Z = false ; + check_Rmin = false ; + check_Rmax = false ; + check_FirstStage = false ; + check_SecondStage = false ; + check_ThirdStage = false ; + + AddModule(Z, + Rmin, + Rmax, + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1); + } + + + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void HydeTrackerAnnular::ConstructDetector(G4LogicalVolume* world) +{ + G4RotationMatrix* MMrot = NULL ; +// G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; + MMpos = G4ThreeVector(0, 0, 0) ; + + bool FirstStage = true ; + bool SecondStage = true ; + bool ThirdStage = true ; + + G4int NumberOfModule = m_PosZ.size() ; + + for (G4int i = 0; i < NumberOfModule; i++) { + // translation to position the module + MMpos = G4ThreeVector(0, 0, m_PosZ[i]); + + // Passage Matrix from Lab Referential to Module Referential + // Identity matrix by default + MMrot = new G4RotationMatrix(); + if (MMpos.z() < 0) MMrot->rotateX(180*deg); + + // Presence of 1st, 2nd and 3rd stage + FirstStage = m_wFirstStage[i] ; + SecondStage = m_wSecondStage[i] ; + ThirdStage = m_wThirdStage[i] ; + + // Build geometry and declare scorers + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world); + } + + delete MMrot ; +} + + + +// Connect the HydeTrackingData class to the output TTree +// of the simulation +void HydeTrackerAnnular::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void HydeTrackerAnnular::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void HydeTrackerAnnular::ReadSensitive(const G4Event* event) +{ +////////////////////////////////////////////////////////////////////////////////////// +//////////////////////// Used to Read Event Map of detector ////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + + // Read the Scorer associated to the first Stage + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/StripNumberX") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/StripNumberY") ; + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDAnnular/InterCoordAngPhi") ; + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; + + // Read the Scorer associated to the Third Stage + //Energy + G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYDAnnular/ThirdStageEnergy") ; + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" + << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << endl ; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYDTrkFirstStageFrontEDetectorNbr(m_index["Annular"] + N); + ms_Event->SetHYDTrkFirstStageFrontTDetectorNbr(m_index["Annular"] + N); + ms_Event->SetHYDTrkFirstStageBackEDetectorNbr(m_index["Annular"] + N); + ms_Event->SetHYDTrkFirstStageBackTDetectorNbr(m_index["Annular"] + N); + + // Energy + for (G4int l = 0 ; l < sizeE ; l++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; + } + + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeT ; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second) ; + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimePPAC) ; + ms_Event->SetHYDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)) ; + ms_Event->SetHYDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)) ; + } + Time_itr++; + } + + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEStripNbr(X) ; + ms_Event->SetHYDTrkFirstStageFrontTStripNbr(X) ; + } + + X_itr++; + } + + // Y + Y_itr = YHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < sizeY ; h++) { + G4int YTrackID = Y_itr->first - N ; + G4double Y = *(Y_itr->second) ; + if (YTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageBackEStripNbr(Y) ; + ms_Event->SetHYDTrkFirstStageBackTStripNbr(Y) ; + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosXTrackID = Pos_X_itr->first - N ; + G4double PosX = *(Pos_X_itr->second) ; + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX) ; + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosYTrackID = Pos_Y_itr->first - N ; + G4double PosY = *(Pos_Y_itr->second) ; + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY) ; + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosZTrackID = Pos_Z_itr->first - N ; + G4double PosZ = *(Pos_Z_itr->second) ; + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ) ; + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; + G4double AngTheta = *(Ang_Theta_itr->second) ; + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + // Second Stage + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYDTrkThirdStageEPadNbr(1); + ms_Event->SetHYDTrkThirdStageTPadNbr(1); + ms_Event->SetHYDTrkThirdStageTTime(1); + ms_Event->SetHYDTrkThirdStageTDetectorNbr(m_index["Annular"] + N); + ms_Event->SetHYDTrkThirdStageEDetectorNbr(m_index["Annular"] + N); + } + + ThirdStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap ->clear(); + EnergyHitMap ->clear(); + TimeHitMap ->clear(); + XHitMap ->clear(); + YHitMap ->clear(); + PosXHitMap ->clear(); + PosYHitMap ->clear(); + PosZHitMap ->clear(); + AngThetaHitMap ->clear(); + AngPhiHitMap ->clear(); + ThirdStageEnergyHitMap ->clear(); + } +} + + + +void HydeTrackerAnnular::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYDAnnular"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYDAnnular", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYDAnnular", 0); + G4VPrimitiveScorer* Energy = new HYDScorerFirstStageEnergy("StripEnergy", "HYDAnnular", 0); + G4VPrimitiveScorer* StripPositionX = new HYDScorerFirstStageFrontStripAnnular("StripNumberX", 0, FirstStageRmax, 128); + G4VPrimitiveScorer* StripPositionY = new HYDScorerFirstStageBackStripAnnular("StripNumberY", 0, FirstStageRmax, 128); + + //and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYDAnnular"); + G4VPrimitiveScorer* SecondStageEnergy = new HYDScorerSecondStageEnergy("SecondStageEnergy", "HYDAnnular", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYDAnnular"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYDScorerThirdStageEnergy("ThirdStageEnergy", "HYDAnnular", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +} diff --git a/NPSimulation/src/HydeTrackerDummyShape.cc b/NPSimulation/src/HydeTrackerDummyShape.cc new file mode 100644 index 0000000000000000000000000000000000000000..dd3183a52cedbd556c0d6329b89fc5b7a5a789fb --- /dev/null +++ b/NPSimulation/src/HydeTrackerDummyShape.cc @@ -0,0 +1,978 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 03/09/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a dummy module for the Hyde tracker * + * The goal of this class is to be a starting point to create a * + * new shape to be added to the Hyde tracker. * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 07/09/09: Fix bug for placing module with (r,theta,phi) method. * + * (N. de Sereville) * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Trd.hh" +#include "G4Box.hh" +#include "G4Trap.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "HydeTrackerDummyShape.hh" +#include "GeneralScorers.hh" +#include "HydeScorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYDDUMMYSHAPE; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerDummyShape::HydeTrackerDummyShape() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerDummyShape::~HydeTrackerDummyShape() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerDummyShape::AddModule(G4ThreeVector X1_Y1 , + G4ThreeVector X128_Y1 , + G4ThreeVector X1_Y128 , + G4ThreeVector X128_Y128 , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage) +{ + m_DefinitionType.push_back(true) ; + + m_X1_Y1.push_back(X1_Y1) ; + m_X128_Y1.push_back(X128_Y1) ; + m_X1_Y128.push_back(X1_Y128) ; + m_X128_Y128.push_back(X128_Y128) ; + + m_R.push_back(0) ; + m_Theta.push_back(0) ; + m_Phi.push_back(0) ; + m_beta_u.push_back(0) ; + m_beta_v.push_back(0) ; + m_beta_w.push_back(0) ; + + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; + +// m_wNumberStrip.push_back(wNumberStrip); +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerDummyShape::AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage) +{ + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_X1_Y1.push_back(empty) ; + m_X128_Y1.push_back(empty) ; + m_X1_Y128.push_back(empty) ; + m_X128_Y128.push_back(empty) ; + + m_R.push_back(R) ; + m_Theta.push_back(Theta) ; + m_Phi.push_back(Phi) ; + m_beta_u.push_back(beta_u) ; + m_beta_v.push_back(beta_v) ; + m_beta_w.push_back(beta_w) ; + + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerDummyShape::VolumeMaker(G4int TelescopeNumber, + G4ThreeVector MMpos, + G4RotationMatrix* MMrot, + bool wFirstStage, + bool wSecondStage, + bool wThirdStage, + G4LogicalVolume* world) +{ + G4double NbrTelescopes = TelescopeNumber ; + G4String DetectorNumber ; + ostringstream Number ; + Number << NbrTelescopes ; + DetectorNumber = Number.str() ; + + ///////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol; + G4double density = 0. , a = 0, z = 0; + G4int ncomponents = 0; + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Vacuum + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". + // If don't you will have a Warning unused variable 'myPVP' + G4PVPlacement* PVPBuffer; + G4String Name = "HYDDummyShape" + DetectorNumber ; + + G4Box* solidHYDDummyShape = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); + G4LogicalVolume* logicHYDDummyShape = new G4LogicalVolume(solidHYDDummyShape, Vacuum, Name, 0, 0, 0); + + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , + logicHYDDummyShape , + Name , + world , + false , + 0); + + logicHYDDummyShape->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicHYDDummyShape->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + //Place two marker to identify the u and v axis on silicon face: + //marker are placed a bit before the silicon itself so they don't perturbate simulation + //Uncomment to help debugging or if you want to understand the way the code work. + //I should recommand to Comment it during simulation to avoid perturbation of simulation + //Remember G4 is limitationg step on geometry constraints. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "logicMarkerU",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; + + G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "logicMarkerV",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; + + G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green + logicMarkerV->SetVisAttributes(MarkerVVisAtt); + */ + + //////////////////////////////////////////////////////////////// + ///////////////// First Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageThickness); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, Silicon, "logicFirstStage", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, + positionFirstStage, + logicFirstStage, +// "G" + DetectorNumber + "FirstStage", + Name + "_FirstStage", + logicHYDDummyShape, + false, + 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + ///Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 0.2)); + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////////// Second Stage Construction //////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Box* solidSecondStage = new G4Box("solidSecondStage", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageThickness); + G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, Silicon, "logicSecondStage", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, + positionSecondStage, + logicSecondStage, +// "G" + DetectorNumber + "SecondStage", + Name + "_SecondStage", + logicHYDDummyShape, + false, + 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + ///Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + logicSecondStage->SetVisAttributes(SecondStageVisAtt) ; + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageThickness); + G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, + positionThirdStage, + logicThirdStage, +// "G" + DetectorNumber + "ThirdStage", + Name + "_ThirdStage", + logicHYDDummyShape, + false, + 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + ///Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)); + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void HydeTrackerDummyShape::ReadConfiguration(string Path) +{ + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer, DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; + G4ThreeVector A , B , C , D ; + G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; + int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 ; + int NSTRIP = 128; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + bool check_beta = false; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_NStrip = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 13, "HYDDummyShape") == 0) { + G4cout << "///" << G4endl ; + G4cout << "DummyShape element found: " << G4endl ; + ReadingStatus = true ; + } + + while (ReadingStatus) { + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} + + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax * mm ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay * mm ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az * mm ; + + A = G4ThreeVector(Ax, Ay, Az); + cout << "X1 Y1 corner position : " << A << endl; + } + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx * mm ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By * mm ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz * mm ; + + B = G4ThreeVector(Bx, By, Bz); + cout << "X128 Y1 corner position : " << B << endl; + } + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx * mm ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy * mm ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz * mm ; + + C = G4ThreeVector(Cx, Cy, Cz); + cout << "X1 Y128 corner position : " << C << endl; + } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx * mm ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy * mm ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz * mm ; + + D = G4ThreeVector(Dx, Dy, Dz); + cout << "X128 Y128 corner position : " << D << endl; + } + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta * deg; + cout << "Theta: " << Theta / deg << endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi * deg; + cout << "Phi: " << Phi / deg << endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R * mm; + cout << "R: " << R / mm << endl; + } + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + check_beta = true; + ConfigFile >> DataBuffer ; + beta_u = atof(DataBuffer.c_str()) ; + beta_u = beta_u * deg ; + ConfigFile >> DataBuffer ; + beta_v = atof(DataBuffer.c_str()) ; + beta_v = beta_v * deg ; + ConfigFile >> DataBuffer ; + beta_w = atof(DataBuffer.c_str()) ; + beta_w = beta_w * deg ; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; + } + + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true ; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()) ; + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true ; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()) ; + } + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true ; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 7, "NSTRIP=") == 0) { + check_NStrip = true ; + ConfigFile >> DataBuffer; + NSTRIP = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true ; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; + } + + else G4cout << "WARNING: Wrong Token, HydeTrackerDummyShape: DummyShape Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1); + } + + // With angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + check_beta = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1); + } + } + } +} + + + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void HydeTrackerDummyShape::ConstructDetector(G4LogicalVolume* world) +{ + G4RotationMatrix* MMrot = NULL ; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; + bool FirstStage = true ; + bool SecondStage = true ; + bool ThirdStage = true ; + + G4int NumberOfTelescope = m_DefinitionType.size() ; + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + + MMv = m_X1_Y128[i] - m_X1_Y1[i]; + MMv = MMv.unit(); + + G4ThreeVector MMscal = MMu.dot(MMv); + + MMw = MMu.cross(MMv); +// if (MMw.z() > 0) MMw = MMv.cross(MMu) ; + MMw = MMw.unit(); + + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i] ; + G4double Phi = m_Phi[i] ; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + G4ThreeVector CT = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + CT ; + } + + FirstStage = m_wFirstStage[i] ; + SecondStage = m_wSecondStage[i] ; + ThirdStage = m_wThirdStage[i] ; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world); + } + + delete MMrot ; +} + + + +// Connect the HydeTrackingData class to the output TTree +// of the simulation +void HydeTrackerDummyShape::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void HydeTrackerDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void HydeTrackerDummyShape::ReadSensitive(const G4Event* event) +{ + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr ; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL ; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr ; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL ; + + + // Read the Scorer associate to the Silicon Strip + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/StripIDFront") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/StripIDBack"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDDummyShape/InterCoordAngPhi") ; + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; + + + // Read the Scorer associate to the SecondStage + //Energy + G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYDDummyShape/SecondStageEnergy") ; + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; + + + // Read the Scorer associate to the ThirdStage + //Energy + G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYDDummyShape/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" + << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << endl ; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYDTrkFirstStageFrontEDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetHYDTrkFirstStageFrontTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetHYDTrkFirstStageBackEDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetHYDTrkFirstStageBackTDetectorNbr(m_index["DummyShape"] + N); + + // Energy + for (G4int l = 0 ; l < sizeE ; l++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; + } + + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeT ; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimeGpd); + ms_Event->SetHYDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)); + ms_Event->SetHYDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)); + } + Time_itr++; + } + + // Strip X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYDTrkFirstStageFrontTStripNbr(X); + } + X_itr++; + } + + // Strip Y + Y_itr = YHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < sizeY ; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYDTrkFirstStageBackTStripNbr(Y); + } + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosXTrackID = Pos_X_itr->first - N ; + G4double PosX = *(Pos_X_itr->second) ; + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX) ; + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosYTrackID = Pos_Y_itr->first - N ; + G4double PosY = *(Pos_Y_itr->second) ; + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY) ; + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosZTrackID = Pos_Z_itr->first - N ; + G4double PosZ = *(Pos_Z_itr->second) ; + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ) ; + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; + G4double AngTheta = *(Ang_Theta_itr->second) ; + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N ; + G4double AngPhi = *(Ang_Phi_itr->second) ; + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; + } + Ang_Phi_itr++; + } + + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYDTrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)) ; + ms_Event->SetHYDTrkSecondStageEPadNbr(1); + ms_Event->SetHYDTrkSecondStageTPadNbr(1); + ms_Event->SetHYDTrkSecondStageTTime(1); + ms_Event->SetHYDTrkSecondStageTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetHYDTrkSecondStageEDetectorNbr(m_index["DummyShape"] + N); + } + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYDTrkThirdStageEPadNbr(1); + ms_Event->SetHYDTrkThirdStageTPadNbr(1); + ms_Event->SetHYDTrkThirdStageTTime(1); + ms_Event->SetHYDTrkThirdStageTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetHYDTrkThirdStageEDetectorNbr(m_index["DummyShape"] + N); + } + ThirdStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap -> clear(); + EnergyHitMap -> clear(); + TimeHitMap -> clear(); + XHitMap -> clear(); + YHitMap -> clear(); + PosXHitMap -> clear(); + PosYHitMap -> clear(); + PosZHitMap -> clear(); + AngThetaHitMap -> clear(); + AngPhiHitMap -> clear(); + SecondStageEnergyHitMap -> clear(); + ThirdStageEnergyHitMap -> clear(); + } +} + + + +void HydeTrackerDummyShape::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYDDummyShape"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYDDummyShape", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYDDummyShape", 0); + G4VPrimitiveScorer* Energy = new HYDScorerFirstStageEnergy("StripEnergy", "HYDDummyShape", 0); + G4VPrimitiveScorer* StripPositionX = new HYDScorerFirstStageFrontStripDummyShape("StripIDFront", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new HYDScorerFirstStageBackStripDummyShape("StripIDBack", 0, NumberOfStrips); + + //and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + + // Second stage Associate Scorer + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYDDummyShape"); + G4VPrimitiveScorer* SecondStageEnergy = new HYDScorerSecondStageEnergy("SecondStageEnergy", "HYDDummyShape", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYDDummyShape"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYDScorerThirdStageEnergy("ThirdStageEnergy", "HYDDummyShape", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +} diff --git a/NPSimulation/src/HydeTrackerModule.cc b/NPSimulation/src/HydeTrackerModule.cc new file mode 100644 index 0000000000000000000000000000000000000000..9ddf93f440fe8d85fe91aaa6e957316ef875548d --- /dev/null +++ b/NPSimulation/src/HydeTrackerModule.cc @@ -0,0 +1,63 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: This class is an Abstract Base Class (ABC) from which should * + * derive all different modules from the Hyde tracker. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "HydeTrackerModule.hh" +#include "RootOutput.h" + + +THydeTrackerData *HydeTrackerModule::ms_Event = 0; + + + +HydeTrackerModule::HydeTrackerModule() +{ + if (ms_Event == 0) ms_Event = new THydeTrackerData(); + + InitializeRootOutput(); + InitializeIndex(); +} + + + +HydeTrackerModule::~HydeTrackerModule() +{ +} + + + +void HydeTrackerModule::InitializeRootOutput() +{ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + // if the branch does not exist yet, create it + if (!pTree->GetBranch("HYDE")) + pTree->Branch("HYDE", "THydeTrackerData", &ms_Event); +} + + + +void HydeTrackerModule::InitializeIndex() +{ + m_index["Square"] = 0; + m_index["Trapezoid"] = 100; + m_index["Annular"] = 200; + m_index["DummyShape"] = 1000; +} diff --git a/NPSimulation/src/HydeTrackerSquare.cc b/NPSimulation/src/HydeTrackerSquare.cc new file mode 100644 index 0000000000000000000000000000000000000000..1287fb3a64ad6f2d66f603aaa0c85ba8630ea953 --- /dev/null +++ b/NPSimulation/src/HydeTrackerSquare.cc @@ -0,0 +1,1161 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 10/06/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a module of square shape for the Hyde tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 07/09/09: Fix bug for placing module with (r,theta,phi) method. * + * (N. de Sereville) * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Trd.hh" +#include "G4Box.hh" +#include "G4Trap.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "HydeTrackerSquare.hh" +#include "GeneralScorers.hh" +#include "HydeScorers.hh" +#include "RootOutput.h" +#include "MUST2Array.hh" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYDSQUARE; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerSquare::HydeTrackerSquare() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerSquare::~HydeTrackerSquare() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerSquare::AddModule(G4ThreeVector X1_Y1 , + G4ThreeVector X128_Y1 , + G4ThreeVector X1_Y128 , + G4ThreeVector X128_Y128 , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage) +{ + m_DefinitionType.push_back(true) ; + + m_X1_Y1.push_back(X1_Y1) ; + m_X128_Y1.push_back(X128_Y1) ; + m_X1_Y128.push_back(X1_Y128) ; + m_X128_Y128.push_back(X128_Y128) ; + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; + + m_R.push_back(0) ; + m_Theta.push_back(0) ; + m_Phi.push_back(0) ; + m_beta_u.push_back(0) ; + m_beta_v.push_back(0) ; + m_beta_w.push_back(0) ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerSquare::AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage) +{ + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R) ; + m_Theta.push_back(Theta) ; + m_Phi.push_back(Phi) ; + m_beta_u.push_back(beta_u) ; + m_beta_v.push_back(beta_v) ; + m_beta_w.push_back(beta_w) ; + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; + + m_X1_Y1.push_back(empty) ; + m_X128_Y1.push_back(empty) ; + m_X1_Y128.push_back(empty) ; + m_X128_Y128.push_back(empty) ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerSquare::VolumeMaker(G4int TelescopeNumber, + G4ThreeVector MMpos, + G4RotationMatrix* MMrot, + bool wFirstStage, + bool wSecondStage, + bool wThirdStage, + G4LogicalVolume* world) +{ + G4double NbrTelescopes = TelescopeNumber ; + G4String DetectorNumber ; + ostringstream Number ; + Number << NbrTelescopes ; + DetectorNumber = Number.str() ; + + ///////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol ; + G4double density = 0. , a = 0, z = 0 ; + G4int ncomponents = 0, natoms = 0 ; + + 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.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + G4Element* I = new G4Element("Iode" , symbol = "I" , z = 53 , a = 126.9 * g / mole); + G4Element* Cs = new G4Element("Cesium" , symbol = "Cs" , z = 55 , a = 132.9 * g / mole); + + G4Element* Co = new G4Element("Cobalt" , symbol = "Co" , z = 27 , a = 58.933 * g / mole); + G4Element* Cr = new G4Element("Cromium" , symbol = "Cr" , z = 24 , a = 51.996 * g / mole); + G4Element* Ni = new G4Element("Nickel" , symbol = "Ni" , z = 28 , a = 58.69 * g / mole); + G4Element* Fe = new G4Element("Iron" , symbol = "Fe" , z = 26 , a = 55.847 * g / mole); + G4Element* W = new G4Element("Tungsten" , symbol = "W" , z = 74 , a = 183.5 * g / mole); + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Al + density = 2.702 * g / cm3; + a = 26.98 * g / mole; + G4Material* Aluminium = new G4Material("Aluminium", z = 13., a, density); + + // Iron +// density = 7.874 * g / cm3; +// a = 55.847 * g / mole; +// G4Material* Iron = new G4Material("Iron", z = 26., a, density); + + // CsI + density = 4.51 * g / cm3; + G4Material* CsI = new G4Material("CsI", density, ncomponents = 2); + CsI->AddElement(Cs , natoms = 1); + CsI->AddElement(I , natoms = 1); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + // Mylar + density = 1.397 * g / cm3; + G4Material* Myl = new G4Material("Mylar", density, ncomponents = 3); + Myl->AddElement(C, natoms = 10); + Myl->AddElement(H, natoms = 8); + Myl->AddElement(O, natoms = 4); + + // Havar + G4Material* Harvar = new G4Material("Havar", 8.3*g / cm3, 5); + Harvar->AddElement(Co , 42); + Harvar->AddElement(Cr , 20); + Harvar->AddElement(Ni , 13); + Harvar->AddElement(Fe , 19); + Harvar->AddElement(W , 1); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". + // If don't you will have a Warning unused variable 'myPVP' + G4PVPlacement* PVPBuffer ; + + G4Trd* solidMM = new G4Trd("HYDSquare" + DetectorNumber, 0.5*FaceFront, 0.5*FaceFront, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); +// G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, Iron, "HYDSquare" + DetectorNumber, 0, 0, 0) ; + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, Vacuum, "HYDSquare" + DetectorNumber, 0, 0, 0) ; + + G4String Name = "HYDSquare" + DetectorNumber ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , + logicMM , + Name , + world , + false , + 0); + + logicMM->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicMM->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); + + G4Trd* solidVacBox = new G4Trd("solidVacBox", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*VacBoxThickness); + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, Vacuum, "logicVacBox", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetectorNumber + "VacBox", logicMM, false, 0); + + logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); + + // Add a degrader plate between Si and CsI: + /* + G4Box* Degrader = new G4Box("Degrader" , 50*mm , 50*mm , 0.1*mm ); + G4LogicalVolume* logicDegrader = new G4LogicalVolume( Degrader , Harvar, "logicDegrader",0,0,0); + PVPBuffer = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicDegrader,"Degrader",logicVacBox,false,0) ; + */ + + //Place two marker to identify the u and v axis on silicon face: + //marker are placed a bit before the silicon itself so they don't perturbate simulation + //Uncomment to help debugging or if you want to understand the way the code work. + //I should recommand to Comment it during simulation to avoid perturbation of simulation + //Remember G4 is limitationg step on geometry constraints. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "logicMarkerU",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; + + G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "logicMarkerV",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; + + G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green + logicMarkerV->SetVisAttributes(MarkerVVisAtt); + */ + + //////////////////////////////////////////////////////////////// + /////////////////Si Strip Construction////////////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); + + G4Box* solidAluStrip = new G4Box("AluBox", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*AluStripThickness); +// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Vacuum, "logicAluStrip", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetectorNumber + "AluStripFront", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetectorNumber + "AluStripBack", logicMM, false, 0); + + logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + + G4Box* solidSilicon = new G4Box("solidSilicon", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, Silicon, "logicSilicon", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, 0); + + + // Set First Stage sensible + logicSilicon->SetSensitiveDetector(m_FirstStageScorer); + + ///Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + logicSilicon->SetVisAttributes(SiliconVisAtt) ; + } + + //////////////////////////////////////////////////////////////// + //////////////////// SiLi Construction //////////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + G4double SiLiSpace = 8 * mm; + + G4RotationMatrix* rotSiLi = Rotation(0., 0., 0.); + + G4ThreeVector positionSiLi = G4ThreeVector(-0.25 * SiliconFace - 0.5 * SiLiSpace, 0, 0); + G4ThreeVector positionSiLi2 = G4ThreeVector(0.25 * SiliconFace + 0.5 * SiLiSpace, 0, 0); + + G4Box* solidSiLi = new G4Box("SiLi", 0.5*SiLiFaceX, 0.5*SiLiFaceY, 0.5*SiLiThickness); + + G4LogicalVolume* logicSiLi = new G4LogicalVolume(solidSiLi, Aluminium, "SiLi" + DetectorNumber, 0, 0, 0); + + // First Si(Li) 2 time 4 detectore + PVPBuffer = new G4PVPlacement(G4Transform3D(*rotSiLi, positionSiLi) , + logicSiLi , + "SiLi" + DetectorNumber , + logicVacBox , + false , + 0); + + // Second Si(Li) 2 time 4 detectore + PVPBuffer = new G4PVPlacement(G4Transform3D(*rotSiLi, positionSiLi2) , + logicSiLi , + "SiLi" + DetectorNumber , + logicVacBox , + false , + 1); + + // SiLi are placed inside of the VacBox... + // Left/Right define when looking to detector from Si to CsI + G4double SiLi_HighY_Upper = 19.86 * mm; + G4double SiLi_HighY_Center = 25.39 * mm ; + G4double SiLi_WidthX_Left = 22.85 * mm; + G4double SiLi_WidthX_Right = 24.9 * mm ; + G4double SiLi_ShiftX = 0.775 * mm ; + + // SiLi : left side of SiLi detector + G4Box* solidSiLi_LT = new G4Box("SiLi_LT" , 0.5*SiLi_WidthX_Left , 0.5*SiLi_HighY_Upper , 0.5*SiLiThickness); + G4Box* solidSiLi_RT = new G4Box("SiLi_RT" , 0.5*SiLi_WidthX_Right , 0.5*SiLi_HighY_Upper , 0.5*SiLiThickness); + G4Box* solidSiLi_LC1 = new G4Box("SiLi_LC1" , 0.5*SiLi_WidthX_Left , 0.5*SiLi_HighY_Center , 0.5*SiLiThickness); + G4Box* solidSiLi_RC1 = new G4Box("SiLi_RC1" , 0.5*SiLi_WidthX_Right , 0.5*SiLi_HighY_Center , 0.5*SiLiThickness); + G4Box* solidSiLi_LB = new G4Box("SiLi_LB" , 0.5*SiLi_WidthX_Left , 0.5*SiLi_HighY_Upper , 0.5*SiLiThickness); + G4Box* solidSiLi_RB = new G4Box("SiLi_RB" , 0.5*SiLi_WidthX_Right , 0.5*SiLi_HighY_Upper , 0.5*SiLiThickness); + G4Box* solidSiLi_LC2 = new G4Box("SiLi_LC2" , 0.5*SiLi_WidthX_Left , 0.5*SiLi_HighY_Center , 0.5*SiLiThickness); + G4Box* solidSiLi_RC2 = new G4Box("SiLi_RC2" , 0.5*SiLi_WidthX_Right , 0.5*SiLi_HighY_Center , 0.5*SiLiThickness); + + G4LogicalVolume* logicSiLi_LT = new G4LogicalVolume(solidSiLi_LT , Silicon , "SiLi_LT" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_RT = new G4LogicalVolume(solidSiLi_RT , Silicon , "SiLi_RT" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_LC1 = new G4LogicalVolume(solidSiLi_LC1 , Silicon , "SiLi_LC1" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_RC1 = new G4LogicalVolume(solidSiLi_RC1 , Silicon , "SiLi_RC1" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_LB = new G4LogicalVolume(solidSiLi_LB , Silicon , "SiLi_LB" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_RB = new G4LogicalVolume(solidSiLi_RB , Silicon , "SiLi_RB" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_LC2 = new G4LogicalVolume(solidSiLi_LC2 , Silicon , "SiLi_LC2" , 0 , 0 , 0); + G4LogicalVolume* logicSiLi_RC2 = new G4LogicalVolume(solidSiLi_RC2 , Silicon , "SiLi_RC2" , 0 , 0 , 0); + + G4double interSiLi = 0.5 * mm; + + // Top + G4ThreeVector positionSiLi_LT = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX , + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi , + 0); + + G4ThreeVector positionSiLi_RT = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX , + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi , + 0); + + G4ThreeVector positionSiLi_LC1 = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX , + 0.5 * SiLi_HighY_Center + 0.5 * interSiLi , + 0); + + G4ThreeVector positionSiLi_RC1 = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX , + 0.5 * SiLi_HighY_Center + 0.5 * interSiLi , + 0); + + // Bottom + G4ThreeVector positionSiLi_LB = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX , + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi , + 0); + + G4ThreeVector positionSiLi_RB = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX , + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi , + 0); + + G4ThreeVector positionSiLi_LC2 = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX , + -0.5 * SiLi_HighY_Center - 0.5 * interSiLi , + 0); + + G4ThreeVector positionSiLi_RC2 = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX , + -0.5 * SiLi_HighY_Center - 0.5 * interSiLi , + 0); + + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LT , logicSiLi_LT , Name + "_SiLi_LT" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RT , logicSiLi_RT , Name + "_SiLi_RT" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LC1 , logicSiLi_LC1 , Name + "_SiLi_LC1" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RC1 , logicSiLi_RC1 , Name + "_SiLi_RC1" , logicSiLi , false , 0) ; + + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LB , logicSiLi_LB , Name + "_SiLi_LB" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RB , logicSiLi_RB , Name + "_SiLi_RB" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_LC2 , logicSiLi_LC2 , Name + "_SiLi_LC2" , logicSiLi , false , 0) ; + PVPBuffer = new G4PVPlacement(0 , positionSiLi_RC2 , logicSiLi_RC2 , Name + "_SiLi_RC2" , logicSiLi , false , 0) ; + + logicSiLi->SetVisAttributes(G4VisAttributes(G4Colour(1, 1., 1.))); + + // Set Second Stage sensible + logicSiLi_LT->SetSensitiveDetector(m_SecondStageScorer); + logicSiLi_RT->SetSensitiveDetector(m_SecondStageScorer); + logicSiLi_LC1->SetSensitiveDetector(m_SecondStageScorer); + logicSiLi_RC1->SetSensitiveDetector(m_SecondStageScorer); + + logicSiLi_LB->SetSensitiveDetector(m_SecondStageScorer); + logicSiLi_RB->SetSensitiveDetector(m_SecondStageScorer); + logicSiLi_LC2->SetSensitiveDetector(m_SecondStageScorer); + logicSiLi_RC2->SetSensitiveDetector(m_SecondStageScorer); + + // Mark blue a SiLi to see telescope orientation + logicSiLi_LT->SetVisAttributes(G4VisAttributes(G4Colour(0, 0., 1.))); + logicSiLi_RT->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + logicSiLi_LC1->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + logicSiLi_RC1->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + + logicSiLi_LB->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + logicSiLi_RB->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + logicSiLi_LC2->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + logicSiLi_RC2->SetVisAttributes(G4VisAttributes(G4Colour(0, 1., 0))); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + +// G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThirdStageThickness); + G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*FaceFront, 0.5*FaceFront, 0.5*ThirdStageThickness); + G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); + + ///Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)) ; + logicThirdStage->SetVisAttributes(ThirdStageVisAtt) ; +// logicThirdStage->SetVisAttributes(G4VisAttributes::Invisible); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void HydeTrackerSquare::ReadConfiguration(string Path) +{ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; + G4ThreeVector A , B , C , D ; + G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; + int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 ; + + bool ReadingStatus = false ; + + bool check_A = false ; + bool check_C = false ; + bool check_B = false ; + bool check_D = false ; + + bool check_Theta = false ; + bool check_Phi = false ; + bool check_R = false ; + bool check_beta = false ; + + bool check_FirstStage = false ; + bool check_SecondStage = false ; + bool check_ThirdStage = false ; + bool checkVis = false ; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 9, "HYDSquare") == 0) { + G4cout << "///" << G4endl ; + G4cout << "Square element found: " << G4endl ; + ReadingStatus = true ; + } + + while(ReadingStatus){ + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} + + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax * mm ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay * mm ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az * mm ; + + A = G4ThreeVector(Ax, Ay, Az); + cout << "X1 Y1 corner position : " << A << endl; + } + + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx * mm ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By * mm ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz * mm ; + + B = G4ThreeVector(Bx, By, Bz); + cout << "X128 Y1 corner position : " << B << endl; + } + + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx * mm ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy * mm ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz * mm ; + + C = G4ThreeVector(Cx, Cy, Cz); + cout << "X1 Y128 corner position : " << C << endl; + } + + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx * mm ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy * mm ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz * mm ; + + D = G4ThreeVector(Dx, Dy, Dz); + cout << "X128 Y128 corner position : " << D << endl; + } + + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta * deg; + cout << "Theta: " << Theta / deg << endl; + } + + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi * deg; + cout << "Phi: " << Phi / deg << endl; + } + + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R * mm; + cout << "R: " << R / mm << endl; + } + + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + check_beta = true; + ConfigFile >> DataBuffer ; + beta_u = atof(DataBuffer.c_str()) ; + beta_u = beta_u * deg ; + ConfigFile >> DataBuffer ; + beta_v = atof(DataBuffer.c_str()) ; + beta_v = beta_v * deg ; + ConfigFile >> DataBuffer ; + beta_w = atof(DataBuffer.c_str()) ; + beta_w = beta_w * deg ; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; + } + + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true ; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true ; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true ; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true ; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; + } + + else G4cout << "WARNING: Wrong Token, HydeTrackerSquare: Square Element not added" << G4endl; + + //Add The previously define telescope + //With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false ; + check_A = false ; + check_C = false ; + check_B = false ; + check_D = false ; + check_FirstStage = false ; + check_SecondStage = false ; + check_ThirdStage = false ; + checkVis = false ; + + AddModule(A , + B , + C , + D , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1); + } + + //with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false ; + check_Theta = false ; + check_Phi = false ; + check_R = false ; + check_beta = false ; + check_FirstStage = false ; + check_SecondStage = false ; + check_ThirdStage = false ; + checkVis = false ; + + AddModule(R , + Theta , + Phi , + beta_u , + beta_v , + beta_w , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1); + } + + + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void HydeTrackerSquare::ConstructDetector(G4LogicalVolume* world) +{ + G4RotationMatrix* MMrot = NULL ; +/* G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ;*/ + MMpos = G4ThreeVector(0, 0, 0) ; + MMu = G4ThreeVector(0, 0, 0) ; + MMv = G4ThreeVector(0, 0, 0) ; + MMw = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; + bool FirstStage = true ; + bool SecondStage = true ; + bool ThirdStage = true ; + + G4int NumberOfTelescope = m_DefinitionType.size() ; + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "############ Hyde " << i << " #############" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i] ; + G4cout << "MMu: X = " << MMu(0) << " , Y = " << MMu(1) << " , Z = " << MMu(2) << G4endl; + MMu = MMu.unit() ; + G4cout << "Norm MMu: X = " << MMu(0) << " , Y = " << MMu(1) << " , Z = " << MMu(2) << G4endl; + + MMv = m_X1_Y128[i] - m_X1_Y1[i] ; + G4cout << "MMv X = " << MMv(0) << " , Y = " << MMv(1) << " , Z = " << MMv(2) << G4endl; + MMv = MMv.unit() ; + G4cout << "Norm MMv X = " << MMv(0) << " , Y = " << MMv(1) << " , Z = " << MMv(2) << G4endl; + + G4ThreeVector MMscal = MMu.dot(MMv); + G4cout << "Norm MMu.MMv X = " << MMv(0) << " , Y = " << MMv(1) << " , Z = " << MMv(2) << G4endl; + + MMw = MMu.cross(MMv) ; +// if (MMw.z() > 0) MMw = MMv.cross(MMu) ; + MMw = MMw.unit() ; + + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4 ; + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw) ; + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter ; + } + + // By Angle + else { + G4double Theta = m_Theta[i] ; + G4double Phi = m_Phi[i] ; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad) ; + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad) ; + G4double wZ = m_R[i] * cos(Theta / rad) ; + MMw = G4ThreeVector(wX, wY, wZ) ; + + // vector corresponding to the center of the module + CT = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + CT ; + } + + FirstStage = m_wFirstStage[i] ; + SecondStage = m_wSecondStage[i] ; + ThirdStage = m_wThirdStage[i] ; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world); + } + + delete MMrot ; +} + + + +// Connect the HydeTrackingData class to the output TTree +// of the simulation +void HydeTrackerSquare::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void HydeTrackerSquare::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void HydeTrackerSquare::ReadSensitive(const G4Event* event) +{ +////////////////////////////////////////////////////////////////////////////////////// +//////////////////////// Used to Read Event Map of detector ////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Si(Li) + std::map<G4int, G4double*>::iterator SiLiEnergy_itr ; + G4THitsMap<G4double>* SiLiEnergyHitMap = NULL ; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr ; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL ; + + + // Read the Scorer associate to the Silicon Strip + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/StripNumberX") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/StripNumberY") ; + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDSquare/InterCoordAngPhi") ; + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; + + + // Read the Scorer associate to the SiLi + //Energy + G4int SiLiEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYDSquare/SecondStageEnergy") ; + SiLiEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SiLiEnergyCollectionID)) ; + SiLiEnergy_itr = SiLiEnergyHitMap->GetMap()->begin() ; + + + // Read the Scorer associate to the CsI crystal + //Energy + G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYDSquare/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" + << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << endl ; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYDTrkFirstStageFrontEDetectorNbr(m_index["Square"] + N); + ms_Event->SetHYDTrkFirstStageFrontTDetectorNbr(m_index["Square"] + N); + ms_Event->SetHYDTrkFirstStageBackEDetectorNbr(m_index["Square"] + N); + ms_Event->SetHYDTrkFirstStageBackTDetectorNbr(m_index["Square"] + N); + + // Energy + for (G4int l = 0 ; l < sizeE ; l++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; + } + + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeT ; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimePPAC) ; + ms_Event->SetHYDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)) ; + ms_Event->SetHYDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)) ; + } + Time_itr++; + } + + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYDTrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + + // Y + Y_itr = YHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < sizeY ; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYDTrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosXTrackID = Pos_X_itr->first - N ; + G4double PosX = *(Pos_X_itr->second) ; + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX) ; + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosYTrackID = Pos_Y_itr->first - N ; + G4double PosY = *(Pos_Y_itr->second) ; + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY) ; + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosZTrackID = Pos_Z_itr->first - N ; + G4double PosZ = *(Pos_Z_itr->second) ; + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ) ; + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; + G4double AngTheta = *(Ang_Theta_itr->second) ; + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N ; + G4double AngPhi = *(Ang_Phi_itr->second) ; + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; + } + Ang_Phi_itr++; + } + + // Second Stage + SiLiEnergy_itr = SiLiEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < SiLiEnergyHitMap->entries() ; h++) { + G4int SiLiEnergyTrackID = SiLiEnergy_itr->first - N; + G4double SiLiEnergy = *(SiLiEnergy_itr->second); + + if (SiLiEnergyTrackID == NTrackID) { + ms_Event->SetHYDTrkSecondStageEEnergy(RandGauss::shoot(SiLiEnergy, ResoSecondStage)) ; + ms_Event->SetHYDTrkSecondStageEPadNbr(1); + ms_Event->SetHYDTrkSecondStageTPadNbr(1); + ms_Event->SetHYDTrkSecondStageTTime(1); + ms_Event->SetHYDTrkSecondStageTDetectorNbr(m_index["Square"] + N); + ms_Event->SetHYDTrkSecondStageEDetectorNbr(m_index["Square"] + N); + } + + SiLiEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYDTrkThirdStageEPadNbr(1); + ms_Event->SetHYDTrkThirdStageTPadNbr(1); + ms_Event->SetHYDTrkThirdStageTTime(1); + ms_Event->SetHYDTrkThirdStageTDetectorNbr(m_index["Square"] + N); + ms_Event->SetHYDTrkThirdStageEDetectorNbr(m_index["Square"] + N); + } + + ThirdStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap ->clear(); + EnergyHitMap ->clear() ; + TimeHitMap ->clear() ; + XHitMap ->clear() ; + YHitMap ->clear() ; + PosXHitMap ->clear(); + PosYHitMap ->clear(); + PosZHitMap ->clear(); + AngThetaHitMap ->clear(); + AngPhiHitMap ->clear(); + SiLiEnergyHitMap ->clear() ; + ThirdStageEnergyHitMap ->clear() ; + } +} + + + +void HydeTrackerSquare::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYDSquare"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYDSquare", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYDSquare", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYDSquare", 0); + G4VPrimitiveScorer* Energy = new HYDScorerFirstStageEnergy("StripEnergy", "HYDSquare", 0); + G4VPrimitiveScorer* StripPositionX = new HYDScorerFirstStageFrontStripSquare("StripNumberX", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new HYDScorerFirstStageBackStripSquare("StripNumberY", 0, NumberOfStrips); + + //and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYDSquare"); + G4VPrimitiveScorer* SecondStageEnergy = new HYDScorerSecondStageEnergy("SecondStageEnergy", "HYDSquare", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYDSquare"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYDScorerThirdStageEnergy("ThirdStageEnergy", "HYDSquare", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +} diff --git a/NPSimulation/src/HydeTrackerTrapezoid.cc b/NPSimulation/src/HydeTrackerTrapezoid.cc new file mode 100644 index 0000000000000000000000000000000000000000..0f98230059e1cf443205b0c5a8cafb5d78ecd361 --- /dev/null +++ b/NPSimulation/src/HydeTrackerTrapezoid.cc @@ -0,0 +1,1028 @@ +/***************************************************************************** + * Copyright (C) 2009 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 15/07/09 * + * Last update : 12/10/09 * + *---------------------------------------------------------------------------* + * Decription: Define a module of trapezoidal shape for the Hyde tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <string> +#include <cmath> + +// G4 Geometry headers +#include "G4Box.hh" +#include "G4Trap.hh" + +// G4 various headers +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4PVDivision.hh" + +// G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPTool headers +#include "HydeTrackerTrapezoid.hh" +#include "GeneralScorers.hh" +#include "HydeScorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYDTRAP ; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerTrapezoid::HydeTrackerTrapezoid() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +HydeTrackerTrapezoid::~HydeTrackerTrapezoid() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerTrapezoid::AddModule(G4ThreeVector X1_Y1 , + G4ThreeVector X128_Y1 , + G4ThreeVector X1_Y128 , + G4ThreeVector X128_Y128 , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage) +{ + m_DefinitionType.push_back(true) ; + + m_X1_Y1.push_back(X1_Y1) ; + m_X128_Y1.push_back(X128_Y1) ; + m_X1_Y128.push_back(X1_Y128) ; + m_X128_Y128.push_back(X128_Y128) ; + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; + + m_R.push_back(0) ; + m_Theta.push_back(0) ; + m_Phi.push_back(0) ; + m_beta_u.push_back(0) ; + m_beta_v.push_back(0) ; + m_beta_w.push_back(0) ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerTrapezoid::AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage) +{ + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R) ; + m_Theta.push_back(Theta) ; + m_Phi.push_back(Phi) ; + m_beta_u.push_back(beta_u) ; + m_beta_v.push_back(beta_v) ; + m_beta_w.push_back(beta_w) ; + m_wFirstStage.push_back(wFirstStage) ; + m_wSecondStage.push_back(wSecondStage) ; + m_wThirdStage.push_back(wThirdStage) ; + + m_X1_Y1.push_back(empty) ; + m_X128_Y1.push_back(empty) ; + m_X1_Y128.push_back(empty) ; + m_X128_Y128.push_back(empty) ; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void HydeTrackerTrapezoid::VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + G4LogicalVolume* world) +{ + G4double NbrTelescopes = TelescopeNumber ; + G4String DetectorNumber ; + ostringstream Number ; + Number << NbrTelescopes ; + DetectorNumber = Number.str() ; + + //////////////////////////////////////////////////////////////// + /////////////////Element Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + G4String symbol ; + G4double density = 0. , a = 0, z = 0 ; + G4int ncomponents = 0, natoms = 0 ; + + 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.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , symbol = "N" , z = 7 , a = 14.01 * g / mole); + G4Element* O = new G4Element("Oxigen" , symbol = "O" , z = 8 , a = 16.00 * g / mole); + G4Element* I = new G4Element("Iode" , symbol = "I" , z = 53 , a = 126.9 * g / mole); + G4Element* Cs = new G4Element("Cesium" , symbol = "Cs" , z = 55 , a = 132.9 * g / mole); + + G4Element* Co = new G4Element("Cobalt" , symbol = "Co" , z = 27 , a = 58.933 * g / mole); + G4Element* Cr = new G4Element("Cromium" , symbol = "Cr" , z = 24 , a = 51.996 * g / mole); + G4Element* Ni = new G4Element("Nickel" , symbol = "Ni" , z = 28 , a = 58.69 * g / mole); + G4Element* Fe = new G4Element("Iron" , symbol = "Fe" , z = 26 , a = 55.847 * g / mole); + G4Element* W = new G4Element("Tungsten" , symbol = "W" , z = 74 , a = 183.5 * g / mole); + + //////////////////////////////////////////////////////////////// + /////////////////Material Definition /////////////////////////// + //////////////////////////////////////////////////////////////// + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + G4Material* Silicon = new G4Material("Si", z = 14., a, density); + + // Al +// density = 2.702 * g / cm3; +// a = 26.98 * g / mole; +// G4Material* Aluminium = new G4Material("Aluminium", z = 13., a, density); + + // Iron +// density = 7.874 * g / cm3; +// a = 55.847 * g / mole; +// G4Material* Iron = new G4Material("Iron", z = 26., a, density); + + // CsI + density = 4.51 * g / cm3; + G4Material* CsI = new G4Material("CsI", density, ncomponents = 2); + CsI->AddElement(Cs , natoms = 1); + CsI->AddElement(I , natoms = 1); + + // Vacuum + density = 0.000000001 * mg / cm3; + G4Material* Vacuum = new G4Material("Vacuum", density, ncomponents = 2); + Vacuum->AddElement(N, .7); + Vacuum->AddElement(O, .3); + + // Mylar + density = 1.397 * g / cm3; + G4Material* Myl = new G4Material("Mylar", density, ncomponents = 3); + Myl->AddElement(C, natoms = 10); + Myl->AddElement(H, natoms = 8); + Myl->AddElement(O, natoms = 4); + + // Havar + G4Material* Harvar = new G4Material("Havar", 8.3*g / cm3, 5); + Harvar->AddElement(Co , 42); + Harvar->AddElement(Cr , 20); + Harvar->AddElement(Ni , 13); + Harvar->AddElement(Fe , 19); + Harvar->AddElement(W , 1); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". + // If don't you will have a Warning unused variable 'myPVP' + G4PVPlacement* PVPBuffer ; + + // Definition of the volume containing the sensitive detector + G4Trap* solidMM = new G4Trap("HYDTrapezoid" + DetectorNumber, + Length/2, 0*deg, 0*deg, + Height/2, BaseSmall/2, BaseLarge/2, 0*deg, + Height/2, BaseSmall/2, BaseLarge/2, 0*deg); + +// G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, Iron, "HYDTrapezoid" + DetectorNumber, 0, 0, 0) ; + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, Vacuum, "HYDTrapezoid" + DetectorNumber, 0, 0, 0) ; + + G4String Name = "HYDTrapezoid" + DetectorNumber ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , + logicMM , + Name , + world , + false , + 0); + + logicMM->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicMM->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Definition of a vaccuum volume + G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); + + G4Trap* solidVacBox = new G4Trap("solidVacBox", + VacBoxThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, + FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg); + + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, Vacuum, "logicVacBox", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetectorNumber + "VacBox", logicMM, false, 0); + + logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); + + // Add a degrader plate between Si and CsI: + /* + G4Box* Degrader = new G4Box("Degrader" , 50*mm , 50*mm , 0.1*mm ); + G4LogicalVolume* logicDegrader = new G4LogicalVolume( Degrader , Harvar, "logicDegrader",0,0,0); + PVPBuffer = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicDegrader,"Degrader",logicVacBox,false,0) ; + */ + + //Place two marker to identify the u and v axis on silicon face: + //marker are placed a bit before the silicon itself so they don't perturbate simulation + //Uncomment to help debugging or if you want to understand the way the code work. + //I should recommand to Comment it during simulation to avoid perturbation of simulation + //Remember G4 is limitationg step on geometry constraints. + /* + G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; + G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , Vacuum , "logicMarkerU",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; + + G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; + G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , Vacuum , "logicMarkerV",0,0,0) ; + PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; + + G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green + logicMarkerV->SetVisAttributes(MarkerVVisAtt); + */ + + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); + + G4Trap* solidAluStrip = new G4Trap("AluBox", + AluStripThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, + FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg); + +// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Vacuum, "logicAluStrip", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetectorNumber + "AluStripFront", logicMM, false, 0); + PVPBuffer = new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetectorNumber + "AluStripBack", logicMM, false, 0); + + logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + + G4Trap* solidSilicon = new G4Trap("solidSilicon", + FirstStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg, + FirstStageHeight/2, FirstStageBaseSmall/2, FirstStageBaseLarge/2, 0*deg); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, Silicon, "logicSilicon", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, 0); + + // Set First Stage sensible + logicSilicon->SetSensitiveDetector(m_FirstStageScorer); + + // Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + logicSilicon->SetVisAttributes(SiliconVisAtt) ; + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Trap* solidThirdStage = new G4Trap("solidThirdStage", + ThirdStageThickness/2, 0*deg, 0*deg, + Height/2, BaseSmall/2, BaseLarge/2, 0*deg, + Height/2, BaseSmall/2, BaseLarge/2, 0*deg); + + G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); + + // Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)) ; + logicThirdStage->SetVisAttributes(ThirdStageVisAtt) ; +// logicThirdStage->SetVisAttributes(G4VisAttributes::Invisible); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void HydeTrackerTrapezoid::ReadConfiguration(string Path) +{ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; + G4ThreeVector A , B , C , D ; + G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; + int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 ; + + bool ReadingStatus = false ; + + bool check_A = false ; + bool check_C = false ; + bool check_B = false ; + bool check_D = false ; + + bool check_Theta = false ; + bool check_Phi = false ; + bool check_R = false ; + bool check_beta = false ; + + bool check_FirstStage = false ; + bool check_SecondStage = false ; + bool check_ThirdStage = false ; + bool checkVis = false ; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 12, "HYDTrapezoid") == 0) { + G4cout << "///" << G4endl ; + G4cout << "Trapezoid element found: " << G4endl ; + ReadingStatus = true ; + } + + while(ReadingStatus){ + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} + + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax * mm ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay * mm ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az * mm ; + + A = G4ThreeVector(Ax, Ay, Az); + cout << "X1 Y1 corner position : " << A << endl; + } + + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx * mm ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By * mm ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz * mm ; + + B = G4ThreeVector(Bx, By, Bz); + cout << "X128 Y1 corner position : " << B << endl; + } + + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx * mm ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy * mm ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz * mm ; + + C = G4ThreeVector(Cx, Cy, Cz); + cout << "X1 Y128 corner position : " << C << endl; + } + + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx * mm ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy * mm ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz * mm ; + + D = G4ThreeVector(Dx, Dy, Dz); + cout << "X128 Y128 corner position : " << D << endl; + } + + + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + Theta = Theta * deg; + cout << "Theta: " << Theta / deg << endl; + } + + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + Phi = Phi * deg; + cout << "Phi: " << Phi / deg << endl; + } + + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + R = R * mm; + cout << "R: " << R / mm << endl; + } + + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + check_beta = true; + ConfigFile >> DataBuffer ; + beta_u = atof(DataBuffer.c_str()) ; + beta_u = beta_u * deg ; + ConfigFile >> DataBuffer ; + beta_v = atof(DataBuffer.c_str()) ; + beta_v = beta_v * deg ; + ConfigFile >> DataBuffer ; + beta_w = atof(DataBuffer.c_str()) ; + beta_w = beta_w * deg ; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; + } + + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true ; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true ; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true ; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true ; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; + } + + else G4cout << "WARNING: Wrong Token, HydeTrackerTrapezoid: Trapezoid Element not added" << G4endl; + + //Add The previously define telescope + //With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false ; + check_A = false ; + check_C = false ; + check_B = false ; + check_D = false ; + check_FirstStage = false ; + check_SecondStage = false ; + check_ThirdStage = false ; + checkVis = false ; + + AddModule(A , + B , + C , + D , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1); + } + + //with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && checkVis) && !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false ; + check_Theta = false ; + check_Phi = false ; + check_R = false ; + check_beta = false ; + check_FirstStage = false ; + check_SecondStage = false ; + check_ThirdStage = false ; + checkVis = false ; + + AddModule(R , + Theta , + Phi , + beta_u , + beta_v , + beta_w , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1); + } + + + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void HydeTrackerTrapezoid::ConstructDetector(G4LogicalVolume* world) +{ + G4RotationMatrix* MMrot = NULL ; +/* G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ;*/ + MMpos = G4ThreeVector(0, 0, 0) ; + MMu = G4ThreeVector(0, 0, 0) ; + MMv = G4ThreeVector(0, 0, 0) ; + MMw = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; + bool FirstStage = true ; + bool SecondStage = true ; + bool ThirdStage = true ; + + G4int NumberOfModule = m_DefinitionType.size() ; + + for (G4int i = 0; i < NumberOfModule; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "############ Hyde Trapezoid " << i << " #############" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y128[i] ; + G4cout << "MMu: " << MMu << G4endl; + MMu = MMu.unit() ; + G4cout << "Norm MMu: " << MMu << G4endl; + + MMv = -0.5 * (m_X1_Y1[i] + m_X128_Y128[i] - m_X1_Y128[i] - m_X128_Y1[i]); + G4cout << "MMv: " << MMv << G4endl; + MMv = MMv.unit() ; + G4cout << "Norm MMv: " << MMv << G4endl; + + G4ThreeVector MMscal = MMu.dot(MMv); + G4cout << "Norm MMu.MMv: " << MMscal << G4endl; + + MMw = MMu.cross(MMv) ; +// if (MMw.z() > 0) MMw = MMv.cross(MMu) ; + MMw = MMw.unit() ; + G4cout << "Norm MMw: " << MMw << G4endl; + + // Center of the module + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4 ; + + // Passage Matrix from Lab Referential to Module Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw) ; + // translation to place Module + MMpos = MMw * Length * 0.5 + MMCenter ; + } + + // By Angle + else { + G4double Theta = m_Theta[i] ; + G4double Phi = m_Phi[i] ; + //This part because if Phi and Theta = 0 equation are false + if (Theta == 0) Theta = 0.0001 ; + if (Theta == 2*cos(0)) Theta = 2 * acos(0) - 0.00001 ; + if (Phi == 0) Phi = 0.0001 ; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad) ; + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad) ; + G4double wZ = m_R[i] * cos(Theta / rad) ; + + MMw = G4ThreeVector(wX, wY, wZ) ; +// G4ThreeVector CT = MMw ; + CT = MMw ; + MMw = MMw.unit() ; + + G4ThreeVector Y = G4ThreeVector(0 , 1 , 0) ; + + MMu = MMw.cross(Y) ; + MMv = MMw.cross(MMu) ; + + MMv = MMv.unit(); + MMu = MMu.unit(); + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + CT ; + } + + FirstStage = m_wFirstStage[i] ; + SecondStage = m_wSecondStage[i] ; + ThirdStage = m_wThirdStage[i] ; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world); + } + + delete MMrot ; +} + + + +// Connect the HydeTrackingData class to the output TTree +// of the simulation +void HydeTrackerTrapezoid::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void HydeTrackerTrapezoid::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void HydeTrackerTrapezoid::ReadSensitive(const G4Event* event) +{ +////////////////////////////////////////////////////////////////////////////////////// +//////////////////////// Used to Read Event Map of detector ////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + + // Read the Scorer associated to the first Stage + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/StripNumberX") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/StripNumberY") ; + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYDTrapezoid/InterCoordAngPhi") ; + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; + + // Read the Scorer associated to the Third Stage + //Energy + G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYDTrapezoid/ThirdStageEnergy") ; + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" + << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << endl ; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYDTrkFirstStageFrontEDetectorNbr(m_index["Trapezoid"] + N); + ms_Event->SetHYDTrkFirstStageFrontTDetectorNbr(m_index["Trapezoid"] + N); + ms_Event->SetHYDTrkFirstStageBackEDetectorNbr(m_index["Trapezoid"] + N); + ms_Event->SetHYDTrkFirstStageBackTDetectorNbr(m_index["Trapezoid"] + N); + + // Energy + for (G4int l = 0 ; l < sizeE ; l++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; + } + + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeT ; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + + if (TTrackID == NTrackID) { + T = RandGauss::shoot(T, ResoTimePPAC) ; + ms_Event->SetHYDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)) ; + ms_Event->SetHYDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)) ; + } + Time_itr++; + } + + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYDTrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + + // Y + Y_itr = YHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < sizeY ; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYDTrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYDTrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosXTrackID = Pos_X_itr->first - N ; + G4double PosX = *(Pos_X_itr->second) ; + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX) ; + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosYTrackID = Pos_Y_itr->first - N ; + G4double PosY = *(Pos_Y_itr->second) ; + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY) ; + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int PosZTrackID = Pos_Z_itr->first - N ; + G4double PosZ = *(Pos_Z_itr->second) ; + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ) ; + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; + G4double AngTheta = *(Ang_Theta_itr->second) ; + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeX ; h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N ; + G4double AngPhi = *(Ang_Phi_itr->second) ; + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; + } + Ang_Phi_itr++; + } + + // Second Stage + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYDTrkThirdStageEPadNbr(1); + ms_Event->SetHYDTrkThirdStageTPadNbr(1); + ms_Event->SetHYDTrkThirdStageTTime(1); + ms_Event->SetHYDTrkThirdStageTDetectorNbr(m_index["Trapezoid"] + N); + ms_Event->SetHYDTrkThirdStageEDetectorNbr(m_index["Trapezoid"] + N); + } + + ThirdStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap ->clear(); + EnergyHitMap ->clear(); + TimeHitMap ->clear(); + XHitMap ->clear(); + YHitMap ->clear(); + PosXHitMap ->clear(); + PosYHitMap ->clear(); + PosZHitMap ->clear(); + AngThetaHitMap ->clear(); + AngPhiHitMap ->clear(); + ThirdStageEnergyHitMap ->clear(); + } +} + + + +void HydeTrackerTrapezoid::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYDTrapezoid"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYDTrapezoid", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYDTrapezoid", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYDTrapezoid", 0); + G4VPrimitiveScorer* Energy = new HYDScorerFirstStageEnergy("StripEnergy", "HYDTrapezoid", 0); + G4VPrimitiveScorer* StripPositionX = new HYDScorerFirstStageFrontStripTrapezoid("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYDScorerFirstStageBackStripTrapezoid("StripNumberY", 0, NumberOfStripsY); + + //and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + m_SecondStageScorer = new G4MultiFunctionalDetector("SecondStageScorerHYDTrapezoid"); + G4VPrimitiveScorer* SecondStageEnergy = new HYDScorerSecondStageEnergy("SecondStageEnergy", "HYDTrapezoid", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYDTrapezoid"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYDScorerThirdStageEnergy("ThirdStageEnergy", "HYDTrapezoid", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +} diff --git a/NPSimulation/src/Target.cc b/NPSimulation/src/Target.cc index 50905a4c6eebc8937eeb07e0614abc8719a933a6..aa668a3648b463572d32148b012e301c732c8dbd 100644 --- a/NPSimulation/src/Target.cc +++ b/NPSimulation/src/Target.cc @@ -208,10 +208,10 @@ G4Material* Target::GetMaterialFromLibrary(G4String MaterialName, G4double Tempe return myMaterial; } - else if (MaterialName == "Pb208") { + else if (MaterialName == "208Pb") { G4Element* Pb = new G4Element("Lead" , "Pb" , 82. , 207.2*g / mole); - G4Material* myMaterial = new G4Material("Pb208", 11.342*g / cm3, 1); + G4Material* myMaterial = new G4Material("208Pb", 11.342*g / cm3, 1); myMaterial->AddElement(Pb , 1); return myMaterial; } @@ -292,21 +292,21 @@ void Target::ReadConfiguration(string Path) check_Thickness = true ; ConfigFile >> DataBuffer; m_TargetThickness = atof(DataBuffer.c_str()) * micrometer; - cout << "Target Thickness: " << m_TargetThickness << endl ; + cout << "Target Thickness: " << m_TargetThickness / micrometer << " micrometer" << endl; } else if (DataBuffer.compare(0, 6, "ANGLE=") == 0) { check_Angle = true ; ConfigFile >> DataBuffer; m_TargetAngle = atof(DataBuffer.c_str()) * deg; - cout << "Target Angle: " << m_TargetAngle << endl ; + cout << "Target Angle: " << m_TargetAngle / deg << endl ; } else if (DataBuffer.compare(0, 7, "RADIUS=") == 0) { check_Radius = true ; ConfigFile >> DataBuffer; m_TargetRadius = atof(DataBuffer.c_str()) * mm; - cout << "Target Radius: " << m_TargetRadius << endl ; + cout << "Target Radius: " << m_TargetRadius / mm << " mm " << endl; } else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { diff --git a/NPSimulation/vis.mac b/NPSimulation/vis.mac index c896f6e11c8d53873c1d77f5db6bfab6aea99f63..c510026907f09b443c90c2c4fc12293827072fe5 100644 --- a/NPSimulation/vis.mac +++ b/NPSimulation/vis.mac @@ -9,18 +9,18 @@ # choose a graphic system #/vis/open OGLIX #/vis/open OGLSX -#/vis/open VRML2FILE -#/vis/scene/create -#/vis/drawVolume -#/vis/viewer/set/viewpointThetaPhi 0 0 deg -#/vis/viewer/zoom 7 +/vis/open VRML2FILE +/vis/scene/create +/vis/drawVolume +/vis/viewer/set/viewpointThetaPhi 0 0 deg +/vis/viewer/zoom 7 ## options to draw trajectories -#/vis/scene/endOfEventAction accumulate -#/vis/scene/add/trajectories 1 -#/tracking/storeTrajectory 1 -#/vis/scene/add/axes 0 0 0 20 cm -#/vis/viewer/refresh +/vis/scene/endOfEventAction accumulate +/vis/scene/add/trajectories 1 +/tracking/storeTrajectory 1 +/vis/scene/add/axes 0 0 0 20 cm +/vis/viewer/refresh # run event #/run/beamOn 0 diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index ac401db3e530c8082f475105ece3004a59ddc8a5..f1d2c9d25b395be8ccc3d7d5acd4360d99c3af79 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -32,9 +32,16 @@ Nicolas de Sereville, IPNO + Execute ./Simulation --help or ./Analysis --help to know the available options. + + TAsciiFile class + + This class allows to store any regular text file in a ROOT file + + This is used to store the event generator, detector configuration files + + RootInput facility + Support for adding TFriend object + + RootOutput facility + + Support for adding TAsciiFile object automatically + + NPTagManager facility ?? Adrien ?? @@ -46,10 +53,12 @@ Nicolas de Sereville, IPNO + NPAnalysis ------------ - + No new functionality in NPSimulation + Using the NPOptionManager facility, calling NPAnalysis is now: ./Analysis -D xxx.detector -E xxx.reaction -R RunToTreat.txt + + A simple but functional example for MUST2 analysis can be found + in the NPAnalysis/must2 directory. + **************************************************************************** * SPECIFIC FEATURES * @@ -68,3 +77,4 @@ Nicolas de Sereville, IPNO + PARIS ------- + + Add documentation