diff --git a/NPLib/Detectors/TRex/TTRexData.cxx b/NPLib/Detectors/TRex/TTRexData.cxx index e3e24d290b4f243edd88f2dd579637ead4f7125d..1339c9fc6b15eda609a55f8f79d87bfefd112086 100644 --- a/NPLib/Detectors/TRex/TTRexData.cxx +++ b/NPLib/Detectors/TRex/TTRexData.cxx @@ -64,6 +64,15 @@ void TTRexData::Clear() { fTRexBack_T_StripNbr.clear(); fTRexBack_Time.clear(); + // PAD + // Energy + fTRexPAD_E_DetectorNbr.clear(); + fTRexPAD_Energy.clear(); + // Time + fTRexPAD_T_DetectorNbr.clear(); + fTRexPAD_Time.clear(); + + } @@ -108,4 +117,23 @@ void TTRexData::Dump() const { cout << "DetNbr: " << fTRexBack_T_DetectorNbr[i] << " Time: " << fTRexBack_Time[i]; } + // PAD + // Energy + mysize = fTRexPAD_E_DetectorNbr.size(); + cout << "TRex_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fTRexPAD_E_DetectorNbr[i] + << " Energy: " << fTRexPAD_Energy[i]; + } + + // Time + mysize = fTRexPAD_T_DetectorNbr.size(); + cout << "TRex_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fTRexPAD_T_DetectorNbr[i] + << " Time: " << fTRexPAD_Time[i]; + } + } diff --git a/NPLib/Detectors/TRex/TTRexData.h b/NPLib/Detectors/TRex/TTRexData.h index 4d31df19ec8b5f39aa4e41c7b758a1d5d212a56f..b49d9b6347f97dcf11290a8a95c7016e8a48feda 100644 --- a/NPLib/Detectors/TRex/TTRexData.h +++ b/NPLib/Detectors/TRex/TTRexData.h @@ -57,6 +57,16 @@ class TTRexData : public TObject { vector<UShort_t> fTRexBack_T_StripNbr; vector<Double_t> fTRexBack_Time; + // PAD + // Energy + vector<UShort_t> fTRexPAD_E_DetectorNbr; + vector<Double_t> fTRexPAD_Energy; + + // Time + vector<UShort_t> fTRexPAD_T_DetectorNbr; + vector<Double_t> fTRexPAD_Time; + + ////////////////////////////////////////////////////////////// // Constructor and destructor @@ -138,6 +148,29 @@ class TTRexData : public TObject { SetBack_Time(Time); };//! + // PAD + // Energy + inline void SetPADE_DetectorNbr(const UShort_t& DetNbr) + {fTRexPAD_E_DetectorNbr.push_back(DetNbr);} //! + inline void SetPAD_Energy(const Double_t& Energy) + {fTRexPAD_Energy.push_back(Energy);}//! + // Prefer global setter so that all vectors have the same size + inline void SetPADEnergy(const UShort_t& DetNbr, const Double_t& Energy) { + SetPADE_DetectorNbr(DetNbr); + SetPAD_Energy(Energy); + };//! + + // Time + inline void SetPADT_DetectorNbr(const UShort_t& DetNbr) + {fTRexPAD_T_DetectorNbr.push_back(DetNbr);} //! + inline void SetPAD_Time(const Double_t& Time) + {fTRexPAD_Time.push_back(Time);}//! + // Prefer global setter so that all vectors have the same size + inline void SetPADTime(const UShort_t& DetNbr,const Double_t& Time) { + SetPADT_DetectorNbr(DetNbr); + SetPAD_Time(Time); + };//! + ////////////////////// GETTERS //////////////////////// // Front @@ -182,6 +215,23 @@ class TTRexData : public TObject { inline Double_t GetBack_Time(const unsigned int &i) const {return fTRexBack_Time[i];}//! + // PAD + // Energy + inline UShort_t GetPADMultEnergy() const + {return fTRexPAD_E_DetectorNbr.size();} + inline UShort_t GetPADE_DetectorNbr(const unsigned int &i) const + {return fTRexPAD_E_DetectorNbr[i];}//! + inline Double_t GetPAD_Energy(const unsigned int &i) const + {return fTRexPAD_Energy[i];}//! + + // Time + inline UShort_t GetPADMultTime() const + {return fTRexPAD_T_DetectorNbr.size();} + inline UShort_t GetPADT_DetectorNbr(const unsigned int &i) const + {return fTRexPAD_T_DetectorNbr[i];}//! + inline Double_t GetPAD_Time(const unsigned int &i) const + {return fTRexPAD_Time[i];}//! + ////////////////////////////////////////////////////////////// // Required for ROOT dictionnary diff --git a/NPLib/Detectors/TRex/TTRexPhysics.cxx b/NPLib/Detectors/TRex/TTRexPhysics.cxx index 9006ccd691d44b095024b794d9f662c27a4c2dba..ba614c410b411ea9b26b93239028e1d0b4b695c9 100644 --- a/NPLib/Detectors/TRex/TTRexPhysics.cxx +++ b/NPLib/Detectors/TRex/TTRexPhysics.cxx @@ -1,18 +1,18 @@ /***************************************************************************** - * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * Copyright (C) 2009-2016 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: Adrien Matta contact address: a.matta@surrey.ac.uk * + * Original Author: Adrien Matta contact address: a.matta@surrey.ac.uk * * * - * Creation Date : January 2016 * + * Creation Date : January 2016 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class hold TRex Raw data * + * This class hold TRex Treat data * * * *---------------------------------------------------------------------------* * Comment: * @@ -37,20 +37,19 @@ using namespace std; // ROOT #include "TChain.h" - ClassImp(TTRexPhysics) -/////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// TTRexPhysics::TTRexPhysics() - : m_EventData(new TTRexData), - m_PreTreatedData(new TTRexData), - m_EventPhysics(this), - m_Spectra(0), - m_E_RAW_Threshold(0), // adc channels - m_E_Threshold(0), // MeV - m_NumberOfDetectors(0) { -} + : m_EventData(new TTRexData), + m_PreTreatedData(new TTRexData), + m_EventPhysics(this), + m_Spectra(0), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + m_NumberOfDetectors(0) { + } @@ -66,13 +65,41 @@ void TTRexPhysics::BuildPhysicalEvent() { // apply thresholds and calibration PreTreat(); - // match energy and time together - for (UShort_t e = 0; e < m_PreTreatedData->GetFrontMultEnergy(); e++) { - for (UShort_t t = 0; t < m_PreTreatedData->GetFrontMultTime(); t++) { - if (m_PreTreatedData->GetFrontE_DetectorNbr(e) == m_PreTreatedData->GetFrontT_DetectorNbr(t)) { - DetectorNumber.push_back(m_PreTreatedData->GetFrontE_DetectorNbr(e)); - Energy.push_back(m_PreTreatedData->GetFront_Energy(e)); - Time.push_back(m_PreTreatedData->GetFront_Time(t)); + // match Front and Back Energy + for (UShort_t f = 0; f < m_PreTreatedData->GetFrontMultEnergy(); f++) { + for (UShort_t b = 0; b < m_PreTreatedData->GetBackMultEnergy(); b++) { + if (m_PreTreatedData->GetFrontE_DetectorNbr(f) == m_PreTreatedData->GetBackE_DetectorNbr(b)) { + DetectorNumber.push_back(m_PreTreatedData->GetFrontE_DetectorNbr(f)); + Energy.push_back(m_PreTreatedData->GetFront_Energy(f)); + Strip_Front.push_back(m_PreTreatedData->GetFrontE_StripNbr(f)); + Strip_Back.push_back(m_PreTreatedData->GetBackE_StripNbr(b)); + bool checkTime = false; + double tt; + // Look for associated time + for (UShort_t t = 0; t < m_PreTreatedData->GetBackMultTime(); t++) { + if(m_PreTreatedData->GetFrontE_DetectorNbr(f) == m_PreTreatedData->GetBackT_DetectorNbr(t)){ + tt=m_PreTreatedData->GetBack_Time(t); + checkTime =true; + } + } + if(checkTime) + Time.push_back(tt); + else + Time.push_back(-1000); + + bool checkPAD = false; + double pp; + // Look for associated time + for (UShort_t t = 0; t < m_PreTreatedData->GetPADMultEnergy(); t++) { + if(m_PreTreatedData->GetFrontE_DetectorNbr(f) == m_PreTreatedData->GetBackT_DetectorNbr(t)){ + pp=m_PreTreatedData->GetPAD_Energy(t); + checkPAD =true; + } + } + if(checkPAD) + PAD_E.push_back(pp); + else + PAD_E.push_back(-1000); } } } @@ -82,27 +109,60 @@ void TTRexPhysics::BuildPhysicalEvent() { void TTRexPhysics::PreTreat() { // This method typically applies thresholds and calibrations // Might test for disabled channels for more complex detector - // clear pre-treated object ClearPreTreatedData(); // instantiate CalibrationManager static CalibrationManager* Cal = CalibrationManager::getInstance(); + // Front // Energy for (UShort_t i = 0; i < m_EventData->GetFrontMultEnergy(); ++i) { if (m_EventData->GetFront_Energy(i) > m_E_RAW_Threshold) { - Double_t Energy = Cal->ApplyCalibration("TRex/ENERGY"+NPL::itoa(m_EventData->GetFrontE_DetectorNbr(i)),m_EventData->GetFront_Energy(i)); + Double_t Energy = Cal->ApplyCalibration("TRex/ENERGY_FRONT"+NPL::itoa(m_EventData->GetFrontE_DetectorNbr(i)),m_EventData->GetFront_Energy(i)); if (Energy > m_E_Threshold) { - m_PreTreatedData->SetFrontEnergy(m_EventData->GetFrontE_DetectorNbr(i),0, Energy); + m_PreTreatedData->SetFrontEnergy(m_EventData->GetFrontE_DetectorNbr(i),m_EventData->GetFrontE_StripNbr(i), Energy); } } } // Time for (UShort_t i = 0; i < m_EventData->GetFrontMultTime(); ++i) { - Double_t Time= Cal->ApplyCalibration("TRex/TIME"+NPL::itoa(m_EventData->GetFrontT_DetectorNbr(i)),m_EventData->GetFront_Time(i)); - m_PreTreatedData->SetFrontTime(m_EventData->GetFrontT_DetectorNbr(i),0, Time); + Double_t Time= Cal->ApplyCalibration("TRex/TIME_FRONT"+NPL::itoa(m_EventData->GetFrontT_DetectorNbr(i)),m_EventData->GetFront_Time(i)); + m_PreTreatedData->SetFrontTime(m_EventData->GetFrontT_DetectorNbr(i),m_EventData->GetFrontT_StripNbr(i), Time); + } + + // Back + // Energy + for (UShort_t i = 0; i < m_EventData->GetBackMultEnergy(); ++i) { + if (m_EventData->GetBack_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = Cal->ApplyCalibration("TRex/ENERGY_BACK"+NPL::itoa(m_EventData->GetBackE_DetectorNbr(i)),m_EventData->GetBack_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetBackEnergy(m_EventData->GetBackE_DetectorNbr(i),m_EventData->GetBackE_StripNbr(i), Energy); + } + } + } + + // Time + for (UShort_t i = 0; i < m_EventData->GetBackMultTime(); ++i) { + Double_t Time= Cal->ApplyCalibration("TRex/TIME_BACK"+NPL::itoa(m_EventData->GetBackT_DetectorNbr(i)),m_EventData->GetBack_Time(i)); + m_PreTreatedData->SetBackTime(m_EventData->GetBackT_DetectorNbr(i),m_EventData->GetBackT_StripNbr(i), Time); + } + // PAD + // Energy + for (UShort_t i = 0; i < m_EventData->GetPADMultEnergy(); ++i) { + if (m_EventData->GetPAD_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = Cal->ApplyCalibration("TRex/ENERGY_PAD"+NPL::itoa(m_EventData->GetPADE_DetectorNbr(i)),m_EventData->GetPAD_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetPADEnergy(m_EventData->GetPADE_DetectorNbr(i), Energy); + } + } + } + + // Time + for (UShort_t i = 0; i < m_EventData->GetPADMultTime(); ++i) { + Double_t Time= Cal->ApplyCalibration("TRex/TIME_PAD"+NPL::itoa(m_EventData->GetPADT_DetectorNbr(i)),m_EventData->GetPAD_Time(i)); + m_PreTreatedData->SetPADTime(m_EventData->GetPADT_DetectorNbr(i), Time); } } @@ -175,7 +235,10 @@ void TTRexPhysics::ReadAnalysisConfig() { /////////////////////////////////////////////////////////////////////////// void TTRexPhysics::Clear() { DetectorNumber.clear(); + Strip_Front.clear(); + Strip_Back.clear(); Energy.clear(); + PAD_E.clear(); Time.clear(); } @@ -183,124 +246,102 @@ void TTRexPhysics::Clear() { /////////////////////////////////////////////////////////////////////////// void TTRexPhysics::ReadConfiguration(string Path) { - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; - bool check_Shape = false ; - bool check_X = false ; - bool check_Y = false ; - bool check_Z = false ; - bool ReadingStatus = false ; - - while (!ConfigFile.eof()){ + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + double X,Y,Z; + bool check_X = false ; + bool check_Y = false ; + bool check_Z = false ; + bool ReadingStatus = false ; + + + while (!ConfigFile.eof()) { getline(ConfigFile, LineBuffer); - // If line is a Start Up TRex bloc, Reading toggle to true - string name="TRex"; - if (LineBuffer.compare(0, name.length(), name) == 0){ - cout << "///" << endl ; - cout << "TRex found: " << endl ; - ReadingStatus = true ; + // If line is a Start Up TRex bloc, Reading toggle to true + string name = "TRex"; + + if (LineBuffer.compare(0, name.length(), name) == 0) { + cout << "///" << endl ; + cout << "TRex found: " << endl ; + ReadingStatus = true ; } + // Else don't toggle to Reading Block Status + else ReadingStatus = false ; + // Reading Block - while(ReadingStatus) - { - // Pickup Next Word + while(ReadingStatus){ + // Pickup Next Word ConfigFile >> DataBuffer ; - // Comment Line + // 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, name.length(), name) == 0) { - cout << "\033[1;311mWARNING: Another detector is find before standard sequence of Token, Error may occured in detector definition\033[0m" << endl ; + else if (DataBuffer.compare(0, name.length(),name) == 0) { + cout << "WARNING: Another Detector is find before standard sequence of Token, Error may occured in Telecope definition" << endl ; ReadingStatus = false ; } - //Angle method - else if (DataBuffer=="THETA=") { - check_Theta = true; - ConfigFile >> DataBuffer ; - cout << "Theta: " << atof(DataBuffer.c_str()) << "deg" << endl; - } - - else if (DataBuffer=="PHI=") { - check_Phi = true; - ConfigFile >> DataBuffer ; - cout << "Phi: " << atof( DataBuffer.c_str() ) << "deg" << endl; - } - - else if (DataBuffer=="R=") { - check_R = true; - ConfigFile >> DataBuffer ; - cout << "R: " << atof( DataBuffer.c_str() ) << "mm" << endl; - } - //Position method - else if (DataBuffer=="X=") { + else if (DataBuffer.compare(0, 2, "X=") == 0) { check_X = true; ConfigFile >> DataBuffer ; - cout << "X: " << atof( DataBuffer.c_str() ) << "mm" << endl; + X = atof(DataBuffer.c_str()) ; + X = X ; + cout << "X: " << X << endl; } - else if (DataBuffer=="Y=") { + else if (DataBuffer.compare(0, 2, "Y=") == 0) { check_Y = true; ConfigFile >> DataBuffer ; - cout << "Y: " << atof( DataBuffer.c_str() ) << "mm"<< endl; + Y = atof(DataBuffer.c_str()) ; + Y = Y ; + cout << "Y: " << Y << endl; } - else if (DataBuffer=="Z=") { + else if (DataBuffer.compare(0, 2, "Z=") == 0) { check_Z = true; ConfigFile >> DataBuffer ; - cout << "Z: " << atof( DataBuffer.c_str() ) << "mm" << endl; + Z = atof(DataBuffer.c_str()) ; + Z = Z ; + cout << "Z: " << Z << endl; } - - //General - else if (DataBuffer=="Shape=") { - check_Shape = true; - ConfigFile >> DataBuffer ; - cout << "Shape: " << DataBuffer << endl; + else if (DataBuffer.compare(0, 8, "Chamber=") == 0) { + ConfigFile >> DataBuffer ; } - /////////////////////////////////////////////////// // If no Detector Token and no comment, toggle out else{ - ReadingStatus = false; cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl ; + ReadingStatus = false; + cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl ; } ///////////////////////////////////////////////// // If All necessary information there, toggle out - if ( ((check_Theta && check_Phi && check_R) ||( check_X && check_Y && check_Z) ) && check_Shape ){ - m_NumberOfDetectors++; - - // Reinitialisation of Check Boolean - check_Theta = false ; - check_Phi = false ; - check_R = false ; - check_Shape = false ; - check_X = false ; - check_Y = false ; - check_Z = false ; - ReadingStatus = false ; - cout << "///"<< endl ; + if (check_X && check_Y && check_Z){ + // Convert Cartesian to Spherical (detector always face the target) + AddBarrelDetector(X,Y,Z); + + // Reinitialisation of Check Boolean + check_X = false ; + check_Y = false ; + check_Z = false ; + ReadingStatus = false ; + cout << "///"<< endl ; } } } } - - /////////////////////////////////////////////////////////////////////////// void TTRexPhysics::InitSpectra() { m_Spectra = new TTRexSpectra(m_NumberOfDetectors); @@ -340,7 +381,63 @@ map< string , TH1*> TTRexPhysics::GetSpectra() { return empty; } } +/////////////////////////////////////////////////////////////////////////// +void TTRexPhysics::AddBarrelDetector(double X, double Y, double Z){ + TVector3 U; TVector3 V;TVector3 Strip_1_1; + m_NumberOfDetectors++; + double StripPitchFront= 50/16.; + double StripPitchBack= 50/16.; + + // Half the length of the wafer (square wafer) + double A = (50-StripPitchFront)*0.5; + double B = (50-StripPitchBack)*0.5; + double Zc=0; + if(Z<0){// Up Stream + Zc = Z +B; + if(X==0 && Y>0) {U=TVector3(-1,0,0) ;V=TVector3(0,0,-1); Strip_1_1=TVector3( A , Y ,Zc); } + else if(X==0 && Y<0) {U=TVector3(1,0,0) ;V=TVector3(0,0,-1); Strip_1_1=TVector3( -A , Y ,Zc);} + else if(Y==0 && X>0) {U=TVector3(0,1,0) ;V=TVector3(0,0,-1); Strip_1_1=TVector3( X , -A ,Zc); } + else if(Y==0 && X<0) {U=TVector3(0,-1,0) ;V=TVector3(0,0,-1); Strip_1_1=TVector3( X , A ,Zc);} + } + else if(Z>0){//Down Stream + Zc = Z -B; + if(X==0 && Y>0) {U=TVector3(1,0,0) ;V=TVector3(0,0,1); Strip_1_1=TVector3( -A , Y ,Zc); } + else if(X==0 && Y<0) {U=TVector3(-1,0,0) ;V=TVector3(0,0,1); Strip_1_1=TVector3( A , Y ,Zc); } + else if(Y==0 && X>0) {U=TVector3(0,-1,0) ;V=TVector3(0,0,1); Strip_1_1=TVector3( X , A ,Zc); } + else if(Y==0 && X<0) {U=TVector3(0,1,0) ;V=TVector3(0,0,1); Strip_1_1=TVector3( X , -A ,Zc); } + } + + // Buffer object to fill Position Array + vector<double> lineX ; vector<double> lineY ; vector<double> lineZ ; + + vector< vector< double > > OneBoxStripPositionX ; + vector< vector< double > > OneBoxStripPositionY ; + vector< vector< double > > OneBoxStripPositionZ ; + + TVector3 StripCenter = Strip_1_1; + for(int f = 0 ; f < 16; f++){ + lineX.clear() ; + lineY.clear() ; + lineZ.clear() ; + + for(int b = 0 ; b < 16; b++){ + StripCenter = Strip_1_1 + ( StripPitchFront*f*U + StripPitchBack*b*V ); + + lineX.push_back( StripCenter.X() ); + lineY.push_back( StripCenter.Y() ); + lineZ.push_back( StripCenter.Z() ); + } + + OneBoxStripPositionX.push_back(lineX); + OneBoxStripPositionY.push_back(lineY); + OneBoxStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back( OneBoxStripPositionX ) ; + m_StripPositionY.push_back( OneBoxStripPositionY ) ; + m_StripPositionZ.push_back( OneBoxStripPositionZ ) ; + +} //////////////////////////////////////////////////////////////////////////////// @@ -366,8 +463,11 @@ void TTRexPhysics::WriteSpectra() { void TTRexPhysics::AddParameterToCalibrationManager() { CalibrationManager* Cal = CalibrationManager::getInstance(); for (int i = 0; i < m_NumberOfDetectors; ++i) { - Cal->AddParameter("TRex", "D"+ NPL::itoa(i+1)+"_ENERGY","TRex_D"+ NPL::itoa(i+1)+"_ENERGY"); - Cal->AddParameter("TRex", "D"+ NPL::itoa(i+1)+"_TIME","TRex_D"+ NPL::itoa(i+1)+"_TIME"); + Cal->AddParameter("TRex", "D"+ NPL::itoa(i+1)+"_ENERGY_FRONT","TRex_D"+ NPL::itoa(i+1)+"_ENERGY_FRONT"); + Cal->AddParameter("TRex", "D"+ NPL::itoa(i+1)+"_TIME_FRONT","TRex_D"+ NPL::itoa(i+1)+"_TIME_FRONT"); + Cal->AddParameter("TRex", "D"+ NPL::itoa(i+1)+"_ENERGY_FRONT","TRex_D"+ NPL::itoa(i+1)+"_ENERGY_FRONT"); + Cal->AddParameter("TRex", "D"+ NPL::itoa(i+1)+"_TIME_FRONT","TRex_D"+ NPL::itoa(i+1)+"_TIME_FRONT"); + } } @@ -396,7 +496,22 @@ void TTRexPhysics::InitializeRootOutput() { outputTree->Branch("TRex", "TTRexPhysics", &m_EventPhysics); } +//////////////////////////////////////////////////////////////////////////////// +TVector3 TTRexPhysics::GetPositionOfInteraction(const int& i,bool random) const{ + static TVector3 Position ; + static double BoxPitchBack= 50/16.; + static double BoxPitchFront= 50/16.; + Position = TVector3 ( GetStripPositionX( DetectorNumber[i], Strip_Front[i], Strip_Back[i] ), + GetStripPositionY( DetectorNumber[i] , Strip_Front[i], Strip_Back[i] ), + GetStripPositionZ( DetectorNumber[i] , Strip_Front[i], Strip_Back[i] )) ; + + if(random){ + return Position; + } + + return Position ; +} //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // diff --git a/NPLib/Detectors/TRex/TTRexPhysics.h b/NPLib/Detectors/TRex/TTRexPhysics.h index 3b0334fed4033b46f36b6080c7281c9dea154395..1333aafb36b455ef6fb3241dc2cd52258e635450 100644 --- a/NPLib/Detectors/TRex/TTRexPhysics.h +++ b/NPLib/Detectors/TRex/TTRexPhysics.h @@ -32,6 +32,7 @@ using namespace std; #include "TObject.h" #include "TH1.h" #include "TCanvas.h" +#include "TVector3.h" // NPTool headers #include "TTRexData.h" @@ -63,9 +64,12 @@ class TTRexPhysics : public TObject, public NPL::VDetector { // data obtained after BuildPhysicalEvent() and stored in // output ROOT file public: - vector<int> DetectorNumber; - vector<double> Energy; - vector<double> Time; + vector<int> DetectorNumber; + vector<int> Strip_Front; + vector<int> Strip_Back; + vector<double> Energy; + vector<double> PAD_E; + vector<double> Time; ////////////////////////////////////////////////////////////// @@ -139,7 +143,10 @@ class TTRexPhysics : public TObject, public NPL::VDetector { // give and external TTRexData object to TTRexPhysics. // needed for online analysis for example void SetRawDataPointer(TTRexData* rawDataPointer) {m_EventData = rawDataPointer;} - + + // Add a detector + void AddBarrelDetector(double X, double Y, double Z); + // objects are not written in the TTree private: TTRexData* m_EventData; //! @@ -148,8 +155,8 @@ class TTRexPhysics : public TObject, public NPL::VDetector { // getters for raw and pre-treated data object public: - TTRexData* GetRawData() const {return m_EventData;} - TTRexData* GetPreTreatedData() const {return m_PreTreatedData;} + TTRexData* GetRawData() const {return m_EventData;} //! + TTRexData* GetPreTreatedData() const {return m_PreTreatedData;}//! // parameters used in the analysis private: @@ -157,11 +164,19 @@ class TTRexPhysics : public TObject, public NPL::VDetector { double m_E_RAW_Threshold; //! double m_E_Threshold; //! - // number of detectors - private: - int m_NumberOfDetectors; //! - - // spectra class + public: // Get the spatial position of interaction + // Use to access the strip position + inline double GetStripPositionX( const int& N , const int& Front , const int& Back ) const{ return m_StripPositionX[N-1][Front-1][Back-1] ; } ; + inline double GetStripPositionY( const int& N , const int& Front , const int& Back ) const{ return m_StripPositionY[N-1][Front-1][Back-1] ; } ; + inline double GetStripPositionZ( const int& N , const int& Front , const int& Back ) const{ return m_StripPositionZ[N-1][Front-1][Back-1] ; } ; + TVector3 GetPositionOfInteraction(const int& i,bool random) const; + + private: // Spatial Position of Strip Calculated on bases of detector position + int m_NumberOfDetectors;//! + vector< vector < vector < double > > > m_StripPositionX;//! + vector< vector < vector < double > > > m_StripPositionY;//! + vector< vector < vector < double > > > m_StripPositionZ;//! + // spectra class private: TTRexSpectra* m_Spectra; // ! diff --git a/NPSimulation/Detectors/TRex/TRex.cc b/NPSimulation/Detectors/TRex/TRex.cc index 706210c821ea09341118c9463b8f27e515390765..e536c2eb99cb90cb4a568b3a1ea86c028eb959d4 100644 --- a/NPSimulation/Detectors/TRex/TRex.cc +++ b/NPSimulation/Detectors/TRex/TRex.cc @@ -55,7 +55,7 @@ namespace TRex_NS{ // Energy and time Resolution const double EnergyThreshold = 0.1*MeV; const double ResoTime = 4.5*ns ; - const double ResoEnergy = 5.0*MeV ; + const double ResoEnergy = 0.1*MeV ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -63,7 +63,9 @@ namespace TRex_NS{ // TRex Specific Method TRex::TRex(){ m_Event = new TTRexData() ; - m_TRexScorer = 0; + m_StripScorer = 0; + m_PADScorer = 0; + m_BarrelDetector = 0; m_Chamber=0; @@ -104,10 +106,10 @@ G4AssemblyVolume* TRex::BuildBarrelDetector(){ PCB->SetVisAttributes(m_PCBVisAtt); Det->SetVisAttributes(m_SiliconVisAtt); - Det->SetSensitiveDetector(m_TRexScorer); + Det->SetSensitiveDetector(m_StripScorer); PCBE->SetVisAttributes(m_PADVisAtt); DetE->SetVisAttributes(m_SiliconVisAtt); -// DetE->SetSensitiveDetector(m_TRexScorer); + DetE->SetSensitiveDetector(m_PADScorer); G4ThreeVector PosPCB(16.5*mm,0,0); G4ThreeVector PosDet(0,0,0); @@ -322,8 +324,15 @@ void TRex::ReadSensitive(const G4Event* event){ G4THitsMap<G4double*>* StripHitMap; std::map<G4int, G4double**>::iterator Strip_itr; - G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TRexScorer/Barrel"); + G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TRexStripScorer/Strip"); StripHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(StripCollectionID)); + + G4THitsMap<G4double*>* PADHitMap; + std::map<G4int, G4double**>::iterator PAD_itr; + + G4int PADCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TRexPADScorer/PAD"); + PADHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PADCollectionID)); + // Loop on the Strip map for (Strip_itr = StripHitMap->GetMap()->begin() ; Strip_itr != StripHitMap->GetMap()->end() ; Strip_itr++){ @@ -354,6 +363,32 @@ void TRex::ReadSensitive(const G4Event* event){ } // clear map for next event StripHitMap->clear(); + + // Loop on the PAD map + for (PAD_itr = PADHitMap->GetMap()->begin() ; PAD_itr != PADHitMap->GetMap()->end() ; PAD_itr++){ + G4double* Info = *(PAD_itr->second); + + double Energy = Info[0]; + + if(Energy>TRex_NS::EnergyThreshold){ + double Time = Info[1]; + int DetNbr = (int) Info[7]; + + m_Event->SetPADEnergy(DetNbr,RandGauss::shoot(Energy,TRex_NS::ResoEnergy)); + m_Event->SetPADTime(DetNbr,RandGauss::shoot(Time, TRex_NS::ResoTime)); + + // Interraction Coordinates + /* ms_InterCoord->SetDetectedPositionX(Info[2]) ; + ms_InterCoord->SetDetectedPositionY(Info[3]) ; + ms_InterCoord->SetDetectedPositionZ(Info[4]) ; + ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; + ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; +*/ + } + } + // clear map for next event + PADHitMap->clear(); + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -361,16 +396,24 @@ void TRex::ReadSensitive(const G4Event* event){ void TRex::InitializeScorers() { // This check is necessary in case the geometry is reloaded bool already_exist = false; - m_TRexScorer = CheckScorer("TRexScorer",already_exist) ; + m_StripScorer = CheckScorer("TRexStripScorer",already_exist) ; + m_PADScorer = CheckScorer("TRexPADScorer",already_exist) ; if(already_exist) return ; // Otherwise the scorer is initialised - G4VPrimitiveScorer* Strip= new SILICONSCORERS::PS_Silicon_Rectangle("Barrel",0,50*mm,50*mm,16,16,0,"yz") ; + G4VPrimitiveScorer* Strip= new SILICONSCORERS::PS_Silicon_Rectangle("Strip",0,50*mm,50*mm,16,16,0,"yz") ; + G4VPrimitiveScorer* PAD= new SILICONSCORERS::PS_Silicon_Rectangle("PAD",0,50*mm,50*mm,1,1,0) ; + //and register it to the multifunctionnal detector - m_TRexScorer->RegisterPrimitive(Strip); - G4SDManager::GetSDMpointer()->AddNewDetector(m_TRexScorer) ; + m_StripScorer->RegisterPrimitive(Strip); + m_PADScorer->RegisterPrimitive(PAD); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_PADScorer) ; + + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Detectors/TRex/TRex.hh b/NPSimulation/Detectors/TRex/TRex.hh index 831c9bc4ada667a8c137a37b4f986b913af2ef44..4cf8208245a2cf78d7daf28dcdcb1fa84c3f4079 100644 --- a/NPSimulation/Detectors/TRex/TRex.hh +++ b/NPSimulation/Detectors/TRex/TRex.hh @@ -88,7 +88,9 @@ class TRex : public NPS::VDetector{ void InitializeScorers() ; // Associated Scorer - G4MultiFunctionalDetector* m_TRexScorer ; + G4MultiFunctionalDetector* m_StripScorer ; + G4MultiFunctionalDetector* m_PADScorer ; + //////////////////////////////////////////////////// ///////////Event class to store Data//////////////// ////////////////////////////////////////////////////