diff --git a/NPLib/Detectors/AnnularCsI/TAnnularCsIData.cxx b/NPLib/Detectors/AnnularCsI/TAnnularCsIData.cxx index 8789f51a92bc5a63b0c260e0c3ce443ef2f80a59..2f141152c2ab9454b1d9763c542f89b772959238 100644 --- a/NPLib/Detectors/AnnularCsI/TAnnularCsIData.cxx +++ b/NPLib/Detectors/AnnularCsI/TAnnularCsIData.cxx @@ -32,6 +32,7 @@ ClassImp(TAnnularCsIData) ////////////////////////////////////////////////////////////////////// TAnnularCsIData::TAnnularCsIData() { + Clear(); } diff --git a/NPLib/Detectors/AnnularCsI/TAnnularCsIData.h b/NPLib/Detectors/AnnularCsI/TAnnularCsIData.h index f2ae5b8db93d0bc898e1ceee7e6ab43efec2456c..f47bf23f5404394435fcd69296d69ae96f8812ce 100644 --- a/NPLib/Detectors/AnnularCsI/TAnnularCsIData.h +++ b/NPLib/Detectors/AnnularCsI/TAnnularCsIData.h @@ -1,5 +1,5 @@ -#ifndef __AnnularCsIDATA__ -#define __AnnularCsIDATA__ +#ifndef AnnularCsIDATA_Include_Guard +#define AnnularCsIDATA_Include_Guard /***************************************************************************** * Copyright (C) 2009-2018 this file is part of the NPTool Project * * * diff --git a/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.cxx b/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.cxx index ecc1087ce11f5bce5f70a22ff786c9939e6e7d9b..40c297613cd67bfc5d7e4ce8f966b25807da9014 100644 --- a/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.cxx +++ b/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.cxx @@ -1,18 +1,18 @@ /***************************************************************************** - * 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: Greg Christian contact address: gchristian@tamu.edu * + * Original Author: Greg Christian contact address: gchristian@tamu.edu * * * - * Creation Date : March 2018 * + * Creation Date : March 2018 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class hold AnnularCsI Treated data * + * This class hold AnnularCsI Treated data * * * *---------------------------------------------------------------------------* * Comment: * @@ -23,6 +23,7 @@ #include "TAnnularCsIPhysics.h" // STL +#include <cassert> #include <sstream> #include <iostream> #include <cmath> @@ -49,51 +50,43 @@ TAnnularCsIPhysics::TAnnularCsIPhysics() m_EventPhysics(this), m_Spectra(0), m_E_RAW_Threshold(0), // adc channels - m_E_Threshold(0), // MeV - m_NumberOfDetectors(0) { + m_E_Threshold(0) // MeV +{ + ; } /////////////////////////////////////////////////////////////////////////// -/// A usefull method to bundle all operation to add a detector -void TAnnularCsIPhysics::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++; -} - -/////////////////////////////////////////////////////////////////////////// -void TAnnularCsIPhysics::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 TAnnularCsIPhysics::AddWedge(double R_min, double R_max, + double Phi_min, double Phi_max, + double Z) { + // Add wedge spanning R_min -> R_max and Phi_min -> Phi_max + double R = (R_max - R_min) / 2; + double Phi = ((Phi_min - Phi_max) / 2); + + m_WedgePosition.push_back( TVector3(R*cos(Phi), R*sin(Phi), Z) ); } +/////////////////////////////////////////////////////////////////////////// +TVector3 TAnnularCsIPhysics::GetPositionOfInteraction(int i) const { + return m_WedgePosition.at(DetectorNumber[i] - 1); +} + /////////////////////////////////////////////////////////////////////////// void TAnnularCsIPhysics::BuildSimplePhysicalEvent() { BuildPhysicalEvent(); } - - /////////////////////////////////////////////////////////////////////////// void TAnnularCsIPhysics::BuildPhysicalEvent() { // apply thresholds and calibration PreTreat(); - // match energy and time together + // loop over energies 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)); - } - } - } + DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e)); + Energy.push_back(m_PreTreatedData->Get_Energy(e)); + } } /////////////////////////////////////////////////////////////////////////// @@ -207,29 +200,24 @@ void TAnnularCsIPhysics::ReadConfiguration(NPL::InputParser parser) { if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> cart = {"POS","Shape"}; - vector<string> sphe = {"R","Theta","Phi","Shape"}; + vector<string> wedge = {"R_MIN", "R_MAX", "PHI_MIN","PHI_MAX", "Z"}; for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// AnnularCsI " << 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(NPOptionManager::getInstance()->GetVerboseLevel()) + if(blocks[i]->HasTokenList(wedge)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()){ cout << endl << "//// AnnularCsI " << 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); + } + double R_min = blocks[i]->GetDouble("R_MIN", "mm"); + double R_max = blocks[i]->GetDouble("R_MIN", "mm"); + double Phi_min = blocks[i]->GetDouble("PHI_MIN", "deg"); + double Phi_max = blocks[i]->GetDouble("PHI_MAX", "deg"); + double Z = blocks[i]->GetDouble("Z", "mm"); + + AddWedge(R_min,R_max,Phi_min,Phi_max,Z); } else{ - cout << "ERROR: check your input file formatting " << endl; + cout << "ERROR (TAnnularCsIPhysics.cxx): " + << "check your input file formatting " << endl; exit(1); } } @@ -237,7 +225,7 @@ void TAnnularCsIPhysics::ReadConfiguration(NPL::InputParser parser) { /////////////////////////////////////////////////////////////////////////// void TAnnularCsIPhysics::InitSpectra() { - m_Spectra = new TAnnularCsISpectra(m_NumberOfDetectors); + m_Spectra = new TAnnularCsISpectra(GetNumberOfDetectors()); } @@ -285,7 +273,7 @@ void TAnnularCsIPhysics::WriteSpectra() { /////////////////////////////////////////////////////////////////////////// void TAnnularCsIPhysics::AddParameterToCalibrationManager() { CalibrationManager* Cal = CalibrationManager::getInstance(); - for (int i = 0; i < m_NumberOfDetectors; ++i) { + for (int i = 0; i < GetNumberOfDetectors(); ++i) { Cal->AddParameter("AnnularCsI", "D"+ NPL::itoa(i+1)+"_ENERGY","AnnularCsI_D"+ NPL::itoa(i+1)+"_ENERGY"); Cal->AddParameter("AnnularCsI", "D"+ NPL::itoa(i+1)+"_TIME","AnnularCsI_D"+ NPL::itoa(i+1)+"_TIME"); } diff --git a/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.h b/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.h index bf46f41099c64092cd1f8db7df3d90c94cb39252..81400468b76ffd386e377b8797858e9167618075 100644 --- a/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.h +++ b/NPLib/Detectors/AnnularCsI/TAnnularCsIPhysics.h @@ -1,20 +1,20 @@ #ifndef TAnnularCsIPHYSICS_H #define TAnnularCsIPHYSICS_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: Greg Christian contact address: gchristian@tamu.edu * + * Original Author: Greg Christian contact address: gchristian@tamu.edu * * * - * Creation Date : March 2018 * + * Creation Date : March 2018 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class hold AnnularCsI Treated data * + * This class hold AnnularCsI Treated data * * * *---------------------------------------------------------------------------* * Comment: * @@ -26,7 +26,6 @@ #include <vector> #include <map> #include <string> -using namespace std; // ROOT headers #include "TObject.h" @@ -46,135 +45,145 @@ class TAnnularCsISpectra; class TAnnularCsIPhysics : public TObject, public NPL::VDetector { ////////////////////////////////////////////////////////////// // constructor and destructor - public: - TAnnularCsIPhysics(); - ~TAnnularCsIPhysics() {}; +public: + TAnnularCsIPhysics(); + ~TAnnularCsIPhysics() {}; ////////////////////////////////////////////////////////////// // Inherited from TObject and overriden to avoid warnings - public: - void Clear(); - void Clear(const Option_t*) {}; +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); - +public: + std::vector<int> DetectorNumber; + std::vector<double> Energy; + std::vector<double> Time; + + // Add A wedge + void AddWedge(double R_min, double R_max, + double Phi_min, double Phi_max, + double Z); + ////////////////////////////////////////////////////////////// // methods inherited from the VDetector ABC class - public: - // read stream from ConfigFile to pick-up detector parameters - void ReadConfiguration(NPL::InputParser); +public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); - // add parameters to the CalibrationManger - void AddParameterToCalibrationManager(); + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); - // method called event by event, aiming at extracting the - // physical information from detector - void BuildPhysicalEvent(); + // 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 BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); - // same as above but for online analysis - void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + // 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 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(); + // 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(); + // create branches of output ROOT file + void InitializeRootOutput(); - // clear the raw and physical data objects event by event - void ClearEventPhysics() {Clear();} - void ClearEventData() {m_EventData->Clear();} + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} - // methods related to the TAnnularCsISpectra class - // instantiate the TAnnularCsISpectra class and - // declare list of histograms - void InitSpectra(); + // methods related to the TAnnularCsISpectra class + // instantiate the TAnnularCsISpectra class and + // declare list of histograms + void InitSpectra(); - // fill the spectra - void FillSpectra(); + // fill the spectra + void FillSpectra(); - // used for Online mainly, sanity check for histograms and - // change their color if issues are found, for example - void CheckSpectra(); + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); - // used for Online only, clear all the spectra - void ClearSpectra(); + // used for Online only, clear all the spectra + void ClearSpectra(); - // write spectra to ROOT output file - void WriteSpectra(); + // write spectra to ROOT output file + void WriteSpectra(); ////////////////////////////////////////////////////////////// // specific methods to AnnularCsI array - public: - // remove bad channels, calibrate the data and apply thresholds - void PreTreat(); +public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); - // clear the pre-treated object - void ClearPreTreatedData() {m_PreTreatedData->Clear();} + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} - // read the user configuration file. If no file is found, load standard one - void ReadAnalysisConfig(); + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); - // give and external TAnnularCsIData object to TAnnularCsIPhysics. - // needed for online analysis for example - void SetRawDataPointer(TAnnularCsIData* rawDataPointer) {m_EventData = rawDataPointer;} + // give and external TAnnularCsIData object to TAnnularCsIPhysics. + // needed for online analysis for example + void SetRawDataPointer(TAnnularCsIData* rawDataPointer) {m_EventData = rawDataPointer;} // objects are not written in the TTree - private: - TAnnularCsIData* m_EventData; //! - TAnnularCsIData* m_PreTreatedData; //! - TAnnularCsIPhysics* m_EventPhysics; //! +private: + TAnnularCsIData* m_EventData; //! + TAnnularCsIData* m_PreTreatedData; //! + TAnnularCsIPhysics* m_EventPhysics; //! // getters for raw and pre-treated data object - public: - TAnnularCsIData* GetRawData() const {return m_EventData;} - TAnnularCsIData* GetPreTreatedData() const {return m_PreTreatedData;} +public: + TAnnularCsIData* GetRawData() const {return m_EventData;} + TAnnularCsIData* GetPreTreatedData() const {return m_PreTreatedData;} + // getters for interaction position + TVector3 GetPositionOfInteraction(int i) const; + // parameters used in the analysis - private: - // thresholds - double m_E_RAW_Threshold; //! - double m_E_Threshold; //! - - // number of detectors - private: - int m_NumberOfDetectors; //! +private: + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + // interaction position + std::vector<TVector3> m_WedgePosition; //! // spectra class - private: - TAnnularCsISpectra* m_Spectra; // ! +private: + TAnnularCsISpectra* m_Spectra; // ! +public: // spectra getter - public: - map<string, TH1*> GetSpectra(); + std::map<std::string, TH1*> GetSpectra(); + + // get number of detectors + UInt_t GetNumberOfDetectors() const { return m_WedgePosition.size(); } // Static constructor to be passed to the Detector Factory - public: - static NPL::VDetector* Construct(); +public: + static NPL::VDetector* Construct(); - ClassDef(TAnnularCsIPhysics,1) // AnnularCsIPhysics structure + ClassDef(TAnnularCsIPhysics,1) // AnnularCsIPhysics structure }; #endif + +/* Local Variables: */ +/* mode: c++ */ +/* End: */