From 2115533ff9b6273ed45f08c0396896618289ea78 Mon Sep 17 00:00:00 2001 From: adrien-matta <a.matta@surrey.ac.uk> Date: Wed, 6 Nov 2013 17:04:16 +0100 Subject: [PATCH] * Adding Tiara file in NPS and prepare template Tiara class --- NPLib/Tiara/TTiaraHyballData.h | 96 ++++++++++ NPLib/Tiara/libTiara.so | Bin 100212 -> 100212 bytes NPSimulation/Tiara/Tiara.cc | 324 +++++++++++++++++++++++++++++++++ NPSimulation/Tiara/Tiara.hh | 157 ++++++++++++++++ 4 files changed, 577 insertions(+) create mode 100644 NPLib/Tiara/TTiaraHyballData.h create mode 100644 NPSimulation/Tiara/Tiara.cc create mode 100644 NPSimulation/Tiara/Tiara.hh diff --git a/NPLib/Tiara/TTiaraHyballData.h b/NPLib/Tiara/TTiaraHyballData.h new file mode 100644 index 000000000..f83901360 --- /dev/null +++ b/NPLib/Tiara/TTiaraHyballData.h @@ -0,0 +1,96 @@ +#ifndef __TiaraHyballDATA__ +#define __TiaraHyballDATA__ +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold the Tiara Hyball Silicon array raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include<stdlib.h> +#include <vector> +#include <map> +using namespace std ; + +// ROOT +#include "TNamed.h" + +class TTiaraHyballData : public TNamed { + private: + vector<unsigned short> fTiaraHyball_Ring_DetectorNbr; + vector<unsigned short> fTiaraHyball_Ring_StripNbr; + vector<double> fTiaraHyball_Ring_Energy; + vector<double> fTiaraHyball_Ring_Time; + + vector<unsigned short> fTiaraHyball_Sector_DetectorNbr; + vector<unsigned short> fTiaraHyball_Sector_StripNbr; + vector<double> fTiaraHyball_Sector_Energy; + vector<double> fTiaraHyball_Sector_Time; + + ///////////// Fast Setters //////////////////// + public: + + + + ///////////// Getter and Setter //////////////// + public: + inline void Set_Ring_DetectorNbr(unsigned short& Ring_DetectorNbr) + {fTiaraHyball_Ring_DetectorNbr.push_back(Ring_DetectorNbr);} + inline unsigned short Get_Ring_DetectorNbr(unsigned int& i) + {return fTiaraHyball_Ring_DetectorNbr[i];} + + inline void Set_Ring_StripNbr(unsigned short& Ring_StripNbr) + {fTiaraHyball_Ring_StripNbr.push_back(Ring_StripNbr);} + inline unsigned short Get_Ring_StripNbr(unsigned int& i) + {return fTiaraHyball_Ring_StripNbr[i];} + + inline void Set_Ring_Energy(double& Ring_Energy) + {fTiaraHyball_Ring_Energy.push_back(Ring_Energy);} + inline double Get_Ring_Energy(unsigned int& i) + {return fTiaraHyball_Ring_Energy[i];} + + inline void Set_Ring_Time(double& Ring_Time) + {fTiaraHyball_Ring_Time.push_back(Ring_Time);} + inline double Get_Ring_Time(unsigned int& i) + {return fTiaraHyball_Ring_Time[i];} + + inline void Set_Sector_DetectorNbr(unsigned short& Sector_DetectorNbr) + {fTiaraHyball_Sector_DetectorNbr.push_back(Sector_DetectorNbr);} + inline unsigned short Get_Sector_DetectorNbr(unsigned int& i) + {return fTiaraHyball_Sector_DetectorNbr[i];} + + inline void Set_Sector_StripNbr(unsigned short& Sector_StripNbr) + {fTiaraHyball_Sector_StripNbr.push_back(Sector_StripNbr);} + inline unsigned short Get_Sector_StripNbr(unsigned int& i) + {return fTiaraHyball_Sector_StripNbr[i];} + + inline void Set_Sector_Energy(double& Sector_Energy) + {fTiaraHyball_Sector_Energy.push_back(Sector_Energy);} + inline double Get_Sector_Energy(unsigned int& i) + {return fTiaraHyball_Sector_Energy[i];} + + inline void Set_Sector_Time(double& Sector_Time) + {fTiaraHyball_Sector_Time.push_back(Sector_Time);} + inline double Get_Sector_Time(unsigned int& i) + {return fTiaraHyball_Sector_Time[i];} + + +}; + +#endif diff --git a/NPLib/Tiara/libTiara.so b/NPLib/Tiara/libTiara.so index 38c84331f8a0c128a800a1760bf6ea7259eda4e0..1ad12a7d9d4dcfc2762b4f7507f2a51e1c83da0e 100755 GIT binary patch delta 45 zcmey;$M&U<ZNmXJ0i6a-DF$tW=d-W&-#y@#yKnOawpq=L3pQtW{o(>rX;b+=0RYyZ B6&C;i delta 45 zcmey;$M&U<ZNmXJ0p>T4oEd}7idTG6jjr-xy}J1V+pK2Bg`2axesKY*w5fcb0M>gH ArT_o{ diff --git a/NPSimulation/Tiara/Tiara.cc b/NPSimulation/Tiara/Tiara.cc new file mode 100644 index 000000000..4efc65558 --- /dev/null +++ b/NPSimulation/Tiara/Tiara.cc @@ -0,0 +1,324 @@ +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe the Tiara Silicon array * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Box.hh" +#include "G4Tubs.hh" + +//G4 sensitive +#include "G4SDManager.hh" + +//G4 various object +#include "G4MaterialTable.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4Colour.hh" +#include "G4PVDivision.hh" +#include "G4SubtractionSolid.hh" + +// NPS +#include "Tiara.hh" + +// NPL +#include "NPOptionManager.h" + +//#include "TiaraScorers.hh" +#include "RootOutput.h" +using namespace TIARA; + +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +Tiara::Tiara(){ + //InitializeMaterial(); + m_EventBarrel = new TTiaraBarrelData(); + m_EventHyball = new TTiaraHyballData(); + + // Dark Grey + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + // Green + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + // Gold Yellow + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + // Light Grey + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + +} +Tiara::~Tiara(){ +} + +//....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 Tiara::ReadConfiguration(string Path){ +/* ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + G4double R,Phi,Thickness,Thickness1,Thickness2,Thickness3,Thickness4,ThicknessPAD1,ThicknessPAD2,ThicknessPAD3,ThicknessPAD4,Z; + R=Phi=Thickness=Thickness1=Thickness2=Thickness3=Thickness4=ThicknessPAD1=ThicknessPAD2=ThicknessPAD3=ThicknessPAD4=Z=0; + + G4ThreeVector Pos; + bool check_R = false ; + bool check_Phi = false ; + bool check_Thickness = false ; + bool check_Thickness1 = false ; + bool check_Thickness2 = false ; + bool check_Thickness3 = false ; + bool check_Thickness4 = false ; + bool check_PAD1 = false ; + bool check_PAD2 = false ; + bool check_PAD3 = false ; + bool check_PAD4 = false ; + bool check_Z = false ; + + bool ReadingStatusQQQ = false ; + bool ReadingStatusBOX = false ; + bool ReadingStatus = false ; + while (!ConfigFile.eof()){ + int VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); + + getline(ConfigFile, LineBuffer); + // cout << LineBuffer << endl; + if (LineBuffer.compare(0, 5, "Tiara") == 0) + ReadingStatus = true; + + while (ReadingStatus && !ConfigFile.eof()) { + ConfigFile >> DataBuffer ; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + // CD case + if (DataBuffer=="TiaraQQQ"){ + if(VerboseLevel==1) G4cout << "///" << G4endl ; + if(VerboseLevel==1) G4cout << "QQQ Quadrant found: " << G4endl ; + ReadingStatusQQQ = true ; + } + + // Box case + else if (DataBuffer=="TiaraBOX"){ + if(VerboseLevel==1) G4cout << "///" << G4endl ; + if(VerboseLevel==1) G4cout << "Box Detector found: " << G4endl ; + ReadingStatusBOX = true ; + } + + // Reading Block + while(ReadingStatusQQQ){ + // Pickup Next Word + ConfigFile >> DataBuffer ; + + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + //Position method + else if (DataBuffer == "Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + Z= atof(DataBuffer.c_str())*mm; + if(VerboseLevel==1) cout << " Z= " << Z/mm << "mm" << endl; + } + + else if (DataBuffer == "R=") { + check_R = true; + ConfigFile >> DataBuffer ; + R= atof(DataBuffer.c_str())*mm; + if(VerboseLevel==1) cout << " R= " << R/mm << "mm" << endl; + } + + else if (DataBuffer == "Phi=") { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi= atof(DataBuffer.c_str())*deg; + if(VerboseLevel==1) cout << " Phi= " << Phi/deg << "deg" << endl; + } + + else if (DataBuffer == "ThicknessDector=") { + check_Thickness = true; + ConfigFile >> DataBuffer ; + Thickness= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessDetector= " << Thickness/um << "um" << endl; + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatusQQQ = false; + G4cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << G4endl ; + exit(1); + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if (check_R && check_Phi && check_Z && check_Thickness){ + + ReadingStatusQQQ = false; + AddQQQDetector(G4ThreeVector(R,Phi,Z),Thickness); + // Reinitialisation of Check Boolean + check_R = false ; + check_Phi = false ; + check_Thickness = false ; + } + + } + + while(ReadingStatusBOX){ + // Pickup Next Word + ConfigFile >> DataBuffer ; + + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + //Position method + else if (DataBuffer == "Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + Z= atof(DataBuffer.c_str())*mm; + if(VerboseLevel==1) cout << " Z= " << Z/mm << "mm" << endl; + } + + else if (DataBuffer == "ThicknessDector1=") { + check_Thickness1 = true; + ConfigFile >> DataBuffer ; + Thickness1= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessDetector1= " << Thickness1/um << "um" << endl; + } + + else if (DataBuffer == "ThicknessDector2=") { + check_Thickness2 = true; + ConfigFile >> DataBuffer ; + Thickness2= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessDetector2= " << Thickness2/um << "um" << endl; + } + + else if (DataBuffer == "ThicknessDector3=") { + check_Thickness3 = true; + ConfigFile >> DataBuffer ; + Thickness3= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessDetector3= " << Thickness3/um << "um" << endl; + } + + else if (DataBuffer == "ThicknessDector4=") { + check_Thickness4 = true; + ConfigFile >> DataBuffer ; + Thickness4= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessDetector4= " << Thickness4/um << "um" << endl; + } + + else if (DataBuffer == "ThicknessPAD1=") { + check_PAD1 = true; + ConfigFile >> DataBuffer ; + ThicknessPAD1= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessPAD1= " << ThicknessPAD1<< "um" << endl; + } + + else if (DataBuffer == "ThicknessPAD2=") { + check_PAD2 = true; + ConfigFile >> DataBuffer ; + ThicknessPAD2= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessPAD2= " << ThicknessPAD2<< "um" << endl; + } + + else if (DataBuffer == "ThicknessPAD3=") { + check_PAD3 = true; + ConfigFile >> DataBuffer ; + ThicknessPAD3= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessPAD3= " << ThicknessPAD3<< "um" << endl; + } + + else if (DataBuffer == "ThicknessPAD4=") { + check_PAD4 = true; + ConfigFile >> DataBuffer ; + ThicknessPAD4= atof(DataBuffer.c_str())*um; + if(VerboseLevel==1) cout << " ThicknessPAD4= " << ThicknessPAD4<< "um" << endl; + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatusBOX = false; + G4cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << G4endl ; + exit(1); + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if (check_Thickness1 && check_Thickness2 && check_Thickness3 && check_Thickness4 + && check_PAD1 && check_PAD2 && check_PAD3 && check_PAD4 + && check_Z){ + ReadingStatusBOX = false; + AddBoxDetector(Z,Thickness1,Thickness2,Thickness3,Thickness4, + ThicknessPAD1,ThicknessPAD2,ThicknessPAD3,ThicknessPAD4); + // Reinitialisation of Check Boolean + check_R = false ; + check_Phi = false ; + check_Thickness1 = false; + check_Thickness2 = false; + check_Thickness3 = false; + check_Thickness4 = false; + check_PAD1 = false; + check_PAD2 = false; + check_PAD3 = false; + check_PAD4 = false; + check_Z = false ; + + } + } + } + }*/ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Tiara::ConstructDetector(G4LogicalVolume* world){ + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void Tiara::ReadSensitive(const G4Event* event){ + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Tiara::InitializeScorers(){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Tiara::InitializeRootOutput(){ +} + + diff --git a/NPSimulation/Tiara/Tiara.hh b/NPSimulation/Tiara/Tiara.hh new file mode 100644 index 000000000..76b6ff31c --- /dev/null +++ b/NPSimulation/Tiara/Tiara.hh @@ -0,0 +1,157 @@ +#ifndef Tiara_h +#define Tiara_h 1 +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe the Tiara Silicon detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +// C++ header +#include <string> +#include <vector> + +// G4 header defining G4 types +#include "globals.hh" + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4VisAttributes.hh" +#include "G4MultiFunctionalDetector.hh" + +// NPSimulation header +#include "VDetector.hh" + +// NPLib +#include "TTiaraBarrelData.h" +#include "TTiaraHyballData.h" + +using namespace std; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace TIARA +{ + // Energy and time Resolution + const G4double ResoTime = 0 ; + //const G4double ResoEnergy = 0.035*MeV ;// = zzkeV of Resolution // Unit is MeV/2.35 + const G4double ResoEnergy = 0.042*MeV ;// = zzkeV of Resolution // Unit is MeV/2.35 +} + +using namespace TIARA; +class Tiara : public VDetector +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + Tiara() ; + ~Tiara() ; + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // To add a box detector + // Effectively construct Volume + void ConstructBarrel(G4LogicalVolume* world); + void ConstructHyball(G4LogicalVolume* world); + void ConstructChamber(G4LogicalVolume* world); + + //////////////////////////////////////////////////// + ///////// 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) ; + + + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// +private: + TTiaraBarrelData* m_EventBarrel ; + TTiaraHyballData* m_EventHyball ; + + + //////////////////////////////////////////////////// + ///////////////// Scorer Related /////////////////// + //////////////////////////////////////////////////// + +private: + // Initialize all Scorer + void InitializeScorers() ; + + // Scorer Associate to the Silicon + G4MultiFunctionalDetector* m_BOXScorer ; + G4MultiFunctionalDetector* m_PADScorer ; + G4MultiFunctionalDetector* m_QQQScorer ; + +private: + // Initialize material used in detector definition + void InitializeMaterial(); + + // List of material + G4Material* m_MaterialSilicon ; + G4Material* m_MaterialAl ; + G4Material* m_MaterialVacuum ; + G4Material* m_MaterialPCB ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + // True if the detector is a Box, false if a quadrant + vector<bool> m_Type ; + + // Used for Quadrant detectors + vector<G4ThreeVector> m_Pos ; // R , Phi , Z + vector<G4double> m_ThicknessQQQ; + + // Used for Box detectors + vector<G4double> m_Z ; + vector< vector<G4double> > m_ThicknessBOX; + vector< vector<G4double> > m_ThicknessPAD; + + // Set to true if you want to see Telescope Frame in your visualisation + bool m_non_sensitive_part_visiualisation ; + +private:/// Visualisation Attribute: + // Dark Grey + G4VisAttributes* SiliconVisAtt ; + // Green + G4VisAttributes* PCBVisAtt; + // Gold Yellow + G4VisAttributes* PADVisAtt ; + // Light Grey + G4VisAttributes* FrameVisAtt ; + +}; +#endif -- GitLab