From a9dd296b55a03c5e254aca3d00667d9b2ceb983d Mon Sep 17 00:00:00 2001 From: moukaddam <mhd.moukaddam@gmail.com> Date: Mon, 6 May 2019 16:22:43 +0200 Subject: [PATCH] implementing the new detector Pyramid class --- NPLib/Detectors/Pyramid/TPyramidData.cxx | 179 ++++-- NPLib/Detectors/Pyramid/TPyramidData.h | 322 ++++++++-- NPLib/Detectors/Pyramid/TPyramidPhysics.cxx | 645 ++++++++++++++------ NPLib/Detectors/Pyramid/TPyramidPhysics.h | 281 +++++---- NPLib/Detectors/Pyramid/TPyramidSpectra.cxx | 344 ++++++++--- NPLib/Detectors/Pyramid/TPyramidSpectra.h | 26 +- 6 files changed, 1276 insertions(+), 521 deletions(-) diff --git a/NPLib/Detectors/Pyramid/TPyramidData.cxx b/NPLib/Detectors/Pyramid/TPyramidData.cxx index 6bd9e86ae..662fcf964 100644 --- a/NPLib/Detectors/Pyramid/TPyramidData.cxx +++ b/NPLib/Detectors/Pyramid/TPyramidData.cxx @@ -1,79 +1,182 @@ /***************************************************************************** - * Copyright (C) 2009-2018 this file is part of the NPTool Project * + * Copyright (C) 2009-2011 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: Mohamad Moukaddam contact address: mohamad.moukaddam@iphc.cnrs.fr * + * Original Author: Mohamad Moukaddam * + * contact address: mohamad.moukaddam@iphc.cnrs.fr * * * - * Creation Date : November 2018 * + * Creation Date : November 2011 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class hold Pyramid Raw data * + * This class hold Pyramid Raw data * * * *---------------------------------------------------------------------------* * Comment: * * * * * *****************************************************************************/ -#include "TPyramidData.h" - #include <iostream> #include <fstream> #include <sstream> #include <string> using namespace std; +#include "TPyramidData.h" + ClassImp(TPyramidData) + ///////////////////////// + TPyramidData::TPyramidData(){ + // Reserve the space for the full array + fPyramid_FrontUpstreamE_DetectorNbr.reserve(1*4); + fPyramid_FrontUpstreamE_StripNbr.reserve(1*4); + fPyramid_FrontUpstreamE_Energy.reserve(1*4); -////////////////////////////////////////////////////////////////////// -TPyramidData::TPyramidData() { -} + fPyramid_FrontDownstreamE_DetectorNbr.reserve(1*4); + fPyramid_FrontDownstreamE_StripNbr.reserve(1*4); + fPyramid_FrontDownstreamE_Energy.reserve(1*4); + fPyramid_BackE_DetectorNbr.reserve(1); + fPyramid_BackE_Energy.reserve(1); + fPyramid_OuterE_DetectorNbr.reserve(1*4); + fPyramid_OuterE_StripNbr.reserve(1*4); + fPyramid_OuterE_Energy.reserve(1*4); + + fPyramid_FrontUpstreamT_DetectorNbr.reserve(1*4); + fPyramid_FrontUpstreamT_StripNbr.reserve(1*4); + fPyramid_FrontUpstreamT_Time.reserve(1*4); -////////////////////////////////////////////////////////////////////// -TPyramidData::~TPyramidData() { -} + fPyramid_FrontDownstreamT_DetectorNbr.reserve(1*4); + fPyramid_FrontDownstreamT_StripNbr.reserve(1*4); + fPyramid_FrontDownstreamT_Time.reserve(1*4); + fPyramid_BackT_DetectorNbr.reserve(1); + fPyramid_BackT_Time.reserve(1); + + fPyramid_OuterT_DetectorNbr.reserve(1*4); + fPyramid_OuterT_StripNbr.reserve(1*4); + fPyramid_OuterT_Time.reserve(1*4); -////////////////////////////////////////////////////////////////////// -void TPyramidData::Clear() { - // Energy - fPyramid_E_DetectorNbr.clear(); - fPyramid_Energy.clear(); - // Time - fPyramid_T_DetectorNbr.clear(); - fPyramid_Time.clear(); } +///////////////////////// +TPyramidData::~TPyramidData(){ + Clear(); +} + +///////////////////////// +void TPyramidData::Clear(){ + fPyramid_FrontUpstreamE_DetectorNbr.clear(); + fPyramid_FrontUpstreamE_StripNbr.clear(); + fPyramid_FrontUpstreamE_Energy.clear(); + + fPyramid_FrontDownstreamE_DetectorNbr.clear(); + fPyramid_FrontDownstreamE_StripNbr.clear(); + fPyramid_FrontDownstreamE_Energy.clear(); + + fPyramid_BackE_DetectorNbr.clear(); + fPyramid_BackE_Energy.clear(); + + fPyramid_OuterE_DetectorNbr.clear(); + fPyramid_OuterE_StripNbr.clear(); + fPyramid_OuterE_Energy.clear(); + + fPyramid_FrontUpstreamT_DetectorNbr.clear(); + fPyramid_FrontUpstreamT_StripNbr.clear(); + fPyramid_FrontUpstreamT_Time.clear(); + + fPyramid_FrontDownstreamT_DetectorNbr.clear(); + fPyramid_FrontDownstreamT_StripNbr.clear(); + fPyramid_FrontDownstreamT_Time.clear(); + + fPyramid_BackT_DetectorNbr.clear(); + fPyramid_BackT_Time.clear(); + + fPyramid_OuterT_DetectorNbr.clear(); + fPyramid_OuterT_StripNbr.clear(); + fPyramid_OuterT_Time.clear(); -////////////////////////////////////////////////////////////////////// -void TPyramidData::Dump() const { - // This method is very useful for debuging and worth the dev. - cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TPyramidData::Dump()] XXXXXXXXXXXXXXXXX" << endl; - // Energy - size_t mysize = fPyramid_E_DetectorNbr.size(); - cout << "Pyramid_E_Mult: " << mysize << endl; - - for (size_t i = 0 ; i < mysize ; i++){ - cout << "DetNbr: " << fPyramid_E_DetectorNbr[i] - << " Energy: " << fPyramid_Energy[i]; +} + +///////////////////////// +void TPyramidData::Dump() const{ + cout << "************* TPyramidData Event ************"<< endl; + cout << "*** Inner Barrel Front Upstream ***" << endl ; + for( unsigned int i = 0; i < fPyramid_FrontUpstreamE_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fPyramid_FrontUpstreamE_DetectorNbr[i] << " | " ; + cout << "Strip Number = " + << fPyramid_FrontUpstreamE_StripNbr[i] << " | "; + cout << "Energy = " + << fPyramid_FrontUpstreamE_Energy[i]<< endl ; } - // Time - mysize = fPyramid_T_DetectorNbr.size(); - cout << "Pyramid_T_Mult: " << mysize << endl; - - for (size_t i = 0 ; i < mysize ; i++){ - cout << "DetNbr: " << fPyramid_T_DetectorNbr[i] - << " Time: " << fPyramid_Time[i]; + for( unsigned int i = 0; i < fPyramid_FrontUpstreamT_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fPyramid_FrontUpstreamT_DetectorNbr[i] << " | " ; + cout << "Strip Number = " + << fPyramid_FrontUpstreamT_StripNbr[i] << " | "; + cout << "Time = " + << fPyramid_FrontUpstreamT_Time[i] << endl ; + } + + + cout << "*** Inner Barrel Front Downstream ***" << endl ; + for( unsigned int i = 0; i < fPyramid_FrontDownstreamE_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fPyramid_FrontDownstreamE_DetectorNbr[i] << " | "; + cout << "Strip Number = " + << fPyramid_FrontDownstreamE_StripNbr[i] << " | "; + cout << "Energy = " + << fPyramid_FrontDownstreamE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fPyramid_FrontDownstreamT_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fPyramid_FrontDownstreamT_DetectorNbr[i] << " | "; + cout << "Strip Number = " + << fPyramid_FrontDownstreamT_StripNbr[i] << " | "; + cout << "Time = " + << fPyramid_FrontDownstreamT_Time[i] << endl ; + } + + cout << "*** Inner Barrel Back ***" << endl ; + for( unsigned int i = 0; i < fPyramid_BackE_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fPyramid_BackE_DetectorNbr[i] << " | "; + cout << "Energy = " + << fPyramid_BackE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fPyramid_BackT_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fPyramid_BackT_DetectorNbr[i] << " | "; + cout << "Time = " + << fPyramid_BackT_Time[i] << endl ; + } + + cout << "*** Outer Barrel ***" << endl; + for( unsigned int i = 0; i < fPyramid_OuterE_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fPyramid_OuterE_DetectorNbr[i] << " | "; + cout << "Energy = " + << fPyramid_OuterE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fPyramid_OuterT_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fPyramid_OuterT_DetectorNbr[i] << " | "; + cout << "Time = " + << fPyramid_OuterT_Time[i] << endl ; } } + diff --git a/NPLib/Detectors/Pyramid/TPyramidData.h b/NPLib/Detectors/Pyramid/TPyramidData.h index f17191efa..00d31fc3e 100644 --- a/NPLib/Detectors/Pyramid/TPyramidData.h +++ b/NPLib/Detectors/Pyramid/TPyramidData.h @@ -1,16 +1,17 @@ #ifndef __PyramidDATA__ #define __PyramidDATA__ /***************************************************************************** - * Copyright (C) 2009-2018 this file is part of the NPTool Project * + * Copyright (C) 2009-2018 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: Mohamad Moukaddam contact address: mohamad.moukaddam@iphc.cnrs.fr * + * Original Author: Mohamad Moukaddam * + * contact address: mohamad.moukaddam@iphc.cnrs.fr * * * - * Creation Date : November 2018 * + * Creation Date : November 2018 * * Last update : * *---------------------------------------------------------------------------* * Decription: * @@ -23,82 +24,273 @@ *****************************************************************************/ // STL +#include<stdlib.h> #include <vector> -using namespace std; +#include <map> +using namespace std ; // ROOT -#include "TObject.h" +#include "TNamed.h" -class TPyramidData : public TObject { - ////////////////////////////////////////////////////////////// - // data members are hold into vectors in order - // to allow multiplicity treatment - private: - // Energy - vector<UShort_t> fPyramid_E_DetectorNbr; - vector<Double_t> fPyramid_Energy; +class TPyramidData : public TNamed { + private: + // Pyramid + vector<unsigned short> fPyramid_FrontUpstreamE_DetectorNbr; + vector<unsigned short> fPyramid_FrontUpstreamE_StripNbr; + vector<double> fPyramid_FrontUpstreamE_Energy; - // Time - vector<UShort_t> fPyramid_T_DetectorNbr; - vector<Double_t> fPyramid_Time; + vector<unsigned short> fPyramid_FrontUpstreamT_DetectorNbr; + vector<unsigned short> fPyramid_FrontUpstreamT_StripNbr; + vector<double> fPyramid_FrontUpstreamT_Time; + vector<unsigned short> fPyramid_FrontDownstreamE_DetectorNbr; + vector<unsigned short> fPyramid_FrontDownstreamE_StripNbr; + vector<double> fPyramid_FrontDownstreamE_Energy; - ////////////////////////////////////////////////////////////// - // Constructor and destructor - public: - TPyramidData(); - ~TPyramidData(); - + vector<unsigned short> fPyramid_FrontDownstreamT_DetectorNbr; + vector<unsigned short> fPyramid_FrontDownstreamT_StripNbr; + vector<double> fPyramid_FrontDownstreamT_Time; + + vector<unsigned short> fPyramid_BackE_DetectorNbr; + vector<double> fPyramid_BackE_Energy; + + vector<unsigned short> fPyramid_BackT_DetectorNbr; + vector<double> fPyramid_BackT_Time; + + vector<unsigned short> fPyramid_OuterE_DetectorNbr; + vector<unsigned short> fPyramid_OuterE_StripNbr; + vector<double> fPyramid_OuterE_Energy; + + vector<unsigned short> fPyramid_OuterT_DetectorNbr; + vector<unsigned short> fPyramid_OuterT_StripNbr; + vector<double> fPyramid_OuterT_Time; - ////////////////////////////////////////////////////////////// - // Inherited from TObject and overriden to avoid warnings public: + TPyramidData(); + virtual ~TPyramidData(); + void Clear(); void Clear(const Option_t*) {}; void Dump() const; + ////////////////// MULTIPLICITY GETTER ///////////////////// + // E + inline unsigned int GetFrontUpstreamEMult(){ + return fPyramid_FrontUpstreamE_DetectorNbr.size(); + }//! - ////////////////////////////////////////////////////////////// - // Getters and Setters - // Prefer inline declaration to avoid unnecessary called of - // frequently used methods - // add //! to avoid ROOT creating dictionnary for the methods - public: - ////////////////////// SETTERS //////////////////////// - // Energy - inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){ - fPyramid_E_DetectorNbr.push_back(DetNbr); - fPyramid_Energy.push_back(Energy); - };//! - - // Time - inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) { - fPyramid_T_DetectorNbr.push_back(DetNbr); - fPyramid_Time.push_back(Time); - };//! - - - ////////////////////// GETTERS //////////////////////// - // Energy - inline UShort_t GetMultEnergy() const - {return fPyramid_E_DetectorNbr.size();} - inline UShort_t GetE_DetectorNbr(const unsigned int &i) const - {return fPyramid_E_DetectorNbr[i];}//! - inline Double_t Get_Energy(const unsigned int &i) const - {return fPyramid_Energy[i];}//! - - // Time - inline UShort_t GetMultTime() const - {return fPyramid_T_DetectorNbr.size();} - inline UShort_t GetT_DetectorNbr(const unsigned int &i) const - {return fPyramid_T_DetectorNbr[i];}//! - inline Double_t Get_Time(const unsigned int &i) const - {return fPyramid_Time[i];}//! - - - ////////////////////////////////////////////////////////////// - // Required for ROOT dictionnary - ClassDef(TPyramidData,1) // PyramidData structure + // T + inline unsigned int GetFrontUpstreamTMult(){ + return fPyramid_FrontUpstreamT_DetectorNbr.size(); + }//! + + ///////////////////// + // E + inline unsigned int GetFrontDownstreamEMult(){ + return fPyramid_FrontDownstreamE_DetectorNbr.size(); + }//! + + // T + inline unsigned int GetFrontDownstreamTMult(){ + return fPyramid_FrontDownstreamT_DetectorNbr.size(); + }//! + + ///////////////////// + // E + inline unsigned int GetBackEMult(){ + return fPyramid_BackE_DetectorNbr.size(); + }//! + + // T + inline unsigned int GetBackTMult(){ + return fPyramid_BackT_DetectorNbr.size(); + }//! + + ///////////////////// + // E + inline unsigned int GetOuterEMult(){ + return fPyramid_OuterE_DetectorNbr.size(); + }//! + + // T + inline unsigned int GetOuterTMult(){ + return fPyramid_OuterT_DetectorNbr.size(); + }//! + + ///////////////////// FAST SETTERS //////////////////////// + // E + inline void SetFrontUpstreamE(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + SetFrontUpstreamEDetectorNbr(DetNbr); + SetFrontUpstreamEStripNbr(StripNbr); + SetFrontUpstreamEEnergy(Energy); + }//! + + // T + inline void SetFrontUpstreamT(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Time){ + SetFrontUpstreamTDetectorNbr(DetNbr); + SetFrontUpstreamTStripNbr(StripNbr); + SetFrontUpstreamTTime(Time); + }//! + + ///////////////////// + // E + inline void SetFrontDownstreamE( const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + SetFrontDownstreamEDetectorNbr(DetNbr); + SetFrontDownstreamEStripNbr(StripNbr); + SetFrontDownstreamEEnergy(Energy); + }//! + + // T + inline void SetFrontDownstreamT( const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Time){ + SetFrontDownstreamTDetectorNbr(DetNbr); + SetFrontDownstreamTStripNbr(StripNbr); + SetFrontDownstreamTTime(Time); + }//! + + ///////////////////// + // E + inline void SetBackE( const unsigned short& DetNbr , const double& Energy){ + SetBackEDetectorNbr(DetNbr); + SetBackEEnergy(Energy); + }//! + + // T + inline void SetBackT( const unsigned short& DetNbr , const double& Time){ + SetBackTDetectorNbr(DetNbr); + SetBackTTime(Time); + }//! + + ///////////////////// + // E + inline void SetOuterE( const unsigned short& DetNbr , const unsigned short StripNbr, const double& Energy){ + SetOuterEDetectorNbr(DetNbr); + SetOuterEStripNbr(StripNbr); + SetOuterEEnergy(Energy); + }//! + + // T + inline void SetOuterT( const unsigned short& DetNbr , const unsigned short StripNbr , const double& Time){ + SetOuterTDetectorNbr(DetNbr); + SetOuterTStripNbr(StripNbr); + SetOuterTTime(Time); + }//! + + + + ////////////////////// SETTERS And GETTERS ///////////////////////// + inline void SetFrontUpstreamEDetectorNbr(const unsigned short& FrontUpstreamE_DetectorNbr) + {fPyramid_FrontUpstreamE_DetectorNbr.push_back(FrontUpstreamE_DetectorNbr);}//! + inline unsigned short GetFrontUpstreamEDetectorNbr(const unsigned int& i) + {return fPyramid_FrontUpstreamE_DetectorNbr[i];}//! + + inline void SetFrontUpstreamEStripNbr(const unsigned short& FrontUpstreamE_StripNbr) + {fPyramid_FrontUpstreamE_StripNbr.push_back(FrontUpstreamE_StripNbr);}//! + inline unsigned short GetFrontUpstreamEStripNbr(const unsigned int& i) + {return fPyramid_FrontUpstreamE_StripNbr[i];}//! + + inline void SetFrontUpstreamEEnergy(const double& FrontUpstreamE_Energy) + {fPyramid_FrontUpstreamE_Energy.push_back(FrontUpstreamE_Energy);}//! + inline double GetFrontUpstreamEEnergy(const unsigned int& i) + {return fPyramid_FrontUpstreamE_Energy[i];}//! + + inline void SetFrontUpstreamTDetectorNbr(const unsigned short& FrontUpstreamT_DetectorNbr) + {fPyramid_FrontUpstreamT_DetectorNbr.push_back(FrontUpstreamT_DetectorNbr);}//! + inline unsigned short GetFrontUpstreamTDetectorNbr(const unsigned int& i) + {return fPyramid_FrontUpstreamT_DetectorNbr[i];}//! + + inline void SetFrontUpstreamTStripNbr(const unsigned short& FrontUpstreamT_StripNbr) + {fPyramid_FrontUpstreamT_StripNbr.push_back(FrontUpstreamT_StripNbr);}//! + inline unsigned short GetFrontUpstreamTStripNbr(const unsigned int& i) + {return fPyramid_FrontUpstreamT_StripNbr[i];}//! + + inline void SetFrontUpstreamTTime(const double& FrontUpstreamT_Time) + {fPyramid_FrontUpstreamT_Time.push_back(FrontUpstreamT_Time);}//! + inline double GetFrontUpstreamTTime(const unsigned int& i) + {return fPyramid_FrontUpstreamT_Time[i];}//! + + inline void SetFrontDownstreamEDetectorNbr(const unsigned short& FrontDownstreamE_DetectorNbr) + {fPyramid_FrontDownstreamE_DetectorNbr.push_back(FrontDownstreamE_DetectorNbr);}//! + inline unsigned short GetFrontDownstreamEDetectorNbr(const unsigned int& i) + {return fPyramid_FrontDownstreamE_DetectorNbr[i];}//! + + inline void SetFrontDownstreamEStripNbr(const unsigned short& FrontDownstreamE_StripNbr) + {fPyramid_FrontDownstreamE_StripNbr.push_back(FrontDownstreamE_StripNbr);}//! + inline unsigned short GetFrontDownstreamEStripNbr(const unsigned int& i) + {return fPyramid_FrontDownstreamE_StripNbr[i];}//! + + inline void SetFrontDownstreamEEnergy(const double& FrontDownstreamE_Energy) + {fPyramid_FrontDownstreamE_Energy.push_back(FrontDownstreamE_Energy);}//! + inline double GetFrontDownstreamEEnergy(const unsigned int& i) + {return fPyramid_FrontDownstreamE_Energy[i];}//! + + inline void SetFrontDownstreamTDetectorNbr(const unsigned short& FrontDownstreamT_DetectorNbr) + {fPyramid_FrontDownstreamT_DetectorNbr.push_back(FrontDownstreamT_DetectorNbr);}//! + inline unsigned short GetFrontDownstreamTDetectorNbr(const unsigned int& i) + {return fPyramid_FrontDownstreamT_DetectorNbr[i];}//! + + inline void SetFrontDownstreamTStripNbr(const unsigned short& FrontDownstreamT_StripNbr) + {fPyramid_FrontDownstreamT_StripNbr.push_back(FrontDownstreamT_StripNbr);}//! + inline unsigned short GetFrontDownstreamTStripNbr(const unsigned int& i) + {return fPyramid_FrontDownstreamT_StripNbr[i];}//! + + inline void SetFrontDownstreamTTime(const double& FrontDownstreamT_Time) + {fPyramid_FrontDownstreamT_Time.push_back(FrontDownstreamT_Time);}//! + inline double GetFrontDownstreamTTime(const unsigned int& i) + {return fPyramid_FrontDownstreamT_Time[i];}//! + + inline void SetBackEDetectorNbr(const unsigned short& BackE_DetectorNbr) + {fPyramid_BackE_DetectorNbr.push_back(BackE_DetectorNbr);}//! + inline unsigned short GetBackEDetectorNbr(const unsigned int& i) + {return fPyramid_BackE_DetectorNbr[i];}//! + + inline void SetBackEEnergy(const double& BackE_Energy) + {fPyramid_BackE_Energy.push_back(BackE_Energy);}//! + inline double GetBackEEnergy(const unsigned int& i) + {return fPyramid_BackE_Energy[i];}//! + + inline void SetBackTDetectorNbr(const unsigned short& BackT_DetectorNbr) + {fPyramid_BackT_DetectorNbr.push_back(BackT_DetectorNbr);}//! + inline unsigned short GetBackTDetectorNbr(const unsigned int& i) + {return fPyramid_BackT_DetectorNbr[i];}//! + + inline void SetBackTTime(const double& BackT_Time) + {fPyramid_BackT_Time.push_back(BackT_Time);}//! + inline double GetBackTTime(const unsigned int& i) + {return fPyramid_BackT_Time[i];}//! + + inline void SetOuterEDetectorNbr(const unsigned short& OuterE_DetectorNbr) + {fPyramid_OuterE_DetectorNbr.push_back(OuterE_DetectorNbr);}//! + inline unsigned short GetOuterEDetectorNbr(const unsigned int& i) + {return fPyramid_OuterE_DetectorNbr[i];}//! + + inline void SetOuterEStripNbr(const unsigned short& OuterE_StripNbr) + {fPyramid_OuterE_StripNbr.push_back(OuterE_StripNbr);}//! + inline unsigned short GetOuterEStripNbr(const unsigned int& i) + {return fPyramid_OuterE_StripNbr[i];}//! + + inline void SetOuterEEnergy(const double& OuterE_Energy) + {fPyramid_OuterE_Energy.push_back(OuterE_Energy);}//! + inline double GetOuterEEnergy(const unsigned int& i) + {return fPyramid_OuterE_Energy[i];}//! + + + inline void SetOuterTDetectorNbr(const unsigned short& OuterT_DetectorNbr) + {fPyramid_OuterT_DetectorNbr.push_back(OuterT_DetectorNbr);}//! + inline unsigned short GetOuterTDetectorNbr(const unsigned int& i) + {return fPyramid_OuterT_DetectorNbr[i];}//! + + inline void SetOuterTStripNbr(const unsigned short& OuterT_StripNbr) + {fPyramid_OuterT_StripNbr.push_back(OuterT_StripNbr);}//! + inline unsigned short GetOuterTStripNbr(const unsigned int& i) + {return fPyramid_OuterT_StripNbr[i];}//! + + inline void SetOuterTTime(const double& OuterT_Time) + {fPyramid_OuterT_Time.push_back(OuterT_Time);}//! + inline double GetOuterTTime(const unsigned int& i) + {return fPyramid_OuterT_Time[i];}//! + + + ClassDef(TPyramidData,1) // PyramidData structure }; #endif diff --git a/NPLib/Detectors/Pyramid/TPyramidPhysics.cxx b/NPLib/Detectors/Pyramid/TPyramidPhysics.cxx index 483c3834c..e8fece80a 100644 --- a/NPLib/Detectors/Pyramid/TPyramidPhysics.cxx +++ b/NPLib/Detectors/Pyramid/TPyramidPhysics.cxx @@ -21,312 +21,575 @@ *****************************************************************************/ #include "TPyramidPhysics.h" - +using namespace Pyramid_LOCAL; // STL #include <sstream> #include <iostream> #include <cmath> #include <stdlib.h> #include <limits> -using namespace std; // NPL #include "RootInput.h" #include "RootOutput.h" -#include "NPDetectorFactory.h" +#include "TAsciiFile.h" #include "NPOptionManager.h" +#include "NPDetectorFactory.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif // ROOT #include "TChain.h" +#include "TRandom3.h" -ClassImp(TPyramidPhysics) - - +TRandom *Random = new TRandom3(); /////////////////////////////////////////////////////////////////////////// -TPyramidPhysics::TPyramidPhysics() - : m_EventData(new TPyramidData), - m_PreTreatedData(new TPyramidData), - m_EventPhysics(this), - m_Spectra(0), - m_E_RAW_Threshold(0), // adc channels - m_E_Threshold(0), // MeV - m_NumberOfDetectors(0) { -} -/////////////////////////////////////////////////////////////////////////// -/// A usefull method to bundle all operation to add a detector -void TPyramidPhysics::AddDetector(TVector3 , string ){ - // In That simple case nothing is done - // Typically for more complex detector one would calculate the relevant - // positions (stripped silicon) or angles (gamma array) - m_NumberOfDetectors++; -} +ClassImp(TPyramidPhysics) + /////////////////////////////////////////////////////////////////////////// + TPyramidPhysics::TPyramidPhysics(){ + EventMultiplicity = 0 ; + m_EventData = new TPyramidData ; + m_PreTreatedData = new TPyramidData ; + m_PreTreatedMSData = new TPyramidData ; + m_EventPhysics = this ; + m_NumberOfDetector = 0 ; + + m_Take_E_Strip= true; + m_Take_T_Back=true; + m_Strip_E_Threshold = 300*keV; + m_Back_E_Threshold = 10*keV; + m_Maximum_FrontBack_Difference = 30*keV; + m_OuterBack_E_Threshold = 50*keV; + m_Spectra = NULL ; + } /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::AddDetector(double R, double Theta, double Phi, string shape){ - // Compute the TVector3 corresponding - TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - // Call the cartesian method - AddDetector(Pos,shape); -} - -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::BuildSimplePhysicalEvent() { +void TPyramidPhysics::BuildSimplePhysicalEvent(){ BuildPhysicalEvent(); } +/////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::BuildPhysicalEvent(){ + PreTreat(); // At this stage all vectors are fo same size, & each event share the same detector/strip + + unsigned int sizeU = m_PreTreatedData->GetFrontUpstreamEMult(); + unsigned int sizeO = m_PreTreatedData->GetOuterEMult(); + EventMultiplicity = sizeU; + + //m_PreTreatedData->Dump(); + static string name; // token + + for(unsigned int i = 0 ; i < sizeU ; i++){ + // detector and strip + int det = m_PreTreatedData->GetFrontUpstreamEDetectorNbr(i); + int strip = m_PreTreatedData->GetFrontUpstreamEStripNbr(i) ; + // calibrated energy + double EU = m_PreTreatedData->GetFrontUpstreamEEnergy(i) ; + double ED = m_PreTreatedData->GetFrontDownstreamEEnergy(i); + // matchsticked energy for position calibration + double msU = m_PreTreatedMSData->GetFrontUpstreamEEnergy(i) ; + double msD = m_PreTreatedMSData->GetFrontDownstreamEEnergy(i); + + double RowPos = (msU-msD)/(msU+msD); + name = "PYRAMID/D"; + name+=NPL::itoa(det); + name+="_STRIP"; + name+=NPL::itoa(strip); + name+="_POS"; + double Pos = CalibrationManager::getInstance()->ApplyResistivePositionCalibration(name,RowPos); // returns ((RowPos-d)/k) + + //Fix Balistic deficit + // calibration is applied as: (U+D)*( 1 + BD*(pow(k,2)-pow(pos-d,2)) ), + // While BD > 0 and |k| >= |pos-d| for good events + // Get resistive shift and length, this will fix asymetries + double d = CalibrationManager::getInstance()->GetValue(name,0); // resistive strip length shift + double k = CalibrationManager::getInstance()->GetValue(name,1); // resistive strip half-length + name ="PYRAMID/D"; + name+=NPL::itoa(det); + name+="_STRIP"; + name+=NPL::itoa(strip); + name+="_BALLISTIC"; + double BD_x_k2 =CalibrationManager::getInstance()->ApplyCalibration(name, k ); + double BD_x_Pos2 =CalibrationManager::getInstance()->ApplyCalibration(name, (RowPos-d) ); + double BD = (BD_x_k2 - BD_x_Pos2); + + // Fill the members + Detector_N.push_back(det); + Strip_N.push_back(strip); + Strip_Pos.push_back(Pos); // position expressed in [-1;+1] + UpStream_E.push_back(EU); + DownStream_E.push_back(ED); + Strip_E.push_back( (EU+ED) * (1+BD) ); + //cout << det << " " << strip << " " << Pos << " " << RowPos << " " + // << EU << " " << ED << " " << " " << EU+ED << endl ; + //cin.get(); + } + + //Outer + for(unsigned int i = 0 ; i < sizeO ; i++){ + // detector and strip + int det = m_PreTreatedData->GetOuterEDetectorNbr(i); + int strip = m_PreTreatedData->GetOuterEStripNbr(i) ; + double EO = m_PreTreatedData->GetOuterEEnergy(i); + Outer_Detector_N.push_back(det); + Outer_Strip_N.push_back(strip); + Outer_Strip_E.push_back(EO); + } - +} /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::BuildPhysicalEvent() { - // apply thresholds and calibration - PreTreat(); - - // match energy and time together - unsigned int mysizeE = m_PreTreatedData->GetMultEnergy(); - unsigned int mysizeT = m_PreTreatedData->GetMultTime(); - for (UShort_t e = 0; e < mysizeE ; e++) { - for (UShort_t t = 0; t < mysizeT ; t++) { - if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) { - DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e)); - Energy.push_back(m_PreTreatedData->Get_Energy(e)); - Time.push_back(m_PreTreatedData->Get_Time(t)); - } +void TPyramidPhysics::PreTreat(){ + ClearPreTreatedData(); + // Gain Calibration + // The cal function first call the MatchStick one + unsigned int sizeU = m_EventData->GetFrontUpstreamEMult(); + unsigned int sizeD = m_EventData->GetFrontDownstreamEMult(); + unsigned int sizeB = m_EventData->GetBackEMult(); + unsigned int sizeO = m_EventData->GetOuterEMult(); + + for(unsigned int i = 0 ; i < sizeU ; i++){ + double EU = Cal_Strip_Upstream_E(i) ; + int det = m_EventData->GetFrontUpstreamEDetectorNbr(i); + int strip = m_EventData->GetFrontUpstreamEStripNbr(i); + int key = det*10+strip; // key of the map + if(EU > 0) { // threshold on energy is applied below + m_mapU[key].push_back(EU); + m_mapMSU[key].push_back(Match_Strip_Upstream_E(i)); } } -} -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::PreTreat() { - // This method typically applies thresholds and calibrations - // Might test for disabled channels for more complex detector + for(unsigned int i = 0 ; i < sizeD ; i++){ + double ED = Cal_Strip_Downstream_E(i) ; + int det = m_EventData->GetFrontDownstreamEDetectorNbr(i); + int strip = m_EventData->GetFrontDownstreamEStripNbr(i); + int key = det*10+strip; // key of the map strip ={1,2,3,4} + if(ED > 0 ) { // threshold on energy is applied below + m_mapD[key].push_back(ED); + m_mapMSD[key].push_back(Match_Strip_Downstream_E(i)); + } + } - // clear pre-treated object - ClearPreTreatedData(); + for(unsigned int i = 0 ; i < sizeB ; i++){ + double EB = Cal_Back_E(i) ; + int det = m_EventData->GetBackEDetectorNbr(i); + int key = det; // key of the map + if(EB > m_Back_E_Threshold) m_mapB[key].push_back(EB); + } - // instantiate CalibrationManager - static CalibrationManager* Cal = CalibrationManager::getInstance(); + for(unsigned int i = 0 ; i < sizeO ; i++){ + double EO = m_EventData->GetOuterEEnergy(i); + int det = m_EventData->GetOuterEDetectorNbr(i); + int strip = m_EventData->GetOuterEStripNbr(i); + int key = det*10+strip; // key of the map OuterStrip={1,2,3,4} => key + if(EO > m_OuterBack_E_Threshold) m_mapO[key].push_back(EO); + } - // Energy - unsigned int mysize = m_EventData->GetMultEnergy(); - for (UShort_t i = 0; i < mysize ; ++i) { - if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) { - Double_t Energy = Cal->ApplyCalibration("Pyramid/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); - if (Energy > m_E_Threshold) { - m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy); - } +//Apply selection and matching + //NOTE about Matching + // Applying a strong strip-matching condition between the inner and outer might not be adequate + // in the case of a large beam spot, since some particles at specific angles can fire an Inner-strip (n) + // and an Outer-strip (n+/-1). The strip-matching can be addressed in the user Analysis.cxx + +double EU, ED, EUms, EDms, EB, EO ; +map<int,vector <double> >::iterator it; + +for (it= m_mapU.begin(); it!=m_mapU.end(); ++it){ + // Define the detector and strip + int key = it->first ; + int strip = (key)%10; + int det = (key)/10; + EU=ED=EUms=EDms=0; + // skip any event where U and D are not present simultaneously + if (m_mapU[key].size()==1 && m_mapD[key].size()==1){ + if( (m_mapU[key][0]+m_mapD[key][0])> m_Strip_E_Threshold ){ // U+D greater than threshold + EU = m_mapU[key][0]; + ED = m_mapD[key][0]; + EUms = m_mapMSU[key][0]; + EDms = m_mapMSD[key][0]; + m_PreTreatedData->SetFrontUpstreamE(det,strip,EU); + m_PreTreatedData->SetFrontDownstreamE(det,strip,ED); + m_PreTreatedMSData->SetFrontUpstreamE(det,strip,EUms); + m_PreTreatedMSData->SetFrontDownstreamE(det,strip,EDms); } } +} - // Time - mysize = m_EventData->GetMultTime(); - for (UShort_t i = 0; i < mysize; ++i) { - Double_t Time= Cal->ApplyCalibration("Pyramid/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); - m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time); +for (it= m_mapB.begin(); it!=m_mapB.end(); ++it){ + EB=0 ; + int det = it->first; + if (m_mapB[det].size()==1){ + EB = m_mapB[det][0]; + m_PreTreatedData->SetBackE(det,EB); } } +for (it= m_mapO.begin(); it!=m_mapO.end(); ++it){ + EO=0; + int key = it->first ; + int strip = (key)%10; + int det = (key)/10; + if (m_mapO[key].size()==1){ + EO = m_mapO[key][0]; + m_PreTreatedData->SetOuterE(det,strip,EO); + } +} +}// end -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::ReadAnalysisConfig() { - bool ReadingStatus = false; +//////////////////////////////////////////////////////////////////////////// +bool TPyramidPhysics :: IsValidChannel(const string DetectorType, const int detector , const int channel){ - // path to file - string FileName = "./configs/ConfigPyramid.dat"; + if(DetectorType == "InnerStripUpstream") + return *(m_InnerStripUpstreamChannelStatus[detector-1].begin()+channel-1); - // open analysis config file - ifstream AnalysisConfigFile; - AnalysisConfigFile.open(FileName.c_str()); + if(DetectorType == "InnerStripDownstream") + return *(m_InnerStripDownstreamChannelStatus[detector-1].begin()+channel-1); - if (!AnalysisConfigFile.is_open()) { - cout << " No ConfigPyramid.dat found: Default parameter loaded for Analayis " << FileName << endl; - return; - } - cout << " Loading user parameter for Analysis from ConfigPyramid.dat " << endl; - - // Save it in a TAsciiFile - TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); - asciiConfig->AppendLine("%%% ConfigPyramid.dat %%%"); - asciiConfig->Append(FileName.c_str()); - asciiConfig->AppendLine(""); - // read analysis config file - string LineBuffer,DataBuffer,whatToDo; - while (!AnalysisConfigFile.eof()) { - // Pick-up next line - getline(AnalysisConfigFile, LineBuffer); - - // search for "header" - string name = "ConfigPyramid"; - if (LineBuffer.compare(0, name.length(), name) == 0) - ReadingStatus = true; - - // loop on tokens and data - while (ReadingStatus ) { - whatToDo=""; - AnalysisConfigFile >> whatToDo; - - // Search for comment symbol (%) - if (whatToDo.compare(0, 1, "%") == 0) { - AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); - } + else if(DetectorType == "OuterStrip") + return *(m_OuterStripChannelStatus[detector-1].begin()+channel-1); - else if (whatToDo=="E_RAW_THRESHOLD") { - AnalysisConfigFile >> DataBuffer; - m_E_RAW_Threshold = atof(DataBuffer.c_str()); - cout << whatToDo << " " << m_E_RAW_Threshold << endl; - } + if(DetectorType == "InnerBack") + return *(m_InnerBackChannelStatus[detector-1].begin()+channel-1); - else if (whatToDo=="E_THRESHOLD") { - AnalysisConfigFile >> DataBuffer; - m_E_Threshold = atof(DataBuffer.c_str()); - cout << whatToDo << " " << m_E_Threshold << endl; - } + else if(DetectorType == "OuterBack") + return *(m_OuterBackChannelStatus[detector-1].begin()+channel-1); - else { - ReadingStatus = false; - } - } - } + else return false; } - - /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::Clear() { - DetectorNumber.clear(); - Energy.clear(); - Time.clear(); +void TPyramidPhysics::ReadAnalysisConfig(){ } +/////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::Clear(){ + EventMultiplicity=0; + Outer_Detector_N.clear(); + Detector_N.clear(); + Strip_E.clear(); + Strip_T.clear(); + Strip_N.clear(); + Strip_Pos.clear(); + DownStream_E.clear(); + DownStream_T.clear(); + UpStream_E.clear(); + UpStream_T.clear(); + Back_E.clear(); + Back_T.clear(); + Outer_Strip_E.clear(); + Outer_Strip_T.clear(); + Outer_Strip_N.clear(); + Outer_Back_E.clear(); + Outer_Back_T.clear(); + m_mapU.clear(); + m_mapD.clear(); + m_mapMSU.clear(); // after matchstick + m_mapMSD.clear(); // after matchstick + m_mapB.clear(); + m_mapO.clear(); +} +/////////////////////////////////////////////////////////////////////////// +//// Innherited from VDetector Class //// /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::ReadConfiguration(NPL::InputParser parser) { +void TPyramidPhysics::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Pyramid"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> cart = {"POS","Shape"}; - vector<string> sphe = {"R","Theta","Phi","Shape"}; + vector<string> token = {"Inner","Outer","Z","ANGLE"}; for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Pyramid " << i+1 << endl; - - TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(Pos,Shape); - } - else if(blocks[i]->HasTokenList(sphe)){ + if(blocks[i]->HasTokenList(token)){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Pyramid " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - string Shape = blocks[i]->GetString("Shape"); - AddDetector(R,Theta,Phi,Shape); + m_boolInner.push_back(blocks[i]->GetInt("Inner")); + m_boolOuter.push_back(blocks[i]->GetInt("Outer")); + //m_boolChamber = blocks[i]->GetInt("Chamber"); + m_Z.push_back(blocks[i]->GetDouble("Z","mm")); + m_ANGLE.push_back(blocks[i]->GetDouble("ANGLE","deg")); } + else{ cout << "ERROR: check your input file formatting " << endl; exit(1); } } -} + blocks.clear(); + + InitializeStandardParameter(); + ReadAnalysisConfig(); +} /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::InitSpectra() { - m_Spectra = new TPyramidSpectra(m_NumberOfDetectors); +void TPyramidPhysics::InitSpectra(){ + m_Spectra = new TPyramidSpectra(m_NumberOfDetector); } - - /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::FillSpectra() { +void TPyramidPhysics::FillSpectra(){ m_Spectra -> FillRawSpectra(m_EventData); m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); m_Spectra -> FillPhysicsSpectra(m_EventPhysics); } - - - /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::CheckSpectra() { - m_Spectra->CheckSpectra(); +void TPyramidPhysics::CheckSpectra(){ + // To be done } - - - /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::ClearSpectra() { +void TPyramidPhysics::ClearSpectra(){ // To be done } - - - /////////////////////////////////////////////////////////////////////////// -map< string , TH1*> TPyramidPhysics::GetSpectra() { +map< string,TH1* > TPyramidPhysics::GetSpectra() { if(m_Spectra) return m_Spectra->GetMapHisto(); else{ - map< string , TH1*> empty; + map< string,TH1* > empty; return empty; } -} +} /////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::WriteSpectra() { - m_Spectra->WriteSpectra(); -} +void TPyramidPhysics::AddParameterToCalibrationManager(){ + + CalibrationManager* Cal = CalibrationManager::getInstance(); + // E and T + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + for( int j = 0 ; j < 4 ; ++j){ + Cal->AddParameter("Pyramid","B"+NPL::itoa(i+1)+"_UPSTREAM"+NPL::itoa(j+1)+"_E","Pyramid_B"+NPL::itoa(i+1)+"_UPSTREAM"+NPL::itoa(j+1)+"_E") ; + Cal->AddParameter("Pyramid","B"+NPL::itoa(i+1)+"_DOWNSTREAM"+NPL::itoa(j+1)+"_E","Pyramid_B"+NPL::itoa(i+1)+"_DOWNSTREAM"+NPL::itoa(j+1)+"_E") ; + Cal->AddParameter("Pyramid","B"+NPL::itoa(i+1)+"_UPSTREAM"+NPL::itoa(j+1)+"_MATCHSTICK","Pyramid_B"+NPL::itoa(i+1)+"_UPSTREAM"+NPL::itoa(j+1)+"_MATCHSTICK") ; + Cal->AddParameter("Pyramid","B"+NPL::itoa(i+1)+"_DOWNSTREAM"+NPL::itoa(j+1)+"_MATCHSTICK","Pyramid_B"+NPL::itoa(i+1)+"_DOWNSTREAM"+NPL::itoa(j+1)+"_MATCHSTICK") ; + Cal->AddParameter("Pyramid","B"+NPL::itoa(i+1)+"_STRIP"+NPL::itoa(j+1)+"_BALLISTIC","Pyramid_B"+NPL::itoa(i+1)+"_STRIP"+NPL::itoa(j+1)+"_BALLISTIC") ; + Cal->AddParameter("Pyramid","B"+NPL::itoa(i+1)+"_STRIP"+NPL::itoa(j+1)+"_POS","Pyramid_B"+NPL::itoa(i+1)+"_STRIP"+NPL::itoa(j+1)+"_POS") ; + } -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::AddParameterToCalibrationManager() { - CalibrationManager* Cal = CalibrationManager::getInstance(); - for (int i = 0; i < m_NumberOfDetectors; ++i) { - Cal->AddParameter("Pyramid", "D"+ NPL::itoa(i+1)+"_ENERGY","Pyramid_D"+ NPL::itoa(i+1)+"_ENERGY"); - Cal->AddParameter("Pyramid", "D"+ NPL::itoa(i+1)+"_TIME","Pyramid_D"+ NPL::itoa(i+1)+"_TIME"); + Cal->AddParameter("Pyramid","B" + NPL::itoa( i+1 ) + "_BACK_E","Pyramid_B" + NPL::itoa( i+1 ) + "_BACK_E"); } -} + return; +} +/////////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::InitializeRootInputRaw(){ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus( "Pyramid" , true ); +// inputChain->SetBranchStatus( "fPyramid_*" , true ); + inputChain->SetBranchAddress( "Pyramid" , &m_EventData ); +} -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::InitializeRootInputRaw() { +/////////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::InitializeRootInputPhysics(){ TChain* inputChain = RootInput::getInstance()->GetChain(); - inputChain->SetBranchStatus("Pyramid", true ); - inputChain->SetBranchAddress("Pyramid", &m_EventData ); + inputChain->SetBranchStatus("Pyramid" , true ); + inputChain->SetBranchStatus("EventMultiplicity",true); + inputChain->SetBranchStatus("Detector_N",true); + inputChain->SetBranchStatus("Outer_Detector_N",true); + inputChain->SetBranchStatus("Strip_E",true); + inputChain->SetBranchStatus("Strip_T",true); + inputChain->SetBranchStatus("Strip_N",true); + inputChain->SetBranchStatus("Strip_Pos",true); + inputChain->SetBranchStatus("DownStream_E",true); + inputChain->SetBranchStatus("DownStream_T",true); + inputChain->SetBranchStatus("UpStream_E",true); + inputChain->SetBranchStatus("UpStream_T",true); + inputChain->SetBranchStatus("Back_E",true); + inputChain->SetBranchStatus("Back_T",true); + inputChain->SetBranchStatus("Outer_Strip_E",true); + inputChain->SetBranchStatus("Outer_Strip_T",true); + inputChain->SetBranchStatus("Outer_Strip_N",true); + inputChain->SetBranchStatus("Outer_Back_E",true); + inputChain->SetBranchStatus("Outer_Back_T",true); + inputChain->SetBranchAddress("Pyramid" , &m_EventPhysics ); + } +/////////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::InitializeRootOutput(){ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch( "Pyramid" , "TPyramidPhysics" , &m_EventPhysics ); +} +///// Specific to PyramidArray //// +void TPyramidPhysics::AddDetector(double X,double Y,double Z){ + cout << "Adding Pyramid centered at : ("<<X<<";"<<Y<<";"<<Z<<")"<<endl; -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::InitializeRootInputPhysics() { - TChain* inputChain = RootInput::getInstance()->GetChain(); - inputChain->SetBranchAddress("Pyramid", &m_EventPhysics); + m_NumberOfDetector+=8; + + /* + double StripPitchSector = (Wedge_Phi_Max-Wedge_Phi_Min)/Wedge_Sector_NumberOfStrip ; + double StripPitchRing = (Wedge_R_Max-Wedge_R_Min)/Wedge_Ring_NumberOfStrip ; + + TVector3 Strip_1_1; + + m_NumberOfDetector++; + Strip_1_1=TVector3(0,0,Z); + + // Buffer object to fill Position Array + vector<double> lineX ; vector<double> lineY ; vector<double> lineZ ; + + vector< vector< double > > OneWedgeStripPositionX ; + vector< vector< double > > OneWedgeStripPositionY ; + vector< vector< double > > OneWedgeStripPositionZ ; + + TVector3 StripCenter = Strip_1_1; + for(int f = 0 ; f < Wedge_Ring_NumberOfStrip ; f++){ + lineX.clear() ; + lineY.clear() ; + lineZ.clear() ; + + for(int b = 0 ; b < Wedge_Sector_NumberOfStrip ; b++){ + StripCenter = Strip_1_1; + StripCenter.SetY(Wedge_R_Max-f*StripPitchRing); + StripCenter.SetZ(Z); + StripCenter.RotateZ(Phi+Wedge_Phi_Min+b*StripPitchSector); + lineX.push_back( StripCenter.X() ); + lineY.push_back( StripCenter.Y() ); + lineZ.push_back( StripCenter.Z() ); + } + OneWedgeStripPositionX.push_back(lineX); + OneWedgeStripPositionY.push_back(lineY); + OneWedgeStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back( OneWedgeStripPositionX ) ; + m_StripPositionY.push_back( OneWedgeStripPositionY ) ; + m_StripPositionZ.push_back( OneWedgeStripPositionZ ) ; + + return;*/ } +/////////////////////////////////////////////////////////////////////////////// +TVector3 TPyramidPhysics::GetDetectorNormal( const int i) const{ + return (TVector3(0,0,i)); +} +/////////////////////////////////////////////////////////////////////////////// +TVector3 TPyramidPhysics::GetPositionOfInteraction(const int i) const{ + // All in mm + double INNER_PCB_Width = 27.10; + double INNER_ActiveWafer_Length = 94.80; + double INNER_ActiveWafer_Width = 22.6; + double StripPitch = INNER_ActiveWafer_Width/8.0; + + //Calculate position locally as if it's detector 3 (at 12'oclock) that is hit + double X = (Strip_N[i]*StripPitch-0.5*INNER_ActiveWafer_Width)-(0.5*StripPitch); + double Y = INNER_PCB_Width*(0.5+sin(45*deg)); + double Z = Strip_Pos[i]*(0.5*INNER_ActiveWafer_Length); + TVector3 POS(X,Y,-Z); // since RowPos = (U-D)/(U+D) => Downstream hit (i.e. Z>0) has RowPos<0, thus the sign + POS.RotateZ((3-Detector_N[i])*45*deg);// looking downstream, Detector 1 is at 3 o'clock + return( POS ) ; +} +/////////////////////////////////////////////////////////////////////////////// +TVector3 TPyramidPhysics::GetRandomisedPositionOfInteraction(const int i) const{ + TVector3 RandomPOS = GetPositionOfInteraction(i); + TVector3 v1(-12.0, 27.10*(0.5+sin(45*deg)), 0.0); + TVector3 v2(12.0, 27.10*(0.5+sin(45*deg)), 0.0); + v1.RotateZ((3-Detector_N[i])*45*deg); + v2.RotateZ((3-Detector_N[i])*45*deg); + TVector3 u = (v2-v1).Unit(); + double RandomNumber = Random->Rndm(); + TVector3 DeltaHolder((RandomNumber*5.65)-(5.65/2.),(RandomNumber*5.65)-(5.65/2.),0.0); + TVector3 DeltaVector(u.X()*DeltaHolder.X(),u.Y()*DeltaHolder.Y(),u.Z()*DeltaHolder.Z()); + RandomPOS.SetXYZ(RandomPOS.X()+DeltaVector.X(),RandomPOS.Y()+DeltaVector.Y(),RandomPOS.Z()+DeltaVector.Z()); + return( RandomPOS ); +} +/////////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::InitializeStandardParameter(){ + /* // Enable all channel + vector< bool > ChannelStatus; + m_RingChannelStatus.clear() ; + m_SectorChannelStatus.clear() ; + + ChannelStatus.resize(16,true); + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + m_RingChannelStatus[i] = ChannelStatus; + } -/////////////////////////////////////////////////////////////////////////// -void TPyramidPhysics::InitializeRootOutput() { - TTree* outputTree = RootOutput::getInstance()->GetTree(); - outputTree->Branch("Pyramid", "TPyramidPhysics", &m_EventPhysics); + ChannelStatus.resize(8,true); + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + m_SectorChannelStatus[i] = ChannelStatus; + } + + m_MaximumStripMultiplicityAllowed = m_NumberOfDetector ; + */ + return; +} +/////////////////////////////////////////////////////////////////////////////// +double TPyramidPhysics::Cal_Strip_Upstream_E(const int i){ + static string name; name ="PYRAMID/D" ; + name+= NPL::itoa( m_EventData->GetFrontUpstreamEDetectorNbr(i) ) ; + name+= "_UPSTREAM" ; + name+= NPL::itoa( m_EventData->GetFrontUpstreamEStripNbr(i) ) ; + name+= "_E"; + double MSEnergy = Match_Strip_Upstream_E(i); + double CalEnergy = CalibrationManager::getInstance()->ApplyCalibration(name,MSEnergy); + return CalEnergy ; +} +/////////////////////////////////////////////////////////////////////////////// +double TPyramidPhysics::Cal_Strip_Downstream_E(const int i){ + static string name; name = "PYRAMID/D" ; + name+= NPL::itoa( m_EventData->GetFrontDownstreamEDetectorNbr(i) ) ; + name+= "_DOWNSTREAM" ; + name+= NPL::itoa( m_EventData->GetFrontDownstreamEStripNbr(i) ) ; + name+= "_E"; + double MSEnergy = Match_Strip_Downstream_E(i); + double CalEnergy = CalibrationManager::getInstance()->ApplyCalibration(name, MSEnergy); + return CalEnergy ; +} +/////////////////////////////////////////////////////////////////////////////// +double TPyramidPhysics::Match_Strip_Upstream_E(const int i){ + static string name; name = "PYRAMID/D" ; + name+= NPL::itoa( m_EventData->GetFrontUpstreamEDetectorNbr(i) ) ; + name+= "_UPSTREAM" ; + name+= NPL::itoa( m_EventData->GetFrontUpstreamEStripNbr(i) ) ; + name+= "_MATCHSTICK"; + double RawEnergy = m_EventData->GetFrontUpstreamEEnergy(i); + double MSEnergy = CalibrationManager::getInstance()->ApplyCalibration(name,RawEnergy); + return MSEnergy ; +} +/////////////////////////////////////////////////////////////////////////////// +double TPyramidPhysics::Match_Strip_Downstream_E(const int i){ + static string name; name ="PYRAMID/D" ; + name+= NPL::itoa( m_EventData->GetFrontDownstreamEDetectorNbr(i) ) ; + name+= "_DOWNSTREAM" ; + name+= NPL::itoa( m_EventData->GetFrontDownstreamEStripNbr(i) ) ; + name+= "_MATCHSTICK"; + double RawEnergy = m_EventData->GetFrontDownstreamEEnergy(i); + double MSEnergy = CalibrationManager::getInstance()->ApplyCalibration(name,RawEnergy); + return MSEnergy; +} +/////////////////////////////////////////////////////////////////////////////// +double TPyramidPhysics::Cal_Back_E(const int i){ + static string name; name = "PYRAMID/D" ; + name+= NPL::itoa( m_EventData->GetBackEDetectorNbr(i) ) ; + name+= "_BACK_E"; + return CalibrationManager::getInstance()->ApplyCalibration(name, m_EventData->GetBackEEnergy(i)); } +//////////////////////////////////////////////////////////////////////////// +void TPyramidPhysics::WriteSpectra(){ + m_Spectra->WriteSpectra(); +} //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPL::VDetector* TPyramidPhysics::Construct() { +NPL::VDetector* TPyramidPhysics::Construct(){ return (NPL::VDetector*) new TPyramidPhysics(); } - //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// diff --git a/NPLib/Detectors/Pyramid/TPyramidPhysics.h b/NPLib/Detectors/Pyramid/TPyramidPhysics.h index a30e0b061..bdf4eb467 100644 --- a/NPLib/Detectors/Pyramid/TPyramidPhysics.h +++ b/NPLib/Detectors/Pyramid/TPyramidPhysics.h @@ -1,180 +1,239 @@ #ifndef TPyramidPHYSICS_H #define TPyramidPHYSICS_H /***************************************************************************** - * Copyright (C) 2009-2018 this file is part of the NPTool Project * + * Copyright (C) 2009-2018 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: Mohamad Moukaddam contact address: mohamad.moukaddam@iphc.cnrs.fr * + * Original Author: Mohamad Moukaddam * + * contact address: mohamad.moukaddam@iphc.cnrs.fr * * * - * Creation Date : November 2018 * + * Creation Date : November 2018 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class hold Pyramid Treated data * + * This class hold Pyramid Treated data * * * *---------------------------------------------------------------------------* * Comment: * * * * * *****************************************************************************/ - -// C++ headers +// STL #include <vector> #include <map> #include <string> using namespace std; - -// ROOT headers -#include "TObject.h" -#include "TH1.h" -#include "TVector3.h" -// NPTool headers +// NPL #include "TPyramidData.h" #include "TPyramidSpectra.h" #include "NPCalibrationManager.h" #include "NPVDetector.h" #include "NPInputParser.h" -// forward declaration -class TPyramidSpectra; +// ROOT +#include "TVector2.h" +#include "TVector3.h" +#include "TObject.h" +#include "TH1.h" +class TPyramidSpectra; +using namespace std ; -class TPyramidPhysics : public TObject, public NPL::VDetector { - ////////////////////////////////////////////////////////////// - // constructor and destructor +class TPyramidPhysics : public TObject, public NPL::VDetector{ public: TPyramidPhysics(); ~TPyramidPhysics() {}; - - ////////////////////////////////////////////////////////////// - // Inherited from TObject and overriden to avoid warnings public: void Clear(); void Clear(const Option_t*) {}; - - ////////////////////////////////////////////////////////////// - // data obtained after BuildPhysicalEvent() and stored in - // output ROOT file - public: - vector<int> DetectorNumber; - vector<double> Energy; - vector<double> Time; - - /// A usefull method to bundle all operation to add a detector - void AddDetector(TVector3 POS, string shape); - void AddDetector(double R, double Theta, double Phi, string shape); - - ////////////////////////////////////////////////////////////// - // methods inherited from the VDetector ABC class public: - // read stream from ConfigFile to pick-up detector parameters - void ReadConfiguration(NPL::InputParser); - - // add parameters to the CalibrationManger - void AddParameterToCalibrationManager(); - - // method called event by event, aiming at extracting the - // physical information from detector - void BuildPhysicalEvent(); - - // same as BuildPhysicalEvent() method but with a simpler - // treatment - void BuildSimplePhysicalEvent(); - - // same as above but for online analysis + // Provide Physical Multiplicity + Int_t EventMultiplicity; + + // Detector + vector<int> Detector_N ; + vector<int> Outer_Detector_N ; + + // Inner + vector<double> Strip_E; + vector<double> Strip_T; + vector<int> Strip_N; + vector<double> Strip_Pos; + + // Control stuff + vector<double> DownStream_E; + vector<double> DownStream_T; + vector<double> UpStream_E; + vector<double> UpStream_T; + vector<double> Back_E; + vector<double> Back_T; + + // Outter + vector<double> Outer_Strip_E; + vector<double> Outer_Strip_T; + vector<double> Outer_Strip_N; + vector<double> Outer_Back_E; + vector<double> Outer_Back_T; + + double XCoord; + double YCoord; + double ZCoord; + + + public: // Innherited from VDetector Class + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(NPL::InputParser) ; + + // Add Parameter to the CalibrationManger + void AddParameterToCalibrationManager() ; + + // 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 InitializeRootInputRaw() ; + + // Activated associated Branches and link it to the private member DetectorPhysics address + // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated + void InitializeRootInputPhysics() ; + + // Create associated branches and associated private member DetectorPhysics address + void InitializeRootOutput() ; + + // 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 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() ; + + // Same as above but for online analysis void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; - // activate raw data object and branches from input TChain - // in this method mother branches (Detector) AND daughter leaves - // (fDetector_parameter) have to be activated - void InitializeRootInputRaw(); - - // activate physics data object and branches from input TChain - // in this method mother branches (Detector) AND daughter leaves - // (fDetector_parameter) have to be activated - void InitializeRootInputPhysics(); - - // create branches of output ROOT file - void InitializeRootOutput(); - - // clear the raw and physical data objects event by event + // Those two method all to clear the Event Physics or Data void ClearEventPhysics() {Clear();} void ClearEventData() {m_EventData->Clear();} - // methods related to the TPyramidSpectra class - // instantiate the TPyramidSpectra class and - // declare list of histograms + // Method related to the TSpectra classes, aimed at providing a framework + // for online applications + // Instantiate the Spectra class and the histogramm throught it void InitSpectra(); - - // fill the spectra + // Fill the spectra hold by the spectra class void FillSpectra(); - - // used for Online mainly, sanity check for histograms and - // change their color if issues are found, for example + // Used for Online mainly, perform check on the histo and for example change + // their color if issues are found void CheckSpectra(); - - // used for Online only, clear all the spectra + // Used for Online only, clear all the spectra hold by the Spectra class void ClearSpectra(); - - // write spectra to ROOT output file + // Write Spectra to file void WriteSpectra(); + public:// Specific to Pyramid Array + // Clear The PreTeated object + void ClearPreTreatedData() {m_PreTreatedData->Clear(); m_PreTreatedMSData->Clear();} - - ////////////////////////////////////////////////////////////// - // specific methods to Pyramid array - public: - // remove bad channels, calibrate the data and apply thresholds + // Remove bad channel, calibrate the data and apply threshold void PreTreat(); - // clear the pre-treated object - void ClearPreTreatedData() {m_PreTreatedData->Clear();} + // Return false if the channel is disabled by user + // Frist argument is either "X","Y","SiLi","CsI" + bool IsValidChannel(const string DetectorType, const int detector , const int channel); - // read the user configuration file. If no file is found, load standard one + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of detector + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one void ReadAnalysisConfig(); - // give and external TPyramidData object to TPyramidPhysics. - // needed for online analysis for example + // Add a Detector + void AddDetector( double X,double Y,double Z); + + // Give and external TMustData object to TPyramidPhysics. Needed for online analysis for example. void SetRawDataPointer(TPyramidData* rawDataPointer) {m_EventData = rawDataPointer;} - - // objects are not written in the TTree - private: - TPyramidData* m_EventData; //! - TPyramidData* m_PreTreatedData; //! - TPyramidPhysics* m_EventPhysics; //! - - // getters for raw and pre-treated data object - public: + // Retrieve raw and pre-treated data TPyramidData* GetRawData() const {return m_EventData;} TPyramidData* GetPreTreatedData() const {return m_PreTreatedData;} - // parameters used in the analysis - private: - // thresholds - double m_E_RAW_Threshold; //! - double m_E_Threshold; //! + double GetNumberOfDetector() const { return m_NumberOfDetector; }; + + // To be called after a build Physical Event + int GetEventMultiplicity() const { return EventMultiplicity; }; + + double GetXCoord() const { return XCoord; }; + double GetYCoord() const { return YCoord; }; + double GetZCoord() const { return ZCoord; }; + + TVector3 GetPositionOfInteraction(const int i) const; + TVector3 GetRandomisedPositionOfInteraction(const int i) const; + TVector3 GetDetectorNormal(const int i) const; + + private: // Parameter used in the analysis + // By default take EX and TY. + bool m_Take_E_Strip;//! + bool m_Take_T_Back;//! + + // Threshold + double m_Strip_E_Threshold ;//! + double m_Back_E_Threshold ;//! + double m_OuterBack_E_Threshold ;//! + double m_Maximum_FrontBack_Difference ;//! + private: // Root Input and Output tree classes + TPyramidData* m_EventData;//! + TPyramidData* m_PreTreatedData;//! + TPyramidData* m_PreTreatedMSData;//! stores the intermediate Matchsticks calibrated Data + TPyramidPhysics* m_EventPhysics;//! + map<int, vector <double> > m_mapU;//! the maps sorts out the data before storing in m_PreTreatedData + map<int, vector <double> > m_mapD;//! + map<int, vector <double> > m_mapB;//! + map<int, vector <double> > m_mapO;//! + map<int, vector <double> > m_mapMSU;//! + map<int, vector <double> > m_mapMSD;//! + + private: // Map of activated channel + map< int, vector<bool> > m_InnerStripUpstreamChannelStatus;//! + map< int, vector<bool> > m_InnerStripDownstreamChannelStatus;//! + map< int, vector<bool> > m_OuterStripChannelStatus;//! + map< int, vector<bool> > m_InnerBackChannelStatus;//! + map< int, vector<bool> > m_OuterBackChannelStatus;//! + + private: // Spatial Position of Strip Calculated on bases of detector position + int m_NumberOfDetector;//! + vector< vector<double> > m_StripPositionX;//! + vector< vector<double> > m_StripPositionY;//! + vector< vector<double> > m_StripPositionZ;//! - // number of detectors private: - int m_NumberOfDetectors; //! + bool m_boolChamber; + vector<bool> m_boolInner; + vector<bool> m_boolOuter; + vector<double> m_Z; // shift on the z-axis + vector<double> m_ANGLE; // angle of rotation around the downstream width - // spectra class - private: - TPyramidSpectra* m_Spectra; // ! + private: // Spectra + TPyramidSpectra* m_Spectra;//! - // spectra getter public: - map<string, TH1*> GetSpectra(); + map< string,TH1* > GetSpectra(); - // Static constructor to be passed to the Detector Factory - public: - static NPL::VDetector* Construct(); + private: // Usefull method + // Calibrate data + double Cal_Strip_Upstream_E(const int i); + double Cal_Strip_Downstream_E(const int i); + double Cal_Back_E(const int i); + double Match_Strip_Upstream_E(const int i); + double Match_Strip_Downstream_E(const int i); + + public: // Static constructor to be passed to the Detector Factory + static NPL::VDetector* Construct(); + ClassDef(TPyramidPhysics,1) // PyramidPhysics structure - ClassDef(TPyramidPhysics,1) // PyramidPhysics structure }; +namespace Pyramid_LOCAL{ + string itoa(unsigned int value); +} #endif diff --git a/NPLib/Detectors/Pyramid/TPyramidSpectra.cxx b/NPLib/Detectors/Pyramid/TPyramidSpectra.cxx index 436e7571e..11befab17 100644 --- a/NPLib/Detectors/Pyramid/TPyramidSpectra.cxx +++ b/NPLib/Detectors/Pyramid/TPyramidSpectra.cxx @@ -1,18 +1,19 @@ /***************************************************************************** - * Copyright (C) 2009-2018 this file is part of the NPTool Project * + * Copyright (C) 2009-2018 this file is part of the NPTool Project * * * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the list of contributors see $NPTOOL/Licence/Contributors * *****************************************************************************/ /***************************************************************************** - * Original Author: Mohamad Moukaddam contact address: mohamad.moukaddam@iphc.cnrs.fr * + * Original Author: Mohamad Moukaddam * + * contact address: mohamad.moukaddam@iphc.cnrs.fr * * * - * Creation Date : November 2018 * + * Creation Date : November 2018 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class hold Pyramid Spectra * + * This class hold Pyramid Spectra * * * *---------------------------------------------------------------------------* * Comment: * @@ -20,155 +21,296 @@ * * *****************************************************************************/ -// class header -#include "TPyramidSpectra.h" - // STL -#include <iostream> +#include <iostream> +#include <cstdlib> +#include <stdexcept> #include <string> using namespace std; -// NPTool header +// NPL +#include "TPyramidSpectra.h" #include "NPOptionManager.h" - +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif //////////////////////////////////////////////////////////////////////////////// -TPyramidSpectra::TPyramidSpectra() - : fNumberOfDetectors(0) { +TPyramidSpectra::TPyramidSpectra(){ SetName("Pyramid"); + fNumberOfDetector= 0; + fInnerStrip=4; + fOuterStrip=4; } - - //////////////////////////////////////////////////////////////////////////////// -TPyramidSpectra::TPyramidSpectra(unsigned int NumberOfDetectors) { +TPyramidSpectra::TPyramidSpectra(unsigned int NumberOfDetector){ if(NPOptionManager::getInstance()->GetVerboseLevel()>0) cout << "************************************************" << endl - << "TPyramidSpectra : Initalizing control spectra for " - << NumberOfDetectors << " Detectors" << endl + << "TPyramidSpectra : Initalising control spectra for " + << NumberOfDetector << " Detectors" << endl << "************************************************" << endl ; + SetName("Pyramid"); - fNumberOfDetectors = NumberOfDetectors; + fNumberOfDetector= NumberOfDetector; + fInnerStrip=4; + fOuterStrip=4; InitRawSpectra(); InitPreTreatedSpectra(); InitPhysicsSpectra(); } - - //////////////////////////////////////////////////////////////////////////////// -TPyramidSpectra::~TPyramidSpectra() { +TPyramidSpectra::~TPyramidSpectra(){ } - - //////////////////////////////////////////////////////////////////////////////// -void TPyramidSpectra::InitRawSpectra() { - static string name; - for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors - // Energy - name = "Pyramid"+NPL::itoa(i+1)+"_ENERGY_RAW"; - AddHisto1D(name, name, 4096, 0, 16384, "Pyramid/RAW"); - // Time - name = "Pyramid"+NPL::itoa(i+1)+"_TIME_RAW"; - AddHisto1D(name, name, 4096, 0, 16384, "Pyramid/RAW"); - } // end loop on number of detectors +void TPyramidSpectra::InitRawSpectra(){ + string name; + string BaseFamily = "Pyramid/RAW/"; + + //// HIT //// + // Inner + // Hit Up Stream + name = "INNER_US_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector*fInnerStrip, 1, fNumberOfDetector*fInnerStrip+1, BaseFamily+"HIT"); + //Hit Down Stream + name = "INNER_DS_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector*fInnerStrip, 1, fNumberOfDetector*fInnerStrip+1, BaseFamily+"HIT"); + // Hit Back + name = "INNER_BACK_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1, BaseFamily+"HIT"); + + // Outer + //Hit Strip + name = "OUTER_STRIP_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector*fOuterStrip, 1, fNumberOfDetector*fOuterStrip+1, BaseFamily+"HIT"); + + //// E //// + // Inner + // E Up Stream + name = "INNER_US_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector*fInnerStrip, 1, fNumberOfDetector*fInnerStrip+1, 512,0,16384,BaseFamily+"E"); + //E Down Stream + name = "INNER_DS_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector*fInnerStrip, 1, fNumberOfDetector*fInnerStrip+1,512,0,16384, BaseFamily+"E"); + //E Back + name = "INNER_BACK_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1,512,0,16384, BaseFamily+"E"); + + // Outer + //E Strip + name = "OUTER_STRIP_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector*fOuterStrip, 1, fNumberOfDetector*fOuterStrip+1,512,0,16384, BaseFamily+"E"); + + //// VS //// + // Inner + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerStrip;j++){ + name = "IB"+NPL::itoa(i+1)+"_VS"+NPL::itoa(j+1)+"_RAW"; + AddHisto2D(name, name,1024,0,0,1024,0,0,BaseFamily+"VS"); + } + } } - - //////////////////////////////////////////////////////////////////////////////// -void TPyramidSpectra::InitPreTreatedSpectra() { - static string name; - for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors - // Energy - name = "Pyramid"+NPL::itoa(i+1)+"_ENERGY_CAL"; - AddHisto1D(name, name, 500, 0, 25, "Pyramid/CAL"); - // Time - name = "Pyramid"+NPL::itoa(i+1)+"_TIME_CAL"; - AddHisto1D(name, name, 500, 0, 25, "Pyramid/CAL"); - - - } // end loop on number of detectors +void TPyramidSpectra::InitPreTreatedSpectra(){ + string BaseFamily = "Pyramid/CAL/"; + string name ; + //// VS //// + // Inner + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerStrip;j++){ + name = "IB"+NPL::itoa(i+1)+"_VS"+NPL::itoa(j+1)+"_CAL"; + AddHisto2D(name,name,2048,0,0,2048,0,0,BaseFamily+"VS"); + } + name = "IB"+NPL::itoa(i+1)+"_VS_BACK_CAL"; + AddHisto2D(name,name,2048,0,0,2048,0,0,BaseFamily+"VS"); + } } - - //////////////////////////////////////////////////////////////////////////////// -void TPyramidSpectra::InitPhysicsSpectra() { - static string name; - // Kinematic Plot - name = "Pyramid_ENERGY_TIME"; - AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "Pyramid/PHY"); -} - +void TPyramidSpectra::InitPhysicsSpectra(){ +string BaseFamily = "Pyramid/PHY"; +string name ; + //// E POS //// + // Inner + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerStrip;j++){ + name = "IB"+NPL::itoa(i+1)+"_EPOS"+NPL::itoa(j+1)+"_CAL"; + AddHisto2D(name, name,1000,-0.5,1.5,1000,0,30,BaseFamily); + } + } + //// E Theta //// + // Inner + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerStrip;j++){ + name = "IB"+NPL::itoa(i+1)+"_ETHETA"+NPL::itoa(j+1)+"_CAL"; + AddHisto2D(name, name,360,0,180,1000,0,30,BaseFamily); + } + } + //// E Theta //// + // Inner + name = "IB_ETHETA_CAL"; + AddHisto2D(name, name,360,0,180,1000,0,30,BaseFamily); +} //////////////////////////////////////////////////////////////////////////////// -void TPyramidSpectra::FillRawSpectra(TPyramidData* RawData) { - static string name; - static string family; +void TPyramidSpectra::FillRawSpectra(TPyramidData* RawData){ + string name; + string family; + string BaseFamily = "Pyramid/RAW/"; + + // INNER_US_HIT_RAW + for (unsigned int i = 0; i < RawData->GetFrontUpstreamEMult(); i++) { + name = "INNER_US_HIT_RAW"; + family = BaseFamily+"HIT"; + + FillSpectra(family,name + ,(RawData->GetFrontUpstreamEDetectorNbr(i)-1)*fInnerStrip + +RawData->GetFrontUpstreamEStripNbr(i)); + + family = BaseFamily+"E"; + name = "INNER_US_E_RAW"; + FillSpectra(family,name + ,(RawData->GetFrontUpstreamEDetectorNbr(i)-1)*fInnerStrip + +RawData->GetFrontUpstreamEStripNbr(i),RawData->GetFrontUpstreamEEnergy(i)); + } + // INNER_DS_HIT_RAW + for (unsigned int i = 0; i < RawData->GetFrontDownstreamEMult(); i++) { + name = "INNER_DS_HIT_RAW"; + family = BaseFamily+"HIT"; + + FillSpectra(family,name + ,(RawData->GetFrontDownstreamEDetectorNbr(i)-1)*fInnerStrip + +RawData->GetFrontDownstreamEStripNbr(i)); + + name = "INNER_DS_E_RAW"; + family = BaseFamily+"E"; + FillSpectra(family,name + ,(RawData->GetFrontDownstreamEDetectorNbr(i)-1)*fInnerStrip + +RawData->GetFrontDownstreamEStripNbr(i),RawData->GetFrontDownstreamEEnergy(i)); + } - // Energy - unsigned int sizeE = RawData->GetMultEnergy(); - for (unsigned int i = 0; i < sizeE; i++) { - name = "Pyramid"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; - family = "Pyramid/RAW"; + // INNER_BACK_HIT_RAW + for (unsigned int i = 0; i < RawData->GetBackEMult(); i++) { + name = "INNER_BACK_HIT_RAW"; + family = BaseFamily+"HIT"; - FillSpectra(family,name,RawData->Get_Energy(i)); - } + FillSpectra(family,name + ,(RawData->GetBackEDetectorNbr(i)-1)); - // Time - unsigned int sizeT = RawData->GetMultTime(); - for (unsigned int i = 0; i < sizeT; i++) { - name = "Pyramid"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; - family = "Pyramid/RAW"; + name = "INNER_BACK_E_RAW"; + family = BaseFamily+"E"; + FillSpectra(family,name + ,(RawData->GetBackEDetectorNbr(i)-1), RawData->GetBackEEnergy(i)); + } - FillSpectra(family,name,RawData->Get_Time(i)); + // OUTER_STRIP_HIT_RAW + for (unsigned int i = 0; i < RawData->GetOuterEMult(); i++) { + name = "OUTER_STRIP_HIT_RAW"; + family = BaseFamily+"HIT"; + + FillSpectra(family,name + ,(RawData->GetOuterEDetectorNbr(i)-1)*fInnerStrip + +RawData->GetOuterEStripNbr(i)); + + family = BaseFamily+"E"; + name = "OUTER_STRIP_E_RAW"; + FillSpectra(family,name + ,(RawData->GetOuterEDetectorNbr(i)-1)*fInnerStrip + +RawData->GetOuterEStripNbr(i),RawData->GetOuterEEnergy(i)); + } + + // INNER_VS_RAW + family = BaseFamily+"VS"; + for (unsigned int i = 0; i < RawData->GetFrontUpstreamEMult(); i++) { + int UpStreamDetNbr = RawData->GetFrontUpstreamEDetectorNbr(i); + int UpStreamStrNbr = RawData->GetFrontUpstreamEStripNbr(i); + + for (unsigned int j = 0; j < RawData->GetFrontDownstreamEMult(); j++) { + int DoStreamDetNbr = RawData->GetFrontDownstreamEDetectorNbr(j); + int DoStreamStrNbr = RawData->GetFrontDownstreamEStripNbr(j); + if(UpStreamDetNbr==DoStreamDetNbr && UpStreamStrNbr==DoStreamStrNbr){ + name = "IB"+NPL::itoa(UpStreamDetNbr)+"_VS"+NPL::itoa(UpStreamStrNbr)+"_RAW"; + FillSpectra(family,name + ,RawData->GetFrontUpstreamEEnergy(i),RawData->GetFrontDownstreamEEnergy(j)); + } + } } } - - //////////////////////////////////////////////////////////////////////////////// -void TPyramidSpectra::FillPreTreatedSpectra(TPyramidData* PreTreatedData) { - static string name; - static string family; +void TPyramidSpectra::FillPreTreatedSpectra(TPyramidData* PreTreatedData){ +string BaseFamily = "Pyramid/CAL/"; +// INNER_VS_CAL + string family = BaseFamily+"VS"; + string name ; + + unsigned int sizeU = PreTreatedData->GetFrontUpstreamEMult(); + unsigned int sizeD = PreTreatedData->GetFrontDownstreamEMult(); + unsigned int sizeB = PreTreatedData->GetBackEMult(); - // Energy - unsigned int sizeE = PreTreatedData->GetMultEnergy(); - for (unsigned int i = 0; i < sizeE; i++) { - name = "Pyramid"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; - family = "Pyramid/CAL"; - - FillSpectra(family,name,PreTreatedData->Get_Energy(i)); - } - - // Time - unsigned int sizeT = PreTreatedData->GetMultTime(); - for (unsigned int i = 0; i < sizeT; i++) { - name = "Pyramid"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; - family = "Pyramid/CAL"; - - FillSpectra(family,name,PreTreatedData->Get_Time(i)); + for (unsigned int i = 0; i < sizeU ; i++) { + int UpStreamDetNbr = PreTreatedData->GetFrontUpstreamEDetectorNbr(i); + int UpStreamStrNbr = PreTreatedData->GetFrontUpstreamEStripNbr(i); + + for (unsigned int j = 0; j < sizeD ; j++) { + int DoStreamDetNbr = PreTreatedData->GetFrontDownstreamEDetectorNbr(j); + int DoStreamStrNbr = PreTreatedData->GetFrontDownstreamEStripNbr(j); + if(UpStreamDetNbr==DoStreamDetNbr && UpStreamStrNbr==DoStreamStrNbr){ + name = "IB"+NPL::itoa(UpStreamDetNbr)+"_VS"+NPL::itoa(UpStreamStrNbr)+"_CAL"; + FillSpectra(family,name + ,PreTreatedData->GetFrontUpstreamEEnergy(i),PreTreatedData->GetFrontDownstreamEEnergy(j)); + + for (unsigned int k = 0; k < sizeB; k++) { + if(UpStreamDetNbr == PreTreatedData->GetBackEDetectorNbr(k)){ + name = "IB"+NPL::itoa(UpStreamDetNbr)+"_VS_BACK_CAL"; + FillSpectra(family,name + ,PreTreatedData->GetFrontUpstreamEEnergy(i) + +PreTreatedData->GetFrontDownstreamEEnergy(j), + PreTreatedData->GetBackEEnergy(k)); + } + } + } + } } } - - //////////////////////////////////////////////////////////////////////////////// -void TPyramidSpectra::FillPhysicsSpectra(TPyramidPhysics* Physics) { - static string name; - static string family; - family= "Pyramid/PHY"; - +void TPyramidSpectra::FillPhysicsSpectra(TPyramidPhysics* Physics){ + string family = "Pyramid/PHY"; + string name ; + //// E POS //// + // Inner + //unsigned int size = Physics->Strip_E.size(); + for(unsigned int i = 0 ; i < Physics->Strip_E.size() ; i++){ + name ="IB"+NPL::itoa(Physics->Detector_N[i])+"_EPOS"+NPL::itoa(Physics->Strip_N[i])+"_CAL"; + FillSpectra(family,name + ,Physics->Strip_Pos[i],Physics->Strip_E[i]); + + name = "IB"+NPL::itoa(Physics->Detector_N[i])+"_ETHETA"+NPL::itoa(Physics->Strip_N[i])+"_CAL"; + double Theta = Physics->GetPositionOfInteraction(i).Angle(TVector3(0,0,1)); + + FillSpectra(family,name + ,Theta*rad/deg,Physics->Strip_E[i]); + + name = "IB_ETHETA_CAL"; + FillSpectra(family,name + ,Theta*rad/deg,Physics->Strip_E[i]); + } + // Energy vs time - unsigned int sizeE = Physics->Energy.size(); + /*unsigned int sizeE = Physics->Energy.size(); for(unsigned int i = 0 ; i < sizeE ; i++){ name = "Pyramid_ENERGY_TIME"; FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); } + */ } diff --git a/NPLib/Detectors/Pyramid/TPyramidSpectra.h b/NPLib/Detectors/Pyramid/TPyramidSpectra.h index 7bc326611..c78fbf57f 100644 --- a/NPLib/Detectors/Pyramid/TPyramidSpectra.h +++ b/NPLib/Detectors/Pyramid/TPyramidSpectra.h @@ -27,36 +27,32 @@ #include "TPyramidData.h" #include "TPyramidPhysics.h" -// Forward Declaration -class TPyramidPhysics; +// ForwardDeclaration +class TPyramidPhysics ; - -class TPyramidSpectra : public VSpectra { - ////////////////////////////////////////////////////////////// - // constructor and destructor +class TPyramidSpectra: public VSpectra { public: + // constructor and destructor TPyramidSpectra(); - TPyramidSpectra(unsigned int NumberOfDetectors); + TPyramidSpectra(unsigned int NumberOfDetector); ~TPyramidSpectra(); - ////////////////////////////////////////////////////////////// - // Initialization methods private: + // Initialization methods void InitRawSpectra(); void InitPreTreatedSpectra(); void InitPhysicsSpectra(); - ////////////////////////////////////////////////////////////// - // Filling methods public: + // Filling methods void FillRawSpectra(TPyramidData*); void FillPreTreatedSpectra(TPyramidData*); void FillPhysicsSpectra(TPyramidPhysics*); - ////////////////////////////////////////////////////////////// - // Detector parameters - private: - unsigned int fNumberOfDetectors; + private: // Information + unsigned int fNumberOfDetector; + unsigned int fInnerStrip; + unsigned int fOuterStrip; }; #endif -- GitLab