diff --git a/NPLib/HYDE2/Hyde2Tracker.cxx b/NPLib/HYDE2/Hyde2Tracker.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ee29c1f1f1fb1d328a13e990ffcbb48812050983 --- /dev/null +++ b/NPLib/HYDE2/Hyde2Tracker.cxx @@ -0,0 +1,284 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 * + * THyde2TrackerPhysics 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 "Hyde2Tracker.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" + +// Hyde2 headers +#include "Hyde2TrackerTrapezoid1.h" +#include "Hyde2TrackerTrapezoid2.h" +#include "Hyde2TrackerSquare1.h" + +using namespace std ; + + + + +Hyde2Tracker::Hyde2Tracker() + : m_EventData (new THyde2TrackerData()), + m_EventPhysics (new THyde2TrackerPhysics()) +{ +} + + + +Hyde2Tracker::~Hyde2Tracker() +{ + delete m_EventData; + delete m_EventPhysics; +} + + + +void Hyde2Tracker::Clear() +{ +} + + + +// Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token +void Hyde2Tracker::ReadConfiguration(string Path) +{ + // open configuration file + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + bool HYD2TrkTrapezoid1 = false; + bool HYD2TrkTrapezoid2 = false; + bool HYD2TrkSquare1 = false; + + string LineBuffer; + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 11, "HYD2Square1") == 0 && HYD2TrkSquare1 == false) { + HYD2TrkSquare1 = true; + + // instantiate a new "detector" corresponding to the Shape elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerSquare1(m_ModulesMap, m_EventPhysics); + + // Pass the data object to the Hyde2Tracker*** object + myDetector->SetHyde2DataPointer(m_EventData); + + // read part of the configuration file corresponding to shape elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + } + else if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0 && HYD2TrkTrapezoid1 == false) { + HYD2TrkTrapezoid1 = true; + + // instantiate a new "detector" corresponding to the Trapezoid elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerTrapezoid1(m_ModulesMap, m_EventPhysics); + + // Pass the data object to the Hyde2Tracker*** object + myDetector->SetHyde2DataPointer(m_EventData); + + // read part of the configuration file corresponding to trapezoid elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + } + else if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0 && HYD2TrkTrapezoid2 == false) { + HYD2TrkTrapezoid2 = true; + + // instantiate a new "detector" corresponding to the Trapezoid elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerTrapezoid2(m_ModulesMap, m_EventPhysics); + + // Pass the data object to the Hyde2Tracker*** object + myDetector->SetHyde2DataPointer(m_EventData); + + // read part of the configuration file corresponding to trapezoid elements + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + } + } +} + + +// Read stream at Path and pick-up calibration parameter using Token +// If argument is "Simulation" no change calibration is loaded +void Hyde2Tracker::ReadCalibrationFile(string Path) +{ + Path.c_str(); // remove warning at compilation time + +/* // 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 Hyde2Tracker::InitializeRootInput() +{ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("HYDE2", true); + inputChain->SetBranchStatus("fHYD2*", true); + inputChain->SetBranchAddress("HYDE2", &m_EventData); +} + + + +// Create associated branches and associated private member DetectorPhysics address +void Hyde2Tracker::InitializeRootOutput() +{ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("HYDE2", "THyde2TrackerPhysics", &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 Hyde2Tracker::BuildPhysicalEvent() +{ + if (m_EventData->GetHYD2TrkFirstStageFrontEMult() > 0) { + for (UInt_t i = 0; i < m_EventData->GetHYD2TrkFirstStageFrontEMult(); i++) { + UShort_t detecNbr = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(i); + m_ModulesMap[detecNbr]->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 Hyde2Tracker::BuildSimplePhysicalEvent() +{ + BuildPhysicalEvent(); +} + + + +void Hyde2Tracker::DumpModulesMap() +{ + cout << "Hyde2Tracker::DumpMap()" << endl; + + map<int, Hyde2TrackerModule*>::iterator it; + + for (it = m_ModulesMap.begin(); it != m_ModulesMap.end(); ++it) { + cout << "Module " << it->first << " -> Address " << it->second << endl; + } +} + + + +void Hyde2Tracker::DumpStrippingScheme(int moduleNumber) +{ + cout << "Hyde2Tracker::DumpStrippingScheme()" << endl; + + for (int i = 1; i < 128; i++) { // front part + for (int j = 1; j < 128; j++) { // back part + cout << "strips X, Y: " << i << " " << j << "\t--->\t (X,Y,Z) mm: " + << m_ModulesMap[moduleNumber]->GetStripPositionX(moduleNumber, i, j) << "\t" + << m_ModulesMap[moduleNumber]->GetStripPositionY(moduleNumber, i, j) << "\t" + << m_ModulesMap[moduleNumber]->GetStripPositionZ(moduleNumber, i, j) << endl; + } + } +} + + + +double Hyde2Tracker::GetEnergyDeposit() +{ + if (m_EventPhysics->GetEventMultiplicity() > 0) { + return m_EventPhysics->GetTotalEnergy(0); + } + else + return -1000; +} + + + +TVector3 Hyde2Tracker::GetPositionOfInteraction() +{ + TVector3 Position = TVector3(-1000,-1000,-1000); + + if (m_EventPhysics->GetEventMultiplicity() == 1) { + Int_t ModuleNbr = m_EventPhysics->GetModuleNumber(0); + Int_t FrontPos = m_EventPhysics->GetFirstStageFrontPosition(0); + Int_t BackPos = m_EventPhysics->GetFirstStageBackPosition(0); + Position = TVector3(m_ModulesMap[ModuleNbr]->GetStripPositionX(ModuleNbr, FrontPos, BackPos), + m_ModulesMap[ModuleNbr]->GetStripPositionY(ModuleNbr, FrontPos, BackPos), + m_ModulesMap[ModuleNbr]->GetStripPositionZ(ModuleNbr, FrontPos, BackPos)); + } + + return Position; +} diff --git a/NPLib/HYDE2/Hyde2Tracker.h b/NPLib/HYDE2/Hyde2Tracker.h new file mode 100644 index 0000000000000000000000000000000000000000..36093b0c92dab10455d5a9bfac8364aeb33254e4 --- /dev/null +++ b/NPLib/HYDE2/Hyde2Tracker.h @@ -0,0 +1,110 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 * + * THyde2TrackerPhysics 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 Hyde2Tracker_H +#define Hyde2Tracker_H + +// NPL +#include "../include/VDetector.h" +#include "THyde2TrackerData.h" +#include "THyde2TrackerPhysics.h" +#include "Hyde2TrackerModule.h" + +// C++ +#include <map> +#include <vector> + +// Root +#include "TObject.h" +#include "TVector3.h" + +class Hyde2Tracker : public NPA::VDetector +{ +public: + Hyde2Tracker(); + virtual ~Hyde2Tracker(); + +public: + void Clear(); + void Clear(const Option_t*) {}; + +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: + void DumpModulesMap(); + void DumpStrippingScheme(int moduleNumber); + +private: + map<int, Hyde2TrackerModule*> m_ModulesMap; + +public: + // Get Root input and output objects + THyde2TrackerData* GetEventData() {return m_EventData;} + THyde2TrackerPhysics* GetEventPhysics() {return m_EventPhysics;} + + // To be called after a build Physical Event + double GetEnergyDeposit(); + TVector3 GetPositionOfInteraction(); + + +private: + //////////////////////////////////////// + // Root Input and Output tree classes // + //////////////////////////////////////// + THyde2TrackerData* m_EventData; + THyde2TrackerPhysics* m_EventPhysics; +}; + +#endif diff --git a/NPLib/HYDE2/Hyde2TrackerModule.cxx b/NPLib/HYDE2/Hyde2TrackerModule.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e2334f9337e836a3f28b0d92f6ff71212ea3ddb4 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerModule.cxx @@ -0,0 +1,23 @@ +#include "Hyde2TrackerModule.h" + + + +Hyde2TrackerModule::Hyde2TrackerModule() +{ + InitializeIndex(); +} + + + +Hyde2TrackerModule::~Hyde2TrackerModule() +{ +} + + + +void Hyde2TrackerModule::InitializeIndex() +{ + m_index["Square1"] = 2000; + m_index["Trapezoid1"] = 2200; + m_index["Trapezoid2"] = 2300; +} diff --git a/NPLib/HYDE2/Hyde2TrackerModule.h b/NPLib/HYDE2/Hyde2TrackerModule.h new file mode 100644 index 0000000000000000000000000000000000000000..69c9659836f19f1fc32532f9bb13021e7f08eb45 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerModule.h @@ -0,0 +1,48 @@ +#ifndef Hyde2TrackerModule_h +#define Hyde2TrackerModule_h 1 + +// C++ headers +#include <string> +#include <map> + +// NPTool - ROOT headers +#include "THyde2TrackerData.h" + +using namespace std; + + + +class Hyde2TrackerModule +{ +public: + Hyde2TrackerModule(); + virtual ~Hyde2TrackerModule(); + +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + virtual void ReadConfiguration(string Path) = 0; + + // The goal of this method is to extract physical parameters from raw data + // Method called at each event read from the Input Tree + virtual void BuildPhysicalEvent() = 0; + + // Same as before but with a simpler treatment + virtual void BuildSimplePhysicalEvent() = 0; + + // Initialize the Index map for the different modules of Hyde2 + void InitializeIndex(); + + // Pass the THyde2TrackerData object from THyde2TrackerPhysics to the + // classes deriving from Hyde2TrackerModule + virtual void SetHyde2DataPointer(THyde2TrackerData* hyde2Data) = 0; + + // + virtual double GetStripPositionX(Int_t DetectorNumber, Int_t stripX, Int_t stripY) = 0; + virtual double GetStripPositionY(Int_t DetectorNumber, Int_t stripX, Int_t stripY) = 0; + virtual double GetStripPositionZ(Int_t DetectorNumber, Int_t stripX, Int_t stripY) = 0; + +protected: + map<string, int> m_index; +}; + +#endif diff --git a/NPLib/HYDE2/Hyde2TrackerSquare1.cxx b/NPLib/HYDE2/Hyde2TrackerSquare1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..705b5b8d140a6cddc0f09879c02673259fce8bb3 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerSquare1.cxx @@ -0,0 +1,559 @@ +#include "Hyde2TrackerSquare1.h" + +// C++ headers +#include <limits> +#include <iostream> +#include <fstream> +#include <string> +#include <cmath> +#include <stdlib.h> + +// Hyde2 +#include "THyde2TrackerPhysics.h" + + +Hyde2TrackerSquare1::Hyde2TrackerSquare1(map<int, Hyde2TrackerModule*> &Module, + THyde2TrackerPhysics* &EventPhysics) + : m_ModuleTest(Module), + m_EventPhysics(EventPhysics), + m_EventData(0), + m_PreTreatData(new THyde2TrackerData), + m_NumberOfModule(0), + m_FirstStageFace(87.42), // mm + m_NumberOfStrips(220) +{ + m_StripPitch = m_FirstStageFace / (double)m_NumberOfStrips; +} + + + +Hyde2TrackerSquare1::~Hyde2TrackerSquare1() +{ + delete m_PreTreatData; +} + + + +void Hyde2TrackerSquare1::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; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + + // If line is a Hyde2XXX bloc, reading toggle to true + // and toggle to true flags indicating which shape is treated. + if (LineBuffer.compare(0, 9, "HYD2Square1") == 0) { + cout << "///////////////////////" << endl; + cout << "Square1 module found:" << endl; + ReadingStatus = true; + } + + // Reading Block + while (ReadingStatus) { + 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, 11, "HYD2Square1") == 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 ) { + AddModule(A, B, C, D); + m_ModuleTest[m_index["Square1"] + m_NumberOfModule] = this; + } + + // with angle method + else if ( check_Theta && check_Phi && check_R && check_beta ) { + AddModule(Theta, Phi, R, beta_u, beta_v, beta_w); + m_ModuleTest[m_index["Square1"] + m_NumberOfModule] = this; + } + + // 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; + + } // end test for adding a module + } // end while for reading block + } // end while for reading file + + cout << endl << "/////////////////////////////" << endl<<endl; +} + + + +void Hyde2TrackerSquare1::PreTreat() +{ +} + + + +void Hyde2TrackerSquare1::BuildPhysicalEvent() +{ + // Check flags +// bool Check_FirstStage = false; + bool Check_SecondStage = false; + bool Check_ThirdStage = false; + bool Check_FourthStage = false; + bool Check_FifthStage = false; + bool Check_SixthStage = 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 = m_EventData->GetHYD2TrkFirstStageFrontEMult(); + int multYE = m_EventData->GetHYD2TrkFirstStageBackEMult(); + int multXT = m_EventData->GetHYD2TrkFirstStageFrontTMult(); + int multYT = m_EventData->GetHYD2TrkFirstStageBackTMult(); + // calculate multiplicity of 2nd and third stages + int mult2E = m_EventData->GetHYD2TrkSecondStageEMult(); + int mult2T = m_EventData->GetHYD2TrkSecondStageTMult(); + int mult3E = m_EventData->GetHYD2TrkThirdStageEMult(); + int mult3T = m_EventData->GetHYD2TrkThirdStageTMult(); + int mult4E = m_EventData->GetHYD2TrkFourthStageEMult(); + int mult4T = m_EventData->GetHYD2TrkFourthStageTMult(); + int mult5E = m_EventData->GetHYD2TrkFifthStageEMult(); + int mult5T = m_EventData->GetHYD2TrkFifthStageTMult(); + int mult6E = m_EventData->GetHYD2TrkSixthStageEMult(); + int mult6T = m_EventData->GetHYD2TrkSixthStageTMult(); + + // Deal with multiplicity 1 for the first layer + if (multXE==1 && multYE==1 && multXT==1 && multYT==1) { + // calculate detector number + int det_ref = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(0); + int detecXE = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(0) / det_ref; + int detecXT = m_EventData->GetHYD2TrkFirstStageFrontTDetectorNbr(0) / det_ref; + int detecYE = m_EventData->GetHYD2TrkFirstStageBackEDetectorNbr(0) / det_ref; + int detecYT = m_EventData->GetHYD2TrkFirstStageBackTDetectorNbr(0) / det_ref; + + // case of same detector + if (detecXE*detecXT*detecYE*detecYT == 1) { + // store module number + m_EventPhysics->SetModuleNumber(det_ref); + // calculate strip number + int stripXE = m_EventData->GetHYD2TrkFirstStageFrontEStripNbr(0); + int stripXT = m_EventData->GetHYD2TrkFirstStageFrontTStripNbr(0); + int stripYE = m_EventData->GetHYD2TrkFirstStageBackEStripNbr(0); + int stripYT = m_EventData->GetHYD2TrkFirstStageBackTStripNbr(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; + // store strip ID + m_EventPhysics->SetFirstStageFrontPosition(stripXE); + m_EventPhysics->SetFirstStageBackPosition(stripYE); + // get energy from strips and store it + double EnergyStripFront = m_EventData->GetHYD2TrkFirstStageFrontEEnergy(0); + m_EventPhysics->SetFirstStageEnergy(EnergyStripFront); + double EnergyTot = EnergyStripFront; + // get time from strips and store it + double TimeStripBack = m_EventData->GetHYD2TrkFirstStageBackEEnergy(0); + m_EventPhysics->SetFirstStageTime(TimeStripBack); + + // check if we have a 2nd stage event + if (mult2E==1 && mult2T==1) { + Check_SecondStage = true; + double EnergySecond = m_EventData->GetHYD2TrkSecondStageEEnergy(0); + m_EventPhysics->SetSecondStageEnergy(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 = m_EventData->GetHYD2TrkThirdStageEEnergy(0); + m_EventPhysics->SetThirdStageEnergy(EnergyThird); + EnergyTot += EnergyThird; + } + else if (mult3E>1 || mult3T>1) { + cout << "Warning: multiplicity in third stage greater than in firststage" << endl; + } + + // check if we have a Fourth stage event + if (mult4E==1 && mult4T==1) { + Check_FourthStage = true; + double EnergyFourth = m_EventData->GetHYD2TrkFourthStageEEnergy(0); + m_EventPhysics->SetFourthStageEnergy(EnergyFourth); + EnergyTot += EnergyFourth; + } + else if (mult4E>1 || mult4T>1) { + cout << "Warning: multiplicity in fourth stage greater than in firststage" << endl; + } + + // check if we have a Fifth stage event + if (mult5E==1 && mult5T==1) { + Check_FifthStage = true; + double EnergyFifth = m_EventData->GetHYD2TrkFifthStageEEnergy(0); + m_EventPhysics->SetFifthStageEnergy(EnergyFifth); + EnergyTot += EnergyFifth; + } + else if (mult5E>1 || mult5T>1) { + cout << "Warning: multiplicity in fifth stage greater than in firststage" << endl; + } + + // check if we have a Sixth stage event + if (mult6E==1 && mult6T==1) { + Check_SixthStage = true; + double EnergySixth = m_EventData->GetHYD2TrkSixthStageEEnergy(0); + m_EventPhysics->SetSixthStageEnergy(EnergySixth); + EnergyTot += EnergySixth; + } + else if (mult6E>1 || mult6T>1) { + cout << "Warning: multiplicity in sixth stage greater than in firststage" << endl; + } + + // Fill total energy + m_EventPhysics->SetTotalEnergy(EnergyTot); + + // check strip position +/* cout << "strips X, Y : " << stripXE << " " << stripYE << endl; + cout << "position : " << endl; + cout << "\t X: " << GetStripPositionX(det_ref + m_index["Square1"], stripXE, stripYE) << endl; + cout << "\t Y: " << GetStripPositionY(det_ref + m_index["Square1"], stripXE, stripYE) << endl; + cout << "\t Z: " << GetStripPositionZ(det_ref + m_index["Square1"], stripXE, stripYE) << endl; +*/ + // Fill default values for second an third stages + if (!Check_SecondStage) { + m_EventPhysics->SetSecondStageEnergy(-1000); + m_EventPhysics->SetSecondStageTime(-1000); + m_EventPhysics->SetSecondStagePosition(-1000); + } + if (!Check_ThirdStage) { + m_EventPhysics->SetThirdStageEnergy(-1000); + m_EventPhysics->SetThirdStageTime(-1000); + m_EventPhysics->SetThirdStagePosition(-1000); + } + if (!Check_FourthStage) { + m_EventPhysics->SetFourthStageEnergy(-1000); + m_EventPhysics->SetFourthStageTime(-1000); + m_EventPhysics->SetFourthStagePosition(-1000); + } + if (!Check_FifthStage) { + m_EventPhysics->SetFifthStageEnergy(-1000); + m_EventPhysics->SetFifthStageTime(-1000); + m_EventPhysics->SetFifthStagePosition(-1000); + } + if (!Check_SixthStage) { + m_EventPhysics->SetSixthStageEnergy(-1000); + m_EventPhysics->SetSixthStageTime(-1000); + m_EventPhysics->SetSixthStagePosition(-1000); + } + } + 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 Hyde2TrackerSquare1::BuildSimplePhysicalEvent() +{ +} + + + +void Hyde2TrackerSquare1::AddModule(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; + + // 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) * (m_StripPitch/2.); + + for (int i = 0; i < m_NumberOfStrips; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < m_NumberOfStrips; j++) { + StripCenter = Strip_1_1 + m_StripPitch*(i*U + j*V); + + 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 Hyde2TrackerSquare1::AddModule(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w) +{ + m_NumberOfModule++; + + // convert from degree to radian: + theta *= M_PI/180; + phi *= M_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 * M_PI/180. , U ) ; + V.Rotate( beta_u * M_PI/180. , U ) ; + + U.Rotate( beta_v * M_PI/180. , V ) ; + V.Rotate( beta_v * M_PI/180. , V ) ; + + U.Rotate( beta_w * M_PI/180. , W ) ; + V.Rotate( beta_w * M_PI/180. , W ) ; + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0,0,0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector< vector< double > > OneModuleStripPositionX; + vector< vector< double > > OneModuleStripPositionY; + vector< vector< double > > OneModuleStripPositionZ; + + // Moving C to the 1.1 corner: + Strip_1_1 = C - 0.5 * (m_FirstStageFace - m_StripPitch) * (U + V); + + for (int i = 0; i < m_NumberOfStrips; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < m_NumberOfStrips; j++) { + StripCenter = Strip_1_1 + m_StripPitch * (i*U + j*V); + + 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 ); +} diff --git a/NPLib/HYDE2/Hyde2TrackerSquare1.h b/NPLib/HYDE2/Hyde2TrackerSquare1.h new file mode 100644 index 0000000000000000000000000000000000000000..364699f8f7545b3f729f2c3054111fa84a19d316 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerSquare1.h @@ -0,0 +1,98 @@ +#ifndef Hyde2TrackerSquare1_h +#define Hyde2TrackerSquare1_h 1 + +// C++ headers +#include <string> +#include <map> +#include <vector> + +// ROOT headers +#include "TVector3.h" + +// Hyde2 headers +#include "THyde2TrackerData.h" +#include "THyde2TrackerPhysics.h" +#include "Hyde2TrackerModule.h" + +using namespace std; + + + +class Hyde2TrackerSquare1 : public Hyde2TrackerModule +{ +public: + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + Hyde2TrackerSquare1(map<int, Hyde2TrackerModule*> &Module, THyde2TrackerPhysics* &EventPhysics); + virtual ~Hyde2TrackerSquare1(); + +public: + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule class ///// + //////////////////////////////////////////////////// + // Read stream at Configfile to pick-up parameters of detector (Position,...) + void ReadConfiguration(string Path); + + // The goal of this method is to extract physical parameters from raw data + // Method called at each event read from the Input Tree + void BuildPhysicalEvent(); + + // Same as before but with a simpler treatment + void BuildSimplePhysicalEvent(); + +private: + map<int, Hyde2TrackerModule*> &m_ModuleTest; + THyde2TrackerPhysics* &m_EventPhysics; + +public: + void SetHyde2DataPointer(THyde2TrackerData* hyde2Data) {m_EventData = hyde2Data;}; + void PreTreat(); + +private: + // Hyde2 data coming from THyde2TrackerPhysics through the + // SetHyde2DataPointer method + THyde2TrackerData* m_EventData; + THyde2TrackerData* m_PreTreatData; + +public: + //////////////////////////////// + // Specific to Hyde2Tracker // + //////////////////////////////// + // Add a Module using Corner Coordinate information + void AddModule(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 AddModule(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-m_index["Square1"]][X-1][Y-1]; } + double GetStripPositionY(int N ,int X ,int Y) { return m_StripPositionY[N-1-m_index["Square1"]][X-1][Y-1]; } + double GetStripPositionZ(int N ,int X ,int Y) { return m_StripPositionZ[N-1-m_index["Square1"]][X-1][Y-1]; } + double GetNumberOfModule() { return m_NumberOfModule; } + +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; + +private: + ////////////////////////////// + // Geometry and stip number // + ////////////////////////////// + double m_FirstStageFace; // mm + int m_NumberOfStrips; + double m_StripPitch; +}; + +#endif diff --git a/NPLib/HYDE2/Hyde2TrackerTrapezoid1.cxx b/NPLib/HYDE2/Hyde2TrackerTrapezoid1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e83e1394917c8b64f803c241def5f196909b977a --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerTrapezoid1.cxx @@ -0,0 +1,560 @@ +#include "Hyde2TrackerTrapezoid1.h" + +// C++ headers +#include <limits> +#include <iostream> +#include <fstream> +#include <string> +#include <cmath> +#include <stdlib.h> + +// Hyde2 +#include "THyde2TrackerPhysics.h" + + +Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1(map<int, Hyde2TrackerModule*> &Module, + THyde2TrackerPhysics* &EventPhysics) + : m_ModuleTest(Module), + m_EventPhysics(EventPhysics), + m_EventData(0), + m_PreTreatData(new THyde2TrackerData), + m_NumberOfModule(0), + m_FirstStageHeight(87.68), // mm + m_FirstStageBaseLarge(85.48), // mm + m_FirstStageBaseSmall(54.17), // mm + m_NumberOfStripsX(214), + m_NumberOfStripsY(220) +{ + m_StripPitchX = m_FirstStageBaseLarge / (double)m_NumberOfStripsX; + m_StripPitchY = m_FirstStageHeight / (double)m_NumberOfStripsY; +} + + + +Hyde2TrackerTrapezoid1::~Hyde2TrackerTrapezoid1() +{ + delete m_PreTreatData; +} + + + +void Hyde2TrackerTrapezoid1::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; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + + // If line is a Hyde2XXX bloc, reading toggle to true + // and toggle to true flags indicating which shape is treated. + if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0) { + cout << "///////////////////////" << endl; + cout << "Trapezoid1 module found:" << endl; + ReadingStatus = true; + } + + // Reading Block + while (ReadingStatus) { + 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, 14, "HYD2Trapezoid1") == 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 ) { + AddModule(A, B, C, D); + m_ModuleTest[m_index["Trapezoid1"] + m_NumberOfModule] = this; + } + + // with angle method + else if ( check_Theta && check_Phi && check_R && check_beta ) { + AddModule(Theta, Phi, R, beta_u, beta_v, beta_w); + m_ModuleTest[m_index["Trapezoid1"] + m_NumberOfModule] = this; + } + + // 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; + + } // end test for adding a module + } // end while for reading block + } // end while for reading file + + cout << endl << "/////////////////////////////" << endl<<endl; +} + + + +void Hyde2TrackerTrapezoid1::PreTreat() +{ +} + + + +void Hyde2TrackerTrapezoid1::BuildPhysicalEvent() +{ + // Check flags +// bool Check_FirstStage = false; + bool Check_SecondStage = false; + bool Check_ThirdStage = false; + bool Check_FourthStage = false; + bool Check_FifthStage = false; + bool Check_SixthStage = 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 = m_EventData->GetHYD2TrkFirstStageFrontEMult(); + int multYE = m_EventData->GetHYD2TrkFirstStageBackEMult(); + int multXT = m_EventData->GetHYD2TrkFirstStageFrontTMult(); + int multYT = m_EventData->GetHYD2TrkFirstStageBackTMult(); + // calculate multiplicity of 2nd and third stages + int mult2E = m_EventData->GetHYD2TrkSecondStageEMult(); + int mult2T = m_EventData->GetHYD2TrkSecondStageTMult(); + int mult3E = m_EventData->GetHYD2TrkThirdStageEMult(); + int mult3T = m_EventData->GetHYD2TrkThirdStageTMult(); + int mult4E = m_EventData->GetHYD2TrkFourthStageEMult(); + int mult4T = m_EventData->GetHYD2TrkFourthStageTMult(); + int mult5E = m_EventData->GetHYD2TrkFifthStageEMult(); + int mult5T = m_EventData->GetHYD2TrkFifthStageTMult(); + int mult6E = m_EventData->GetHYD2TrkSixthStageEMult(); + int mult6T = m_EventData->GetHYD2TrkSixthStageTMult(); + + // Deal with multiplicity 1 for the first layer + if (multXE==1 && multYE==1 && multXT==1 && multYT==1) { + // calculate detector number + int det_ref = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(0); + int detecXE = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(0) / det_ref; + int detecXT = m_EventData->GetHYD2TrkFirstStageFrontTDetectorNbr(0) / det_ref; + int detecYE = m_EventData->GetHYD2TrkFirstStageBackEDetectorNbr(0) / det_ref; + int detecYT = m_EventData->GetHYD2TrkFirstStageBackTDetectorNbr(0) / det_ref; + + // case of same detector + if (detecXE*detecXT*detecYE*detecYT == 1) { + // store module number + m_EventPhysics->SetModuleNumber(det_ref); + // calculate strip number + int stripXE = m_EventData->GetHYD2TrkFirstStageFrontEStripNbr(0); + int stripXT = m_EventData->GetHYD2TrkFirstStageFrontTStripNbr(0); + int stripYE = m_EventData->GetHYD2TrkFirstStageBackEStripNbr(0); + int stripYT = m_EventData->GetHYD2TrkFirstStageBackTStripNbr(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; + // store strip ID + m_EventPhysics->SetFirstStageFrontPosition(stripXE); + m_EventPhysics->SetFirstStageBackPosition(stripYE); + // get energy from strips and store it + double EnergyStripFront = m_EventData->GetHYD2TrkFirstStageFrontEEnergy(0); + m_EventPhysics->SetFirstStageEnergy(EnergyStripFront); + double EnergyTot = EnergyStripFront; + // get time from strips and store it + double TimeStripBack = m_EventData->GetHYD2TrkFirstStageBackEEnergy(0); + m_EventPhysics->SetFirstStageTime(TimeStripBack); + + // check if we have a 2nd stage event + if (mult2E==1 && mult2T==1) { + Check_SecondStage = true; + double EnergySecond = m_EventData->GetHYD2TrkSecondStageEEnergy(0); + m_EventPhysics->SetSecondStageEnergy(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 = m_EventData->GetHYD2TrkThirdStageEEnergy(0); + m_EventPhysics->SetThirdStageEnergy(EnergyThird); + EnergyTot += EnergyThird; + } + else if (mult3E>1 || mult3T>1) { + cout << "Warning: multiplicity in third stage greater than in firststage" << endl; + } + + // check if we have a fourth stage event + if (mult4E==1 && mult4T==1) { + Check_FourthStage = true; + double EnergyFourth = m_EventData->GetHYD2TrkFourthStageEEnergy(0); + m_EventPhysics->SetFourthStageEnergy(EnergyFourth); + EnergyTot += EnergyFourth; + } + else if (mult4E>1 || mult4T>1) { + cout << "Warning: multiplicity in fourth stage greater than in firststage" << endl; + } + + // check if we have a fifth stage event + if (mult5E==1 && mult5T==1) { + Check_FifthStage = true; + double EnergyFifth = m_EventData->GetHYD2TrkFifthStageEEnergy(0); + m_EventPhysics->SetFifthStageEnergy(EnergyFifth); + EnergyTot += EnergyFifth; + } + else if (mult5E>1 || mult5T>1) { + cout << "Warning: multiplicity in fifth stage greater than in firststage" << endl; + } + + // check if we have a sixth stage event + if (mult6E==1 && mult6T==1) { + Check_SixthStage = true; + double EnergySixth = m_EventData->GetHYD2TrkSixthStageEEnergy(0); + m_EventPhysics->SetSixthStageEnergy(EnergySixth); + EnergyTot += EnergySixth; + } + else if (mult6E>1 || mult6T>1) { + cout << "Warning: multiplicity in sixth stage greater than in firststage" << endl; + } + + // Fill total energy + m_EventPhysics->SetTotalEnergy(EnergyTot); + + // Fill default values for second an third stages + if (!Check_SecondStage) { + m_EventPhysics->SetSecondStageEnergy(-1000); + m_EventPhysics->SetSecondStageTime(-1000); + m_EventPhysics->SetSecondStagePosition(-1000); + } + if (!Check_ThirdStage) { + m_EventPhysics->SetThirdStageEnergy(-1000); + m_EventPhysics->SetThirdStageTime(-1000); + m_EventPhysics->SetThirdStagePosition(-1000); + } + if (!Check_FourthStage) { + m_EventPhysics->SetFourthStageEnergy(-1000); + m_EventPhysics->SetFourthStageTime(-1000); + m_EventPhysics->SetFourthStagePosition(-1000); + } + if (!Check_FifthStage) { + m_EventPhysics->SetFifthStageEnergy(-1000); + m_EventPhysics->SetFifthStageTime(-1000); + m_EventPhysics->SetFifthStagePosition(-1000); + } + if (!Check_SixthStage) { + m_EventPhysics->SetSixthStageEnergy(-1000); + m_EventPhysics->SetSixthStageTime(-1000); + m_EventPhysics->SetSixthStagePosition(-1000); + } + } + 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 Hyde2TrackerTrapezoid1::BuildSimplePhysicalEvent() +{ +} + + + +void Hyde2TrackerTrapezoid1::AddModule(TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128) +{ + m_NumberOfModule++; + + // Definition of vectors U and V are *identical* with definition + // in NPS. + // Vector U parallel to BaseLarge + TVector3 U = C_X128_Y1 - C_X1_Y1; + U = U.Unit(); + + // Vector V parallel to height + TVector3 V = 0.5 * (C_X1_Y128 + C_X128_Y128 - C_X1_Y1 - C_X128_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; + + // 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 + m_StripPitchX/2*U + m_StripPitchY/2*V; + + for (int i = 0; i < m_NumberOfStripsX; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < m_NumberOfStripsY; j++) { + StripCenter = Strip_1_1 + i*m_StripPitchX*U + j*m_StripPitchY*V; + + 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 Hyde2TrackerTrapezoid1::AddModule(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w) +{ + m_NumberOfModule++; + + // convert from degree to radian: + theta *= M_PI/180; + phi *= M_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 * M_PI/180. , U ) ; + V.Rotate( beta_u * M_PI/180. , U ) ; + + U.Rotate( beta_v * M_PI/180. , V ) ; + V.Rotate( beta_v * M_PI/180. , V ) ; + + U.Rotate( beta_w * M_PI/180. , W ) ; + V.Rotate( beta_w * M_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 ); +} diff --git a/NPLib/HYDE2/Hyde2TrackerTrapezoid1.h b/NPLib/HYDE2/Hyde2TrackerTrapezoid1.h new file mode 100644 index 0000000000000000000000000000000000000000..d747be07d436035c67330e14b855abed3da59092 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerTrapezoid1.h @@ -0,0 +1,102 @@ +#ifndef Hyde2TrackerTrapezoid1_h +#define Hyde2TrackerTrapezoid1_h 1 + +// C++ headers +#include <string> +#include <map> +#include <vector> + +// ROOT headers +#include "TVector3.h" + +// Hyde2 headers +#include "THyde2TrackerData.h" +#include "THyde2TrackerPhysics.h" +#include "Hyde2TrackerModule.h" + +using namespace std; + + + +class Hyde2TrackerTrapezoid1 : public Hyde2TrackerModule +{ +public: + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + Hyde2TrackerTrapezoid1(map<int, Hyde2TrackerModule*> &Module, THyde2TrackerPhysics* &EventPhysics); + virtual ~Hyde2TrackerTrapezoid1(); + +public: + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule class ///// + //////////////////////////////////////////////////// + // Read stream at Configfile to pick-up parameters of detector (Position,...) + void ReadConfiguration(string Path); + + // The goal of this method is to extract physical parameters from raw data + // Method called at each event read from the Input Tree + void BuildPhysicalEvent(); + + // Same as before but with a simpler treatment + void BuildSimplePhysicalEvent(); + +private: + map<int, Hyde2TrackerModule*> &m_ModuleTest; + THyde2TrackerPhysics* &m_EventPhysics; + +public: + void SetHyde2DataPointer(THyde2TrackerData* hyde2Data) {m_EventData = hyde2Data;}; + void PreTreat(); + +private: + // Hyde2 data coming from THyde2TrackerPhysics through the + // SetHyde2DataPointer method + THyde2TrackerData* m_EventData; + THyde2TrackerData* m_PreTreatData; + +public: + //////////////////////////////// + // Specific to Hyde2Tracker // + //////////////////////////////// + // Add a Module using Corner Coordinate information + void AddModule(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 AddModule(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-m_index["Trapezoid1"]][X-1][Y-1]; } + double GetStripPositionY(int N ,int X ,int Y) { return m_StripPositionY[N-1-m_index["Trapezoid1"]][X-1][Y-1]; } + double GetStripPositionZ(int N ,int X ,int Y) { return m_StripPositionZ[N-1-m_index["Trapezoid1"]][X-1][Y-1]; } + double GetNumberOfModule() { return m_NumberOfModule; } + +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; + +private: + ////////////////////////////// + // Geometry and stip number // + ////////////////////////////// + double m_FirstStageHeight; // mm + double m_FirstStageBaseLarge; // mm + double m_FirstStageBaseSmall; // mm + int m_NumberOfStripsX; + int m_NumberOfStripsY; + double m_StripPitchX; // mm + double m_StripPitchY; // mm +}; + +#endif diff --git a/NPLib/HYDE2/Hyde2TrackerTrapezoid2.cxx b/NPLib/HYDE2/Hyde2TrackerTrapezoid2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d8e9dbac966e6904b62234b4abf0780c1f34c716 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerTrapezoid2.cxx @@ -0,0 +1,560 @@ +#include "Hyde2TrackerTrapezoid2.h" + +// C++ headers +#include <limits> +#include <iostream> +#include <fstream> +#include <string> +#include <cmath> +#include <stdlib.h> + +// Hyde2 +#include "THyde2TrackerPhysics.h" + + +Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2(map<int, Hyde2TrackerModule*> &Module, + THyde2TrackerPhysics* &EventPhysics) + : m_ModuleTest(Module), + m_EventPhysics(EventPhysics), + m_EventData(0), + m_PreTreatData(new THyde2TrackerData), + m_NumberOfModule(0), + m_FirstStageHeight(50.52), // mm + m_FirstStageBaseLarge(51.62), // mm + m_FirstStageBaseSmall(20.30), // mm + m_NumberOfStripsX(129), + m_NumberOfStripsY(126) +{ + m_StripPitchX = m_FirstStageBaseLarge / (double)m_NumberOfStripsX; + m_StripPitchY = m_FirstStageHeight / (double)m_NumberOfStripsY; +} + + + +Hyde2TrackerTrapezoid2::~Hyde2TrackerTrapezoid2() +{ + delete m_PreTreatData; +} + + + +void Hyde2TrackerTrapezoid2::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; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + + // If line is a Hyde2XXX bloc, reading toggle to true + // and toggle to true flags indicating which shape is treated. + if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0) { + cout << "///////////////////////" << endl; + cout << "Trapezoid2 module found:" << endl; + ReadingStatus = true; + } + + // Reading Block + while (ReadingStatus) { + 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, 14, "HYD2Trapezoid2") == 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 ) { + AddModule(A, B, C, D); + m_ModuleTest[m_index["Trapezoid2"] + m_NumberOfModule] = this; + } + + // with angle method + else if ( check_Theta && check_Phi && check_R && check_beta ) { + AddModule(Theta, Phi, R, beta_u, beta_v, beta_w); + m_ModuleTest[m_index["Trapezoid2"] + m_NumberOfModule] = this; + } + + // 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; + + } // end test for adding a module + } // end while for reading block + } // end while for reading file + + cout << endl << "/////////////////////////////" << endl<<endl; +} + + + +void Hyde2TrackerTrapezoid2::PreTreat() +{ +} + + + +void Hyde2TrackerTrapezoid2::BuildPhysicalEvent() +{ + // Check flags +// bool Check_FirstStage = false; + bool Check_SecondStage = false; + bool Check_ThirdStage = false; + bool Check_FourthStage = false; + bool Check_FifthStage = false; + bool Check_SixthStage = 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 = m_EventData->GetHYD2TrkFirstStageFrontEMult(); + int multYE = m_EventData->GetHYD2TrkFirstStageBackEMult(); + int multXT = m_EventData->GetHYD2TrkFirstStageFrontTMult(); + int multYT = m_EventData->GetHYD2TrkFirstStageBackTMult(); + // calculate multiplicity of 2nd and third stages + int mult2E = m_EventData->GetHYD2TrkSecondStageEMult(); + int mult2T = m_EventData->GetHYD2TrkSecondStageTMult(); + int mult3E = m_EventData->GetHYD2TrkThirdStageEMult(); + int mult3T = m_EventData->GetHYD2TrkThirdStageTMult(); + int mult4E = m_EventData->GetHYD2TrkFourthStageEMult(); + int mult4T = m_EventData->GetHYD2TrkFourthStageTMult(); + int mult5E = m_EventData->GetHYD2TrkFifthStageEMult(); + int mult5T = m_EventData->GetHYD2TrkFifthStageTMult(); + int mult6E = m_EventData->GetHYD2TrkSixthStageEMult(); + int mult6T = m_EventData->GetHYD2TrkSixthStageTMult(); + + // Deal with multiplicity 1 for the first layer + if (multXE==1 && multYE==1 && multXT==1 && multYT==1) { + // calculate detector number + int det_ref = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(0); + int detecXE = m_EventData->GetHYD2TrkFirstStageFrontEDetectorNbr(0) / det_ref; + int detecXT = m_EventData->GetHYD2TrkFirstStageFrontTDetectorNbr(0) / det_ref; + int detecYE = m_EventData->GetHYD2TrkFirstStageBackEDetectorNbr(0) / det_ref; + int detecYT = m_EventData->GetHYD2TrkFirstStageBackTDetectorNbr(0) / det_ref; + + // case of same detector + if (detecXE*detecXT*detecYE*detecYT == 1) { + // store module number + m_EventPhysics->SetModuleNumber(det_ref); + // calculate strip number + int stripXE = m_EventData->GetHYD2TrkFirstStageFrontEStripNbr(0); + int stripXT = m_EventData->GetHYD2TrkFirstStageFrontTStripNbr(0); + int stripYE = m_EventData->GetHYD2TrkFirstStageBackEStripNbr(0); + int stripYT = m_EventData->GetHYD2TrkFirstStageBackTStripNbr(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; + // store strip ID + m_EventPhysics->SetFirstStageFrontPosition(stripXE); + m_EventPhysics->SetFirstStageBackPosition(stripYE); + // get energy from strips and store it + double EnergyStripFront = m_EventData->GetHYD2TrkFirstStageFrontEEnergy(0); + m_EventPhysics->SetFirstStageEnergy(EnergyStripFront); + double EnergyTot = EnergyStripFront; + // get time from strips and store it + double TimeStripBack = m_EventData->GetHYD2TrkFirstStageBackEEnergy(0); + m_EventPhysics->SetFirstStageTime(TimeStripBack); + + // check if we have a 2nd stage event + if (mult2E==1 && mult2T==1) { + Check_SecondStage = true; + double EnergySecond = m_EventData->GetHYD2TrkSecondStageEEnergy(0); + m_EventPhysics->SetSecondStageEnergy(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 = m_EventData->GetHYD2TrkThirdStageEEnergy(0); + m_EventPhysics->SetThirdStageEnergy(EnergyThird); + EnergyTot += EnergyThird; + } + else if (mult3E>1 || mult3T>1) { + cout << "Warning: multiplicity in third stage greater than in firststage" << endl; + } + + // check if we have a fourth stage event + if (mult4E==1 && mult4T==1) { + Check_FourthStage = true; + double EnergyFourth = m_EventData->GetHYD2TrkFourthStageEEnergy(0); + m_EventPhysics->SetFourthStageEnergy(EnergyFourth); + EnergyTot += EnergyFourth; + } + else if (mult4E>1 || mult4T>1) { + cout << "Warning: multiplicity in fourth stage greater than in firststage" << endl; + } + + // check if we have a fifth stage event + if (mult5E==1 && mult5T==1) { + Check_FifthStage = true; + double EnergyFifth = m_EventData->GetHYD2TrkFifthStageEEnergy(0); + m_EventPhysics->SetFifthStageEnergy(EnergyFifth); + EnergyTot += EnergyFifth; + } + else if (mult5E>1 || mult5T>1) { + cout << "Warning: multiplicity in fifth stage greater than in firststage" << endl; + } + + // check if we have a sixth stage event + if (mult6E==1 && mult6T==1) { + Check_SixthStage = true; + double EnergySixth = m_EventData->GetHYD2TrkSixthStageEEnergy(0); + m_EventPhysics->SetSixthStageEnergy(EnergySixth); + EnergyTot += EnergySixth; + } + else if (mult6E>1 || mult6T>1) { + cout << "Warning: multiplicity in sixth stage greater than in firststage" << endl; + } + + // Fill total energy + m_EventPhysics->SetTotalEnergy(EnergyTot); + + // Fill default values for second an third stages + if (!Check_SecondStage) { + m_EventPhysics->SetSecondStageEnergy(-1000); + m_EventPhysics->SetSecondStageTime(-1000); + m_EventPhysics->SetSecondStagePosition(-1000); + } + if (!Check_ThirdStage) { + m_EventPhysics->SetThirdStageEnergy(-1000); + m_EventPhysics->SetThirdStageTime(-1000); + m_EventPhysics->SetThirdStagePosition(-1000); + } + if (!Check_FourthStage) { + m_EventPhysics->SetFourthStageEnergy(-1000); + m_EventPhysics->SetFourthStageTime(-1000); + m_EventPhysics->SetFourthStagePosition(-1000); + } + if (!Check_FifthStage) { + m_EventPhysics->SetFifthStageEnergy(-1000); + m_EventPhysics->SetFifthStageTime(-1000); + m_EventPhysics->SetFifthStagePosition(-1000); + } + if (!Check_SixthStage) { + m_EventPhysics->SetSixthStageEnergy(-1000); + m_EventPhysics->SetSixthStageTime(-1000); + m_EventPhysics->SetSixthStagePosition(-1000); + } + } + 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 Hyde2TrackerTrapezoid2::BuildSimplePhysicalEvent() +{ +} + + + +void Hyde2TrackerTrapezoid2::AddModule(TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128) +{ + m_NumberOfModule++; + + // Definition of vectors U and V are *identical* with definition + // in NPS. + // Vector U parallel to BaseLarge + TVector3 U = C_X128_Y1 - C_X1_Y1; + U = U.Unit(); + + // Vector V parallel to height + TVector3 V = 0.5 * (C_X1_Y128 + C_X128_Y128 - C_X1_Y1 - C_X128_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; + + // 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 + m_StripPitchX/2*U + m_StripPitchY/2*V; + + for (int i = 0; i < m_NumberOfStripsX; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < m_NumberOfStripsY; j++) { + StripCenter = Strip_1_1 + i*m_StripPitchX*U + j*m_StripPitchY*V; + + 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 Hyde2TrackerTrapezoid2::AddModule(double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w) +{ + m_NumberOfModule++; + + // convert from degree to radian: + theta *= M_PI/180; + phi *= M_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 * M_PI/180. , U ) ; + V.Rotate( beta_u * M_PI/180. , U ) ; + + U.Rotate( beta_v * M_PI/180. , V ) ; + V.Rotate( beta_v * M_PI/180. , V ) ; + + U.Rotate( beta_w * M_PI/180. , W ) ; + V.Rotate( beta_w * M_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 ); +} diff --git a/NPLib/HYDE2/Hyde2TrackerTrapezoid2.h b/NPLib/HYDE2/Hyde2TrackerTrapezoid2.h new file mode 100644 index 0000000000000000000000000000000000000000..7959cbf03b6a817764ac09a7a6974c0784c32350 --- /dev/null +++ b/NPLib/HYDE2/Hyde2TrackerTrapezoid2.h @@ -0,0 +1,102 @@ +#ifndef Hyde2TrackerTrapezoid2_h +#define Hyde2TrackerTrapezoid2_h 1 + +// C++ headers +#include <string> +#include <map> +#include <vector> + +// ROOT headers +#include "TVector3.h" + +// Hyde2 headers +#include "THyde2TrackerData.h" +#include "THyde2TrackerPhysics.h" +#include "Hyde2TrackerModule.h" + +using namespace std; + + + +class Hyde2TrackerTrapezoid2 : public Hyde2TrackerModule +{ +public: + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + Hyde2TrackerTrapezoid2(map<int, Hyde2TrackerModule*> &Module, THyde2TrackerPhysics* &EventPhysics); + virtual ~Hyde2TrackerTrapezoid2(); + +public: + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule class ///// + //////////////////////////////////////////////////// + // Read stream at Configfile to pick-up parameters of detector (Position,...) + void ReadConfiguration(string Path); + + // The goal of this method is to extract physical parameters from raw data + // Method called at each event read from the Input Tree + void BuildPhysicalEvent(); + + // Same as before but with a simpler treatment + void BuildSimplePhysicalEvent(); + +private: + map<int, Hyde2TrackerModule*> &m_ModuleTest; + THyde2TrackerPhysics* &m_EventPhysics; + +public: + void SetHyde2DataPointer(THyde2TrackerData* hyde2Data) {m_EventData = hyde2Data;}; + void PreTreat(); + +private: + // Hyde2 data coming from THyde2TrackerPhysics through the + // SetHyde2DataPointer method + THyde2TrackerData* m_EventData; + THyde2TrackerData* m_PreTreatData; + +public: + //////////////////////////////// + // Specific to Hyde2Tracker // + //////////////////////////////// + // Add a Module using Corner Coordinate information + void AddModule(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 AddModule(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-m_index["Trapezoid2"]][X-1][Y-1]; } + double GetStripPositionY(int N ,int X ,int Y) { return m_StripPositionY[N-1-m_index["Trapezoid2"]][X-1][Y-1]; } + double GetStripPositionZ(int N ,int X ,int Y) { return m_StripPositionZ[N-1-m_index["Trapezoid2"]][X-1][Y-1]; } + double GetNumberOfModule() { return m_NumberOfModule; } + +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; + +private: + ////////////////////////////// + // Geometry and stip number // + ////////////////////////////// + double m_FirstStageHeight; // mm + double m_FirstStageBaseLarge; // mm + double m_FirstStageBaseSmall; // mm + int m_NumberOfStripsX; + int m_NumberOfStripsY; + double m_StripPitchX; // mm + double m_StripPitchY; // mm +}; + +#endif diff --git a/NPLib/HYDE2/Makefile b/NPLib/HYDE2/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f4683340f6454ac7214b0fad0405cb6359b6c497 --- /dev/null +++ b/NPLib/HYDE2/Makefile @@ -0,0 +1,54 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libHyde2Data.so \ + libHyde2TrackerModules.so libHyde2Physics.so +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## Hyde2 ## +libHyde2Data.so: THyde2TrackerData.o THyde2TrackerDataDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THyde2TrackerDataDict.cxx: THyde2TrackerData.h + rootcint -f $@ -c $^ + +libHyde2Physics.so: Hyde2Tracker.o THyde2TrackerPhysics.o \ + THyde2TrackerPhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THyde2TrackerPhysicsDict.cxx: THyde2TrackerPhysics.h + rootcint -f $@ -c $^ + +libHyde2TrackerModules.so: Hyde2TrackerModule.o Hyde2TrackerSquare1.o \ + Hyde2TrackerTrapezoid1.o Hyde2TrackerTrapezoid2.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + + + +# dependances +Hyde2Tracker.o: Hyde2Tracker.cxx Hyde2Tracker.h +THyde2TrackerData.o: THyde2TrackerData.cxx THyde2TrackerData.h +THyde2TrackerPhysics.o: THyde2TrackerPhysics.cxx THyde2TrackerPhysics.h +Hyde2TrackerModule.o: Hyde2TrackerModule.cxx Hyde2TrackerModule.h +Hyde2TrackerSquare1.o: Hyde2TrackerSquare1.cxx Hyde2TrackerSquare1.h +Hyde2TrackerTrapezoid1.o: Hyde2TrackerTrapezoid1.cxx Hyde2TrackerTrapezoid1.h +Hyde2TrackerTrapezoid2.o: Hyde2TrackerTrapezoid2.cxx Hyde2TrackerTrapezoid2.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/HYDE2/Makefile_longer b/NPLib/HYDE2/Makefile_longer new file mode 100644 index 0000000000000000000000000000000000000000..f4683340f6454ac7214b0fad0405cb6359b6c497 --- /dev/null +++ b/NPLib/HYDE2/Makefile_longer @@ -0,0 +1,54 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libHyde2Data.so \ + libHyde2TrackerModules.so libHyde2Physics.so +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## Hyde2 ## +libHyde2Data.so: THyde2TrackerData.o THyde2TrackerDataDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THyde2TrackerDataDict.cxx: THyde2TrackerData.h + rootcint -f $@ -c $^ + +libHyde2Physics.so: Hyde2Tracker.o THyde2TrackerPhysics.o \ + THyde2TrackerPhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THyde2TrackerPhysicsDict.cxx: THyde2TrackerPhysics.h + rootcint -f $@ -c $^ + +libHyde2TrackerModules.so: Hyde2TrackerModule.o Hyde2TrackerSquare1.o \ + Hyde2TrackerTrapezoid1.o Hyde2TrackerTrapezoid2.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + + + +# dependances +Hyde2Tracker.o: Hyde2Tracker.cxx Hyde2Tracker.h +THyde2TrackerData.o: THyde2TrackerData.cxx THyde2TrackerData.h +THyde2TrackerPhysics.o: THyde2TrackerPhysics.cxx THyde2TrackerPhysics.h +Hyde2TrackerModule.o: Hyde2TrackerModule.cxx Hyde2TrackerModule.h +Hyde2TrackerSquare1.o: Hyde2TrackerSquare1.cxx Hyde2TrackerSquare1.h +Hyde2TrackerTrapezoid1.o: Hyde2TrackerTrapezoid1.cxx Hyde2TrackerTrapezoid1.h +Hyde2TrackerTrapezoid2.o: Hyde2TrackerTrapezoid2.cxx Hyde2TrackerTrapezoid2.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/HYDE2/Makefile_shorter b/NPLib/HYDE2/Makefile_shorter new file mode 100644 index 0000000000000000000000000000000000000000..da31f47e92eee971ded7ab629e75849ed448ce8b --- /dev/null +++ b/NPLib/HYDE2/Makefile_shorter @@ -0,0 +1,42 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libHyde2Data.so libHyde2Physics.so +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## Hyde2 ## +libHyde2Data.so: THyde2TrackerData.o THyde2TrackerDataDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THyde2TrackerDataDict.cxx: THyde2TrackerData.h + rootcint -f $@ -c $^ + +libHyde2Physics.so: Hyde2Tracker.o THyde2TrackerPhysics.o THyde2TrackerPhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +THyde2TrackerPhysicsDict.cxx: THyde2TrackerPhysics.h + rootcint -f $@ -c $^ + +# dependances +Hyde2Tracker.o: Hyde2Tracker.cxx Hyde2Tracker.h +THyde2TrackerData.o: THyde2TrackerData.cxx THyde2TrackerData.h +THyde2TrackerPhysics.o: THyde2TrackerPhysics.cxx THyde2TrackerPhysics.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/HYDE2/README.txt b/NPLib/HYDE2/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..738a7783ee0365fd2ed69f0ce68bec94a5150702 --- /dev/null +++ b/NPLib/HYDE2/README.txt @@ -0,0 +1,10 @@ +In case we want to create just the following shared libraries: + +libHyde2Physics.so +libHyde2Data.so + +use the makefile Makefile_shorter. Only the following files are needed: + +HydeTracker.(cxx,h) +THydeTrackerData.(cxx,h) +THydeTrackerPhysics.(cxx,h) diff --git a/NPLib/HYDE2/THyde2TrackerData.cxx b/NPLib/HYDE2/THyde2TrackerData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e069e7fbb33c9ec2a1ca8cb8515fe1310f33e4d3 --- /dev/null +++ b/NPLib/HYDE2/THyde2TrackerData.cxx @@ -0,0 +1,195 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 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 "THyde2TrackerData.h" + +ClassImp(THyde2TrackerData) + +THyde2TrackerData::THyde2TrackerData() +{ + // Default constructor + + Clear(); +} + + + +THyde2TrackerData::~THyde2TrackerData() +{ +} + + + +void THyde2TrackerData::Clear() +{ + // DSSD + // (X,E) + fHYD2Trk_FirstStage_FrontE_DetectorNbr.clear(); + fHYD2Trk_FirstStage_FrontE_StripNbr.clear() ; + fHYD2Trk_FirstStage_FrontE_Energy.clear() ; + // (X,T) + fHYD2Trk_FirstStage_FrontT_DetectorNbr.clear() ; + fHYD2Trk_FirstStage_FrontT_StripNbr.clear() ; + fHYD2Trk_FirstStage_FrontT_Time.clear() ; + // (Y,E) + fHYD2Trk_FirstStage_BackE_DetectorNbr.clear() ; + fHYD2Trk_FirstStage_BackE_StripNbr.clear() ; + fHYD2Trk_FirstStage_BackE_Energy.clear() ; + // (Y,T) + fHYD2Trk_FirstStage_BackT_DetectorNbr.clear() ; + fHYD2Trk_FirstStage_BackT_StripNbr.clear() ; + fHYD2Trk_FirstStage_BackT_Time.clear() ; + + // Second Stage + // E + fHYD2Trk_SecondStage_E_DetectorNbr.clear() ; + fHYD2Trk_SecondStage_E_PadNbr.clear() ; + fHYD2Trk_SecondStage_E_Energy.clear() ; + // T + fHYD2Trk_SecondStage_T_DetectorNbr.clear() ; + fHYD2Trk_SecondStage_T_PadNbr.clear() ; + fHYD2Trk_SecondStage_T_Time.clear() ; + + // Third Stage + // E + fHYD2Trk_ThirdStage_E_DetectorNbr.clear() ; + fHYD2Trk_ThirdStage_E_PadNbr.clear() ; + fHYD2Trk_ThirdStage_E_Energy.clear() ; + // T + fHYD2Trk_ThirdStage_T_DetectorNbr.clear() ; + fHYD2Trk_ThirdStage_T_PadNbr.clear() ; + fHYD2Trk_ThirdStage_T_Time.clear() ; + + // Fourth Stage + // E + fHYD2Trk_FourthStage_E_DetectorNbr.clear() ; + fHYD2Trk_FourthStage_E_PadNbr.clear() ; + fHYD2Trk_FourthStage_E_Energy.clear() ; + // T + fHYD2Trk_FourthStage_T_DetectorNbr.clear() ; + fHYD2Trk_FourthStage_T_PadNbr.clear() ; + fHYD2Trk_FourthStage_T_Time.clear() ; + + // Fifth Stage + // E + fHYD2Trk_FifthStage_E_DetectorNbr.clear() ; + fHYD2Trk_FifthStage_E_PadNbr.clear() ; + fHYD2Trk_FifthStage_E_Energy.clear() ; + // T + fHYD2Trk_FifthStage_T_DetectorNbr.clear() ; + fHYD2Trk_FifthStage_T_PadNbr.clear() ; + fHYD2Trk_FifthStage_T_Time.clear() ; + + // Sixth Stage + // E + fHYD2Trk_SixthStage_E_DetectorNbr.clear() ; + fHYD2Trk_SixthStage_E_PadNbr.clear() ; + fHYD2Trk_SixthStage_E_Energy.clear() ; + // T + fHYD2Trk_SixthStage_T_DetectorNbr.clear() ; + fHYD2Trk_SixthStage_T_PadNbr.clear() ; + fHYD2Trk_SixthStage_T_Time.clear() ; + +} + + + +void THyde2TrackerData::Dump() const +{ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event XXXXXXXXXXXXXXXXX" << endl; + + // DSSD + // (X,E) + cout << "HYD2Trk_FirstStage_FrontE_Mult = " << fHYD2Trk_FirstStage_FrontE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FirstStage_FrontE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYD2Trk_FirstStage_FrontE_DetectorNbr[i] << " Strip: " << fHYD2Trk_FirstStage_FrontE_StripNbr[i] << " Energy: " << fHYD2Trk_FirstStage_FrontE_Energy[i] << endl; + // (X,T) + cout << "HYD2Trk_FirstStage_FrontT_Mult = " << fHYD2Trk_FirstStage_FrontT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FirstStage_FrontT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYD2Trk_FirstStage_FrontT_DetectorNbr[i] << " Strip: " << fHYD2Trk_FirstStage_FrontT_StripNbr[i] << " Time: " << fHYD2Trk_FirstStage_FrontT_Time[i] << endl; + // (Y,E) + cout << "HYD2Trk_FirstStage_BackE_Mult = " << fHYD2Trk_FirstStage_BackE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FirstStage_BackE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYD2Trk_FirstStage_BackE_DetectorNbr[i] << " Strip: " << fHYD2Trk_FirstStage_BackE_StripNbr[i] << " Energy: " << fHYD2Trk_FirstStage_BackE_Energy[i] << endl; + // (Y,T) + cout << "HYD2Trk_FirstStage_BackT_Mult = " << fHYD2Trk_FirstStage_BackT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FirstStage_BackT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fHYD2Trk_FirstStage_BackT_DetectorNbr[i] << " Strip: " << fHYD2Trk_FirstStage_BackT_StripNbr[i] << " Time: " << fHYD2Trk_FirstStage_BackT_Time[i] << endl; + + // Second Stage + // Energy + cout << "HYD2Trk_SecondStage_E_Mult = " << fHYD2Trk_SecondStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_SecondStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_SecondStage_E_DetectorNbr[i] << " Pad: " << fHYD2Trk_SecondStage_E_PadNbr[i] << " Energy: " << fHYD2Trk_SecondStage_E_Energy[i] << endl; + // Time + cout << "HYD2Trk_SecondStage_T_Mult = " << fHYD2Trk_SecondStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_SecondStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_SecondStage_T_DetectorNbr[i] << " Pad: " << fHYD2Trk_SecondStage_T_PadNbr[i] << " Time: " << fHYD2Trk_SecondStage_T_Time[i] << endl; + + // Third Stage + // Energy + cout << "HYD2Trk_ThirdStage_E_Mult = " << fHYD2Trk_ThirdStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_ThirdStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_ThirdStage_E_DetectorNbr[i] << " Pad: " << fHYD2Trk_ThirdStage_E_PadNbr[i] << " Energy: " << fHYD2Trk_ThirdStage_E_Energy[i] << endl; + // Time + cout << "HYD2Trk_ThirdStage_T_Mult = " << fHYD2Trk_ThirdStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_ThirdStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_ThirdStage_T_DetectorNbr[i] << " Pad: " << fHYD2Trk_ThirdStage_T_PadNbr[i] << " Time: " << fHYD2Trk_ThirdStage_T_Time[i] << endl; + + // Fourth Stage + // Energy + cout << "HYD2Trk_FourthStage_E_Mult = " << fHYD2Trk_FourthStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FourthStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_FourthStage_E_DetectorNbr[i] << " Pad: " << fHYD2Trk_FourthStage_E_PadNbr[i] << " Energy: " << fHYD2Trk_FourthStage_E_Energy[i] << endl; + // Time + cout << "HYD2Trk_FourthStage_T_Mult = " << fHYD2Trk_FourthStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FourthStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_FourthStage_T_DetectorNbr[i] << " Pad: " << fHYD2Trk_FourthStage_T_PadNbr[i] << " Time: " << fHYD2Trk_FourthStage_T_Time[i] << endl; + + // Fifth Stage + // Energy + cout << "HYD2Trk_FifthStage_E_Mult = " << fHYD2Trk_FifthStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FifthStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_FifthStage_E_DetectorNbr[i] << " Pad: " << fHYD2Trk_FifthStage_E_PadNbr[i] << " Energy: " << fHYD2Trk_FifthStage_E_Energy[i] << endl; + // Time + cout << "HYD2Trk_FifthStage_T_Mult = " << fHYD2Trk_FifthStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_FifthStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_FifthStage_T_DetectorNbr[i] << " Pad: " << fHYD2Trk_FifthStage_T_PadNbr[i] << " Time: " << fHYD2Trk_FifthStage_T_Time[i] << endl; + + // Sixth Stage + // Energy + cout << "HYD2Trk_SixthStage_E_Mult = " << fHYD2Trk_SixthStage_E_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_SixthStage_E_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_SixthStage_E_DetectorNbr[i] << " Pad: " << fHYD2Trk_SixthStage_E_PadNbr[i] << " Energy: " << fHYD2Trk_SixthStage_E_Energy[i] << endl; + // Time + cout << "HYD2Trk_SixthStage_T_Mult = " << fHYD2Trk_SixthStage_T_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fHYD2Trk_SixthStage_T_DetectorNbr.size(); i++) + cout << "Det: " << fHYD2Trk_SixthStage_T_DetectorNbr[i] << " Pad: " << fHYD2Trk_SixthStage_T_PadNbr[i] << " Time: " << fHYD2Trk_SixthStage_T_Time[i] << endl; + +} diff --git a/NPLib/HYDE2/THyde2TrackerData.h b/NPLib/HYDE2/THyde2TrackerData.h new file mode 100644 index 0000000000000000000000000000000000000000..6768153a81831a5c9e60145cd8b675b07f03a69e --- /dev/null +++ b/NPLib/HYDE2/THyde2TrackerData.h @@ -0,0 +1,471 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 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 __HYDE2TRACKERDATA__ +#define __HYDE2TRACKERDATA__ + +#include <vector> +#include "TObject.h" + +using namespace std ; + +class THyde2TrackerData : public TObject +{ +protected: + // First Stage + // Double Sided Silicon Detector + // Front + // Energy + vector<UShort_t> fHYD2Trk_FirstStage_FrontE_DetectorNbr; + vector<UShort_t> fHYD2Trk_FirstStage_FrontE_StripNbr; + vector<Double_t> fHYD2Trk_FirstStage_FrontE_Energy; + // Time + vector<UShort_t> fHYD2Trk_FirstStage_FrontT_DetectorNbr; + vector<UShort_t> fHYD2Trk_FirstStage_FrontT_StripNbr; + vector<Double_t> fHYD2Trk_FirstStage_FrontT_Time; + // Back + // Energy + vector<UShort_t> fHYD2Trk_FirstStage_BackE_DetectorNbr; + vector<UShort_t> fHYD2Trk_FirstStage_BackE_StripNbr; + vector<Double_t> fHYD2Trk_FirstStage_BackE_Energy; + // Time + vector<UShort_t> fHYD2Trk_FirstStage_BackT_DetectorNbr; + vector<UShort_t> fHYD2Trk_FirstStage_BackT_StripNbr; + vector<Double_t> fHYD2Trk_FirstStage_BackT_Time; + + // Second Stage + // Energy + vector<UShort_t> fHYD2Trk_SecondStage_E_DetectorNbr; + vector<UShort_t> fHYD2Trk_SecondStage_E_PadNbr; + vector<Double_t> fHYD2Trk_SecondStage_E_Energy; + // Time + vector<UShort_t> fHYD2Trk_SecondStage_T_DetectorNbr; + vector<UShort_t> fHYD2Trk_SecondStage_T_PadNbr; + vector<Double_t> fHYD2Trk_SecondStage_T_Time; + + // Third Stage + // Energy + vector<UShort_t> fHYD2Trk_ThirdStage_E_DetectorNbr; + vector<UShort_t> fHYD2Trk_ThirdStage_E_PadNbr; + vector<Double_t> fHYD2Trk_ThirdStage_E_Energy; + // Time + vector<UShort_t> fHYD2Trk_ThirdStage_T_DetectorNbr; + vector<UShort_t> fHYD2Trk_ThirdStage_T_PadNbr; + vector<Double_t> fHYD2Trk_ThirdStage_T_Time; + + // Fourth Stage + // Energy + vector<UShort_t> fHYD2Trk_FourthStage_E_DetectorNbr; + vector<UShort_t> fHYD2Trk_FourthStage_E_PadNbr; + vector<Double_t> fHYD2Trk_FourthStage_E_Energy; + // Time + vector<UShort_t> fHYD2Trk_FourthStage_T_DetectorNbr; + vector<UShort_t> fHYD2Trk_FourthStage_T_PadNbr; + vector<Double_t> fHYD2Trk_FourthStage_T_Time; + + // Fifth Stage + // Energy + vector<UShort_t> fHYD2Trk_FifthStage_E_DetectorNbr; + vector<UShort_t> fHYD2Trk_FifthStage_E_PadNbr; + vector<Double_t> fHYD2Trk_FifthStage_E_Energy; + // Time + vector<UShort_t> fHYD2Trk_FifthStage_T_DetectorNbr; + vector<UShort_t> fHYD2Trk_FifthStage_T_PadNbr; + vector<Double_t> fHYD2Trk_FifthStage_T_Time; + + // Sixth Stage + // Energy + vector<UShort_t> fHYD2Trk_SixthStage_E_DetectorNbr; + vector<UShort_t> fHYD2Trk_SixthStage_E_PadNbr; + vector<Double_t> fHYD2Trk_SixthStage_E_Energy; + // Time + vector<UShort_t> fHYD2Trk_SixthStage_T_DetectorNbr; + vector<UShort_t> fHYD2Trk_SixthStage_T_PadNbr; + vector<Double_t> fHYD2Trk_SixthStage_T_Time; + +public: + THyde2TrackerData(); + virtual ~THyde2TrackerData(); + + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + ///////////////////// SETTERS //////////////////////// + // DSSD + // (Front, E) + void SetHYD2TrkFirstStageFrontEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FirstStage_FrontE_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFirstStageFrontEStripNbr(UShort_t StripNbr) { + fHYD2Trk_FirstStage_FrontE_StripNbr.push_back(StripNbr); + } + void SetHYD2TrkFirstStageFrontEEnergy(Double_t Energy) { + fHYD2Trk_FirstStage_FrontE_Energy.push_back(Energy); + } + // (Front, T) + void SetHYD2TrkFirstStageFrontTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FirstStage_FrontT_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFirstStageFrontTStripNbr(UShort_t StripNbr) { + fHYD2Trk_FirstStage_FrontT_StripNbr.push_back(StripNbr); + } + void SetHYD2TrkFirstStageFrontTTime(Double_t Time) { + fHYD2Trk_FirstStage_FrontT_Time.push_back(Time); + } + + // (Back, E) + void SetHYD2TrkFirstStageBackEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FirstStage_BackE_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFirstStageBackEStripNbr(UShort_t StripNbr) { + fHYD2Trk_FirstStage_BackE_StripNbr.push_back(StripNbr); + } + void SetHYD2TrkFirstStageBackEEnergy(Double_t Energy) { + fHYD2Trk_FirstStage_BackE_Energy.push_back(Energy); + } + // (Back, T) + void SetHYD2TrkFirstStageBackTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FirstStage_BackT_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFirstStageBackTStripNbr(UShort_t StripNbr) { + fHYD2Trk_FirstStage_BackT_StripNbr.push_back(StripNbr); + } + void SetHYD2TrkFirstStageBackTTime(Double_t Time) { + fHYD2Trk_FirstStage_BackT_Time.push_back(Time); + } + + // Second Stage + // (E) + void SetHYD2TrkSecondStageEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_SecondStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkSecondStageEPadNbr(UShort_t PadNbr) { + fHYD2Trk_SecondStage_E_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkSecondStageEEnergy(Double_t Energy) { + fHYD2Trk_SecondStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYD2TrkSecondStageTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_SecondStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkSecondStageTPadNbr(UShort_t PadNbr) { + fHYD2Trk_SecondStage_T_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkSecondStageTTime(Double_t Time) { + fHYD2Trk_SecondStage_T_Time.push_back(Time); + } + + // Third Stage + // (E) + void SetHYD2TrkThirdStageEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_ThirdStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkThirdStageEPadNbr(UShort_t PadNbr) { + fHYD2Trk_ThirdStage_E_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkThirdStageEEnergy(Double_t Energy) { + fHYD2Trk_ThirdStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYD2TrkThirdStageTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_ThirdStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkThirdStageTPadNbr(UShort_t PadNbr) { + fHYD2Trk_ThirdStage_T_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkThirdStageTTime(Double_t Time) { + fHYD2Trk_ThirdStage_T_Time.push_back(Time); + } + + // Fourth Stage + // (E) + void SetHYD2TrkFourthStageEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FourthStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFourthStageEPadNbr(UShort_t PadNbr) { + fHYD2Trk_FourthStage_E_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkFourthStageEEnergy(Double_t Energy) { + fHYD2Trk_FourthStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYD2TrkFourthStageTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FourthStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFourthStageTPadNbr(UShort_t PadNbr) { + fHYD2Trk_FourthStage_T_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkFourthStageTTime(Double_t Time) { + fHYD2Trk_FourthStage_T_Time.push_back(Time); + } + + // Fifth Stage + // (E) + void SetHYD2TrkFifthStageEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FifthStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFifthStageEPadNbr(UShort_t PadNbr) { + fHYD2Trk_FifthStage_E_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkFifthStageEEnergy(Double_t Energy) { + fHYD2Trk_FifthStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYD2TrkFifthStageTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_FifthStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkFifthStageTPadNbr(UShort_t PadNbr) { + fHYD2Trk_FifthStage_T_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkFifthStageTTime(Double_t Time) { + fHYD2Trk_FifthStage_T_Time.push_back(Time); + } + + // Sixth Stage + // (E) + void SetHYD2TrkSixthStageEDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_SixthStage_E_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkSixthStageEPadNbr(UShort_t PadNbr) { + fHYD2Trk_SixthStage_E_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkSixthStageEEnergy(Double_t Energy) { + fHYD2Trk_SixthStage_E_Energy.push_back(Energy); + } + // (T) + void SetHYD2TrkSixthStageTDetectorNbr(UShort_t DetNbr) { + fHYD2Trk_SixthStage_T_DetectorNbr.push_back(DetNbr); + } + void SetHYD2TrkSixthStageTPadNbr(UShort_t PadNbr) { + fHYD2Trk_SixthStage_T_PadNbr.push_back(PadNbr); + } + void SetHYD2TrkSixthStageTTime(Double_t Time) { + fHYD2Trk_SixthStage_T_Time.push_back(Time); + } + + + ///////////////////// GETTERS //////////////////////// + // DSSD + // (Front, E) + UShort_t GetHYD2TrkFirstStageFrontEMult() { + return fHYD2Trk_FirstStage_FrontE_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFirstStageFrontEDetectorNbr(Int_t i) { + return fHYD2Trk_FirstStage_FrontE_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFirstStageFrontEStripNbr(Int_t i) { + return fHYD2Trk_FirstStage_FrontE_StripNbr.at(i); + } + Double_t GetHYD2TrkFirstStageFrontEEnergy(Int_t i) { + return fHYD2Trk_FirstStage_FrontE_Energy.at(i); + } + // (Front, T) + UShort_t GetHYD2TrkFirstStageFrontTMult() { + return fHYD2Trk_FirstStage_FrontT_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFirstStageFrontTDetectorNbr(Int_t i) { + return fHYD2Trk_FirstStage_FrontT_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFirstStageFrontTStripNbr(Int_t i) { + return fHYD2Trk_FirstStage_FrontT_StripNbr.at(i); + } + Double_t GetHYD2TrkFirstStageFrontTTime(Int_t i) { + return fHYD2Trk_FirstStage_FrontT_Time.at(i); + } + // (Back, E) + UShort_t GetHYD2TrkFirstStageBackEMult() { + return fHYD2Trk_FirstStage_BackE_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFirstStageBackEDetectorNbr(Int_t i) { + return fHYD2Trk_FirstStage_BackE_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFirstStageBackEStripNbr(Int_t i) { + return fHYD2Trk_FirstStage_BackE_StripNbr.at(i); + } + Double_t GetHYD2TrkFirstStageBackEEnergy(Int_t i) { + return fHYD2Trk_FirstStage_BackE_Energy.at(i); + } + // (Back, T) + UShort_t GetHYD2TrkFirstStageBackTMult() { + return fHYD2Trk_FirstStage_BackT_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFirstStageBackTDetectorNbr(Int_t i) { + return fHYD2Trk_FirstStage_BackT_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFirstStageBackTStripNbr(Int_t i) { + return fHYD2Trk_FirstStage_BackT_StripNbr.at(i); + } + Double_t GetHYD2TrkFirstStageBackTTime(Int_t i) { + return fHYD2Trk_FirstStage_BackT_Time.at(i); + } + + // Second Stage + // (E) + UShort_t GetHYD2TrkSecondStageEMult() { + return fHYD2Trk_SecondStage_E_DetectorNbr.size(); + } + UShort_t GetHYD2TrkSecondStageEDetectorNbr(Int_t i) { + return fHYD2Trk_SecondStage_E_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkSecondStageEPadNbr(Int_t i) { + return fHYD2Trk_SecondStage_E_PadNbr.at(i); + } + Double_t GetHYD2TrkSecondStageEEnergy(Int_t i) { + return fHYD2Trk_SecondStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYD2TrkSecondStageTMult() { + return fHYD2Trk_SecondStage_T_DetectorNbr.size(); + } + UShort_t GetHYD2TrkSecondStageTDetectorNbr(Int_t i) { + return fHYD2Trk_SecondStage_T_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkSecondStageTPadNbr(Int_t i) { + return fHYD2Trk_SecondStage_T_PadNbr.at(i); + } + Double_t GetHYD2TrkSecondStageTTime(Int_t i) { + return fHYD2Trk_SecondStage_T_Time.at(i); + } + + // Third Stage + // (E) + UShort_t GetHYD2TrkThirdStageEMult() { + return fHYD2Trk_ThirdStage_E_DetectorNbr.size(); + } + UShort_t GetHYD2TrkThirdStageEDetectorNbr(Int_t i) { + return fHYD2Trk_ThirdStage_E_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkThirdStageEPadNbr(Int_t i) { + return fHYD2Trk_ThirdStage_E_PadNbr.at(i); + } + Double_t GetHYD2TrkThirdStageEEnergy(Int_t i) { + return fHYD2Trk_ThirdStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYD2TrkThirdStageTMult() { + return fHYD2Trk_ThirdStage_T_DetectorNbr.size(); + } + UShort_t GetHYD2TrkThirdStageTDetectorNbr(Int_t i) { + return fHYD2Trk_ThirdStage_T_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkThirdStageTPadNbr(Int_t i) { + return fHYD2Trk_ThirdStage_T_PadNbr.at(i); + } + Double_t GetHYD2TrkThirdStageTTime(Int_t i) { + return fHYD2Trk_ThirdStage_T_Time.at(i); + } + + // Fourth Stage + // (E) + UShort_t GetHYD2TrkFourthStageEMult() { + return fHYD2Trk_FourthStage_E_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFourthStageEDetectorNbr(Int_t i) { + return fHYD2Trk_FourthStage_E_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFourthStageEPadNbr(Int_t i) { + return fHYD2Trk_FourthStage_E_PadNbr.at(i); + } + Double_t GetHYD2TrkFourthStageEEnergy(Int_t i) { + return fHYD2Trk_FourthStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYD2TrkFourthStageTMult() { + return fHYD2Trk_FourthStage_T_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFourthStageTDetectorNbr(Int_t i) { + return fHYD2Trk_FourthStage_T_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFourthStageTPadNbr(Int_t i) { + return fHYD2Trk_FourthStage_T_PadNbr.at(i); + } + Double_t GetHYD2TrkFourthStageTTime(Int_t i) { + return fHYD2Trk_FourthStage_T_Time.at(i); + } + + // Fifth Stage + // (E) + UShort_t GetHYD2TrkFifthStageEMult() { + return fHYD2Trk_FifthStage_E_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFifthStageEDetectorNbr(Int_t i) { + return fHYD2Trk_FifthStage_E_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFifthStageEPadNbr(Int_t i) { + return fHYD2Trk_FifthStage_E_PadNbr.at(i); + } + Double_t GetHYD2TrkFifthStageEEnergy(Int_t i) { + return fHYD2Trk_FifthStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYD2TrkFifthStageTMult() { + return fHYD2Trk_FifthStage_T_DetectorNbr.size(); + } + UShort_t GetHYD2TrkFifthStageTDetectorNbr(Int_t i) { + return fHYD2Trk_FifthStage_T_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkFifthStageTPadNbr(Int_t i) { + return fHYD2Trk_FifthStage_T_PadNbr.at(i); + } + Double_t GetHYD2TrkFifthStageTTime(Int_t i) { + return fHYD2Trk_FifthStage_T_Time.at(i); + } + + // Sixth Stage + // (E) + UShort_t GetHYD2TrkSixthStageEMult() { + return fHYD2Trk_SixthStage_E_DetectorNbr.size(); + } + UShort_t GetHYD2TrkSixthStageEDetectorNbr(Int_t i) { + return fHYD2Trk_SixthStage_E_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkSixthStageEPadNbr(Int_t i) { + return fHYD2Trk_SixthStage_E_PadNbr.at(i); + } + Double_t GetHYD2TrkSixthStageEEnergy(Int_t i) { + return fHYD2Trk_SixthStage_E_Energy.at(i); + } + // (T) + UShort_t GetHYD2TrkSixthStageTMult() { + return fHYD2Trk_SixthStage_T_DetectorNbr.size(); + } + UShort_t GetHYD2TrkSixthStageTDetectorNbr(Int_t i) { + return fHYD2Trk_SixthStage_T_DetectorNbr.at(i); + } + UShort_t GetHYD2TrkSixthStageTPadNbr(Int_t i) { + return fHYD2Trk_SixthStage_T_PadNbr.at(i); + } + Double_t GetHYD2TrkSixthStageTTime(Int_t i) { + return fHYD2Trk_SixthStage_T_Time.at(i); + } + + + ClassDef(THyde2TrackerData, 1) // Hyde2TrackerData structure +}; + +#endif diff --git a/NPLib/HYDE2/THyde2TrackerPhysics.cxx b/NPLib/HYDE2/THyde2TrackerPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5320b726750e056e651b6b21f7a9b1b90401f1cd --- /dev/null +++ b/NPLib/HYDE2/THyde2TrackerPhysics.cxx @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 detector. * + * This class derives from TObject (ROOT) and its aim is to be * + * stored in the output TTree of NPAnalysis. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "THyde2TrackerPhysics.h" + + +ClassImp(THyde2TrackerPhysics) + + +THyde2TrackerPhysics::THyde2TrackerPhysics() +{ +} + + + +THyde2TrackerPhysics::~THyde2TrackerPhysics() +{ + Clear(); +} + + + +void THyde2TrackerPhysics::Clear() +{ + // General members + fEventType.clear(); + fModuleNumber.clear(); + fTotalEnergy.clear(); + + // First stage + fFirstStage_Energy.clear(); + fFirstStage_Time.clear(); + fFirstStage_FrontPosition.clear(); + fFirstStage_BackPosition.clear(); + + // Second stage + fSecondStage_Energy.clear(); + fSecondStage_Time.clear(); + fSecondStage_Position.clear(); + + // Third stage + fThirdStage_Energy.clear(); + fThirdStage_Time.clear(); + fThirdStage_Position.clear(); + + // Fourth stage + fFourthStage_Energy.clear(); + fFourthStage_Time.clear(); + fFourthStage_Position.clear(); +} diff --git a/NPLib/HYDE2/THyde2TrackerPhysics.h b/NPLib/HYDE2/THyde2TrackerPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..3da145f5cfac4114a8611fc2ae98bbc8ba2defe1 --- /dev/null +++ b/NPLib/HYDE2/THyde2TrackerPhysics.h @@ -0,0 +1,173 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 : 08/10/10 * + *---------------------------------------------------------------------------* + * Decription: This class stores the physical results after NPAnalysis is run* + * for the tracker part of the Hyde2 detector. * + * This class derives from TObject (ROOT) and its aim is to be * + * stored in the output TTree of NPAnalysis. * + *---------------------------------------------------------------------------* + * Comment: * + * + 08/10/10: Change private member names and add setters and getters * + * methods. BuildPhysicalEvent() method is moved to the * + * THyde2Tracker*** classes (N. de Sereville) * + * * + * * + *****************************************************************************/ + +#ifndef THYDE2TRACKERPHYSICS_H +#define THYDE2TRACKERPHYSICS_H + +#include "THyde2TrackerData.h" + +// ROOT +#include "TObject.h" + +// C++ +#include <vector> + +using namespace std ; + + +class THyde2TrackerPhysics : public TObject +{ +public: + THyde2TrackerPhysics(); + ~THyde2TrackerPhysics(); + +public: + void Clear(); + void Clear(const Option_t*) {}; + + +private: + vector<Int_t> fEventType; + vector<Int_t> fModuleNumber; + + // First stage + vector<Double_t> fFirstStage_Energy; + vector<Double_t> fFirstStage_Time; + vector<Int_t> fFirstStage_FrontPosition; + vector<Int_t> fFirstStage_BackPosition; + + // Second stage + vector<Double_t> fSecondStage_Energy; + vector<Double_t> fSecondStage_Time; + vector<Int_t> fSecondStage_Position; + + // Third stage + vector<Double_t> fThirdStage_Energy; + vector<Double_t> fThirdStage_Time; + vector<Int_t> fThirdStage_Position; + + // Fourth stage + vector<Double_t> fFourthStage_Energy; + vector<Double_t> fFourthStage_Time; + vector<Int_t> fFourthStage_Position; + + // Fifth stage + vector<Double_t> fFifthStage_Energy; + vector<Double_t> fFifthStage_Time; + vector<Int_t> fFifthStage_Position; + + // Sixth stage + vector<Double_t> fSixthStage_Energy; + vector<Double_t> fSixthStage_Time; + vector<Int_t> fSixthStage_Position; + + vector<Double_t> fTotalEnergy; + + +public: + ///////////////////////////////////// + // SETTERS // + ///////////////////////////////////// + // General + void SetEventType(Int_t evtType) {fEventType.push_back(evtType);} + void SetModuleNumber(Int_t moduleNbr) {fModuleNumber.push_back(moduleNbr);} + void SetTotalEnergy(Double_t ener) {fTotalEnergy.push_back(ener);} + + // First stage + void SetFirstStageEnergy(Double_t ener) {fFirstStage_Energy.push_back(ener);} + void SetFirstStageTime(Double_t time) {fFirstStage_Time.push_back(time);} + void SetFirstStageFrontPosition(Int_t x) {fFirstStage_FrontPosition.push_back(x);} + void SetFirstStageBackPosition(Int_t y) {fFirstStage_BackPosition.push_back(y);} + + // Second stage + void SetSecondStageEnergy(Double_t ener) {fSecondStage_Energy.push_back(ener);} + void SetSecondStageTime(Double_t time) {fSecondStage_Time.push_back(time);} + void SetSecondStagePosition(Int_t pos) {fSecondStage_Position.push_back(pos);} + + // Third stage + void SetThirdStageEnergy(Double_t ener) {fThirdStage_Energy.push_back(ener);} + void SetThirdStageTime(Double_t time) {fThirdStage_Time.push_back(time);} + void SetThirdStagePosition(Int_t pos) {fThirdStage_Position.push_back(pos);} + + // Fourth stage + void SetFourthStageEnergy(Double_t ener) {fFourthStage_Energy.push_back(ener);} + void SetFourthStageTime(Double_t time) {fFourthStage_Time.push_back(time);} + void SetFourthStagePosition(Int_t pos) {fFourthStage_Position.push_back(pos);} + + // Fifth stage + void SetFifthStageEnergy(Double_t ener) {fFifthStage_Energy.push_back(ener);} + void SetFifthStageTime(Double_t time) {fFifthStage_Time.push_back(time);} + void SetFifthStagePosition(Int_t pos) {fFifthStage_Position.push_back(pos);} + + // Sixth stage + void SetSixthStageEnergy(Double_t ener) {fSixthStage_Energy.push_back(ener);} + void SetSixthStageTime(Double_t time) {fSixthStage_Time.push_back(time);} + void SetSixthStagePosition(Int_t pos) {fSixthStage_Position.push_back(pos);} + + ///////////////////////////////////// + // GETTERS // + ///////////////////////////////////// + // General + Int_t GetEventMultiplicity() {return fTotalEnergy.size();} + Int_t GetEventType(Int_t i) {return fEventType.at(i);} + Int_t GetModuleNumber(Int_t i) {return fModuleNumber.at(i);} + Double_t GetTotalEnergy(Int_t i) {return fTotalEnergy.at(i);} + + // First stage + Double_t GetFirstStageEnergy(Int_t i) {return fFirstStage_Energy.at(i);} + Double_t GetFirstStageTime(Int_t i) {return fFirstStage_Time.at(i);} + Int_t GetFirstStageFrontPosition(Int_t i) {return fFirstStage_FrontPosition.at(i);} + Int_t GetFirstStageBackPosition(Int_t i) {return fFirstStage_BackPosition.at(i);} + + // Second stage + Double_t GetSecondStageEnergy(Int_t i) {return fSecondStage_Energy.at(i);} + Double_t GetSecondStageTime(Int_t i) {return fSecondStage_Time.at(i);} + Int_t GetSecondStagePosition(Int_t i) {return fSecondStage_Position.at(i);} + + // Third stage + Double_t GetThirdStageEnergy(Int_t i) {return fThirdStage_Energy.at(i);} + Double_t GetThirdStageTime(Int_t i) {return fThirdStage_Time.at(i);} + Int_t GetThirdStagePosition(Int_t i) {return fThirdStage_Position.at(i);} + + // Fourth stage + Double_t GetFourthStageEnergy(Int_t i) {return fFourthStage_Energy.at(i);} + Double_t GetFourthStageTime(Int_t i) {return fFourthStage_Time.at(i);} + Int_t GetFourthStagePosition(Int_t i) {return fFourthStage_Position.at(i);} + + // Fifth stage + Double_t GetFifthStageEnergy(Int_t i) {return fFifthStage_Energy.at(i);} + Double_t GetFifthStageTime(Int_t i) {return fFifthStage_Time.at(i);} + Int_t GetFifthStagePosition(Int_t i) {return fFifthStage_Position.at(i);} + + // Sixth stage + Double_t GetSixthStageEnergy(Int_t i) {return fSixthStage_Energy.at(i);} + Double_t GetSixthStageTime(Int_t i) {return fSixthStage_Time.at(i);} + Int_t GetSixthStagePosition(Int_t i) {return fSixthStage_Position.at(i);} + + ClassDef(THyde2TrackerPhysics,1) // THyde2TrackerPhysics structure +}; + +#endif diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx index 7d4cde3dae7350ef75d1cf0e3cc3a453f14f5e21..3bc772a6fcce5927e0e7e04270a7d6e244fa2786 100644 --- a/NPLib/VDetector/DetectorManager.cxx +++ b/NPLib/VDetector/DetectorManager.cxx @@ -37,6 +37,7 @@ #include "TChateauCristalPhysics.h" #include "GaspardTracker.h" #include "HydeTracker.h" +#include "Hyde2Tracker.h" #include "Paris.h" #include "TW1Physics.h" #include "Shield.h" @@ -88,6 +89,7 @@ void DetectorManager::ReadConfigurationFile(string Path) Bool_t GeneralTarget = false; Bool_t GPDTracker = false; Bool_t HYDTracker = false; + Bool_t HYD2Tracker = false; Bool_t ParisDet = false; Bool_t ShieldDet = false; Bool_t W1 = false; @@ -164,6 +166,26 @@ void DetectorManager::ReadConfigurationFile(string Path) // Add array to the VDetector Vector AddDetector("HYDE", myDetector); +#endif + } + //////////////////////////////////////////// + //////////// Search for Hyde //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 12, "Hyde2Tracker") == 0 && HYD2Tracker == false) { +#ifdef INC_HYDE2 + HYD2Tracker = true ; + cout << "//////// Hyde2 Tracker ////////" << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Hyde2Tracker(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("HYDE2", myDetector); #endif } //////////////////////////////////////////// diff --git a/NPSimulation/include/Hyde2Scorers.hh b/NPSimulation/include/Hyde2Scorers.hh new file mode 100644 index 0000000000000000000000000000000000000000..56386ea4072a0f2dfaf06ab3b843f0b5d89dc4e6 --- /dev/null +++ b/NPSimulation/include/Hyde2Scorers.hh @@ -0,0 +1,311 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 * + * Hyde2Tracker*** objects. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef HYD2Scorer_h +#define HYD2Scorer_h 1 + +#include "G4VPrimitiveScorer.hh" +#include "G4THitsMap.hh" + +namespace HYD2SCORERS +{ + +class HYD2ScorerFirstStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerFirstStageEnergy(); + +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 HYD2ScorerSecondStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerSecondStageEnergy(); + +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 HYD2ScorerThirdStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerThirdStageEnergy(); + +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 HYD2ScorerFourthStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFourthStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerFourthStageEnergy(); + +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 HYD2ScorerFifthStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFifthStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerFifthStageEnergy(); + +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 HYD2ScorerSixthStageEnergy : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerSixthStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~HYD2ScorerSixthStageEnergy(); + +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 HYD2ScorerFirstStageFrontStripSquare1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageFrontStripSquare1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageFrontStripSquare1(); + +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 HYD2ScorerFirstStageBackStripSquare1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageBackStripSquare1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageBackStripSquare1(); + +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 HYD2ScorerFirstStageFrontStripTrapezoid1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageFrontStripTrapezoid1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageFrontStripTrapezoid1(); + +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 HYD2ScorerFirstStageBackStripTrapezoid1 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageBackStripTrapezoid1(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageBackStripTrapezoid1(); + +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 HYD2ScorerFirstStageFrontStripTrapezoid2 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageFrontStripTrapezoid2(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageFrontStripTrapezoid2(); + +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 HYD2ScorerFirstStageBackStripTrapezoid2 : public G4VPrimitiveScorer +{ +public: // with description + HYD2ScorerFirstStageBackStripTrapezoid2(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~HYD2ScorerFirstStageBackStripTrapezoid2(); + +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; +}; + +} + +using namespace HYD2SCORERS; +#endif diff --git a/NPSimulation/include/Hyde2Tracker.hh b/NPSimulation/include/Hyde2Tracker.hh new file mode 100644 index 0000000000000000000000000000000000000000..00c26ff5acb3a0a2de1a5d73160a9dfed4f8d884 --- /dev/null +++ b/NPSimulation/include/Hyde2Tracker.hh @@ -0,0 +1,73 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 * + * tracker. It allows to have Hyde2 geometries with an * + * heterogeneous set of modules * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2Tracker_h +#define Hyde2Tracker_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "VDetector.hh" +#include "Hyde2TrackerModule.hh" + +using namespace std; + + + +class Hyde2Tracker : public VDetector +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2Tracker(); + virtual ~Hyde2Tracker(); + + //////////////////////////////////////////////////// + ///////// 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<Hyde2TrackerModule*> m_Modules; +}; +#endif diff --git a/NPSimulation/include/Hyde2TrackerModule.hh b/NPSimulation/include/Hyde2TrackerModule.hh new file mode 100644 index 0000000000000000000000000000000000000000..4ea863639451788496f209f4c99871c14c2bf9dd --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerModule.hh @@ -0,0 +1,114 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerModule_h +#define Hyde2TrackerModule_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 "THyde2TrackerData.h" + +using namespace std; + + + +class Hyde2TrackerModule +{ +public: + Hyde2TrackerModule(); + virtual ~Hyde2TrackerModule(); + +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 Hyde2TrackerModule 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 Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** does not derive from VDetector + virtual void SetInterCoordPointer(TInteractionCoordinates* interCoord) = 0; + virtual TInteractionCoordinates* GetInterCoordPointer() = 0; + + // Initialize the Index map for the different modules of Hyde2 + void InitializeIndex(); + +public: + THyde2TrackerData* GetEventPointer() {return ms_Event;}; + +protected: + // Class to store the result of simulation + static THyde2TrackerData* 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; + vector<bool> m_wFourthStage; + vector<bool> m_wFifthStage; + vector<bool> m_wSixthStage; + + // 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; + + // Fourth stage Associate Scorer + G4MultiFunctionalDetector* m_FourthStageScorer; + + // Fifth stage Associate Scorer + G4MultiFunctionalDetector* m_FifthStageScorer; + + // Sixth stage Associate Scorer + G4MultiFunctionalDetector* m_SixthStageScorer; + +protected: + map<string, int> m_index; +}; + +#endif diff --git a/NPSimulation/include/Hyde2TrackerSquare1.hh b/NPSimulation/include/Hyde2TrackerSquare1.hh new file mode 100644 index 0000000000000000000000000000000000000000..ab6f53da6a40aacff4be829964197a733fbf2d04 --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerSquare1.hh @@ -0,0 +1,213 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerSquare1_h +#define Hyde2TrackerSquare1_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "Hyde2TrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class Hyde2TrackerSquare1 : public Hyde2TrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2TrackerSquare1(); + virtual ~Hyde2TrackerSquare1(); + + //////////////////////////////////////////////////// + //////// 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule 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 Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** 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 HYD2SQUARE1 +{ + // Resolution + // If input resolution is Y in MeV units, what is X?? + //ResoFirstStage = X <- X *2.35 = Y; X = Y/2.35 + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0.04255; // = 100 keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.01276; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFourthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFifthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoSixthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeHyd2 = 0.42553; // = 1000ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979; // = 250ps // Unit is ns/2.35 + + // Geometry + //HYDE-TDR + const G4double FaceFront = 97.42*mm; + const G4double FaceBack = 97.42*mm; + const G4double Length = 2.0*cm; + const G4double InterStageDistance = 3*mm; + + // First stage + const G4double FirstStageFace = 87.42*mm; + const G4double FirstStageThickness = 20*micrometer; + const G4int NumberOfStrips = 220; + //const G4int NumberOfStrips = 128; +// const G4double AluFrontThickness = 0.1*micrometer; +// const G4double AluBackThickness = 0.4*micrometer; + + // Second stage + const G4double SecondStageFace = FirstStageFace; + const G4double SecondStageThickness = 100*micrometer; + + // Third stage + const G4double ThirdStageFace = FirstStageFace; + const G4double ThirdStageThickness = 500*micrometer; + + // Fourth stage + const G4double FourthStageFace = FirstStageFace; + const G4double FourthStageThickness = 2000*micrometer; + + // Fifth stage + const G4double FifthStageFace = FirstStageFace; + const G4double FifthStageThickness = 2000*micrometer; + + // Sixth stage + const G4double SixthStageFace = FirstStageFace; + const G4double SixthStageThickness = 1.5*mm; + + // Starting at the front of the first stage and pointing 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; + const G4double FourthStage_PosZ = Length* -0.5 + 0.5*FourthStageThickness + 3*InterStageDistance; + const G4double FifthStage_PosZ = Length* -0.5 + 0.5*FifthStageThickness + 4*InterStageDistance; + const G4double SixthStage_PosZ = Length* -0.5 + 0.5*SixthStageThickness + 5*InterStageDistance; + +// 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/Hyde2TrackerTrapezoid1.hh b/NPSimulation/include/Hyde2TrackerTrapezoid1.hh new file mode 100644 index 0000000000000000000000000000000000000000..595b9b115434e749132a0018353b428abf51a0aa --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerTrapezoid1.hh @@ -0,0 +1,220 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerTrapezoid1_h +#define Hyde2TrackerTrapezoid1_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "Hyde2TrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class Hyde2TrackerTrapezoid1 : public Hyde2TrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2TrackerTrapezoid1(); + virtual ~Hyde2TrackerTrapezoid1(); + + //////////////////////////////////////////////////// + //////// 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule 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 Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** 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 HYD2TRAP1 +{ + // Resolution + // If input resolution is Y in MeV units, what is X?? + //ResoFirstStage = X <- X *2.35 = Y; X = Y/2.35 + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0.04255; // = 100 keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.01276; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFourthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFifthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoSixthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeHyd2 = 0.42553; // = 1000ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979; // = 250ps // Unit is ns/2.35 + + //HYDE-TDR + const G4double Height = 97.68*mm; + const G4double BaseLarge = 97.43*mm; + const G4double BaseSmall = 62.54*mm; + const G4double Length = 20*mm; + const G4double InterStageDistance = 3*mm; + + // First stage + const G4double FirstStageThickness = 20*micrometer; + const G4int NumberOfStripsX = 214; + const G4int NumberOfStripsY = 220; + //HYDE-TDR + const G4double FirstStageHeight = 87.68*mm; + const G4double FirstStageBaseLarge = 85.48*mm; + const G4double FirstStageBaseSmall = 54.17*mm; + + // Second stage + const G4double SecondStageHeight = FirstStageHeight; + const G4double SecondStageBaseLarge = FirstStageBaseLarge; + const G4double SecondStageBaseSmall = FirstStageBaseSmall; + const G4double SecondStageThickness = 100*micrometer; + + + // Third stage + const G4double ThirdStageHeight = FirstStageHeight; + const G4double ThirdStageBaseLarge = FirstStageBaseLarge; + const G4double ThirdStageBaseSmall = FirstStageBaseSmall; + const G4double ThirdStageThickness = 500*micrometer; + + + // Fourth stage + const G4double FourthStageHeight = FirstStageHeight; + const G4double FourthStageBaseLarge = FirstStageBaseLarge; + const G4double FourthStageBaseSmall = FirstStageBaseSmall; + const G4double FourthStageThickness = 2000*micrometer; + + // Fifth stage + const G4double FifthStageHeight = FirstStageHeight; + const G4double FifthStageBaseLarge = FirstStageBaseLarge; + const G4double FifthStageBaseSmall = FirstStageBaseSmall; + const G4double FifthStageThickness = 2000*micrometer; + + // Sixth stage + const G4double SixthStageHeight = FirstStageHeight; + const G4double SixthStageBaseLarge = FirstStageBaseLarge; + const G4double SixthStageBaseSmall = FirstStageBaseSmall; + const G4double SixthStageThickness = 1.5*mm; + + // Starting at the front of the first stage and pointing 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; + const G4double FourthStage_PosZ = Length* -0.5 + 0.5*FourthStageThickness + 3*InterStageDistance; + const G4double FifthStage_PosZ = Length* -0.5 + 0.5*FifthStageThickness + 4*InterStageDistance; + const G4double SixthStage_PosZ = Length* -0.5 + 0.5*SixthStageThickness + 5*InterStageDistance; +} + +#endif diff --git a/NPSimulation/include/Hyde2TrackerTrapezoid2.hh b/NPSimulation/include/Hyde2TrackerTrapezoid2.hh new file mode 100644 index 0000000000000000000000000000000000000000..3f9559e2e911be217d62a84eb5f091cb59aaecb1 --- /dev/null +++ b/NPSimulation/include/Hyde2TrackerTrapezoid2.hh @@ -0,0 +1,220 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#ifndef Hyde2TrackerTrapezoid2_h +#define Hyde2TrackerTrapezoid2_h 1 + +// C++ headers +#include <vector> + +// NPTool header +#include "Hyde2TrackerModule.hh" +#include "TInteractionCoordinates.h" + +using namespace std; + + + +class Hyde2TrackerTrapezoid2 : public Hyde2TrackerModule +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Hyde2TrackerTrapezoid2(); + virtual ~Hyde2TrackerTrapezoid2(); + + //////////////////////////////////////////////////// + //////// 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage); + + // 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 , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + G4LogicalVolume* world); + + + //////////////////////////////////////////////////// + //// Inherite from Hyde2TrackerModule 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 Hyde2TrackerModule + // This is mandatory since the Hyde2Tracker*** 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 HYD2TRAP2 +{ + // Resolution + // If input resolution is Y in MeV units, what is X?? + //ResoFirstStage = X <- X *2.35 = Y; X = Y/2.35 + // Energy/Time resolutions for the different layers + const G4double ResoFirstStage = 0.04255; // = 100 keV of Resolution // Unit is MeV/2.35 + const G4double ResoSecondStage = 0.01276; // = 30 keV of resolution // Unit is MeV/2.35 + const G4double ResoThirdStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFourthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoFifthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoSixthStage = 0.00851; // = 20 keV of resolution // Unit is MeV/2.35 + const G4double ResoTimeHyd2 = 0.42553; // = 1000ps // Unit is ns/2.35 + const G4double ResoTimePPAC = 0.106382979; // = 250ps // Unit is ns/2.35 + + //HYDE-TDR + const G4double Height = 60.52*mm; + const G4double BaseLarge = 62.54*mm; + const G4double BaseSmall = 27.82*mm; + const G4double Length = 20*mm; + const G4double InterStageDistance = 3*mm; + + // First stage + const G4double FirstStageThickness = 20*micrometer; + const G4int NumberOfStripsX = 129; + const G4int NumberOfStripsY = 126; + //HYDE-TDR + const G4double FirstStageHeight = 50.52*mm; + const G4double FirstStageBaseLarge = 51.62*mm; + const G4double FirstStageBaseSmall = 20.30*mm; + + // Second stage + const G4double SecondStageHeight = FirstStageHeight; + const G4double SecondStageBaseLarge = FirstStageBaseLarge; + const G4double SecondStageBaseSmall = FirstStageBaseSmall; + const G4double SecondStageThickness = 100*micrometer; + + + // Third stage + const G4double ThirdStageHeight = FirstStageHeight; + const G4double ThirdStageBaseLarge = FirstStageBaseLarge; + const G4double ThirdStageBaseSmall = FirstStageBaseSmall; + const G4double ThirdStageThickness = 500*micrometer; + + + // Fourth stage + const G4double FourthStageHeight = FirstStageHeight; + const G4double FourthStageBaseLarge = FirstStageBaseLarge; + const G4double FourthStageBaseSmall = FirstStageBaseSmall; + const G4double FourthStageThickness = 2000*micrometer; + + // Fifth stage + const G4double FifthStageHeight = FirstStageHeight; + const G4double FifthStageBaseLarge = FirstStageBaseLarge; + const G4double FifthStageBaseSmall = FirstStageBaseSmall; + const G4double FifthStageThickness = 2000*micrometer; + + // Sixth stage + const G4double SixthStageHeight = FirstStageHeight; + const G4double SixthStageBaseLarge = FirstStageBaseLarge; + const G4double SixthStageBaseSmall = FirstStageBaseSmall; + const G4double SixthStageThickness = 1.5*mm; + + // Starting at the front of the first stage and pointing 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; + const G4double FourthStage_PosZ = Length* -0.5 + 0.5*FourthStageThickness + 3*InterStageDistance; + const G4double FifthStage_PosZ = Length* -0.5 + 0.5*FifthStageThickness + 4*InterStageDistance; + const G4double SixthStage_PosZ = Length* -0.5 + 0.5*SixthStageThickness + 5*InterStageDistance; +} + +#endif diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc index b28e6c1c36d5000a7385ec4985e65eb9e8273ae3..ca89e5848d7a73978749e630700f065dd911a499 100644 --- a/NPSimulation/src/DetectorConstruction.cc +++ b/NPSimulation/src/DetectorConstruction.cc @@ -56,6 +56,7 @@ #include "GaspardTracker.hh" #include "Helios.hh" #include "HydeTracker.hh" +#include "Hyde2Tracker.hh" #include "MUST2Array.hh" #include "Paris.hh" #include "Plastic.hh" @@ -182,6 +183,7 @@ void DetectorConstruction::ReadConfigurationFile(string Path){ bool cGeneralChamber = false; bool cGPDTracker = false; bool cHYDTracker = false; + bool cHYD2Tracker = false; bool cMUST2 = false; bool cPlastic = false; bool cParis = false; @@ -316,7 +318,29 @@ void DetectorConstruction::ReadConfigurationFile(string Path){ #endif } + + //////////////////////////////////////////// + //////////// Search for Hyde2 //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 12, "Hyde2Tracker") == 0 && cHYD2Tracker == false) { +#ifdef INC_HYDE2 + cHYD2Tracker = true ; + if(VerboseLevel==1) cout << endl << "//////// Hyde2 Tracker ////////" << endl ; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Hyde2Tracker() ; + + // Read Position of Telescope + ConfigFile.close() ; + myDetector->ReadConfiguration(Path) ; + ConfigFile.open(Path.c_str()) ; + + // Add array to the VDetector Vector + AddDetector(myDetector) ; +#endif + } + //////////////////////////////////////////// //////////// Search for paris //////////// //////////////////////////////////////////// diff --git a/NPSimulation/src/Hyde2Scorers.cc b/NPSimulation/src/Hyde2Scorers.cc new file mode 100644 index 0000000000000000000000000000000000000000..65e7cdb56aff40c89daf581053e748da2fe89ddb --- /dev/null +++ b/NPSimulation/src/Hyde2Scorers.cc @@ -0,0 +1,820 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 * + * Hyde2Tracker*** objects. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// G4 headers +#include "G4UnitsTable.hh" + +// NPTool headers +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" + +#include "Hyde2TrackerSquare1.hh" +#include "Hyde2TrackerTrapezoid1.hh" +#include "Hyde2TrackerTrapezoid2.hh" +using namespace HYD2SQUARE1; +using namespace HYD2TRAP1; +using namespace HYD2TRAP2; + +//....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) +HYD2ScorerFirstStageEnergy::HYD2ScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerFirstStageEnergy::~HYD2ScorerFirstStageEnergy() +{ +} + +G4bool HYD2ScorerFirstStageEnergy::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 HYD2ScorerFirstStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageEnergy::DrawAll() +{ +} + +void HYD2ScorerFirstStageEnergy::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) +HYD2ScorerSecondStageEnergy::HYD2ScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerSecondStageEnergy::~HYD2ScorerSecondStageEnergy() +{ +} + +G4bool HYD2ScorerSecondStageEnergy::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 HYD2ScorerSecondStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerSecondStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerSecondStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerSecondStageEnergy::DrawAll() +{ +} + +void HYD2ScorerSecondStageEnergy::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) +HYD2ScorerThirdStageEnergy::HYD2ScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerThirdStageEnergy::~HYD2ScorerThirdStageEnergy() +{ +} + +G4bool HYD2ScorerThirdStageEnergy::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 HYD2ScorerThirdStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerThirdStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerThirdStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerThirdStageEnergy::DrawAll() +{ +} + +void HYD2ScorerThirdStageEnergy::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...... +// FourthStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerFourthStageEnergy::HYD2ScorerFourthStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerFourthStageEnergy::~HYD2ScorerFourthStageEnergy() +{ +} + +G4bool HYD2ScorerFourthStageEnergy::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 HYD2ScorerFourthStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFourthStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFourthStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFourthStageEnergy::DrawAll() +{ +} + +void HYD2ScorerFourthStageEnergy::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...... +// FifthStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerFifthStageEnergy::HYD2ScorerFifthStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerFifthStageEnergy::~HYD2ScorerFifthStageEnergy() +{ +} + +G4bool HYD2ScorerFifthStageEnergy::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 HYD2ScorerFifthStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFifthStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFifthStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFifthStageEnergy::DrawAll() +{ +} + +void HYD2ScorerFifthStageEnergy::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...... +// SixthStage Energy Scorer (deal with multiple particle hit) +HYD2ScorerSixthStageEnergy::HYD2ScorerSixthStageEnergy(G4String name, G4String volumeName, G4int depth) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_VolumeName = volumeName; +} + +HYD2ScorerSixthStageEnergy::~HYD2ScorerSixthStageEnergy() +{ +} + +G4bool HYD2ScorerSixthStageEnergy::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 HYD2ScorerSixthStageEnergy::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerSixthStageEnergy::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerSixthStageEnergy::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerSixthStageEnergy::DrawAll() +{ +} + +void HYD2ScorerSixthStageEnergy::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 Square1 geometry +HYD2ScorerFirstStageFrontStripSquare1::HYD2ScorerFirstStageFrontStripSquare1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYD2ScorerFirstStageFrontStripSquare1::~HYD2ScorerFirstStageFrontStripSquare1() +{ +} + +G4bool HYD2ScorerFirstStageFrontStripSquare1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Square1"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2SQUARE1::FirstStageFace / m_NumberOfStrip; + + G4double temp = (POS(0) + HYD2SQUARE1::FirstStageFace / 2.) / StripPitch ; + G4double X = int(temp) + 1 ; + //Rare case where particle is close to edge of silicon plan + // if (X == 129) X = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (X == 221) X = 220; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYD2ScorerFirstStageFrontStripSquare1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageFrontStripSquare1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageFrontStripSquare1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageFrontStripSquare1::DrawAll() +{ +} + +void HYD2ScorerFirstStageFrontStripSquare1::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 Square1 geometry +HYD2ScorerFirstStageBackStripSquare1::HYD2ScorerFirstStageBackStripSquare1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip ; +} + +HYD2ScorerFirstStageBackStripSquare1::~HYD2ScorerFirstStageBackStripSquare1() +{ +} + +G4bool HYD2ScorerFirstStageBackStripSquare1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Square1"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2SQUARE1::FirstStageFace / m_NumberOfStrip; + + G4double temp = (POS(1) + HYD2SQUARE1::FirstStageFace / 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; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (Y == 221) Y = 220; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYD2ScorerFirstStageBackStripSquare1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageBackStripSquare1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageBackStripSquare1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageBackStripSquare1::DrawAll() +{ +} + +void HYD2ScorerFirstStageBackStripSquare1::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 Trapezoid1 geometry +HYD2ScorerFirstStageFrontStripTrapezoid1::HYD2ScorerFirstStageFrontStripTrapezoid1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageFrontStripTrapezoid1::~HYD2ScorerFirstStageFrontStripTrapezoid1() +{ +} + +G4bool HYD2ScorerFirstStageFrontStripTrapezoid1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid1"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP1::FirstStageBaseLarge / m_NumberOfStrip; + + G4double temp = (POS(0) + HYD2TRAP1::FirstStageBaseLarge / 2.) / StripPitch ; + G4double X = int(temp) + 1; + //Rare case where particle is close to edge of silicon plan + // if (X == 129) X = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (X == 215) X = 214; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::DrawAll() +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid1::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 Trapezoid1 geometry +HYD2ScorerFirstStageBackStripTrapezoid1::HYD2ScorerFirstStageBackStripTrapezoid1(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageBackStripTrapezoid1::~HYD2ScorerFirstStageBackStripTrapezoid1() +{ +} + +G4bool HYD2ScorerFirstStageBackStripTrapezoid1::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid1"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP1::FirstStageHeight / m_NumberOfStrip; + + G4double temp = (POS(1) + HYD2TRAP1::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; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (Y == 221) Y = 220; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::DrawAll() +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid1::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 Trapezoid2 geometry +HYD2ScorerFirstStageFrontStripTrapezoid2::HYD2ScorerFirstStageFrontStripTrapezoid2(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageFrontStripTrapezoid2::~HYD2ScorerFirstStageFrontStripTrapezoid2() +{ +} + +G4bool HYD2ScorerFirstStageFrontStripTrapezoid2::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid2"); + + // get front strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP2::FirstStageBaseLarge / m_NumberOfStrip; + + G4double temp = (POS(0) + HYD2TRAP2::FirstStageBaseLarge / 2.) / StripPitch ; + G4double X = int(temp) + 1; + //Rare case where particle is close to edge of silicon plan + // if (X == 129) X = 128; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (X == 130) X = 129; + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, X); + return TRUE; +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::DrawAll() +{ +} + +void HYD2ScorerFirstStageFrontStripTrapezoid2::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 Trapezoid2 geometry +HYD2ScorerFirstStageBackStripTrapezoid2::HYD2ScorerFirstStageBackStripTrapezoid2(G4String name, G4int depth, G4int NumberOfStrip) + : G4VPrimitiveScorer(name, depth), HCID(-1) +{ + m_NumberOfStrip = NumberOfStrip; +} + +HYD2ScorerFirstStageBackStripTrapezoid2::~HYD2ScorerFirstStageBackStripTrapezoid2() +{ +} + +G4bool HYD2ScorerFirstStageBackStripTrapezoid2::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // get detector number + int DetNbr = GENERALSCORERS::PickUpDetectorNumber(aStep, "HYD2Trapezoid2"); + + // get back strip + G4ThreeVector POS = aStep->GetPreStepPoint()->GetPosition(); + POS = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(POS); + + G4double StripPitch = HYD2TRAP2::FirstStageHeight / m_NumberOfStrip; + + G4double temp = (POS(1) + HYD2TRAP2::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; Wed Feb 6 19:16:08 CET 2013 angelmsb + if (Y == 127) Y = 126; + + G4double edep = aStep->GetTotalEnergyDeposit(); + if (edep < 100*keV) return FALSE; + G4int index = aStep->GetTrack()->GetTrackID(); + EvtMap->set(DetNbr + index, Y); + return TRUE; +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::Initialize(G4HCofThisEvent* HCE) +{ + EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::EndOfEvent(G4HCofThisEvent*) +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::Clear() +{ + EvtMap->clear(); +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::DrawAll() +{ +} + +void HYD2ScorerFirstStageBackStripTrapezoid2::PrintAll() +{ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + diff --git a/NPSimulation/src/Hyde2Tracker.cc b/NPSimulation/src/Hyde2Tracker.cc new file mode 100644 index 0000000000000000000000000000000000000000..75cd0a5df4bf6aa77c4d6efc494c4612eb8ad4fe --- /dev/null +++ b/NPSimulation/src/Hyde2Tracker.cc @@ -0,0 +1,170 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 * + * tracker. It allows to have Hyde2 geometries with an * + * heterogeneous set of modules * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <fstream> +#include <sstream> +#include <string> +#include <cmath> + +// NPTool headers +#include "Hyde2Tracker.hh" +#include "Hyde2TrackerSquare1.hh" +#include "Hyde2TrackerTrapezoid1.hh" +#include "Hyde2TrackerTrapezoid2.hh" + +using namespace std; + + +Hyde2Tracker::Hyde2Tracker() +{ +} + + + +Hyde2Tracker::~Hyde2Tracker() +{ +} + + + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void Hyde2Tracker::ReadConfiguration(string Path) +{ + // open configuration file + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + bool HYD2TrkSquare1 = false; + bool HYD2TrkTrapezoid1 = false; + bool HYD2TrkTrapezoid2 = false; + + string LineBuffer; + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 11, "HYD2Square1") == 0 && HYD2TrkSquare1 == false) { + HYD2TrkSquare1 = true; + + // instantiate a new "detector" corresponding to the Square1 elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerSquare1(); + + // 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 Hyde2TrackerSquare1 "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0 && HYD2TrkTrapezoid1 == false) { + HYD2TrkTrapezoid1 = true; + + // instantiate a new "detector" corresponding to the Trapezoid1 elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerTrapezoid1(); + + // 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 Hyde2TrackerTrapezoid1 "detector" + m_Modules.push_back(myDetector); + } + else if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0 && HYD2TrkTrapezoid2 == false) { + HYD2TrkTrapezoid2 = true; + + // instantiate a new "detector" corresponding to the Trapezoid2 elements + Hyde2TrackerModule* myDetector = new Hyde2TrackerTrapezoid2(); + + // 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 Hyde2TrackerTrapezoid2 "detector" + m_Modules.push_back(myDetector); + } + } +} + + + +// Construct detector and initialize sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2Tracker::ConstructDetector(G4LogicalVolume* world) +{ + // loop on sub-detectors belonging to Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ConstructDetector(world); +} + + + +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2Tracker::InitializeRootOutput() +{ + // loop on sub-detectors belonging to Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->InitializeRootOutput(); +} + + + +// Initialize all scorers necessary for each detector +void Hyde2Tracker::InitializeScorers() +{ + // loop on sub-detectors belonging to Hyde2Tracker + 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 Hyde2Tracker::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 Hyde2Tracker + int nbDetectors = m_Modules.size(); + for (int i = 0; i < nbDetectors; i++) m_Modules[i]->ReadSensitive(event); +} diff --git a/NPSimulation/src/Hyde2TrackerModule.cc b/NPSimulation/src/Hyde2TrackerModule.cc new file mode 100644 index 0000000000000000000000000000000000000000..ab454d7fa0a87fbb05ce36e34153857ffa672d49 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerModule.cc @@ -0,0 +1,62 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker. * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "Hyde2TrackerModule.hh" +#include "RootOutput.h" + + +THyde2TrackerData *Hyde2TrackerModule::ms_Event = 0; + + + +Hyde2TrackerModule::Hyde2TrackerModule() +{ + if (ms_Event == 0) ms_Event = new THyde2TrackerData(); + + InitializeRootOutput(); + InitializeIndex(); +} + + + +Hyde2TrackerModule::~Hyde2TrackerModule() +{ +} + + + +void Hyde2TrackerModule::InitializeRootOutput() +{ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + // if the branch does not exist yet, create it + if (!pTree->GetBranch("HYDE2")) + pTree->Branch("HYDE2", "THyde2TrackerData", &ms_Event); +} + + + +void Hyde2TrackerModule::InitializeIndex() +{ + m_index["Square1"] = 2000; + m_index["Trapezoid1"] = 2200; + m_index["Trapezoid2"] = 2300; +} diff --git a/NPSimulation/src/Hyde2TrackerSquare1.cc b/NPSimulation/src/Hyde2TrackerSquare1.cc new file mode 100644 index 0000000000000000000000000000000000000000..eab3597183771af989243b9853b3c67ec867f2e0 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerSquare1.cc @@ -0,0 +1,1252 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 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) * + * + 01/10/10: Fix bug with TInteractionCoordinate map size in Read * + * Sensitive (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 "Hyde2TrackerSquare1.hh" +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYD2SQUARE1; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerSquare1::Hyde2TrackerSquare1() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerSquare1::~Hyde2TrackerSquare1() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Hyde2TrackerSquare1::AddModule(G4ThreeVector X1_Y1 , + G4ThreeVector X128_Y1 , + G4ThreeVector X1_Y128 , + G4ThreeVector X128_Y128 , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage) +{ + 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_wFourthStage.push_back(wFourthStage) ; + m_wFifthStage.push_back(wFifthStage) ; + m_wSixthStage.push_back(wSixthStage) ; + + 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 Hyde2TrackerSquare1::AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage) +{ + 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_wFourthStage.push_back(wFourthStage) ; + m_wFifthStage.push_back(wFifthStage) ; + m_wSixthStage.push_back(wSixthStage) ; + + 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 Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, + G4ThreeVector MMpos, + G4RotationMatrix* MMrot, + bool wFirstStage, + bool wSecondStage, + bool wThirdStage, + bool wFourthStage, + bool wFifthStage , + bool wSixthStage , + 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 ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Square1" + DetectorNumber; + + G4Box* solidHYD2Square1 = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); + G4LogicalVolume* logicHYD2Square1 = new G4LogicalVolume(solidHYD2Square1, Vacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Square1, Name, world, false, 0); + + logicHYD2Square1->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicHYD2Square1->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); + + new G4PVPlacement(0, + positionFirstStage, + logicFirstStage, + Name + "_FirstStage", + logicHYD2Square1, + false, + 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + ///Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + 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); + + new G4PVPlacement(0, + positionSecondStage, + logicSecondStage, + Name + "_SecondStage", + logicHYD2Square1, + 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); + + new G4PVPlacement(0, + positionThirdStage, + logicThirdStage, + Name + "_ThirdStage", + logicHYD2Square1, + false, + 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + ///Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Box* solidFourthStage = new G4Box("solidFourthStage", 0.5*FourthStageFace, 0.5*FourthStageFace, 0.5*FourthStageThickness); + G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, Silicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFourthStage, + logicFourthStage, + Name + "_FourthStage", + logicHYD2Square1, + false, + 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + ///Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Box* solidFifthStage = new G4Box("solidFifthStage", 0.5*FifthStageFace, 0.5*FifthStageFace, 0.5*FifthStageThickness); + G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, Silicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFifthStage, + logicFifthStage, + Name + "_FifthStage", + logicHYD2Square1, + false, + 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + ///Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Box* solidSixthStage = new G4Box("solidSixthStage", 0.5*SixthStageFace, 0.5*SixthStageFace, 0.5*SixthStageThickness); + G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, Silicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionSixthStage, + logicSixthStage, + Name + "_SixthStage", + logicHYD2Square1, + false, + 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + ///Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } + +} + +//....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 Hyde2TrackerSquare1::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 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0, SIXTHSTAGE = 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 check_FourthStage = false ; + bool check_FifthStage = false ; + bool check_SixthStage = false ; + bool checkVis = false ; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 11, "HYD2Square1") == 0) { + G4cout << "///" << G4endl ; + G4cout << "Square1 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, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true ; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true ; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true ; + ConfigFile >> DataBuffer; + SIXTHSTAGE = 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, Hyde2TrackerSquare1: Square1 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 && check_FourthStage && check_FifthStage && check_SixthStage && 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 ; + check_FourthStage = false ; + check_FifthStage = false ; + check_SixthStage = false ; + checkVis = false ; + + AddModule(A , + B , + C , + D , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1 , + FOURTHSTAGE == 1 , + FIFTHSTAGE == 1 , + SIXTHSTAGE == 1); + } + + //with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && 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 ; + check_FourthStage = false ; + check_FifthStage = false ; + check_SixthStage = false ; + checkVis = false ; + + AddModule(R , + Theta , + Phi , + beta_u , + beta_v , + beta_w , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1 , + FOURTHSTAGE == 1 , + FIFTHSTAGE == 1 , + SIXTHSTAGE == 1); + } + + + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerSquare1::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; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = 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(); + + MMw = MMu.cross(MMv); + 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 + 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 + MMCenter = 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 + MMCenter; + } + + FirstStage = m_wFirstStage[i] ; + SecondStage = m_wSecondStage[i] ; + ThirdStage = m_wThirdStage[i] ; + FourthStage = m_wFourthStage[i] ; + FifthStage = m_wFifthStage[i] ; + SixthStage = m_wSixthStage[i] ; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot ; +} + + + +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerSquare1::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void Hyde2TrackerSquare1::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void Hyde2TrackerSquare1::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 ; + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr ; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL ; + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr ; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL ; + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr ; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL ; + + + + // Read the Scorer associate to the Silicon Strip + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberX") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberY") ; + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/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("SecondStageScorerHYD2Square1/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("ThirdStageScorerHYD2Square1/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the FourthStage + //Energy + G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Square1/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the FifthStage + //Energy + G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Square1/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SixthStage + //Energy + G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Square1/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->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->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Square1"] + 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->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(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->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; + } + 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->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(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->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); 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 < PosYHitMap->entries(); 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 < PosZHitMap->entries(); 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 < AngThetaHitMap->entries(); 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 < AngPhiHitMap->entries(); 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->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)) ; + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Square1"] + 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->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Square1"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second) ; + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Square1"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second) ; + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Square1"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second) ; + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Square1"] + N); + } + + SixthStageEnergy_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() ; + FourthStageEnergyHitMap ->clear() ; + FifthStageEnergyHitMap ->clear() ; + SixthStageEnergyHitMap ->clear() ; + } +} + + + +void Hyde2TrackerSquare1::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYD2Square1"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Square1", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Square1", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Square1", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripSquare1("StripNumberX", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripSquare1("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("SecondStageScorerHYD2Square1"); + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Square1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYD2Square1"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Square1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + m_FourthStageScorer = new G4MultiFunctionalDetector("FourthStageScorerHYD2Square1"); + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Square1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + m_FifthStageScorer = new G4MultiFunctionalDetector("FifthStageScorerHYD2Square1"); + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Square1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + m_SixthStageScorer = new G4MultiFunctionalDetector("SixthStageScorerHYD2Square1"); + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Square1", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +} diff --git a/NPSimulation/src/Hyde2TrackerTrapezoid1.cc b/NPSimulation/src/Hyde2TrackerTrapezoid1.cc new file mode 100644 index 0000000000000000000000000000000000000000..fb8fe60d193cffec23a7de447425b4000f1ade19 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerTrapezoid1.cc @@ -0,0 +1,1286 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * + 01/10/10: Fix bug with TInteractionCoordinate map size in Read * + * Sensitive (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 "Hyde2TrackerTrapezoid1.hh" +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYD2TRAP1 ; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerTrapezoid1::~Hyde2TrackerTrapezoid1() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Hyde2TrackerTrapezoid1::AddModule(G4ThreeVector X1_Y1 , + G4ThreeVector X128_Y1 , + G4ThreeVector X1_Y128 , + G4ThreeVector X128_Y128 , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage) +{ + 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_wFourthStage.push_back(wFourthStage) ; + m_wFifthStage.push_back(wFifthStage) ; + m_wSixthStage.push_back(wSixthStage) ; + + 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 Hyde2TrackerTrapezoid1::AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage) +{ + 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_wFourthStage.push_back(wFourthStage) ; + m_wFifthStage.push_back(wFifthStage) ; + m_wSixthStage.push_back(wSixthStage) ; + + 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 Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + 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 ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Trapezoid1" + DetectorNumber ; + + // Definition of the volume containing the sensitive detector + G4Trap* solidHYD2Trapezoid1 = new G4Trap(Name, + Length/2, 0*deg, 0*deg, + Height/2, BaseLarge/2, BaseSmall/2, 0*deg, + Height/2, BaseLarge/2, BaseSmall/2, 0*deg); + G4LogicalVolume* logicHYD2Trapezoid1 = new G4LogicalVolume(solidHYD2Trapezoid1, Vacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid1, Name, world, false, 0); + + logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicHYD2Trapezoid1->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); + + G4Trap* solidFirstStage = new G4Trap("solidFirstStage", + FirstStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, Silicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFirstStage, + logicFirstStage, + Name + "_FirstStage", + logicHYD2Trapezoid1, + false, + 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + ///Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Trap* solidSecondStage = new G4Trap("solidSecondStage", + SecondStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, Silicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, + positionSecondStage, + logicSecondStage, + Name + "_SecondStage", + logicHYD2Trapezoid1, + 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); + + G4Trap* solidThirdStage = new G4Trap("solidThirdStage", + ThirdStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, + positionThirdStage, + logicThirdStage, + Name + "_ThirdStage", + logicHYD2Trapezoid1, + false, + 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + ///Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Trap* solidFourthStage = new G4Trap("solidFourthStage", + FourthStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, Silicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFourthStage, + logicFourthStage, + Name + "_FourthStage", + logicHYD2Trapezoid1, + false, + 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + ///Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Trap* solidFifthStage = new G4Trap("solidFifthStage", + FifthStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, Silicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFifthStage, + logicFifthStage, + Name + "_FifthStage", + logicHYD2Trapezoid1, + false, + 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + ///Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Trap* solidSixthStage = new G4Trap("solidSixthStage", + SixthStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, Silicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionSixthStage, + logicSixthStage, + Name + "_SixthStage", + logicHYD2Trapezoid1, + false, + 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + ///Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } + +} + +//....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 Hyde2TrackerTrapezoid1::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 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0 , SIXTHSTAGE = 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 check_FourthStage = false ; + bool check_FifthStage = false ; + bool check_SixthStage = false ; + bool checkVis = false ; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0) { + G4cout << "///" << G4endl ; + G4cout << "Trapezoid1 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, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true ; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true ; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true ; + ConfigFile >> DataBuffer; + SIXTHSTAGE = 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, Hyde2TrackerTrapezoid1: Trapezoid1 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 && check_FourthStage && check_FifthStage && check_SixthStage && 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 ; + check_FourthStage = false ; + check_FifthStage = false ; + check_SixthStage = false ; + checkVis = false ; + + AddModule(A , + B , + C , + D , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1 , + FOURTHSTAGE == 1 , + FIFTHSTAGE == 1 , + SIXTHSTAGE == 1); + } + + //with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && 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 ; + check_FourthStage = false ; + check_FifthStage = false ; + check_SixthStage = false ; + checkVis = false ; + + AddModule(R , + Theta , + Phi , + beta_u , + beta_v , + beta_w , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1 , + FOURTHSTAGE == 1 , + FIFTHSTAGE == 1 , + SIXTHSTAGE == 1); + } + + + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerTrapezoid1::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 ; + bool FourthStage = true ; + bool FifthStage = true ; + bool SixthStage = 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 trapezoidal referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + G4cout << "MMu: " << MMu << G4endl; + + MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); + MMv = MMv.unit(); + G4cout << "MMv: " << MMv << G4endl; + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + G4cout << "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]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // 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 + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + // in fact, this is vector u + 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(); + MMv = MMw.cross(Y); + MMu = MMv.cross(MMw); + MMv = MMv.unit(); + MMu = MMu.unit(); + + G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; + G4cout << "MMu: " << MMu << G4endl; + G4cout << "MMv: " << MMv << G4endl; + G4cout << "MMw: " << MMw << G4endl; + + // Passage Matrix from Lab Referential to Telescope Referential + 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 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; +} + + + +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerTrapezoid1::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void Hyde2TrackerTrapezoid1::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void Hyde2TrackerTrapezoid1::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; + + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associated to the first Stage + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberX") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberY") ; + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngPhi") ; + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; + + // Read the Scorer associated to the Second and Third Stage + // Energy second stage + G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid1/SecondStageEnergy") ; + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; + // Energy third stage + G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid1/ThirdStageEnergy") ; + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + // Energy Fourth stage + G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid1/FourthStageEnergy") ; + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)) ; + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; + // Energy Fifth stage + G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid1/FifthStageEnergy") ; + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)) ; + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; + // Energy Sixth stage + G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid1/SixthStageEnergy") ; + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)) ; + SixthStageEnergy_itr = SixthStageEnergyHitMap->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->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid1"] + 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->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(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->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; + } + 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->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(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->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); 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 < PosYHitMap->entries(); 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 < PosZHitMap->entries(); 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 < AngThetaHitMap->entries(); 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 < AngPhiHitMap->entries(); 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->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid1"] + 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->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + SixthStageEnergy_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(); + FourthStageEnergyHitMap ->clear(); + FifthStageEnergyHitMap ->clear(); + SixthStageEnergyHitMap ->clear(); + } +} + + + +void Hyde2TrackerTrapezoid1::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Trapezoid1", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid1("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid1("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("SecondStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + m_FourthStageScorer = new G4MultiFunctionalDetector("FourthStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + m_FifthStageScorer = new G4MultiFunctionalDetector("FifthStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + m_SixthStageScorer = new G4MultiFunctionalDetector("SixthStageScorerHYD2Trapezoid1"); + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid1", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +} diff --git a/NPSimulation/src/Hyde2TrackerTrapezoid2.cc b/NPSimulation/src/Hyde2TrackerTrapezoid2.cc new file mode 100644 index 0000000000000000000000000000000000000000..ffdecee53957407aa2b747c89afff8bc7728b204 --- /dev/null +++ b/NPSimulation/src/Hyde2TrackerTrapezoid2.cc @@ -0,0 +1,1286 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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 Hyde2 tracker * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + 12/10/09: Change scorer scheme (N. de Sereville) * + * + 01/10/10: Fix bug with TInteractionCoordinate map size in Read * + * Sensitive (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 "Hyde2TrackerTrapezoid2.hh" +#include "GeneralScorers.hh" +#include "Hyde2Scorers.hh" +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace HYD2TRAP2 ; + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2() +{ + ms_InterCoord = 0; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Hyde2TrackerTrapezoid2::~Hyde2TrackerTrapezoid2() +{ +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Hyde2TrackerTrapezoid2::AddModule(G4ThreeVector X1_Y1 , + G4ThreeVector X128_Y1 , + G4ThreeVector X1_Y128 , + G4ThreeVector X128_Y128 , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage) +{ + 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_wFourthStage.push_back(wFourthStage) ; + m_wFifthStage.push_back(wFifthStage) ; + m_wSixthStage.push_back(wSixthStage) ; + + 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 Hyde2TrackerTrapezoid2::AddModule(G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage) +{ + 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_wFourthStage.push_back(wFourthStage) ; + m_wFifthStage.push_back(wFifthStage) ; + m_wSixthStage.push_back(wSixthStage) ; + + 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 Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wFirstStage , + bool wSecondStage , + bool wThirdStage , + bool wFourthStage , + bool wFifthStage , + bool wSixthStage , + 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 ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Trapezoid2" + DetectorNumber ; + + // Definition of the volume containing the sensitive detector + G4Trap* solidHYD2Trapezoid2 = new G4Trap(Name, + Length/2, 0*deg, 0*deg, + Height/2, BaseLarge/2, BaseSmall/2, 0*deg, + Height/2, BaseLarge/2, BaseSmall/2, 0*deg); + G4LogicalVolume* logicHYD2Trapezoid2 = new G4LogicalVolume(solidHYD2Trapezoid2, Vacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid2, Name, world, false, 0); + + logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes::Invisible); + if (m_non_sensitive_part_visiualisation) logicHYD2Trapezoid2->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); + + G4Trap* solidFirstStage = new G4Trap("solidFirstStage", + FirstStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, Silicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFirstStage, + logicFirstStage, + Name + "_FirstStage", + logicHYD2Trapezoid2, + false, + 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + ///Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Trap* solidSecondStage = new G4Trap("solidSecondStage", + SecondStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, Silicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, + positionSecondStage, + logicSecondStage, + Name + "_SecondStage", + logicHYD2Trapezoid2, + 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); + + G4Trap* solidThirdStage = new G4Trap("solidThirdStage", + ThirdStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, + positionThirdStage, + logicThirdStage, + Name + "_ThirdStage", + logicHYD2Trapezoid2, + false, + 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + ///Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Trap* solidFourthStage = new G4Trap("solidFourthStage", + FourthStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, Silicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFourthStage, + logicFourthStage, + Name + "_FourthStage", + logicHYD2Trapezoid2, + false, + 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + ///Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Trap* solidFifthStage = new G4Trap("solidFifthStage", + FifthStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, Silicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionFifthStage, + logicFifthStage, + Name + "_FifthStage", + logicHYD2Trapezoid2, + false, + 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + ///Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Trap* solidSixthStage = new G4Trap("solidSixthStage", + SixthStageThickness/2, 0*deg, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, + FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); + G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, Silicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, + positionSixthStage, + logicSixthStage, + Name + "_SixthStage", + logicHYD2Trapezoid2, + false, + 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + ///Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } + +} + +//....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 Hyde2TrackerTrapezoid2::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 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0 , SIXTHSTAGE = 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 check_FourthStage = false ; + bool check_FifthStage = false ; + bool check_SixthStage = false ; + bool checkVis = false ; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0) { + G4cout << "///" << G4endl ; + G4cout << "Trapezoid2 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, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true ; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true ; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()) ; + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true ; + ConfigFile >> DataBuffer; + SIXTHSTAGE = 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, Hyde2TrackerTrapezoid2: Trapezoid2 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 && check_FourthStage && check_FifthStage && check_SixthStage && 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 ; + check_FourthStage = false ; + check_FifthStage = false ; + check_SixthStage = false ; + checkVis = false ; + + AddModule(A , + B , + C , + D , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1 , + FOURTHSTAGE == 1 , + FIFTHSTAGE == 1 , + SIXTHSTAGE == 1); + } + + //with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && 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 ; + check_FourthStage = false ; + check_FifthStage = false ; + check_SixthStage = false ; + checkVis = false ; + + AddModule(R , + Theta , + Phi , + beta_u , + beta_v , + beta_w , + FIRSTSTAGE == 1 , + SECONDSTAGE == 1 , + THIRDSTAGE == 1 , + FOURTHSTAGE == 1 , + FIFTHSTAGE == 1 , + SIXTHSTAGE == 1); + } + + + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerTrapezoid2::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 ; + bool FourthStage = true ; + bool FifthStage = true ; + bool SixthStage = 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 trapezoidal referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + G4cout << "MMu: " << MMu << G4endl; + + MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); + MMv = MMv.unit(); + G4cout << "MMv: " << MMv << G4endl; + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + G4cout << "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]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // 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 + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + // in fact, this is vector u + 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(); + MMv = MMw.cross(Y); + MMu = MMv.cross(MMw); + MMv = MMv.unit(); + MMu = MMu.unit(); + + G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; + G4cout << "MMu: " << MMu << G4endl; + G4cout << "MMv: " << MMv << G4endl; + G4cout << "MMw: " << MMw << G4endl; + + // Passage Matrix from Lab Referential to Telescope Referential + 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 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; +} + + + +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerTrapezoid2::InitializeRootOutput() +{ +} + + + +// Set the TinteractionCoordinates object from VDetector to the present class +void Hyde2TrackerTrapezoid2::SetInterCoordPointer(TInteractionCoordinates* interCoord) +{ + ms_InterCoord = interCoord; +} + + + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void Hyde2TrackerTrapezoid2::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; + + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associated to the first Stage + //Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/DetectorNumber") ; + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; + + //Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripEnergy") ; + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; + Energy_itr = EnergyHitMap->GetMap()->begin() ; + + //Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripTime") ; + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; + Time_itr = TimeHitMap->GetMap()->begin() ; + + //Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberX") ; + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; + X_itr = XHitMap->GetMap()->begin() ; + + //Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberY") ; + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; + Y_itr = YHitMap->GetMap()->begin() ; + + //Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordX") ; + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordY") ; + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordZ") ; + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngTheta") ; + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngPhi") ; + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; + + // Read the Scorer associated to the Second and Third Stage + // Energy second stage + G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid2/SecondStageEnergy") ; + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; + // Energy third stage + G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid2/ThirdStageEnergy") ; + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + // Energy Fourth stage + G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid2/FourthStageEnergy") ; + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)) ; + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; + // Energy Fifth stage + G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid2/FifthStageEnergy") ; + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)) ; + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; + // Energy Sixth stage + G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid2/SixthStageEnergy") ; + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)) ; + SixthStageEnergy_itr = SixthStageEnergyHitMap->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->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid2"] + 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->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(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->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; + } + 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->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(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->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); 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 < PosYHitMap->entries(); 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 < PosZHitMap->entries(); 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 < AngThetaHitMap->entries(); 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 < AngPhiHitMap->entries(); 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->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid2"] + 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->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + SixthStageEnergy_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(); + FourthStageEnergyHitMap ->clear(); + FifthStageEnergyHitMap ->clear(); + SixthStageEnergyHitMap ->clear(); + } +} + + + +void Hyde2TrackerTrapezoid2::InitializeScorers() +{ + // First stage Associate Scorer + m_FirstStageScorer = new G4MultiFunctionalDetector("FirstStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* DetNbr = new GENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* TOF = new GENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = new GENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new GENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = new GENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new GENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new GENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Trapezoid2", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid2("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid2("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("SecondStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid2", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + m_ThirdStageScorer = new G4MultiFunctionalDetector("ThirdStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid2", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + m_FourthStageScorer = new G4MultiFunctionalDetector("FourthStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid2", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + m_FifthStageScorer = new G4MultiFunctionalDetector("FifthStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid2", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + m_SixthStageScorer = new G4MultiFunctionalDetector("SixthStageScorerHYD2Trapezoid2"); + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid2", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +} diff --git a/NPSimulation/src/HydeTrackerAnnular.cc b/NPSimulation/src/HydeTrackerAnnular.cc index b5902dd7f7d404e3aec6e8c4ffe01bc14e440ab4..a67b86f0bec2a297c04ab17d195174c52896bddc 100644 --- a/NPSimulation/src/HydeTrackerAnnular.cc +++ b/NPSimulation/src/HydeTrackerAnnular.cc @@ -177,10 +177,6 @@ void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , //////////////////////////////////////////////////////////////// ////////////// 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; @@ -195,7 +191,7 @@ void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , // 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) , + new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , logicMM , Name , world , @@ -217,7 +213,7 @@ void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, Vacuum, "logicVacBox", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetectorNumber + "VacBox", logicMM, false, 0); + new G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetectorNumber + "VacBox", logicMM, false, 0); logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); @@ -269,8 +265,8 @@ void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , // 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); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetectorNumber + "AluStripFront", logicMM, false, 0); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetectorNumber + "AluStripBack", logicMM, false, 0); logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); @@ -285,7 +281,7 @@ void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , 360*deg); G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, Silicon, "logicSilicon", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, 0); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, 0); // Set First Stage sensible logicSilicon->SetSensitiveDetector(m_FirstStageScorer); @@ -318,7 +314,7 @@ void HydeTrackerAnnular::VolumeMaker(G4int TelescopeNumber , G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, Silicon, "logicThirdStage", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); ///Visualisation of Third Stage G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.)) ; diff --git a/NPSimulation/src/Target.cc b/NPSimulation/src/Target.cc index 05460179331207b8ae2f53c1200794481f1541d9..1122c38c5c3250266e265f4ba06c5be3954044cf 100644 --- a/NPSimulation/src/Target.cc +++ b/NPSimulation/src/Target.cc @@ -260,12 +260,12 @@ void Target::ReadConfiguration(string Path) bool check_Thickness = false ; bool check_Radius = false ; - bool check_Angle = false ; +// bool check_Angle = false ; bool check_Material = false ; bool check_X = false ; bool check_Y = false ; bool check_Z = false ; - bool check_m_TargetNbLayers = false; +// bool check_m_TargetNbLayers = false; bool check_Temperature = false ; bool check_Pressure = false ; @@ -301,7 +301,7 @@ void Target::ReadConfiguration(string Path) } else if (DataBuffer.compare(0, 6, "ANGLE=") == 0) { - check_Angle = true ; +// check_Angle = true ; ConfigFile >> DataBuffer; m_TargetAngle = atof(DataBuffer.c_str()) * deg; if(VerboseLevel==1) cout << "Target Angle: " << m_TargetAngle / deg << endl ; @@ -343,7 +343,7 @@ void Target::ReadConfiguration(string Path) } else if (DataBuffer.compare(0, 9, "NBLAYERS=") == 0) { - check_m_TargetNbLayers = true ; +// check_m_TargetNbLayers = true ; ConfigFile >> DataBuffer; m_TargetNbLayers = atoi(DataBuffer.c_str()); if(VerboseLevel==1) cout << "Number of steps for slowing down the beam in target: " << m_TargetNbLayers << endl; @@ -438,7 +438,7 @@ void Target::ReadConfiguration(string Path) } else if (DataBuffer.compare(0, 9, "NBLAYERS=") == 0) { - check_m_TargetNbLayers = true ; +// check_m_TargetNbLayers = true ; ConfigFile >> DataBuffer; m_TargetNbLayers = atoi(DataBuffer.c_str()); if(VerboseLevel==1) cout << "Number of steps for slowing down the beam in target: " << m_TargetNbLayers << endl; @@ -468,11 +468,6 @@ void Target::ReadConfiguration(string Path) // Called After DetecorConstruction::AddDetector Method void Target::ConstructDetector(G4LogicalVolume* world) { - - // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". - // If don't you will have a Warning unused variable 'myPVP' - G4VPhysicalVolume* PVPBuffer ; - if (m_TargetType) { // case of standard target if (m_TargetThickness > 0) { @@ -483,7 +478,6 @@ void Target::ConstructDetector(G4LogicalVolume* world) G4RotationMatrix *rotation = new G4RotationMatrix(); rotation->rotateY(m_TargetAngle); - PVPBuffer = new G4PVPlacement(rotation, G4ThreeVector(m_TargetX, m_TargetY, m_TargetZ), logicTarget, "Target", world, false, 0); G4VisAttributes* TargetVisAtt = new G4VisAttributes(G4Colour(0., 0., 1.));//Blue @@ -496,7 +490,6 @@ void Target::ConstructDetector(G4LogicalVolume* world) if (m_TargetThickness > 0) { G4Tubs* solidTarget = new G4Tubs("solidTarget", 0, m_TargetRadius, 0.5*m_TargetThickness, 0*deg, 360*deg); G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, m_TargetMaterial, "logicTarget"); - PVPBuffer = new G4PVPlacement(0, G4ThreeVector(m_TargetX, m_TargetY, m_TargetZ), logicTarget, "Target", world, false, 0); G4VisAttributes* TargetVisAtt = new G4VisAttributes(G4Colour(0., 0., 1.));//Blue @@ -515,7 +508,6 @@ void Target::ConstructDetector(G4LogicalVolume* world) new G4Tubs("solidTargetWindowsB", 0, m_TargetRadius, 0.5*m_WindowsThickness, 0*deg, 360*deg); G4LogicalVolume* logicWindowsB = new G4LogicalVolume(solidWindowsB, m_WindowsMaterial, "logicTargetWindowsB"); - PVPBuffer = new G4PVPlacement( 0 , TargetPos + G4ThreeVector(0., 0., 0.5*(m_TargetThickness + m_WindowsThickness)) , logicWindowsF , @@ -523,7 +515,6 @@ void Target::ConstructDetector(G4LogicalVolume* world) world , false, 0 ); - PVPBuffer = new G4PVPlacement( 0 , TargetPos + G4ThreeVector(0., 0., -0.5*(m_TargetThickness + m_WindowsThickness)) , logicWindowsB , diff --git a/NPSimulation/src/ThinSi.cc b/NPSimulation/src/ThinSi.cc index e8a4490e2ec0dec06d2503e4f84e868b431d5280..d97c587b9995f291d50e48aaaef27b7b845f1251 100644 --- a/NPSimulation/src/ThinSi.cc +++ b/NPSimulation/src/ThinSi.cc @@ -135,11 +135,6 @@ void ThinSi::VolumeMaker( G4int DetNumber , //////////////////////////////////////////////////////////////// /////////General Geometry Parameter 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 ; - /////// Starting Volume Definition /////// G4String Name = "ThinSi" + DetectorNumber; @@ -148,7 +143,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , G4LogicalVolume* logicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialVacuum, Name, 0, 0); - PVPBuffer = new G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , + G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , logicThinSi , Name , world , @@ -169,7 +164,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - PVPBuffer = new G4PVPlacement( 0, + new G4PVPlacement( 0, FrameTopPosition, logicFrameHorizontal, Name + "_Frame", @@ -177,7 +172,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , false, 0); - PVPBuffer = new G4PVPlacement( 0, + new G4PVPlacement( 0, FrameBottomPosition, logicFrameHorizontal, Name + "_Frame", @@ -185,7 +180,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , false, 0); - PVPBuffer = new G4PVPlacement( 0, + new G4PVPlacement( 0, FrameLeftPosition, logicFrameVertical, Name + "_Frame", @@ -193,7 +188,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , false, 0); - PVPBuffer = new G4PVPlacement( 0, + new G4PVPlacement( 0, FrameRightPosition, logicFrameVertical, Name + "_Frame", @@ -212,10 +207,8 @@ void ThinSi::VolumeMaker( G4int DetNumber , G4LogicalVolume* logicAlu = new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0) ; - PVPBuffer = new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicThinSi , true, 0) ; - PVPBuffer = new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicThinSi , true, 0) ; @@ -225,7 +218,6 @@ void ThinSi::VolumeMaker( G4int DetNumber , G4LogicalVolume* logicSi = new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0); - PVPBuffer = new G4PVPlacement(0, posSi, logicSi, Name + "_Si", logicThinSi, true, 0); //attach it to the Silicon plate