diff --git a/NPLib/Tiara/Makefile b/NPLib/Tiara/Makefile index 0aaaf9b65d4ac227bb348123b5c156ff6d262d1d..d17a4ea11322e4bd38dd7c475de959664b670988 100644 --- a/NPLib/Tiara/Makefile +++ b/NPLib/Tiara/Makefile @@ -9,7 +9,7 @@ all: $(SHARELIB) ############### Detector ############## ## Sharc ## -libTiara.so: TTiaraBarrelData.o TTiaraBarrelDataDict.o TTiaraBarrelPhysics.o TTiaraBarrelPhysicsDict.o TTiaraHyballData.o TTiaraHyballDataDict.o TTiaraHyballPhysics.o TTiaraHyballPhysicsDict.o TTiaraHyballSpectra.o +libTiara.so: TTiaraBarrelData.o TTiaraBarrelDataDict.o TTiaraBarrelPhysics.o TTiaraBarrelPhysicsDict.o TTiaraBarrelSpectra.o TTiaraHyballData.o TTiaraHyballDataDict.o TTiaraHyballPhysics.o TTiaraHyballPhysicsDict.o TTiaraHyballSpectra.o $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ @@ -26,10 +26,12 @@ TTiaraHyballPhysicsDict.cxx: TTiaraHyballPhysics.h rootcint -f $@ -c $^ # dependances -TTiaraHyballSpectra.o: TTiaraHyballSpectra.cxx TTiaraHyballSpectra.h TTiaraBarrelData.o: TTiaraBarrelData.cxx TTiaraBarrelData.h +TTiaraBarrelPhysics.o: TTiaraBarrelData.cxx TTiaraBarrelData.h +TTiaraBarrelSpectra.o: TTiaraBarrelData.cxx TTiaraBarrelData.h TTiaraHyballData.o: TTiaraHyballData.cxx TTiaraHyballData.h TTiaraHyballPhysics.o: TTiaraHyballPhysics.cxx TTiaraHyballPhysics.h +TTiaraHyballSpectra.o: TTiaraHyballSpectra.cxx TTiaraHyballSpectra.h ####################################### diff --git a/NPLib/Tiara/TTiaraBarrelData.h b/NPLib/Tiara/TTiaraBarrelData.h index 3359bb8972ad2e9d0396fa956351ac35516daad5..f2e5e0b1bfe353d184dc34634bcf5da9716deaed 100644 --- a/NPLib/Tiara/TTiaraBarrelData.h +++ b/NPLib/Tiara/TTiaraBarrelData.h @@ -74,45 +74,45 @@ class TTiaraBarrelData : public TNamed { ////////////////// MULTIPLICITY GETTER ///////////////////// // E - inline unsigned int GetFrontUpstreamEMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetFrontUpstreamEMult(){ return fTiaraBarrel_FrontUpstreamE_DetectorNbr.size(); } // T - inline unsigned int GetFrontUpstreamTMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetFrontUpstreamTMult(){ return fTiaraBarrel_FrontUpstreamT_DetectorNbr.size(); } ///////////////////// // E - inline unsigned int GetFrontDownstreamEMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetFrontDownstreamEMult(){ return fTiaraBarrel_FrontDownstreamE_DetectorNbr.size(); } // T - inline unsigned int GetFrontDownstreamTMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetFrontDownstreamTMult(){ return fTiaraBarrel_FrontDownstreamT_DetectorNbr.size(); } ///////////////////// // E - inline unsigned int GetBackEMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetBackEMult(){ return fTiaraBarrel_BackE_DetectorNbr.size(); } // T - inline unsigned int GetFrontBackTMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetFrontBackTMult(){ return fTiaraBarrel_BackT_DetectorNbr.size(); } ///////////////////// // E - inline unsigned int GetOuterEMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetOuterEMult(){ return fTiaraBarrel_OuterE_DetectorNbr.size(); } // T - inline unsigned int GetFrontOuterTMult(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy){ + inline unsigned int GetOuterTMult(){ return fTiaraBarrel_OuterT_DetectorNbr.size(); } diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.cxx b/NPLib/Tiara/TTiaraBarrelPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d7679c7736bca3d3e2d1fdd7b0ab64cd7ca3129a --- /dev/null +++ b/NPLib/Tiara/TTiaraBarrelPhysics.cxx @@ -0,0 +1,627 @@ +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TiaraBarrel treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include "TTiaraBarrelPhysics.h" +using namespace TiaraBarrel_LOCAL; + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "TAsciiFile.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + +// ROOT +#include "TChain.h" +/////////////////////////////////////////////////////////////////////////// + +ClassImp(TTiaraBarrelPhysics) + /////////////////////////////////////////////////////////////////////////// + TTiaraBarrelPhysics::TTiaraBarrelPhysics(){ + EventMultiplicity = 0 ; + m_EventData = new TTiaraBarrelData ; + m_PreTreatedData = new TTiaraBarrelData ; + m_EventPhysics = this ; + m_NumberOfDetector = 0 ; + + m_Take_E_Strip; + m_Take_T_Back; + m_Strip_E_RAW_Threshold ; + m_Back_E_Threshold ; + m_OuterStrip_E_RAW_Threshold ; + m_OuterBack_E_Threshold ; + } + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::BuildSimplePhysicalEvent(){ + BuildPhysicalEvent(); +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::BuildPhysicalEvent(){ +/* PreTreat(); + + if( CheckEvent() == 1 ){ + vector< TVector2 > couple = Match_Ring_Sector() ; + EventMultiplicity = couple.size(); + + unsigned int size = couple.size(); + for(unsigned int i = 0 ; i < size ; ++i){ + + int N = m_PreTreatedData->GetRingEDetectorNbr(couple[i].X()) ; + int Ring = m_PreTreatedData->GetRingEStripNbr(couple[i].X()) ; + int Sector = m_PreTreatedData->GetSectorEStripNbr(couple[i].Y()) ; + + double Ring_E = m_PreTreatedData->GetRingEEnergy( couple[i].X() ) ; + double Sector_E = m_PreTreatedData->GetSectorEEnergy( couple[i].Y() ) ; + + // Search for associate Time: + double Ring_T = -1000 ; + unsigned int StripRingTMult = m_PreTreatedData->GetRingTMult(); + for(unsigned int t = 0 ; t < StripRingTMult ; ++t ){ + if( m_PreTreatedData->GetRingEStripNbr( couple[i].X() ) == m_PreTreatedData->GetRingTStripNbr(t) + &&m_PreTreatedData->GetRingEDetectorNbr( couple[i].X() ) == m_PreTreatedData->GetRingTDetectorNbr(t)) + Ring_T = m_PreTreatedData->GetRingTTime(t); + } + + // Search for associate Time: + double Sector_T = -1000 ; + unsigned int StripSectorTMult = m_PreTreatedData->GetSectorTMult(); + for(unsigned int t = 0 ; t < StripSectorTMult ; ++t ){ + if( m_PreTreatedData->GetSectorEStripNbr( couple[i].X() ) == m_PreTreatedData->GetSectorTStripNbr(t) + &&m_PreTreatedData->GetSectorEDetectorNbr( couple[i].X() ) == m_PreTreatedData->GetSectorTDetectorNbr(t)) + Sector_T = m_PreTreatedData->GetSectorTTime(t); + } + + DetectorNumber.push_back(N); + StripRing_E.push_back(Ring_E); + StripRing_T.push_back(Ring_T) ; + StripSector_E.push_back(Sector_E) ; + StripSector_T.push_back(Sector_T) ; + + if(m_Take_E_Ring) + Strip_E.push_back(Ring_E) ; + else + Strip_E.push_back(Sector_E) ; + + if(m_Take_T_Sector) + Strip_T.push_back(Sector_T) ; + else + Strip_T.push_back(Ring_T) ; + + Strip_Ring.push_back(Ring) ; + Strip_Sector.push_back(Sector) ; + } + }*/ +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::PreTreat(){ + ClearPreTreatedData(); + // Match Stick Calibration + // Gain Calibration + // Position + // Ballistic Deficit correction +} + +/////////////////////////////////////////////////////////////////////////// +vector < TVector2 > TTiaraBarrelPhysics :: Match_Upstream_Downstream(){ + vector < TVector2 > ArrayOfGoodCouple ; +/* + // Prevent code from treating very high multiplicity Event + // Those event are not physical anyway and that improve speed. + if( m_PreTreatedData->GetRingEMult() > m_MaximumStripMultiplicityAllowed || m_PreTreatedData->GetSectorEMult() > m_MaximumStripMultiplicityAllowed ) + return ArrayOfGoodCouple; + + for(unsigned int i = 0 ; i < m_PreTreatedData->GetRingEMult(); i++) { + for(unsigned int j = 0 ; j < m_PreTreatedData->GetSectorEMult(); j++){ + // if same detector check energy + if ( m_PreTreatedData->GetRingEDetectorNbr(i) == m_PreTreatedData->GetSectorEDetectorNbr(j) ){ + // Look if energy match + if( abs( (m_PreTreatedData->GetRingEEnergy(i)-m_PreTreatedData->GetSectorEEnergy(j))/2. ) < m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma ) + ArrayOfGoodCouple . push_back ( TVector2(i,j) ) ; + } + } + } +*/ + // Prevent to treat event with ambiguous matchin beetween X and Y + // if( ArrayOfGoodCouple.size() > m_PreTreatedData->GetRingEMult() ) ArrayOfGoodCouple.clear() ; + return ArrayOfGoodCouple; +} + +//////////////////////////////////////////////////////////////////////////// +bool TTiaraBarrelPhysics :: IsValidChannel(const string DetectorType, const int detector , const int channel){ + + if(DetectorType == "InnerBarrelStripUpstream") + return *(m_InnerBarrelStripUpstreamChannelStatus[detector-1].begin()+channel-1); + + if(DetectorType == "InnerBarrelStripDownstream") + return *(m_InnerBarrelStripDownstreamChannelStatus[detector-1].begin()+channel-1); + + else if(DetectorType == "OuterBarrelStrip") + return *(m_OuterBarrelStripChannelStatus[detector-1].begin()+channel-1); + + if(DetectorType == "InnerBarrelBack") + return *(m_InnerBarrelBackChannelStatus[detector-1].begin()+channel-1); + + else if(DetectorType == "OuterBarrelBack") + return *(m_OuterBarrelBackChannelStatus[detector-1].begin()+channel-1); + + else return false; +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::ReadAnalysisConfig(){ + /* bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigTiaraBarrel.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigTiaraBarrel.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigTiaraBarrel.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigTiaraBarrel.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" + if (LineBuffer.compare(0, 11, "ConfigTiaraBarrel") == 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 (whatToDo=="MAX_STRIP_MULTIPLICITY") { + AnalysisConfigFile >> DataBuffer; + m_MaximumStripMultiplicityAllowed = atoi(DataBuffer.c_str() ); + cout << "MAXIMUN STRIP MULTIPLICITY " << m_MaximumStripMultiplicityAllowed << endl; + } + + else if (whatToDo=="STRIP_ENERGY_MATCHING_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingSigma = atof(DataBuffer.c_str() ); + cout << "STRIP ENERGY MATCHING SIGMA " << m_StripEnergyMatchingSigma <<endl; + } + + else if (whatToDo=="STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingNumberOfSigma = atoi(DataBuffer.c_str() ); + cout << "STRIP ENERGY MATCHING NUMBER OF SIGMA " << m_StripEnergyMatchingNumberOfSigma << endl; + } + + else if (whatToDo== "DISABLE_ALL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int Detector = atoi(DataBuffer.substr(2,1).c_str()); + vector< bool > ChannelStatus; + ChannelStatus.resize(24,false); + m_RingChannelStatus[Detector-1] = ChannelStatus; + ChannelStatus.resize(48,false); + m_SectorChannelStatus[Detector-1] = ChannelStatus; + } + + else if (whatToDo == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int Detector = atoi(DataBuffer.substr(2,1).c_str()); + int channel = -1; + if (DataBuffer.compare(3,4,"STRF") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + *(m_RingChannelStatus[Detector-1].begin()+channel-1) = false; + } + + else if (DataBuffer.compare(3,4,"STRB") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + *(m_SectorChannelStatus[Detector-1].begin()+channel-1) = false; + } + + else cout << "Warning: detector type for TiaraBarrel unknown!" << endl; + +} + +else if (whatToDo=="TAKE_E_RING") { + m_Take_E_Ring = true; + cout << whatToDo << endl; +} + +else if (whatToDo=="TAKE_E_SECTOR") { + m_Take_E_Ring = false; + cout << whatToDo << endl; +} + +else if (whatToDo=="TAKE_T_RING") { + m_Take_T_Sector = false; + cout << whatToDo << endl; +} + +else if (whatToDo=="TAKE_T_SECTOR") { + m_Take_T_Sector = true; + cout << whatToDo << endl; +} + +else if (whatToDo=="STRIP_RING_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripRing_E_RAW_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripRing_E_RAW_Threshold << endl; +} + +else if (whatToDo=="STRIP_SECTOR_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripSector_E_RAW_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripSector_E_RAW_Threshold << endl; +} + +else if (whatToDo=="STRIP_RING_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripRing_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripRing_E_Threshold << endl; +} + +else if (whatToDo=="STRIP_SECTOR_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripSector_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripSector_E_Threshold << endl; +} + +else { + ReadingStatus = false; +} + +} +} +*/ +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::Clear(){ + EventMultiplicity=0; + DetectorNumber .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(); + +} +/////////////////////////////////////////////////////////////////////////// + +//// Innherited from VDetector Class //// + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::ReadConfiguration(string Path){ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + double X,Y,Z; + X = 0 ; Y = 0 ; Z = 0; + TVector3 Pos; + bool check_X = false ; + bool check_Y = false ; + bool check_Z = false ; + + bool ReadingStatusWedge = false ; + bool ReadingStatus = false ; + + bool VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); ; + + while (!ConfigFile.eof()){ + + getline(ConfigFile, LineBuffer); + // cout << LineBuffer << endl; + if (LineBuffer.compare(0, 11, "TiaraBarrel") == 0) + ReadingStatus = true; + + while (ReadingStatus && !ConfigFile.eof()) { + ConfigFile >> DataBuffer ; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + else if (DataBuffer == "X=") { + check_X = true; + ConfigFile >> DataBuffer ; + X= atof(DataBuffer.c_str()); + if(VerboseLevel) cout << " X= " << X << "mm" << endl; + } + + else if (DataBuffer == "Y=") { + check_Y = true; + ConfigFile >> DataBuffer ; + Y= atof(DataBuffer.c_str()); + if(VerboseLevel) cout << " Y= " << Y << "mm" << endl; + } + + else if (DataBuffer == "Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + Z= atof(DataBuffer.c_str()); + if(VerboseLevel) cout << " Z= " << Z << "deg" << endl; + } + + else if (DataBuffer == "ThicknessDector=") { + /*ignore that*/ + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatus= false; + cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << endl ; + exit(1); + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if (check_X && check_Y && check_Z){ + + ReadingStatus= false; + AddDetector(X,Y,Z); + // Reinitialisation of Check Boolean + check_X = false ; + check_Y = false ; + check_Z = false ; + } + } + } + + InitializeStandardParameter(); + ReadAnalysisConfig(); +} +/*/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::InitSpectra(){ + //m_Spectra = new TTiaraBarrelSpectra(); +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::FillSpectra(){ + //m_Spectra -> FillRawSpectra(m_EventData); + //m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + //m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::CheckSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< vector<TString>,TH1* > TTiaraBarrelPhysics::GetSpectra() { + return m_Spectra->GetMapHisto(); +} */ +/////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::AddParameterToCalibrationManager(){ + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + for( int j = 0 ; j < 24 ; ++j){ + Cal->AddParameter("TIARABARREL", "D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_E","TIARABARREL_D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_E") ; + Cal->AddParameter("TIARABARREL", "D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_T","TIARABARREL_D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_T") ; + } + + for( int j = 0 ; j < 48 ; ++j){ + Cal->AddParameter("TIARABARREL", "D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_E","TIARABARREL_D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_E") ; + Cal->AddParameter("TIARABARREL", "D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_T","TIARABARREL_D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_T") ; + } + } + return; + +} + +/////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::InitializeRootInputRaw(){ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus( "TiaraBarrel" , true ); + inputChain->SetBranchStatus( "fTiaraBarrel_*" , true ); + inputChain->SetBranchAddress( "TiaraBarrel" , &m_EventData ); +} + +/////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::InitializeRootInputPhysics(){ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("EventMultiplicity",true); + inputChain->SetBranchStatus("DetectorNumber ",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); +} + +/////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::InitializeRootOutput(){ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch( "TiaraBarrel" , "TTiaraBarrelPhysics" , &m_EventPhysics ); +} + +///// Specific to TiaraBarrelArray //// +void TTiaraBarrelPhysics::AddDetector(double X,double Y,double Z){ + cout << "Adding Tiarrel Barrel centered at : ("<<X<<";"<<Y<<";"<<Z<<")"<<endl; + + 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 TTiaraBarrelPhysics::GetDetectorNormal( const int i) const{ + + return (TVector3(0,0,i)); + +} +/////////////////////////////////////////////////////////////////////////////// +TVector3 TTiaraBarrelPhysics::GetPositionOfInteraction(const int i) const{ +/* TVector3 Position = TVector3 ( GetStripPositionX(DetectorNumber[i],Strip_Ring[i],Strip_Sector[i] ) , + GetStripPositionY( DetectorNumber[i],Strip_Ring[i],Strip_Sector[i] ) , + GetStripPositionZ( DetectorNumber[i],Strip_Ring[i],Strip_Sector[i] ) ) ; + + return(Position) ; +*/ +} +/////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelPhysics::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; + } + + ChannelStatus.resize(8,true); + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + m_SectorChannelStatus[i] = ChannelStatus; + } + + m_MaximumStripMultiplicityAllowed = m_NumberOfDetector ; +*/ + return; +} + +/////////////////////////////////////////////////////////////////////////////// +namespace TiaraBarrel_LOCAL{ + + // transform an integer to a string + string itoa(unsigned int value){ + char buffer [33]; + sprintf(buffer,"%d",value); + return buffer; + } +/* + // DSSD + // Ring + double fStrip_Ring_E(const TTiaraBarrelData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARABARREL/D" + itoa( m_EventData->GetRingEDetectorNbr(i) ) + "_STRIP_RING" + itoa( m_EventData->GetRingEStripNbr(i) ) + "_E", + m_EventData->GetRingEEnergy(i) ); + } + + double fStrip_Ring_T(const TTiaraBarrelData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARABARREL/D" + itoa( m_EventData->GetRingTDetectorNbr(i) ) + "_STRIP_RING" + itoa( m_EventData->GetRingTStripNbr(i) ) +"_T", + m_EventData->GetRingTTime(i) ); + } + + // Sector + double fStrip_Sector_E(const TTiaraBarrelData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARABARREL/D" + itoa( m_EventData->GetSectorTDetectorNbr(i) ) + "_STRIP_SECTOR" + itoa( m_EventData->GetSectorTStripNbr(i) ) +"_E", + m_EventData->GetSectorEEnergy(i) ); + } + + double fStrip_Sector_T(const TTiaraBarrelData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARABARREL/D" + itoa( m_EventData->GetSectorTDetectorNbr(i) ) + "_STRIP_SECTOR" + itoa( m_EventData->GetSectorTStripNbr(i) ) +"_T", + m_EventData->GetRingTTime(i) ); + } +*/ +} + diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.h b/NPLib/Tiara/TTiaraBarrelPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..7195d1fbbbc62a42c625176336d9da5788e67805 --- /dev/null +++ b/NPLib/Tiara/TTiaraBarrelPhysics.h @@ -0,0 +1,216 @@ +#ifndef TTIARABARRELPHYSICS_H +#define TTIARABARRELPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : December 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TiaraBarrel treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ +// STL +#include <vector> +#include <map> +// NPL +#include "TTiaraBarrelData.h" +//#include "TTiaraBarrelSpectra.h" +#include "../include/CalibrationManager.h" +#include "../include/VDetector.h" + +// ROOT +#include "TVector2.h" +#include "TVector3.h" +#include "TObject.h" +#include "TH1.h" + +//class TTiaraBarrelSpectra; + +using namespace std ; + +class TTiaraBarrelPhysics : public TObject, public NPA::VDetector{ + public: + TTiaraBarrelPhysics(); + ~TTiaraBarrelPhysics() {}; + + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: + vector < TVector2 > Match_Upstream_Downstream() ; + + public: + // Provide Physical Multiplicity + Int_t EventMultiplicity; + + // Detector + vector<int> DetectorNumber ; + + // Inner Barrel + 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 Barrel + 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; + + public: // Innherited from VDetector Class + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(string) ; + + // 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();}; + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // 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 hold by the spectra class + // void FillSpectra(); + // 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 hold by the Spectra class + // void ClearSpectra(); + + public:// Specific to TiaraBarrel Array + // Clear The PreTeated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // Remove bad channel, calibrate the data and apply threshold + void PreTreat(); + + // 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); + + // 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(); + + // Add a Detector + void AddDetector( double X,double Y,double Z); + + // Give and external TMustData object to TTiaraBarrelPhysics. Needed for online analysis for example. + void SetRawDataPointer(TTiaraBarrelData* rawDataPointer) {m_EventData = rawDataPointer;} + // Retrieve raw and pre-treated data + TTiaraBarrelData* GetRawData() const {return m_EventData;} + TTiaraBarrelData* GetPreTreatedData() const {return m_PreTreatedData;} + + double GetNumberOfDetector() const { return m_NumberOfDetector; }; + + // To be called after a build Physical Event + int GetEventMultiplicity() const { return EventMultiplicity; }; + + TVector3 GetPositionOfInteraction(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_RAW_Threshold ;//! + double m_Back_E_Threshold ;//! + double m_OuterStrip_E_RAW_Threshold ;//! + double m_OuterBack_E_Threshold ;//! + + private: // Root Input and Output tree classes + TTiaraBarrelData* m_EventData;//! + TTiaraBarrelData* m_PreTreatedData;//! + TTiaraBarrelPhysics* m_EventPhysics;//! + + private: // Map of activated channel + map< int, vector<bool> > m_InnerBarrelStripUpstreamChannelStatus;//! + map< int, vector<bool> > m_InnerBarrelStripDownstreamChannelStatus;//! + map< int, vector<bool> > m_OuterBarrelStripChannelStatus;//! + map< int, vector<bool> > m_InnerBarrelBackChannelStatus;//! + map< int, vector<bool> > m_OuterBarrelBackChannelStatus;//! + + 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;//! + + private: // Spectra + // TTiaraBarrelSpectra* m_Spectra;//! + + public: + //map< vector<TString>,TH1* > GetSpectra(); + + ClassDef(TTiaraBarrelPhysics,1) // SharcPhysics structure +}; + +namespace TiaraBarrel_LOCAL{ + // tranform an integer to a string + string itoa(unsigned int value); + // DSSD + // Ring + /* double fStrip_Ring_E(const TTiaraBarrelData* Data, const int i); + double fStrip_Ring_T(const TTiaraBarrelData* Data, const int i); + + // Sector + double fStrip_Sector_E(const TTiaraBarrelData* Data, const int i); + double fStrip_Sector_T(const TTiaraBarrelData* Data, const int i); +*/ +} + +#endif