diff --git a/Inputs/DetectorConfiguration/Riken_65mm.detector b/Inputs/DetectorConfiguration/Riken_65mm.detector index b1a2d08f122dadb59a432b4028b16fa8fb77f156..f608d938e470c4bf9812f95f83479052f7f3416d 100644 --- a/Inputs/DetectorConfiguration/Riken_65mm.detector +++ b/Inputs/DetectorConfiguration/Riken_65mm.detector @@ -8,26 +8,26 @@ GeneralTarget %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Target - THICKNESS= 18 - RADIUS= 45 - MATERIAL= CD2 - ANGLE= 0 - X= 0 - Y= 0 - Z= 0 +THICKNESS= 250000 +RADIUS= 45 +MATERIAL= D2 +ANGLE= 0 +X= 0 +Y= 0 +Z= 0 -%%CryoTarget -% THICKNESS= 3 -% RADIUS= 45 -% TEMPERATURE= 26 -% PRESSURE= 1 -% MATERIAL= D2 -% WINDOWSTHICKNESS= 0 -% WINDOWSMATERIAL= Mylar -% X= 0 -% Y= 0 -% Z= 0 -% +%CryoTarget +%THICKNESS= 250000 +%RADIUS= 45 +%TEMPERATURE= 300 +%PRESSURE= 1 +%MATERIAL= D2 +%WINDOWSTHICKNESS= 0 +%WINDOWSMATERIAL= Mylar +%X= 0 +%Y= 0 +%Z= 0 + %%%%%%%%%%%%%%%%%%%%% MUST2Array %%%%%%% Telescope 1 %%%%%%% @@ -128,7 +128,7 @@ VIS= all %%%%%%%%%%%%%%%%%%%%% -SSSDArray +%SSSDArray %%%%%%%%%% Det 1 %%%%%%%% SSSD A= 17.61 9.85 104.11 diff --git a/Inputs/DetectorConfiguration/e628.detector b/Inputs/DetectorConfiguration/e628.detector new file mode 100644 index 0000000000000000000000000000000000000000..dc070a5ddf1aab1420710c09942820bfb0efeb9a --- /dev/null +++ b/Inputs/DetectorConfiguration/e628.detector @@ -0,0 +1,96 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CATSArray +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CATSDetector + X1_Y1= -34.36 -34.96 -962.5 + X28_Y1= 36.76 -34.96 -962.5 + X1_Y28= -34.36 36.16 -962.5 + X28_Y28= 36.76 36.16 -962.5 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 +CATSDetector + X1_Y1= 34.26 -35.46 -562.5 + X28_Y1= -36.86 -35.46 -562.5 + X1_Y28= 34.26 35.66 -562.5 + X28_Y28= -36.86 35.66 -562.5 + + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +MUST2Array +%%%%%%% Telescope 1 %%%%%%% +M2Telescope +X1_Y1= 10.85 105.03 146.16 +X1_Y128= 22.8 9.84 175.95 +X128_Y1= 104.09 105.03 108.76 +X128_Y128= 116.04 9.84 138.55 +SI= 1 +SILI= 1 +CSI= 1 +VIS= all + +%%%%%%% Telescope 2 %%%%%%% +M2Telescope +X1_Y1= -116.04 9.84 138.55 +X1_Y128= -22.8 9.84 175.95 +X128_Y1= -104.09 105.03 108.76 +X128_Y128= -10.85 105.03 146.16 +SI= 1 +SILI= 1 +CSI= 1 +VIS= all + +%%%%%%% Telescope 3 %%%%%%% +M2Telescope +X1_Y1= -10.85 -105.03 146.16 +X1_Y128= -22.8 -9.84 175.95 +X128_Y1= -104.09 -105.03 108.76 +X128_Y128= -116.04 -9.84 138.55 +SI= 1 +SILI= 1 +CSI= 1 +VIS= all + +%%%%%%% Telescope 4 %%%%%%% +M2Telescope +X1_Y1= 116.04 -9.84 138.55 +X1_Y128= 22.8 -9.84 175.95 +X128_Y1= 104.09 -105.03 108.76 +X128_Y128= 10.85 -105.03 146.16 +SI= 1 +SILI= 1 +CSI= 1 +VIS= all + + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +TiaraHyball +TiaraHyballWedge + Z= -147 + R= 0 + Phi= 0 +TiaraHyballWedge + Z= -147 + R= 0 + Phi= 60 +TiaraHyballWedge + Z= -147 + R= 0 + Phi= 120 +TiaraHyballWedge + Z= -147 + R= 0 + Phi= 180 +TiaraHyballWedge + Z= -147 + R= 0 + Phi= 240 +TiaraHyballWedge + Z= -147 + R= 0 + Phi= 300 +%%%%%%%%%%%%%%%%%%%%%%%%%%% +TiaraBarrel + X= 0 + Y= 0 + Z= 0 + OuterBarrel= 1 + InnerBarrel= 1 diff --git a/NPAnalysis/10He_Riken/Makefile b/NPAnalysis/10He_Riken/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/10He_Riken/Makefile +++ b/NPAnalysis/10He_Riken/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/EXL/Makefile b/NPAnalysis/EXL/Makefile index 2b175ac4b0375e32f02c758e33da2ad7954014fc..51797100eb27c4574bf05ea9a6e6fc117574f8ef 100644 --- a/NPAnalysis/EXL/Makefile +++ b/NPAnalysis/EXL/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/Gaspard/Makefile b/NPAnalysis/Gaspard/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/Gaspard/Makefile +++ b/NPAnalysis/Gaspard/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/Hyde2/Makefile b/NPAnalysis/Hyde2/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/Hyde2/Makefile +++ b/NPAnalysis/Hyde2/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/MakePhysicalTree/Makefile b/NPAnalysis/MakePhysicalTree/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/MakePhysicalTree/Makefile +++ b/NPAnalysis/MakePhysicalTree/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/Paris/Makefile b/NPAnalysis/Paris/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/Paris/Makefile +++ b/NPAnalysis/Paris/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/RRC66/Makefile b/NPAnalysis/RRC66/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/RRC66/Makefile +++ b/NPAnalysis/RRC66/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/S1107_MakeData/Makefile b/NPAnalysis/S1107_MakeData/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/S1107_MakeData/Makefile +++ b/NPAnalysis/S1107_MakeData/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/Speg/Makefile b/NPAnalysis/Speg/Makefile index 2b175ac4b0375e32f02c758e33da2ad7954014fc..51797100eb27c4574bf05ea9a6e6fc117574f8ef 100644 --- a/NPAnalysis/Speg/Makefile +++ b/NPAnalysis/Speg/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/W1/Makefile b/NPAnalysis/W1/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/W1/Makefile +++ b/NPAnalysis/W1/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/must2/Makefile b/NPAnalysis/must2/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/must2/Makefile +++ b/NPAnalysis/must2/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPAnalysis/sssd/Makefile b/NPAnalysis/sssd/Makefile index 8c3232c0768002d1c10d8d4cf6b8160444f57203..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 100644 --- a/NPAnalysis/sssd/Makefile +++ b/NPAnalysis/sssd/Makefile @@ -4,7 +4,6 @@ include $(NPTOOL)/NPLib/Makefile.arch # additional libraries LIBRARY = `$(NPTOOL)/NPLib/liblist` -LIBRARY += -L$(CLHEP_LIB_DIR) -l$(CLHEP_LIB) PROGRAMS = Analysis diff --git a/NPLib/CATS/Makefile b/NPLib/CATS/Makefile index 7ed4129a7acffa58b6755afce79cd3ca281ec8e7..7dc7ccc1e47fdf770d2c40e2fc2b8f695c1e8e33 100644 --- a/NPLib/CATS/Makefile +++ b/NPLib/CATS/Makefile @@ -8,7 +8,7 @@ all: $(SHARELIB) ############### Detector ############## ## CATS ## -libCATS.so: TCATSData.o TCATSDataDict.o TCATSPhysics.o TCATSPhysicsDict.o +libCATS.so: TCATSData.o TCATSDataDict.o TCATSPhysics.o TCATSPhysicsDict.o TCATSSpectra.o $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ TCATSDataDict.cxx: TCATSData.h @@ -22,6 +22,7 @@ TCATSData.o: TCATSData.cxx TCATSData.h TCATSDataDict.o: TCATSData.cxx TCATSData.h TCATSPhysicsDict.o: TCATSPhysics.cxx TCATSPhysics.h TCATSPhysics.o: TCATSPhysics.cxx TCATSPhysics.h +TCATSSpectra.o: TCATSSpectra.cxx TCATSSpectra.h ####################################### ############# Clean and More ########## diff --git a/NPLib/CATS/TCATSData.cxx b/NPLib/CATS/TCATSData.cxx index 7bdca08b9fa328d0a91d15f2cea5907e08f1922d..424622fd3ce97c4a631b3d4a718e8023f648dbe3 100644 --- a/NPLib/CATS/TCATSData.cxx +++ b/NPLib/CATS/TCATSData.cxx @@ -71,7 +71,7 @@ void TCATSData::Dump() const for (UShort_t i = 0; i < fCATS_DetY.size(); i++) cout << "DetY: " << fCATS_DetY[i] << " StripY: " << fCATS_StripY[i] << " EnergyY: " << fCATS_ChargeY[i] << endl; // (Qfil) - cout << "MM_MultQ = " << fCATS_DetQ.size() << endl; + cout << "CATS_MultQ = " << fCATS_DetQ.size() << endl; for (UShort_t i = 0; i < fCATS_DetQ.size(); i++) cout << "DetQ: " << fCATS_DetQ[i] << " Charge: " << fCATS_Charge[i] << endl; } diff --git a/NPLib/CATS/TCATSPhysics.cxx b/NPLib/CATS/TCATSPhysics.cxx index 834b50732cc81beba72e99d9274d7890990a48c3..15eb776c471457737e57920a374a66b7775eaef1 100644 --- a/NPLib/CATS/TCATSPhysics.cxx +++ b/NPLib/CATS/TCATSPhysics.cxx @@ -39,13 +39,14 @@ using namespace LOCAL_CATS; ClassImp(TCATSPhysics) -/////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// TCATSPhysics::TCATSPhysics() { m_EventData = new TCATSData ; - m_PreTreatedData = new TCATSData ; + m_PreTreatedData = new TCATSData ; m_EventPhysics = this ; - m_NumberOfCATS = 0 ; + m_Spectra = 0; + m_NumberOfCATS = 0 ; } /////////////////////////////////////////////////////////////////////////// @@ -55,211 +56,191 @@ TCATSPhysics::~TCATSPhysics() /////////////////////////////////////////////////////////////////////////// void TCATSPhysics::PreTreat() -{ - ClearPreTreatedData(); - gRandom->SetSeed(0); - // X - for(int i = 0 ; i < m_EventData->GetCATSMultX() ; i++) - { - // Valid Channel X - if(IsValidChannel("X", m_EventData->GetCATSDetX(i), m_EventData->GetCATSStripX(i)) ) - { - if( fCATS_Threshold_X(m_EventData , i) ) - { - double QX = fCATS_X_Q(m_EventData , i); - m_PreTreatedData->SetCATSChargeX( QX ); - //Inversion X - if( *(m_CATSXInversion[m_EventData->GetCATSDetX(i)-1].begin() + m_EventData->GetCATSStripX(i)-1) != m_EventData->GetCATSStripX(i) ) - { - m_PreTreatedData->SetCATSStripX( *(m_CATSXInversion[m_EventData->GetCATSDetX(i)-1].begin() + m_EventData->GetCATSStripX(i)-1) ); - } - else {m_PreTreatedData->SetCATSStripX( m_EventData->GetCATSStripX(i) );} - m_PreTreatedData->SetCATSDetX( m_EventData->GetCATSDetX(i) ); - } - } - } - - // Y - for(int i = 0 ; i < m_EventData->GetCATSMultY() ; i++) - { - // Valid Channel Y - if(IsValidChannel("Y", m_EventData->GetCATSDetY(i), m_EventData->GetCATSStripY(i))) - { - if( fCATS_Threshold_Y(m_EventData , i) ) - { - double QY = fCATS_Y_Q(m_EventData , i); - m_PreTreatedData->SetCATSChargeY( QY ); - //Inversion Y - if( *(m_CATSYInversion[m_EventData->GetCATSDetY(i)-1].begin() + m_EventData->GetCATSStripY(i)-1) != m_EventData->GetCATSStripY(i) ) - { - m_PreTreatedData->SetCATSStripY( *(m_CATSYInversion[m_EventData->GetCATSDetY(i)-1].begin() + m_EventData->GetCATSStripY(i)-1) ); - } - else {m_PreTreatedData->SetCATSStripY( m_EventData->GetCATSStripY(i) );} - m_PreTreatedData->SetCATSDetY( m_EventData->GetCATSDetY(i) ); - } - } - } - return; +{ + ClearPreTreatedData(); + gRandom->SetSeed(0); + // X + for(int i = 0 ; i < m_EventData->GetCATSMultX() ; i++) + { + // Valid Channel X + if(IsValidChannel("X", m_EventData->GetCATSDetX(i), m_EventData->GetCATSStripX(i)) ) + { + if( fCATS_Threshold_X(m_EventData , i) ) + { + double QX = fCATS_X_Q(m_EventData , i); + m_PreTreatedData->SetCATSChargeX( QX ); + //Inversion X + if( *(m_CATSXInversion[m_EventData->GetCATSDetX(i)-1].begin() + m_EventData->GetCATSStripX(i)-1) != m_EventData->GetCATSStripX(i) ) + { + m_PreTreatedData->SetCATSStripX( *(m_CATSXInversion[m_EventData->GetCATSDetX(i)-1].begin() + m_EventData->GetCATSStripX(i)-1) ); + } + else {m_PreTreatedData->SetCATSStripX( m_EventData->GetCATSStripX(i) );} + m_PreTreatedData->SetCATSDetX( m_EventData->GetCATSDetX(i) ); + } } + } + + // Y + for(int i = 0 ; i < m_EventData->GetCATSMultY() ; i++) + { + // Valid Channel Y + if(IsValidChannel("Y", m_EventData->GetCATSDetY(i), m_EventData->GetCATSStripY(i))) + { + if( fCATS_Threshold_Y(m_EventData , i) ) + { + double QY = fCATS_Y_Q(m_EventData , i); + m_PreTreatedData->SetCATSChargeY( QY ); + //Inversion Y + if( *(m_CATSYInversion[m_EventData->GetCATSDetY(i)-1].begin() + m_EventData->GetCATSStripY(i)-1) != m_EventData->GetCATSStripY(i) ) + { + m_PreTreatedData->SetCATSStripY( *(m_CATSYInversion[m_EventData->GetCATSDetY(i)-1].begin() + m_EventData->GetCATSStripY(i)-1) ); + } + else {m_PreTreatedData->SetCATSStripY( m_EventData->GetCATSStripY(i) );} + m_PreTreatedData->SetCATSDetY( m_EventData->GetCATSDetY(i) ); + } + } + } + + + return; +} ///////////////////////////////////////////////////////////////////////////// void TCATSPhysics::BuildSimplePhysicalEvent() { - BuildPhysicalEvent(); + BuildPhysicalEvent(); } ////////////////////////////////////////////////////////////////////////////// -void TCATSPhysics::BuildPhysicalEvent() -{ - PreTreat(); - double Pi = 3.14159265; - - // How many CATS? - int NumberOfCATSHit = 0 ; - int DetectorID = -1; - double SumChargeX[2]; - double SumChargeY[2]; - - - for( unsigned short i = 0 ; i < m_PreTreatedData->GetCATSMultX() ; i++ ) - { - if( m_PreTreatedData->GetCATSDetX(i) != DetectorID) { - NumberOfCATSHit++; - } - if(NumberOfCATSHit == m_NumberOfCATS) break; +void TCATSPhysics::BuildPhysicalEvent(){ + PreTreat(); + double Pi = 3.14159265; + // How many CATS? + int NumberOfCATSHit = 0 ; + int DetectorID = -1; + double SumChargeX[2]; + double SumChargeY[2]; + for( unsigned short i = 0 ; i < m_PreTreatedData->GetCATSMultX() ; i++ ){ + if( m_PreTreatedData->GetCATSDetX(i) != DetectorID) { + NumberOfCATSHit++; } - - - // INITIALISATION OF VECTORS : DIM = NUMBER OF CATS - for(int k = 0 ; k < NumberOfCATSHit ; k++ ) - { - // X - StripMaxX.push_back(-1); - ReconstructionMethodX.push_back(NO); - SumChargeX[k] = 0; - - // Y - StripMaxY.push_back(-1); - ReconstructionMethodY.push_back(NO); - SumChargeY[k] = 0; + if(NumberOfCATSHit == m_NumberOfCATS) break; + } + + + // INITIALISATION OF VECTORS : DIM = NUMBER OF CATS + for(int k = 0 ; k < NumberOfCATSHit ; k++ ){ + // X + StripMaxX.push_back(-1); + ReconstructionMethodX.push_back(NO); + SumChargeX[k] = 0; + + // Y + StripMaxY.push_back(-1); + ReconstructionMethodY.push_back(NO); + SumChargeY[k] = 0; + } + for(int p = 0 ; p < m_NumberOfCATS ; p++){ + for(int z=0; z<28; z++) { + Buffer_X_Q[z][p] = -1; + Buffer_Y_Q[z][p] = -1; } - - for(int p = 0 ; p < m_NumberOfCATS ; p++){ - for(int z=0; z<28; z++) { - Buffer_X_Q[z][p] = -1; - Buffer_Y_Q[z][p] = -1; - } - } - - - for(unsigned int i = 0 ; i < m_PreTreatedData->GetCATSMultX() ; i++ ) - { - int StrX = m_PreTreatedData->GetCATSStripX(i); - int NX = m_PreTreatedData->GetCATSDetX(i); - double CATS_X_Q = m_PreTreatedData->GetCATSChargeX(i) ; - Buffer_X_Q[StrX-1][NX-1] = CATS_X_Q; - SumChargeX[NX-1] += CATS_X_Q; - - ChargeX.push_back(CATS_X_Q); - StripX.push_back(StrX); - DetNumberX.push_back(NX); - HitX++; - if(HitX==1) StripMaxX[NX-1] = StrX; - else if(ChargeX[HitX-1] > Buffer_X_Q[StripMaxX[NX-1] -1][NX-1] ) StripMaxX[NX-1] = StrX ; - } + } + + for(unsigned int i = 0 ; i < m_PreTreatedData->GetCATSMultX() ; i++ ){ + int StrX = m_PreTreatedData->GetCATSStripX(i); + int NX = m_PreTreatedData->GetCATSDetX(i); + double CATS_X_Q = m_PreTreatedData->GetCATSChargeX(i) ; + + Buffer_X_Q[StrX-1][NX-1] = CATS_X_Q; + SumChargeX[NX-1] += CATS_X_Q; + ChargeX.push_back(CATS_X_Q); + StripX.push_back(StrX); + DetNumberX.push_back(NX); + HitX++; + if(HitX==1) StripMaxX[NX-1] = StrX; + else if(ChargeX[HitX-1] > Buffer_X_Q[StripMaxX[NX-1] -1][NX-1] ) StripMaxX[NX-1] = StrX ; +} + for(unsigned int j = 0 ; j < m_PreTreatedData->GetCATSMultY() ; j++ ){ + int StrY = m_PreTreatedData->GetCATSStripY(j); + int NY = m_PreTreatedData->GetCATSDetY(j); + double CATS_Y_Q = m_PreTreatedData->GetCATSChargeY(j) ; + + Buffer_Y_Q[StrY-1][NY-1] = CATS_Y_Q; + SumChargeY[NY-1] += CATS_Y_Q; + + ChargeY.push_back(CATS_Y_Q); + StripY.push_back(StrY); + DetNumberY.push_back(NY); + HitY++; + if(HitY==1) StripMaxY[NY-1] = StrY; + else if(ChargeY[HitY-1] > Buffer_Y_Q[StripMaxY[NY-1] -1][NY-1] ) StripMaxY[NY-1] = StrY ; + } + + double CalculatedStripX = 0, CalculatedStripY = 0; + double posX = 0 , posY = 0; - for(unsigned int j = 0 ; j < m_PreTreatedData->GetCATSMultY() ; j++ ) - { - int StrY = m_PreTreatedData->GetCATSStripY(j); - int NY = m_PreTreatedData->GetCATSDetY(j); - double CATS_Y_Q = m_PreTreatedData->GetCATSChargeY(j) ; - Buffer_Y_Q[StrY-1][NY-1] = CATS_Y_Q; - SumChargeY[NY-1] += CATS_Y_Q; - - ChargeY.push_back(CATS_Y_Q); - StripY.push_back(StrY); - DetNumberY.push_back(NY); - HitY++; - if(HitY==1) StripMaxY[NY-1] = StrY; - else if(ChargeY[HitY-1] > Buffer_Y_Q[StripMaxY[NY-1] -1][NY-1] ) StripMaxY[NY-1] = StrY ; - } + for(ff = 1 ; ff < NumberOfCATSHit ; ff++ ){ + CalculatedStripX = AnalyseX(ff); + CalculatedStripY = AnalyseY(ff); + + posX = CalculatePositionX(CalculatedStripX, NOcor); + posY = CalculatePositionY(CalculatedStripY, NOcor); + + DetNumberX_Position.push_back(ff+1); + DetNumberY_Position.push_back(ff+1); + DetNumberZ_Position.push_back(ff+1); + + PositionX.push_back(posX) ; + PositionY.push_back(posY) ; + PositionZ.push_back(StripPositionZ[ff]) ; + + QsumX.push_back(SumChargeX[ff]); + QsumY.push_back(SumChargeY[ff]); + } + + if(NumberOfCATSHit > 1){ + if(PositionX[0] != -1000 && PositionY[0] != -1000 && PositionX[1] != -1000 && PositionY[1] != -1000) { + double PositionOnTargetX_1; + double PositionOnTargetY_1; + double l = sqrt((PositionZ[0]-PositionZ[1])*(PositionZ[0]-PositionZ[1])); + double L = - PositionZ[1]; + double t = (l+L) / l; + + PositionOnTargetX_1 = PositionX[0] + (PositionX[1] - PositionX[0]) * t ; + PositionOnTargetY_1 = PositionY[0] + (PositionY[1] - PositionY[0]) * t ; + + if(m_TargetAngle != 0){ + double a = (PositionZ[1]-PositionZ[0])/(PositionX[1]-PositionX[0]); + double b = PositionZ[0] - a*PositionX[0]; + PositionOnTargetX = b/(tan(m_TargetAngle*Pi/180.) - a); + + double t_new = (l + L + PositionOnTargetX*tan(m_TargetAngle*Pi/180.)) / l; + PositionOnTargetY = PositionY[0] + (PositionY[1] - PositionY[0]) * t_new ; + } - double CalculatedStripX = 0, CalculatedStripY = 0; - double posX = 0 , posY = 0; - - for(ff = 0 ; ff < NumberOfCATSHit ; ff++ ) - { - CalculatedStripX = AnalyseX(ff); - CalculatedStripY = AnalyseY(ff); - - posX = CalculatePositionX(CalculatedStripX, NOcor); - posY = CalculatePositionY(CalculatedStripY, NOcor); - - DetNumberX_Position.push_back(ff+1); - DetNumberY_Position.push_back(ff+1); - DetNumberZ_Position.push_back(ff+1); - - PositionX.push_back(posX) ; - PositionY.push_back(posY) ; - PositionZ.push_back(StripPositionZ[ff]) ; - - QsumX.push_back(SumChargeX[ff]); - QsumY.push_back(SumChargeY[ff]); + + else{ + PositionOnTargetX = PositionOnTargetX_1; + PositionOnTargetY = PositionOnTargetY_1; + } } - - if(NumberOfCATSHit > 1){ - if(PositionX[0] != -1000 && PositionY[0] != -1000 && PositionX[1] != -1000 && PositionY[1] != -1000) - { - double PositionOnTargetX_1; - double PositionOnTargetY_1; - double l = sqrt((PositionZ[0]-PositionZ[1])*(PositionZ[0]-PositionZ[1])); - double L = - PositionZ[1]; - double t = (l+L) / l; - - PositionOnTargetX_1 = PositionX[0] + (PositionX[1] - PositionX[0]) * t ; - PositionOnTargetY_1 = PositionY[0] + (PositionY[1] - PositionY[0]) * t ; - - if(m_TargetAngle != 0) - { - double a = (PositionZ[1]-PositionZ[0])/(PositionX[1]-PositionX[0]); - double b = PositionZ[0] - a*PositionX[0]; - PositionOnTargetX = b/(tan(m_TargetAngle*Pi/180.) - a); - - double t_new = (l + L + PositionOnTargetX*tan(m_TargetAngle*Pi/180.)) / l; - PositionOnTargetY = PositionY[0] + (PositionY[1] - PositionY[0]) * t_new ; - } - - - else{ - PositionOnTargetX = PositionOnTargetX_1; - PositionOnTargetY = PositionOnTargetY_1; - } - GetPositionOnTarget(); - GetBeamDirection(); - } - - else - { - BeamDirection = TVector3 ( 1 , - 0 , - 0 ); - - PositionOnTargetX = -1000 ; - PositionOnTargetY = -1000 ; - } - } - - else if(NumberOfCATSHit == 1) - { - BeamDirection = TVector3 ( 1 , - 0 , - 0 ); - PositionOnTargetX = -1000 ; - PositionOnTargetY = -1000 ; + + else{ + BeamDirection = TVector3 (1,0,0); + + PositionOnTargetX = -1000 ; + PositionOnTargetY = -1000 ; } + } + + else if(NumberOfCATSHit == 1){ + BeamDirection = TVector3 (1,0,0); + PositionOnTargetX = -1000 ; + PositionOnTargetY = -1000 ; + } + return; - return; - } /////////////////////////////////////////////////////////////////////////// @@ -270,7 +251,7 @@ void TCATSPhysics::ReadConfiguration(string Path) ConfigFile.open(Path.c_str()); string LineBuffer ; string DataBuffer ; - + double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; TVector3 A , B , C , D ; @@ -281,132 +262,132 @@ void TCATSPhysics::ReadConfiguration(string Path) bool ReadingStatus = false ; - + while (!ConfigFile.eof()) + { + getline(ConfigFile, LineBuffer); + + //If line is a Start Up CATS bloc, Reading toggle to true + if (LineBuffer.compare(0, 12, "CATSDetector") == 0) { - getline(ConfigFile, LineBuffer); - - //If line is a Start Up CATS bloc, Reading toggle to true - if (LineBuffer.compare(0, 12, "CATSDetector") == 0) - { - cout << "CATS Detector found: " << endl ; - ReadingStatus = true ; - } - - // Else don't toggle to Reading Block Status - else ReadingStatus = false ; - - // Reading Block - while(ReadingStatus) - { - ConfigFile >> DataBuffer ; - // Comment Line - if(DataBuffer.compare(0, 1, "%") == 0) { - ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); - } - - // Finding another telescope (safety), toggle out - else if (DataBuffer.compare(0, 12, "CATSDetector") == 0) { - cout << "Warning: Another CATS is found before standard sequence of Token, Error may have occurred in CATS definition" << endl ; - ReadingStatus = false ; - } - - // Corner Position method - - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az ; - - A = TVector3(Ax, Ay, Az); - cout << " X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl; - } - - else if (DataBuffer.compare(0, 7, "X28_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz ; - - B = TVector3(Bx, By, Bz); - cout << " X28 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl; - } - - else if (DataBuffer.compare(0, 7, "X1_Y28=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz ; - - C = TVector3(Cx, Cy, Cz); - cout << " X1 Y28 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl; - } - - else if (DataBuffer.compare(0, 8, "X28_Y28=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz ; - - D = TVector3(Dx, Dy, Dz); - cout << " X28 Y28 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl; - - } - - // End Corner Position Method - - ///////////////////////////////////////////////// - // If All necessary information there, toggle out - if (check_A && check_B && check_C && check_D) - { - ReadingStatus = false; - - ///Add The previously define telescope - - AddCATS( A , - B , - C , - D ); - - check_A = false; - check_B = false; - check_C = false; - check_D = false; - } - } - + cout << "CATS Detector found: " << endl ; + ReadingStatus = true ; } - InitializeStandardParameter(); - ReadAnalysisConfig(); - m_method_CATS1X = StringToEnum(m_reconstruction_CATS1X); - m_method_CATS1Y = StringToEnum(m_reconstruction_CATS1Y); - m_method_CATS2X = StringToEnum(m_reconstruction_CATS2X); - m_method_CATS2Y = StringToEnum(m_reconstruction_CATS2Y); + + // Else don't toggle to Reading Block Status + else ReadingStatus = false ; + + // Reading Block + while(ReadingStatus) + { + ConfigFile >> DataBuffer ; + // Comment Line + if(DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); + } + + // Finding another telescope (safety), toggle out + else if (DataBuffer.compare(0, 12, "CATSDetector") == 0) { + cout << "Warning: Another CATS is found before standard sequence of Token, Error may have occurred in CATS definition" << endl ; + ReadingStatus = false ; + } + + // Corner Position method + + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az ; + + A = TVector3(Ax, Ay, Az); + cout << " X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl; + } + + else if (DataBuffer.compare(0, 7, "X28_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz ; + + B = TVector3(Bx, By, Bz); + cout << " X28 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl; + } + + else if (DataBuffer.compare(0, 7, "X1_Y28=") == 0) { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz ; + + C = TVector3(Cx, Cy, Cz); + cout << " X1 Y28 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl; + } + + else if (DataBuffer.compare(0, 8, "X28_Y28=") == 0) { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz ; + + D = TVector3(Dx, Dy, Dz); + cout << " X28 Y28 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl; + + } + + // End Corner Position Method + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + if (check_A && check_B && check_C && check_D) + { + ReadingStatus = false; + + ///Add The previously define telescope + + AddCATS( A , + B , + C , + D ); + + check_A = false; + check_B = false; + check_C = false; + check_D = false; + } + } + + } + InitializeStandardParameter(); + ReadAnalysisConfig(); + m_method_CATS1X = StringToEnum(m_reconstruction_CATS1X); + m_method_CATS1Y = StringToEnum(m_reconstruction_CATS1Y); + m_method_CATS2X = StringToEnum(m_reconstruction_CATS2X); + m_method_CATS2Y = StringToEnum(m_reconstruction_CATS2Y); } ///////////////////////////////////////////////////////////////////// @@ -425,28 +406,28 @@ void TCATSPhysics::InitializeRootInputRaw() // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated void TCATSPhysics::InitializeRootInputPhysics() { - TChain* inputChain = RootInput::getInstance()->GetChain(); - inputChain->SetBranchStatus( "CATS" , true ); - inputChain->SetBranchStatus( "ff" , true ); - inputChain->SetBranchStatus( "DetNumberX" , true ); - inputChain->SetBranchStatus( "StripX" , true ); - inputChain->SetBranchStatus( "ChargeX" , true ); - inputChain->SetBranchStatus( "StripMaxX" , true ); - inputChain->SetBranchStatus( "DetNumberY" , true ); - inputChain->SetBranchStatus( "StripY" , true ); - inputChain->SetBranchStatus( "ChargeY" , true ); - inputChain->SetBranchStatus( "StripMaxY" , true ); - inputChain->SetBranchStatus( "DetNumberX_Position" , true ); - inputChain->SetBranchStatus( "DetNumberY_Position" , true ); - inputChain->SetBranchStatus( "DetNumberZ_Position" , true ); - inputChain->SetBranchStatus( "PositionX" , true ); - inputChain->SetBranchStatus( "PositionY" , true ); - inputChain->SetBranchStatus( "PositionZ" , true ); - inputChain->SetBranchStatus( "PositionOnTargetX" , true ); - inputChain->SetBranchStatus( "PositionOnTargetY" , true ); - inputChain->SetBranchStatus( "QsumX" , true ); - inputChain->SetBranchStatus( "QsumY" , true ); - inputChain->SetBranchAddress( "CATS" , &m_EventPhysics ); + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus( "CATS" , true ); + inputChain->SetBranchStatus( "ff" , true ); + inputChain->SetBranchStatus( "DetNumberX" , true ); + inputChain->SetBranchStatus( "StripX" , true ); + inputChain->SetBranchStatus( "ChargeX" , true ); + inputChain->SetBranchStatus( "StripMaxX" , true ); + inputChain->SetBranchStatus( "DetNumberY" , true ); + inputChain->SetBranchStatus( "StripY" , true ); + inputChain->SetBranchStatus( "ChargeY" , true ); + inputChain->SetBranchStatus( "StripMaxY" , true ); + inputChain->SetBranchStatus( "DetNumberX_Position" , true ); + inputChain->SetBranchStatus( "DetNumberY_Position" , true ); + inputChain->SetBranchStatus( "DetNumberZ_Position" , true ); + inputChain->SetBranchStatus( "PositionX" , true ); + inputChain->SetBranchStatus( "PositionY" , true ); + inputChain->SetBranchStatus( "PositionZ" , true ); + inputChain->SetBranchStatus( "PositionOnTargetX" , true ); + inputChain->SetBranchStatus( "PositionOnTargetY" , true ); + inputChain->SetBranchStatus( "QsumX" , true ); + inputChain->SetBranchStatus( "QsumY" , true ); + inputChain->SetBranchAddress( "CATS" , &m_EventPhysics ); } @@ -466,24 +447,24 @@ void TCATSPhysics::AddCATS(TVector3 C_X1_Y1, TVector3 C_X28_Y1, TVector3 C_X1_Y2 // remove warning C_X28_Y28 *= 1; - // Vector U on Telescope Face (paralelle to Y Strip) + // Vector U on Telescope Face (paralelle to Y Strip) TVector3 U = C_X28_Y1 - C_X1_Y1 ; U = U.Unit() ; - + // Vector V on Telescope Face (parallele to X Strip) TVector3 V = C_X1_Y28 - C_X1_Y1 ; V = V.Unit() ; - + // Position Vector of Strip Center TVector3 StripCenter ; // Position Vector of X=1 Y=1 Strip TVector3 Strip_1_1 ; - + // Geometry Parameters double Face = 71.12 ; //mm double NumberOfStrip = 28 ; double StripPitch = Face / NumberOfStrip ; //mm - + // Buffer object to fill Position Array vector<double> lineX ; vector<double> lineY ; @@ -494,24 +475,24 @@ void TCATSPhysics::AddCATS(TVector3 C_X1_Y1, TVector3 C_X28_Y1, TVector3 C_X1_Y2 // Moving StripCenter to 1.1 corner (strip center!) : Strip_1_1 = C_X1_Y1 + (U+V) * (StripPitch/2) ; - - + + for( int i = 0 ; i < 28 ; i++ ) + { + lineX.clear() ; + lineY.clear() ; + + for( int j = 0 ; j < 28 ; j++ ) { - lineX.clear() ; - lineY.clear() ; - - for( int j = 0 ; j < 28 ; j++ ) - { - StripCenter = Strip_1_1 + StripPitch*( i*U + j*V ) ; - lineX.push_back( StripCenter.x() ) ; - lineY.push_back( StripCenter.y() ) ; - } - - OneDetectorStripPositionX.push_back(lineX); - OneDetectorStripPositionY.push_back(lineY); + StripCenter = Strip_1_1 + StripPitch*( i*U + j*V ) ; + lineX.push_back( StripCenter.x() ) ; + lineY.push_back( StripCenter.y() ) ; } + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + } + OneDetectorStripPositionZ = C_X1_Y1.Z(); StripPositionX.push_back(OneDetectorStripPositionX) ; @@ -523,277 +504,302 @@ void TCATSPhysics::AddCATS(TVector3 C_X1_Y1, TVector3 C_X28_Y1, TVector3 C_X1_Y2 /////////////////////////////////////////////////////////////// void TCATSPhysics::Clear() { - DetNumberX.clear() ; - StripX.clear() ; - ChargeX.clear() ; - StripMaxX.clear() ; - DetNumberY.clear() ; - StripY.clear() ; - ChargeY.clear() ; - StripMaxY.clear() ; - DetNumberX_Position.clear() ; - DetNumberY_Position.clear() ; - DetNumberZ_Position.clear() ; - PositionX.clear() ; - PositionY.clear() ; - PositionZ.clear() ; - QsumX.clear(); - QsumY.clear(); - ReconstructionMethodX.clear() ; - ReconstructionMethodY.clear() ; - - - ff = 0; - HitX = 0; - HitY = 0; + DetNumberX.clear() ; + StripX.clear() ; + ChargeX.clear() ; + StripMaxX.clear() ; + DetNumberY.clear() ; + StripY.clear() ; + ChargeY.clear() ; + StripMaxY.clear() ; + DetNumberX_Position.clear() ; + DetNumberY_Position.clear() ; + DetNumberZ_Position.clear() ; + PositionX.clear() ; + PositionY.clear() ; + PositionZ.clear() ; + QsumX.clear(); + QsumY.clear(); + ReconstructionMethodX.clear() ; + ReconstructionMethodY.clear() ; + + + ff = 0; + HitX = 0; + HitY = 0; } //////////////////////////////////////////////////////////////////////////// bool TCATSPhysics :: IsValidChannel(const string DetectorType, const int Detector , const int channel) - { - if(DetectorType == "X") - return *(m_XChannelStatus[Detector-1].begin()+channel-1); - - else if(DetectorType == "Y") - return *(m_YChannelStatus[Detector-1].begin()+channel-1); - - else return false; - } - - +{ + if(DetectorType == "X") + return *(m_XChannelStatus[Detector-1].begin()+channel-1); + + else if(DetectorType == "Y") + return *(m_YChannelStatus[Detector-1].begin()+channel-1); + + else return false; +} + + /////////////////////////////////////////////////////////////////////////////////// void TCATSPhysics::InitializeStandardParameter() - { - // Enable all channel and no inversion - vector< bool > ChannelStatus; - vector< int > InversionStatus; - m_XChannelStatus.clear() ; - m_YChannelStatus.clear() ; - m_CATSXInversion.clear() ; - m_CATSYInversion.clear() ; - - ChannelStatus.resize(28,true); - InversionStatus.resize(28); - for(unsigned int j = 0 ; j < InversionStatus.size() ; j++) - { - InversionStatus[j] = j+1; - } - - for(int i = 0 ; i < m_NumberOfCATS ; ++i) - { - m_XChannelStatus[i] = ChannelStatus; - m_YChannelStatus[i] = ChannelStatus; - m_CATSXInversion[i] = InversionStatus; - m_CATSYInversion[i] = InversionStatus; - } - - return; - } +{ + // Enable all channel and no inversion + vector< bool > ChannelStatus; + vector< int > InversionStatus; + m_XChannelStatus.clear() ; + m_YChannelStatus.clear() ; + m_CATSXInversion.clear() ; + m_CATSYInversion.clear() ; + + ChannelStatus.resize(28,true); + InversionStatus.resize(28); + for(unsigned int j = 0 ; j < InversionStatus.size() ; j++) + { + InversionStatus[j] = j+1; + } + + for(int i = 0 ; i < m_NumberOfCATS ; ++i) + { + m_XChannelStatus[i] = ChannelStatus; + m_YChannelStatus[i] = ChannelStatus; + m_CATSXInversion[i] = InversionStatus; + m_CATSYInversion[i] = InversionStatus; + } + + return; +} /////////////////////////////////////////////////////////////////////////// void TCATSPhysics::ReadAnalysisConfig() { - bool ReadingStatus = false; - - // path to file - string FileName = "./configs/ConfigCATS.dat"; - - // open analysis config file - ifstream AnalysisConfigFile; - AnalysisConfigFile.open(FileName.c_str()); - - if (!AnalysisConfigFile.is_open()) { - cout << " No ConfigCATS.dat found: Default parameter loaded for Analayis " << FileName << endl; - return; - } - cout << " Loading user parameter for Analysis from ConfigCATS.dat " << endl; - - // Save it in a TAsciiFile - TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); - asciiConfig->AppendLine("%%% ConfigCATS.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, 10, "ConfigCATS") == 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 == "DISABLE_CHANNEL") { - AnalysisConfigFile >> DataBuffer; - cout << whatToDo << " " << DataBuffer << endl; - int Detector = atoi(DataBuffer.substr(4,1).c_str()); - int channel = -1; - if (DataBuffer.compare(5,4,"STRX") == 0) { - channel = atoi(DataBuffer.substr(9).c_str()); - *(m_XChannelStatus[Detector-1].begin()+channel-1) = false; - } - - else if (DataBuffer.compare(5,4,"STRY") == 0) { - channel = atoi(DataBuffer.substr(9).c_str()); - *(m_YChannelStatus[Detector-1].begin()+channel-1) = false; - } - - else cout << "Warning: detector type for CATS unknown!" << endl; - + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigCATS.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigCATS.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigCATS.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigCATS.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, 10, "ConfigCATS") == 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 == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int Detector = atoi(DataBuffer.substr(4,1).c_str()); + int channel = -1; + if (DataBuffer.compare(5,4,"STRX") == 0) { + channel = atoi(DataBuffer.substr(9).c_str()); + *(m_XChannelStatus[Detector-1].begin()+channel-1) = false; } - else if (whatToDo == "INVERSION") { - AnalysisConfigFile >> DataBuffer; - cout << whatToDo << " " << DataBuffer; - int Detector = atoi(DataBuffer.substr(4,1).c_str()); - int channel1 = -1; - int channel2 = -1; - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer; - if (DataBuffer.compare(0,4,"STRX") == 0) { - channel1 = atoi(DataBuffer.substr(4).c_str()); - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - channel2 = atoi(DataBuffer.substr(4).c_str()); - *(m_CATSXInversion[Detector-1].begin()+channel1-1) = channel2; - *(m_CATSXInversion[Detector-1].begin()+channel2-1) = channel1; - } - - else if (DataBuffer.compare(0,4,"STRY") == 0) { - channel1 = atoi(DataBuffer.substr(4).c_str()); - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - channel2 = atoi(DataBuffer.substr(4).c_str()); - *(m_CATSYInversion[Detector-1].begin()+channel1-1) = channel2; - *(m_CATSYInversion[Detector-1].begin()+channel2-1) = channel1; - } + else if (DataBuffer.compare(5,4,"STRY") == 0) { + channel = atoi(DataBuffer.substr(9).c_str()); + *(m_YChannelStatus[Detector-1].begin()+channel-1) = false; } - - else if (whatToDo == "RECONSTRUCTION_METHOD") { - AnalysisConfigFile >> DataBuffer; - cout << whatToDo << " " << DataBuffer; - if (DataBuffer.compare(0,6,"CATS1X") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_reconstruction_CATS1X = DataBuffer; - } - - else if (DataBuffer.compare(0,6,"CATS1Y") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_reconstruction_CATS1Y = DataBuffer; - } - - else if (DataBuffer.compare(0,6,"CATS2X") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_reconstruction_CATS2X = DataBuffer; - } - - else if (DataBuffer.compare(0,6,"CATS2Y") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_reconstruction_CATS2Y = DataBuffer; - } - } - - else if (whatToDo == "CORRECTION_METHOD") { - AnalysisConfigFile >> DataBuffer; - cout << whatToDo << " " << DataBuffer; - if (DataBuffer.compare(0,6,"CATS1X") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_correction_CATS1X = DataBuffer; - } - - else if (DataBuffer.compare(0,6,"CATS1Y") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_correction_CATS1Y = DataBuffer; - } - - else if (DataBuffer.compare(0,6,"CATS2X") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_correction_CATS2X = DataBuffer; - } - - else if (DataBuffer.compare(0,6,"CATS2Y") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_correction_CATS2Y = DataBuffer; - } - } - /*else if (whatToDo == "CORRECTION_METHOD") { - AnalysisConfigFile >> DataBuffer; - cout << whatToDo << " " << DataBuffer << endl; - m_correction = DataBuffer; - }*/ - - else if (whatToDo == "CORRECTION_COEF") { - AnalysisConfigFile >> DataBuffer; - cout << whatToDo << " " << DataBuffer; - if (DataBuffer.compare(0,6,"CATS1X") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_CorrectionCoef_CATS1X = atof(DataBuffer.c_str()); - } - - else if (DataBuffer.compare(0,6,"CATS1Y") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_CorrectionCoef_CATS1Y = atof(DataBuffer.c_str()); - } - - else if (DataBuffer.compare(0,6,"CATS2X") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_CorrectionCoef_CATS2X = atof(DataBuffer.c_str()); - } - - else if (DataBuffer.compare(0,6,"CATS2Y") == 0) { - AnalysisConfigFile >> DataBuffer; - cout << " " << DataBuffer << endl; - m_CorrectionCoef_CATS2Y = atof(DataBuffer.c_str()); - } - } - - - else {ReadingStatus = false;} - + + else cout << "Warning: detector type for CATS unknown!" << endl; + } - } + + else if (whatToDo == "INVERSION") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer; + int Detector = atoi(DataBuffer.substr(4,1).c_str()); + int channel1 = -1; + int channel2 = -1; + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer; + if (DataBuffer.compare(0,4,"STRX") == 0) { + channel1 = atoi(DataBuffer.substr(4).c_str()); + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + channel2 = atoi(DataBuffer.substr(4).c_str()); + *(m_CATSXInversion[Detector-1].begin()+channel1-1) = channel2; + *(m_CATSXInversion[Detector-1].begin()+channel2-1) = channel1; + } + + else if (DataBuffer.compare(0,4,"STRY") == 0) { + channel1 = atoi(DataBuffer.substr(4).c_str()); + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + channel2 = atoi(DataBuffer.substr(4).c_str()); + *(m_CATSYInversion[Detector-1].begin()+channel1-1) = channel2; + *(m_CATSYInversion[Detector-1].begin()+channel2-1) = channel1; + } + } + + else if (whatToDo == "RECONSTRUCTION_METHOD") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer; + if (DataBuffer.compare(0,6,"CATS1X") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_reconstruction_CATS1X = DataBuffer; + } + + else if (DataBuffer.compare(0,6,"CATS1Y") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_reconstruction_CATS1Y = DataBuffer; + } + + else if (DataBuffer.compare(0,6,"CATS2X") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_reconstruction_CATS2X = DataBuffer; + } + + else if (DataBuffer.compare(0,6,"CATS2Y") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_reconstruction_CATS2Y = DataBuffer; + } + } + + else if (whatToDo == "CORRECTION_METHOD") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer; + if (DataBuffer.compare(0,6,"CATS1X") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_correction_CATS1X = DataBuffer; + } + + else if (DataBuffer.compare(0,6,"CATS1Y") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_correction_CATS1Y = DataBuffer; + } + + else if (DataBuffer.compare(0,6,"CATS2X") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_correction_CATS2X = DataBuffer; + } + + else if (DataBuffer.compare(0,6,"CATS2Y") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_correction_CATS2Y = DataBuffer; + } + } + /*else if (whatToDo == "CORRECTION_METHOD") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + m_correction = DataBuffer; + }*/ + + else if (whatToDo == "CORRECTION_COEF") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer; + if (DataBuffer.compare(0,6,"CATS1X") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_CorrectionCoef_CATS1X = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0,6,"CATS1Y") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_CorrectionCoef_CATS1Y = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0,6,"CATS2X") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_CorrectionCoef_CATS2X = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0,6,"CATS2Y") == 0) { + AnalysisConfigFile >> DataBuffer; + cout << " " << DataBuffer << endl; + m_CorrectionCoef_CATS2Y = atof(DataBuffer.c_str()); + } + } + + + else {ReadingStatus = false;} + + } + } } + +/////////////////////////////////////////////////////////////////////////// +void TCATSPhysics::InitSpectra(){ + m_Spectra = new TCATSSpectra(m_NumberOfCATS); +} + +/////////////////////////////////////////////////////////////////////////// +void TCATSPhysics::FillSpectra(){ + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} +/////////////////////////////////////////////////////////////////////////// +void TCATSPhysics::CheckSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +void TCATSPhysics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< vector<TString> , TH1*> TCATSPhysics::GetSpectra() { + return m_Spectra->GetMapHisto(); +} + ///////////////////////////////////////////////////////////////////// // Add Parameter to the CalibrationManger void TCATSPhysics::AddParameterToCalibrationManager() { CalibrationManager* Cal = CalibrationManager::getInstance(); for(int i = 0 ; i < m_NumberOfCATS ; i++) + { + + for( int j = 0 ; j < 28 ; j++) { - - for( int j = 0 ; j < 28 ; j++) - { - Cal->AddParameter("CATS", "D"+itoa(i+1)+"_X"+itoa(j+1)+"_Q","CATS_D"+itoa(i+1)+"_X"+itoa(j+1)+"_Q") ; - Cal->AddParameter("CATS", "D"+itoa(i+1)+"_Y"+itoa(j+1)+"_Q","CATS_D"+itoa(i+1)+"_Y"+itoa(j+1)+"_Q") ; - Cal->AddParameter("CATS", "D"+itoa(i+1)+"_X"+itoa(j+1),"CATS_D"+itoa(i+1)+"_X"+itoa(j+1)) ; - Cal->AddParameter("CATS", "D"+itoa(i+1)+"_Y"+itoa(j+1),"CATS_D"+itoa(i+1)+"_Y"+itoa(j+1)) ; - } - } - - return; + Cal->AddParameter("CATS", "D"+itoa(i+1)+"_X"+itoa(j+1)+"_Q","CATS_D"+itoa(i+1)+"_X"+itoa(j+1)+"_Q") ; + Cal->AddParameter("CATS", "D"+itoa(i+1)+"_Y"+itoa(j+1)+"_Q","CATS_D"+itoa(i+1)+"_Y"+itoa(j+1)+"_Q") ; + Cal->AddParameter("CATS", "D"+itoa(i+1)+"_X"+itoa(j+1),"CATS_D"+itoa(i+1)+"_X"+itoa(j+1)) ; + Cal->AddParameter("CATS", "D"+itoa(i+1)+"_Y"+itoa(j+1),"CATS_D"+itoa(i+1)+"_Y"+itoa(j+1)) ; + } + } + + return; } //////////////////////////////////////////////////////////////// @@ -808,7 +814,7 @@ double TCATSPhysics::AnalyseX(int ff) if(ReconstructionMethodX[ff] == BAR3) CalculatedStripX = Barycentric3MethodX(); if(ReconstructionMethodX[ff] == BAR4) CalculatedStripX = Barycentric4MethodX(); if(ReconstructionMethodX[ff] == BAR5) CalculatedStripX = Barycentric5MethodX(); - + return(CalculatedStripX); } @@ -824,24 +830,24 @@ double TCATSPhysics::AnalyseY(int ff) if(ReconstructionMethodY[ff] == BAR3) CalculatedStripY = Barycentric3MethodY(); if(ReconstructionMethodY[ff] == BAR4) CalculatedStripY = Barycentric4MethodY(); if(ReconstructionMethodY[ff] == BAR5) CalculatedStripY = Barycentric5MethodY(); - - + + return(CalculatedStripY); } //////////////////////////////////////////////////////////////////////// reconstruction TCATSPhysics::ChooseReconstruction(int ff, TString type) { - reconstruction method = NO; - if(ff==0){ - if(type=="X"){method = m_method_CATS1X;} - else if(type=="Y"){method = m_method_CATS1Y;} - } + reconstruction method = NO; + if(ff==0){ + if(type=="X"){method = m_method_CATS1X;} + else if(type=="Y"){method = m_method_CATS1Y;} + } - if(ff==1){ - if(type=="X"){method = m_method_CATS2X;} - else if(type=="Y"){method = m_method_CATS2Y;} - } + if(ff==1){ + if(type=="X"){method = m_method_CATS2X;} + else if(type=="Y"){method = m_method_CATS2Y;} + } return(method); } @@ -849,14 +855,14 @@ reconstruction TCATSPhysics::ChooseReconstruction(int ff, TString type) ///////////////////////////////////////////////////////////////////////// reconstruction TCATSPhysics::StringToEnum(string type) { - reconstruction method = NO; - if(type=="GAUSS"){method = GAUSS;} - if(type=="SECHS"){method = SECHS;} - if(type=="BAR3"){method = BAR3;} - if(type=="BAR4"){method = BAR4;} - if(type=="BAR5"){method = BAR5;} - - return(method); + reconstruction method = NO; + if(type=="GAUSS"){method = GAUSS;} + if(type=="SECHS"){method = SECHS;} + if(type=="BAR3"){method = BAR3;} + if(type=="BAR4"){method = BAR4;} + if(type=="BAR5"){method = BAR5;} + + return(method); } ////////////////////////////////////////////////////////////////////// @@ -865,67 +871,67 @@ double TCATSPhysics::CalculatePositionX(double CalculatedStripX, correction met double positionX=-1000; int IStripX = 0; - if(ReconstructionMethodX[ff] == GAUSS){positionX = CalculatedStripX;} // already in mm -> see gaussian method + if(ReconstructionMethodX[ff] == GAUSS){positionX = CalculatedStripX;} // already in mm -> see gaussian method + + else{ + IStripX = (int) CalculatedStripX ; + + // Decimal Part + double DStripX = CalculatedStripX-IStripX ; + + if( DStripX > 0.5) {IStripX++; DStripX = DStripX-1 ;} else {DStripX = DStripX;} + + // Calculate Geometrical Position + if(IStripX > 0 && IStripX < 29){ + if(ff==0){ //CATS1 + // Warning : DStrip sign has to be determined carefully depending on the X direction + + positionX = (DStripX)*2.54 + StripPositionX[ff][IStripX-1][0] ; //init avec le moins + + if(method == NOcor) positionX = positionX; + else if(method == cor){ + if(ReconstructionMethodX[ff] == BAR3) positionX = CorrectedPositionX3(positionX, 0.60); + if(ReconstructionMethodX[ff] == BAR4) positionX = CorrectedPositionX4(positionX, 0.77); + } + } + + else if(ff==1){ //CATS2 + // Warning : DStrip sign has to be determined carefully depending on the X direction + + positionX = -(DStripX)*2.54 + StripPositionX[ff][IStripX-1][0] ; + + if(method == NOcor) positionX = positionX; + else if(method == cor){ + if(ReconstructionMethodX[ff] == BAR3) positionX = CorrectedPositionX3(positionX, 0.30); + if(ReconstructionMethodX[ff] == BAR4) positionX = CorrectedPositionX4(positionX, 0.67); + } + } + else cout << "only 2CATS!! ff = " << ff << endl; + } + + else {positionX = -1000;} + } + + + if(ff==0 && CalculatedStripX != -1000){ + if(m_correction_CATS1X == "Correction3Points"){ + positionX = Corrected3PointsX(positionX,m_CorrectionCoef_CATS1X); + } + if(m_correction_CATS1X == "Correction4Points"){ + positionX = Corrected4PointsX(positionX,m_CorrectionCoef_CATS1X); + } + } + + if(ff==1 && CalculatedStripX != -1000){ + if(m_correction_CATS2X == "Correction3Points"){ + positionX = Corrected3PointsX(positionX,m_CorrectionCoef_CATS2X); + } + if(m_correction_CATS2X == "Correction4Points"){ + positionX = Corrected4PointsX(positionX,m_CorrectionCoef_CATS2X); + } + } + - else{ - IStripX = (int) CalculatedStripX ; - - // Decimal Part - double DStripX = CalculatedStripX-IStripX ; - - if( DStripX > 0.5) {IStripX++; DStripX = DStripX-1 ;} else {DStripX = DStripX;} - - // Calculate Geometrical Position - if(IStripX > 0 && IStripX < 29){ - if(ff==0){ //CATS1 - // Warning : DStrip sign has to be determined carefully depending on the X direction - - positionX = (DStripX)*2.54 + StripPositionX[ff][IStripX-1][0] ; //init avec le moins - - if(method == NOcor) positionX = positionX; - else if(method == cor){ - if(ReconstructionMethodX[ff] == BAR3) positionX = CorrectedPositionX3(positionX, 0.60); - if(ReconstructionMethodX[ff] == BAR4) positionX = CorrectedPositionX4(positionX, 0.77); - } - } - - else if(ff==1){ //CATS2 - // Warning : DStrip sign has to be determined carefully depending on the X direction - - positionX = -(DStripX)*2.54 + StripPositionX[ff][IStripX-1][0] ; - - if(method == NOcor) positionX = positionX; - else if(method == cor){ - if(ReconstructionMethodX[ff] == BAR3) positionX = CorrectedPositionX3(positionX, 0.30); - if(ReconstructionMethodX[ff] == BAR4) positionX = CorrectedPositionX4(positionX, 0.67); - } - } - else cout << "only 2CATS!! ff = " << ff << endl; - } - - else {positionX = -1000;} - } - - - if(ff==0 && CalculatedStripX != -1000){ - if(m_correction_CATS1X == "Correction3Points"){ - positionX = Corrected3PointsX(positionX,m_CorrectionCoef_CATS1X); - } - if(m_correction_CATS1X == "Correction4Points"){ - positionX = Corrected4PointsX(positionX,m_CorrectionCoef_CATS1X); - } - } - - if(ff==1 && CalculatedStripX != -1000){ - if(m_correction_CATS2X == "Correction3Points"){ - positionX = Corrected3PointsX(positionX,m_CorrectionCoef_CATS2X); - } - if(m_correction_CATS2X == "Correction4Points"){ - positionX = Corrected4PointsX(positionX,m_CorrectionCoef_CATS2X); - } - } - - return positionX; } @@ -934,319 +940,319 @@ double TCATSPhysics::CalculatePositionY(double CalculatedStripY, correction met { double positionY = -1000; - if(ReconstructionMethodY[ff] == GAUSS){positionY = CalculatedStripY;} // already in mm -> see gaussian method - - else{ - // Integer part - int IStripY = (int) CalculatedStripY ; - - // Decimal Part - double DStripY = CalculatedStripY-IStripY ; - - if(DStripY > 0.5) {IStripY++; DStripY = DStripY-1;} - else {DStripY = DStripY; } - - // Calculate Geometrical Position - if(IStripY > 0 && IStripY < 29 ){ - positionY = (DStripY)*2.54 + StripPositionY[ff][0][IStripY-1] ; // conversion en mm initiale - if(ff ==0){ - if(method == NOcor) positionY = positionY; - else if(method == cor) { - if(ReconstructionMethodY[ff] == BAR3) positionY = CorrectedPositionY3(positionY, 0.6); - if(ReconstructionMethodY[ff] == BAR4) positionY = CorrectedPositionY4(positionY, 0.75); - } - } - - else if(ff ==1){ - if(method == NOcor) positionY = positionY; - else if(method == cor){ - if(ReconstructionMethodY[ff] == BAR3) positionY = CorrectedPositionY3(positionY, 0.45); - if(ReconstructionMethodY[ff] == BAR4) positionY = CorrectedPositionY4(positionY, 0.7); - } - } - - else cout << "only 2CATS!! ff = " << ff << endl; - } - - else {positionY = -1000;} - } - - - if(ff==0 && CalculatedStripY != -1000){ - if(m_correction_CATS1Y == "Correction3Points"){ - positionY = Corrected3PointsY(positionY,m_CorrectionCoef_CATS1Y); - } - if(m_correction_CATS1Y == "Correction4Points"){ - positionY = Corrected4PointsY(positionY,m_CorrectionCoef_CATS1Y); - } - } - - if(ff==1 && CalculatedStripY != -1000){ - if(m_correction_CATS2Y == "Correction3Points"){ - positionY = Corrected3PointsY(positionY,m_CorrectionCoef_CATS2Y); - } - if(m_correction_CATS2Y == "Correction4Points"){ - positionY = Corrected4PointsY(positionY,m_CorrectionCoef_CATS2Y); - } - } - + if(ReconstructionMethodY[ff] == GAUSS){positionY = CalculatedStripY;} // already in mm -> see gaussian method + + else{ + // Integer part + int IStripY = (int) CalculatedStripY ; + + // Decimal Part + double DStripY = CalculatedStripY-IStripY ; + + if(DStripY > 0.5) {IStripY++; DStripY = DStripY-1;} + else {DStripY = DStripY; } + + // Calculate Geometrical Position + if(IStripY > 0 && IStripY < 29 ){ + positionY = (DStripY)*2.54 + StripPositionY[ff][0][IStripY-1] ; // conversion en mm initiale + if(ff ==0){ + if(method == NOcor) positionY = positionY; + else if(method == cor) { + if(ReconstructionMethodY[ff] == BAR3) positionY = CorrectedPositionY3(positionY, 0.6); + if(ReconstructionMethodY[ff] == BAR4) positionY = CorrectedPositionY4(positionY, 0.75); + } + } + + else if(ff ==1){ + if(method == NOcor) positionY = positionY; + else if(method == cor){ + if(ReconstructionMethodY[ff] == BAR3) positionY = CorrectedPositionY3(positionY, 0.45); + if(ReconstructionMethodY[ff] == BAR4) positionY = CorrectedPositionY4(positionY, 0.7); + } + } + + else cout << "only 2CATS!! ff = " << ff << endl; + } + + else {positionY = -1000;} + } + + + if(ff==0 && CalculatedStripY != -1000){ + if(m_correction_CATS1Y == "Correction3Points"){ + positionY = Corrected3PointsY(positionY,m_CorrectionCoef_CATS1Y); + } + if(m_correction_CATS1Y == "Correction4Points"){ + positionY = Corrected4PointsY(positionY,m_CorrectionCoef_CATS1Y); + } + } + + if(ff==1 && CalculatedStripY != -1000){ + if(m_correction_CATS2Y == "Correction3Points"){ + positionY = Corrected3PointsY(positionY,m_CorrectionCoef_CATS2Y); + } + if(m_correction_CATS2Y == "Correction4Points"){ + positionY = Corrected4PointsY(positionY,m_CorrectionCoef_CATS2Y); + } + } + return positionY; - + } //////////////////////////////////////////////////////////////////// double TCATSPhysics:: GaussianMethodX() { - int StripMax = StripMaxX[ff]; - double gauss = -1000; - double Q[3]; - double StripPos[3]; - - for(int j = 0; j<3 ; j++) - { - Q[j] = 0; - StripPos[j] = 0; - } - - - if(StripMaxX[ff]> 3 && StripMaxX[ff]< 26) - { - Q[0] = Buffer_X_Q[StripMax-1][ff] ; - StripPos[0] = StripPositionX[ff][StripMax-1][0]; - - if(Buffer_X_Q[StripMax-2][ff]!=-1){ - Q[1] = Buffer_X_Q[StripMax-2][ff]; - StripPos[1] = StripPositionX[ff][StripMax-2][0]; - } - - else { - if(Buffer_X_Q[StripMax-3][ff]!=-1){ - Q[1] = Buffer_X_Q[StripMax-3][ff]; - StripPos[1] = StripPositionX[ff][StripMax-3][0]; - } - else { - if(Buffer_X_Q[StripMax-4][ff]!=-1){ - Q[1] = Buffer_X_Q[StripMax-4][ff]; - StripPos[1] = StripPositionX[ff][StripMax-4][0]; - } - } - } - - if(Buffer_X_Q[StripMax][ff]!=-1){ - Q[2] = Buffer_X_Q[StripMax][ff]; - StripPos[2] = StripPositionX[ff][StripMax][0]; - } - else { - if(Buffer_X_Q[StripMax+1][ff]!=-1){ - Q[2] = Buffer_X_Q[StripMax+1][ff]; - StripPos[2] = StripPositionX[ff][StripMax+1][0]; - } - else { - if(Buffer_X_Q[StripMax+2][ff]!=-1){ - Q[2] = Buffer_X_Q[StripMax+2][ff]; - StripPos[2] = StripPositionX[ff][StripMax+2][0]; - } - } - } - - double Q0_Q1 = log(Q[0]/Q[1]); - double Q0_Q2 = log(Q[0]/Q[2]); - - double num = Q0_Q1 * (StripPos[2]*StripPos[2] - StripPos[0]*StripPos[0]) - Q0_Q2 * (StripPos[1]*StripPos[1] - StripPos[0]*StripPos[0]) ; - double denom = Q0_Q1 * (StripPos[2] - StripPos[0]) - Q0_Q2 * (StripPos[1] - StripPos[0]) ; - if(denom != 0){ - gauss = 0.5*num / denom; - } - else{gauss = -1000;} + int StripMax = StripMaxX[ff]; + double gauss = -1000; + double Q[3]; + double StripPos[3]; + + for(int j = 0; j<3 ; j++) + { + Q[j] = 0; + StripPos[j] = 0; + } + + + if(StripMaxX[ff]> 3 && StripMaxX[ff]< 26) + { + Q[0] = Buffer_X_Q[StripMax-1][ff] ; + StripPos[0] = StripPositionX[ff][StripMax-1][0]; + if(Buffer_X_Q[StripMax-2][ff]!=-1){ + Q[1] = Buffer_X_Q[StripMax-2][ff]; + StripPos[1] = StripPositionX[ff][StripMax-2][0]; + } + + else { + if(Buffer_X_Q[StripMax-3][ff]!=-1){ + Q[1] = Buffer_X_Q[StripMax-3][ff]; + StripPos[1] = StripPositionX[ff][StripMax-3][0]; + } + else { + if(Buffer_X_Q[StripMax-4][ff]!=-1){ + Q[1] = Buffer_X_Q[StripMax-4][ff]; + StripPos[1] = StripPositionX[ff][StripMax-4][0]; + } + } } + if(Buffer_X_Q[StripMax][ff]!=-1){ + Q[2] = Buffer_X_Q[StripMax][ff]; + StripPos[2] = StripPositionX[ff][StripMax][0]; + } + else { + if(Buffer_X_Q[StripMax+1][ff]!=-1){ + Q[2] = Buffer_X_Q[StripMax+1][ff]; + StripPos[2] = StripPositionX[ff][StripMax+1][0]; + } + else { + if(Buffer_X_Q[StripMax+2][ff]!=-1){ + Q[2] = Buffer_X_Q[StripMax+2][ff]; + StripPos[2] = StripPositionX[ff][StripMax+2][0]; + } + } + } + + double Q0_Q1 = log(Q[0]/Q[1]); + double Q0_Q2 = log(Q[0]/Q[2]); + + double num = Q0_Q1 * (StripPos[2]*StripPos[2] - StripPos[0]*StripPos[0]) - Q0_Q2 * (StripPos[1]*StripPos[1] - StripPos[0]*StripPos[0]) ; + double denom = Q0_Q1 * (StripPos[2] - StripPos[0]) - Q0_Q2 * (StripPos[1] - StripPos[0]) ; + if(denom != 0){ + gauss = 0.5*num / denom; + } + else{gauss = -1000;} + + } + else { gauss = -1000; } return gauss; - + } ///////////////////////////////////////////////////////////////////////// double TCATSPhysics::Corrected3PointsX(double Position, double c) { - double Corrected_Position = 0; - int StripMax_ = StripMaxX[ff] -1; - double xmax = StripPositionX[ff][StripMax_][0] ; - - Corrected_Position = (Position - xmax) / c + xmax; - - return Corrected_Position; + double Corrected_Position = 0; + int StripMax_ = StripMaxX[ff] -1; + double xmax = StripPositionX[ff][StripMax_][0] ; + + Corrected_Position = (Position - xmax) / c + xmax; + + return Corrected_Position; } ///////////////////////////////////////////////////////////////////////// double TCATSPhysics::Corrected4PointsX(double Position, double d) { - double Corrected_Position = 0; - double xmax = 0; - int StripMax_ = StripMaxX[ff] -1; - - if(Buffer_X_Q[StripMax_+1][ff] > Buffer_X_Q[StripMax_-1][ff]) { - if(ff==0) xmax = StripPositionX[ff][StripMax_][0] - 1.27; - else xmax = StripPositionX[ff][StripMax_][0] + 1.27; - } - - else{ - if(ff==0) xmax = StripPositionX[ff][StripMax_-1][0] - 1.27; - else xmax = StripPositionX[ff][StripMax_-1][0] + 1.27; - } - - Corrected_Position = (Position - xmax) / d + xmax; - - return Corrected_Position; + double Corrected_Position = 0; + double xmax = 0; + int StripMax_ = StripMaxX[ff] -1; + + if(Buffer_X_Q[StripMax_+1][ff] > Buffer_X_Q[StripMax_-1][ff]) { + if(ff==0) xmax = StripPositionX[ff][StripMax_][0] - 1.27; + else xmax = StripPositionX[ff][StripMax_][0] + 1.27; + } + + else{ + if(ff==0) xmax = StripPositionX[ff][StripMax_-1][0] - 1.27; + else xmax = StripPositionX[ff][StripMax_-1][0] + 1.27; + } + + Corrected_Position = (Position - xmax) / d + xmax; + + return Corrected_Position; } //////////////////////////////////////////////////////////////////////////// double TCATSPhysics:: GaussianMethodY() { - double Q[3]; - double StripPos[3]; - double Q0_Q1, Q0_Q2; - double num, denom; - - for(int j = 0; j<3 ; j++) - { - Q[j] = 0; - StripPos[j] = 0; - } - - int StripMax = StripMaxY[ff]; - - double gauss = -1000; - - if(StripMaxY[ff] > 2 && StripMaxY[ff]<27) - { - Q[0] = Buffer_Y_Q[StripMax-1][ff] ; - StripPos[0] = StripPositionY[ff][0][StripMax-1]; - - if(Buffer_Y_Q[StripMax-2][ff]!=-1){ - Q[1] = Buffer_Y_Q[StripMax-2][ff]; - StripPos[1] = StripPositionY[ff][0][StripMax-2]; - } - - else { - if(Buffer_Y_Q[StripMax-3][ff]!=-1){ - Q[1] = Buffer_Y_Q[StripMax-3][ff]; - StripPos[1] = StripPositionY[ff][0][StripMax-3] ; - } - else { - if(Buffer_Y_Q[StripMax-4][ff]!=-1){ - Q[1] = Buffer_Y_Q[StripMax-4][ff]; - StripPos[1] = StripPositionY[ff][0][StripMax-4] ; - } - } - } - - if(Buffer_Y_Q[StripMax][ff]!=-1){ - Q[2] = Buffer_Y_Q[StripMax][ff]; - StripPos[2] = StripPositionY[ff][0][StripMax]; - } - - else { - if(Buffer_Y_Q[StripMax+1][ff]!=-1){ - Q[2] = Buffer_Y_Q[StripMax+1][ff]; - StripPos[2] = StripPositionY[ff][0][StripMax+1] ; - } - - else { - if(Buffer_Y_Q[StripMax+2][ff]!=-1){ - Q[2] = Buffer_Y_Q[StripMax+2][ff]; - StripPos[2] = StripPositionY[ff][0][StripMax+2] ; - } - } - } - - - - Q0_Q1 = log(Q[0]/Q[1]); - Q0_Q2 = log(Q[0]/Q[2]); - - num = Q0_Q1 * (StripPos[2]*StripPos[2] - StripPos[0]*StripPos[0]) - Q0_Q2 * (StripPos[1]*StripPos[1] - StripPos[0]*StripPos[0]) ; - denom = Q0_Q1 * (StripPos[2] - StripPos[0]) - Q0_Q2 * (StripPos[1] - StripPos[0]) ; - if(denom != 0){ - gauss = 0.5*num / denom; - } + double Q[3]; + double StripPos[3]; + double Q0_Q1, Q0_Q2; + double num, denom; + + for(int j = 0; j<3 ; j++) + { + Q[j] = 0; + StripPos[j] = 0; + } + + int StripMax = StripMaxY[ff]; + double gauss = -1000; + + if(StripMaxY[ff] > 2 && StripMaxY[ff]<27) + { + Q[0] = Buffer_Y_Q[StripMax-1][ff] ; + StripPos[0] = StripPositionY[ff][0][StripMax-1]; + + if(Buffer_Y_Q[StripMax-2][ff]!=-1){ + Q[1] = Buffer_Y_Q[StripMax-2][ff]; + StripPos[1] = StripPositionY[ff][0][StripMax-2]; + } + + else { + if(Buffer_Y_Q[StripMax-3][ff]!=-1){ + Q[1] = Buffer_Y_Q[StripMax-3][ff]; + StripPos[1] = StripPositionY[ff][0][StripMax-3] ; + } + else { + if(Buffer_Y_Q[StripMax-4][ff]!=-1){ + Q[1] = Buffer_Y_Q[StripMax-4][ff]; + StripPos[1] = StripPositionY[ff][0][StripMax-4] ; + } + } } + if(Buffer_Y_Q[StripMax][ff]!=-1){ + Q[2] = Buffer_Y_Q[StripMax][ff]; + StripPos[2] = StripPositionY[ff][0][StripMax]; + } + + else { + if(Buffer_Y_Q[StripMax+1][ff]!=-1){ + Q[2] = Buffer_Y_Q[StripMax+1][ff]; + StripPos[2] = StripPositionY[ff][0][StripMax+1] ; + } + + else { + if(Buffer_Y_Q[StripMax+2][ff]!=-1){ + Q[2] = Buffer_Y_Q[StripMax+2][ff]; + StripPos[2] = StripPositionY[ff][0][StripMax+2] ; + } + } + } + + + + Q0_Q1 = log(Q[0]/Q[1]); + Q0_Q2 = log(Q[0]/Q[2]); + + num = Q0_Q1 * (StripPos[2]*StripPos[2] - StripPos[0]*StripPos[0]) - Q0_Q2 * (StripPos[1]*StripPos[1] - StripPos[0]*StripPos[0]) ; + denom = Q0_Q1 * (StripPos[2] - StripPos[0]) - Q0_Q2 * (StripPos[1] - StripPos[0]) ; + if(denom != 0){ + gauss = 0.5*num / denom; + } + + } + else { gauss = -1000; } return gauss; - + } ///////////////////////////////////////////////////////////////////////// double TCATSPhysics::Corrected3PointsY(double Position, double c) { - double Corrected_Position = 0; - int StripMax_ = StripMaxY[ff] -1; - double ymax = StripPositionY[ff][0][StripMax_] ; - - Corrected_Position = (Position - ymax) / c + ymax; - - return Corrected_Position; + double Corrected_Position = 0; + int StripMax_ = StripMaxY[ff] -1; + double ymax = StripPositionY[ff][0][StripMax_] ; + + Corrected_Position = (Position - ymax) / c + ymax; + + return Corrected_Position; } ///////////////////////////////////////////////////////////////////////// double TCATSPhysics::Corrected4PointsY(double Position, double d) { - double Corrected_Position = 0; - double ymax = 0; - int StripMax_ = StripMaxY[ff] -1; - - if(Buffer_Y_Q[StripMax_+1][ff] > Buffer_Y_Q[StripMax_-1][ff]) { - ymax = StripPositionY[ff][0][StripMax_] + 1.27 ; - } - - else{ - ymax = StripPositionY[ff][0][StripMax_-1] + 1.27; - } - - Corrected_Position = (Position - ymax) / d + ymax; - - return Corrected_Position; + double Corrected_Position = 0; + double ymax = 0; + int StripMax_ = StripMaxY[ff] -1; + + if(Buffer_Y_Q[StripMax_+1][ff] > Buffer_Y_Q[StripMax_-1][ff]) { + ymax = StripPositionY[ff][0][StripMax_] + 1.27 ; + } + + else{ + ymax = StripPositionY[ff][0][StripMax_-1] + 1.27; + } + + Corrected_Position = (Position - ymax) / d + ymax; + + return Corrected_Position; } /////////////////////////////////////////////////////////////// double TCATSPhysics:: Barycentric5MethodX() { double Barycenter = 0 ; - + if(StripMaxX[ff] > 2 && StripMaxX[ff] < 27) + { + int StripMax_ = StripMaxX[ff] -1 ; + double NumberOfPoint = 0 ; + double ChargeTotal =0; + + + for(int i = -2 ; i < 3 ; i++) { - int StripMax_ = StripMaxX[ff] -1 ; - double NumberOfPoint = 0 ; - double ChargeTotal =0; - - - for(int i = -2 ; i < 3 ; i++) - { - if(Buffer_X_Q[StripMax_+i][ff]!=-1) - { - Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; - } - } - - if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; - else {Barycenter = -1000 ; } - + if(Buffer_X_Q[StripMax_+i][ff]!=-1) + { + Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; + } } + + if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; + else {Barycenter = -1000 ; } + + } else - { - Barycenter = -1000 ; - } - + { + Barycenter = -1000 ; + } + return Barycenter ; } @@ -1254,34 +1260,34 @@ double TCATSPhysics:: Barycentric5MethodX() double TCATSPhysics:: Barycentric5MethodY() { double Barycenter = 0 ; - + if(StripMaxY[ff] > 2 && StripMaxY[ff] < 27) + { + int StripMax_ = StripMaxY[ff] -1 ; + double NumberOfPoint = 0 ; + double ChargeTotal =0; + + + for(int i = -2 ; i < 3 ; i++) { - int StripMax_ = StripMaxY[ff] -1 ; - double NumberOfPoint = 0 ; - double ChargeTotal =0; - - - for(int i = -2 ; i < 3 ; i++) - { - if(Buffer_Y_Q[StripMax_+i][ff]!=-1) - { - Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; - } - } - - if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; - else {Barycenter = -1000 ; } // cout << "Yo" << endl ;} - - } - else - { - Barycenter = -1000 ; + if(Buffer_Y_Q[StripMax_+i][ff]!=-1) + { + Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; + } } - - return Barycenter ; + + if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; + else {Barycenter = -1000 ; } // cout << "Yo" << endl ;} + +} +else +{ + Barycenter = -1000 ; +} + +return Barycenter ; } /////////////////////////////////////////////////////////// @@ -1289,235 +1295,235 @@ double TCATSPhysics:: Barycentric5MethodY() /////////////////////////////////////////////////////////////// double TCATSPhysics:: Barycentric3MethodX() { - double Barycenter = 0 ; - - if(StripMaxX[ff] > 2 && StripMaxX[ff] < 27) - { - int StripMax_ = StripMaxX[ff] -1; - double NumberOfPoint = 0 ; - double ChargeTotal =0; - - for(int i = -1 ; i < 2 ; i++) - { - if(Buffer_X_Q[StripMax_+i][ff]!=-1) // Charge initialized to -1 - { - Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; - } - } - - if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; - else {Barycenter = -1000 ;} // cout << "Yo" << endl ;} - } - - - else + double Barycenter = 0 ; + + if(StripMaxX[ff] > 2 && StripMaxX[ff] < 27) + { + int StripMax_ = StripMaxX[ff] -1; + double NumberOfPoint = 0 ; + double ChargeTotal =0; + + for(int i = -1 ; i < 2 ; i++) { - Barycenter = -1000 ; + if(Buffer_X_Q[StripMax_+i][ff]!=-1) // Charge initialized to -1 + { + Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; + } } - - return Barycenter ; + + if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; + else {Barycenter = -1000 ;} // cout << "Yo" << endl ;} +} + + +else +{ + Barycenter = -1000 ; +} + +return Barycenter ; } /////////////////////////////////////////////////////////////// double TCATSPhysics:: Barycentric3MethodY() { - double Barycenter = 0 ; - - if(StripMaxY[ff] > 2 && StripMaxY[ff] < 27) - { - int StripMax_ = StripMaxY[ff] -1 ; // Use because numerotation of array start at 0 ; - double NumberOfPoint = 0 ; - double ChargeTotal =0; - - for(int i = -1 ; i < 2 ; i++) - { - if(Buffer_Y_Q[StripMax_+i][ff]!=-1) // Charge initialized to -1 - { - Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; - } - } - - if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; - else {Barycenter = -1000 ;} // cout << "Yo" << endl ;} - } - - else + double Barycenter = 0 ; + + if(StripMaxY[ff] > 2 && StripMaxY[ff] < 27) + { + int StripMax_ = StripMaxY[ff] -1 ; // Use because numerotation of array start at 0 ; + double NumberOfPoint = 0 ; + double ChargeTotal =0; + + for(int i = -1 ; i < 2 ; i++) { - Barycenter = -1000 ; - // cout << "Strip max " << StripMax << endl; + if(Buffer_Y_Q[StripMax_+i][ff]!=-1) // Charge initialized to -1 + { + Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; + } } - - return Barycenter ; + + if(ChargeTotal>0) Barycenter = Barycenter / ChargeTotal ; + else {Barycenter = -1000 ;} // cout << "Yo" << endl ;} +} + +else +{ + Barycenter = -1000 ; + // cout << "Strip max " << StripMax << endl; +} + +return Barycenter ; } /////////////////////////////////////////////////////////////// double TCATSPhysics:: Barycentric4MethodX() { - double Barycenter = 0 ; - - if(StripMaxX[ff] > 2 && StripMaxX[ff] < 27) { - - int StripMax_ = StripMaxX[ff] -1 ; // Use because numerotation of array start at 0 ; - double NumberOfPoint = 0 ; - double ChargeTotal =0; - - if(Buffer_X_Q[StripMax_+1][ff] > Buffer_X_Q[StripMax_-1][ff]) { - - // cout << "Barycentre droit" << endl; - for(int i = -1 ; i < 3 ; i++) - { - if(Buffer_X_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 - Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; - } - } - } - - else { - // cout << "Barycentre gauche" << endl; - for(int i = -2 ; i < 2 ; i++) - { - if(Buffer_X_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 - Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; - } - } - } - - if(ChargeTotal>0) { - Barycenter = Barycenter / ChargeTotal ; - } - - } - - else - { - Barycenter = -1000 ; - // cout << "Strip max " << StripMax << endl; + double Barycenter = 0 ; + + if(StripMaxX[ff] > 2 && StripMaxX[ff] < 27) { + + int StripMax_ = StripMaxX[ff] -1 ; // Use because numerotation of array start at 0 ; + double NumberOfPoint = 0 ; + double ChargeTotal =0; + + if(Buffer_X_Q[StripMax_+1][ff] > Buffer_X_Q[StripMax_-1][ff]) { + + // cout << "Barycentre droit" << endl; + for(int i = -1 ; i < 3 ; i++) + { + if(Buffer_X_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 + Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; + } + } + } + + else { + // cout << "Barycentre gauche" << endl; + for(int i = -2 ; i < 2 ; i++) + { + if(Buffer_X_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 + Barycenter += (StripMaxX[ff]+i)*Buffer_X_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_X_Q[StripMax_+i][ff]; + } + } } - - return Barycenter ; + + if(ChargeTotal>0) { + Barycenter = Barycenter / ChargeTotal ; + } + + } + + else + { + Barycenter = -1000 ; + // cout << "Strip max " << StripMax << endl; + } + + return Barycenter ; } /////////////////////////////////////////////////////////////// double TCATSPhysics:: Barycentric4MethodY() { - double Barycenter = 0 ; - - if(StripMaxY[ff] > 2 && StripMaxY[ff] < 27) { - - int StripMax_ = StripMaxY[ff] -1 ; // Use because numerotation of array start at 0 ; - double NumberOfPoint = 0 ; - double ChargeTotal =0; - - if(Buffer_Y_Q[StripMax_+1][ff] > Buffer_Y_Q[StripMax_-1][ff]) { - - // cout << "Barycentre droit" << endl; - for(int i = -1 ; i < 3 ; i++) - { - if(Buffer_Y_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 - Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; - } - } - } - - else { - // cout << "Barycentre gauche" << endl; - for(int i = -2 ; i < 2 ; i++) - { - if(Buffer_Y_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 - Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; - NumberOfPoint++; - ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; - } - } - } - - if(ChargeTotal>0) { - Barycenter = Barycenter / ChargeTotal ; - } - - } - - else - { - Barycenter = -1000 ; - // cout << "Strip max " << StripMax << endl; + double Barycenter = 0 ; + + if(StripMaxY[ff] > 2 && StripMaxY[ff] < 27) { + + int StripMax_ = StripMaxY[ff] -1 ; // Use because numerotation of array start at 0 ; + double NumberOfPoint = 0 ; + double ChargeTotal =0; + + if(Buffer_Y_Q[StripMax_+1][ff] > Buffer_Y_Q[StripMax_-1][ff]) { + + // cout << "Barycentre droit" << endl; + for(int i = -1 ; i < 3 ; i++) + { + if(Buffer_Y_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 + Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; + } + } + } + + else { + // cout << "Barycentre gauche" << endl; + for(int i = -2 ; i < 2 ; i++) + { + if(Buffer_Y_Q[StripMax_+i][ff]!=-1) { // Charge initialized to -1 + Barycenter += (StripMaxY[ff]+i)*Buffer_Y_Q[StripMax_+i][ff] ; + NumberOfPoint++; + ChargeTotal+=Buffer_Y_Q[StripMax_+i][ff]; + } + } } - - return Barycenter ; + + if(ChargeTotal>0) { + Barycenter = Barycenter / ChargeTotal ; + } + + } + + else + { + Barycenter = -1000 ; + // cout << "Strip max " << StripMax << endl; + } + + return Barycenter ; } ///////////////////////////////////////////////////////////////////// double TCATSPhysics:: HyperbolicSequentMethodX() { - double sechs = -1000 ; - - if(StripMaxX[ff] > 2 && StripMaxX[ff]<27) - { - double vs1 = sqrt( Buffer_X_Q[StripMaxX[ff]-1][ff]/Buffer_X_Q[StripMaxX[ff]-1+1][ff] ) ; - double vs2 = sqrt( Buffer_X_Q[StripMaxX[ff]-1][ff]/Buffer_X_Q[StripMaxX[ff]-1-1][ff] ) ; - double vs3 = 0.5*( vs1 + vs2 ) ; - double vs4 = log( vs3 + sqrt(vs3*vs3-1.0) ) ; - double vs5 = (vs1 - vs2)/(2.0*sinh(vs4)) ; - - if(vs5<0) vs5=-vs5 ; - - double vs6 = 0.5*log( (1.0+vs5)/(1.0-vs5) ) ; - - if ( Buffer_X_Q[StripMaxX[ff]-1+1][ff]>Buffer_X_Q[StripMaxX[ff]-1-1][ff] ) - { sechs = StripMaxX[ff] + vs6/vs4 ;} - - else - { sechs = StripMaxX[ff] - vs6/vs4 ;} - - } - - else { - sechs = -1000; - } - - return sechs ; + double sechs = -1000 ; + + if(StripMaxX[ff] > 2 && StripMaxX[ff]<27) + { + double vs1 = sqrt( Buffer_X_Q[StripMaxX[ff]-1][ff]/Buffer_X_Q[StripMaxX[ff]-1+1][ff] ) ; + double vs2 = sqrt( Buffer_X_Q[StripMaxX[ff]-1][ff]/Buffer_X_Q[StripMaxX[ff]-1-1][ff] ) ; + double vs3 = 0.5*( vs1 + vs2 ) ; + double vs4 = log( vs3 + sqrt(vs3*vs3-1.0) ) ; + double vs5 = (vs1 - vs2)/(2.0*sinh(vs4)) ; + + if(vs5<0) vs5=-vs5 ; + + double vs6 = 0.5*log( (1.0+vs5)/(1.0-vs5) ) ; + + if ( Buffer_X_Q[StripMaxX[ff]-1+1][ff]>Buffer_X_Q[StripMaxX[ff]-1-1][ff] ) + { sechs = StripMaxX[ff] + vs6/vs4 ;} + + else + { sechs = StripMaxX[ff] - vs6/vs4 ;} + + } + + else { + sechs = -1000; + } + + return sechs ; } ////////////////////////////////////////////////////////////////// double TCATSPhysics:: HyperbolicSequentMethodY() { - double sechs = -1000 ; - - if(StripMaxY[ff] > 2 && StripMaxY[ff]<27) - { - double vs1 = sqrt( Buffer_Y_Q[StripMaxY[ff]-1][ff]/Buffer_Y_Q[StripMaxY[ff]-1+1][ff] ) ; - double vs2 = sqrt( Buffer_Y_Q[StripMaxY[ff]-1][ff]/Buffer_Y_Q[StripMaxY[ff]-1-1][ff] ) ; - double vs3 = 0.5*( vs1 + vs2 ) ; - double vs4 = log( vs3 + sqrt(vs3*vs3-1.0) ) ; - double vs5 = (vs1 - vs2)/(2.0*sinh(vs4)) ; - - if(vs5<0) vs5=-vs5 ; - - double vs6 = 0.5*log( (1.0+vs5)/(1.0-vs5) ) ; - - if ( Buffer_Y_Q[StripMaxY[ff]-1+1][ff]>Buffer_Y_Q[StripMaxY[ff]-1-1][ff] ) - { sechs = StripMaxY[ff] + vs6/vs4 ;} - - else - { sechs = StripMaxY[ff] - vs6/vs4 ;} - - } - - else { - sechs = -1000; - } - - return sechs ; + double sechs = -1000 ; + + if(StripMaxY[ff] > 2 && StripMaxY[ff]<27) + { + double vs1 = sqrt( Buffer_Y_Q[StripMaxY[ff]-1][ff]/Buffer_Y_Q[StripMaxY[ff]-1+1][ff] ) ; + double vs2 = sqrt( Buffer_Y_Q[StripMaxY[ff]-1][ff]/Buffer_Y_Q[StripMaxY[ff]-1-1][ff] ) ; + double vs3 = 0.5*( vs1 + vs2 ) ; + double vs4 = log( vs3 + sqrt(vs3*vs3-1.0) ) ; + double vs5 = (vs1 - vs2)/(2.0*sinh(vs4)) ; + + if(vs5<0) vs5=-vs5 ; + + double vs6 = 0.5*log( (1.0+vs5)/(1.0-vs5) ) ; + + if ( Buffer_Y_Q[StripMaxY[ff]-1+1][ff]>Buffer_Y_Q[StripMaxY[ff]-1-1][ff] ) + { sechs = StripMaxY[ff] + vs6/vs4 ;} + + else + { sechs = StripMaxY[ff] - vs6/vs4 ;} + + } + + else { + sechs = -1000; + } + + return sechs ; } @@ -1530,7 +1536,7 @@ double TCATSPhysics::CorrectedPositionX3(double Position, double a) double xmax = StripPositionX[ff][StripMax_][0] ; Corrected_Position = (Position - xmax) / a + xmax; - + return Corrected_Position; } @@ -1542,7 +1548,7 @@ double TCATSPhysics::CorrectedPositionY3(double Position, double a) double xmax = StripPositionY[ff][0][StripMax_]; Corrected_Position = (Position - xmax) / a + xmax; - + return Corrected_Position; } @@ -1557,7 +1563,7 @@ double TCATSPhysics::CorrectedPositionX4(double Position, double b) if(ff ==0) xmax = StripPositionX[ff][StripMax_][0] - 1.27; else xmax = StripPositionX[ff][StripMax_][0] + 1.27; } - + else{ if(ff ==0) xmax = StripPositionX[ff][StripMax_-1][0] - 1.27; else xmax = StripPositionX[ff][StripMax_-1][0] + 1.27; @@ -1593,8 +1599,8 @@ double TCATSPhysics::CorrectedPositionY4(double Position, double b) TVector3 TCATSPhysics::GetBeamDirection() { TVector3 Position = TVector3 (PositionX[1]-PositionX[0] , - PositionY[1]-PositionY[0] , - PositionZ[1]-PositionZ[0] ); + PositionY[1]-PositionY[0] , + PositionZ[1]-PositionZ[0] ); Position.Unit(); return(Position) ; } @@ -1602,63 +1608,63 @@ TVector3 TCATSPhysics::GetBeamDirection() /////////////////////////////////////////////////////////////// TVector3 TCATSPhysics::GetPositionOnTarget() { - double Pi = 3.14159265; - TVector3 Position = TVector3 (GetPositionOnTargetX() , - GetPositionOnTargetY() , - GetPositionOnTargetX()*tan(m_TargetAngle*Pi/180)); - Position.Unit(); - return(Position) ; + double Pi = 3.14159265; + TVector3 Position = TVector3 (GetPositionOnTargetX() , + GetPositionOnTargetY() , + GetPositionOnTargetX()*tan(m_TargetAngle*Pi/180)); + Position.Unit(); + return(Position) ; } //////////////////////////////////////////////////////////////////////// namespace LOCAL_CATS { // transform an integer to a string - string itoa(int value) - { - std::ostringstream o; - - if (!(o << value)) - return "" ; - - return o.str(); - } - - double fCATS_X_Q(const TCATSData* m_EventData , const int i) - { - return CalibrationManager::getInstance()->ApplyCalibration( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ) + "_Q", - m_EventData->GetCATSChargeX(i) + gRandom->Rndm() - fCATS_Ped_X(m_EventData, i) ); - } - - double fCATS_Y_Q(const TCATSData* m_EventData , const int i) - { - return CalibrationManager::getInstance()->ApplyCalibration( "CATS/D" + itoa( m_EventData->GetCATSDetY(i) ) + "_Y" + itoa( m_EventData->GetCATSStripY(i) ) + "_Q", - m_EventData->GetCATSChargeY(i) + gRandom->Rndm() - fCATS_Ped_Y(m_EventData, i) ); - } - - bool fCATS_Threshold_X(const TCATSData* m_EventData , const int i) - { - return CalibrationManager::getInstance()->ApplyThreshold( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ), - m_EventData->GetCATSChargeX(i)); - } - - bool fCATS_Threshold_Y(const TCATSData* m_EventData , const int i) - { - return CalibrationManager::getInstance()->ApplyThreshold( "CATS/D" + itoa( m_EventData->GetCATSDetY(i) ) + "_Y" + itoa( m_EventData->GetCATSStripY(i) ), - m_EventData->GetCATSChargeY(i)); - } - - double fCATS_Ped_X(const TCATSData* m_EventData, const int i) - { - return CalibrationManager::getInstance()->GetPedestal( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ) ); - } - - double fCATS_Ped_Y(const TCATSData* m_EventData, const int i) - { - return CalibrationManager::getInstance()->GetPedestal( "CATS/D" + itoa( m_EventData->GetCATSDetY(i) ) + "_Y" + itoa( m_EventData->GetCATSStripY(i) ) ); - } - - + string itoa(int value) + { + std::ostringstream o; + + if (!(o << value)) + return "" ; + + return o.str(); + } + + double fCATS_X_Q(const TCATSData* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyCalibration( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ) + "_Q", + m_EventData->GetCATSChargeX(i) + gRandom->Rndm() - fCATS_Ped_X(m_EventData, i) ); + } + + double fCATS_Y_Q(const TCATSData* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyCalibration( "CATS/D" + itoa( m_EventData->GetCATSDetY(i) ) + "_Y" + itoa( m_EventData->GetCATSStripY(i) ) + "_Q", + m_EventData->GetCATSChargeY(i) + gRandom->Rndm() - fCATS_Ped_Y(m_EventData, i) ); + } + + bool fCATS_Threshold_X(const TCATSData* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyThreshold( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ), + m_EventData->GetCATSChargeX(i)); + } + + bool fCATS_Threshold_Y(const TCATSData* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyThreshold( "CATS/D" + itoa( m_EventData->GetCATSDetY(i) ) + "_Y" + itoa( m_EventData->GetCATSStripY(i) ), + m_EventData->GetCATSChargeY(i)); + } + + double fCATS_Ped_X(const TCATSData* m_EventData, const int i) + { + return CalibrationManager::getInstance()->GetPedestal( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ) ); + } + + double fCATS_Ped_Y(const TCATSData* m_EventData, const int i) + { + return CalibrationManager::getInstance()->GetPedestal( "CATS/D" + itoa( m_EventData->GetCATSDetY(i) ) + "_Y" + itoa( m_EventData->GetCATSStripY(i) ) ); + } + + } diff --git a/NPLib/CATS/TCATSPhysics.h b/NPLib/CATS/TCATSPhysics.h index 9d135fce2f61d9611e3bdf18c98c9393896154bb..a7394fcacf2c9e64a8428fe9653a5c8e8756487b 100644 --- a/NPLib/CATS/TCATSPhysics.h +++ b/NPLib/CATS/TCATSPhysics.h @@ -31,6 +31,7 @@ #include <TRandom3.h> // NPLib #include "TCATSData.h" +#include "TCATSSpectra.h" #include "../include/VDetector.h" #include "../include/CalibrationManager.h" #include "../include/DetectorManager.h" @@ -38,6 +39,8 @@ #define NBDETECTOR 2 #define NBSTRIPS 28 +// forward declaration +class TCATSSpectra; using namespace std ; enum reconstruction{NO,SECHS,GAUSS,BAR3,BAR4,BAR5}; @@ -45,193 +48,209 @@ enum correction{NOcor,cor}; class TCATSPhysics : public TObject, public NPA::VDetector { - - public: // Constructor and Destructor - TCATSPhysics(); - ~TCATSPhysics(); - - private: // Root Input and Output tree classes - - TCATSData* m_EventData;//! - TCATSData* m_PreTreatedData;//! - TCATSPhysics* m_EventPhysics;//! - - public : - // marker of the cats used - int ff ; - - // Vector of dim = multiplicity of event on all detector - vector<int> DetNumberX; - vector<int> StripX; - vector<double> ChargeX; - - // Vector of dim = number of CATS - vector<int> StripMaxX; - - - // Vector of dim = multiplicity of event on all detector - vector<int> DetNumberY; - vector<int> StripY; - vector<double> ChargeY; - - // Vector of dim = number of CATS - vector<int> StripMaxY; - - // Vector of dim = number of CATS - vector<int> DetNumberX_Position; - vector<int> DetNumberY_Position; - vector<int> DetNumberZ_Position; - vector<double> PositionX; - vector<double> PositionY; - vector<double> PositionZ; - vector<double> QsumX; - vector<double> QsumY; - double PositionOnTargetX; - double PositionOnTargetY; - - TVector3 BeamDirection ; //! - - double Buffer_X_Q[NBSTRIPS][NBDETECTOR];//! - double Buffer_Y_Q[NBSTRIPS][NBDETECTOR];//! - - int HitX; //! - int HitY; //! - - vector<reconstruction> ReconstructionMethodX; - vector<reconstruction> ReconstructionMethodY; - - - private : - vector< vector< vector<double> > > StripPositionX;//! - vector< vector< vector<double> > > StripPositionY;//! - vector<double> StripPositionZ;//! - int m_NumberOfCATS; - double m_TargetAngle; - double m_TargetThickness; - double m_CorrectionCoef_CATS1X;//! - double m_CorrectionCoef_CATS1Y;//! - double m_CorrectionCoef_CATS2X;//! - double m_CorrectionCoef_CATS2Y;//! - - - string m_correction_CATS1X;//! - string m_correction_CATS1Y;//! - string m_correction_CATS2X;//! - string m_correction_CATS2Y;//! - - string m_reconstruction_CATS1X;//! - string m_reconstruction_CATS1Y;//! - string m_reconstruction_CATS2X;//! - string m_reconstruction_CATS2Y;//! - reconstruction m_method_CATS1X;//! - reconstruction m_method_CATS1Y;//! - reconstruction m_method_CATS2X;//! - reconstruction m_method_CATS2Y;//! - - private : - // Map of activated channel - map< int, vector<bool> > m_XChannelStatus;//! - map< int, vector<bool> > m_YChannelStatus;//! - // Map of inverted channel - map< int, vector<int> > m_CATSXInversion;//! - map< int, vector<int> > m_CATSYInversion;//! - - public: // Output data of interest - // for a CATS - void SetTargetAngle(double TargetAngle) {m_TargetAngle = TargetAngle;} - void SetTargetThickness(double TargetThickness) {m_TargetThickness = TargetThickness;} - - - // Remove bad channel, calibrate the data and apply threshold - void PreTreat(); - - // 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() ; - - // Clear The PreTeated object - void ClearPreTreatedData() {m_PreTreatedData->Clear();} - - void BuildPhysicalEvent(); - - void BuildSimplePhysicalEvent(); - - // Same as above but for online analysis - void BuildOnlinePhysicalEvent() {BuildSimplePhysicalEvent();}; - - // Those two method all to clear the Event Physics or Data - void ClearEventPhysics() {Clear();} - void ClearEventData() {m_EventData->Clear();} - - void Clear(); - void Clear(const Option_t*) {}; - - // Give and external TCATSData object to TCATSPhysics, needed for online analysis - void SetRawDataPointer(TCATSData* rawDataPointer) {m_EventData = rawDataPointer;} - - // Return false if the channel is disabled by user - bool IsValidChannel(const string DetectorType, const int Detector , const int channel); - - void InitializeStandardParameter(); - - void AddParameterToCalibrationManager(); - - void ReadAnalysisConfig(); - - void ReadConfiguration(string); - - void AddCATS(TVector3 C_X1_Y1, TVector3 C_X28_Y1, TVector3 C_X1_Y28, TVector3 C_X28_Y28); - - double AnalyseX(int ff); - - double AnalyseY(int ff); - - double CalculatePositionX( double CalculatedStripX, correction method); - - double CalculatePositionY( double CalculatedStripY, correction method); - - reconstruction ChooseReconstruction(int ff, TString type); - - reconstruction StringToEnum(string type); - - double CorrectedPositionX3(double Position, double a) ; - double CorrectedPositionY3(double Position, double a) ; - double CorrectedPositionX4(double Position, double b); - double CorrectedPositionY4(double Position, double b); - double Corrected3PointsX(double Position, double c); - double Corrected3PointsY(double Position, double c); - double Corrected4PointsX(double Position, double d); - double Corrected4PointsY(double Position, double d); - - - // Methode de reconstruction X - double HyperbolicSequentMethodX(); - double GaussianMethodX(); - double Barycentric5MethodX(); - double Barycentric4MethodX(); - double Barycentric3MethodX(); - - // Methode de Reconstruction Y - double HyperbolicSequentMethodY(); - double GaussianMethodY(); - double Barycentric5MethodY(); - double Barycentric4MethodY(); - double Barycentric3MethodY(); - - TVector3 GetBeamDirection(); - TVector3 GetPositionOnTarget(); - - double GetPositionOnTargetX() {return PositionOnTargetX;} - double GetPositionOnTargetY() {return PositionOnTargetY;} - - ClassDef(TCATSPhysics,1) // CATSPhysics structure + + public: // Constructor and Destructor + TCATSPhysics(); + ~TCATSPhysics(); + + private: // Root Input and Output tree classes + TCATSData* m_EventData;//! + TCATSData* m_PreTreatedData;//! + TCATSPhysics* m_EventPhysics;//! + + public : + // marker of the cats used + int ff ; + + // Vector of dim = multiplicity of event on all detector + vector<int> DetNumberX; + vector<int> StripX; + vector<double> ChargeX; + + // Vector of dim = number of CATS + vector<int> StripMaxX; + + + // Vector of dim = multiplicity of event on all detector + vector<int> DetNumberY; + vector<int> StripY; + vector<double> ChargeY; + + // Vector of dim = number of CATS + vector<int> StripMaxY; + + // Vector of dim = number of CATS + vector<int> DetNumberX_Position; + vector<int> DetNumberY_Position; + vector<int> DetNumberZ_Position; + vector<double> PositionX; + vector<double> PositionY; + vector<double> PositionZ; + vector<double> QsumX; + vector<double> QsumY; + double PositionOnTargetX; + double PositionOnTargetY; + + TVector3 BeamDirection ; //! + + double Buffer_X_Q[NBSTRIPS][NBDETECTOR];//! + double Buffer_Y_Q[NBSTRIPS][NBDETECTOR];//! + + int HitX; //! + int HitY; //! + + vector<reconstruction> ReconstructionMethodX; + vector<reconstruction> ReconstructionMethodY; + + + private : + vector< vector< vector<double> > > StripPositionX;//! + vector< vector< vector<double> > > StripPositionY;//! + vector<double> StripPositionZ;//! + int m_NumberOfCATS; + double m_TargetAngle; + double m_TargetThickness; + double m_CorrectionCoef_CATS1X;//! + double m_CorrectionCoef_CATS1Y;//! + double m_CorrectionCoef_CATS2X;//! + double m_CorrectionCoef_CATS2Y;//! + + + string m_correction_CATS1X;//! + string m_correction_CATS1Y;//! + string m_correction_CATS2X;//! + string m_correction_CATS2Y;//! + + string m_reconstruction_CATS1X;//! + string m_reconstruction_CATS1Y;//! + string m_reconstruction_CATS2X;//! + string m_reconstruction_CATS2Y;//! + reconstruction m_method_CATS1X;//! + reconstruction m_method_CATS1Y;//! + reconstruction m_method_CATS2X;//! + reconstruction m_method_CATS2Y;//! + + private : + // Map of activated channel + map< int, vector<bool> > m_XChannelStatus;//! + map< int, vector<bool> > m_YChannelStatus;//! + // Map of inverted channel + map< int, vector<int> > m_CATSXInversion;//! + map< int, vector<int> > m_CATSYInversion;//! + + public: // Output data of interest + // for a CATS + void SetTargetAngle(double TargetAngle) {m_TargetAngle = TargetAngle;} + void SetTargetThickness(double TargetThickness) {m_TargetThickness = TargetThickness;} + + + // Remove bad channel, calibrate the data and apply threshold + void PreTreat(); + + // 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() ; + + // Clear The PreTeated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + void BuildPhysicalEvent(); + + void BuildSimplePhysicalEvent(); + + // Same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildSimplePhysicalEvent();}; + + // 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(); + + void Clear(); + void Clear(const Option_t*) {}; + + // Give and external TCATSData object to TCATSPhysics, needed for online analysis + void SetRawDataPointer(TCATSData* rawDataPointer) {m_EventData = rawDataPointer;} + + // Return false if the channel is disabled by user + bool IsValidChannel(const string DetectorType, const int Detector , const int channel); + + void InitializeStandardParameter(); + + void AddParameterToCalibrationManager(); + + void ReadAnalysisConfig(); + + void ReadConfiguration(string); + + void AddCATS(TVector3 C_X1_Y1, TVector3 C_X28_Y1, TVector3 C_X1_Y28, TVector3 C_X28_Y28); + + double AnalyseX(int ff); + + double AnalyseY(int ff); + + double CalculatePositionX( double CalculatedStripX, correction method); + + double CalculatePositionY( double CalculatedStripY, correction method); + + reconstruction ChooseReconstruction(int ff, TString type); + + reconstruction StringToEnum(string type); + + double CorrectedPositionX3(double Position, double a) ; + double CorrectedPositionY3(double Position, double a) ; + double CorrectedPositionX4(double Position, double b); + double CorrectedPositionY4(double Position, double b); + double Corrected3PointsX(double Position, double c); + double Corrected3PointsY(double Position, double c); + double Corrected4PointsX(double Position, double d); + double Corrected4PointsY(double Position, double d); + + + // Methode de reconstruction X + double HyperbolicSequentMethodX(); + double GaussianMethodX(); + double Barycentric5MethodX(); + double Barycentric4MethodX(); + double Barycentric3MethodX(); + + // Methode de Reconstruction Y + double HyperbolicSequentMethodY(); + double GaussianMethodY(); + double Barycentric5MethodY(); + double Barycentric4MethodY(); + double Barycentric3MethodY(); + + TVector3 GetBeamDirection(); + TVector3 GetPositionOnTarget(); + + double GetPositionOnTargetX() {return PositionOnTargetX;} + double GetPositionOnTargetY() {return PositionOnTargetY;} + + private: // Spectra Class + TCATSSpectra* m_Spectra;//! + + public: // Spectra Getter + map< vector<TString> , TH1*> GetSpectra(); + + + ClassDef(TCATSPhysics,1) // CATSPhysics structure }; diff --git a/NPLib/CATS/TCATSSpectra.cxx b/NPLib/CATS/TCATSSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..580bcaf1970a377f4ded903aaba1526a320864cc --- /dev/null +++ b/NPLib/CATS/TCATSSpectra.cxx @@ -0,0 +1,362 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Tiara/Hyball * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// NPL +#include "TCATSSpectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + + +// ROOT +#include "TString.h" +#include "TDirectory.h" +#include "TFile.h" + + +//////////////////////////////////////////////////////////////////////////////// +TCATSSpectra::TCATSSpectra(){ + fNumberOfCats = 0; + fStripsNumber = 28; + + // An histo of size fEventLoopSize is reset every fEventLoopSize to monitor the + fEventLoopSize = 5000; + fEventLoopStep = 100; + fEventLoopIndex = 0; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TCATSSpectra::TCATSSpectra(unsigned int NumberOfCats){ + if (NPOptionManager::getInstance()->GetVerboseLevel() > 0) { + cout << "************************************************" << endl; + cout << "TCATSSpectra: Initalising control spectra for " << NumberOfCats << " detectors" << endl; + cout << "************************************************" << endl; + } + + fNumberOfCats = NumberOfCats; + fStripsNumber = 28; + // An histo of size fEventLoopSize is reset every fEventLoopSize to monitor the + fEventLoopSize = 10000; + fEventLoopStep = 1; + fEventLoopIndex = 0; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + + +//////////////////////////////////////////////////////////////////////////////// +TCATSSpectra::~TCATSSpectra(){ +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::InitRawSpectra(){ + TString name; + + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + // CATS_STRX_Q_RAW + name = Form("CATS%d_STRX_Q_RAW", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, "CATS/RAW/STRQ"); + + // CATS_STRY_Q_RAW + name = Form("CATS%d_STRY_Q_RAW", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, "CATS/RAW/STRQ"); + + // STRX_MULT + name = Form("CATS%d_STRX_MULT", i+1); + AddHisto1D(name, name, fStripsNumber, 1, fStripsNumber+1, "CATS/RAW/MULT"); + + // STRY_MULT + name = Form("CATS%d_STRY_MULT", i+1); + AddHisto1D(name, name, fStripsNumber, 1, fStripsNumber+1, "CATS/RAW/MULT"); + } // end loop on number of cats +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::InitPreTreatedSpectra(){ + TString family = "CATS/CAL/STRQ" ; + TString name; + + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + // CATS_STRX_Q_CAL + name = Form("CATS%d_STRX_Q_CAL", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, family); + + // CATS_STRY_Q_CAL + name = Form("CATS%d_STRY_Q_CAL", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, family); + // end loop on number of cats + + // STRX_MULT + name = Form("CATS%d_STRX_CAL_MULT", i+1); + AddHisto1D(name, name, fStripsNumber, 1, fStripsNumber+1, "CATS/CAL/MULT"); + + // STRY_MULT + name = Form("CATS%d_STRY_CAL_MULT", i+1); + AddHisto1D(name, name, fStripsNumber, 1, fStripsNumber+1, "CATS/CAL/MULT"); + } // end loop on number of cats +} + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::InitPhysicsSpectra(){ + TString family = "CATS/PHY/QSUM" ; + TString name; + + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + name = Form("CATS%d_QSUM_STRMAX_X_CAL", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, family); + + name = Form("CATS%d_QSUM_STRMAX_Y_CAL", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, family); + } // end loop on number of cats + + family = "CATS/PHY/CTRL"; + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + name = Form("CATS%d_QMEAN_TIME", i+1); + AddHisto1D(name, name, fEventLoopSize,0,fEventLoopSize,family); + fEventLoopQSum.push_back(0); + } // end loop on number of cats + + family = "CATS/PHY/POS"; + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + name = Form("CATS%d_POS", i+1); + AddHisto2D(name, name,100,-50,50,100,-50,50,family); + } // end loop on number of cats + + name = "TARGET_POS"; + AddHisto2D(name, name,100,-50,50,100,-50,50,family); + + +} + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::FillRawSpectra(TCATSData* RawData){ + TString name; + TString family; + + // CATS_STRX_Q_RAW + for (unsigned int i = 0; i < RawData->GetCATSMultX(); ++i) { // loop on vector + family = "CATS/RAW/STRQ"; + name = Form("CATS%d_STRX_Q_RAW", RawData->GetCATSDetX(i)); + GetHisto(family, name) -> Fill(RawData->GetCATSStripX(i), RawData->GetCATSChargeX(i)); + } // end loop on vector + + // CATS_STRY_Q_RAW + for (unsigned int i = 0; i < RawData->GetCATSMultY(); ++i) { // loop on vector + family = "CATS/RAW/STRQ"; + name = Form("CATS%d_STRY_Q_RAW", RawData->GetCATSDetY(i)); + GetHisto(family, name) -> Fill(RawData->GetCATSStripY(i), RawData->GetCATSChargeY(i)); + } // end loop on vector + + // STRX_MULT + int myMULT[fStripsNumber]; + for (unsigned int i = 0; i < fNumberOfCats; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < RawData->GetCATSMultX(); i++) myMULT[RawData->GetCATSDetX(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfCats; i++) { + name = Form("CATS%d_STRX_MULT", i+1); + family = "CATS/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // STRY_MULT + for (unsigned int i = 0; i < fNumberOfCats; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < RawData->GetCATSMultY(); i++) myMULT[RawData->GetCATSDetY(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfCats; i++) { + name = Form("CATS%d_STRY_MULT", i+1); + family = "CATS/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::FillPreTreatedSpectra(TCATSData* PreTreatedData){ + TString name; + TString family; + + // CATS_STRX_Q_CAL + for (unsigned int i = 0; i < PreTreatedData->GetCATSMultX(); ++i) { // loop on vector + family = "CATS/CAL/STRQ"; + name = Form("CATS%d_STRX_Q_CAL", PreTreatedData->GetCATSDetX(i)); + GetHisto(family,name) -> Fill(PreTreatedData->GetCATSStripX(i), PreTreatedData->GetCATSChargeX(i)); + } // end loop on vector + + // CATS_STRY_Q_CAL + for (unsigned int i = 0; i < PreTreatedData->GetCATSMultY(); ++i) { // loop on vector + family = "CATS/CAL/STRQ"; + name = Form("CATS%d_STRY_Q_CAL", PreTreatedData->GetCATSDetY(i)); + GetHisto(family,name) -> Fill(PreTreatedData->GetCATSStripY(i), PreTreatedData->GetCATSChargeY(i)); + } // end loop on vector + + // STRX_MULT + int myMULT[fStripsNumber]; + for (unsigned int i = 0; i < fNumberOfCats; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < PreTreatedData->GetCATSMultX(); i++) myMULT[PreTreatedData->GetCATSDetX(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfCats; i++) { + name = Form("CATS%d_STRX_CAL_MULT", i+1); + family = "CATS/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // STRY_MULT + for (unsigned int i = 0; i < fNumberOfCats; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < PreTreatedData->GetCATSMultY(); i++) myMULT[PreTreatedData->GetCATSDetY(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfCats; i++) { + name = Form("CATS%d_STRY_CAL_MULT", i+1); + family = "CATS/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + +} + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::FillPhysicsSpectra(TCATSPhysics* Physics){ + TString name,family; + // CATS_STRX_Q_CAL + for (unsigned int i = 0; i < Physics->DetNumberX.size() ; ++i) { // loop on vector + family="CATS/PHY/QSUM"; + name = Form("CATS%d_QSUM_STRMAX_X_CAL", Physics->DetNumberX[i]); + GetHisto(family,name) -> Fill(Physics->StripMaxX[i],Physics->QsumX[i]); + name = Form("CATS%d_QSUM_STRMAX_Y_CAL", Physics->DetNumberX[i]); + GetHisto(family,name) -> Fill(Physics->StripMaxY[i],Physics->QsumY[i]); + + } + // An histo of size fEventLoopSize is reset every fEventLoopSize to monitor the + // Keep Track of how many event elapsed + + if(Physics->StripMaxX.size()==fNumberOfCats){ + fEventLoopIndex++; + family = "CATS/PHY/CTRL"; + + for (unsigned int i = 0; i < Physics->StripMaxX.size(); ++i) { + fEventLoopQSum[i]+=Physics->QsumX[i]/1000000.; + name = Form("CATS%d_QMEAN_TIME",i+1); + + GetHisto(family,name) ->SetBinContent(fEventLoopIndex/fEventLoopStep,fEventLoopQSum[i]/fEventLoopStep); + } + } + + // Reset the mean every bin + if(fEventLoopIndex%fEventLoopStep>fEventLoopStep) + for (unsigned int i = 0; i < fNumberOfCats; ++i) + fEventLoopQSum[i]=0; + + // Restart histo + if(fEventLoopIndex > fEventLoopSize) + fEventLoopIndex = 0 ; + + if(Physics->StripMaxX.size()==fNumberOfCats){ + for (unsigned int i = 0; i < Physics->StripMaxX.size(); ++i) { + family = "CATS/PHY/POS"; + name = Form("CATS%d_POS", i+1); + GetHisto(family,name) -> Fill(Physics->PositionX[i],Physics->PositionY[i]); + } + + name = "TARGET_POS"; + GetHisto(family,name)->Fill(Physics->PositionOnTargetX,Physics->PositionOnTargetY); +} + +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCATSSpectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family){ + // create histo + TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup); + + vector<TString> index; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index] = hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCATSSpectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family){ + // create histo + TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + + vector<TString> index; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index] = hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCATSSpectra::GetHisto(TString family, TString name){ + vector<TString> index; + index.push_back(family); + index.push_back(name); + + return fMapHisto.at(index); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::WriteHisto(TString filename){ + TFile* f = NULL; + + if (filename != "VOID") { + f = new TFile(filename,"RECREATE"); + } + + map< vector<TString>, TH1* >::iterator it; + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) { + it->second->Write(); + } + + if (filename != "VOID") { + f->Close(); + delete f; + } +} diff --git a/NPLib/CATS/TCATSSpectra.h b/NPLib/CATS/TCATSSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..dc8cbc9f32e891dc7af44449faeb4769be92f59e --- /dev/null +++ b/NPLib/CATS/TCATSSpectra.h @@ -0,0 +1,88 @@ +#ifndef TTIARAHYBALLSPECTRA_H +#define TTIARAHYBALLSPECTRA_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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Tiara/Hyball * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// ROOT headers +#include "TObject.h" +#include <TH1.h> +#include <TH2.h> +#include <TString.h> + +// NPLib headers +#include "TCATSData.h" +#include "TCATSPhysics.h" + +// C++ STL headers +#include <map> +using namespace std; + + +// Forward Declaration +class TCATSPhysics; + + +class TCATSSpectra { + public: + // constructor and destructor + TCATSSpectra(); + TCATSSpectra(unsigned int NumberOfCats); + ~TCATSSpectra(); + + private: + // Instantiate and register histo to maps + TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family); + TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, + Int_t nbinsy, Double_t ylow, Double_t yup, TString family); + + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TCATSData*); + void FillPreTreatedSpectra(TCATSData*); + void FillPhysicsSpectra(TCATSPhysics*); + + public: + // get map histo which will be used for GSpectra in GUser + map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;} + TH1* GetHisto(TString family, TString name); + void WriteHisto(TString filename = "VOID"); + + private: // Information on MUST2 + unsigned int fNumberOfCats; + unsigned int fStripsNumber; + int fEventLoopSize; + int fEventLoopStep; + int fEventLoopIndex; + vector<double> fEventLoopQSum; + + private: +// map holding histo pointers and their family names +map< vector<TString>, TH1* > fMapHisto; +}; + +#endif diff --git a/NPLib/Charissa/Makefile b/NPLib/Charissa/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b251010c9da427044978c1d296f6039ff7469aa8 --- /dev/null +++ b/NPLib/Charissa/Makefile @@ -0,0 +1,40 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libCharissa.so + +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## MUST2 ## +libCharissa.so: TCharissaData.o TCharissaDataDict.o TCharissaPhysics.o TCharissaPhysicsDict.o TCharissaSpectra.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +TCharissaDataDict.cxx: TCharissaData.h + rootcint -f $@ -c $^ + +TCharissaPhysicsDict.cxx: TCharissaPhysics.h + rootcint -f $@ -c $^ + +# dependances +TCharissaData.o: TCharissaData.cxx TCharissaData.h +TCharissaPhysics.o: TCharissaPhysics.cxx TCharissaPhysics.h +TCharissaSpectra.o: TCharissaSpectra.cxx TCharissaSpectra.h +####################################### + +############# Clean and More ########## +clean: + @rm -f core *~ *.o *Dict* + +distclean: + make clean; rm -f *.so + +.SUFFIXES: .$(SrcSuf) + +### + +.$(SrcSuf).$(ObjSuf): + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< + + diff --git a/NPLib/Charissa/TCharissaData.cxx b/NPLib/Charissa/TCharissaData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d04557b054bc1940dd3119cb7d9e6c86b370da35 --- /dev/null +++ b/NPLib/Charissa/TCharissaData.cxx @@ -0,0 +1,143 @@ +/***************************************************************************** + * 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 : febuary 2009 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold must2 Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include <iostream> +using namespace std; + +#include "TCharissaData.h" + + +ClassImp(TCharissaData) + +TCharissaData::TCharissaData() +{ + // Default constructor + Clear(); +} + + + +TCharissaData::~TCharissaData() +{ +} + + + +void TCharissaData::Clear() +{ + // DSSSD 1st layer + // (X,E) + fCharissa_Layer1_StripXE_DetectorNbr.clear(); + fCharissa_Layer1_StripXE_StripNbr.clear(); + fCharissa_Layer1_StripXE_Energy.clear(); + // (X,T) + fCharissa_Layer1_StripXT_DetectorNbr.clear(); + fCharissa_Layer1_StripXT_StripNbr.clear(); + fCharissa_Layer1_StripXT_Time.clear(); + // (Y,E) + fCharissa_Layer1_StripYE_DetectorNbr.clear(); + fCharissa_Layer1_StripYE_StripNbr.clear(); + fCharissa_Layer1_StripYE_Energy.clear(); + // (Y,T) + fCharissa_Layer1_StripYT_DetectorNbr.clear(); + fCharissa_Layer1_StripYT_StripNbr.clear(); + fCharissa_Layer1_StripYT_Time.clear(); + + // DSSSD 2nd layer + // (X,E) + fCharissa_Layer2_StripXE_DetectorNbr.clear(); + fCharissa_Layer2_StripXE_StripNbr.clear(); + fCharissa_Layer2_StripXE_Energy.clear(); + // (X,T) + fCharissa_Layer2_StripXT_DetectorNbr.clear(); + fCharissa_Layer2_StripXT_StripNbr.clear(); + fCharissa_Layer2_StripXT_Time.clear(); + // (Y,E) + fCharissa_Layer2_StripYE_DetectorNbr.clear(); + fCharissa_Layer2_StripYE_StripNbr.clear(); + fCharissa_Layer2_StripYE_Energy.clear(); + // (Y,T) + fCharissa_Layer2_StripYT_DetectorNbr.clear(); + fCharissa_Layer2_StripYT_StripNbr.clear(); + fCharissa_Layer2_StripYT_Time.clear(); + + // CsI E + fCharissa_CsIE_DetectorNbr.clear(); + fCharissa_CsIE_CristalNbr.clear(); + fCharissa_CsIE_Energy.clear(); + // CsI T + fCharissa_CsIT_DetectorNbr.clear(); + fCharissa_CsIT_CristalNbr.clear(); + fCharissa_CsIT_Time.clear(); +} + + + +void TCharissaData::Dump() const +{ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX TCharissaData: New Event XXXXXXXXXXXXXXXXX" << endl; + + // DSSSD 1st layer + // (X,E) + cout << "Charissa_Layer1_StripXE_Mult = " << fCharissa_Layer1_StripXE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer1_StripXE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer1_StripXE_DetectorNbr[i] << " Strip: " << fCharissa_Layer1_StripXE_StripNbr[i] << " Energy: " << fCharissa_Layer1_StripXE_Energy[i] << endl; + // (X,T) + cout << "Charissa_Layer1 StripXT_Mult = " << fCharissa_Layer1_StripXT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer1_StripXT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer1_StripXT_DetectorNbr[i] << " Strip: " << fCharissa_Layer1_StripXT_StripNbr[i] << " Time: " << fCharissa_Layer1_StripXT_Time[i] << endl; + // (Y,E) + cout << "Charissa_Layer1 StripYE_Mult = " << fCharissa_Layer1_StripYE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer1_StripYE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer1_StripYE_DetectorNbr[i] << " Strip: " << fCharissa_Layer1_StripYE_StripNbr[i] << " Energy: " << fCharissa_Layer1_StripYE_Energy[i] << endl; + // (Y,T) + cout << "Charissa_Layer1 StripYT_Mult = " << fCharissa_Layer1_StripYT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer1_StripYT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer1_StripYT_DetectorNbr[i] << " Strip: " << fCharissa_Layer1_StripYT_StripNbr[i] << " Time: " << fCharissa_Layer1_StripYT_Time[i] << endl; + + // DSSSD 2nd layer + // (X,E) + cout << "Charissa_Layer2_StripXE_Mult = " << fCharissa_Layer2_StripXE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer2_StripXE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer2_StripXE_DetectorNbr[i] << " Strip: " << fCharissa_Layer2_StripXE_StripNbr[i] << " Energy: " << fCharissa_Layer2_StripXE_Energy[i] << endl; + // (X,T) + cout << "Charissa_Layer2 StripXT_Mult = " << fCharissa_Layer2_StripXT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer2_StripXT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer2_StripXT_DetectorNbr[i] << " Strip: " << fCharissa_Layer2_StripXT_StripNbr[i] << " Time: " << fCharissa_Layer2_StripXT_Time[i] << endl; + // (Y,E) + cout << "Charissa_Layer2 StripYE_Mult = " << fCharissa_Layer2_StripYE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer2_StripYE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer2_StripYE_DetectorNbr[i] << " Strip: " << fCharissa_Layer2_StripYE_StripNbr[i] << " Energy: " << fCharissa_Layer2_StripYE_Energy[i] << endl; + // (Y,T) + cout << "Charissa_Layer2 StripYT_Mult = " << fCharissa_Layer2_StripYT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_Layer2_StripYT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fCharissa_Layer2_StripYT_DetectorNbr[i] << " Strip: " << fCharissa_Layer2_StripYT_StripNbr[i] << " Time: " << fCharissa_Layer2_StripYT_Time[i] << endl; + + // CsI + // Energy + cout << "Charissa_CsIE_Mult = " << fCharissa_CsIE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_CsIE_DetectorNbr.size(); i++) + cout << "Det: " << fCharissa_CsIE_DetectorNbr[i] << " Pad: " << fCharissa_CsIE_CristalNbr[i] << " Energy: " << fCharissa_CsIE_Energy[i] << endl; + // Time + cout << "Charissa_CsIT_Mult = " << fCharissa_CsIT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fCharissa_CsIT_DetectorNbr.size(); i++) + cout << "Det: " << fCharissa_CsIT_DetectorNbr[i] << " Pad: " << fCharissa_CsIT_CristalNbr[i] << " Time: " << fCharissa_CsIT_Time[i] << endl; +} diff --git a/NPLib/Charissa/TCharissaData.h b/NPLib/Charissa/TCharissaData.h new file mode 100644 index 0000000000000000000000000000000000000000..7585fe5a1b03468c62537c1df7c29ce43ca96a10 --- /dev/null +++ b/NPLib/Charissa/TCharissaData.h @@ -0,0 +1,196 @@ +#ifndef __CHARISSADATA__ +#define __CHARISSADATA__ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : december 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds Charissa raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TObject.h" + +#include <vector> +using namespace std; + +class TCharissaData : public TObject { + private: + // DSSSD 1st layer + // X strips + // Energy + vector<UShort_t> fCharissa_Layer1_StripXE_DetectorNbr; + vector<UShort_t> fCharissa_Layer1_StripXE_StripNbr; + vector<Double_t> fCharissa_Layer1_StripXE_Energy; + // Time + vector<UShort_t> fCharissa_Layer1_StripXT_DetectorNbr; + vector<UShort_t> fCharissa_Layer1_StripXT_StripNbr; + vector<Double_t> fCharissa_Layer1_StripXT_Time; + // Y strips + // Energy + vector<UShort_t> fCharissa_Layer1_StripYE_DetectorNbr; + vector<UShort_t> fCharissa_Layer1_StripYE_StripNbr; + vector<Double_t> fCharissa_Layer1_StripYE_Energy; + // Time + vector<UShort_t> fCharissa_Layer1_StripYT_DetectorNbr; + vector<UShort_t> fCharissa_Layer1_StripYT_StripNbr; + vector<Double_t> fCharissa_Layer1_StripYT_Time; + + // DSSSD 2nd layer + // X strips + // Energy + vector<UShort_t> fCharissa_Layer2_StripXE_DetectorNbr; + vector<UShort_t> fCharissa_Layer2_StripXE_StripNbr; + vector<Double_t> fCharissa_Layer2_StripXE_Energy; + // Time + vector<UShort_t> fCharissa_Layer2_StripXT_DetectorNbr; + vector<UShort_t> fCharissa_Layer2_StripXT_StripNbr; + vector<Double_t> fCharissa_Layer2_StripXT_Time; + // Y strips + // Energy + vector<UShort_t> fCharissa_Layer2_StripYE_DetectorNbr; + vector<UShort_t> fCharissa_Layer2_StripYE_StripNbr; + vector<Double_t> fCharissa_Layer2_StripYE_Energy; + // Time + vector<UShort_t> fCharissa_Layer2_StripYT_DetectorNbr; + vector<UShort_t> fCharissa_Layer2_StripYT_StripNbr; + vector<Double_t> fCharissa_Layer2_StripYT_Time; + + // CsI + // Energy + vector<UShort_t> fCharissa_CsIE_DetectorNbr; + vector<UShort_t> fCharissa_CsIE_CristalNbr; + vector<Double_t> fCharissa_CsIE_Energy; + // Time + vector<UShort_t> fCharissa_CsIT_DetectorNbr; + vector<UShort_t> fCharissa_CsIT_CristalNbr; + vector<Double_t> fCharissa_CsIT_Time; + + public: + TCharissaData(); + virtual ~TCharissaData(); + + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + ///////////////////// SETTERS //////////////////////// + // DSSSD 1st stage + // (X,E) + void SetCharissaLayer1StripXEDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer1_StripXE_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer1StripXEStripNbr(const UShort_t StripNbr) {fCharissa_Layer1_StripXE_StripNbr.push_back(StripNbr);} + void SetCharissaLayer1StripXEEnergy(const Double_t Energy) {fCharissa_Layer1_StripXE_Energy.push_back(Energy);} + // (X,T) + void SetCharissaLayer1StripXTDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer1_StripXT_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer1StripXTStripNbr(const UShort_t StripNbr) {fCharissa_Layer1_StripXT_StripNbr.push_back(StripNbr);} + void SetCharissaLayer1StripXTTime(const Double_t Time) {fCharissa_Layer1_StripXT_Time.push_back(Time);} + // (Y,E) + void SetCharissaLayer1StripYEDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer1_StripYE_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer1StripYEStripNbr(const UShort_t StripNbr) {fCharissa_Layer1_StripYE_StripNbr.push_back(StripNbr);} + void SetCharissaLayer1StripYEEnergy(const Double_t Energy) {fCharissa_Layer1_StripYE_Energy.push_back(Energy);} + // (Y,T) + void SetCharissaLayer1StripYTDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer1_StripYT_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer1StripYTStripNbr(const UShort_t StripNbr) {fCharissa_Layer1_StripYT_StripNbr.push_back(StripNbr);} + void SetCharissaLayer1StripYTTime(const Double_t Time) {fCharissa_Layer1_StripYT_Time.push_back(Time);} + + // DSSSD 2nd stage + // (X,E) + void SetCharissaLayer2StripXEDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer2_StripXE_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer2StripXEStripNbr(const UShort_t StripNbr) {fCharissa_Layer2_StripXE_StripNbr.push_back(StripNbr);} + void SetCharissaLayer2StripXEEnergy(const Double_t Energy) {fCharissa_Layer2_StripXE_Energy.push_back(Energy);} + // (X,T) + void SetCharissaLayer2StripXTDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer2_StripXT_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer2StripXTStripNbr(const UShort_t StripNbr) {fCharissa_Layer2_StripXT_StripNbr.push_back(StripNbr);} + void SetCharissaLayer2StripXTTime(const Double_t Time) {fCharissa_Layer2_StripXT_Time.push_back(Time);} + // (Y,E) + void SetCharissaLayer2StripYEDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer2_StripYE_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer2StripYEStripNbr(const UShort_t StripNbr) {fCharissa_Layer2_StripYE_StripNbr.push_back(StripNbr);} + void SetCharissaLayer2StripYEEnergy(const Double_t Energy) {fCharissa_Layer2_StripYE_Energy.push_back(Energy);} + // (Y,T) + void SetCharissaLayer2StripYTDetectorNbr(const UShort_t DetNbr) {fCharissa_Layer2_StripYT_DetectorNbr.push_back(DetNbr);} + void SetCharissaLayer2StripYTStripNbr(const UShort_t StripNbr) {fCharissa_Layer2_StripYT_StripNbr.push_back(StripNbr);} + void SetCharissaLayer2StripYTTime(const Double_t Time) {fCharissa_Layer2_StripYT_Time.push_back(Time);} + + // CsI + // (E) + void SetCharissaCsIEDetectorNbr(const UShort_t DetNbr) {fCharissa_CsIE_DetectorNbr.push_back(DetNbr);} + void SetCharissaCsIECristalNbr(const UShort_t CristalNbr) {fCharissa_CsIE_CristalNbr.push_back(CristalNbr);} + void SetCharissaCsIEEnergy(const Double_t Energy) {fCharissa_CsIE_Energy.push_back(Energy);} + // (T) + void SetCharissaCsITDetectorNbr(const UShort_t DetNbr) {fCharissa_CsIT_DetectorNbr.push_back(DetNbr);} + void SetCharissaCsITCristalNbr(const UShort_t CristalNbr) {fCharissa_CsIT_CristalNbr.push_back(CristalNbr);} + void SetCharissaCsITTime(const Double_t Time) {fCharissa_CsIT_Time.push_back(Time);} + + ///////////////////// GETTERS //////////////////////// + // DSSSD 1st layer + // (X,E) + UShort_t GetCharissaLayer1StripXEMult() const {return fCharissa_Layer1_StripXE_DetectorNbr.size();} + UShort_t GetCharissaLayer1StripXEDetectorNbr(const Int_t i) const {return fCharissa_Layer1_StripXE_DetectorNbr[i];} + UShort_t GetCharissaLayer1StripXEStripNbr(const Int_t i) const {return fCharissa_Layer1_StripXE_StripNbr[i];} + Double_t GetCharissaLayer1StripXEEnergy(const Int_t i) const {return fCharissa_Layer1_StripXE_Energy[i];} + // (X,T) + UShort_t GetCharissaLayer1StripXTMult() const {return fCharissa_Layer1_StripXT_DetectorNbr.size();} + UShort_t GetCharissaLayer1StripXTDetectorNbr(const Int_t i) const {return fCharissa_Layer1_StripXT_DetectorNbr[i];} + UShort_t GetCharissaLayer1StripXTStripNbr(const Int_t i) const {return fCharissa_Layer1_StripXT_StripNbr[i];} + Double_t GetCharissaLayer1StripXTTime(const Int_t i) const {return fCharissa_Layer1_StripXT_Time[i];} + // (Y,E) + UShort_t GetCharissaLayer1StripYEMult() const {return fCharissa_Layer1_StripYE_DetectorNbr.size();} + UShort_t GetCharissaLayer1StripYEDetectorNbr(const Int_t i) const {return fCharissa_Layer1_StripYE_DetectorNbr[i];} + UShort_t GetCharissaLayer1StripYEStripNbr(const Int_t i) const {return fCharissa_Layer1_StripYE_StripNbr[i];} + Double_t GetCharissaLayer1StripYEEnergy(const Int_t i) const {return fCharissa_Layer1_StripYE_Energy[i];} + // (Y,T) + UShort_t GetCharissaLayer1StripYTMult() const {return fCharissa_Layer1_StripYT_DetectorNbr.size();} + UShort_t GetCharissaLayer1StripYTDetectorNbr(const Int_t i) const {return fCharissa_Layer1_StripYT_DetectorNbr[i];} + UShort_t GetCharissaLayer1StripYTStripNbr(const Int_t i) const {return fCharissa_Layer1_StripYT_StripNbr[i];} + Double_t GetCharissaLayer1StripYTTime(const Int_t i) const {return fCharissa_Layer1_StripYT_Time[i];} + + // DSSSD 2nd layer + // (X,E) + UShort_t GetCharissaLayer2StripXEMult() const {return fCharissa_Layer2_StripXE_DetectorNbr.size();} + UShort_t GetCharissaLayer2StripXEDetectorNbr(const Int_t i) const {return fCharissa_Layer2_StripXE_DetectorNbr[i];} + UShort_t GetCharissaLayer2StripXEStripNbr(const Int_t i) const {return fCharissa_Layer2_StripXE_StripNbr[i];} + Double_t GetCharissaLayer2StripXEEnergy(const Int_t i) const {return fCharissa_Layer2_StripXE_Energy[i];} + // (X,T) + UShort_t GetCharissaLayer2StripXTMult() const {return fCharissa_Layer2_StripXT_DetectorNbr.size();} + UShort_t GetCharissaLayer2StripXTDetectorNbr(const Int_t i) const {return fCharissa_Layer2_StripXT_DetectorNbr[i];} + UShort_t GetCharissaLayer2StripXTStripNbr(const Int_t i) const {return fCharissa_Layer2_StripXT_StripNbr[i];} + Double_t GetCharissaLayer2StripXTTime(const Int_t i) const {return fCharissa_Layer2_StripXT_Time[i];} + // (Y,E) + UShort_t GetCharissaLayer2StripYEMult() const {return fCharissa_Layer2_StripYE_DetectorNbr.size();} + UShort_t GetCharissaLayer2StripYEDetectorNbr(const Int_t i) const {return fCharissa_Layer2_StripYE_DetectorNbr[i];} + UShort_t GetCharissaLayer2StripYEStripNbr(const Int_t i) const {return fCharissa_Layer2_StripYE_StripNbr[i];} + Double_t GetCharissaLayer2StripYEEnergy(const Int_t i) const {return fCharissa_Layer2_StripYE_Energy[i];} + // (Y,T) + UShort_t GetCharissaLayer2StripYTMult() const {return fCharissa_Layer2_StripYT_DetectorNbr.size();} + UShort_t GetCharissaLayer2StripYTDetectorNbr(const Int_t i) const {return fCharissa_Layer2_StripYT_DetectorNbr[i];} + UShort_t GetCharissaLayer2StripYTStripNbr(const Int_t i) const {return fCharissa_Layer2_StripYT_StripNbr[i];} + Double_t GetCharissaLayer2StripYTTime(const Int_t i) const {return fCharissa_Layer2_StripYT_Time[i];} + + // CsI + //(E) + UShort_t GetCharissaCsIEMult() const {return fCharissa_CsIE_DetectorNbr.size();} + UShort_t GetCharissaCsIEDetectorNbr(const Int_t i) const {return fCharissa_CsIE_DetectorNbr[i];} + UShort_t GetCharissaCsIECristalNbr(const Int_t i) const {return fCharissa_CsIE_CristalNbr[i];} + Double_t GetCharissaCsIEEnergy(const Int_t i) const {return fCharissa_CsIE_Energy[i];} + //(T) + UShort_t GetCharissaCsITMult() const {return fCharissa_CsIT_DetectorNbr.size();} + UShort_t GetCharissaCsITDetectorNbr(const Int_t i) const {return fCharissa_CsIT_DetectorNbr[i];} + UShort_t GetCharissaCsITCristalNbr(const Int_t i) const {return fCharissa_CsIT_CristalNbr[i];} + Double_t GetCharissaCsITTime(const Int_t i) const {return fCharissa_CsIT_Time[i];} + + ClassDef(TCharissaData,1) // CharissaData structure +}; + +#endif diff --git a/NPLib/Charissa/TCharissaPhysics.cxx b/NPLib/Charissa/TCharissaPhysics.cxx new file mode 100755 index 0000000000000000000000000000000000000000..fd0cd110a468f90d8dba2d58c565860dae8bb5c4 --- /dev/null +++ b/NPLib/Charissa/TCharissaPhysics.cxx @@ -0,0 +1,1411 @@ +/***************************************************************************** + * 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 : December 2013 * + * * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Charissa treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include "TCharissaPhysics.h" +using namespace CHARISSA_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" + +// ROOT +#include "TChain.h" +/////////////////////////////////////////////////////////////////////////// + +ClassImp(TCharissaPhysics) +/////////////////////////////////////////////////////////////////////////// +TCharissaPhysics::TCharissaPhysics(){ + EventMultiplicity = 0 ; + m_EventData = new TCharissaData ; + m_PreTreatedData = new TCharissaData ; + m_EventPhysics = this ; + m_Spectra = NULL; + m_NumberOfTelescope = 0 ; + m_MaximumStripMultiplicityAllowed = 10; + m_StripEnergyMatchingSigma = 0.020 ; + m_StripEnergyMatchingNumberOfSigma = 3; + // Raw Threshold + m_Si_X_E_RAW_Threshold = 8200 ; + m_Si_Y_E_RAW_Threshold = 8200 ; + m_CsI_E_RAW_Threshold = 8200 ; + // Calibrated Threshold + m_Si_X_E_Threshold = 0 ; + m_Si_Y_E_Threshold = 0 ; + m_CsI_E_Threshold = 0; + m_NumberOfStrip = 16; + + m_Take_E_Y=false; + m_Take_T_Y=true; + + } + + + +/////////////////////////////////////////////////////////////////////////// +TCharissaPhysics::~TCharissaPhysics(){ + +} +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::BuildSimplePhysicalEvent(){ + BuildPhysicalEvent(); +} + +/////////////////////////////////////////////////////////////////////////// + +void TCharissaPhysics::BuildPhysicalEvent(){ + PreTreat(); + bool check_CSI = false ; + + m_Layer1_StripXEMult = m_PreTreatedData->GetCharissaLayer1StripXEMult(); + m_Layer1_StripYEMult = m_PreTreatedData->GetCharissaLayer1StripYEMult(); + m_Layer1_StripXTMult = m_PreTreatedData->GetCharissaLayer1StripXTMult(); + m_Layer1_StripYTMult = m_PreTreatedData->GetCharissaLayer1StripYTMult(); + m_Layer2_StripXEMult = m_PreTreatedData->GetCharissaLayer2StripXEMult(); + m_Layer2_StripYEMult = m_PreTreatedData->GetCharissaLayer2StripYEMult(); + m_Layer2_StripXTMult = m_PreTreatedData->GetCharissaLayer2StripXTMult(); + m_Layer2_StripYTMult = m_PreTreatedData->GetCharissaLayer2StripYTMult(); + m_CsIEMult = m_PreTreatedData->GetCharissaCsIEMult(); + m_CsITMult = m_PreTreatedData->GetCharissaCsITMult(); + + // Layer 1 + if( Layer1_CheckEvent() == 1 ){ + vector< TVector2 > Layer1_couple = Layer1_Match_X_Y() ; + EventMultiplicity = Layer1_couple.size(); + + for(unsigned int i = 0 ; i < Layer1_couple.size() ; ++i){ + check_CSI = false ; + + int Layer1_N = m_PreTreatedData->GetCharissaLayer1StripXEDetectorNbr(Layer1_couple[i].X()) ; + + int Layer1_X = m_PreTreatedData->GetCharissaLayer1StripXEStripNbr(Layer1_couple[i].X()) ; + int Layer1_Y = m_PreTreatedData->GetCharissaLayer1StripYEStripNbr(Layer1_couple[i].Y()) ; + + double Layer1_Si_X_E = m_PreTreatedData->GetCharissaLayer1StripXEEnergy( Layer1_couple[i].X() ) ; + double Layer1_Si_Y_E = m_PreTreatedData->GetCharissaLayer1StripYEEnergy( Layer1_couple[i].Y() ) ; + + // Search for associate Time + double Layer1_Si_X_T = -1000 ; + + for(unsigned int t = 0 ; t < m_Layer1_StripXTMult ; ++t ) + { + if( m_PreTreatedData->GetCharissaLayer1StripXTStripNbr( Layer1_couple[i].X() ) == m_PreTreatedData->GetCharissaLayer1StripXTStripNbr(t) + ||m_PreTreatedData->GetCharissaLayer1StripXTDetectorNbr( Layer1_couple[i].X() ) == m_PreTreatedData->GetCharissaLayer1StripXTDetectorNbr(t)) + Layer1_Si_X_T = m_PreTreatedData->GetCharissaLayer1StripXTTime(t); + } + + double Layer1_Si_Y_T = -1000 ; + + for(unsigned int t = 0 ; t < m_Layer1_StripYTMult ; ++t ) + { + if( m_PreTreatedData->GetCharissaLayer1StripYTStripNbr( Layer1_couple[i].Y() ) == m_PreTreatedData->GetCharissaLayer1StripYTStripNbr(t) + ||m_PreTreatedData->GetCharissaLayer1StripYTDetectorNbr( Layer1_couple[i].Y() ) == m_PreTreatedData->GetCharissaLayer1StripYTDetectorNbr(t)) + Layer1_Si_Y_T = m_PreTreatedData->GetCharissaLayer1StripYTTime(t); + } + + Layer1_Si_X.push_back(Layer1_X) ; Layer1_Si_Y.push_back(Layer1_Y) ; Layer1_TelescopeNumber.push_back(Layer1_N) ; + + if(m_Take_E_Y) Layer1_Si_E.push_back(Layer1_Si_Y_E); + else Layer1_Si_E.push_back(Layer1_Si_X_E); + + if(m_Take_T_Y) Layer1_Si_T.push_back(Layer1_Si_Y_T); + else Layer1_Si_T.push_back(Layer1_Si_X_T); + + // Store the other value for checking purpose + Layer1_Si_EX.push_back(Layer1_Si_X_E); + Layer1_Si_TX.push_back(Layer1_Si_X_T); + Layer1_Si_EY.push_back(Layer1_Si_Y_E); + Layer1_Si_TY.push_back(Layer1_Si_Y_T); + } + } + + + // Layer 2 + if( Layer2_CheckEvent() == 1 ){ + vector< TVector2 > Layer2_couple = Layer2_Match_X_Y() ; + EventMultiplicity = Layer2_couple.size(); + + for(unsigned int i = 0 ; i < Layer2_couple.size() ; ++i){ + + check_CSI = false ; + + int Layer2_N = m_PreTreatedData->GetCharissaLayer2StripXEDetectorNbr(Layer2_couple[i].X()) ; + int Layer2_X = m_PreTreatedData->GetCharissaLayer2StripXEStripNbr(Layer2_couple[i].X()) ; + int Layer2_Y = m_PreTreatedData->GetCharissaLayer2StripYEStripNbr(Layer2_couple[i].Y()) ; + + double Layer2_Si_X_E = m_PreTreatedData->GetCharissaLayer1StripXEEnergy( Layer2_couple[i].X() ) ; + double Layer2_Si_Y_E = m_PreTreatedData->GetCharissaLayer1StripYEEnergy( Layer2_couple[i].Y() ) ; + + // Search for associate Time + double Layer2_Si_X_T = -1000 ; + + for(unsigned int t = 0 ; t < m_Layer2_StripXTMult ; ++t ) + { + if( m_PreTreatedData->GetCharissaLayer2StripXTStripNbr( Layer2_couple[i].X() ) == m_PreTreatedData->GetCharissaLayer2StripXTStripNbr(t) + ||m_PreTreatedData->GetCharissaLayer2StripXTDetectorNbr( Layer2_couple[i].X() ) == m_PreTreatedData->GetCharissaLayer2StripXTDetectorNbr(t)) + Layer2_Si_X_T = m_PreTreatedData->GetCharissaLayer2StripXTTime(t); + } + + double Layer2_Si_Y_T = -1000 ; + + for(unsigned int t = 0 ; t < m_Layer2_StripYTMult ; ++t ) + { + if( m_PreTreatedData->GetCharissaLayer2StripYTStripNbr( Layer2_couple[i].Y() ) == m_PreTreatedData->GetCharissaLayer2StripYTStripNbr(t) + ||m_PreTreatedData->GetCharissaLayer2StripYTDetectorNbr( Layer2_couple[i].Y() ) == m_PreTreatedData->GetCharissaLayer2StripYTDetectorNbr(t)) + Layer2_Si_Y_T = m_PreTreatedData->GetCharissaLayer2StripYTTime(t); + } + + Layer2_Si_X.push_back(Layer2_X) ; Layer2_Si_Y.push_back(Layer2_Y) ; Layer2_TelescopeNumber.push_back(Layer2_N) ; + + if(m_Take_E_Y) Layer2_Si_E.push_back(Layer2_Si_Y_E); + else Layer2_Si_E.push_back(Layer2_Si_X_E); + + if(m_Take_T_Y) Layer2_Si_T.push_back(Layer2_Si_Y_T); + else Layer2_Si_T.push_back(Layer2_Si_X_T); + + // Store the other value for checking purpose + Layer2_Si_EX.push_back(Layer2_Si_X_E); + Layer2_Si_TX.push_back(Layer2_Si_X_T); + Layer2_Si_EY.push_back(Layer2_Si_Y_E); + Layer2_Si_TY.push_back(Layer2_Si_Y_T); + + for(unsigned int j = 0 ; j < m_CsIEMult ; ++j){ + if(m_PreTreatedData->GetCharissaCsIEDetectorNbr(j)==Layer2_N){ + if(Match_Si_CsI( Layer2_X, Layer2_Y , m_PreTreatedData->GetCharissaCsIECristalNbr(j) ) ){ + CsI_N.push_back( m_PreTreatedData->GetCharissaCsIECristalNbr(j) ) ; + CsI_E.push_back( m_PreTreatedData->GetCharissaCsIEEnergy(j) ) ; + + // Look for associate Time + for(unsigned int k =0 ; k < m_CsITMult ; ++k){ + // Same Cristal; Same Detector + if( m_PreTreatedData->GetCharissaCsIECristalNbr(j)==m_PreTreatedData->GetCharissaCsITCristalNbr(k) + && m_PreTreatedData->GetCharissaCsIEDetectorNbr(j)==m_PreTreatedData->GetCharissaCsITDetectorNbr(k) ) + CsI_T.push_back( m_PreTreatedData->GetCharissaCsITTime(j) ) ; break ; + } + check_CSI = true ; + } + } + } + + if(!check_CSI){ + CsI_N.push_back(0) ; + CsI_E.push_back(-1000) ; + CsI_T.push_back(-1000) ; + } + } + } + + + + + + return; + +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::PreTreat(){ + + ClearPreTreatedData(); + m_Layer1_StripXEMult = m_EventData->GetCharissaLayer1StripXEMult(); + m_Layer1_StripYEMult = m_EventData->GetCharissaLayer1StripYEMult(); + m_Layer1_StripXTMult = m_EventData->GetCharissaLayer1StripXTMult(); + m_Layer1_StripYTMult = m_EventData->GetCharissaLayer1StripYTMult(); + + m_Layer2_StripXEMult = m_PreTreatedData->GetCharissaLayer2StripXEMult(); + m_Layer2_StripYEMult = m_PreTreatedData->GetCharissaLayer2StripYEMult(); + m_Layer2_StripXTMult = m_PreTreatedData->GetCharissaLayer2StripXTMult(); + m_Layer2_StripYTMult = m_PreTreatedData->GetCharissaLayer2StripYTMult(); + + m_CsIEMult = m_EventData->GetCharissaCsIEMult(); + m_CsITMult = m_EventData->GetCharissaCsITMult(); + + // X Layer1 + // E + for(unsigned int i = 0 ; i < m_Layer1_StripXEMult ; ++i){ + if( m_EventData->GetCharissaLayer1StripXEEnergy(i)>m_Si_X_E_RAW_Threshold && IsValidChannel("X", m_EventData->GetCharissaLayer1StripXEDetectorNbr(i), m_EventData->GetCharissaLayer1StripXEStripNbr(i)) ){ + double Layer1_EX = fSi_X_E(m_EventData , i); + if( Layer1_EX > m_Si_X_E_Threshold ){ + m_PreTreatedData->SetCharissaLayer1StripXEDetectorNbr( m_EventData->GetCharissaLayer1StripXEDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripXEStripNbr( m_EventData->GetCharissaLayer1StripXEStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripXEEnergy( Layer1_EX ); + } + + } + } + + // T + for(unsigned int i = 0 ; i < m_Layer1_StripXTMult ; ++i){ + if(IsValidChannel("X", m_EventData->GetCharissaLayer1StripXTDetectorNbr(i), m_EventData->GetCharissaLayer1StripXTStripNbr(i))){ + m_PreTreatedData->SetCharissaLayer1StripXTDetectorNbr( m_EventData->GetCharissaLayer1StripXTDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripXTStripNbr( m_EventData->GetCharissaLayer1StripXTStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripXTTime( fSi_X_T(m_EventData , i) ); + } + } + + // Y Layer1 + // E + for(unsigned int i = 0 ; i < m_Layer1_StripYEMult ; ++i){ + if( m_EventData->GetCharissaLayer1StripYEEnergy(i)<m_Si_Y_E_RAW_Threshold && IsValidChannel("Y", m_EventData->GetCharissaLayer1StripYEDetectorNbr(i), m_EventData->GetCharissaLayer1StripYEStripNbr(i))){ + double Layer1_EY = fSi_Y_E(m_EventData , i); + if( Layer1_EY >m_Si_Y_E_Threshold ){ + m_PreTreatedData->SetCharissaLayer1StripYEDetectorNbr( m_EventData->GetCharissaLayer1StripYEDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripYEStripNbr( m_EventData->GetCharissaLayer1StripYEStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripYEEnergy( Layer1_EY ); + } + } + } + + // T + for(unsigned int i = 0 ; i < m_Layer1_StripYTMult ; ++i){ + if(IsValidChannel("Y", m_EventData->GetCharissaLayer1StripYTDetectorNbr(i), m_EventData->GetCharissaLayer1StripYTStripNbr(i))){ + m_PreTreatedData->SetCharissaLayer1StripYTDetectorNbr( m_EventData->GetCharissaLayer1StripYTDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripYTStripNbr( m_EventData->GetCharissaLayer1StripYTStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer1StripYTTime( fSi_Y_T(m_EventData , i) ); + } + } + + + // X Layer2 + // E + for(unsigned int i = 0 ; i < m_Layer2_StripXEMult ; ++i){ + if( m_EventData->GetCharissaLayer2StripXEEnergy(i)>m_Si_X_E_RAW_Threshold && IsValidChannel("X", m_EventData->GetCharissaLayer2StripXEDetectorNbr(i), m_EventData->GetCharissaLayer1StripXEStripNbr(i)) ){ + double Layer2_EX = fSi_X_E(m_EventData , i); + if( Layer2_EX > m_Si_X_E_Threshold ){ + m_PreTreatedData->SetCharissaLayer2StripXEDetectorNbr( m_EventData->GetCharissaLayer2StripXEDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripXEStripNbr( m_EventData->GetCharissaLayer2StripXEStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripXEEnergy( Layer2_EX ); + } + } + } + + + // T + for(unsigned int i = 0 ; i < m_Layer2_StripXTMult ; ++i){ + if(IsValidChannel("X", m_EventData->GetCharissaLayer2StripXTDetectorNbr(i), m_EventData->GetCharissaLayer2StripXTStripNbr(i))){ + m_PreTreatedData->SetCharissaLayer2StripXTDetectorNbr( m_EventData->GetCharissaLayer2StripXTDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripXTStripNbr( m_EventData->GetCharissaLayer2StripXTStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripXTTime( fSi_X_T(m_EventData , i) ); + } + } + + // Y Layer2 + // E + for(unsigned int i = 0 ; i < m_Layer2_StripYEMult ; ++i){ + if( m_EventData->GetCharissaLayer2StripYEEnergy(i)<m_Si_Y_E_RAW_Threshold && IsValidChannel("Y", m_EventData->GetCharissaLayer2StripYEDetectorNbr(i), m_EventData->GetCharissaLayer1StripYEStripNbr(i))){ + double Layer2_EY = fSi_Y_E(m_EventData , i); + if( Layer2_EY >m_Si_Y_E_Threshold ){ + m_PreTreatedData->SetCharissaLayer2StripYEDetectorNbr( m_EventData->GetCharissaLayer2StripYEDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripYEStripNbr( m_EventData->GetCharissaLayer2StripYEStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripYEEnergy( Layer2_EY ); + } + } + } + + // T + for(unsigned int i = 0 ; i < m_Layer2_StripYTMult ; ++i){ + if( IsValidChannel("Y", m_EventData->GetCharissaLayer2StripYTDetectorNbr(i), m_EventData->GetCharissaLayer1StripYTStripNbr(i))){ + m_PreTreatedData->SetCharissaLayer2StripYTDetectorNbr( m_EventData->GetCharissaLayer2StripYTDetectorNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripYTStripNbr( m_EventData->GetCharissaLayer2StripYTStripNbr(i) ); + m_PreTreatedData->SetCharissaLayer2StripYTTime( fSi_Y_T(m_EventData,i) ); + } + } + + // CsI + // E + for(unsigned int i = 0 ; i < m_CsIEMult ; ++i){ + if( m_EventData->GetCharissaCsIEEnergy(i)>m_CsI_E_RAW_Threshold && IsValidChannel("CsI", m_EventData->GetCharissaCsIEDetectorNbr(i), m_EventData->GetCharissaCsIECristalNbr(i))){ + double ECsI = fCsI_E(m_EventData , i); + if( ECsI > m_CsI_E_Threshold ){ + m_PreTreatedData->SetCharissaCsIEDetectorNbr( m_EventData->GetCharissaCsIEDetectorNbr(i) ); + m_PreTreatedData->SetCharissaCsIECristalNbr( m_EventData->GetCharissaCsIECristalNbr(i) ); + m_PreTreatedData->SetCharissaCsIEEnergy( ECsI ); + } + } + } + + // T + for(unsigned int i = 0 ; i < m_CsITMult ; ++i){ + if(IsValidChannel("CsI", m_EventData->GetCharissaCsITDetectorNbr(i), m_EventData->GetCharissaCsITCristalNbr(i))){ + m_PreTreatedData->SetCharissaCsITDetectorNbr( m_EventData->GetCharissaCsITDetectorNbr(i) ); + m_PreTreatedData->SetCharissaCsITCristalNbr( m_EventData->GetCharissaCsITCristalNbr(i) ); + m_PreTreatedData->SetCharissaCsITTime( fCsI_T(m_EventData , i) ); + } + } + + return; +} + + +/////////////////////////////////////////////////////////////////////////// +int TCharissaPhysics :: Layer1_CheckEvent(){ + // Check the size of the different elements + if( m_PreTreatedData->GetCharissaLayer1StripXEMult() == m_PreTreatedData->GetCharissaLayer1StripYEMult() /*&& m_PreTreatedData->GetCharissaLayer1StripYEMult() == m_PreTreatedData->GetCharissaLayer1StripXTMult() && m_PreTreatedData->GetCharissaLayer1StripXTMult() == m_PreTreatedData->GetCharissaLayer1StripYTMult()*/ ) + return 1 ; // Regular Event + + else if( m_PreTreatedData->GetCharissaLayer1StripXEMult() == m_PreTreatedData->GetCharissaLayer1StripYEMult()+1 || m_PreTreatedData->GetCharissaLayer1StripXEMult() == m_PreTreatedData->GetCharissaLayer1StripYEMult()-1 ) + return 2 ; // Pseudo Event, potentially interstrip + + else + return -1 ; // Rejected Event + +} + +/////////////////////////////////////////////////////////////////////////// +int TCharissaPhysics :: Layer2_CheckEvent(){ + // Check the size of the different elements + if( m_PreTreatedData->GetCharissaLayer2StripXEMult() == m_PreTreatedData->GetCharissaLayer2StripYEMult() /*&& m_PreTreatedData->GetCharissaLayer1StripYEMult() == m_PreTreatedData->GetCharissaLayer1StripXTMult() && m_PreTreatedData->GetCharissaLayer1StripXTMult() == m_PreTreatedData->GetCharissaLayer1StripYTMult()*/ ) + return 1 ; // Regular Event + + else if( m_PreTreatedData->GetCharissaLayer2StripXEMult() == m_PreTreatedData->GetCharissaLayer2StripYEMult()+1 || m_PreTreatedData->GetCharissaLayer2StripXEMult() == m_PreTreatedData->GetCharissaLayer2StripYEMult()-1 ) + return 2 ; // Pseudo Event, potentially interstrip + + else + return -1 ; // Rejected Event + +} + +/////////////////////////////////////////////////////////////////////////// +bool TCharissaPhysics :: ResolvePseudoEvent(){ + return false; +} + +/////////////////////////////////////////////////////////////////////////// +vector < TVector2 > TCharissaPhysics :: Layer1_Match_X_Y(){ + vector < TVector2 > ArrayOfGoodCouple ; + m_Layer1_StripXEMult = m_PreTreatedData->GetCharissaLayer1StripXEMult(); + m_Layer1_StripYEMult = m_PreTreatedData->GetCharissaLayer1StripXEMult(); + + // Prevent code from treating very high multiplicity Event + // Those event are not physical anyway and that improve speed. + if( m_Layer1_StripXEMult > m_MaximumStripMultiplicityAllowed || m_Layer1_StripYEMult > m_MaximumStripMultiplicityAllowed ) + return ArrayOfGoodCouple; + + for(unsigned int i = 0 ; i < m_Layer1_StripXEMult ; ++i){ + for(unsigned int j = 0 ; j < m_Layer1_StripYEMult ; j++){ + // if same detector check energy + if ( m_PreTreatedData->GetCharissaLayer1StripXEDetectorNbr(i) == m_PreTreatedData->GetCharissaLayer1StripYEDetectorNbr(j) ){ + // Look if energy match + if( abs( (m_PreTreatedData->GetCharissaLayer1StripXEEnergy(i)-m_PreTreatedData->GetCharissaLayer1StripYEEnergy(j))/2. ) < m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma ){ + // Special Option, if the event is between two CsI cristal, it is rejected. + if(m_Ignore_not_matching_CsI){ + bool check_validity=false; + for (unsigned int hh = 0 ; hh<m_NumberOfStrip ; ++hh ){ + if( Match_Si_CsI(m_PreTreatedData->GetCharissaLayer1StripXEStripNbr(i), m_PreTreatedData->GetCharissaLayer1StripYEStripNbr(j) , hh+1) ) + check_validity=true; + } + + if(check_validity) + ArrayOfGoodCouple . push_back ( TVector2(i,j) ) ; + } + + + + // Regular case, keep the event + else ArrayOfGoodCouple . push_back ( TVector2(i,j) ) ; + } + } + } + } + + // Prevent to treat event with ambiguous matchin beetween X and Y + if( ArrayOfGoodCouple.size() > m_Layer1_StripXEMult ) ArrayOfGoodCouple.clear() ; + + return ArrayOfGoodCouple; +} + +/////////////////////////////////////////////////////////////////////////// +vector < TVector2 > TCharissaPhysics :: Layer2_Match_X_Y(){ + vector < TVector2 > ArrayOfGoodCouple ; + m_Layer2_StripXEMult = m_PreTreatedData->GetCharissaLayer2StripXEMult(); + m_Layer2_StripYEMult = m_PreTreatedData->GetCharissaLayer2StripXEMult(); + + // Prevent code from treating very high multiplicity Event + // Those event are not physical anyway and that improve speed. + if( m_Layer2_StripXEMult > m_MaximumStripMultiplicityAllowed || m_Layer2_StripYEMult > m_MaximumStripMultiplicityAllowed ) + return ArrayOfGoodCouple; + + for(unsigned int i = 0 ; i < m_Layer2_StripXEMult ; ++i){ + for(unsigned int j = 0 ; j < m_Layer2_StripYEMult ; j++){ + // if same detector check energy + if ( m_PreTreatedData->GetCharissaLayer2StripXEDetectorNbr(i) == m_PreTreatedData->GetCharissaLayer2StripYEDetectorNbr(j) ){ + // Look if energy match + if( abs( (m_PreTreatedData->GetCharissaLayer2StripXEEnergy(i)-m_PreTreatedData->GetCharissaLayer2StripYEEnergy(j))/2. ) < m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma ){ + // Special Option, if the event is between two CsI cristal, it is rejected. + if(m_Ignore_not_matching_CsI){ + bool check_validity=false; + for (unsigned int hh = 0 ; hh<m_NumberOfStrip ; ++hh ){ + if( Match_Si_CsI(m_PreTreatedData->GetCharissaLayer2StripXEStripNbr(i), m_PreTreatedData->GetCharissaLayer2StripYEStripNbr(j) , hh+1) ) + check_validity=true; + } + + if(check_validity) + ArrayOfGoodCouple . push_back ( TVector2(i,j) ) ; + } + + + + // Regular case, keep the event + else ArrayOfGoodCouple . push_back ( TVector2(i,j) ) ; + } + } + } + } + + // Prevent to treat event with ambiguous matchin beetween X and Y + if( ArrayOfGoodCouple.size() > m_Layer2_StripXEMult ) ArrayOfGoodCouple.clear() ; + + return ArrayOfGoodCouple; +} + + + + + +//////////////////////////////////////////////////////////////////////////// +bool TCharissaPhysics :: IsValidChannel(const string DetectorType, const int telescope , const int channel){ + if(DetectorType == "CsI") + return *(m_CsIChannelStatus[telescope-1].begin()+channel-1); + + else if(DetectorType == "X") + return *(m_XChannelStatus[telescope-1].begin()+channel-1); + + else if(DetectorType == "Y") + return *(m_YChannelStatus[telescope-1].begin()+channel-1); + + else return false; +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::ReadAnalysisConfig(){ + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigCharissa.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigCharissa.dat found: Default parameters loaded for Analysis " << FileName << endl; + return; + } + cout << " Loading user parameters for Analysis from ConfigCharissa.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigCharissaCHARISSA.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, "ConfigCharissa") == 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 telescope = atoi(DataBuffer.substr(2,1).c_str()); + vector< bool > ChannelStatus; + ChannelStatus.resize( m_NumberOfStrip,false); + m_XChannelStatus[telescope-1] = ChannelStatus; + m_YChannelStatus[telescope-1] = ChannelStatus; + ChannelStatus.resize(m_NumberOfStrip,false); + m_CsIChannelStatus[telescope-1] = ChannelStatus; + } + + else if (whatToDo == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int telescope = atoi(DataBuffer.substr(2,1).c_str()); + int channel = -1; + if (DataBuffer.compare(3,4,"STRX") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + *(m_XChannelStatus[telescope-1].begin()+channel-1) = false; + } + + else if (DataBuffer.compare(3,4,"STRY") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + *(m_YChannelStatus[telescope-1].begin()+channel-1) = false; + } + + + else if (DataBuffer.compare(3,3,"CSI") == 0) { + channel = atoi(DataBuffer.substr(6).c_str()); + *(m_CsIChannelStatus[telescope-1].begin()+channel-1) = false; + } + + else cout << "Warning: detector type for CharissaCHARISSA unknown!" << endl; + + } + + else if (whatToDo=="TAKE_E_Y") { + m_Take_E_Y = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_T_Y") { + m_Take_T_Y = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_E_X") { + m_Take_E_Y = false; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_T_X") { + m_Take_T_Y = false; + cout << whatToDo << endl; + } + + else if (whatToDo== "IGNORE_NOT_MATCHING_CSI") { + m_Ignore_not_matching_CsI = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="CSI_SIZE") { + AnalysisConfigFile >> DataBuffer; + m_CsI_Size = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_CsI_Size << endl; + } + + + else if (whatToDo=="SI_X_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_X_E_RAW_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_X_E_RAW_Threshold << endl; + } + + else if (whatToDo=="SI_Y_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_Y_E_RAW_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_Y_E_RAW_Threshold << endl; + } + + + else if (whatToDo== "CSI_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_CsI_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_CsI_E_Threshold << endl; + } + + else if (whatToDo=="SI_X_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_X_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_X_E_Threshold << endl; + } + + else if (whatToDo== "SI_Y_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_Y_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_Y_E_Threshold << endl; + } + + + else if (whatToDo=="CSI_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_CsI_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_CsI_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + + } + } +} + + + + +/////////////////////////////////////////////////////////////////////////// +bool TCharissaPhysics :: Match_Si_CsI(int X, int Y , int CristalNbr){ + + if( abs(m_CsI_MatchingX[CristalNbr-1] - X) < m_CsI_Size/2.&& + abs(m_CsI_MatchingY[CristalNbr-1] - Y) < m_CsI_Size/2.) + + return true ; + + else return false; + +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::Clear(){ + EventMultiplicity= 0 ; + + Layer1_TelescopeNumber.clear(); + EventType.clear(); + TotalEnergy.clear(); + + // Si X + Layer1_Si_E.clear(); + Layer1_Si_T.clear(); + Layer1_Si_X.clear(); + Layer1_Si_Y.clear(); + Layer2_Si_E.clear(); + Layer2_Si_T.clear(); + Layer2_Si_X.clear(); + Layer2_Si_Y.clear(); + + + // CsI + CsI_E.clear(); + CsI_T.clear(); + CsI_N.clear(); + + Layer1_Si_EX.clear(); + Layer1_Si_TX.clear(); + Layer1_Si_EY.clear(); + Layer1_Si_TY.clear(); + Layer1_TelescopeNumber_X.clear(); + Layer1_TelescopeNumber_Y.clear(); + Layer2_Si_EX.clear(); + Layer2_Si_TX.clear(); + Layer2_Si_EY.clear(); + Layer2_Si_TY.clear(); + Layer2_TelescopeNumber_X.clear(); + Layer2_TelescopeNumber_Y.clear(); +} +/////////////////////////////////////////////////////////////////////////// + +void TCharissaPhysics::ReadCalibrationRun(){ + m_Layer1_StripXEMult = m_EventData->GetCharissaLayer1StripXEMult(); + m_Layer1_StripYEMult = m_EventData->GetCharissaLayer1StripYEMult(); + m_Layer1_StripXTMult = m_EventData->GetCharissaLayer1StripXTMult(); + m_Layer1_StripYTMult = m_EventData->GetCharissaLayer1StripYTMult(); + m_Layer2_StripXEMult = m_EventData->GetCharissaLayer2StripXEMult(); + m_Layer2_StripYEMult = m_EventData->GetCharissaLayer2StripYEMult(); + m_Layer2_StripXTMult = m_EventData->GetCharissaLayer2StripXTMult(); + m_Layer2_StripYTMult = m_EventData->GetCharissaLayer2StripYTMult(); + m_CsIEMult = m_EventData->GetCharissaCsIEMult(); + m_CsITMult = m_EventData->GetCharissaCsITMult(); + + // X Layer 1 + // E + for(unsigned int i = 0 ; i < m_Layer1_StripXEMult;++i){ + Layer1_TelescopeNumber_X.push_back(m_EventData->GetCharissaLayer1StripXEDetectorNbr(i)); + Layer1_Si_EX.push_back( fSi_X_E( m_EventData , i) ); + Layer1_Si_X.push_back(m_EventData->GetCharissaLayer1StripXEStripNbr(i)); + } + // T + for(unsigned int i = 0 ; i < m_Layer1_StripXTMult;++i){ + Layer1_TelescopeNumber_X.push_back(m_EventData->GetCharissaLayer1StripXTDetectorNbr(i)); + Layer1_Si_TX.push_back( fSi_X_T( m_EventData , i) ); + Layer1_Si_X.push_back(m_EventData->GetCharissaLayer1StripXTStripNbr(i)); + } + + // Y Layer 1 + // E + for(unsigned int i = 0 ; i < m_Layer1_StripYEMult;++i){ + Layer1_TelescopeNumber_Y.push_back(m_EventData->GetCharissaLayer1StripYEDetectorNbr(i)); + Layer1_Si_EY.push_back( fSi_Y_E( m_EventData , i) ); + Layer1_Si_Y.push_back(m_EventData->GetCharissaLayer1StripYEStripNbr(i)); + } + + // T + for(unsigned int i = 0 ; i < m_Layer1_StripYTMult;++i){ + Layer1_TelescopeNumber_Y.push_back(m_EventData->GetCharissaLayer1StripYTDetectorNbr(i)); + Layer1_Si_TY.push_back( fSi_Y_T( m_EventData , i) ); + Layer1_Si_Y.push_back(m_EventData->GetCharissaLayer1StripYTStripNbr(i)); + } + + + // X Layer 2 + // E + for(unsigned int i = 0 ; i < m_Layer2_StripXEMult;++i){ + Layer2_TelescopeNumber_X.push_back(m_EventData->GetCharissaLayer2StripXEDetectorNbr(i)); + Layer2_Si_EX.push_back( fSi_X_E( m_EventData , i) ); + Layer2_Si_X.push_back(m_EventData->GetCharissaLayer2StripXEStripNbr(i)); + } + // T + for(unsigned int i = 0 ; i < m_Layer2_StripXTMult;++i){ + Layer2_TelescopeNumber_X.push_back(m_EventData->GetCharissaLayer2StripXTDetectorNbr(i)); + Layer2_Si_TX.push_back( fSi_X_T( m_EventData , i) ); + Layer2_Si_X.push_back(m_EventData->GetCharissaLayer2StripXTStripNbr(i)); + } + + // Y Layer 2 + // E + for(unsigned int i = 0 ; i < m_Layer2_StripYEMult;++i){ + Layer2_TelescopeNumber_Y.push_back(m_EventData->GetCharissaLayer2StripYEDetectorNbr(i)); + Layer2_Si_EY.push_back( fSi_Y_E( m_EventData , i) ); + Layer2_Si_Y.push_back(m_EventData->GetCharissaLayer2StripYEStripNbr(i)); + } + + // T + for(unsigned int i = 0 ; i < m_Layer2_StripYTMult;++i){ + Layer2_TelescopeNumber_Y.push_back(m_EventData->GetCharissaLayer2StripYTDetectorNbr(i)); + Layer2_Si_TY.push_back( fSi_Y_T( m_EventData , i) ); + Layer2_Si_Y.push_back(m_EventData->GetCharissaLayer2StripYTStripNbr(i)); + } + + + //CsI Energy + for(unsigned int j = 0 ; j < m_CsIEMult ; ++j){ + CsI_N.push_back(m_EventData->GetCharissaCsIECristalNbr(j)) ; + CsI_E.push_back(fCsI_E(m_EventData , j)) ; + } + + //CsI Time + for(unsigned int j = 0 ; j < m_CsITMult ; ++j){ + CsI_T.push_back(fCsI_T(m_EventData , j)) ; + } + +} + +//// Innherited from VDetector Class //// + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::ReadConfiguration(string Path){ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + // A:X1_Y1 --> X:1 Y:1 + // B:X m_NumberOfStrip_Y1 --> X: m_NumberOfStrip Y:1 + // C:X1_Y m_NumberOfStrip --> X:1 Y: m_NumberOfStrip + // D:X m_NumberOfStrip_Y m_NumberOfStrip --> X: m_NumberOfStrip Y: m_NumberOfStrip + + double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz; + TVector3 A , B , C , D; + double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0; + + bool check_A = false ; + bool check_C = false ; + bool check_B = false ; + bool check_D = false ; + + bool check_Theta = false ; + bool check_Phi = false ; + bool check_R = false ; + bool check_beta = false ; + + bool ReadingStatus = false ; + + + while (!ConfigFile.eof()) + { + + getline(ConfigFile, LineBuffer); + + // If line is a Start Up CharissaCHARISSA bloc, Reading toggle to true + if (LineBuffer.compare(0, 17, "CharissaTelescope")==0) + { + cout << "///" << endl ; + cout << "Telescope found: " << endl ; + ReadingStatus = true ; + + } + + // Else don't toggle to Reading Block Status + else ReadingStatus = false ; + + // Reading Block + while(ReadingStatus) + { + + ConfigFile >> DataBuffer ; + // Comment Line + if(DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); + + } + + // Finding another telescope (safety), toggle out + else if (DataBuffer=="CharissaTelescope") { + cout << "WARNING: Another Telescope is find before standard sequence of Token, Error may occured in Telecope definition" << endl ; + ReadingStatus = false ; + } + + // Position method + + else if (DataBuffer=="X1_Y1=") { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + + A = TVector3(Ax, Ay, Az); + cout << "X1 Y1 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl; + + } + + + else if (DataBuffer=="X16_Y1=") { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + + B = TVector3(Bx, By, Bz); + cout << "X16 Y1 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl; + + } + + + else if (DataBuffer=="X1_Y16=") { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + + C = TVector3(Cx, Cy, Cz); + cout << "X1 Y16 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl; + + } + + else if (DataBuffer=="X16_Y16=") { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + + D = TVector3(Dx, Dy, Dz); + cout << "X16 Y16 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl; + + } + + // End Position Method + + // Angle method + else if (DataBuffer=="THETA=") { + check_Theta = true; + ConfigFile >> DataBuffer ; + Theta = atof(DataBuffer.c_str()) ; + cout << "Theta: " << Theta << endl; + + } + + //Angle method + else if (DataBuffer=="PHI=") { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi = atof(DataBuffer.c_str()) ; + cout << "Phi: " << Phi << endl; + + } + + //Angle method + else if (DataBuffer=="R=") { + check_R = true; + ConfigFile >> DataBuffer ; + R = atof(DataBuffer.c_str()) ; + cout << "R: " << R << endl; + + } + + //Angle method + else if (DataBuffer=="BETA=") { + check_beta = true; + ConfigFile >> DataBuffer ; + beta_u = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + beta_v = atof(DataBuffer.c_str()) ; + ConfigFile >> DataBuffer ; + beta_w = atof(DataBuffer.c_str()) ; + cout << "Beta: " << beta_u << " " << beta_v << " " << beta_w << endl ; + + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + if ( (check_A && check_B && check_C && check_D) || (check_Theta && check_Phi && check_R && check_beta) ) + { + ReadingStatus = false; + + ///Add The previously define telescope + //With position method + if ( check_A && check_B && check_C && check_D ) + { + AddTelescope( A, + B, + C, + D) ; + } + + //with angle method + else if ( check_Theta && check_Phi && check_R && check_beta ) + { + AddTelescope( Theta, + Phi, + R, + beta_u, + beta_v, + beta_w); + } + + check_A = false ; + check_B = false ; + check_C = false ; + check_D = false ; + + check_Theta = false ; + check_Phi = false ; + check_R = false ; + check_beta = false ; + } + } + } + + InitializeStandardParameter(); + ReadAnalysisConfig(); + + cout << endl << "/////////////////////////////" << endl << endl; + +} +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::InitSpectra(){ + m_Spectra = new TCharissaSpectra(m_NumberOfTelescope); +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::FillSpectra(){ + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); +} +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::CheckSpectra(){ + m_Spectra->CheckSpectra(); +} +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< vector<TString> , TH1*> TCharissaPhysics::GetSpectra() { +return m_Spectra->GetMapHisto(); +} +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::AddParameterToCalibrationManager() +{ + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < m_NumberOfTelescope ; ++i){ + + for( int j = 0 ; j < m_NumberOfStrip ; ++j){ + Cal->AddParameter("CHARISSA", "T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_E","CHARISSA_T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_E") ; + Cal->AddParameter("CHARISSA", "T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_E","CHARISSA_T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_E") ; + Cal->AddParameter("CHARISSA", "T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_T","CHARISSA_T"+itoa(i+1)+"_Si_X"+itoa(j+1)+"_T") ; + Cal->AddParameter("CHARISSA", "T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_T","CHARISSA_T"+itoa(i+1)+"_Si_Y"+itoa(j+1)+"_T") ; + } + + for( int j = 0 ; j < m_NumberOfStrip ; ++j){ + Cal->AddParameter("CHARISSA", "T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_E","CHARISSA_T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_E") ; + Cal->AddParameter("CHARISSA", "T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_T","CHARISSA_T"+itoa(i+1)+"_CsI"+itoa(j+1)+"_T") ; + } + } + + return; + +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::InitializeRootInputRaw() +{ + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus( "CHARISSA" , true ) ; + inputChain->SetBranchStatus( "fMM_*" , true ) ; + inputChain->SetBranchAddress( "CHARISSA" , &m_EventData ) ; +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::InitializeRootInputPhysics() +{ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus( "CHARISSA" , true ); + inputChain->SetBranchStatus( "EventMultiplicity" , true ); + inputChain->SetBranchStatus( "EventType" , true ); + inputChain->SetBranchStatus( "Layer1_TelescopeNumber" , true ); + inputChain->SetBranchStatus( "Layer1_Si_E" , true ); + inputChain->SetBranchStatus( "Layer1_Si_T" , true ); + inputChain->SetBranchStatus( "Layer1_Si_X" , true ); + inputChain->SetBranchStatus( "Layer1_Si_Y" , true ); + inputChain->SetBranchStatus( "Layer1_Si_EX" , true ); + inputChain->SetBranchStatus( "Layer1_Si_TX" , true ); + inputChain->SetBranchStatus( "Layer1_Si_EY" , true ); + inputChain->SetBranchStatus( "Layer1_Si_TY" , true ); + inputChain->SetBranchStatus( "Layer1_TelescopeNumber_X" , true ); + inputChain->SetBranchStatus( "Layer1_TelescopeNumber_Y" , true ); + inputChain->SetBranchStatus( "Layer2_TelescopeNumber" , true ); + inputChain->SetBranchStatus( "Layer2_Si_E" , true ); + inputChain->SetBranchStatus( "Layer2_Si_T" , true ); + inputChain->SetBranchStatus( "Layer2_Si_X" , true ); + inputChain->SetBranchStatus( "Layer2_Si_Y" , true ); + inputChain->SetBranchStatus( "Layer2_Si_EX" , true ); + inputChain->SetBranchStatus( "Layer2_Si_TX" , true ); + inputChain->SetBranchStatus( "Layer2_Si_EY" , true ); + inputChain->SetBranchStatus( "Layer2_Si_TY" , true ); + inputChain->SetBranchStatus( "Layer2_TelescopeNumber_X" , true ); + inputChain->SetBranchStatus( "Layer2_TelescopeNumber_Y" , true ); + inputChain->SetBranchStatus( "CsI_E" , true ); + inputChain->SetBranchStatus( "CsI_T" , true ); + inputChain->SetBranchStatus( "CsI_N" , true ); + inputChain->SetBranchStatus( "TotalEnergy" , true ); + inputChain->SetBranchAddress( "CHARISSA" , &m_EventPhysics); +} + +/////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::InitializeRootOutput() +{ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch( "CHARISSA" , "TCharissaPhysics" , &m_EventPhysics ); +} + + +///// Specific to CHARISSAArray //// +///////////////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::AddTelescope( TVector3 C_X1_Y1, + TVector3 C_X16_Y1, + TVector3 C_X1_Y16, + TVector3 C_X16_Y16) +{ + // To avoid warning + C_X16_Y16 *= 1; + + m_NumberOfTelescope++; + + // Vector U on Telescope Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U = C_X16_Y1 - C_X1_Y1 ; + double Ushift = (U.Mag()-98)/2.; + U = U.Unit(); + // Vector V on Telescope Face (parallele to X Strip) + TVector3 V = C_X1_Y16 - C_X1_Y1 ; + double Vshift = (V.Mag() -98)/2. ; + V = V.Unit() ; + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0,0,0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + // Geometry Parameter + double Face = 98; //mm + double NumberOfStrip = m_NumberOfStrip; + double StripPitch = Face/NumberOfStrip ; //mm + // Buffer object to fill Position Array + vector<double> lineX ; vector<double> lineY ; vector<double> lineZ ; + + vector< vector< double > > OneTelescopeStripPositionX ; + vector< vector< double > > OneTelescopeStripPositionY ; + vector< vector< double > > OneTelescopeStripPositionZ ; + + // Moving StripCenter to 1.1 corner: + Strip_1_1 = C_X1_Y1 + (U+V) * (StripPitch/2.) ; + Strip_1_1+= U*Ushift+V*Vshift ; + + for( int i = 0 ; i < m_NumberOfStrip ; ++i ) + { + lineX.clear() ; + lineY.clear() ; + lineZ.clear() ; + + for( int j = 0 ; j < m_NumberOfStrip ; ++j ) + { + StripCenter = Strip_1_1 + StripPitch*( i*U + j*V ); + lineX.push_back( StripCenter.X() ); + lineY.push_back( StripCenter.Y() ); + lineZ.push_back( StripCenter.Z() ); + } + + OneTelescopeStripPositionX.push_back(lineX); + OneTelescopeStripPositionY.push_back(lineY); + OneTelescopeStripPositionZ.push_back(lineZ); + + } + m_StripPositionX.push_back( OneTelescopeStripPositionX ) ; + m_StripPositionY.push_back( OneTelescopeStripPositionY ) ; + m_StripPositionZ.push_back( OneTelescopeStripPositionZ ) ; + +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::InitializeStandardParameter() +{ + // Enable all channel + vector< bool > ChannelStatus; + m_XChannelStatus.clear() ; + m_YChannelStatus.clear() ; + m_CsIChannelStatus.clear() ; + + ChannelStatus.resize(m_NumberOfStrip,true); + for(int i = 0 ; i < m_NumberOfTelescope ; ++i) + { + m_XChannelStatus[i] = ChannelStatus; + m_YChannelStatus[i] = ChannelStatus; + } + + ChannelStatus.resize(m_NumberOfStrip,true); + for(int i = 0 ; i < m_NumberOfTelescope ; ++i) + { + m_CsIChannelStatus[i] = ChannelStatus; + } + + + m_MaximumStripMultiplicityAllowed = m_NumberOfTelescope ; + + return; +} + + +////////////////////////////////////////////////////////////////////////////////////////////// +void TCharissaPhysics::AddTelescope( double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w) +{ + + + m_NumberOfTelescope++; + + double Pi = 3.141592654 ; + + // convert from degree to radian: + theta = theta * Pi/180. ; + phi = phi * Pi/180. ; + + //Vector U on Telescope Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U ; + //Vector V on Telescope Face (parallele to X Strip) + TVector3 V ; + //Vector W normal to Telescope Face (pointing CsI) + TVector3 W ; + //Vector position of Telescope Face center + TVector3 C ; + + C = TVector3 ( distance * sin(theta) * cos(phi) , + distance * sin(theta) * sin(phi) , + distance * cos(theta) ); + + TVector3 P = TVector3( cos(theta ) * cos(phi) , + cos(theta ) * sin(phi) , + -sin(theta) ); + + W = C.Unit() ; + U = W .Cross ( P ) ; + V = W .Cross ( U ); + + U = U.Unit(); + V = V.Unit(); + + U.Rotate( beta_u * Pi/180. , U ) ; + V.Rotate( beta_u * Pi/180. , U ) ; + + U.Rotate( beta_v * Pi/180. , V ) ; + V.Rotate( beta_v * Pi/180. , V ) ; + + U.Rotate( beta_w * Pi/180. , W ) ; + V.Rotate( beta_w * Pi/180. , W ) ; + + double Face = 98 ; //mm + double NumberOfStrip = m_NumberOfStrip ; + double StripPitch = Face/NumberOfStrip ; //mm + + vector<double> lineX ; vector<double> lineY ; vector<double> lineZ ; + + vector< vector< double > > OneTelescopeStripPositionX ; + vector< vector< double > > OneTelescopeStripPositionY ; + vector< vector< double > > OneTelescopeStripPositionZ ; + + double X , Y , Z ; + + //Moving C to the 1.1 corner: + C.SetX( C.X() - ( Face/2 - StripPitch/2 ) * ( V.X() + U.X() ) ) ; + C.SetY( C.Y() - ( Face/2 - StripPitch/2 ) * ( V.Y() + U.Y() ) ) ; + C.SetZ( C.Z() - ( Face/2 - StripPitch/2 ) * ( V.Z() + U.Z() ) ) ; + + for( int i = 0 ; i < m_NumberOfStrip ; ++i ) + { + + lineX.clear() ; + lineY.clear() ; + lineZ.clear() ; + + for( int j = 0 ; j < m_NumberOfStrip ; ++j ) + { + X = C.X() + StripPitch * ( U.X()*i + V.X()*j ) ; + Y = C.Y() + StripPitch * ( U.Y()*i + V.Y()*j ) ; + Z = C.Z() + StripPitch * ( U.Z()*i + V.Z()*j ) ; + + lineX.push_back(X) ; + lineY.push_back(Y) ; + lineZ.push_back(Z) ; + + } + + OneTelescopeStripPositionX.push_back(lineX) ; + OneTelescopeStripPositionY.push_back(lineY) ; + OneTelescopeStripPositionZ.push_back(lineZ) ; + + } + m_StripPositionX.push_back( OneTelescopeStripPositionX ) ; + m_StripPositionY.push_back( OneTelescopeStripPositionY ) ; + m_StripPositionZ.push_back( OneTelescopeStripPositionZ ) ; +} + + +////////////////////////////////////////////////////////////////////////////////////////////// +TVector3 TCharissaPhysics::GetPositionOfInteraction(const int i) const +{ + TVector3 Position = TVector3 ( GetStripPositionX( Layer1_TelescopeNumber[i] , Layer1_Si_X[i] , Layer1_Si_Y[i] ) , + GetStripPositionY( Layer1_TelescopeNumber[i] , Layer1_Si_X[i] , Layer1_Si_Y[i] ) , + GetStripPositionZ( Layer1_TelescopeNumber[i] , Layer1_Si_X[i] , Layer1_Si_Y[i] ) ) ; + + return(Position) ; + +} + +TVector3 TCharissaPhysics::GetTelescopeNormal( const int i) const +{ + TVector3 U = TVector3 ( GetStripPositionX( Layer1_TelescopeNumber[i] , m_NumberOfStrip , 1 ) , + GetStripPositionY( Layer1_TelescopeNumber[i] , m_NumberOfStrip , 1 ) , + GetStripPositionZ( Layer1_TelescopeNumber[i] , m_NumberOfStrip , 1 ) ) + + -TVector3 ( GetStripPositionX( Layer1_TelescopeNumber[i] , 1 , 1 ) , + GetStripPositionY( Layer1_TelescopeNumber[i] , 1 , 1 ) , + GetStripPositionZ( Layer1_TelescopeNumber[i] , 1 , 1 ) ); + + TVector3 V = TVector3 ( GetStripPositionX( Layer1_TelescopeNumber[i] , m_NumberOfStrip , m_NumberOfStrip ) , + GetStripPositionY( Layer1_TelescopeNumber[i] , m_NumberOfStrip , m_NumberOfStrip ) , + GetStripPositionZ( Layer1_TelescopeNumber[i] , m_NumberOfStrip , m_NumberOfStrip ) ) + + -TVector3 ( GetStripPositionX( Layer1_TelescopeNumber[i] , m_NumberOfStrip , 1 ) , + GetStripPositionY( Layer1_TelescopeNumber[i] , m_NumberOfStrip , 1 ) , + GetStripPositionZ( Layer1_TelescopeNumber[i] , m_NumberOfStrip , 1 ) ); + + TVector3 Normal = U.Cross(V); + + return(Normal.Unit()) ; +} + +/////////////////////////////////////////////////////////////////////////// +namespace CHARISSA_LOCAL +{ + + // tranform an integer to a string + string itoa(int value) + { +char buffer [33]; +sprintf(buffer,"%d",value); +return buffer; + } + + // DSSD + // X + double fSi_X_E(const TCharissaData* m_EventData , const int i) + { +return CalibrationManager::getInstance()->ApplyCalibration( "CHARISSA/T" + itoa( m_EventData->GetCharissaLayer1StripXEDetectorNbr(i) ) + "_Si_X" + itoa( m_EventData->GetCharissaLayer1StripXEStripNbr(i) ) + "_E", + m_EventData->GetCharissaLayer1StripXEEnergy(i) ); + } + + double fSi_X_T(const TCharissaData* m_EventData , const int i) + { +return CalibrationManager::getInstance()->ApplyCalibration( "CHARISSA/T" + itoa( m_EventData->GetCharissaLayer1StripXTDetectorNbr(i) ) + "_Si_X" + itoa( m_EventData->GetCharissaLayer1StripXTStripNbr(i) ) +"_T", + m_EventData->GetCharissaLayer1StripXTTime(i) ); + } + + // Y + double fSi_Y_E(const TCharissaData* m_EventData , const int i) + { +return CalibrationManager::getInstance()->ApplyCalibration( "CHARISSA/T" + itoa( m_EventData->GetCharissaLayer1StripYEDetectorNbr(i) ) + "_Si_Y" + itoa( m_EventData->GetCharissaLayer1StripYEStripNbr(i) ) +"_E", + m_EventData->GetCharissaLayer1StripYEEnergy(i) ); + } + + double fSi_Y_T(const TCharissaData* m_EventData , const int i) + { +return CalibrationManager::getInstance()->ApplyCalibration( "CHARISSA/T" + itoa( m_EventData->GetCharissaLayer1StripYTDetectorNbr(i) ) + "_Si_Y" + itoa( m_EventData->GetCharissaLayer1StripYTStripNbr(i) ) +"_T", + m_EventData->GetCharissaLayer1StripYTTime(i) ); + } + + // CsI + double fCsI_E(const TCharissaData* m_EventData , const int i) + { +return CalibrationManager::getInstance()->ApplyCalibration( "CHARISSA/T" + itoa( m_EventData->GetCharissaCsIEDetectorNbr(i) ) + "_CsI" + itoa( m_EventData->GetCharissaCsIECristalNbr(i) ) +"_E", + m_EventData->GetCharissaCsIEEnergy(i) ); + } + + double fCsI_T(const TCharissaData* m_EventData , const int i) + { +return CalibrationManager::getInstance()->ApplyCalibration( "CHARISSA/T" + itoa( m_EventData->GetCharissaCsITDetectorNbr(i) ) + "_CsI" + itoa( m_EventData->GetCharissaCsITCristalNbr(i) ) +"_T", + m_EventData->GetCharissaCsITTime(i) ); + } + +} + + diff --git a/NPLib/Charissa/TCharissaPhysics.h b/NPLib/Charissa/TCharissaPhysics.h new file mode 100755 index 0000000000000000000000000000000000000000..8e5bcb41c477f1c07ef3184422eddee1edac1314 --- /dev/null +++ b/NPLib/Charissa/TCharissaPhysics.h @@ -0,0 +1,310 @@ +#ifndef TCHARISSAPHYSICS_H +#define TCHARISSAPHYSICS_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: matta@ipno.in2p3.fr * + * * + * Creation Date : December 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold charissa treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ +// STL +#include <vector> +#include <map> +// NPL +#include "TCharissaData.h" +#include "TCharissaSpectra.h" +#include "../include/CalibrationManager.h" +#include "../include/VDetector.h" +// ROOT +#include "TVector2.h" +#include "TVector3.h" +#include "TObject.h" +#include "TH1.h" + +using namespace std ; + +// Forward Declaration +class TCharissaSpectra; + +class TCharissaPhysics : public TObject, public NPA::VDetector{ + public: + TCharissaPhysics(); + ~TCharissaPhysics(); + + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: + vector < TVector2 > Layer1_Match_X_Y(); + vector < TVector2 > Layer2_Match_X_Y(); + bool Match_Si_CsI(int X, int Y , int CristalNbr); + bool ResolvePseudoEvent(); + int Layer1_CheckEvent(); + int Layer2_CheckEvent(); + + public: + + // Provide Physical Multiplicity + Int_t EventMultiplicity; + + // Provide a Classification of Event + vector<int> EventType ; + + // Telescope + vector<int> Layer1_TelescopeNumber ; + vector<int> Layer2_TelescopeNumber ; + + // Si + vector<double> Layer1_Si_E ; + vector<double> Layer1_Si_T ; + vector<int> Layer1_Si_X ; + vector<int> Layer1_Si_Y ; + + vector<double> Layer2_Si_E ; + vector<double> Layer2_Si_T ; + vector<int> Layer2_Si_X ; + vector<int> Layer2_Si_Y ; + + // Use for checking purpose + vector<double> Layer1_Si_EX ; + vector<double> Layer1_Si_TX ; + vector<double> Layer1_Si_EY ; + vector<double> Layer1_Si_TY ; + vector<int> Layer1_TelescopeNumber_X ; + vector<int> Layer1_TelescopeNumber_Y ; + + vector<double> Layer2_Si_EX ; + vector<double> Layer2_Si_TX ; + vector<double> Layer2_Si_EY ; + vector<double> Layer2_Si_TY ; + vector<int> Layer2_TelescopeNumber_X ; + vector<int> Layer2_TelescopeNumber_Y ; + // Si(Li) + + + // CsI + vector<double> CsI_E ; + vector<double> CsI_T ; + vector<int> CsI_N ; + + // Physical Value + vector<double> TotalEnergy ; + + + 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 CHARISSA 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","CsI" + bool IsValidChannel(const string DetectorType, const int telescope , const int channel); + + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of telescope + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + // Add a Telescope using Corner Coordinate information + void AddTelescope( TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128); + + // Add a Telescope using R Theta Phi of Si center information + void AddTelescope( double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w); + + // Use for reading Calibration Run, very simple methods; only apply calibration, no condition + void ReadCalibrationRun(); + + // Give and external TMustData object to TCharissaPhysics. Needed for online analysis for example. + void SetRawDataPointer(TCharissaData* rawDataPointer) {m_EventData = rawDataPointer;} + // Retrieve raw and pre-treated data + TCharissaData* GetRawData() const {return m_EventData;} + TCharissaData* GetPreTreatedData() const {return m_PreTreatedData;} + + // Use to access the strip position + double GetStripPositionX( const int N , const int X , const int Y ) const{ return m_StripPositionX[N-1][X-1][Y-1] ; } ; + double GetStripPositionY( const int N , const int X , const int Y ) const{ return m_StripPositionY[N-1][X-1][Y-1] ; } ; + double GetStripPositionZ( const int N , const int X , const int Y ) const{ return m_StripPositionZ[N-1][X-1][Y-1] ; } ; + + double GetNumberOfTelescope() const { return m_NumberOfTelescope ; }; + + // To be called after a build Physical Event + int GetEventMultiplicity() const { return EventMultiplicity; }; + + double GetEnergyDeposit(const int i) const{ return TotalEnergy[i] ;}; + + TVector3 GetPositionOfInteraction(const int i) const; + TVector3 GetTelescopeNormal(const int i) const; + + private: // Parameter used in the analysis + + // By default take EX and TY. + bool m_Take_E_Y;//! + bool m_Take_T_Y;//! + + // Size Container to be used in the different loop of the analysis (value must be given locally) + unsigned int m_Layer1_StripXEMult;//! + unsigned int m_Layer1_StripYEMult;//! + unsigned int m_Layer1_StripXTMult;//! + unsigned int m_Layer1_StripYTMult;//! + unsigned int m_Layer2_StripXEMult;//! + unsigned int m_Layer2_StripYEMult;//! + unsigned int m_Layer2_StripXTMult;//! + unsigned int m_Layer2_StripYTMult;//! + unsigned int m_CsIEMult;//! + unsigned int m_CsITMult;//! + + + // Event over this value after pre-treatment are not treated / avoid long treatment time on spurious event + unsigned int m_MaximumStripMultiplicityAllowed ;//! + // Give the allowance in percent of the difference in energy between X and Y + double m_StripEnergyMatchingSigma ; //! + double m_StripEnergyMatchingNumberOfSigma ; //! + + // Raw Threshold + int m_Si_X_E_RAW_Threshold ;//! + int m_Si_Y_E_RAW_Threshold ;//! + int m_CsI_E_RAW_Threshold ;//! + + // Calibrated Threshold + double m_Si_X_E_Threshold ;//! + double m_Si_Y_E_Threshold ;//! + double m_CsI_E_Threshold ;//! + + // Geometric Matching + // size in strip of a cristal + int m_CsI_Size;//! + // center position of the cristal on X + vector< int > m_CsI_MatchingX;//! + // center position of the cristal on X + vector< int > m_CsI_MatchingY;//! + + // If set to true, all event that do not come in front of a cristal will be ignore all time (crossing or not), + // Warning, this option reduce statistic, however it help eliminating unrealevent event that cross the DSSD + // And go between pad or cristal. + bool m_Ignore_not_matching_CsI;//! + + private: // Root Input and Output tree classes + + TCharissaData* m_EventData;//! + TCharissaData* m_PreTreatedData;//! + TCharissaPhysics* m_EventPhysics;//! + + private: // Map of activated channel + map< int, vector<bool> > m_XChannelStatus;//! + map< int, vector<bool> > m_YChannelStatus;//! + map< int, vector<bool> > m_CsIChannelStatus;//! + + private: // Spatial Position of Strip Calculated on bases of detector position + + unsigned int m_NumberOfTelescope;//! + unsigned int m_NumberOfStrip;//! + + vector< vector < vector < double > > > m_StripPositionX;//! + vector< vector < vector < double > > > m_StripPositionY;//! + vector< vector < vector < double > > > m_StripPositionZ;//! + + private: // Spectra Class + TCharissaSpectra* m_Spectra;//! + + public: // Spectra Getter + map< vector<TString> , TH1*> GetSpectra(); + + ClassDef(TCharissaPhysics,1) // CharissaPhysics structure +}; + +namespace CHARISSA_LOCAL +{ + + // tranform an integer to a string + string itoa(int value); + // DSSD + // X + double fSi_X_E(const TCharissaData* Data, const int i); + double fSi_X_T(const TCharissaData* Data, const int i); + + // Y + double fSi_Y_E(const TCharissaData* Data, const int i); + double fSi_Y_T(const TCharissaData* Data, const int i); + + // CsI + double fCsI_E(const TCharissaData* Data, const int i); + double fCsI_T(const TCharissaData* Data, const int i); + +} + + +#endif diff --git a/NPLib/Charissa/TCharissaSpectra.cxx b/NPLib/Charissa/TCharissaSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..97e328052366dab76a4f700574614f2bfbaaad2c --- /dev/null +++ b/NPLib/Charissa/TCharissaSpectra.cxx @@ -0,0 +1,587 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Charissa * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// NPL +#include "TCharissaSpectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + + +// ROOT +#include "TString.h" +#include "TDirectory.h" +#include "TFile.h" + + +//////////////////////////////////////////////////////////////////////////////// +TCharissaSpectra::TCharissaSpectra() +{ + fNumberOfTelescope = 0; + fStripX = 16; + fStripY = 16; + fCrystalCsI = 1; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TCharissaSpectra::TCharissaSpectra(unsigned int NumberOfTelescope) +{ + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TCharissaSpectra : Initalising control spectra for " + << NumberOfTelescope << " Telescopes" << endl + << "************************************************" << endl ; + + fNumberOfTelescope = NumberOfTelescope; + fStripX = 16; + fStripY = 16; + fCrystalCsI = 1; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + + +//////////////////////////////////////////////////////////////////////////////// +TCharissaSpectra::~TCharissaSpectra(){ +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::InitRawSpectra() +{ + TString name; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { // loop on number of detectors + // L1_STRX_E_RAW + name = Form("CHA%d_L1_STRX_E_RAW", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 512, 0, 16384, "CHARISSA/RAW/STRXE"); + + // L1_STRY_E_RAW + name = Form("CHA%d_L1_STRY_E_RAW", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 512, 0, 16384, "CHARISSA/RAW/STRYE"); + + // L2_STRX_E_RAW + name = Form("CHA%d_L2_STRX_E_RAW", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 512, 0, 16384, "CHARISSA/RAW/STRXE"); + + // L2_STRY_E_RAW + name = Form("CHA%d_L2_STRY_E_RAW", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 512, 0, 16384, "CHARISSA/RAW/STRYE"); + + // CSI_E_RAW + name = Form("CHA%d_CSI_E_RAW", i+1); + AddHisto2D(name, name, fCrystalCsI, 1, fCrystalCsI+1, 512, 0, 16384, "CHARISSA/RAW/CSIE"); + + // L1_STRX_RAW_MULT + name = Form("CHA%d_L1_STRX_RAW_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/RAW/MULT"); + + // L1_STRY_RAW_MULT + name = Form("CHA%d_L1_STRY_RAW_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/RAW/MULT"); + + // L2_STRX_RAW_MULT + name = Form("CHA%d_L2_STRX_RAW_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/RAW/MULT"); + + // L2_STRY_RAW_MULT + name = Form("CHA%d_L2_STRY_RAW_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/RAW/MULT"); + + // CSI_RAW_MULT + name = Form("CHA%d_CSI_RAW_MULT", i+1); + AddHisto1D(name, name, fCrystalCsI, 1, fCrystalCsI+1, "CHARISSA/RAW/MULT"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::InitPreTreatedSpectra() +{ + TString name; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { // loop on number of detectors + // L1_STRX_E_CAL + name = Form("CHA%d_L1_STRX_E_CAL", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 500, 0, 50, "CHARISSA/CAL/STRXE"); + + // L1_STRY_E_CAL + name = Form("CHA%d_L1_STRY_E_CAL", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 500, 0, 50, "CHARISSA/CAL/STRYE"); + + // L2_STRX_E_CAL + name = Form("CHA%d_L2_STRX_E_CAL", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 500, 0, 50, "CHARISSA/CAL/STRXE"); + + // L2_STRY_E_CAL + name = Form("CHA%d_L2_STRY_E_CAL", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 500, 0, 50, "CHARISSA/CAL/STRYE"); + + // CSI_E_CAL + name = Form("CHA%d_CSI_E_CAL", i+1); + AddHisto2D(name, name, fCrystalCsI, 1, fCrystalCsI+1, 500, 0, 50, "CHARISSA/CAL/CSIE"); + + // STRX_L1_CAL_MULT + name = Form("CHA%d_L1_STRX_CAL_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/CAL/MULT"); + + // STRY_L1_CAL_MULT + name = Form("CHA%d_L1_STRY_CAL_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/CAL/MULT"); + + // STRX_L2_CAL_MULT + name = Form("CHA%d_L2_STRX_CAL_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/CAL/MULT"); + + // STRY_L2_CAL_MULT + name = Form("CHA%d_L2_STRY_CAL_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "CHARISSA/CAL/MULT"); + + // CSI_CAL_MULT + name = Form("CHA%d_CSI_CAL_MULT", i+1); + AddHisto1D(name, name, fCrystalCsI, 1, fCrystalCsI+1, "CHARISSA/CAL/MULT"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::InitPhysicsSpectra() +{ + TString name; + + // L1 X-Y Impact Matrix + name = "CHA_L1_IMPACT_MATRIX"; + AddHisto2D(name, name, 500, -150, 150, 500, -150, 150, "CHARISSA/PHY"); + + // L2 X-Y Impact Matrix + name = "CHA_L2_IMPACT_MATRIX"; + AddHisto2D(name, name, 500, -150, 150, 500, -150, 150, "CHARISSA/PHY"); + + // L1 kinematic line + name = "CHA_L1_THETA_E"; + AddHisto2D(name, name, 360, 0, 180, 500, 0, 50, "CHARISSA/PHY"); + + // L2 kinematic line + name = "CHA_L2_THETA_E"; + AddHisto2D(name, name, 360, 0, 180, 500, 0, 50, "CHARISSA/PHY"); + + // X-Y Energy Correlation + for (unsigned int i = 0 ; i < fNumberOfTelescope ; i++) { // loop on number of detectors + // L1 + name = Form("CHA%d_L1_XY_COR", i+1); + AddHisto2D(name, name, 500, 0, 50, 500, 0, 50, "CHARISSA/PHY"); + + // L2 + name = Form("CHA%d_L2_XY_COR", i+1); + AddHisto2D(name, name, 500, 0, 50, 500, 0, 50, "CHARISSA/PHY"); + } + + // ID Plot + // E-TOF: + name = "CHA_E_TOF"; + AddHisto2D(name, name,500,0,50,1000,200,1200,"CHARISSA/PHY"); + + // SILIE-DE: + name = "CHA_SILIE_E"; + AddHisto2D(name, name,500,0,200,500,0,50,"CHARISSA/PHY"); + + // CSI-DE: + name = "CHA_CSIE_E"; + AddHisto2D(name, name,500,0,500,500,0,50,"CHARISSA/PHY"); + + // Etot-DE: + name = "CHA_Etot_E"; + AddHisto2D(name, name,500,0,500,500,0,50,"CHARISSA/PHY"); + + + // ID plot detector by detector + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { // loop on number of detectors + // E-TOF: + name = Form("CHA%d_E_TOF",i+1); + AddHisto2D(name, name,500,0,50,1000,200,1200,"CHARISSA/PHY"); + + // SILIE-DE: + name = Form("CHA%d_SILIE_E",i+1); + AddHisto2D(name, name,500,0,200,500,0,50,"CHARISSA/PHY"); + + // CSI-DE: + name = Form("CHA%d_CSIE_E",i+1); + AddHisto2D(name, name,500,0,500,500,0,50,"CHARISSA/PHY"); + + // Etot-DE: + name = Form("CHA%d_Etot_E",i+1); + AddHisto2D(name, name,500,0,500,500,0,50,"CHARISSA/PHY"); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::FillRawSpectra(TCharissaData* RawData) +{ + TString name; + TString family; + // L1_STRX_E + for (unsigned int i = 0; i < RawData->GetCharissaLayer1StripXEMult(); i++) { + name = Form("CHA%d_L1_STRX_E_RAW", RawData->GetCharissaLayer1StripXEDetectorNbr(i)); + family = "CHARISSA/RAW/STRXE"; + GetHisto(family,name) -> Fill(RawData->GetCharissaLayer1StripXEStripNbr(i), RawData->GetCharissaLayer1StripXEEnergy(i)); + } + + // L1_STRY_E + for (unsigned int i = 0; i < RawData->GetCharissaLayer1StripYEMult(); i++) { + name = Form("CHA%d_L1_STRY_E_RAW", RawData->GetCharissaLayer1StripYEDetectorNbr(i)); + family = "CHARISSA/RAW/STRYE"; + GetHisto(family,name) -> Fill(RawData->GetCharissaLayer1StripYEStripNbr(i), RawData->GetCharissaLayer1StripYEEnergy(i)); + } + + // L2_STRX_E + for (unsigned int i = 0; i < RawData->GetCharissaLayer2StripXEMult(); i++) { + name = Form("CHA%d_L2_STRX_E_RAW", RawData->GetCharissaLayer2StripXEDetectorNbr(i)); + family = "CHARISSA/RAW/STRXE"; + GetHisto(family,name) -> Fill(RawData->GetCharissaLayer2StripXEStripNbr(i), RawData->GetCharissaLayer2StripXEEnergy(i)); + } + + // L2_STRY_E + for (unsigned int i = 0; i < RawData->GetCharissaLayer2StripYEMult(); i++) { + name = Form("CHA%d_L2_STRY_E_RAW", RawData->GetCharissaLayer2StripYEDetectorNbr(i)); + family = "CHARISSA/RAW/STRYE"; + GetHisto(family,name) -> Fill(RawData->GetCharissaLayer2StripYEStripNbr(i), RawData->GetCharissaLayer2StripYEEnergy(i)); + } + + // CSI_E + for (unsigned int i = 0; i < RawData->GetCharissaCsIEMult(); i++) { + name = Form("CHA%d_CSI_E_RAW", RawData->GetCharissaCsIEDetectorNbr(i)); + family = "CHARISSA/RAW/CSIE"; + GetHisto(family,name) -> Fill(RawData->GetCharissaCsIECristalNbr(i), RawData->GetCharissaCsIEEnergy(i)); + } + + // L1_STRX MULT + int myMULT[fNumberOfTelescope]; + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < RawData->GetCharissaLayer1StripXEMult(); i++) myMULT[RawData->GetCharissaLayer1StripXEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L1_STRX_RAW_MULT", i+1); + family = "CHARISSA/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // L1_STRY MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < RawData->GetCharissaLayer1StripYEMult(); i++) myMULT[RawData->GetCharissaLayer1StripYEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L1_STRY_RAW_MULT", i+1); + family = "CHARISSA/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // L2_STRX MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < RawData->GetCharissaLayer2StripXEMult(); i++) myMULT[RawData->GetCharissaLayer2StripXEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L2_STRX_RAW_MULT", i+1); + family = "CHARISSA/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // L2_STRY MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < RawData->GetCharissaLayer2StripYEMult(); i++) myMULT[RawData->GetCharissaLayer2StripYEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L2_STRY_RAW_MULT", i+1); + family = "CHARISSA/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // CSI MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < RawData->GetCharissaCsIEMult();i++) myMULT[RawData->GetCharissaCsIEDetectorNbr(i)-1] += 1; + + for( unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_CSI_RAW_MULT", i+1); + family = "CHARISSA/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::FillPreTreatedSpectra(TCharissaData* PreTreatedData) +{ + TString name; + TString family; + + // L1_STRX_E + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer1StripXEMult(); i++) { + name = Form("CHA%d_L1_STRX_E_CAL", PreTreatedData->GetCharissaLayer1StripXEDetectorNbr(i)); + family = "CHARISSA/CAL/STRXE"; + GetHisto(family,name) -> Fill(PreTreatedData->GetCharissaLayer1StripXEStripNbr(i), PreTreatedData->GetCharissaLayer1StripXEEnergy(i)); + } + + // L1_STRY_E + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer1StripYEMult(); i++) { + name = Form("CHA%d_L1_STRY_E_CAL", PreTreatedData->GetCharissaLayer1StripYEDetectorNbr(i)); + family = "CHARISSA/CAL/STRYE"; + GetHisto(family,name) -> Fill(PreTreatedData->GetCharissaLayer1StripYEStripNbr(i), PreTreatedData->GetCharissaLayer1StripYEEnergy(i)); + } + + // L2_STRX_E + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer2StripXEMult(); i++) { + name = Form("CHA%d_L2_STRX_E_CAL", PreTreatedData->GetCharissaLayer2StripXEDetectorNbr(i)); + family = "CHARISSA/CAL/STRXE"; + GetHisto(family,name) -> Fill(PreTreatedData->GetCharissaLayer2StripXEStripNbr(i), PreTreatedData->GetCharissaLayer2StripXEEnergy(i)); + } + + // L2_STRY_E + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer2StripYEMult(); i++) { + name = Form("CHA%d_L2_STRY_E_CAL", PreTreatedData->GetCharissaLayer2StripYEDetectorNbr(i)); + family = "CHARISSA/CAL/STRYE"; + GetHisto(family,name) -> Fill(PreTreatedData->GetCharissaLayer2StripYEStripNbr(i), PreTreatedData->GetCharissaLayer2StripYEEnergy(i)); + } + + // CSI_E + for (unsigned int i = 0; i < PreTreatedData->GetCharissaCsIEMult(); i++) { + name = Form("CHA%d_CSI_E_CAL", PreTreatedData->GetCharissaCsIEDetectorNbr(i)); + family = "CHARISSA/CAL/CSIE"; + GetHisto(family,name) -> Fill(PreTreatedData->GetCharissaCsIECristalNbr(i), PreTreatedData->GetCharissaCsIEEnergy(i)); + } + + // L1_STRX MULT + int myMULT[fNumberOfTelescope]; + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer1StripXEMult(); i++) myMULT[PreTreatedData->GetCharissaLayer1StripXEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L1_STRX_CAL_MULT", i+1); + family = "CHARISSA/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // L1_STRY MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer1StripYEMult(); i++) myMULT[PreTreatedData->GetCharissaLayer1StripYEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L1_STRY_CAL_MULT", i+1); + family = "CHARISSA/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // L2_STRX MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer2StripXEMult(); i++) myMULT[PreTreatedData->GetCharissaLayer2StripXEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L2_STRX_CAL_MULT", i+1); + family = "CHARISSA/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // L2_STRY MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < PreTreatedData->GetCharissaLayer2StripYEMult(); i++) myMULT[PreTreatedData->GetCharissaLayer2StripYEDetectorNbr(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_L2_STRY_CAL_MULT", i+1); + family = "CHARISSA/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // CSI MULT + for (unsigned int i = 0; i < fNumberOfTelescope; i++) myMULT[i] = 0; + + for (unsigned int i = 0; i < PreTreatedData->GetCharissaCsIEMult();i++) myMULT[PreTreatedData->GetCharissaCsIEDetectorNbr(i)-1] += 1; + + for( unsigned int i = 0; i < fNumberOfTelescope; i++) { + name = Form("CHA%d_CSI_CAL_MULT", i+1); + family = "CHARISSA/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::FillPhysicsSpectra(TCharissaPhysics* Physics) +{ + cout << "TCharissaSpactra::FillPhysicsSpectra has to be implemented !" << endl; + + TString name; + TString family= "CHARISSA/PHY"; + // X-Y Impact Matrix + + for(unsigned int i = 0 ; i < Physics->Layer1_Si_E.size(); i++){ + name = "CHA_IMPACT_MATRIX"; + double x = Physics->GetPositionOfInteraction(i).x(); + double y = Physics->GetPositionOfInteraction(i).y(); + GetHisto(family,name)-> Fill(x,y); + + name = "L1_CHA_THETA_E"; + double Theta = Physics->GetPositionOfInteraction(i).Angle(TVector3(0,0,1)); + Theta = Theta/deg; + GetHisto(family,name)-> Fill(Theta,Physics->Layer1_Si_E[i]); + + // STRX_E_CAL + name = Form("CHA%d_XY_COR", Physics->Layer1_TelescopeNumber[i]); + GetHisto(family,name)-> Fill(Physics->Layer1_Si_EX[i],Physics->Layer1_Si_EY[i]); + + + // E-TOF: + name = "CHA_E_TOF"; + GetHisto(family,name)->Fill(Physics->Layer1_Si_E[i],Physics->Layer1_Si_T[i]); + + name = Form("CHA%d_E_TOF", Physics->Layer1_TelescopeNumber[i]); + GetHisto(family,name)->Fill(Physics->Layer1_Si_E[i],Physics->Layer1_Si_T[i]); + + + double Etot; + if(Physics->CsI_E[i]>0){ + name = "CHA_CSIE_E"; + Etot = Physics->Layer1_Si_E[i]+Physics->Layer2_Si_E[i]+Physics->CsI_E[i]; + GetHisto(family,name)->Fill(Physics->CsI_E[i],Physics->Layer1_Si_E[i]+Physics->Layer2_Si_E[i]); + name = Form("CHA%d_CSIE_E", Physics->Layer1_TelescopeNumber[i]); + GetHisto(family,name)->Fill(Physics->CsI_E[i],Physics->Layer1_Si_E[i]+Physics->Layer2_Si_E[i]); + + } + + if(Etot>0){ + name = "CHA_Etot_E"; + GetHisto(family,name)->Fill(Etot,Physics->Layer1_Si_E[i]); + name = Form("CHA%d_Etot_E", Physics->Layer1_TelescopeNumber[i]); + GetHisto(family,name)->Fill(Etot,Physics->Layer1_Si_E[i]); + } + + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCharissaSpectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family){ + // create histo + TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup); + + vector<TString> index ; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index]=hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCharissaSpectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family){ + // create histo + TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + + vector<TString> index ; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index]=hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCharissaSpectra::GetHisto(TString family, TString name){ + vector<TString> index ; + index.push_back(family); + index.push_back(name); + + // fill map + return fMapHisto.at(index); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::WriteHisto(TString filename) +{ + TFile *f = NULL; + + if (filename != "VOID") { + f = new TFile(filename, "RECREATE"); + } + + map< vector<TString>, TH1* >::iterator it; + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) { + it->second->Write(); + } + + if (filename != "VOID") { + f->Close(); + delete f; + } +} + + + +/////////////////////////////////////////////////////////////////////////////// +void TCharissaSpectra::CheckSpectra() +{ + map< vector<TString>, TH1* >::iterator it; + Color_t ok_color = kTeal+9; + Color_t warning_color = kOrange+8; warning_color *= 1; + Color_t bad_color = kRed; bad_color *= 1; + + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) + { + it->second->SetLineColor(ok_color); + it->second->SetFillStyle(1001); + it->second->SetFillColor(ok_color); + } +} diff --git a/NPLib/Charissa/TCharissaSpectra.h b/NPLib/Charissa/TCharissaSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..56bbd447754c61a06072f42897a9d5c9a094c271 --- /dev/null +++ b/NPLib/Charissa/TCharissaSpectra.h @@ -0,0 +1,86 @@ +#ifndef TCHARISSASPECTRA_H +#define TCHARISSASPECTRA_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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Charissa * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// C++ STL headers +#include <map> + +// ROOT headers +#include "TObject.h" +#include <TH1.h> +#include <TH2.h> +#include <TString.h> + +// NPLib headers +#include "TCharissaData.h" +#include "TCharissaPhysics.h" +using namespace std; + +// ForwardDeclaration +class TCharissaPhysics; + +class TCharissaSpectra { + public: + // constructor and destructor + TCharissaSpectra(); + TCharissaSpectra(unsigned int NumberOfTelescope); + ~TCharissaSpectra(); + + private: + // Instantiate and register histo to maps + TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family); + TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, + Int_t nbinsy, Double_t ylow, Double_t yup, TString family); + + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TCharissaData*); + void FillPreTreatedSpectra(TCharissaData*); + void FillPhysicsSpectra(TCharissaPhysics*); + // Check the Spectra + void CheckSpectra(); + + public: + // get map histo which will be used for GSpectra in GUser + map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;} + TH1* GetHisto(TString family,TString name); + void WriteHisto(TString filename="VOID"); + + private: // Information on CHARISSA + unsigned int fNumberOfTelescope; + unsigned int fStripX; + unsigned int fStripY; + unsigned int fCrystalCsI; + + private: + // map holding histo pointers and their family names + map< vector<TString>, TH1* > fMapHisto; +}; + +#endif diff --git a/NPLib/Exogam/TExogamPhysics.cxx b/NPLib/Exogam/TExogamPhysics.cxx index 6613a864bf47239193e3980f0f0776b5c7d98841..ead6899941a3af0d3a8c7f91235b932b71167bff 100644 --- a/NPLib/Exogam/TExogamPhysics.cxx +++ b/NPLib/Exogam/TExogamPhysics.cxx @@ -67,10 +67,8 @@ void TExogamPhysics::PreTreat() { ClearPreTreatedData(); - //ECC - //E - + for(unsigned int i = 0 ; i < EventData -> GetECCEMult(); i++) { UShort_t cristal_E = 10000 ; UShort_t cristal_T = 2000; //if(IsValidChannel) @@ -84,12 +82,14 @@ void TExogamPhysics::PreTreat() if(cristal_E > Threshold_ECC) { - if(EventData -> GetECCTMult() !=0) - { - for(unsigned int k = 0; k < EventData -> GetECCTMult(); k++) - { - if(clover == EventData -> GetECCTClover(k) && cristal == EventData -> GetECCTCristal(k)) - { + + PreTreatedData->SetECCEClover ( clover ) ; + PreTreatedData->SetECCECristal( cristal ) ; + PreTreatedData->SetECCEEnergy ( cristal_E ) ; + + bool checkT = false; + for(unsigned int k = 0; k < EventData -> GetECCTMult(); k++){ + if(clover == EventData -> GetECCTClover(k) && cristal == EventData -> GetECCTCristal(k)){ // cout << EventData -> GetECCTTime(k) << endl; if(EventData -> GetECCTTime(k) < 16383) cristal_T = CalibrationManager::getInstance()-> ApplyCalibration("EXOGAM/Cl"+itoa(clover)+"_Cr"+itoa(cristal)+"_T", EventData -> GetECCTTime(k)); @@ -97,35 +97,24 @@ void TExogamPhysics::PreTreat() //if(cristal_T >5000 && cristal_T !=25000 ) cout << "PreTreat " << cristal_T << " " << EventData -> GetECCTTime(k) << " " << clover << " " << cristal << " " << EventData->GetECCTMult() << endl; - PreTreatedData->SetECCEClover ( EventData->GetECCEClover(i) ) ; - PreTreatedData->SetECCECristal( EventData->GetECCECristal(i) ) ; - PreTreatedData->SetECCEEnergy ( cristal_E ) ; - PreTreatedData->SetECCTClover ( EventData->GetECCEClover(i) ) ; - PreTreatedData->SetECCTCristal( EventData->GetECCECristal(i) ) ; + checkT=true; + PreTreatedData->SetECCTClover (clover ) ; + PreTreatedData->SetECCTCristal( cristal ) ; PreTreatedData->SetECCTTime ( cristal_T ) ; ECC_Multiplicity ++; GOCCE_Multiplicity++; } - else { } + } - } - else // case of calibration with ECCTMult = 0 - { - cristal_T = 3000; - //cout << cristal_E << endl; - - PreTreatedData->SetECCEClover ( EventData->GetECCEClover(i) ) ; - PreTreatedData->SetECCECristal( EventData->GetECCECristal(i) ) ; - PreTreatedData->SetECCEEnergy ( cristal_E ) ; - PreTreatedData->SetECCTClover ( EventData->GetECCEClover(i) ) ; - PreTreatedData->SetECCTCristal( EventData->GetECCECristal(i) ) ; - PreTreatedData->SetECCTTime ( cristal_T ) ; - // if(cristal_T > 5000 && cristal_T !=30000) cout << "PreTreat (default = 30000) " << cristal_T << " " << clover << " " << cristal << endl; - - - } + if(!checkT) { + PreTreatedData->SetECCTClover (clover ) ; + PreTreatedData->SetECCTCristal( cristal ) ; + PreTreatedData->SetECCTTime ( -1000 ) ; + } + + } } } @@ -174,8 +163,6 @@ void TExogamPhysics::PreTreat() void TExogamPhysics::BuildPhysicalEvent() { - //cout << "Exogam Build ?" << endl; - PreTreat(); if(PreTreatedData -> GetECCEMult() != PreTreatedData -> GetECCTMult()) cout << PreTreatedData -> GetECCEMult() << " " << PreTreatedData -> GetECCTMult() << endl; @@ -580,7 +567,8 @@ void TExogamPhysics::AddClover(string AngleFile) Angles.push_back(angle); // Theta (k = 0) Phi (k = 1) //cout << angle << endl; - // cout << NumberOfClover << " " << Angles[0] << endl; + if(Angles.size()==2) + cout << "Clover " << NumberOfClover << ": Theta=" << Angles[0] << " Phi=" << Angles[1]<< endl; } @@ -624,7 +612,7 @@ void TExogamPhysics::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 TExogamPhysics::InitializeRootInput() +void TExogamPhysics::InitializeRootInputRaw() { TChain* inputChain = RootInput::getInstance()->GetChain() ; inputChain->SetBranchStatus( "EXOGAM" , true ) ; diff --git a/NPLib/Exogam/TExogamPhysics.h b/NPLib/Exogam/TExogamPhysics.h index e5e6c975d414c694aea5a4d7e92c7e8f07ba329a..a76843b950a3fe5ae63bdeeb247557522308c02d 100644 --- a/NPLib/Exogam/TExogamPhysics.h +++ b/NPLib/Exogam/TExogamPhysics.h @@ -104,7 +104,7 @@ class TExogamPhysics : public TObject, public NPA::VDetector // 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 InitializeRootInput() ; + void InitializeRootInputRaw() ; // Create associated branches and associated private member DetectorPhysics address diff --git a/NPLib/IORoot/RootInput.cxx b/NPLib/IORoot/RootInput.cxx index d5f7e9467a6e6c374efa3a92fc892cc53c321b36..4c986232eba895bf73c0101ea0068c7d0e30af64 100644 --- a/NPLib/IORoot/RootInput.cxx +++ b/NPLib/IORoot/RootInput.cxx @@ -29,7 +29,7 @@ #include "RootInput.h" #include "TAsciiFile.h" -RootInput *RootInput::instance = 0; +RootInput* RootInput::instance = 0; RootInput* RootInput::getInstance(string configFileName) { @@ -268,8 +268,8 @@ RootInput::~RootInput() if (system("rm -rf ./.tmp") != 0) cout << "RootInput::~RootInput() problem deleting ./.tmp directory" << endl; } - delete pRootFile; - delete pRootChain; + //delete pRootFile; + //delete pRootChain; } ///////////////////////////////////////////////////////////////////// diff --git a/NPLib/IORoot/RootOutput.cxx b/NPLib/IORoot/RootOutput.cxx index d383613869f7550ce7ff914d9a5ce51b5dd4ded8..476c1c008118ad6a0a599f4c00a8a7c7c04424ab 100644 --- a/NPLib/IORoot/RootOutput.cxx +++ b/NPLib/IORoot/RootOutput.cxx @@ -28,7 +28,7 @@ using namespace std; -RootOutput *RootOutput::instance = 0; +RootOutput* RootOutput::instance = 0; RootOutput* RootOutput::getInstance(TString fileNameBase, TString treeNameBase) { @@ -131,7 +131,6 @@ RootOutput::~RootOutput() cout << " - Number of entries in the Tree: " << pRootTree->GetEntries() << endl; cout << " - Number of bites written to file: " << pRootTree->Write() << endl; - // write TAsciiFile if used // EventGenerator if (!pEventGenerator->IsEmpty()) pEventGenerator->Write(); @@ -143,7 +142,6 @@ RootOutput::~RootOutput() if (!pRunToTreatFile->IsEmpty()) pRunToTreatFile->Write(); // Analysis ConfigFile if (!pAnalysisConfigFile->IsEmpty()) pAnalysisConfigFile->Write(); - pRootFile->Flush(); pRootFile->Close(); } @@ -167,7 +165,6 @@ RootOutput::~RootOutput() else { cout << "No histograms and Tree !" << endl; } - } TFile* RootOutput::InitFile(TString fileNameBase){ @@ -186,4 +183,4 @@ TFile* RootOutput::InitFile(TString fileNameBase){ cout << "ERROR: Do not use RootOutput::InitFile without a proof environment (use --proof option to NPTool)" << endl ; exit(1); } -} \ No newline at end of file +} diff --git a/NPLib/MUST2/Makefile b/NPLib/MUST2/Makefile index 95002197ec3da9ebbf1cd3327ca3f929316287a7..3b0d6b11aa76cd837c2fbc0081c1d0ef16bdb8df 100644 --- a/NPLib/MUST2/Makefile +++ b/NPLib/MUST2/Makefile @@ -9,7 +9,7 @@ all: $(SHARELIB) ############### Detector ############## ## MUST2 ## -libMust2.so: TMust2Data.o TMust2DataDict.o TMust2Physics.o TMust2Spectra.o TMust2SpectraDict.o TMust2PhysicsDict.o +libMust2.so: TMust2Data.o TMust2DataDict.o TMust2Physics.o TMust2PhysicsDict.o TMust2Spectra.o $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ TMust2DataDict.cxx: TMust2Data.h @@ -18,9 +18,6 @@ TMust2DataDict.cxx: TMust2Data.h TMust2PhysicsDict.cxx: TMust2Physics.h rootcint -f $@ -c $^ -TMust2SpectraDict.cxx: TMust2Spectra.h - rootcint -f $@ -c $^ - # dependances TMust2Data.o: TMust2Data.cxx TMust2Data.h TMust2Physics.o: TMust2Physics.cxx TMust2Physics.h diff --git a/NPLib/MUST2/TMust2Physics.cxx b/NPLib/MUST2/TMust2Physics.cxx index 8c965891dc2c91e8e3c3ce89f6d218f96b93fac1..754d2562802b79c978fe9ab3025d3e47f99846ef 100644 --- a/NPLib/MUST2/TMust2Physics.cxx +++ b/NPLib/MUST2/TMust2Physics.cxx @@ -32,6 +32,8 @@ using namespace MUST2_LOCAL; #include "RootInput.h" #include "RootOutput.h" #include "TAsciiFile.h" +#include "NPOptionManager.h" + // ROOT #include "TChain.h" /////////////////////////////////////////////////////////////////////////// @@ -43,6 +45,7 @@ TMust2Physics::TMust2Physics(){ m_EventData = new TMust2Data ; m_PreTreatedData = new TMust2Data ; m_EventPhysics = this ; + m_Spectra = NULL; m_NumberOfTelescope = 0 ; m_MaximumStripMultiplicityAllowed = 10; m_StripEnergyMatchingSigma = 0.020 ; @@ -173,6 +176,10 @@ TMust2Physics::TMust2Physics(){ } +/////////////////////////////////////////////////////////////////////////// +TMust2Physics::~TMust2Physics(){ + +} /////////////////////////////////////////////////////////////////////////// void TMust2Physics::BuildSimplePhysicalEvent(){ BuildPhysicalEvent(); @@ -300,7 +307,9 @@ void TMust2Physics::BuildPhysicalEvent(){ } } - + + + return; } @@ -1031,7 +1040,29 @@ void TMust2Physics::ReadConfiguration(string Path){ cout << endl << "/////////////////////////////" << endl << endl; } +/////////////////////////////////////////////////////////////////////////// +void TMust2Physics::InitSpectra(){ + m_Spectra = new TMust2Spectra(m_NumberOfTelescope); +} +/////////////////////////////////////////////////////////////////////////// +void TMust2Physics::FillSpectra(){ + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} +/////////////////////////////////////////////////////////////////////////// +void TMust2Physics::CheckSpectra(){ + m_Spectra->CheckSpectra(); +} +/////////////////////////////////////////////////////////////////////////// +void TMust2Physics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< vector<TString> , TH1*> TMust2Physics::GetSpectra() { +return m_Spectra->GetMapHisto(); +} /////////////////////////////////////////////////////////////////////////// void TMust2Physics::AddParameterToCalibrationManager() { diff --git a/NPLib/MUST2/TMust2Physics.h b/NPLib/MUST2/TMust2Physics.h index 503061d1cad0a13ffbc1d873d7da842f832e2283..951e91d5778a564749cefc5266fcb0ec09be9fe0 100644 --- a/NPLib/MUST2/TMust2Physics.h +++ b/NPLib/MUST2/TMust2Physics.h @@ -24,265 +24,285 @@ *****************************************************************************/ // STL #include <vector> - +#include <map> // NPL #include "TMust2Data.h" +#include "TMust2Spectra.h" #include "../include/CalibrationManager.h" #include "../include/VDetector.h" // ROOT #include "TVector2.h" #include "TVector3.h" #include "TObject.h" +#include "TH1.h" using namespace std ; +// Forward Declaration +class TMust2Spectra; + class TMust2Physics : public TObject, public NPA::VDetector{ -public: - TMust2Physics(); - ~TMust2Physics() {}; - -public: - void Clear(); - void Clear(const Option_t*) {}; - -public: - vector < TVector2 > Match_X_Y() ; - bool Match_Si_CsI(int X, int Y , int CristalNbr); - bool Match_Si_SiLi(int X, int Y , int PadNbr); - bool ResolvePseudoEvent(); - int CheckEvent(); - -public: - - // Provide Physical Multiplicity - Int_t EventMultiplicity; - - // Provide a Classification of Event - vector<int> EventType ; - - // Telescope - vector<int> TelescopeNumber ; - - // Si - vector<double> Si_E ; - vector<double> Si_T ; - vector<int> Si_X ; - vector<int> Si_Y ; - - // Use for checking purpose - vector<double> Si_EX ; - vector<double> Si_TX ; - vector<double> Si_EY ; - vector<double> Si_TY ; - vector<int> TelescopeNumber_X ; - vector<int> TelescopeNumber_Y ; - // Si(Li) - vector<double> SiLi_E ; - vector<double> SiLi_T ; - vector<int> SiLi_N ; - - // CsI - vector<double> CsI_E ; - vector<double> CsI_T ; - vector<int> CsI_N ; - - // Physical Value - vector<double> TotalEnergy ; - - -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();} - -public: // Specific to MUST2 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 telescope , const int channel); - - // Initialize the standard parameter for analysis - // ie: all channel enable, maximum multiplicity for strip = number of telescope - void InitializeStandardParameter(); - - // Read the user configuration file; if no file found, load standard one - void ReadAnalysisConfig(); - - // Add a Telescope using Corner Coordinate information - void AddTelescope( TVector3 C_X1_Y1, - TVector3 C_X128_Y1, - TVector3 C_X1_Y128, - TVector3 C_X128_Y128); - - // Add a Telescope using R Theta Phi of Si center information - void AddTelescope( double theta, - double phi, - double distance, - double beta_u, - double beta_v, - double beta_w); - - // Use for reading Calibration Run, very simple methods; only apply calibration, no condition - void ReadCalibrationRun(); - - // Give and external TMustData object to TMust2Physics. Needed for online analysis for example. - void SetRawDataPointer(TMust2Data* rawDataPointer) {m_EventData = rawDataPointer;} - // Retrieve raw and pre-treated data - TMust2Data* GetRawData() const {return m_EventData;} - TMust2Data* GetPreTreatedData() const {return m_PreTreatedData;} - - // Use to access the strip position - double GetStripPositionX( const int N , const int X , const int Y ) const{ return m_StripPositionX[N-1][X-1][Y-1] ; } ; - double GetStripPositionY( const int N , const int X , const int Y ) const{ return m_StripPositionY[N-1][X-1][Y-1] ; } ; - double GetStripPositionZ( const int N , const int X , const int Y ) const{ return m_StripPositionZ[N-1][X-1][Y-1] ; } ; - - double GetNumberOfTelescope() const { return m_NumberOfTelescope ; }; - - // To be called after a build Physical Event - int GetEventMultiplicity() const { return EventMultiplicity; }; - - double GetEnergyDeposit(const int i) const{ return TotalEnergy[i] ;}; - - TVector3 GetPositionOfInteraction(const int i) const; - TVector3 GetTelescopeNormal(const int i) const; - -private: // Parameter used in the analysis - - // By default take EX and TY. - bool m_Take_E_Y;//! - bool m_Take_T_Y;//! - - // Size Container to be used in the different loop of the analysis (value must be given locally) - unsigned int m_StripXEMult;//! - unsigned int m_StripYEMult;//! - unsigned int m_StripXTMult;//! - unsigned int m_StripYTMult;//! - unsigned int m_SiLiEMult;//! - unsigned int m_SiLiTMult;//! - unsigned int m_CsIEMult;//! - unsigned int m_CsITMult;//! - - - // Event over this value after pre-treatment are not treated / avoid long treatment time on spurious event - unsigned int m_MaximumStripMultiplicityAllowed ;//! - // Give the allowance in percent of the difference in energy between X and Y - double m_StripEnergyMatchingSigma ; //! - double m_StripEnergyMatchingNumberOfSigma ; //! - - // Raw Threshold - int m_Si_X_E_RAW_Threshold ;//! - int m_Si_Y_E_RAW_Threshold ;//! - int m_SiLi_E_RAW_Threshold ;//! - int m_CsI_E_RAW_Threshold ;//! - - // Calibrated Threshold - double m_Si_X_E_Threshold ;//! - double m_Si_Y_E_Threshold ;//! - double m_SiLi_E_Threshold ;//! - double m_CsI_E_Threshold ;//! - - // Geometric Matching - // size in strip of a pad - int m_SiLi_Size;//! - // center position of the pad on X - vector< int > m_SiLi_MatchingX;//! - // center position of the pad on Y - vector< int > m_SiLi_MatchingY;//! - // size in strip of a cristal - int m_CsI_Size;//! - // center position of the cristal on X - vector< int > m_CsI_MatchingX;//! - // center position of the cristal on X - vector< int > m_CsI_MatchingY;//! - - // If set to true, all event that do not come in front of a cristal will be ignore all time (crossing or not), - // Warning, this option reduce statistic, however it help eliminating unrealevent event that cross the DSSD - // And go between pad or cristal. - bool m_Ignore_not_matching_SiLi;//! - bool m_Ignore_not_matching_CsI;//! - -private: // Root Input and Output tree classes - - TMust2Data* m_EventData;//! - TMust2Data* m_PreTreatedData;//! - TMust2Physics* m_EventPhysics;//! - - -private: // Map of activated channel - map< int, vector<bool> > m_XChannelStatus;//! - map< int, vector<bool> > m_YChannelStatus;//! - map< int, vector<bool> > m_SiLiChannelStatus;//! - map< int, vector<bool> > m_CsIChannelStatus;//! - -private: // Spatial Position of Strip Calculated on bases of detector position - - int m_NumberOfTelescope;//! - - vector< vector < vector < double > > > m_StripPositionX;//! - vector< vector < vector < double > > > m_StripPositionY;//! - vector< vector < vector < double > > > m_StripPositionZ;//! - - ClassDef(TMust2Physics,1) // Must2Physics structure + public: + TMust2Physics(); + ~TMust2Physics(); + + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: + vector < TVector2 > Match_X_Y() ; + bool Match_Si_CsI(int X, int Y , int CristalNbr); + bool Match_Si_SiLi(int X, int Y , int PadNbr); + bool ResolvePseudoEvent(); + int CheckEvent(); + + public: + + // Provide Physical Multiplicity + Int_t EventMultiplicity; + + // Provide a Classification of Event + vector<int> EventType ; + + // Telescope + vector<int> TelescopeNumber ; + + // Si + vector<double> Si_E ; + vector<double> Si_T ; + vector<int> Si_X ; + vector<int> Si_Y ; + + // Use for checking purpose + vector<double> Si_EX ; + vector<double> Si_TX ; + vector<double> Si_EY ; + vector<double> Si_TY ; + vector<int> TelescopeNumber_X ; + vector<int> TelescopeNumber_Y ; + // Si(Li) + vector<double> SiLi_E ; + vector<double> SiLi_T ; + vector<int> SiLi_N ; + + // CsI + vector<double> CsI_E ; + vector<double> CsI_T ; + vector<int> CsI_N ; + + // Physical Value + vector<double> TotalEnergy ; + + + 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 MUST2 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 telescope , const int channel); + + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of telescope + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + // Add a Telescope using Corner Coordinate information + void AddTelescope( TVector3 C_X1_Y1, + TVector3 C_X128_Y1, + TVector3 C_X1_Y128, + TVector3 C_X128_Y128); + + // Add a Telescope using R Theta Phi of Si center information + void AddTelescope( double theta, + double phi, + double distance, + double beta_u, + double beta_v, + double beta_w); + + // Use for reading Calibration Run, very simple methods; only apply calibration, no condition + void ReadCalibrationRun(); + + // Give and external TMustData object to TMust2Physics. Needed for online analysis for example. + void SetRawDataPointer(TMust2Data* rawDataPointer) {m_EventData = rawDataPointer;} + // Retrieve raw and pre-treated data + TMust2Data* GetRawData() const {return m_EventData;} + TMust2Data* GetPreTreatedData() const {return m_PreTreatedData;} + + // Use to access the strip position + double GetStripPositionX( const int N , const int X , const int Y ) const{ return m_StripPositionX[N-1][X-1][Y-1] ; } ; + double GetStripPositionY( const int N , const int X , const int Y ) const{ return m_StripPositionY[N-1][X-1][Y-1] ; } ; + double GetStripPositionZ( const int N , const int X , const int Y ) const{ return m_StripPositionZ[N-1][X-1][Y-1] ; } ; + + double GetNumberOfTelescope() const { return m_NumberOfTelescope ; }; + + // To be called after a build Physical Event + int GetEventMultiplicity() const { return EventMultiplicity; }; + + double GetEnergyDeposit(const int i) const{ return TotalEnergy[i] ;}; + + TVector3 GetPositionOfInteraction(const int i) const; + TVector3 GetTelescopeNormal(const int i) const; + + private: // Parameter used in the analysis + + // By default take EX and TY. + bool m_Take_E_Y;//! + bool m_Take_T_Y;//! + + // Size Container to be used in the different loop of the analysis (value must be given locally) + unsigned int m_StripXEMult;//! + unsigned int m_StripYEMult;//! + unsigned int m_StripXTMult;//! + unsigned int m_StripYTMult;//! + unsigned int m_SiLiEMult;//! + unsigned int m_SiLiTMult;//! + unsigned int m_CsIEMult;//! + unsigned int m_CsITMult;//! + + + // Event over this value after pre-treatment are not treated / avoid long treatment time on spurious event + unsigned int m_MaximumStripMultiplicityAllowed ;//! + // Give the allowance in percent of the difference in energy between X and Y + double m_StripEnergyMatchingSigma ; //! + double m_StripEnergyMatchingNumberOfSigma ; //! + + // Raw Threshold + int m_Si_X_E_RAW_Threshold ;//! + int m_Si_Y_E_RAW_Threshold ;//! + int m_SiLi_E_RAW_Threshold ;//! + int m_CsI_E_RAW_Threshold ;//! + + // Calibrated Threshold + double m_Si_X_E_Threshold ;//! + double m_Si_Y_E_Threshold ;//! + double m_SiLi_E_Threshold ;//! + double m_CsI_E_Threshold ;//! + + // Geometric Matching + // size in strip of a pad + int m_SiLi_Size;//! + // center position of the pad on X + vector< int > m_SiLi_MatchingX;//! + // center position of the pad on Y + vector< int > m_SiLi_MatchingY;//! + // size in strip of a cristal + int m_CsI_Size;//! + // center position of the cristal on X + vector< int > m_CsI_MatchingX;//! + // center position of the cristal on X + vector< int > m_CsI_MatchingY;//! + + // If set to true, all event that do not come in front of a cristal will be ignore all time (crossing or not), + // Warning, this option reduce statistic, however it help eliminating unrealevent event that cross the DSSD + // And go between pad or cristal. + bool m_Ignore_not_matching_SiLi;//! + bool m_Ignore_not_matching_CsI;//! + + private: // Root Input and Output tree classes + + TMust2Data* m_EventData;//! + TMust2Data* m_PreTreatedData;//! + TMust2Physics* m_EventPhysics;//! + + private: // Map of activated channel + map< int, vector<bool> > m_XChannelStatus;//! + map< int, vector<bool> > m_YChannelStatus;//! + map< int, vector<bool> > m_SiLiChannelStatus;//! + map< int, vector<bool> > m_CsIChannelStatus;//! + + private: // Spatial Position of Strip Calculated on bases of detector position + + int m_NumberOfTelescope;//! + + vector< vector < vector < double > > > m_StripPositionX;//! + vector< vector < vector < double > > > m_StripPositionY;//! + vector< vector < vector < double > > > m_StripPositionZ;//! + + private: // Spectra Class + TMust2Spectra* m_Spectra;//! + + public: // Spectra Getter + map< vector<TString> , TH1*> GetSpectra(); + + ClassDef(TMust2Physics,1) // Must2Physics structure }; namespace MUST2_LOCAL { - + // tranform an integer to a string string itoa(int value); // DSSD // X double fSi_X_E(const TMust2Data* Data, const int i); double fSi_X_T(const TMust2Data* Data, const int i); - + // Y double fSi_Y_E(const TMust2Data* Data, const int i); double fSi_Y_T(const TMust2Data* Data, const int i); - + // SiLi double fSiLi_E(const TMust2Data* Data, const int i); double fSiLi_T(const TMust2Data* Data, const int i); - + // CsI double fCsI_E(const TMust2Data* Data, const int i); double fCsI_T(const TMust2Data* Data, const int i); - + } diff --git a/NPLib/MUST2/TMust2Spectra.cxx b/NPLib/MUST2/TMust2Spectra.cxx index b7315448588247e3b8f3b0b7c3a13bd96c069abe..62d1b83e58d62d8d07b04a4ba20a3e6f163b25ce 100644 --- a/NPLib/MUST2/TMust2Spectra.cxx +++ b/NPLib/MUST2/TMust2Spectra.cxx @@ -20,230 +20,643 @@ * * * * *****************************************************************************/ + +// NPL #include "TMust2Spectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + +// ROOT #include "TString.h" +#include "TDirectory.h" +#include "TFile.h" -ClassImp(TMust2Spectra) +//////////////////////////////////////////////////////////////////////////////// +TMust2Spectra::TMust2Spectra(){ + fNumberOfTelescope = 0; + fStripX=128; + fStripY=128; + fPadSili=16; + fCrystalCsI=16; +} -TMust2Spectra::TMust2Spectra() - : fMust2Data(new TMust2Data()), - fMust2PreTreatedData(new TMust2Data()), - fMust2Physics(new TMust2Physics()) -{ - fMust2PreTreatedData = fMust2Physics->GetPreTreatedData(); +//////////////////////////////////////////////////////////////////////////////// +TMust2Spectra::TMust2Spectra(unsigned int NumberOfTelescope){ + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TMust2Spectra : Initalising control spectra for " + << NumberOfTelescope << " Telescopes" << endl + << "************************************************" << endl ; + + fNumberOfTelescope = NumberOfTelescope; + fStripX=128; + fStripY=128; + fPadSili=16; + fCrystalCsI=16; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); } +//////////////////////////////////////////////////////////////////////////////// +TMust2Spectra::~TMust2Spectra(){ +} +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::InitRawSpectra(){ + TString name; + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { // loop on number of detectors + // STRX_E_RAW + name = Form("MM%d_STRX_E_RAW", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 512, 0, 8192, "MUST2/RAW/STRXE"); + + // STRY_E_RAW + name = Form("MM%d_STRY_E_RAW", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 512, 0, 8192, "MUST2/RAW/STRYE"); + + // STRX_T_RAW + name = Form("MM%d_STRX_T_RAW", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 512, 0, 8192, "MUST2/RAW/STRXT"); + + // STRY_T_RAW + name = Form("MM%d_STRY_T_RAW", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 512, 0, 8192, "MUST2/RAW/STRYT"); + + // SILI_E_RAW + name = Form("MM%d_SILI_E_RAW", i+1); + AddHisto2D(name, name, fPadSili, 1, fPadSili+1, 512, 0, 8192, "MUST2/RAW/SILIE"); + + // SILI_T_RAW + name = Form("MM%d_SILI_T_RAW", i+1); + AddHisto2D(name, name, fPadSili, 1, fPadSili+1, 512, 0, 8192, "MUST2/RAW/SILIT"); + + // CSI_E_RAW + name = Form("MM%d_CSI_E_RAW", i+1); + AddHisto2D(name, name, fCrystalCsI, 1, fCrystalCsI+1, 512, 0, 8192, "MUST2/RAW/CSIE"); + + // CSI_T_RAW + name = Form("MM%d_CSI_T_RAW", i+1); + AddHisto2D(name, name, fCrystalCsI, 1, fCrystalCsI+1, 512, 0, 8192, "MUST2/RAW/CSIT"); + + // STRX_RAW_MULT + name = Form("MM%d_STRX_RAW_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "MUST2/RAW/MULT"); + + // STRY_RAW_MULT + name = Form("MM%d_STRY_RAW_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "MUST2/RAW/MULT"); + + // SILI_RAW_MULT + name = Form("MM%d_SILI_RAW_MULT", i+1); + AddHisto1D(name, name, fPadSili, 1, fPadSili+1, "MUST2/RAW/MULT"); + + // CSI_RAW_MULT + name = Form("MM%d_CSI_RAW_MULT", i+1); + AddHisto1D(name, name, fCrystalCsI, 1, fCrystalCsI+1, "MUST2/RAW/MULT"); + } // end loop on number of detectors +} -TMust2Spectra::~TMust2Spectra() +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::InitPreTreatedSpectra() { -} + TString name; + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { // loop on number of detectors + // STRX_E_CAL + name = Form("MM%d_STRX_E_CAL", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 500, 0, 50, "MUST2/CAL/STRXE"); + // STRY_E_CAL + name = Form("MM%d_STRY_E_CAL", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 500, 0, 50, "MUST2/CAL/STRYE"); + // STRX_T_CAL + name = Form("MM%d_STRX_T_CAL", i+1); + AddHisto2D(name, name, fStripX, 1, fStripX+1, 500, 0, 500, "MUST2/CAL/STRXT"); -void TMust2Spectra::InitRawUserSpectra() -{ - TString name; - for (Int_t i = 0; i < NUMBERMUST2; ++i) { // loop on number of detectors - // STRX_MULT - name = Form("MM%d_STRX_MULT", i+1); - MM_STRX_MULT[i] = AddTH1(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, "MUST2/BRUT/MULT"); - - // STRY_MULT - name = Form("MM%d_STRY_MULT", i+1); - MM_STRY_MULT[i] = AddTH1(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, "MUST2/BRUT/MULT"); - - // SILI_MULT - name = Form("MM%d_SILI_MULT", i+1); - MM_SILI_MULT[i] = AddTH1(name, name, NUMBERSILI, 1, NUMBERSILI+1, "MUST2/BRUT/MULT"); - - // CSI_MULT - name = Form("MM%d_CSI_MULT", i+1); - MM_CSI_MULT[i] = AddTH1(name, name, NUMBERCSI, 1, NUMBERCSI+1, "MUST2/BRUT/MULT"); - } // end loop on number of detectors + // STRY_T_CAL + name = Form("MM%d_STRY_T_CAL", i+1); + AddHisto2D(name, name, fStripY, 1, fStripY+1, 500, 0, 500, "MUST2/CAL/STRYT"); + + // SILI_E_CAL + name = Form("MM%d_SILI_E_CAL", i+1); + AddHisto2D(name, name, fPadSili, 1, fPadSili+1, 500, 0, 50, "MUST2/CAL/SILIE"); + + // SILI_T_CAL + name = Form("MM%d_SILI_T_CAL", i+1); + AddHisto2D(name, name, fPadSili, 1, fPadSili+1, 500, 0, 50, "MUST2/CAL/SILIT"); + + // CSI_E_CAL + name = Form("MM%d_CSI_E_CAL", i+1); + AddHisto2D(name, name, fCrystalCsI, 1, fCrystalCsI+1, 500, 0, 50, "MUST2/CAL/CSIE"); + + // CSI_T_CAL + name = Form("MM%d_CSI_T_CAL", i+1); + AddHisto2D(name, name, fCrystalCsI, 1, fCrystalCsI+1, 500, 0, 50, "MUST2/CAL/CSIT"); + + // STRX_CAL_MULT + name = Form("MM%d_STRX_CAL_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "MUST2/CAL/MULT"); + + // STRY_CAL_MULT + name = Form("MM%d_STRY_CAL_MULT", i+1); + AddHisto1D(name, name, fStripX, 1, fStripX+1, "MUST2/CAL/MULT"); + + // SILI_CAL_MULT + name = Form("MM%d_SILI_CAL_MULT", i+1); + AddHisto1D(name, name, fPadSili, 1, fPadSili+1, "MUST2/CAL/MULT"); + + // CSI_CAL_MULT + name = Form("MM%d_CSI_CAL_MULT", i+1); + AddHisto1D(name, name, fCrystalCsI, 1, fCrystalCsI+1, "MUST2/CAL/MULT"); + + } // end loop on number of detectors +} + +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::InitPhysicsSpectra(){ + TString name; + // X-Y Impact Matrix + name = "MM_IMPACT_MATRIX"; + AddHisto2D(name, name,500,-150,150,500,-150,150, "MUST2/PHY"); + + // X-Y Impact Matrix + name = "MM_THETA_E"; + AddHisto2D(name, name,360,0,180,500,0,50,"MUST2/PHY"); + + // X-Y Energy Correlation + for (unsigned int i = 0 ; i < fNumberOfTelescope ; i++) { // loop on number of detectors + name = Form("MM%d_XY_COR", i+1); + AddHisto2D(name, name,500,0,50,500,0,50, "MUST2/PHY"); + } + + // ID Plot + // E-TOF: + name = "MM_E_TOF"; + AddHisto2D(name, name,500,0,50,1000,200,1200,"MUST2/PHY"); + + // SILIE-DE: + name = "MM_SILIE_E"; + AddHisto2D(name, name,500,0,200,500,0,50,"MUST2/PHY"); + + // CSI-DE: + name = "MM_CSIE_E"; + AddHisto2D(name, name,500,0,500,500,0,50,"MUST2/PHY"); + + // Etot-DE: + name = "MM_Etot_E"; + AddHisto2D(name, name,500,0,500,500,0,50,"MUST2/PHY"); + + + // ID plot detector by detector + for (unsigned int i = 0; i < fNumberOfTelescope; i++) { // loop on number of detectors + // E-TOF: + name = Form("MM%d_E_TOF",i+1); + AddHisto2D(name, name,500,0,50,1000,200,1200,"MUST2/PHY"); + + // SILIE-DE: + name = Form("MM%d_SILIE_E",i+1); + AddHisto2D(name, name,500,0,200,500,0,50,"MUST2/PHY"); + + // CSI-DE: + name = Form("MM%d_CSIE_E",i+1); + AddHisto2D(name, name,500,0,500,500,0,50,"MUST2/PHY"); + + // Etot-DE: + name = Form("MM%d_Etot_E",i+1); + AddHisto2D(name, name,500,0,500,500,0,50,"MUST2/PHY"); + } } -void TMust2Spectra::InitUserSpectra() -{ - TString name; - for (Int_t i = 0; i < NUMBERMUST2; i++) { // loop on number of detectors - // STRX_E_BRU - name = Form("MM%d_STRX_E_BRU", i+1); - MM_STRX_E_BRU[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 512, 0, 8192, "MUST2/BRUT/STRXE"); - - // STRY_E_BRU - name = Form("MM%d_STRY_E_BRU", i+1); - MM_STRY_E_BRU[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 512, 0, 8192, "MUST2/BRUT/STRYE"); - - // STRX_T_BRU - name = Form("MM%d_STRX_T_BRU", i+1); - MM_STRX_T_BRU[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 512, 0, 8192, "MUST2/BRUT/STRXT"); - - // STRY_T_BRU - name = Form("MM%d_STRY_T_BRU", i+1); - MM_STRY_T_BRU[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 512, 0, 8192, "MUST2/BRUT/STRYT"); - - // SILI_E_BRU - name = Form("MM%d_SILI_E_BRU", i+1); - MM_SILI_E_BRU[i] = AddTH2(name, name, NUMBERSILI, 1, NUMBERSILI+1, 512, 0, 8192, "MUST2/BRUT/SILIE"); - - // SILI_T_BRU - name = Form("MM%d_SILI_T_BRU", i+1); - MM_SILI_T_BRU[i] = AddTH2(name, name, NUMBERSILI, 1, NUMBERSILI+1, 512, 0, 8192, "MUST2/BRUT/SILIT"); - - // CSI_E_BRU - name = Form("MM%d_CSI_E_BRU", i+1); - MM_CSI_E_BRU[i] = AddTH2(name, name, NUMBERCSI, 1, NUMBERCSI+1, 512, 0, 8192, "MUST2/BRUT/CSIE"); - - // CSI_T_BRU - name = Form("MM%d_CSI_T_BRU", i+1); - MM_CSI_T_BRU[i] = AddTH2(name, name, NUMBERCSI, 1, NUMBERCSI+1, 512, 0, 8192, "MUST2/BRUT/CSIT"); - - // STRX_E_CAL - name = Form("MM%d_STRX_E_CAL", i+1); - MM_STRX_E_CAL[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 500, 0, 50, "MUST2/CAL/STRXE"); - - // STRY_E_CAL - name = Form("MM%d_STRY_E_CAL", i+1); - MM_STRY_E_CAL[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 500, 0, 50, "MUST2/CAL/STRYE"); - - // STRX_T_CAL - name = Form("MM%d_STRX_T_CAL", i+1); - MM_STRX_T_CAL[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 500, 0, 500, "MUST2/CAL/STRXT"); - - // STRY_T_CAL - name = Form("MM%d_STRY_T_CAL", i+1); - MM_STRY_T_CAL[i] = AddTH2(name, name, NUMBERSTRIPS, 1, NUMBERSTRIPS+1, 500, 0, 500, "MUST2/CAL/STRYT"); - - // SILI_E_CAL - name = Form("MM%d_SILI_E_CAL", i+1); - MM_SILI_E_CAL[i] = AddTH2(name, name, NUMBERSILI, 1, NUMBERSILI+1, 500, 0, 50, "MUST2/CAL/SILIE"); - - // SILI_T_CAL - name = Form("MM%d_SILI_T_CAL", i+1); - MM_SILI_T_CAL[i] = AddTH2(name, name, NUMBERSILI, 1, NUMBERSILI+1, 500, 0, 50, "MUST2/CAL/SILIT"); - - // CSI_E_CAL - name = Form("MM%d_CSI_E_CAL", i+1); - MM_CSI_E_CAL[i] = AddTH2(name, name, NUMBERCSI, 1, NUMBERCSI+1, 500, 0, 50, "MUST2/CAL/CSIE"); - - // CSI_T_CAL - name = Form("MM%d_CSI_T_CAL", i+1); - MM_CSI_T_CAL[i] = AddTH2(name, name, NUMBERCSI, 1, NUMBERCSI+1, 500, 0, 50, "MUST2/CAL/CSIT"); - } // end loop on number of detectors +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::FillRawSpectra(TMust2Data* RawData){ + TString name; + TString family; + + // STRX_E + for (unsigned int i = 0; i < RawData->GetMMStripXEMult(); i++) { + name = Form("MM%d_STRX_E_RAW", RawData->GetMMStripXEDetectorNbr(i) ); + family = "MUST2/RAW/STRXE"; + + GetHisto(family,name) + -> Fill(RawData->GetMMStripXEStripNbr(i), + RawData->GetMMStripXEEnergy(i) - 8192); + } + + // STRY_E + for (unsigned int i = 0; i < RawData->GetMMStripYEMult(); i++) { + name = Form("MM%d_STRY_E_RAW", RawData->GetMMStripYEDetectorNbr(i) ); + family = "MUST2/RAW/STRYE"; + + GetHisto(family,name) + -> Fill(RawData->GetMMStripYEStripNbr(i), + 8192 - RawData->GetMMStripYEEnergy(i)); + } + + // STRX_T + for (unsigned int i = 0; i < RawData->GetMMStripXTMult(); i++) { + name = Form("MM%d_STRX_T_RAW", RawData->GetMMStripXTDetectorNbr(i) ); + family = "MUST2/RAW/STRXT"; + + GetHisto(family,name) + -> Fill(RawData->GetMMStripXTStripNbr(i), + RawData->GetMMStripXTTime(i) - 8192); + } + // STRY_T + for (unsigned int i = 0; i < RawData->GetMMStripYTMult(); i++) { + name = Form("MM%d_STRY_T_RAW", RawData->GetMMStripYTDetectorNbr(i) ); + family = "MUST2/RAW/STRYT"; + + GetHisto(family,name) + -> Fill(RawData->GetMMStripYTStripNbr(i), + 8192 - RawData->GetMMStripYTTime(i)); + } + + // SILI_E + for (unsigned int i = 0; i < RawData->GetMMSiLiEMult(); i++) { + name = Form("MM%d_SILI_E_RAW", RawData->GetMMSiLiEDetectorNbr(i) ); + family = "MUST2/RAW/SILIE"; + + GetHisto(family,name) + -> Fill(RawData->GetMMSiLiEPadNbr(i), + RawData->GetMMSiLiEEnergy(i)); + } + + // SILI_T + for (unsigned int i = 0; i < RawData->GetMMSiLiTMult(); i++) { + name = Form("MM%d_SILI_T_RAW", RawData->GetMMSiLiTDetectorNbr(i) ); + family = "MUST2/RAW/SILIT"; + + GetHisto(family,name) + -> Fill(RawData->GetMMSiLiTPadNbr(i), + RawData->GetMMSiLiTTime(i)); + } + + // CSI_E + for (unsigned int i = 0; i < RawData->GetMMCsIEMult(); i++) { + name = Form("MM%d_CSI_E_RAW", RawData->GetMMCsIEDetectorNbr(i) ); + family = "MUST2/RAW/CSIE"; + + GetHisto(family,name) + -> Fill(RawData->GetMMCsIECristalNbr(i), + RawData->GetMMCsIEEnergy(i)); + } + + // CSI_T + for (unsigned int i = 0; i < RawData->GetMMCsITMult(); i++) { + name = Form("MM%d_CSI_T_RAW", RawData->GetMMCsITDetectorNbr(i) ); + family = "MUST2/RAW/CSIT"; + + GetHisto(family,name) + -> Fill(RawData->GetMMCsITCristalNbr(i), + RawData->GetMMCsITTime(i)); + } + + // STRX MULT + int myMULT[fNumberOfTelescope]; + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < RawData->GetMMStripXEMult();i++){ + myMULT[RawData->GetMMStripXEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + + name = Form("MM%d_STRX_RAW_MULT", i+1); + family= "MUST2/RAW/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + + // STRY MULT + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < RawData->GetMMStripYEMult();i++){ + myMULT[RawData->GetMMStripYEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + name = Form("MM%d_STRY_RAW_MULT", i+1); + family= "MUST2/RAW/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + + // SILI MULT + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < RawData->GetMMSiLiEMult();i++){ + myMULT[RawData->GetMMSiLiEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + name = Form("MM%d_SILI_RAW_MULT", i+1); + family= "MUST2/RAW/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + + // CSI MULT + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < RawData->GetMMCsIEMult();i++){ + myMULT[RawData->GetMMCsIEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + name = Form("MM%d_CSI_RAW_MULT", i+1); + family= "MUST2/RAW/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + } +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::FillPreTreatedSpectra(TMust2Data* PreTreatedData){ + TString name ; + TString family; + // STRX_E + for (unsigned int i = 0; i < PreTreatedData->GetMMStripXEMult(); i++) { + name = Form("MM%d_STRX_E_CAL", PreTreatedData->GetMMStripXEDetectorNbr(i) ); + family = "MUST2/CAL/STRXE"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMStripXEStripNbr(i), + PreTreatedData->GetMMStripXEEnergy(i)); + } + // STRY_E + for (unsigned int i = 0; i < PreTreatedData->GetMMStripYEMult(); i++) { + name = Form("MM%d_STRY_E_CAL", PreTreatedData->GetMMStripYEDetectorNbr(i) ); + family = "MUST2/CAL/STRYE"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMStripYEStripNbr(i), + PreTreatedData->GetMMStripYEEnergy(i)); + } + // STRX_T + for (unsigned int i = 0; i < PreTreatedData->GetMMStripXTMult(); i++) { + name = Form("MM%d_STRX_T_CAL", PreTreatedData->GetMMStripXTDetectorNbr(i) ); + family = "MUST2/CAL/STRXT"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMStripXTStripNbr(i), + PreTreatedData->GetMMStripXTTime(i)); + } + // STRY_T + for (unsigned int i = 0; i < PreTreatedData->GetMMStripYTMult(); i++) { + name = Form("MM%d_STRY_T_CAL", PreTreatedData->GetMMStripYTDetectorNbr(i) ); + family = "MUST2/CAL/STRYT"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMStripYTStripNbr(i), + PreTreatedData->GetMMStripYTTime(i)); + } + // SILI_E + for (unsigned int i = 0; i < PreTreatedData->GetMMSiLiEMult(); i++) { + name = Form("MM%d_SILI_E_CAL", PreTreatedData->GetMMSiLiEDetectorNbr(i) ); + family = "MUST2/CAL/SILIE"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMSiLiEPadNbr(i), + PreTreatedData->GetMMSiLiEEnergy(i)); + } + // SILI_T + for (unsigned int i = 0; i < PreTreatedData->GetMMSiLiTMult(); i++) { + name = Form("MM%d_SILI_T_CAL", PreTreatedData->GetMMSiLiTDetectorNbr(i) ); + family = "MUST2/CAL/SILIT"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMSiLiTPadNbr(i), + PreTreatedData->GetMMSiLiTTime(i)); + } + // CSI_E + for (unsigned int i = 0; i < PreTreatedData->GetMMCsIEMult(); i++) { + name = Form("MM%d_CSI_E_CAL", PreTreatedData->GetMMCsIEDetectorNbr(i) ); + family = "MUST2/CAL/CSIE"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMCsIECristalNbr(i), + PreTreatedData->GetMMCsIEEnergy(i)); + } + + // CSI_T + for (unsigned int i = 0; i < PreTreatedData->GetMMCsITMult(); i++) { + name = Form("MM%d_CSI_T_CAL", PreTreatedData->GetMMCsITDetectorNbr(i) ); + family = "MUST2/CAL/CSIT"; + + GetHisto(family,name) + -> Fill(PreTreatedData->GetMMCsITCristalNbr(i), + PreTreatedData->GetMMCsITTime(i)); + } + + // STRX MULT + int myMULT[fNumberOfTelescope]; + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < PreTreatedData->GetMMStripXEMult();i++){ + myMULT[PreTreatedData->GetMMStripXEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + + name = Form("MM%d_STRX_CAL_MULT", i+1); + family= "MUST2/CAL/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + + // STRY MULT + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < PreTreatedData->GetMMStripYEMult();i++){ + myMULT[PreTreatedData->GetMMStripYEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + name = Form("MM%d_STRY_CAL_MULT", i+1); + family= "MUST2/CAL/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + + // SILI MULT + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < PreTreatedData->GetMMSiLiEMult();i++){ + myMULT[PreTreatedData->GetMMSiLiEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + name = Form("MM%d_SILI_CAL_MULT", i+1); + family= "MUST2/CAL/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } + + // CSI MULT + for( unsigned int i = 0; i < fNumberOfTelescope; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < PreTreatedData->GetMMCsIEMult();i++){ + myMULT[PreTreatedData->GetMMCsIEDetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfTelescope; i++){ + name = Form("MM%d_CSI_CAL_MULT", i+1); + family= "MUST2/CAL/MULT"; + GetHisto(family,name) + -> Fill(myMULT[i]); + } +} +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::FillPhysicsSpectra(TMust2Physics* Physics){ + TString name; + TString family= "MUST2/PHY"; + // X-Y Impact Matrix + + for(unsigned int i = 0 ; i < Physics->Si_E.size(); i++){ + name = "MM_IMPACT_MATRIX"; + double x = Physics->GetPositionOfInteraction(i).x(); + double y = Physics->GetPositionOfInteraction(i).y(); + GetHisto(family,name)-> Fill(x,y); + + name = "MM_THETA_E"; + double Theta = Physics->GetPositionOfInteraction(i).Angle(TVector3(0,0,1)); + Theta = Theta/deg; + GetHisto(family,name)-> Fill(Theta,Physics->Si_E[i]); + + // STRX_E_CAL + name = Form("MM%d_XY_COR", Physics->TelescopeNumber[i]); + GetHisto(family,name)-> Fill(Physics->Si_EX[i],Physics->Si_EY[i]); + + + // Fill only for particle stopped in the first stage + if(Physics->SiLi_E[i]<0 && Physics->CsI_E[i]<0){ + // E-TOF: + name = "MM_E_TOF"; + GetHisto(family,name)->Fill(Physics->Si_E[i],Physics->Si_T[i]); + + name = Form("MM%d_E_TOF", Physics->TelescopeNumber[i]); + GetHisto(family,name)->Fill(Physics->Si_E[i],Physics->Si_T[i]); + } + + double Etot=0; + if(Physics->SiLi_E[i]>0){ + name = "MM_SILIE_E"; + Etot = Physics->SiLi_E[i]; + GetHisto(family,name)->Fill(Physics->SiLi_E[i],Physics->Si_E[i]); + + name = Form("MM%d_SILIE_E", Physics->TelescopeNumber[i]); + GetHisto(family,name)->Fill(Physics->SiLi_E[i],Physics->Si_E[i]); + } + + if(Physics->CsI_E[i]>0){ + name = "MM_CSIE_E"; + Etot += Physics->CsI_E[i]; + GetHisto(family,name)->Fill(Physics->CsI_E[i],Physics->Si_E[i]); + name = Form("MM%d_CSIE_E", Physics->TelescopeNumber[i]); + GetHisto(family,name)->Fill(Physics->CsI_E[i],Physics->Si_E[i]); + + } + + if(Etot>0){ + name = "MM_Etot_E"; + GetHisto(family,name)->Fill(Etot,Physics->Si_E[i]); + name = Form("MM%d_Etot_E", Physics->TelescopeNumber[i]); + GetHisto(family,name)->Fill(Etot,Physics->Si_E[i]); + } + + } -void TMust2Spectra::FillRawUserSpectra() -{ - } +//////////////////////////////////////////////////////////////////////////////// +TH1* TMust2Spectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family){ + // create histo + TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup); + vector<TString> index ; + index.push_back(family); + index.push_back(name); + // fill map + fMapHisto[index]=hist; -void TMust2Spectra::FillUserSpectra() -{ - // STRX_E - for (Int_t i = 0; i < fMust2Data->GetMMStripXEMult(); i++) { - MM_STRX_E_BRU[fMust2Data->GetMMStripXEDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMStripXEStripNbr(i), fMust2Data->GetMMStripXEEnergy(i) - 8192); - } - - // STRY_E - for (Int_t i = 0; i < fMust2Data->GetMMStripYEMult(); i++) { - MM_STRY_E_BRU[fMust2Data->GetMMStripYEDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMStripYEStripNbr(i), 8192 - fMust2Data->GetMMStripYEEnergy(i)); - } - - // STRX_T - for (Int_t i = 0; i < fMust2Data->GetMMStripXTMult(); i++) { - MM_STRX_T_BRU[fMust2Data->GetMMStripXTDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMStripXTStripNbr(i), fMust2Data->GetMMStripXTTime(i) - 8192); - } - // STRY_T - for (Int_t i = 0; i < fMust2Data->GetMMStripYTMult(); i++) { - MM_STRY_T_BRU[fMust2Data->GetMMStripYTDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMStripYTStripNbr(i), 8192 - fMust2Data->GetMMStripYTTime(i)); - } - - // SILI_E - for (Int_t i = 0; i < fMust2Data->GetMMSiLiEMult(); i++) { - MM_SILI_E_BRU[fMust2Data->GetMMSiLiEDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMSiLiEPadNbr(i), fMust2Data->GetMMSiLiEEnergy(i)); - } - - // SILI_T - for (Int_t i = 0; i < fMust2Data->GetMMSiLiTMult(); i++) { - MM_SILI_T_BRU[fMust2Data->GetMMSiLiTDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMSiLiTPadNbr(i), fMust2Data->GetMMSiLiTTime(i)); - } - - // CSI_E - for (Int_t i = 0; i < fMust2Data->GetMMCsIEMult(); i++) { - MM_CSI_E_BRU[fMust2Data->GetMMCsIEDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMCsIECristalNbr(i), fMust2Data->GetMMCsIEEnergy(i)); - } - - // CSI_T - for (Int_t i = 0; i < fMust2Data->GetMMCsITMult(); i++) { - MM_CSI_T_BRU[fMust2Data->GetMMCsITDetectorNbr(i) - 1] -> Fill(fMust2Data->GetMMCsITCristalNbr(i), fMust2Data->GetMMCsITTime(i)); - } - - // fill calibrated user spectra - // STRX_E - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMStripXEMult(); i++) { - MM_STRX_E_CAL[fMust2PreTreatedData->GetMMStripXEDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMStripXEStripNbr(i), fMust2PreTreatedData->GetMMStripXEEnergy(i)); - } - // STRY_E - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMStripYEMult(); i++) { - MM_STRY_E_CAL[fMust2PreTreatedData->GetMMStripYEDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMStripYEStripNbr(i), fMust2PreTreatedData->GetMMStripYEEnergy(i)); - } - // STRX_T - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMStripXTMult(); i++) { - MM_STRX_T_CAL[fMust2PreTreatedData->GetMMStripXTDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMStripXTStripNbr(i), fMust2PreTreatedData->GetMMStripXTTime(i)); - } - // STRY_T - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMStripYTMult(); i++) { - MM_STRY_T_CAL[fMust2PreTreatedData->GetMMStripYTDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMStripYTStripNbr(i), fMust2PreTreatedData->GetMMStripYTTime(i)); - } - // SILI_E - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMSiLiEMult(); i++) { - MM_SILI_E_CAL[fMust2PreTreatedData->GetMMSiLiEDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMSiLiEPadNbr(i), fMust2PreTreatedData->GetMMSiLiEEnergy(i)); - } - // SILI_T - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMSiLiTMult(); i++) { - MM_SILI_T_CAL[fMust2PreTreatedData->GetMMSiLiTDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMSiLiTPadNbr(i), fMust2PreTreatedData->GetMMSiLiTTime(i)); - } - // CSI_E - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMCsIEMult(); i++) { - MM_CSI_E_CAL[fMust2PreTreatedData->GetMMCsIEDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMCsIECristalNbr(i), fMust2PreTreatedData->GetMMCsIEEnergy(i)); - } - // CSI_T - for (Int_t i = 0; i < fMust2PreTreatedData->GetMMCsITMult(); i++) { - MM_CSI_T_CAL[fMust2PreTreatedData->GetMMCsITDetectorNbr(i) - 1] -> Fill(fMust2PreTreatedData->GetMMCsITCristalNbr(i), fMust2PreTreatedData->GetMMCsITTime(i)); - } + return hist; } +//////////////////////////////////////////////////////////////////////////////// +TH1* TMust2Spectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family){ + // create histo + TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + vector<TString> index ; + index.push_back(family); + index.push_back(name); -TH1* TMust2Spectra::AddTH1(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, const char* family) -{ - // create histo - TH1 *hist = new TH1I(name, title, nbinsx, xlow, xup); + // fill map + fMapHisto[index]=hist; + + return hist; +} - // fill map - fMapHisto[family].push_back(hist); +//////////////////////////////////////////////////////////////////////////////// +TH1* TMust2Spectra::GetHisto(TString family, TString name){ + vector<TString> index ; + index.push_back(family); + index.push_back(name); - return hist; + // fill map + return fMapHisto.at(index); } +//////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::WriteHisto(TString filename){ + TFile* f=NULL; + if(filename!="VOID"){ + f = new TFile(filename,"RECREATE"); + } -TH1* TMust2Spectra::AddTH2(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char* family) -{ - // create histo - TH1 *hist = new TH2I(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + map< vector<TString>, TH1* >::iterator it; - // fill map - fMapHisto[family].push_back(hist); + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){ + it->second->Write(); + } + + if(filename!="VOID"){ + f->Close(); + delete f; + } + +} +/////////////////////////////////////////////////////////////////////////////// +void TMust2Spectra::CheckSpectra(){ +map< vector<TString>, TH1* >::iterator it; + Color_t ok_color = kTeal+9; + Color_t warning_color = kOrange+8; warning_color *= 1; + Color_t bad_color = kRed; bad_color *= 1; + + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){ + it->second->SetLineColor(ok_color); + it->second->SetFillStyle(1001); + it->second->SetFillColor(ok_color); + } - return hist; } diff --git a/NPLib/MUST2/TMust2Spectra.h b/NPLib/MUST2/TMust2Spectra.h index b65e990f4cc5c34aad398a344cbeb9df98b2df58..308004ad288ceac0a5365c9bb305dd5e345eff8d 100644 --- a/NPLib/MUST2/TMust2Spectra.h +++ b/NPLib/MUST2/TMust2Spectra.h @@ -1,5 +1,5 @@ -#ifndef __MUST2SPECTRA__ -#define __MUST2SPECTRA__ +#ifndef TMUST2SPECTRA_H +#define TMUST2SPECTRA_H /***************************************************************************** * Copyright (C) 2009-2013 this file is part of the NPTool Project * * * @@ -25,97 +25,63 @@ // C++ STL headers #include <map> -#include <string> // ROOT headers #include "TObject.h" #include <TH1.h> #include <TH2.h> +#include <TString.h> // NPLib headers #include "TMust2Data.h" #include "TMust2Physics.h" - using namespace std; -#define NUMBERMUST2 8 -#define NUMBERSTRIPS 128 -#define NUMBERSILI 16 -#define NUMBERCSI 16 - - -class TMust2Spectra : public TObject { - public: - // constructor and destructor - TMust2Spectra(); - virtual ~TMust2Spectra(); - - // Instantiate and register histo to maps - TH1* AddTH1(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, const char* family = "MUST2"); - TH1* AddTH2(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char* family = "MUST2"); - - // Initialization methods - void InitRawUserSpectra(); - void InitUserSpectra(); - // Filling methods - void FillRawUserSpectra(); - void FillUserSpectra(); - - // getters and setters - // getters - TMust2Data* GetMust2Data() const {return fMust2Data;} - TMust2Data* GetMust2PreTreatedData() const {return fMust2PreTreatedData;} - TMust2Physics* GetMust2Physics() const {return fMust2Physics;} - // setters - void SetMust2Data(TMust2Data* must2Data) {fMust2Data = must2Data;} - void SetMust2PreTreatedData(TMust2Data* must2PreTreatedData) {fMust2PreTreatedData = must2PreTreatedData;} - void SetMust2Data(TMust2Physics* must2Physics) {fMust2Physics = must2Physics;} - - // get map histo which will be used for GSpectra in GUser - map< string, vector<TH1*> > GetMapHisto() const {return fMapHisto;} - - - private: - // Data and physics class for Must2 - TMust2Data *fMust2Data; - TMust2Data *fMust2PreTreatedData; - TMust2Physics *fMust2Physics; - - private: - // map holding histo pointers and their family names - map< string, vector<TH1*> > fMapHisto; - - private: - // monodim - TH1 *MM_STRX_MULT[NUMBERMUST2]; // dim = 128 - TH1 *MM_STRY_MULT[NUMBERMUST2]; // dim = 128 - TH1 *MM_SILI_MULT[NUMBERMUST2]; // dim = 16 - TH1 *MM_CSI_MULT[NUMBERMUST2]; // dim = 16 - - // bidim - TH1 *MM_STRX_E_BRU[NUMBERMUST2]; // dim = 128 x 512 - TH1 *MM_STRY_E_BRU[NUMBERMUST2]; - TH1 *MM_STRX_T_BRU[NUMBERMUST2]; - TH1 *MM_STRY_T_BRU[NUMBERMUST2]; - // SiLi E - TH1 *MM_SILI_E_BRU[NUMBERMUST2]; // dim = 16 x 512 - TH1 *MM_SILI_T_BRU[NUMBERMUST2]; // dim = 16 x 512 - // CsI E - TH1 *MM_CSI_E_BRU[NUMBERMUST2]; // dim = 16 x 512 - TH1 *MM_CSI_T_BRU[NUMBERMUST2]; // dim = 16 x 512 - // Strips (X,Y) (E.T) - TH1 *MM_STRX_E_CAL[NUMBERMUST2]; // dim = 128 x 500 (50 MeV range) - TH1 *MM_STRY_E_CAL[NUMBERMUST2]; - TH1 *MM_STRX_T_CAL[NUMBERMUST2]; // dim = 128 x 500 (500 ns range) - TH1 *MM_STRY_T_CAL[NUMBERMUST2]; - // SiLi E - TH1 *MM_SILI_E_CAL[NUMBERMUST2]; // dim = 16 x 512 - TH1 *MM_SILI_T_CAL[NUMBERMUST2]; // dim = 16 x 512 - // CsI E - TH1 *MM_CSI_E_CAL[NUMBERMUST2]; // dim = 16 x 512 - TH1 *MM_CSI_T_CAL[NUMBERMUST2]; // dim = 16 x 512 - - ClassDef(TMust2Spectra,1) // Must2Spectra structure +// ForwardDeclaration +class TMust2Physics ; + +class TMust2Spectra { + public: + // constructor and destructor + TMust2Spectra(); + TMust2Spectra(unsigned int NumberOfTelescope); + ~TMust2Spectra(); + + private: + // Instantiate and register histo to maps + TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family); + TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, + Int_t nbinsy, Double_t ylow, Double_t yup,TString family); + + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TMust2Data*); + void FillPreTreatedSpectra(TMust2Data*); + void FillPhysicsSpectra(TMust2Physics*); + // Check the Spectra + void CheckSpectra(); + + public: + // get map histo which will be used for GSpectra in GUser + map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;} + TH1* GetHisto(TString family,TString name); + void WriteHisto(TString filename="VOID"); + + private: // Information on MUST2 + unsigned int fNumberOfTelescope; + unsigned int fStripX; + unsigned int fStripY; + unsigned int fPadSili; + unsigned int fCrystalCsI; + + private: + // map holding histo pointers and their family names + map< vector<TString>, TH1* > fMapHisto; }; #endif diff --git a/NPLib/Maya/ConfigReader.cxx b/NPLib/Maya/ConfigReader.cxx index 019ba728956a85cfc20c9e178ce756f17374f384..c850a6fb2772ece89df41ad7c9a19c8d1476abb7 100755 --- a/NPLib/Maya/ConfigReader.cxx +++ b/NPLib/Maya/ConfigReader.cxx @@ -343,7 +343,7 @@ template<typename T> int ConfigReader::Read(string token, std::vector<std::vecto return npar ; } -template<typename T> int ConfigReader::Read(string token, std::vector<T> &v1, int dimension = 1){ +template<typename T> int ConfigReader::Read(string token, std::vector<T> &v1, int dimension){ if((dimension<1) || (token.size()==0) ) return 0 ; if(!files_already_read) { if (FindAllToken() == -1) { diff --git a/NPLib/Physics/NPReaction.cxx b/NPLib/Physics/NPReaction.cxx index efa74ddfc3813f14b38c0e1ff8d31386b599a179..b26c96698e2d88912b9e3198bdd8e245fe7f5d12 100644 --- a/NPLib/Physics/NPReaction.cxx +++ b/NPLib/Physics/NPReaction.cxx @@ -65,6 +65,9 @@ Reaction::Reaction(){ // Need to be done before initializePrecomputeVariable fKineLine3 = 0 ; fKineLine4 = 0 ; + fLineBrho3 = 0 ; + fTheta3VsTheta4 = 0; + fAngleLine = 0; // fNuclei1 = new Beam(); @@ -127,6 +130,9 @@ Reaction::Reaction(string reaction){ fKineLine3 = 0 ; fKineLine4 = 0 ; + fLineBrho3 = 0; + fTheta3VsTheta4 = 0; + fAngleLine = 0; fNuclei1 = new Beam(A); fNuclei2 = new Nucleus(b); fNuclei3 = new Nucleus(c); @@ -450,9 +456,6 @@ void Reaction::ReadConfigurationFile(string Path){ //////////////////////////////////////////////////////////////////////////////////////////// void Reaction::initializePrecomputeVariable(){ - // delete the previously calculated kinematical line: - if(fKineLine3!=0) {delete fKineLine3 ; fKineLine3 = 0;} - if(fKineLine4!=0) {delete fKineLine4 ; fKineLine4 = 0;} m1 = fNuclei1->Mass(); m2 = fNuclei2->Mass(); @@ -463,13 +466,15 @@ void Reaction::initializePrecomputeVariable(){ fTotalEnergyImpulsionCM = TLorentzVector(0,0,0,sqrt(s)); - ECM_1 = (s + m1*m1 - m2*m2)/(2*sqrt(s)); - ECM_2 = (s + m2*m2 - m1*m1)/(2*sqrt(s)); - ECM_3 = (s + m3*m3 - m4*m4)/(2*sqrt(s)); - ECM_4 = (s + m4*m4 - m3*m3)/(2*sqrt(s)); + ECM_1 = (s + m1*m1 - m2*m2)/(2*sqrt(s)); + ECM_2 = (s + m2*m2 - m1*m1)/(2*sqrt(s)); + ECM_3 = (s + m3*m3 - m4*m4)/(2*sqrt(s)); + ECM_4 = (s + m4*m4 - m3*m3)/(2*sqrt(s)); - pCM_3 = sqrt(ECM_3*ECM_3 - m3*m3); - pCM_4 = sqrt(ECM_4*ECM_4 - m4*m4); + pCM_1 = sqrt(ECM_1*ECM_1 - m1*m1); + pCM_2 = sqrt(ECM_2*ECM_2 - m2*m2); + pCM_3 = sqrt(ECM_3*ECM_3 - m3*m3); + pCM_4 = sqrt(ECM_4*ECM_4 - m4*m4); fImpulsionLab_1 = TVector3(0,0,sqrt(fBeamEnergy*fBeamEnergy + 2*fBeamEnergy*m1)); fImpulsionLab_2 = TVector3(0,0,0); @@ -506,93 +511,103 @@ void Reaction::SetNuclei3(double EnergyLab, double ThetaLab){ //////////////////////////////////////////////////////////////////////////////////////////// -TGraph* Reaction::GetKinematicLine3(){ - - if(fKineLine3==0){ - int size = 360; - double x[size]; - double y[size]; - double theta3,E3,theta4,E4; - - for (int i = 0; i < size; ++i){ - SetThetaCM(((double)i)/2*deg); - KineRelativistic(theta3, E3, theta4, E4); - fNuclei3->SetKineticEnergy(E3); - - x[i] = theta3/deg; - y[i] = E3; - } +TGraph* Reaction::GetKinematicLine3(double AngleStep_CM){ + + vector<double> vx; + vector<double> vy; + double theta3,E3,theta4,E4; - fKineLine3 = new TGraph(size,x,y); - // fKineLine3->SetTitle("Kinematic Line of particule 3"); - } + for (double angle=0 ; angle < 360 ; angle+=AngleStep_CM){ + SetThetaCM(angle*deg); + KineRelativistic(theta3, E3, theta4, E4); + fNuclei3->SetKineticEnergy(E3); + + vx.push_back(theta3/deg); + vy.push_back(E3); + } + fKineLine3 = new TGraph(vx.size(),&vx[0],&vy[0]); + return(fKineLine3); } - //////////////////////////////////////////////////////////////////////////////////////////// -TGraph* Reaction::GetKinematicLine4(){ - if(fKineLine4==0){ - int size = 360; - double x[size]; - double y[size]; +TGraph* Reaction::GetKinematicLine4(double AngleStep_CM){ + + vector<double> vx; + vector<double> vy; double theta3,E3,theta4,E4; - for (int i = 0; i < size; ++i) - { - SetThetaCM(((double)i)/2*deg); - KineRelativistic(theta3, E3, theta4, E4); - fNuclei4->SetKineticEnergy(E4); - - x[i] = theta4/deg; - y[i] = E4; - } - fKineLine4= new TGraph(size,x,y); - // fKineLine4->SetTitle("Kinematic Line of particule 4"); - } + for (double angle=0 ; angle < 360 ; angle+=AngleStep_CM){ + SetThetaCM(angle*deg); + KineRelativistic(theta3, E3, theta4, E4); + fNuclei4->SetKineticEnergy(E4); + + vx.push_back(theta3/deg); + vy.push_back(E4); + } + fKineLine4= new TGraph(vx.size(),&vx[0],&vy[0]); + return(fKineLine4); } +//////////////////////////////////////////////////////////////////////////////////////////// +TGraph* Reaction::GetTheta3VsTheta4(double AngleStep_CM) +{ + + vector<double> vx; + vector<double> vy; + double theta3,E3,theta4,E4; + + for (double angle=0 ; angle < 360 ; angle+=AngleStep_CM){ + SetThetaCM(angle*deg); + KineRelativistic(theta3, E3, theta4, E4); + + vx.push_back(theta3/deg); + vy.push_back(theta4/deg); + } + fTheta3VsTheta4= new TGraph(vx.size(),&vx[0],&vy[0]); + return(fTheta3VsTheta4); +} + //////////////////////////////////////////////////////////////////////////////////////////// -TGraph* Reaction::GetBrhoLine3(){ - int size = 360; - double x[size]; - double y[size]; +TGraph* Reaction::GetBrhoLine3(double AngleStep_CM){ + + vector<double> vx; + vector<double> vy; double theta3,E3,theta4,E4; double Brho; - for (int i = 0; i < size; ++i) - { - SetThetaCM(((double)i)/2*deg); + for (double angle=0 ; angle < 360 ; angle+=AngleStep_CM){ + SetThetaCM(angle*deg); KineRelativistic(theta3, E3, theta4, E4); fNuclei3->SetKineticEnergy(E3); Brho = fNuclei3->GetBrho(); - x[i] = theta3/deg; - y[i] = Brho; + vx.push_back(theta3/deg); + vy.push_back(Brho); } - TGraph* LineBrho3= new TGraph(size,x,y); - return(LineBrho3); + fLineBrho3= new TGraph(vx.size(),&vx[0],&vy[0]); + return(fLineBrho3); } //////////////////////////////////////////////////////////////////////////////////////////// -TGraph* Reaction::GetThetaLabVersusThetaCM(){ - int size = 360; - double x[size]; - double y[size]; +TGraph* Reaction::GetThetaLabVersusThetaCM(double AngleStep_CM){ + + vector<double> vx; + vector<double> vy; double theta3,E3,theta4,E4; - for (int i = 0; i < size; ++i){ - SetThetaCM(((double)i)/2*deg); + for (double angle=0 ; angle < 360 ; angle+=AngleStep_CM){ + SetThetaCM(angle*deg); KineRelativistic(theta3, E3, theta4, E4); - x[i] = fThetaCM/deg; - y[i] = theta3/deg; + vx.push_back(fThetaCM/deg); + vy.push_back(theta3/deg); } - TGraph* AngleLine= new TGraph(size,x,y); - return(AngleLine); + fAngleLine= new TGraph(vx.size(),&vx[0],&vy[0]); + return(fAngleLine); } diff --git a/NPLib/Physics/NPReaction.h b/NPLib/Physics/NPReaction.h index 4e08cfe10d84e3282c80145047c00c6472149e2a..72a2b9654bddc29f6d05a858370b349d33dd7e38 100644 --- a/NPLib/Physics/NPReaction.h +++ b/NPLib/Physics/NPReaction.h @@ -74,8 +74,11 @@ namespace NPL{ bool fshoot4; private: // use to display the kinematical line - TGraph* fKineLine3 ; - TGraph* fKineLine4 ; + TGraph* fKineLine3 ; + TGraph* fKineLine4 ; + TGraph* fTheta3VsTheta4; + TGraph* fLineBrho3; + TGraph* fAngleLine; private: Beam* fNuclei1; // Beam Nucleus* fNuclei2; // Target @@ -151,12 +154,14 @@ namespace NPL{ TVector3 fImpulsionCM_4; // CM Energy composante & CM impulsion norme - Double_t ECM_1; - Double_t ECM_2; - Double_t ECM_3; - Double_t ECM_4; - Double_t pCM_3; - Double_t pCM_4; + Double_t ECM_1; + Double_t ECM_2; + Double_t ECM_3; + Double_t ECM_4; + Double_t pCM_1; + Double_t pCM_2; + Double_t pCM_3; + Double_t pCM_4; // Mandelstam variable Double_t s; @@ -192,11 +197,20 @@ namespace NPL{ void SetNuclei3(double EnergyLab, double ThetaLab); - TGraph* GetKinematicLine3(); - TGraph* GetKinematicLine4(); - TGraph* GetBrhoLine3(); - TGraph* GetThetaLabVersusThetaCM(); - void PrintKinematic(); + TGraph* GetKinematicLine3(double AngleStep_CM=1); + TGraph* GetKinematicLine4(double AngleStep_CM=1); + TGraph* GetBrhoLine3(double AngleStep_CM=1); + TGraph* GetThetaLabVersusThetaCM(double AngleStep_CM=1); + TGraph* GetTheta3VsTheta4(double AngleStep_CM=1); + void PrintKinematic(); + double GetP_CM_1() {return pCM_1;} + double GetP_CM_2() {return pCM_2;} + double GetP_CM_3() {return pCM_3;} + double GetP_CM_4() {return pCM_4;} + double GetE_CM_1() {return ECM_1;} + double GetE_CM_2() {return ECM_2;} + double GetE_CM_3() {return ECM_3;} + double GetE_CM_4() {return ECM_4;} // Print private paremeter void Print() const; diff --git a/NPLib/S2/Makefile b/NPLib/S2/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..333d703c02b28fc26deed5ff60f6202e2a63a90e --- /dev/null +++ b/NPLib/S2/Makefile @@ -0,0 +1,39 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libS2.so + +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## S2 detector ## +libS2.so: TS2Data.o TS2DataDict.o TS2Physics.o TS2PhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +TS2DataDict.cxx: TS2Data.h + rootcint -f $@ -c $^ + +TS2PhysicsDict.cxx: TS2Physics.h + rootcint -f $@ -c $^ + +# dependances +TS2Data.o: TS2Data.cxx TS2Data.h +TS2Physics.o: TS2Physics.cxx TS2Physics.h +####################################### + +############# Clean and More ########## +clean: + @rm -f core *~ *.o *Dict* + +distclean: + make clean; rm -f *.so + +.SUFFIXES: .$(SrcSuf) + +### + +.$(SrcSuf).$(ObjSuf): + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< + + diff --git a/NPLib/S2/TS2Data.cxx b/NPLib/S2/TS2Data.cxx new file mode 100644 index 0000000000000000000000000000000000000000..21d0227c8a163478e0347087bd046691e06fc31f --- /dev/null +++ b/NPLib/S2/TS2Data.cxx @@ -0,0 +1,68 @@ +#include <iostream> +using namespace std; + +#include "TS2Data.h" + + +ClassImp(TS2Data) + +TS2Data::TS2Data() +{ + // Default constructor + + Clear(); +} + + + +TS2Data::~TS2Data() +{ +} + + + +void TS2Data::Clear() +{ + // DSSD + // (Th,E) + fS2_Theta_E_DetNbr.clear(); + fS2_Theta_E_StripNbr.clear(); + fS2_Theta_E_Energy.clear(); + // (Th,T) + fS2_Theta_T_DetNbr.clear(); + fS2_Theta_T_StripNbr.clear(); + fS2_Theta_T_Time.clear(); + // (Ph,E) + fS2_Phi_E_DetNbr.clear(); + fS2_Phi_E_StripNbr.clear(); + fS2_Phi_E_Energy.clear(); + // (Ph,T) + fS2_Phi_T_DetNbr.clear(); + fS2_Phi_T_StripNbr.clear(); + fS2_Phi_T_Time.clear(); +} + + + +void TS2Data::Dump() const +{ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event XXXXXXXXXXXXXXXXX" << endl; + + // DSSD + // (Th,E) + cout << "S2_MultThE = " << fS2_Theta_E_DetNbr.size() << endl; + for (UShort_t i = 0; i < fS2_Theta_E_DetNbr.size(); i++) + cout << "DetThE: " << fS2_Theta_E_DetNbr[i] << " StripThE: " << fS2_Theta_E_StripNbr[i] << " EnergyTh: " << fS2_Theta_E_Energy[i] << endl; + // (Th,T) + cout << "S2_MultThT = " << fS2_Theta_T_DetNbr.size() << endl; + for (UShort_t i = 0; i < fS2_Theta_T_DetNbr.size(); i++) + cout << "DetThT: " << fS2_Theta_T_DetNbr[i] << " StripThT: " << fS2_Theta_T_StripNbr[i] << " TimeTh: " << fS2_Theta_T_Time[i] << endl; + // (Ph,E) + cout << "S2_MultPhE = " << fS2_Phi_E_DetNbr.size() << endl; + for (UShort_t i = 0; i < fS2_Phi_E_DetNbr.size(); i++) + cout << "DetPhE: " << fS2_Phi_E_DetNbr[i] << " StripPhE: " << fS2_Phi_E_StripNbr[i] << " EnergyPh: " << fS2_Phi_E_Energy[i] << endl; + // (Ph,T) + cout << "S2_MultThT = " << fS2_Phi_T_DetNbr.size() << endl; + for (UShort_t i = 0; i < fS2_Phi_T_DetNbr.size(); i++) + cout << "DetThT: " << fS2_Phi_T_DetNbr[i] << " StripThT: " << fS2_Phi_T_StripNbr[i] << " TimeTh: " << fS2_Phi_T_Time[i] << endl; +} diff --git a/NPLib/S2/TS2Data.h b/NPLib/S2/TS2Data.h new file mode 100644 index 0000000000000000000000000000000000000000..20e4ef1b90067c98367843bb1d1da1f389e5965d --- /dev/null +++ b/NPLib/S2/TS2Data.h @@ -0,0 +1,85 @@ +#ifndef __S2DATA__ +#define __S2DATA__ + +#include <vector> + +#include "TObject.h" + +using namespace std; + +class TS2Data : public TObject { + private: + // DSSD + // Theta strips + // ADC + vector<UShort_t> fS2_Theta_E_DetNbr; + vector<UShort_t> fS2_Theta_E_StripNbr; + vector<Double_t> fS2_Theta_E_Energy; + // TDC + vector<UShort_t> fS2_Theta_T_DetNbr; + vector<UShort_t> fS2_Theta_T_StripNbr; + vector<Double_t> fS2_Theta_T_Time; + // Phi strips + // ADC + vector<UShort_t> fS2_Phi_E_DetNbr; + vector<UShort_t> fS2_Phi_E_StripNbr; + vector<Double_t> fS2_Phi_E_Energy; + // TDC + vector<UShort_t> fS2_Phi_T_DetNbr; + vector<UShort_t> fS2_Phi_T_StripNbr; + vector<Double_t> fS2_Phi_T_Time; + + public: + TS2Data(); + virtual ~TS2Data(); + + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + + ///////////////////// GETTERS //////////////////////// + // (Th,E) + UShort_t GetS2ThetaEMult() {return fS2_Theta_E_DetNbr.size();} + UShort_t GetS2ThetaEDetectorNbr(Int_t i) {return fS2_Theta_E_DetNbr.at(i);} + UShort_t GetS2ThetaEStripNbr(Int_t i) {return fS2_Theta_E_StripNbr.at(i);} + Double_t GetS2ThetaEEnergy(Int_t i) {return fS2_Theta_E_Energy.at(i);} + // (Th,T) + UShort_t GetS2ThetaTMult() {return fS2_Theta_T_DetNbr.size();} + UShort_t GetS2ThetaTDetectorNbr(Int_t i) {return fS2_Theta_T_DetNbr.at(i);} + UShort_t GetS2ThetaTStripNbr(Int_t i) {return fS2_Theta_T_StripNbr.at(i);} + Double_t GetS2ThetaTTime(Int_t i) {return fS2_Theta_T_Time.at(i);} + // (Ph,E) + UShort_t GetS2PhiEMult() {return fS2_Phi_E_DetNbr.size();} + UShort_t GetS2PhiEDetectorNbr(Int_t i) {return fS2_Phi_E_DetNbr.at(i);} + UShort_t GetS2PhiEStripNbr(Int_t i) {return fS2_Phi_E_StripNbr.at(i);} + Double_t GetS2PhiEEnergy(Int_t i) {return fS2_Phi_E_Energy.at(i);} + // (Ph,T) + UShort_t GetS2PhiTMult() {return fS2_Phi_T_DetNbr.size();} + UShort_t GetS2PhiTDetectorNbr(Int_t i) {return fS2_Phi_T_DetNbr.at(i);} + UShort_t GetS2PhiTStripNbr(Int_t i) {return fS2_Phi_T_StripNbr.at(i);} + Double_t GetS2PhiTTime(Int_t i) {return fS2_Phi_T_Time.at(i);} + + ///////////////////// SETTERS //////////////////////// + // (Th,E) + void SetS2ThetaEDetectorNbr(UShort_t det) {fS2_Theta_E_DetNbr.push_back(det);} + void SetS2ThetaEStripNbr(UShort_t Nr) {fS2_Theta_E_StripNbr.push_back(Nr);} + void SetS2ThetaEEnergy(Double_t E) {fS2_Theta_E_Energy.push_back(E);} + // (Th,T) + void SetS2ThetaTDetectorNbr(UShort_t det) {fS2_Theta_T_DetNbr.push_back(det);} + void SetS2ThetaTStripNbr(UShort_t Nr) {fS2_Theta_T_StripNbr.push_back(Nr);} + void SetS2ThetaTTime(Double_t T) {fS2_Theta_T_Time.push_back(T);} + // (Ph,E) + void SetS2PhiEDetectorNbr(UShort_t det) {fS2_Phi_E_DetNbr.push_back(det);} + void SetS2PhiEStripNbr(UShort_t Nr) {fS2_Phi_E_StripNbr.push_back(Nr);} + void SetS2PhiEEnergy(Double_t E) {fS2_Phi_E_Energy.push_back(E);} + // (Ph,T) + void SetS2PhiTDetectorNbr(UShort_t det) {fS2_Phi_T_DetNbr.push_back(det);} + void SetS2PhiTStripNbr(UShort_t Nr) {fS2_Phi_T_StripNbr.push_back(Nr);} + void SetS2PhiTTime(Double_t T) {fS2_Phi_T_Time.push_back(T);} + + ClassDef(TS2Data,1) // S2Data structure +}; + +#endif diff --git a/NPLib/S2/TS2Physics.cxx b/NPLib/S2/TS2Physics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f6c875d4b08a7c6ce31c1769dc02250fb1baed74 --- /dev/null +++ b/NPLib/S2/TS2Physics.cxx @@ -0,0 +1,1171 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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: Sandra GIRON contact address: giron@ipno.in2p3.fr * + * * + * Creation Date : april 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold S2 treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include "TS2Physics.h" +using namespace S2_LOCAL; + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> + +// NPL +#include "../include/RootInput.h" +#include "../include/RootOutput.h" + +// ROOT +#include "TChain.h" +/////////////////////////////////////////////////////////////////////////// + +ClassImp(TS2Physics) +/////////////////////////////////////////////////////////////////////////// +TS2Physics::TS2Physics() +{ + EventMultiplicity = 0 ; + m_EventData = new TS2Data ; + m_PreTreatedData = new TS2Data ; + m_EventPhysics = this ; + + m_NumberOfAnnular = 0 ; + m_NumberOfStripsTheta = 64 ; + m_NumberOfStripsPhi = 16 ; + m_NumberOfQuadrants = 4 ; + + m_MaximumStripMultiplicityAllowed = 10 ; + m_StripEnergyMatchingSigma = 0.020 ; // (in MeV) be careful to redefine if calibrated energy are in keV + m_StripEnergyMatchingNumberOfSigma= 30 ; + + // Raw Threshold + m_S2_Theta_E_RAW_Threshold = 8200 ; + m_S2_Phi_E_RAW_Threshold = 8200 ; + + // Calibrated Threshold + m_S2_Theta_E_Threshold = 0 ; + m_S2_Phi_E_Threshold = 0 ; + m_S2_Theta_E_Threshold_sup = 100000 ; + m_S2_Phi_E_Threshold_sup = 100000 ; + + + m_Take_E_Phi=false; + m_Take_T_Phi=true; + +} + + +/////////////////////////////////////////////////////////////////////////// +void TS2Physics::BuildSimplePhysicalEvent() +{ + + PreTreat(); + /* + // Theta + // E + for(int i = 0 ; i < m_PreTreatedData->GetS2ThetaEMult() ; i++) + { + NTheta .push_back( m_PreTreatedData->GetS2ThetaEDetectorNbr(i) ) ; + StrTheta .push_back( m_PreTreatedData->GetS2ThetaEStripNbr(i) ) ; + ETheta .push_back( m_PreTreatedData->GetS2ThetaEEnergy(i)) ; + + // T + for(int j = 0 ; j < m_PreTreatedData->GetS2ThetaTMult() ; j++) + { + if(m_PreTreatedData->GetS2ThetaEDetectorNbr(i) == m_PreTreatedData->GetS2ThetaTDetectorNbr(j) && m_PreTreatedData->GetS2ThetaEStripNbr(i) == m_PreTreatedData->GetS2ThetaTStripNbr(j)) + TTheta.push_back( m_PreTreatedData->GetS2ThetaTTime(j) ) ; + } + } + + // Phi + // E + for(int i = 0 ; i < m_PreTreatedData->GetS2PhiEMult() ; i++) + { + NPhi.push_back(m_PreTreatedData->GetS2PhiEDetectorNbr(i) ) ; + StrPhi .push_back( m_PreTreatedData->GetS2PhiEStripNbr(i) ) ; + EPhi .push_back( m_PreTreatedData->GetS2PhiEEnergy(i) ) ; + + // T + for(int j = 0 ; j < m_PreTreatedData->GetS2PhiTMult() ; j++) + { + if(m_PreTreatedData->GetS2PhiEDetectorNbr(i) == m_PreTreatedData->GetS2PhiTDetectorNbr(j) && m_PreTreatedData->GetS2PhiEStripNbr(i) == m_PreTreatedData->GetS2PhiTStripNbr(j)) + TPhi .push_back( m_PreTreatedData->GetS2PhiTTime(j) ) ; + } + } + + return; + */ +} + +/////////////////////////////////////////////////////////////////////////// + +void TS2Physics::BuildPhysicalEvent() +{ + PreTreat(); + + + // if( CheckEvent() == 1 ) + { + vector< TVector2 > couple = Match_Theta_Phi() ; + EventMultiplicity = couple.size(); + + // cout << EventMultiplicity << endl; + + for(unsigned int i = 0 ; i < couple.size() ; i++) + { + // cout << "CheckEvent = 1, Multiplicity = " << EventMultiplicity << endl; + + int N = m_PreTreatedData->GetS2ThetaEDetectorNbr(couple[i].X()) ; + + int Theta = m_PreTreatedData->GetS2ThetaEStripNbr(couple[i].X()) ; + int Phi = m_PreTreatedData->GetS2PhiEStripNbr(couple[i].Y()) ; + + double S2_Theta_E = m_PreTreatedData->GetS2ThetaEEnergy( couple[i].X() ) ; + double S2_Phi_E = m_PreTreatedData->GetS2PhiEEnergy( couple[i].Y() ) ; + + //cout << N << " " << Theta << " " << Phi << " " << S2_Theta_E << " " << S2_Phi_E << endl; + + // Search for associate Time + double S2_Theta_T = -1000 ; + for(unsigned int t = 0 ; t < m_PreTreatedData->GetS2ThetaTMult() ; t++ ) + { + if( m_PreTreatedData->GetS2ThetaTStripNbr( couple[i].X() ) == m_PreTreatedData->GetS2ThetaTStripNbr(t) + || m_PreTreatedData->GetS2ThetaTDetectorNbr( couple[i].X() ) == m_PreTreatedData->GetS2ThetaTDetectorNbr(t)) + { + S2_Theta_T = m_PreTreatedData->GetS2ThetaTTime(t); + // cout << "Theta_T = " << S2_Theta_T << endl; + } + } + + double S2_Phi_T = -1000 ; + for(unsigned int t = 0 ; t < m_PreTreatedData->GetS2PhiTMult() ; t++ ) + { + if( m_PreTreatedData->GetS2PhiTStripNbr( couple[i].Y() ) == m_PreTreatedData->GetS2PhiTStripNbr(t) + || m_PreTreatedData->GetS2PhiTDetectorNbr( couple[i].Y() ) == m_PreTreatedData->GetS2PhiTDetectorNbr(t)) + { + S2_Phi_T = m_PreTreatedData->GetS2PhiTTime(t); + // cout << "Phi_T = " << S2_Phi_T << endl; + } + } + + Si_Theta.push_back(Theta) ; Si_Phi.push_back(Phi) ; AnnularNumber.push_back(N) ; + + if(m_Take_E_Phi) Si_E.push_back(S2_Phi_E); + else Si_E.push_back(S2_Theta_E); + + if(m_Take_T_Phi) Si_T.push_back(S2_Phi_T) ; + else Si_T.push_back(S2_Theta_T) ; + + // Store the other value for checking purpose + Si_ETheta.push_back(S2_Theta_E); ; + Si_TTheta.push_back(S2_Theta_T); ; + + Si_EPhi.push_back(S2_Phi_E); ; + Si_TPhi.push_back(S2_Phi_T); ; + + // cout << N << " " << Theta << " " << Phi << " " << S2_Theta_E << " " << S2_Phi_E << endl; + + } // check event + } + + + +} + +/////////////////////////////////////////////////////////////////////////// +void TS2Physics::PreTreat() +{ + ClearPreTreatedData(); + + // Theta + // E + for(int i = 0 ; i < m_EventData->GetS2ThetaEMult() ; i++) + { + + if(m_EventData->GetS2ThetaEEnergy(i)> m_S2_Theta_E_RAW_Threshold && IsValidChannel("Theta", m_EventData->GetS2ThetaEDetectorNbr(i), m_EventData->GetS2ThetaEStripNbr(i)) ) + { + double ETheta = fS2_Theta_E(m_EventData , i); + + if( ETheta > m_S2_Theta_E_Threshold && ETheta < m_S2_Theta_E_Threshold_sup) + { + m_PreTreatedData->SetS2ThetaEDetectorNbr( m_EventData->GetS2ThetaEDetectorNbr(i) ) ; + m_PreTreatedData->SetS2ThetaEStripNbr( m_EventData->GetS2ThetaEStripNbr(i) ) ; + m_PreTreatedData->SetS2ThetaEEnergy( ETheta ) ; + } + } + } + + // T + for(int i = 0 ; i < m_EventData->GetS2ThetaTMult() ; i++) + { + if(IsValidChannel("Theta", m_EventData->GetS2ThetaTDetectorNbr(i), m_EventData->GetS2ThetaTStripNbr(i))) + { + m_PreTreatedData->SetS2ThetaTDetectorNbr( m_EventData->GetS2ThetaTDetectorNbr(i) ) ; + m_PreTreatedData->SetS2ThetaTStripNbr( m_EventData->GetS2ThetaTStripNbr(i) ) ; + m_PreTreatedData->SetS2ThetaTTime( fS2_Theta_T(m_EventData , i) ) ; + } + } + + + // Phi + // E + for(int i = 0 ; i < m_EventData->GetS2PhiEMult() ; i++) + { + if( m_EventData->GetS2PhiEEnergy(i)< m_S2_Phi_E_RAW_Threshold && IsValidChannel("Phi", m_EventData->GetS2PhiEDetectorNbr(i), m_EventData->GetS2PhiEStripNbr(i))) + { + double EPhi = fS2_Phi_E(m_EventData , i); + + if( EPhi > m_S2_Phi_E_Threshold && EPhi < m_S2_Phi_E_Threshold_sup) + { + m_PreTreatedData->SetS2PhiEDetectorNbr( m_EventData->GetS2PhiEDetectorNbr(i) ) ; + m_PreTreatedData->SetS2PhiEStripNbr( m_EventData->GetS2PhiEStripNbr(i) ) ; + m_PreTreatedData->SetS2PhiEEnergy( EPhi ) ; + } + } + } + + // T + for(int i = 0 ; i < m_EventData->GetS2PhiTMult() ; i++) + { + if(IsValidChannel("Phi", m_EventData->GetS2PhiTDetectorNbr(i), m_EventData->GetS2PhiTStripNbr(i))) + { + m_PreTreatedData->SetS2PhiTDetectorNbr( m_EventData->GetS2PhiTDetectorNbr(i) ) ; + m_PreTreatedData->SetS2PhiTStripNbr( m_EventData->GetS2PhiTStripNbr(i) ) ; + m_PreTreatedData->SetS2PhiTTime( fS2_Phi_T(m_EventData , i) ) ; + } + } + +// if (m_EventData->GetS2ThetaEEnergy(0)) { + m_EventData->Dump(); + m_PreTreatedData->Dump(); +// } + + return; +} + + +/////////////////////////////////////////////////////////////////////////// +int TS2Physics :: CheckEvent() +{ + // m_PreTreatedData -> Dump(); + + // Check the size of the different elements + if(m_PreTreatedData->GetS2ThetaEMult() == m_PreTreatedData->GetS2PhiEMult() ) + // && m_PreTreatedData->GetS2PhiEMult() == m_PreTreatedData->GetS2ThetaTMult() && m_PreTreatedData->GetS2ThetaTMult() == m_PreTreatedData->GetS2PhiTMult()) + { + // cout << "CHECK 1" << endl; + return 1 ; // Regular Event + } + + else if(m_PreTreatedData->GetS2ThetaEMult() == m_PreTreatedData->GetS2PhiEMult()+1 || m_PreTreatedData->GetS2ThetaEMult() == m_PreTreatedData->GetS2PhiEMult()-1 ) + { + // cout << "CHECK 2" << endl; + return 2 ; // Pseudo Event, potentially interstrip + } + + else { + // cout << "CHECK -1" << endl; + return -1 ; // Rejected Event + } + +} + +/////////////////////////////////////////////////////////////////////////// +bool TS2Physics :: ResolvePseudoEvent() +{ + return false; +} + +/////////////////////////////////////////////////////////////////////////// +vector < TVector2 > TS2Physics :: Match_Theta_Phi() +{ + + vector < TVector2 > ArrayOfGoodCouple ; + + // Prevent code from treating very high multiplicity Event + // Those event are not physical anyway and that improve speed. + if( m_PreTreatedData->GetS2ThetaEMult() > m_MaximumStripMultiplicityAllowed || m_PreTreatedData->GetS2PhiEMult() > m_MaximumStripMultiplicityAllowed ) + { + // cout << "too high multiplicity : ThetaEMult = " << m_PreTreatedData->GetS2ThetaEMult()<< " PhiEMult = " << m_PreTreatedData->GetS2PhiEMult() << endl; + return ArrayOfGoodCouple; + } + + for(int i = 0 ; i < m_PreTreatedData->GetS2ThetaEMult(); i++) + { + for(int j = 0 ; j < m_PreTreatedData->GetS2PhiEMult(); j++) + { + // if same detector check energy + + // cout << "inside loop" <<endl; + + if ( m_PreTreatedData->GetS2ThetaEDetectorNbr(i) == m_PreTreatedData->GetS2PhiEDetectorNbr(j) ) + { + if(Match_Theta_Phi_Position(m_PreTreatedData->GetS2ThetaEStripNbr(i), m_PreTreatedData->GetS2PhiEStripNbr(j))) + { + //cout << "new condition : same detector phi and theta " << endl; + + // Look if energy match + double ETheta = m_PreTreatedData->GetS2ThetaEEnergy(i) ; + double EPhi = m_PreTreatedData->GetS2PhiEEnergy(j) ; + double mean = ( ETheta + EPhi ) /2. ; + double distTheta = abs(ETheta-mean); + double distPhi = abs(EPhi-mean); + + // cout << ETheta << " " << EPhi << " " << mean << " " << distTheta << " " << distPhi << endl; + + // cout << m_StripEnergyMatchingNumberOfSigma << " " << m_StripEnergyMatchingSigma << endl; + // cout << m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma << endl; + + if( distTheta < m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma && distPhi< m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma ) + { + ArrayOfGoodCouple . push_back ( TVector2(i,j) ) ; + // cout << "same energy theta phi" << endl; + } + } + } + } + } + + // Prevent to treat event with ambiguous matching beetween Theta and Phi + if( ArrayOfGoodCouple.size() > m_PreTreatedData->GetS2ThetaEMult() ) + { + // cout << "clear event at the end"<< endl;; + ArrayOfGoodCouple.clear() ; + } + + return ArrayOfGoodCouple; +} + +bool TS2Physics::Match_Theta_Phi_Position(int theta, int phi) +{ + bool status = false; + + if(phi > 2 && phi < 7) + { + if(theta > 48 && theta < 65) status = true; + } + + else if(phi > 6 && phi < 11) + { + if(theta > 16 && theta < 33) status = true; + } + + else if(phi > 10 && phi < 15) + { + if(theta > 0 && theta < 16) status = true; + } + + else if((phi > 14 && phi < 17) || (phi > 0 && phi < 3)) + { + if(theta > 32 && theta < 49) status = true; + } + + // if(status == true) cout << theta << " " << phi << endl; + + return status; +} + +//////////////////////////////////////////////////////////////////////////// +bool TS2Physics :: IsValidChannel(string DetectorType, int telescope , int channel) +{ + vector<bool>::iterator it ; + if(DetectorType == "Theta") + return *(m_ThetaChannelStatus[telescope-1].begin()+channel-1); + + else if(DetectorType == "Phi") + return *(m_PhiChannelStatus[telescope-1].begin()+channel-1); + + else return false; +} + +/////////////////////////////////////////////////////////////////////////// +void TS2Physics::ReadAnalysisConfig() +{ + + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigS2.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigS2.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigS2.dat " << endl; + + // 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, 8, "ConfigS2") == 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.compare(0, 22, "MAX_STRIP_MULTIPLICITY") == 0) { + else if (whatToDo=="MAX_STRIP_MULTIPLICITY") { + AnalysisConfigFile >> DataBuffer; + m_MaximumStripMultiplicityAllowed = atoi(DataBuffer.c_str() ); + cout << "MAXIMUM STRIP MULTIPLICITY " << m_MaximumStripMultiplicityAllowed << endl; + } + + // else if (whatToDo.compare(0, 27, "STRIP_ENERGY_MATCHING_SIGMA") == 0) { + 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 telescope = atoi(DataBuffer.substr(1,1).c_str()); + vector< bool > ChannelStatus; + ChannelStatus.resize(64,false); + m_ThetaChannelStatus[telescope-1] = ChannelStatus; + ChannelStatus.resize(16,false); + m_PhiChannelStatus[telescope-1] = ChannelStatus; + } + + else if (whatToDo == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int telescope = atoi(DataBuffer.substr(1,1).c_str()); + int channel = -1; + if (DataBuffer.compare(2,5,"THETA") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + // cout << "disable channel theta " << telescope << " " << channel << endl; + *(m_ThetaChannelStatus[telescope-1].begin()+channel-1) = false; + } + + else if (DataBuffer.compare(2,3,"PHI") == 0) { + channel = atoi(DataBuffer.substr(5).c_str()); + //cout << "disable channel phi " << telescope << " " << channel << endl; + *(m_PhiChannelStatus[telescope-1].begin()+channel-1) = false; + } + + else cout << "Warning: detector type for S2 unknown!" << endl; + + } + + else if (whatToDo=="TAKE_E_Phi") { + m_Take_E_Phi = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_T_Phi") { + m_Take_T_Phi = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_E_Theta") { + m_Take_E_Phi = false; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_T_Theta") { + m_Take_T_Phi = false; + cout << whatToDo << endl; + } + + else if (whatToDo=="S2_Theta_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_S2_Theta_E_RAW_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Theta_E_RAW_Threshold << endl; + } + + else if (whatToDo=="S2_Phi_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_S2_Phi_E_RAW_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Phi_E_RAW_Threshold << endl; + } + + else if (whatToDo=="S2_Theta_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_S2_Theta_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Theta_E_Threshold << endl; + } + + else if (whatToDo== "S2_Phi_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_S2_Phi_E_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Phi_E_Threshold << endl; + } + + else if (whatToDo=="S2_Theta_E_THRESHOLD_SUP") { + AnalysisConfigFile >> DataBuffer; + m_S2_Theta_E_Threshold_sup = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Theta_E_Threshold_sup << endl; + } + + else if (whatToDo== "S2_Phi_E_THRESHOLD_SUP") { + AnalysisConfigFile >> DataBuffer; + m_S2_Phi_E_Threshold_sup = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Phi_E_Threshold_sup << endl; + } + + else if (whatToDo=="S2_Theta_T_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_S2_Theta_T_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Theta_T_Threshold << endl; + } + + else if (whatToDo== "S2_Phi_T_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_S2_Phi_T_Threshold = atoi(DataBuffer.c_str()); + cout << whatToDo << " " << m_S2_Phi_T_Threshold << endl; + } + + else { + ReadingStatus = false; + } + + } + } +} + + +/////////////////////////////////////////////////////////////////////////// +void TS2Physics::Clear() +{ + EventMultiplicity= 0 ; + + AnnularNumber .clear() ; + EventType .clear() ; + + // Si Theta + + Si_E.clear() ; + Si_T.clear() ; + Si_Theta.clear() ; + Si_Phi.clear() ; + + + Si_ETheta.clear() ; + Si_TTheta.clear() ; + Si_EPhi.clear() ; + Si_TPhi.clear() ; + + AnnularNumber_Theta.clear() ; + AnnularNumber_Phi.clear() ; + + /* + NTheta.clear() ; + StrTheta.clear() ; + ETheta.clear() ; + TTheta.clear() ; + + NPhi.clear() ; + StrPhi.clear() ; + EPhi.clear() ; + TPhi.clear() ; + */ +} +/////////////////////////////////////////////////////////////////////////// + +void TS2Physics::ReadCalibrationRun() +{ + // Theta + // E + + for(int i = 0 ; i < m_EventData->GetS2ThetaEMult();i++) + { + AnnularNumber_Theta.push_back(m_EventData->GetS2ThetaEDetectorNbr(i)); + Si_ETheta.push_back( fS2_Theta_E( m_EventData , i) ) ; + Si_Theta.push_back(m_EventData->GetS2ThetaEStripNbr(i)); + } + + // T + for(int i = 0 ; i < m_EventData->GetS2ThetaTMult();i++) + { + AnnularNumber_Theta.push_back(m_EventData->GetS2ThetaTDetectorNbr(i)); + Si_TTheta.push_back( fS2_Theta_T( m_EventData , i) ) ; + Si_Theta.push_back(m_EventData->GetS2ThetaTStripNbr(i)); + } + + // Phi + // E + for(int i = 0 ; i < m_EventData->GetS2PhiEMult();i++) + { + AnnularNumber_Phi.push_back(m_EventData->GetS2PhiEDetectorNbr(i)); + Si_EPhi.push_back( fS2_Phi_E( m_EventData , i) ) ; + Si_Phi.push_back(m_EventData->GetS2PhiEStripNbr(i)); + } + + // T + for(int i = 0 ; i < m_EventData->GetS2PhiTMult();i++) + { + AnnularNumber_Phi.push_back(m_EventData->GetS2PhiTDetectorNbr(i)); + Si_TPhi.push_back( fS2_Phi_T( m_EventData , i) ) ; + Si_Phi.push_back(m_EventData->GetS2PhiTStripNbr(i)); + } + +} + +//// Innherited from VDetector Class //// + +// Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token +void TS2Physics::ReadConfiguration(string Path) +{ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + // A:Theta1_Phi1 --> Theta:1 Phi:1 + // B:Theta128_Phi1 --> Theta:128 Phi:1 + // C:Theta1_Phi128 --> Theta:1 Phi:128 + // D:Theta128_Phi128 --> Theta:128 Phi:128 + + double Centerx, Centery, Centerz; + double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; + TVector3 A , B , C , D, Center ; + // double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; + + bool check_Center = false ; + bool check_A = false ; + bool check_C = false ; + bool check_B = false ; + bool check_D = false ; + + bool ReadingStatus = false ; + + + while (!ConfigFile.eof()) + { + + getline(ConfigFile, LineBuffer); + + // If line is a Start Up S2 bloc, Reading toggle to true + if (LineBuffer.compare(0, 11, "AnnularS2")==0) + { + cout << "///" << endl ; + cout << "Annular found: " << endl ; + ReadingStatus = true ; + + } + + // Else don't toggle to Reading Block Status + else ReadingStatus = false ; + + // Reading Block + while(ReadingStatus) + { + + ConfigFile >> DataBuffer ; + // Comment Line + if(DataBuffer.compare(0, 1, "%") == 0) { + ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); + + } + + // Finding another telescope (safety), toggle out + else if (DataBuffer=="AnnularS2") { + cout << "WARNING: Another Annular is find before standard sequence of Token, Error may occured in Telecope definition" << endl ; + ReadingStatus = false ; + } + + // Position method + else if (DataBuffer=="CalculatedCenter=") { + check_Center = true; + ConfigFile >> DataBuffer ; + Centerx = atof(DataBuffer.c_str()) ; + Centerx = Centerx ; + ConfigFile >> DataBuffer ; + Centery = atof(DataBuffer.c_str()) ; + Centery = Centery ; + ConfigFile >> DataBuffer ; + Centerz = atof(DataBuffer.c_str()) ; + Centerz = Centerz ; + + Center = TVector3(Centerx, Centery, Centerz); + cout << "Center position : (" << Center.X() << ";" << Center.Y() << ";" << Center.Z() << ")" << endl; + } + + else if (DataBuffer=="Phi2_Phi3=") { + check_A = true; + ConfigFile >> DataBuffer ; + Ax = atof(DataBuffer.c_str()) ; + Ax = Ax ; + ConfigFile >> DataBuffer ; + Ay = atof(DataBuffer.c_str()) ; + Ay = Ay ; + ConfigFile >> DataBuffer ; + Az = atof(DataBuffer.c_str()) ; + Az = Az ; + + A = TVector3(Ax, Ay, Az); + cout << "Phi2 Phi3 corner position : (" << A.X() << ";" << A.Y() << ";" << A.Z() << ")" << endl; + + } + + + else if (DataBuffer=="Phi6_Phi7=") { + check_B = true; + ConfigFile >> DataBuffer ; + Bx = atof(DataBuffer.c_str()) ; + Bx = Bx ; + ConfigFile >> DataBuffer ; + By = atof(DataBuffer.c_str()) ; + By = By ; + ConfigFile >> DataBuffer ; + Bz = atof(DataBuffer.c_str()) ; + Bz = Bz ; + + B = TVector3(Bx, By, Bz); + cout << "Phi6 Phi7 corner position : (" << B.X() << ";" << B.Y() << ";" << B.Z() << ")" << endl; + + } + + + else if (DataBuffer=="Phi10_Phi11=") { + check_C = true; + ConfigFile >> DataBuffer ; + Cx = atof(DataBuffer.c_str()) ; + Cx = Cx ; + ConfigFile >> DataBuffer ; + Cy = atof(DataBuffer.c_str()) ; + Cy = Cy ; + ConfigFile >> DataBuffer ; + Cz = atof(DataBuffer.c_str()) ; + Cz = Cz ; + + C = TVector3(Cx, Cy, Cz); + cout << "Phi10 Phi11 corner position : (" << C.X() << ";" << C.Y() << ";" << C.Z() << ")" << endl; + + } + + else if (DataBuffer=="Phi14_Phi15=") { + check_D = true; + ConfigFile >> DataBuffer ; + Dx = atof(DataBuffer.c_str()) ; + Dx = Dx ; + ConfigFile >> DataBuffer ; + Dy = atof(DataBuffer.c_str()) ; + Dy = Dy ; + ConfigFile >> DataBuffer ; + Dz = atof(DataBuffer.c_str()) ; + Dz = Dz ; + + D = TVector3(Dx, Dy, Dz); + cout << "Phi14 Phi15 corner position : (" << D.X() << ";" << D.Y() << ";" << D.Z() << ")" << endl; + + } + + // End Position Method + + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + if ( (check_Center && check_A && check_B && check_C && check_D)) // || (check_Theta && check_Phi && check_R && check_beta) ) + { + ReadingStatus = false; + + ///Add The previously define telescope + //With position method + if ( check_Center && check_A && check_B && check_C && check_D ) + { + AddAnnular(Center, + A , + B , + C , + D ) ; + } + + //with angle method + + check_Center = false ; + check_A = false ; + check_B = false ; + check_C = false ; + check_D = false ; + } + + } + } + InitializeStandardParameter(); + ReadAnalysisConfig(); + + cout << endl << "/////////////////////////////" << endl << endl; + +} + +// Add Parameter to the CalibrationManger +void TS2Physics::AddParameterToCalibrationManager() +{ + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < m_NumberOfAnnular ; i++) + { + + for( int j = 0 ; j < 64 ; j++) + { + Cal->AddParameter("S2", "T"+itoa(i+1)+"_Theta"+itoa(j+1)+"_E","S"+itoa(i+1)+"_THETA"+itoa(j+1)+"_E") ; + Cal->AddParameter("S2", "T"+itoa(i+1)+"_Theta"+itoa(j+1)+"_T","S"+itoa(i+1)+"_THETA"+itoa(j+1)+"_T") ; + } + + for( int j = 0 ; j < 16 ; j++) + { + Cal->AddParameter("S2", "T"+itoa(i+1)+"_Phi"+itoa(j+1)+"_E","S"+itoa(i+1)+"_PHI"+itoa(j+1)+"_E") ; + Cal->AddParameter("S2", "T"+itoa(i+1)+"_Phi"+itoa(j+1)+"_T","S"+itoa(i+1)+"_PHI"+itoa(j+1)+"_T") ; + } + } + + return; + +} + +// 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 TS2Physics::InitializeRootInput() +{ + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus( "S2_ANNULAR" , true ) ; + inputChain->SetBranchStatus( "fS2_*" , true ) ; + inputChain->SetBranchAddress( "S2_ANNULAR" , &m_EventData ) ; +} + + +// Create associated branches and associated private member DetectorPhysics address +void TS2Physics::InitializeRootOutput() +{ + TTree* outputTree = RootOutput::getInstance()->GetTree() ; + outputTree->Branch( "S2" , "TS2Physics" , &m_EventPhysics ) ; +} + + +///// Specific to S2Array //// + +void TS2Physics::AddAnnular(TVector3 C_Center , + TVector3 C_Phi2_Phi3 , + TVector3 C_Phi6_Phi7 , + TVector3 C_Phi10_Phi11 , + TVector3 C_Phi14_Phi15 ) +{ + + // To avoid warning + C_Phi2_Phi3 *= 1; + + m_NumberOfAnnular++; + + // Geometry Parameter + double rmin = 23.942; //with intern interstrip //23990; without // µm + double rmax = 48.038; //with inter interstrip //47990; without // µm + + // Theta & phi strips pitch + double thetaPitch = (rmax - rmin) / m_NumberOfStripsTheta * m_NumberOfQuadrants; + double phiPitch = 2*M_PI / m_NumberOfStripsPhi; + + // Vector U on Annular Face (theta) + TVector3 U = C_Phi2_Phi3 - C_Center ; + // double Ushift = (U.Mag() -98)/2. ; + U = U.Unit() ; + + // Vector V on Annular Face (radius) + TVector3 V = C_Phi6_Phi7 - C_Center ; + //double Vshift = (V.Mag()-98)/2. ; + V = V.Unit() ; + + // Coordinate system with ux vector on first quadrant + U.RotateZ(2*phiPitch); + V.RotateZ(2*phiPitch); + + + // Buffer object to fill Position Array + vector<double> lineX ; + vector<double> lineY ; + vector<double> lineZ ; + + + lineX.resize(64,-100); + lineY.resize(64,-100); + lineZ.resize(64,-100); + + + vector< vector< double > > OneAnnularStripPositionX ; + vector< vector< double > > OneAnnularStripPositionY ; + vector< vector< double > > OneAnnularStripPositionZ ; + + for (int i = 0; i < m_NumberOfStripsPhi; i++) + { + OneAnnularStripPositionX.push_back(lineX); + OneAnnularStripPositionY.push_back(lineY); + OneAnnularStripPositionZ.push_back(lineZ); + } + + //////////////////////////////////////////////////////////////////////////// + // Construct strip mapping + ////////////////////////////////////////////////////////////////////////// + + vector< vector<int> > Map; + vector<int> line; + line.resize(64,-1); + + for(int i = 0; i < m_NumberOfStripsPhi; i++) + { + Map.push_back(line); + } + + for(int i = 0; i < m_NumberOfStripsTheta; i++) + { + int Strip_Theta_Number = i+1; + + for(int j = 0; j < m_NumberOfStripsPhi; j++) + { + switch (j+1) + { + case 1 : + case 2 : + case 15: + case 16: if(Strip_Theta_Number <= 48 && Strip_Theta_Number > 32) Map[j][i] = 48 - Strip_Theta_Number ; + break; + + case 3 : + case 4 : + case 5 : + case 6 : if(Strip_Theta_Number <= 64 && Strip_Theta_Number > 48) Map[j][i] = 64 - Strip_Theta_Number ; + break; + + case 7 : + case 8 : + case 9 : + case 10: if(Strip_Theta_Number <= 32 && Strip_Theta_Number > 16) Map[j][i] = 32 - Strip_Theta_Number ; + break; + + case 11: + case 12: + case 13: + case 14: if( Strip_Theta_Number<= 16 && Strip_Theta_Number > 0) Map[j][i] = Strip_Theta_Number - 1 ; + break; + } + + // cout << j+1 << " " << i+1 << " " << Map[j][i] << endl; + } + } + + ////////////////////////////////////////////////////////////////////////// + + // loop on phi strips + for(int phinb = 0; phinb < m_NumberOfStripsPhi; phinb++) + { + double x = 0; + double y = 0; + // center of phi strips + double phi = phiPitch/2 + phiPitch*phinb ; + + for(int thetanb = 0; thetanb < m_NumberOfStripsTheta; thetanb++) + { + int localtheta = Map[phinb][thetanb]; + + if(localtheta != -1) + { + // cout << " cc " <<thetanb+1 << " " <<phinb+1 << " " << Map[phinb][thetanb] << endl; + TVector3 StripCenter = TVector3(0,0,0) ; + + double r = 0; + + r = rmax - thetaPitch/2 - thetaPitch*localtheta; + + // calculate x and y projections + x = r * cos(phi); + y = r * sin(phi); + + StripCenter = C_Center + ( x*U + y*V) ; + + lineX[thetanb] = StripCenter.X(); + lineY[thetanb] = StripCenter.Y(); + lineZ[thetanb] = StripCenter.Z(); + + } + } + + OneAnnularStripPositionX[phinb] = lineX ; + OneAnnularStripPositionY[phinb] = lineY ; + OneAnnularStripPositionZ[phinb] = lineZ ; + + } + + m_StripPositionX.push_back(OneAnnularStripPositionX ) ; + m_StripPositionY.push_back(OneAnnularStripPositionY ) ; + m_StripPositionZ.push_back(OneAnnularStripPositionZ ) ; + +} + + + +void TS2Physics::InitializeStandardParameter() +{ + // Enable all channel + vector< bool > ChannelStatus; + m_ThetaChannelStatus.clear() ; + m_PhiChannelStatus.clear() ; + + ChannelStatus.resize(64,true); + + for(int i = 0 ; i < m_NumberOfAnnular ; i ++) + { + m_ThetaChannelStatus[i] = ChannelStatus; + } + + ChannelStatus.resize(16,true); + for(int i = 0 ; i < m_NumberOfAnnular ; i ++) + { + m_PhiChannelStatus[i] = ChannelStatus; + } + + m_MaximumStripMultiplicityAllowed = m_NumberOfAnnular ; + + return; +} + +void TS2Physics::Dump_Positions() +{ + double x = 0; + double y = 0; + double z = 0; + + for(int k = 0; k < m_NumberOfAnnular; k++) + { + for(int i = 0 ; i < m_NumberOfStripsPhi; i++) + { + for(int j = 0; j < m_NumberOfStripsTheta; j++) + { + x = GetStripPositionX(k, i, j); + y = GetStripPositionY(k, i, j); + z = GetStripPositionZ(k, i, j); + + cout << k+1 << i+1 << " " << j+1 << " " << x << " " << y << " " << z << endl; + } + } + } + +} + +TVector3 TS2Physics::GetPositionOfInteraction(const int i) const +{ + /* + cout << endl; + cout << AnnularNumber[i] << " " << Si_Phi[i] << " " << Si_Theta[i] << endl; + cout << GetStripPositionX(AnnularNumber[i], Si_Phi[i] , Si_Theta[i] ) << " " << GetStripPositionY( AnnularNumber[i], Si_Phi[i] , Si_Theta[i] ) << " " << GetStripPositionZ( AnnularNumber[i], Si_Phi[i] , Si_Theta[i]) << endl; + */ + + TVector3 Position = TVector3 (GetStripPositionX( AnnularNumber[i], Si_Phi[i] , Si_Theta[i] ) , + GetStripPositionY( AnnularNumber[i], Si_Phi[i] , Si_Theta[i] ) , + GetStripPositionZ( AnnularNumber[i], Si_Phi[i] , Si_Theta[i] ) ) ; + + + return(Position) ; + +} + +TVector3 TS2Physics::GetAnnularNormal( const int i) const +{ + TVector3 U = TVector3 ( GetStripPositionX( AnnularNumber[i] , 4 , 64 ) , + GetStripPositionY( AnnularNumber[i] , 4 , 64 ) , + GetStripPositionZ( AnnularNumber[i] , 4 , 64 ) ) + + - TVector3 (GetStripPositionX( AnnularNumber[i] , 12 , 1 ) , + GetStripPositionY( AnnularNumber[i] , 12 , 1 ) , + GetStripPositionZ( AnnularNumber[i] , 12 , 1 ) ); + + TVector3 V = TVector3 (GetStripPositionX( AnnularNumber[i] , 8, 32 ) , + GetStripPositionY( AnnularNumber[i] , 8, 32 ) , + GetStripPositionZ( AnnularNumber[i] , 8, 32 ) ) + + - TVector3 (GetStripPositionX( AnnularNumber[i] , 16, 33) , + GetStripPositionY( AnnularNumber[i] , 16, 33) , + GetStripPositionZ( AnnularNumber[i] , 16, 33) ); + + TVector3 Normal = U.Cross(V); + + return(Normal.Unit()) ; + +} + +/////////////////////////////////////////////////////////////////////////// +namespace S2_LOCAL +{ + + // tranform an integer to a string + string itoa(int value) + { + std::ostringstream o; + + if (!(o << value)) + return "" ; + + return o.str(); + } + + // DSSD + // Theta + double fS2_Theta_E(TS2Data* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyCalibration( "S2/T" + itoa( m_EventData->GetS2ThetaEDetectorNbr(i) ) + "_Theta" + itoa( m_EventData->GetS2ThetaEStripNbr(i) ) + "_E", + m_EventData->GetS2ThetaEEnergy(i) ); + + } + + double fS2_Theta_T(TS2Data* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyCalibration( "S2/T" + itoa( m_EventData->GetS2ThetaTDetectorNbr(i) ) + "_Theta" + itoa( m_EventData->GetS2ThetaTStripNbr(i) ) +"_T", + m_EventData->GetS2ThetaTTime(i) ); + + } + + // Phi + double fS2_Phi_E(TS2Data* m_EventData , const int i) + { + + return CalibrationManager::getInstance()->ApplyCalibration( "S2/T" + itoa( m_EventData->GetS2PhiEDetectorNbr(i) ) + "_Phi" + itoa( m_EventData->GetS2PhiEStripNbr(i) ) +"_E", + m_EventData->GetS2PhiEEnergy(i) ); + + } + + double fS2_Phi_T(TS2Data* m_EventData , const int i) + { + return CalibrationManager::getInstance()->ApplyCalibration( "S2/T" + itoa( m_EventData->GetS2PhiTDetectorNbr(i) ) + "_Phi" + itoa( m_EventData->GetS2PhiTStripNbr(i) ) +"_T", + m_EventData->GetS2PhiTTime(i) ); + + } + + +} + diff --git a/NPLib/S2/TS2Physics.h b/NPLib/S2/TS2Physics.h new file mode 100644 index 0000000000000000000000000000000000000000..6a5b03ed06d24d5499b0b307162c349f5c0cb069 --- /dev/null +++ b/NPLib/S2/TS2Physics.h @@ -0,0 +1,248 @@ +#ifndef TS2PHYSICS_H +#define TS2PHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2010 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: Sandra GIRON contact address: giron@ipno.in2p3.fr * + * * + * Creation Date : april 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold annular S2 treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ +// STL +#include <vector> + +// NPL +#include "TS2Data.h" +#include "../include/CalibrationManager.h" +#include "../include/VDetector.h" +// ROOT +#include "TVector2.h" +#include "TVector3.h" +#include "TObject.h" + +using namespace std ; + +class TS2Physics : public TObject, public NPA::VDetector +{ + public: + TS2Physics() ; + ~TS2Physics() {}; + + public: + void Clear() ; + void Clear(const Option_t*) {}; + + public: + vector < TVector2 > Match_Theta_Phi() ; + // bool Match_Theta_Phi(int Theta, int Phi); + + int CheckEvent(); + bool ResolvePseudoEvent(); + + public: + + // Provide Physical Multiplicity + Int_t EventMultiplicity ; + + // Provide a Classification of Event + vector<int> EventType ; + + // Annular + vector<int> AnnularNumber ; + + + // Strips + + vector<double> Si_E ; + vector<double> Si_T ; + vector<int> Si_Theta ; + vector<int> Si_Phi ; + + vector<int> AnnularNumber_Theta ; //! + vector<int> AnnularNumber_Phi ; //! + + // Use for checking purpose + vector<double> Si_ETheta ; + vector<double> Si_TTheta ; + vector<double> Si_EPhi ; + vector<double> Si_TPhi ; + + /* + vector<int> NTheta ; //! + vector<int> StrTheta ; + vector<double> ETheta ; + vector<double> TTheta ; + + vector<int> NPhi ; //! + vector<int> StrPhi ; + vector<double> EPhi ; + vector<double> TPhi ; + */ + + 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 InitializeRootInput() ; + + + // 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() ; + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() { Clear(); } + void ClearEventData() {m_EventData->Clear();} + + + + public: // Specific to S2 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 + // First argument is either "THETA","PHI" + bool IsValidChannel(string DetectorType, int telescope , int channel); + + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of telescope (must2) + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + // Add a Annular using Corner Coordinate information + void AddAnnular(TVector3 C_Center , + TVector3 C_Phi2_Phi3 , + TVector3 C_Phi6_Phi7 , + TVector3 C_Phi10_Phi11 , + TVector3 C_Phi14_Phi15 ); + + // Use for reading Calibration Run, very simple methods; only apply calibration, no condition + void ReadCalibrationRun(); + + bool Match_Theta_Phi_Position(int theta, int phi); + + // Use to access the strip position + double GetStripPositionX( const int N, const int Phi , const int Theta ) const{ return m_StripPositionX[N-1][Phi-1][Theta-1] ; } ; + double GetStripPositionY( const int N, const int Phi , const int Theta ) const{ return m_StripPositionY[N-1][Phi-1][Theta-1] ; } ; + double GetStripPositionZ( const int N, const int Phi , const int Theta ) const{ return m_StripPositionZ[N-1][Phi-1][Theta-1] ; } ; + + double GetNumberOfAnnular() const { return m_NumberOfAnnular ; } ; + + // To be called after a build Physical Event + int GetEventMultiplicity() const { return EventMultiplicity; } ; + + void Dump_Positions(); + + TVector3 GetPositionOfInteraction(const int i) const ; + TVector3 GetAnnularNormal( const int i) const ; + + private: // Parameter used in the analysis + + // By default take ETheta and TPhi. + bool m_Take_E_Phi;//! + bool m_Take_T_Phi;//! + + + // Event over this value after pre-treatment are not treated / avoid long treatment time on spurious event + int m_MaximumStripMultiplicityAllowed ;//! + // Give the allowance in percent of the difference in energy between Theta and Phi + double m_StripEnergyMatchingSigma ; //! + double m_StripEnergyMatchingNumberOfSigma ; //! + + // Raw Threshold + int m_S2_Theta_E_RAW_Threshold ;//! + int m_S2_Phi_E_RAW_Threshold ;//! + + // Calibrated Threshold + double m_S2_Theta_T_Threshold; //! + double m_S2_Phi_T_Threshold; //! + double m_S2_Theta_E_Threshold ; //! + double m_S2_Phi_E_Threshold ; //! + double m_S2_Theta_E_Threshold_sup ;//! + double m_S2_Phi_E_Threshold_sup ; //! + + + private: // Root Input and Output tree classes + + TS2Data* m_EventData ;//! + TS2Data* m_PreTreatedData ;//! + TS2Physics* m_EventPhysics ;//! + + + private: // Map of activated channel + map< int, vector<bool> > m_ThetaChannelStatus;//! + map< int, vector<bool> > m_PhiChannelStatus;//! + + private: // Spatial Position of Strip Calculated on bases of detector position + + int m_NumberOfAnnular ;//! + + private: + ////////////////////////////// + // Geometry and strip number // + ////////////////////////////// + int m_NumberOfStripsTheta; //! + int m_NumberOfStripsPhi; //! + int m_NumberOfQuadrants; //! + + vector < vector < vector < double > > > m_StripPositionX ;//! + vector < vector < vector < double > > > m_StripPositionY ;//! + vector < vector < vector < double > > > m_StripPositionZ ;//! + + ClassDef(TS2Physics,1) // S2Physics structure + }; + +namespace S2_LOCAL +{ + + // tranform an integer to a string + string itoa(int value); + // DSSD + // X + double fS2_Theta_E(TS2Data* Data, const int i); + double fS2_Theta_T(TS2Data* Data, const int i); + + // Y + double fS2_Phi_E(TS2Data* Data, const int i); + double fS2_Phi_T(TS2Data* Data, const int i); + +} + + +#endif diff --git a/NPLib/Tiara/Makefile b/NPLib/Tiara/Makefile index 423704968c7276754b291fb92d66f38dc9ab3fd8..d17a4ea11322e4bd38dd7c475de959664b670988 100644 --- a/NPLib/Tiara/Makefile +++ b/NPLib/Tiara/Makefile @@ -9,19 +9,29 @@ all: $(SHARELIB) ############### Detector ############## ## Sharc ## -libTiara.so: TTiaraBarrelData.o TTiaraBarrelDataDict.o TTiaraHyballData.o TTiaraHyballDataDict.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) $@ TTiaraBarrelDataDict.cxx: TTiaraBarrelData.h rootcint -f $@ -c $^ +TTiaraBarrelPhysicsDict.cxx: TTiaraBarrelPhysics.h + rootcint -f $@ -c $^ + TTiaraHyballDataDict.cxx: TTiaraHyballData.h rootcint -f $@ -c $^ +TTiaraHyballPhysicsDict.cxx: TTiaraHyballPhysics.h + rootcint -f $@ -c $^ + # dependances -TTiaraBarrelData.o: TTiaraBarrelData.cxx TTiaraBarrelData.h -TTiaraHyballData.o: TTiaraHyballData.cxx TTiaraHyballData.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 ####################################### @@ -38,5 +48,3 @@ distclean: .$(SrcSuf).$(ObjSuf): $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< - - diff --git a/NPLib/Tiara/TTiaraBarrelData.cxx b/NPLib/Tiara/TTiaraBarrelData.cxx index 3ad018a41ef8a0eeacde59b3572b17f8e221bbb2..d1a71bf2bca68cb5585833130eeb05ca4d832379 100644 --- a/NPLib/Tiara/TTiaraBarrelData.cxx +++ b/NPLib/Tiara/TTiaraBarrelData.cxx @@ -32,25 +32,38 @@ ClassImp(TTiaraBarrelData) TTiaraBarrelData::TTiaraBarrelData(){ // Reserve the space for the full array - fTiaraBarrel_Front_Upstream_DetectorNbr.reserve(8*4); - fTiaraBarrel_Front_Upstream_StripNbr.reserve(8*4); - fTiaraBarrel_Front_Upstream_Energy.reserve(8*4); - fTiaraBarrel_Front_Upstream_Time.reserve(8*4); - - fTiaraBarrel_Front_Downstream_DetectorNbr.reserve(8*4); - fTiaraBarrel_Front_Downstream_StripNbr.reserve(8*4); - fTiaraBarrel_Front_Downstream_Energy.reserve(8*4); - fTiaraBarrel_Front_Downstream_Time.reserve(8*4); - - fTiaraBarrel_Back_DetectorNbr.reserve(8); - fTiaraBarrel_Back_Energy.reserve(8); - fTiaraBarrel_Back_Time.reserve(8); - - fTiaraBarrel_Outer_DetectorNbr.reserve(8*4); - fTiaraBarrel_Outer_StripNbr.reserve(8*4); - fTiaraBarrel_Outer_Energy.reserve(8*4); - fTiaraBarrel_Outer_Time.reserve(8*4); - } + fTiaraBarrel_FrontUpstreamE_DetectorNbr.reserve(8*4); + fTiaraBarrel_FrontUpstreamE_StripNbr.reserve(8*4); + fTiaraBarrel_FrontUpstreamE_Energy.reserve(8*4); + + fTiaraBarrel_FrontDownstreamE_DetectorNbr.reserve(8*4); + fTiaraBarrel_FrontDownstreamE_StripNbr.reserve(8*4); + fTiaraBarrel_FrontDownstreamE_Energy.reserve(8*4); + + fTiaraBarrel_BackE_DetectorNbr.reserve(8); + fTiaraBarrel_BackE_Energy.reserve(8); + + fTiaraBarrel_OuterE_DetectorNbr.reserve(8*4); + fTiaraBarrel_OuterE_StripNbr.reserve(8*4); + fTiaraBarrel_OuterE_Energy.reserve(8*4); + + fTiaraBarrel_FrontUpstreamT_DetectorNbr.reserve(8*4); + fTiaraBarrel_FrontUpstreamT_StripNbr.reserve(8*4); + fTiaraBarrel_FrontUpstreamT_Time.reserve(8*4); + + fTiaraBarrel_FrontDownstreamT_DetectorNbr.reserve(8*4); + fTiaraBarrel_FrontDownstreamT_StripNbr.reserve(8*4); + fTiaraBarrel_FrontDownstreamT_Time.reserve(8*4); + + fTiaraBarrel_BackT_DetectorNbr.reserve(8); + fTiaraBarrel_BackT_Time.reserve(8); + + fTiaraBarrel_OuterT_DetectorNbr.reserve(8*4); + fTiaraBarrel_OuterT_StripNbr.reserve(8*4); + fTiaraBarrel_OuterT_Time.reserve(8*4); + + +} ///////////////////////// TTiaraBarrelData::~TTiaraBarrelData(){ @@ -59,71 +72,110 @@ TTiaraBarrelData::~TTiaraBarrelData(){ ///////////////////////// void TTiaraBarrelData::Clear(){ - fTiaraBarrel_Front_Upstream_DetectorNbr.clear(); - fTiaraBarrel_Front_Upstream_StripNbr.clear(); - fTiaraBarrel_Front_Upstream_Energy.clear(); - fTiaraBarrel_Front_Upstream_Time.clear(); - - fTiaraBarrel_Front_Downstream_DetectorNbr.clear(); - fTiaraBarrel_Front_Downstream_StripNbr.clear(); - fTiaraBarrel_Front_Downstream_Energy.clear(); - fTiaraBarrel_Front_Downstream_Time.clear(); - - fTiaraBarrel_Back_DetectorNbr.clear(); - fTiaraBarrel_Back_Energy.clear(); - fTiaraBarrel_Back_Time.clear(); - - fTiaraBarrel_Outer_DetectorNbr.clear(); - fTiaraBarrel_Outer_StripNbr.clear(); - fTiaraBarrel_Outer_Energy.clear(); - fTiaraBarrel_Outer_Time.clear(); + fTiaraBarrel_FrontUpstreamE_DetectorNbr.clear(); + fTiaraBarrel_FrontUpstreamE_StripNbr.clear(); + fTiaraBarrel_FrontUpstreamE_Energy.clear(); + + fTiaraBarrel_FrontDownstreamE_DetectorNbr.clear(); + fTiaraBarrel_FrontDownstreamE_StripNbr.clear(); + fTiaraBarrel_FrontDownstreamE_Energy.clear(); + + fTiaraBarrel_BackE_DetectorNbr.clear(); + fTiaraBarrel_BackE_Energy.clear(); + + fTiaraBarrel_OuterE_DetectorNbr.clear(); + fTiaraBarrel_OuterE_StripNbr.clear(); + fTiaraBarrel_OuterE_Energy.clear(); + + fTiaraBarrel_FrontUpstreamT_DetectorNbr.clear(); + fTiaraBarrel_FrontUpstreamT_StripNbr.clear(); + fTiaraBarrel_FrontUpstreamT_Time.clear(); + + fTiaraBarrel_FrontDownstreamT_DetectorNbr.clear(); + fTiaraBarrel_FrontDownstreamT_StripNbr.clear(); + fTiaraBarrel_FrontDownstreamT_Time.clear(); + + fTiaraBarrel_BackT_DetectorNbr.clear(); + fTiaraBarrel_BackT_Time.clear(); + + fTiaraBarrel_OuterT_DetectorNbr.clear(); + fTiaraBarrel_OuterT_StripNbr.clear(); + fTiaraBarrel_OuterT_Time.clear(); + + + } ///////////////////////// void TTiaraBarrelData::Dump() const{ cout << "************* TTiaraBarrelData Event ************"<< endl; cout << "*** Inner Barrel Front Upstream ***" << endl ; - for( unsigned int i = 0; i < fTiaraBarrel_Front_Upstream_DetectorNbr.size(); i ++){ + for( unsigned int i = 0; i < fTiaraBarrel_FrontUpstreamE_DetectorNbr.size(); i ++){ cout << "Detector Number = " - << fTiaraBarrel_Front_Upstream_DetectorNbr[i] << endl ; + << fTiaraBarrel_FrontUpstreamE_DetectorNbr[i] << " | " ; cout << "Strip Number = " - << fTiaraBarrel_Front_Upstream_StripNbr[i] << endl; + << fTiaraBarrel_FrontUpstreamE_StripNbr[i] << " | "; cout << "Energy = " - << fTiaraBarrel_Front_Upstream_Energy[i]<< endl ; + << fTiaraBarrel_FrontUpstreamE_Energy[i]<< endl ; + } + + for( unsigned int i = 0; i < fTiaraBarrel_FrontUpstreamT_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fTiaraBarrel_FrontUpstreamT_DetectorNbr[i] << " | " ; + cout << "Strip Number = " + << fTiaraBarrel_FrontUpstreamT_StripNbr[i] << " | "; cout << "Time = " - << fTiaraBarrel_Front_Upstream_Time[i] << endl ; + << fTiaraBarrel_FrontUpstreamT_Time[i] << endl ; } cout << "*** Inner Barrel Front Downstream ***" << endl ; - for( unsigned int i = 0; i < fTiaraBarrel_Front_Downstream_DetectorNbr.size(); i ++){ + for( unsigned int i = 0; i < fTiaraBarrel_FrontDownstreamE_DetectorNbr.size(); i ++){ cout << "Detector Number = " - << fTiaraBarrel_Front_Downstream_DetectorNbr[i] << endl; + << fTiaraBarrel_FrontDownstreamE_DetectorNbr[i] << " | "; cout << "Strip Number = " - << fTiaraBarrel_Front_Downstream_StripNbr[i] << endl; + << fTiaraBarrel_FrontDownstreamE_StripNbr[i] << " | "; cout << "Energy = " - << fTiaraBarrel_Front_Downstream_Energy[i] << endl ; + << fTiaraBarrel_FrontDownstreamE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fTiaraBarrel_FrontDownstreamT_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fTiaraBarrel_FrontDownstreamT_DetectorNbr[i] << " | "; + cout << "Strip Number = " + << fTiaraBarrel_FrontDownstreamT_StripNbr[i] << " | "; cout << "Time = " - << fTiaraBarrel_Front_Downstream_Time[i] << endl ; + << fTiaraBarrel_FrontDownstreamT_Time[i] << endl ; } cout << "*** Inner Barrel Back ***" << endl ; - for( unsigned int i = 0; i < fTiaraBarrel_Back_DetectorNbr.size(); i ++){ + for( unsigned int i = 0; i < fTiaraBarrel_BackE_DetectorNbr.size(); i ++){ cout << "Detector Number = " - << fTiaraBarrel_Back_DetectorNbr[i] << endl; + << fTiaraBarrel_BackE_DetectorNbr[i] << " | "; cout << "Energy = " - << fTiaraBarrel_Back_Energy[i] << endl ; + << fTiaraBarrel_BackE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fTiaraBarrel_BackT_DetectorNbr.size(); i ++){ + cout << "Detector Number = " + << fTiaraBarrel_BackT_DetectorNbr[i] << " | "; cout << "Time = " - << fTiaraBarrel_Back_Time[i] << endl ; + << fTiaraBarrel_BackT_Time[i] << endl ; } + cout << "*** Outer Barrel ***" << endl; - for( unsigned int i = 0; i < fTiaraBarrel_Outer_DetectorNbr.size() ; i ++){ + for( unsigned int i = 0; i < fTiaraBarrel_OuterE_DetectorNbr.size() ; i ++){ cout << "Detector Number = " - << fTiaraBarrel_Outer_DetectorNbr[i] << endl; + << fTiaraBarrel_OuterE_DetectorNbr[i] << " | "; cout << "Energy = " - << fTiaraBarrel_Outer_Energy[i] << endl ; + << fTiaraBarrel_OuterE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fTiaraBarrel_OuterT_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fTiaraBarrel_OuterT_DetectorNbr[i] << " | "; cout << "Time = " - << fTiaraBarrel_Outer_Time[i] << endl ; + << fTiaraBarrel_OuterT_Time[i] << endl ; } } diff --git a/NPLib/Tiara/TTiaraBarrelData.h b/NPLib/Tiara/TTiaraBarrelData.h index 2667befb63ed52e28541ccdee803e0f20937c357..f2e5e0b1bfe353d184dc34634bcf5da9716deaed 100644 --- a/NPLib/Tiara/TTiaraBarrelData.h +++ b/NPLib/Tiara/TTiaraBarrelData.h @@ -34,24 +34,35 @@ using namespace std ; class TTiaraBarrelData : public TNamed { private: // Tiara - vector<unsigned short> fTiaraBarrel_Front_Upstream_DetectorNbr; - vector<unsigned short> fTiaraBarrel_Front_Upstream_StripNbr; - vector<double> fTiaraBarrel_Front_Upstream_Energy; - vector<double> fTiaraBarrel_Front_Upstream_Time; + vector<unsigned short> fTiaraBarrel_FrontUpstreamE_DetectorNbr; + vector<unsigned short> fTiaraBarrel_FrontUpstreamE_StripNbr; + vector<double> fTiaraBarrel_FrontUpstreamE_Energy; - vector<unsigned short> fTiaraBarrel_Front_Downstream_DetectorNbr; - vector<unsigned short> fTiaraBarrel_Front_Downstream_StripNbr; - vector<double> fTiaraBarrel_Front_Downstream_Energy; - vector<double> fTiaraBarrel_Front_Downstream_Time; + vector<unsigned short> fTiaraBarrel_FrontUpstreamT_DetectorNbr; + vector<unsigned short> fTiaraBarrel_FrontUpstreamT_StripNbr; + vector<double> fTiaraBarrel_FrontUpstreamT_Time; - vector<unsigned short> fTiaraBarrel_Back_DetectorNbr; - vector<double> fTiaraBarrel_Back_Energy; - vector<double> fTiaraBarrel_Back_Time; + vector<unsigned short> fTiaraBarrel_FrontDownstreamE_DetectorNbr; + vector<unsigned short> fTiaraBarrel_FrontDownstreamE_StripNbr; + vector<double> fTiaraBarrel_FrontDownstreamE_Energy; - vector<unsigned short> fTiaraBarrel_Outer_DetectorNbr; - vector<unsigned short> fTiaraBarrel_Outer_StripNbr; - vector<double> fTiaraBarrel_Outer_Energy; - vector<double> fTiaraBarrel_Outer_Time; + vector<unsigned short> fTiaraBarrel_FrontDownstreamT_DetectorNbr; + vector<unsigned short> fTiaraBarrel_FrontDownstreamT_StripNbr; + vector<double> fTiaraBarrel_FrontDownstreamT_Time; + + vector<unsigned short> fTiaraBarrel_BackE_DetectorNbr; + vector<double> fTiaraBarrel_BackE_Energy; + + vector<unsigned short> fTiaraBarrel_BackT_DetectorNbr; + vector<double> fTiaraBarrel_BackT_Time; + + vector<unsigned short> fTiaraBarrel_OuterE_DetectorNbr; + vector<unsigned short> fTiaraBarrel_OuterE_StripNbr; + vector<double> fTiaraBarrel_OuterE_Energy; + + vector<unsigned short> fTiaraBarrel_OuterT_DetectorNbr; + vector<unsigned short> fTiaraBarrel_OuterT_StripNbr; + vector<double> fTiaraBarrel_OuterT_Time; public: TTiaraBarrelData(); @@ -60,114 +71,223 @@ class TTiaraBarrelData : public TNamed { void Clear(); void Clear(const Option_t*) {}; void Dump() const; - ///////////////////// FAST SETTERS //////////////////////// - inline void Set_Front_Upstream(const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy , const double& Time){ - Set_Front_Upstream_DetectorNbr(DetNbr); - Set_Front_Upstream_StripNbr(StripNbr); - Set_Front_Upstream_Energy(Energy); - Set_Front_Upstream_Time(Time); + + ////////////////// MULTIPLICITY GETTER ///////////////////// + // E + inline unsigned int GetFrontUpstreamEMult(){ + return fTiaraBarrel_FrontUpstreamE_DetectorNbr.size(); + } + + // T + inline unsigned int GetFrontUpstreamTMult(){ + return fTiaraBarrel_FrontUpstreamT_DetectorNbr.size(); } + ///////////////////// - inline void Set_Front_Downstreamm( const unsigned short& DetNbr , const unsigned short& StripNbr , const double& Energy , const double& Time){ + // E + inline unsigned int GetFrontDownstreamEMult(){ + return fTiaraBarrel_FrontDownstreamE_DetectorNbr.size(); + } - Set_Front_Downstream_DetectorNbr(DetNbr); - Set_Front_Downstream_StripNbr(StripNbr); - Set_Front_Downstream_Energy(Energy); - Set_Front_Downstream_Time(Time); + // T + inline unsigned int GetFrontDownstreamTMult(){ + return fTiaraBarrel_FrontDownstreamT_DetectorNbr.size(); } ///////////////////// - inline void Set_Back( const unsigned short& DetNbr , const double& Energy , const double& Time){ + // E + inline unsigned int GetBackEMult(){ + return fTiaraBarrel_BackE_DetectorNbr.size(); + } + + // T + inline unsigned int GetFrontBackTMult(){ + return fTiaraBarrel_BackT_DetectorNbr.size(); + } + + ///////////////////// + // E + inline unsigned int GetOuterEMult(){ + return fTiaraBarrel_OuterE_DetectorNbr.size(); + } + + // T + inline unsigned int GetOuterTMult(){ + return fTiaraBarrel_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); + } - Set_Back_DetectorNbr(DetNbr); - Set_Back_Energy(Energy); - Set_Back_Time(Time); + // T + inline void SetBackT( const unsigned short& DetNbr , const double& Time){ + SetBackTDetectorNbr(DetNbr); + SetBackTTime(Time); } ///////////////////// - inline void Set_Outer( const unsigned short& DetNbr , const unsigned short StripNbr, const double& Energy , const double& Time){ - - Set_Outer_DetectorNbr(DetNbr); - Set_Outer_StripNbr(StripNbr); - Set_Outer_Energy(Energy); - Set_Outer_Time(Time); - } - - ///////////////////// SETTERS //////////////////////// - inline void Set_Front_Upstream_DetectorNbr(const unsigned short& Front_Upstream_DetectorNbr) - {fTiaraBarrel_Front_Upstream_DetectorNbr.push_back(Front_Upstream_DetectorNbr);} - inline unsigned short Get_Front_Upstream_DetectorNbr(const unsigned int& i) const - {return fTiaraBarrel_Front_Upstream_DetectorNbr[i];} - - inline void Set_Front_Upstream_StripNbr(const unsigned short& Front_Upstream_StripNbr) - {fTiaraBarrel_Front_Upstream_StripNbr.push_back(Front_Upstream_StripNbr);} - inline unsigned short Get_Front_Upstream_StripNbr(const unsigned int& i) const - {return fTiaraBarrel_Front_Upstream_StripNbr[i];} - - inline void Set_Front_Upstream_Energy(const double& Front_Upstream_Energy) - {fTiaraBarrel_Front_Upstream_Energy.push_back(Front_Upstream_Energy);} - inline double Get_Front_Upstream_Energy(const unsigned int& i) const - {return fTiaraBarrel_Front_Upstream_Energy[i];} - - inline void Set_Front_Upstream_Time(const double& Front_Upstream_Time) - {fTiaraBarrel_Front_Upstream_Time.push_back(Front_Upstream_Time);} - inline double Get_Front_Upstream_Time(const unsigned int& i) const - {return fTiaraBarrel_Front_Upstream_Time[i];} - - inline void Set_Front_Downstream_DetectorNbr(const unsigned short& Front_Downstream_DetectorNbr) - {fTiaraBarrel_Front_Downstream_DetectorNbr.push_back(Front_Downstream_DetectorNbr);} - inline unsigned short Get_Front_Downstream_DetectorNbr(const unsigned int& i) const - {return fTiaraBarrel_Front_Downstream_DetectorNbr[i];} - - inline void Set_Front_Downstream_StripNbr(const unsigned short& Front_Downstream_StripNbr) - {fTiaraBarrel_Front_Downstream_StripNbr.push_back(Front_Downstream_StripNbr);} - inline unsigned short Get_Front_Downstream_StripNbr(const unsigned int& i) const - {return fTiaraBarrel_Front_Downstream_StripNbr[i];} - - inline void Set_Front_Downstream_Energy(const double& Front_Downstream_Energy) - {fTiaraBarrel_Front_Downstream_Energy.push_back(Front_Downstream_Energy);} - inline double Get_Front_Downstream_Energy(const unsigned int& i) const - {return fTiaraBarrel_Front_Downstream_Energy[i];} - - inline void Set_Front_Downstream_Time(const double& Front_Downstream_Time) - {fTiaraBarrel_Front_Downstream_Time.push_back(Front_Downstream_Time);} - inline double Get_Front_Downstream_Time(const unsigned int& i) const - {return fTiaraBarrel_Front_Downstream_Time[i];} - - inline void Set_Back_DetectorNbr(const unsigned short& Back_DetectorNbr) - {fTiaraBarrel_Back_DetectorNbr.push_back(Back_DetectorNbr);} - inline unsigned short Get_Back_DetectorNbr(const unsigned int& i) const - {return fTiaraBarrel_Back_DetectorNbr[i];} - - inline void Set_Back_Energy(const double& Back_Energy) - {fTiaraBarrel_Back_Energy.push_back(Back_Energy);} - inline double Get_Back_Energy(const unsigned int& i) const - {return fTiaraBarrel_Back_Energy[i];} - - inline void Set_Back_Time(const double& Back_Time) - {fTiaraBarrel_Back_Time.push_back(Back_Time);} - inline double Get_Back_Time(const unsigned int& i) const - {return fTiaraBarrel_Back_Time[i];} - - inline void Set_Outer_DetectorNbr(const unsigned short& Outer_DetectorNbr) - {fTiaraBarrel_Outer_DetectorNbr.push_back(Outer_DetectorNbr);} - inline unsigned short Get_Outer_DetectorNbr(const unsigned int& i) const - {return fTiaraBarrel_Outer_DetectorNbr[i];} - - inline void Set_Outer_StripNbr(const unsigned short& Outer_StripNbr) - {fTiaraBarrel_Outer_StripNbr.push_back(Outer_StripNbr);} - inline unsigned short Get_Outer_StripNbr(const unsigned int& i) const - {return fTiaraBarrel_Outer_StripNbr[i];} - - inline void Set_Outer_Energy(const double& Outer_Energy) - {fTiaraBarrel_Outer_Energy.push_back(Outer_Energy);} - inline double Get_Outer_Energy(const unsigned int& i) const - {return fTiaraBarrel_Outer_Energy[i];} - - inline void Set_Outer_Time(const double& Outer_Time) - {fTiaraBarrel_Outer_Time.push_back(Outer_Time);} - inline double Get_Outer_Time(const unsigned int& i) const - {return fTiaraBarrel_Outer_Time[i];} + // 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) + {fTiaraBarrel_FrontUpstreamE_DetectorNbr.push_back(FrontUpstreamE_DetectorNbr);} + inline unsigned short GetFrontUpstreamEDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_FrontUpstreamE_DetectorNbr[i];} + + inline void SetFrontUpstreamEStripNbr(const unsigned short& FrontUpstreamE_StripNbr) + {fTiaraBarrel_FrontUpstreamE_StripNbr.push_back(FrontUpstreamE_StripNbr);} + inline unsigned short GetFrontUpstreamEStripNbr(const unsigned int& i) + {return fTiaraBarrel_FrontUpstreamE_StripNbr[i];} + + inline void SetFrontUpstreamEEnergy(const double& FrontUpstreamE_Energy) + {fTiaraBarrel_FrontUpstreamE_Energy.push_back(FrontUpstreamE_Energy);} + inline double GetFrontUpstreamEEnergy(const unsigned int& i) + {return fTiaraBarrel_FrontUpstreamE_Energy[i];} + + inline void SetFrontUpstreamTDetectorNbr(const unsigned short& FrontUpstreamT_DetectorNbr) + {fTiaraBarrel_FrontUpstreamT_DetectorNbr.push_back(FrontUpstreamT_DetectorNbr);} + inline unsigned short GetFrontUpstreamTDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_FrontUpstreamT_DetectorNbr[i];} + + inline void SetFrontUpstreamTStripNbr(const unsigned short& FrontUpstreamT_StripNbr) + {fTiaraBarrel_FrontUpstreamT_StripNbr.push_back(FrontUpstreamT_StripNbr);} + inline unsigned short GetFrontUpstreamTStripNbr(const unsigned int& i) + {return fTiaraBarrel_FrontUpstreamT_StripNbr[i];} + + inline void SetFrontUpstreamTTime(const double& FrontUpstreamT_Time) + {fTiaraBarrel_FrontUpstreamT_Time.push_back(FrontUpstreamT_Time);} + inline double GetFrontUpstreamTTime(const unsigned int& i) + {return fTiaraBarrel_FrontUpstreamT_Time[i];} + + inline void SetFrontDownstreamEDetectorNbr(const unsigned short& FrontDownstreamE_DetectorNbr) + {fTiaraBarrel_FrontDownstreamE_DetectorNbr.push_back(FrontDownstreamE_DetectorNbr);} + inline unsigned short GetFrontDownstreamEDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_FrontDownstreamE_DetectorNbr[i];} + + inline void SetFrontDownstreamEStripNbr(const unsigned short& FrontDownstreamE_StripNbr) + {fTiaraBarrel_FrontDownstreamE_StripNbr.push_back(FrontDownstreamE_StripNbr);} + inline unsigned short GetFrontDownstreamEStripNbr(const unsigned int& i) + {return fTiaraBarrel_FrontDownstreamE_StripNbr[i];} + + inline void SetFrontDownstreamEEnergy(const double& FrontDownstreamE_Energy) + {fTiaraBarrel_FrontDownstreamE_Energy.push_back(FrontDownstreamE_Energy);} + inline double GetFrontDownstreamEEnergy(const unsigned int& i) + {return fTiaraBarrel_FrontDownstreamE_Energy[i];} + + inline void SetFrontDownstreamTDetectorNbr(const unsigned short& FrontDownstreamT_DetectorNbr) + {fTiaraBarrel_FrontDownstreamT_DetectorNbr.push_back(FrontDownstreamT_DetectorNbr);} + inline unsigned short GetFrontDownstreamTDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_FrontDownstreamT_DetectorNbr[i];} + + inline void SetFrontDownstreamTStripNbr(const unsigned short& FrontDownstreamT_StripNbr) + {fTiaraBarrel_FrontDownstreamT_StripNbr.push_back(FrontDownstreamT_StripNbr);} + inline unsigned short GetFrontDownstreamTStripNbr(const unsigned int& i) + {return fTiaraBarrel_FrontDownstreamT_StripNbr[i];} + + inline void SetFrontDownstreamTTime(const double& FrontDownstreamT_Time) + {fTiaraBarrel_FrontDownstreamT_Time.push_back(FrontDownstreamT_Time);} + inline double GetFrontDownstreamTTime(const unsigned int& i) + {return fTiaraBarrel_FrontDownstreamT_Time[i];} + + inline void SetBackEDetectorNbr(const unsigned short& BackE_DetectorNbr) + {fTiaraBarrel_BackE_DetectorNbr.push_back(BackE_DetectorNbr);} + inline unsigned short GetBackEDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_BackE_DetectorNbr[i];} + + inline void SetBackEEnergy(const double& BackE_Energy) + {fTiaraBarrel_BackE_Energy.push_back(BackE_Energy);} + inline double GetBackEEnergy(const unsigned int& i) + {return fTiaraBarrel_BackE_Energy[i];} + + inline void SetBackTDetectorNbr(const unsigned short& BackT_DetectorNbr) + {fTiaraBarrel_BackT_DetectorNbr.push_back(BackT_DetectorNbr);} + inline unsigned short GetBackTDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_BackT_DetectorNbr[i];} + + inline void SetBackTTime(const double& BackT_Time) + {fTiaraBarrel_BackT_Time.push_back(BackT_Time);} + inline double GetBackTTime(const unsigned int& i) + {return fTiaraBarrel_BackT_Time[i];} + + inline void SetOuterEDetectorNbr(const unsigned short& OuterE_DetectorNbr) + {fTiaraBarrel_OuterE_DetectorNbr.push_back(OuterE_DetectorNbr);} + inline unsigned short GetOuterEDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_OuterE_DetectorNbr[i];} + + inline void SetOuterEStripNbr(const unsigned short& OuterE_StripNbr) + {fTiaraBarrel_OuterE_StripNbr.push_back(OuterE_StripNbr);} + inline unsigned short GetOuterEStripNbr(const unsigned int& i) + {return fTiaraBarrel_OuterE_StripNbr[i];} + + inline void SetOuterEEnergy(const double& OuterE_Energy) + {fTiaraBarrel_OuterE_Energy.push_back(OuterE_Energy);} + inline double GetOuterEEnergy(const unsigned int& i) + {return fTiaraBarrel_OuterE_Energy[i];} + + + inline void SetOuterTDetectorNbr(const unsigned short& OuterT_DetectorNbr) + {fTiaraBarrel_OuterT_DetectorNbr.push_back(OuterT_DetectorNbr);} + inline unsigned short GetOuterTDetectorNbr(const unsigned int& i) + {return fTiaraBarrel_OuterT_DetectorNbr[i];} + + inline void SetOuterTStripNbr(const unsigned short& OuterT_StripNbr) + {fTiaraBarrel_OuterT_StripNbr.push_back(OuterT_StripNbr);} + inline unsigned short GetOuterTStripNbr(const unsigned int& i) + {return fTiaraBarrel_OuterT_StripNbr[i];} + + inline void SetOuterTTime(const double& OuterT_Time) + {fTiaraBarrel_OuterT_Time.push_back(OuterT_Time);} + inline double GetOuterTTime(const unsigned int& i) + {return fTiaraBarrel_OuterT_Time[i];} + ClassDef(TTiaraBarrelData,1) // TiaraData structure }; diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.cxx b/NPLib/Tiara/TTiaraBarrelPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6a469dcc9ae35923efcdc4311f3e02d204acf1f1 --- /dev/null +++ b/NPLib/Tiara/TTiaraBarrelPhysics.cxx @@ -0,0 +1,651 @@ +/***************************************************************************** + * 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" + +// 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= true; + m_Take_T_Back=true; + m_Strip_E_RAW_Threshold=0 ; + m_Back_E_Threshold =0; + m_OuterStrip_E_RAW_Threshold =0; + m_OuterBack_E_Threshold =0; + } + +/////////////////////////////////////////////////////////////////////////// +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(); + + // Gain Calibration + // The cal function first call the MatchStick one + unsigned int sizeU = m_EventData-> GetFrontUpstreamEMult(); + unsigned int sizeD = m_EventData-> GetFrontDownstreamEMult(); + + for(unsigned int i = 0 ; i < sizeU ; i++){ + double EU = Cal_Strip_Upstream_E(i) ; + m_PreTreatedData->SetFrontUpstreamE(m_EventData-> GetFrontUpstreamEDetectorNbr(i), + m_EventData-> GetFrontUpstreamEStripNbr(i), + EU); + + for(unsigned int j = 0 ; j < sizeD ; j++){ + double ED = Cal_Strip_Downstream_E(j) ; + m_PreTreatedData->SetFrontDownstreamE(m_EventData-> GetFrontDownstreamEDetectorNbr(i), + m_EventData-> GetFrontDownstreamEStripNbr(i), + ED); + if(EU>0 && ED>0){ + if( m_EventData->GetFrontUpstreamEDetectorNbr(i) + == m_EventData->GetFrontDownstreamEDetectorNbr(j) + && m_EventData->GetFrontUpstreamEStripNbr(i) + == m_EventData->GetFrontDownstreamEStripNbr(j)){ + + Strip_E.push_back(EU+ED); + double POS = + CalibrationManager::getInstance()->ApplyResistivePositionCalibration("TIARABARREL/B"+itoa(m_EventData->GetFrontUpstreamEDetectorNbr(i))+"_STRIP"+itoa(m_EventData->GetFrontUpstreamEStripNbr(i))+"_POS",(ED-EU)/(EU+ED)); + Strip_Pos.push_back(POS); + Strip_N.push_back(m_EventData->GetFrontUpstreamEStripNbr(i)); + DetectorNumber.push_back(m_EventData->GetFrontUpstreamEDetectorNbr(i)); + } + } + } + } + + // 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(m_NumberOfDetector); +} + +/////////////////////////////////////////////////////////////////////////// +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(); + // E and T + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + for( int j = 0 ; j < 4 ; ++j){ + Cal->AddParameter("TIARABARREL","B"+itoa(i+1)+"_UPSTREAM"+itoa(j+1)+"_E","TIARABARREL_B"+itoa(i+1)+"_UPSTREAM"+itoa(j+1)+"_E") ; + Cal->AddParameter("TIARABARREL","B"+itoa(i+1)+"_DOWNSTREAM"+itoa(j+1)+"_E","TIARABARREL_B"+itoa(i+1)+"_DOWNSTREAM"+itoa(j+1)+"_E") ; + + Cal->AddParameter("TIARABARREL","MATCHSTICK_B"+itoa(i+1)+"_UPSTREAM"+itoa(j+1)+"_E","TIARABARREL_MATCHSTICK_B"+itoa(i+1)+"_UPSTREAM"+itoa(j+1)+"_E") ; + Cal->AddParameter("TIARABARREL","MATCHSTICK_B"+itoa(i+1)+"_DOWNSTREAM"+itoa(j+1)+"_E","TIARABARREL_MATCHSTICK_B"+itoa(i+1)+"_DOWNSTREAM"+itoa(j+1)+"_E") ; + + + Cal->AddParameter("TIARABARREL","B"+itoa(i+1)+"_STRIP"+itoa(j+1)+"_POS","TIARABARREL_B"+itoa(i+1)+"_STRIP"+itoa(j+1)+"_POS") ; + } + } + 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(TVector3(0,0,0)) ; + +} +/////////////////////////////////////////////////////////////////////////////// +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; +} + +/////////////////////////////////////////////////////////////////////////////// +// transform an integer to a string +string TTiaraBarrelPhysics::itoa(unsigned int value){ + char buffer [33]; + sprintf(buffer,"%d",value); + return buffer; +} +/////////////////////////////////////////////////////////////////////////////// +double TTiaraBarrelPhysics::Cal_Strip_Upstream_E(const int i){ + return CalibrationManager::getInstance()->ApplyCalibration("TIARABARREL/B" + itoa( m_EventData->GetFrontUpstreamEDetectorNbr(i) ) + "_UPSTREAM" + itoa( m_EventData->GetFrontUpstreamEStripNbr(i) ) + "_E", + Match_Strip_Upstream_E(i) ); +} +/////////////////////////////////////////////////////////////////////////////// +double TTiaraBarrelPhysics::Cal_Strip_Downstream_E(const int i){ + return CalibrationManager::getInstance()->ApplyCalibration("TIARABARREL/B" + itoa( m_EventData->GetFrontDownstreamEDetectorNbr(i) ) + "_DOWNSTREAM" + itoa( m_EventData->GetFrontDownstreamEStripNbr(i) ) + "_E", + Match_Strip_Downstream_E(i) ); +} +/////////////////////////////////////////////////////////////////////////////// +double TTiaraBarrelPhysics::Match_Strip_Upstream_E(const int i){ + return CalibrationManager::getInstance()->ApplyCalibration("TIARABARREL/MATCHSTICK_B" + itoa( m_EventData->GetFrontUpstreamEDetectorNbr(i) ) + "_UPSTREAM" + itoa( m_EventData->GetFrontUpstreamEStripNbr(i) ) + "_E", + m_EventData->GetFrontUpstreamEEnergy(i) ); +} +/////////////////////////////////////////////////////////////////////////////// +double TTiaraBarrelPhysics::Match_Strip_Downstream_E(const int i){ + return CalibrationManager::getInstance()->ApplyCalibration("TIARABARREL/MATCHSTICK_B" + itoa( m_EventData->GetFrontDownstreamEDetectorNbr(i) ) + "_DOWNSTREAM" + itoa( m_EventData->GetFrontDownstreamEStripNbr(i) ) + "_E", + m_EventData->GetFrontDownstreamEEnergy(i) ); +} diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.h b/NPLib/Tiara/TTiaraBarrelPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..c5ea79d6c61984f39129b35ec57c68bdde8f2b3a --- /dev/null +++ b/NPLib/Tiara/TTiaraBarrelPhysics.h @@ -0,0 +1,213 @@ +#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_Strip_E_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(); + + private: // Usefull method + // tranform an integer to a string + string itoa(unsigned int value); + // Calibrate data + double Cal_Strip_Upstream_E(const int i); + double Cal_Strip_Downstream_E(const int i); + double Match_Strip_Upstream_E(const int i); + double Match_Strip_Downstream_E(const int i); + + ClassDef(TTiaraBarrelPhysics,1) // SharcPhysics structure + +}; + +#endif diff --git a/NPLib/Tiara/TTiaraBarrelSpectra.cxx b/NPLib/Tiara/TTiaraBarrelSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d79aaf1a54d10c596cadbe5423833716fa1af96a --- /dev/null +++ b/NPLib/Tiara/TTiaraBarrelSpectra.cxx @@ -0,0 +1,338 @@ +/***************************************************************************** + * 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: A. MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for TiaraBarrel * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ + +// NPL +#include "TTiaraBarrelSpectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + + +// ROOT +#include "TString.h" +#include "TDirectory.h" +#include "TFile.h" + + +//////////////////////////////////////////////////////////////////////////////// +TTiaraBarrelSpectra::TTiaraBarrelSpectra(){ + fNumberOfDetector= 0; + fInnerBarrelStrip=4; + fOuterBarrelStrip=4; +} + +//////////////////////////////////////////////////////////////////////////////// +TTiaraBarrelSpectra::TTiaraBarrelSpectra(unsigned int NumberOfDetector){ + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TTiaraBarrelSpectra : Initalising control spectra for " + << NumberOfDetector << " Detectors" << endl + << "************************************************" << endl ; + + fNumberOfDetector= NumberOfDetector; + fInnerBarrelStrip=4; + fOuterBarrelStrip=4; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + +//////////////////////////////////////////////////////////////////////////////// +TTiaraBarrelSpectra::~TTiaraBarrelSpectra(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::InitRawSpectra(){ + TString name; + TString BaseFamily = "TIARA/BARREL/RAW/"; + + //// HIT //// + // Inner Barrel + // Hit Up Stream + name = "INNER_BARREL_US_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector*fInnerBarrelStrip, 1, fNumberOfDetector*fInnerBarrelStrip+1, BaseFamily+"HIT"); + //Hit Down Stream + name = "INNER_BARREL_DS_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector*fInnerBarrelStrip, 1, fNumberOfDetector*fInnerBarrelStrip+1, BaseFamily+"HIT"); + // Hit Back + name = "INNER_BARREL_BACK_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1, BaseFamily+"HIT"); + + // Outer Barrel + //Hit Strip + name = "OUTER_BARREL_STRIP_HIT_RAW"; + AddHisto1D(name, name, fNumberOfDetector*fOuterBarrelStrip, 1, fNumberOfDetector*fOuterBarrelStrip+1, BaseFamily+"HIT"); + + //// E //// + // Inner Barrel + // E Up Stream + name = "INNER_BARREL_US_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector*fInnerBarrelStrip, 1, fNumberOfDetector*fInnerBarrelStrip+1, 512,0,16384,BaseFamily+"E"); + //E Down Stream + name = "INNER_BARREL_DS_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector*fInnerBarrelStrip, 1, fNumberOfDetector*fInnerBarrelStrip+1,512,0,16384, BaseFamily+"E"); + //E Back + name = "INNER_BARREL_BACK_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1,512,0,16384, BaseFamily+"E"); + + // Outer Barrel + //E Strip + name = "OUTER_BARREL_STRIP_E_RAW"; + AddHisto2D(name, name, fNumberOfDetector*fOuterBarrelStrip, 1, fNumberOfDetector*fOuterBarrelStrip+1,512,0,16384, BaseFamily+"E"); + + //// VS //// + // Inner Barrel + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerBarrelStrip;j++){ + name = Form("IB%d_VS%d_RAW",i+1,j+1); + AddHisto2D(name, name,1024,0,16384,1024,0,16384,BaseFamily+"VS"); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::InitPreTreatedSpectra(){ + TString BaseFamily = "TIARA/BARREL/CAL/"; + TString name ; + //// VS //// + // Inner Barrel + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerBarrelStrip;j++){ + name = Form("IB%d_VS%d_CAL",i+1,j+1); + AddHisto2D(name,name,2048,-1,30,2048,-1,30,BaseFamily+"VS"); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::InitPhysicsSpectra(){ +string BaseFamily = "/TIARA/BARREL/PHY/"; +string name ; + //// E POS //// + // Inner Barrel + for(unsigned int i = 0 ; i < fNumberOfDetector ; i++){ + for(unsigned int j = 0 ; j < fInnerBarrelStrip;j++){ + name = Form("IB%d_EPOS%d_CAL",i+1,j+1); + AddHisto2D(name, name,100,-0.5,1.5,100,0,30,BaseFamily); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::FillRawSpectra(TTiaraBarrelData* RawData){ + TString name; + TString family; + TString BaseFamily = "TIARA/BARREL/RAW/"; + + // INNER_BARREL_US_HIT_RAW + for (unsigned int i = 0; i < RawData->GetFrontUpstreamEMult(); i++) { + name = "INNER_BARREL_US_HIT_RAW"; + family = BaseFamily+"HIT"; + + GetHisto(family,name) + ->Fill((RawData->GetFrontUpstreamEDetectorNbr(i)-1)*fInnerBarrelStrip + +RawData->GetFrontUpstreamEStripNbr(i)); + + family = BaseFamily+"E"; + name = "INNER_BARREL_US_E_RAW"; + GetHisto(family,name) + ->Fill((RawData->GetFrontUpstreamEDetectorNbr(i)-1)*fInnerBarrelStrip + +RawData->GetFrontUpstreamEStripNbr(i),RawData->GetFrontUpstreamEEnergy(i)); + } + // INNER_BARREL_DS_HIT_RAW + for (unsigned int i = 0; i < RawData->GetFrontDownstreamEMult(); i++) { + name = "INNER_BARREL_DS_HIT_RAW"; + family = BaseFamily+"HIT"; + + GetHisto(family,name) + ->Fill((RawData->GetFrontDownstreamEDetectorNbr(i)-1)*fInnerBarrelStrip + +RawData->GetFrontDownstreamEStripNbr(i)); + + name = "INNER_BARREL_DS_E_RAW"; + family = BaseFamily+"E"; + GetHisto(family,name) + ->Fill((RawData->GetFrontDownstreamEDetectorNbr(i)-1)*fInnerBarrelStrip + +RawData->GetFrontDownstreamEStripNbr(i),RawData->GetFrontDownstreamEEnergy(i)); + } + + // INNER_BARREL_BACK_HIT_RAW + for (unsigned int i = 0; i < RawData->GetBackEMult(); i++) { + name = "INNER_BARREL_BACK_HIT_RAW"; + family = BaseFamily+"HIT"; + + GetHisto(family,name) + ->Fill((RawData->GetBackEDetectorNbr(i)-1)); + + name = "INNER_BARREL_BACK_E_RAW"; + family = BaseFamily+"E"; + GetHisto(family,name) + ->Fill((RawData->GetBackEDetectorNbr(i)-1), RawData->GetBackEEnergy(i)); + } + + // OUTER_BARREL_STRIP_HIT_RAW + for (unsigned int i = 0; i < RawData->GetOuterEMult(); i++) { + name = "OUTER_BARREL_STRIP_HIT_RAW"; + family = BaseFamily+"HIT"; + + GetHisto(family,name) + ->Fill((RawData->GetOuterEDetectorNbr(i)-1)*fInnerBarrelStrip + +RawData->GetOuterEStripNbr(i)); + + family = BaseFamily+"E"; + name = "OUTER_BARREL_STRIP_E_RAW"; + GetHisto(family,name) + ->Fill((RawData->GetOuterEDetectorNbr(i)-1)*fInnerBarrelStrip + +RawData->GetOuterEStripNbr(i),RawData->GetOuterEEnergy(i)); + } + + // INNER_BARREL_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 = Form("IB%d_VS%d_RAW",UpStreamDetNbr,UpStreamStrNbr); + GetHisto(family,name) + ->Fill(RawData->GetFrontUpstreamEEnergy(i),RawData->GetFrontDownstreamEEnergy(j)); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::FillPreTreatedSpectra(TTiaraBarrelData* PreTreatedData){ +TString BaseFamily = "TIARA/BARREL/CAL/"; +// INNER_BARREL_VS_CAL + TString family = BaseFamily+"VS"; + TString name ; + for (unsigned int i = 0; i < PreTreatedData->GetFrontUpstreamEMult(); i++) { + int UpStreamDetNbr = PreTreatedData->GetFrontUpstreamEDetectorNbr(i); + int UpStreamStrNbr = PreTreatedData->GetFrontUpstreamEStripNbr(i); + + for (unsigned int j = 0; j < PreTreatedData->GetFrontDownstreamEMult(); j++) { + int DoStreamDetNbr = PreTreatedData->GetFrontDownstreamEDetectorNbr(j); + int DoStreamStrNbr = PreTreatedData->GetFrontDownstreamEStripNbr(j); + if(UpStreamDetNbr==DoStreamDetNbr && UpStreamStrNbr==DoStreamStrNbr){ + name = Form("IB%d_VS%d_CAL",UpStreamDetNbr,UpStreamStrNbr); + GetHisto(family,name) + ->Fill(PreTreatedData->GetFrontUpstreamEEnergy(i),PreTreatedData->GetFrontDownstreamEEnergy(j)); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::FillPhysicsSpectra(TTiaraBarrelPhysics* Physics){ +string family = "/TIARA/BARREL/PHY/"; +string name ; + //// E POS //// + // Inner Barrel + unsigned int size = Physics->Strip_E.size(); + for(unsigned int i = 0 ; i < Physics->Strip_E.size() ; i++){ + name = Form("IB%d_EPOS%d_CAL",Physics->DetectorNumber[i],Physics->Strip_N[i]); + GetHisto(family,name) + ->Fill(Physics->Strip_Pos[i],Physics->Strip_E[i]); + } +} + +//////////////////////////////////////////////////////////////////////////////// +TH1* TTiaraBarrelSpectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family){ + // create histo + TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup); + + vector<TString> index ; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index]=hist; + + return hist; +} + +//////////////////////////////////////////////////////////////////////////////// +TH1* TTiaraBarrelSpectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family){ + // create histo + TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + + vector<TString> index ; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index]=hist; + + return hist; +} + +//////////////////////////////////////////////////////////////////////////////// +TH1* TTiaraBarrelSpectra::GetHisto(TString family, TString name){ + vector<TString> index ; + index.push_back(family); + index.push_back(name); + // fill map + return fMapHisto.at(index); +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::WriteHisto(TString filename){ + TFile* f=NULL; + + if(filename!="VOID"){ + f = new TFile(filename,"RECREATE"); + } + + map< vector<TString>, TH1* >::iterator it; + + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){ + it->second->Write(); + } + + if(filename!="VOID"){ + f->Close(); + delete f; + } + +} +/////////////////////////////////////////////////////////////////////////////// +void TTiaraBarrelSpectra::CheckSpectra(){ + map< vector<TString>, TH1* >::iterator it; + Color_t ok_color = kTeal+9; + Color_t warning_color = kOrange+8; warning_color *= 1; + Color_t bad_color = kRed; bad_color *= 1; + + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){ + it->second->SetLineColor(ok_color); + it->second->SetFillStyle(1001); + it->second->SetFillColor(ok_color); + } + +} diff --git a/NPLib/Tiara/TTiaraBarrelSpectra.h b/NPLib/Tiara/TTiaraBarrelSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..8b15478f38f2317f230ded3aa22f0958c71eaa3e --- /dev/null +++ b/NPLib/Tiara/TTiaraBarrelSpectra.h @@ -0,0 +1,85 @@ +#ifndef TTIARABARRELSPECTRA_H +#define TTIARABARRELSPECTRA_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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : march 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for TiaraBarrel * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// C++ STL headers +#include <map> + +// ROOT headers +#include "TObject.h" +#include <TH1.h> +#include <TH2.h> +#include <TString.h> + +// NPLib headers +#include "TTiaraBarrelData.h" +#include "TTiaraBarrelPhysics.h" +using namespace std; + +// ForwardDeclaration +class TTiaraBarrelPhysics ; + +class TTiaraBarrelSpectra { + public: + // constructor and destructor + TTiaraBarrelSpectra(); + TTiaraBarrelSpectra(unsigned int NumberOfDetector); + ~TTiaraBarrelSpectra(); + + private: + // Instantiate and register histo to maps + TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family); + TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, + Int_t nbinsy, Double_t ylow, Double_t yup,TString family); + + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TTiaraBarrelData*); + void FillPreTreatedSpectra(TTiaraBarrelData*); + void FillPhysicsSpectra(TTiaraBarrelPhysics*); + // Check the Spectra + void CheckSpectra(); + + public: + // get map histo which will be used for GSpectra in GUser + map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;} + TH1* GetHisto(TString family,TString name); + void WriteHisto(TString filename="VOID"); + + private: // Information on TIARA/BARREL + unsigned int fNumberOfDetector; + unsigned int fInnerBarrelStrip; + unsigned int fOuterBarrelStrip; + + private: + // map holding histo pointers and their family names + map< vector<TString>, TH1* > fMapHisto; +}; + +#endif diff --git a/NPLib/Tiara/TTiaraHyballData.cxx b/NPLib/Tiara/TTiaraHyballData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..477afced0a5d4037eb037d50a48bbb17437fcdd6 --- /dev/null +++ b/NPLib/Tiara/TTiaraHyballData.cxx @@ -0,0 +1,121 @@ +/***************************************************************************** + * 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 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Tiara Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +#include "TTiaraHyballData.h" + +ClassImp(TTiaraHyballData) + ///////////////////////// + TTiaraHyballData::TTiaraHyballData(){ + + // Reserve the space for the full array + fTiaraHyball_RingE_DetectorNbr.reserve(6*32); + fTiaraHyball_RingE_StripNbr.reserve(6*32); + fTiaraHyball_RingE_Energy.reserve(6*32); + + fTiaraHyball_SectorE_DetectorNbr.reserve(6*24); + fTiaraHyball_SectorE_StripNbr.reserve(6*24); + fTiaraHyball_SectorE_Energy.reserve(6*24); + + fTiaraHyball_RingT_DetectorNbr.reserve(6*32); + fTiaraHyball_RingT_StripNbr.reserve(6*32); + fTiaraHyball_RingT_Time.reserve(6*32); + + fTiaraHyball_SectorT_DetectorNbr.reserve(6*24); + fTiaraHyball_SectorT_StripNbr.reserve(6*24); + fTiaraHyball_SectorT_Time.reserve(6*24); +} + +///////////////////////// +TTiaraHyballData::~TTiaraHyballData(){ + Clear(); +} + +///////////////////////// +void TTiaraHyballData::Clear(){ + fTiaraHyball_RingE_DetectorNbr.clear(); + fTiaraHyball_RingE_StripNbr.clear(); + fTiaraHyball_RingE_Energy.clear(); + + fTiaraHyball_SectorE_DetectorNbr.clear(); + fTiaraHyball_SectorE_StripNbr.clear(); + fTiaraHyball_SectorE_Energy.clear(); + + fTiaraHyball_RingT_DetectorNbr.clear(); + fTiaraHyball_RingT_StripNbr.clear(); + fTiaraHyball_RingT_Time.clear(); + + fTiaraHyball_SectorT_DetectorNbr.clear(); + fTiaraHyball_SectorT_StripNbr.clear(); + fTiaraHyball_SectorT_Time.clear(); +} + + +///////////////////////// +void TTiaraHyballData::Dump() const{ + cout << "************* TTiaraHyballData Event ************"<< endl; + cout << "*** Ring ***" << endl; + for( unsigned int i = 0; i < fTiaraHyball_RingE_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fTiaraHyball_RingE_DetectorNbr[i] << " | "; + cout << "RingE Number = " + << fTiaraHyball_RingE_StripNbr[i] << " | "; + cout << "Energy = " + << fTiaraHyball_RingE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fTiaraHyball_RingT_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fTiaraHyball_RingT_DetectorNbr[i] << " | "; + cout << "RingT Number = " + << fTiaraHyball_RingT_StripNbr[i] << " | "; + cout << "Time = " + << fTiaraHyball_RingT_Time[i] << endl ; + } + + + + cout << "*** Sector ***" << endl; + for( unsigned int i = 0; i < fTiaraHyball_SectorE_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fTiaraHyball_SectorE_DetectorNbr[i] << " | "; + cout << "SectorE Number = " + << fTiaraHyball_SectorE_StripNbr[i] << " | "; + cout << "Energy = " + << fTiaraHyball_SectorE_Energy[i] << endl ; + } + + for( unsigned int i = 0; i < fTiaraHyball_SectorT_DetectorNbr.size() ; i ++){ + cout << "Detector Number = " + << fTiaraHyball_SectorT_DetectorNbr[i] << " | "; + cout << "SectorT Number = " + << fTiaraHyball_SectorT_StripNbr[i] << " | "; + cout << "Time = " + << fTiaraHyball_SectorT_Time[i] << endl; + } + +} + diff --git a/NPLib/Tiara/TTiaraHyballData.h b/NPLib/Tiara/TTiaraHyballData.h index f886a5f3b7ab4d13213a8be1f11bd8428aebd8ae..7d0a4a307248ed28113ff31f288873c6d69504fe 100644 --- a/NPLib/Tiara/TTiaraHyballData.h +++ b/NPLib/Tiara/TTiaraHyballData.h @@ -32,87 +32,131 @@ using namespace std ; #include "TNamed.h" class TTiaraHyballData : public TNamed { - + public: TTiaraHyballData(); ~TTiaraHyballData(); - + public: void Clear(); void Clear(const Option_t*) {}; void Dump() const; private: - vector<unsigned short> fTiaraHyball_Ring_DetectorNbr; - vector<unsigned short> fTiaraHyball_Ring_StripNbr; - vector<double> fTiaraHyball_Ring_Energy; - vector<double> fTiaraHyball_Ring_Time; + vector<unsigned short> fTiaraHyball_RingE_DetectorNbr; + vector<unsigned short> fTiaraHyball_RingE_StripNbr; + vector<double> fTiaraHyball_RingE_Energy; + + vector<unsigned short> fTiaraHyball_RingT_DetectorNbr; + vector<unsigned short> fTiaraHyball_RingT_StripNbr; + vector<double> fTiaraHyball_RingT_Time; - vector<unsigned short> fTiaraHyball_Sector_DetectorNbr; - vector<unsigned short> fTiaraHyball_Sector_StripNbr; - vector<double> fTiaraHyball_Sector_Energy; - vector<double> fTiaraHyball_Sector_Time; + vector<unsigned short> fTiaraHyball_SectorE_DetectorNbr; + vector<unsigned short> fTiaraHyball_SectorE_StripNbr; + vector<double> fTiaraHyball_SectorE_Energy; + + vector<unsigned short> fTiaraHyball_SectorT_DetectorNbr; + vector<unsigned short> fTiaraHyball_SectorT_StripNbr; + vector<double> fTiaraHyball_SectorT_Time; + + ///////////// Multiplicity Getter //////////////////// + public: + inline unsigned int GetRingEMult() const {return fTiaraHyball_RingE_DetectorNbr.size();} + inline unsigned int GetRingTMult() const {return fTiaraHyball_RingT_DetectorNbr.size();} + inline unsigned int GetSectorEMult() const {return fTiaraHyball_SectorE_DetectorNbr.size();} + inline unsigned int GetSectorTMult() const {return fTiaraHyball_SectorT_DetectorNbr.size();} ///////////// Fast Setters //////////////////// public: - inline void Set_Ring(const unsigned short& DetNbr, const unsigned short& StripNbr, const double& Energy, const double& Time){ - Set_Ring_DetectorNbr(DetNbr); - Set_Ring_StripNbr(StripNbr); - Set_Ring_Energy(Energy); - Set_Ring_Time(Time); + inline void SetRingE(const unsigned short& DetNbr, const unsigned short& StripNbr, const double& Energy){ + SetRingEDetectorNbr(DetNbr); + SetRingEStripNbr(StripNbr); + SetRingEEnergy(Energy); }; - inline void Set_Sector(const unsigned short& DetNbr, const unsigned short& StripNbr, const double& Energy, const double& Time){ - Set_Sector_DetectorNbr(DetNbr); - Set_Sector_StripNbr(StripNbr); - Set_Sector_Energy(Energy); - Set_Sector_Time(Time); + inline void SetRingT(const unsigned short& DetNbr, const unsigned short& StripNbr,const double& Time){ + SetRingTDetectorNbr(DetNbr); + SetRingTStripNbr(StripNbr); + SetRingTTime(Time); }; + inline void SetSectorE(const unsigned short& DetNbr, const unsigned short& StripNbr, const double& Energy){ + SetSectorEDetectorNbr(DetNbr); + SetSectorEStripNbr(StripNbr); + SetSectorEEnergy(Energy); + }; + + inline void SetSectorT(const unsigned short& DetNbr, const unsigned short& StripNbr, const double& Time){ + SetSectorTDetectorNbr(DetNbr); + SetSectorTStripNbr(StripNbr); + SetSectorTTime(Time); + }; ///////////// Getter and Setter //////////////// public: - inline void Set_Ring_DetectorNbr(const unsigned short& Ring_DetectorNbr) - {fTiaraHyball_Ring_DetectorNbr.push_back(Ring_DetectorNbr);} - inline unsigned short Get_Ring_DetectorNbr(const unsigned int& i) const - {return fTiaraHyball_Ring_DetectorNbr[i];} - - inline void Set_Ring_StripNbr(const unsigned short& Ring_StripNbr) - {fTiaraHyball_Ring_StripNbr.push_back(Ring_StripNbr);} - inline unsigned short Get_Ring_StripNbr(const unsigned int& i) const - {return fTiaraHyball_Ring_StripNbr[i];} - - inline void Set_Ring_Energy(const double& Ring_Energy) - {fTiaraHyball_Ring_Energy.push_back(Ring_Energy);} - inline double Get_Ring_Energy(const unsigned int& i) const - {return fTiaraHyball_Ring_Energy[i];} - - inline void Set_Ring_Time(const double& Ring_Time) - {fTiaraHyball_Ring_Time.push_back(Ring_Time);} - inline double Get_Ring_Time(const unsigned int& i) const - {return fTiaraHyball_Ring_Time[i];} - - inline void Set_Sector_DetectorNbr(const unsigned short& Sector_DetectorNbr) - {fTiaraHyball_Sector_DetectorNbr.push_back(Sector_DetectorNbr);} - inline unsigned short Get_Sector_DetectorNbr(const unsigned int& i) const - {return fTiaraHyball_Sector_DetectorNbr[i];} - - inline void Set_Sector_StripNbr(const unsigned short& Sector_StripNbr) - {fTiaraHyball_Sector_StripNbr.push_back(Sector_StripNbr);} - inline unsigned short Get_Sector_StripNbr(const unsigned int& i) const - {return fTiaraHyball_Sector_StripNbr[i];} - - inline void Set_Sector_Energy(const double& Sector_Energy) - {fTiaraHyball_Sector_Energy.push_back(Sector_Energy);} - inline double Get_Sector_Energy(const unsigned int& i) const - {return fTiaraHyball_Sector_Energy[i];} - - inline void Set_Sector_Time(const double& Sector_Time) - {fTiaraHyball_Sector_Time.push_back(Sector_Time);} - inline double Get_Sector_Time(const unsigned int& i) const - {return fTiaraHyball_Sector_Time[i];} - - + inline void SetRingEDetectorNbr(const unsigned short& RingE_DetectorNbr) + {fTiaraHyball_RingE_DetectorNbr.push_back(RingE_DetectorNbr);} + inline unsigned short GetRingEDetectorNbr(const unsigned int& i) const + {return fTiaraHyball_RingE_DetectorNbr[i];} + + + inline void SetRingEStripNbr(const unsigned short& RingE_StripNbr) + {fTiaraHyball_RingE_StripNbr.push_back(RingE_StripNbr);} + inline unsigned short GetRingEStripNbr(const unsigned int& i) const + {return fTiaraHyball_RingE_StripNbr[i];} + + inline void SetRingEEnergy(const double& RingE_Energy) + {fTiaraHyball_RingE_Energy.push_back(RingE_Energy);} + inline double GetRingEEnergy(const unsigned int& i) const + {return fTiaraHyball_RingE_Energy[i];} + + inline void SetRingTDetectorNbr(const unsigned short& RingT_DetectorNbr) + {fTiaraHyball_RingT_DetectorNbr.push_back(RingT_DetectorNbr);} + inline unsigned short GetRingTDetectorNbr(const unsigned int& i) const + {return fTiaraHyball_RingT_DetectorNbr[i];} + + inline void SetRingTStripNbr(const unsigned short& RingT_StripNbr) + {fTiaraHyball_RingT_StripNbr.push_back(RingT_StripNbr);} + inline unsigned short GetRingTStripNbr(const unsigned int& i) const + {return fTiaraHyball_RingT_StripNbr[i];} + + inline void SetRingTTime(const double& RingT_Time) + {fTiaraHyball_RingT_Time.push_back(RingT_Time);} + inline double GetRingTTime(const unsigned int& i) const + {return fTiaraHyball_RingT_Time[i];} + + inline void SetSectorEDetectorNbr(const unsigned short& SectorE_DetectorNbr) + {fTiaraHyball_SectorE_DetectorNbr.push_back(SectorE_DetectorNbr);} + inline unsigned short GetSectorEDetectorNbr(const unsigned int& i) const + {return fTiaraHyball_SectorE_DetectorNbr[i];} + + inline void SetSectorEStripNbr(const unsigned short& SectorE_StripNbr) + {fTiaraHyball_SectorE_StripNbr.push_back(SectorE_StripNbr);} + inline unsigned short GetSectorEStripNbr(const unsigned int& i) const + {return fTiaraHyball_SectorE_StripNbr[i];} + + inline void SetSectorEEnergy(const double& SectorE_Energy) + {fTiaraHyball_SectorE_Energy.push_back(SectorE_Energy);} + inline double GetSectorEEnergy(const unsigned int& i) const + {return fTiaraHyball_SectorE_Energy[i];} + + inline void SetSectorTDetectorNbr(const unsigned short& SectorT_DetectorNbr) + {fTiaraHyball_SectorT_DetectorNbr.push_back(SectorT_DetectorNbr);} + inline unsigned short GetSectorTDetectorNbr(const unsigned int& i) const + {return fTiaraHyball_SectorT_DetectorNbr[i];} + + inline void SetSectorTStripNbr(const unsigned short& SectorT_StripNbr) + {fTiaraHyball_SectorT_StripNbr.push_back(SectorT_StripNbr);} + inline unsigned short GetSectorTStripNbr(const unsigned int& i) const + {return fTiaraHyball_SectorT_StripNbr[i];} + + inline void SetSectorTTime(const double& SectorT_Time) + {fTiaraHyball_SectorT_Time.push_back(SectorT_Time);} + inline double GetSectorTTime(const unsigned int& i) const + {return fTiaraHyball_SectorT_Time[i];} + + + ClassDef(TTiaraHyballData,1) // TiaraData structure }; #endif diff --git a/NPLib/Tiara/TTiaraHyballPhysics.cxx b/NPLib/Tiara/TTiaraHyballPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..42e165b9c62e431ff5265696964ba22cfe2b3b79 --- /dev/null +++ b/NPLib/Tiara/TTiaraHyballPhysics.cxx @@ -0,0 +1,696 @@ +/***************************************************************************** + * 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 TiaraHyball treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include "TTiaraHyballPhysics.h" +using namespace TiaraHyball_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(TTiaraHyballPhysics) + /////////////////////////////////////////////////////////////////////////// + TTiaraHyballPhysics::TTiaraHyballPhysics(){ + EventMultiplicity = 0 ; + m_EventData = new TTiaraHyballData ; + m_PreTreatedData = new TTiaraHyballData ; + m_EventPhysics = this ; + m_NumberOfDetector = 0 ; + m_MaximumStripMultiplicityAllowed = 10; + m_StripEnergyMatchingSigma = 0.060 ; + m_StripEnergyMatchingNumberOfSigma = 3; + + // Threshold + m_StripRing_E_RAW_Threshold = 0 ; + m_StripRing_E_Threshold = 0 ; + + m_StripSector_E_RAW_Threshold = 0 ; + m_StripSector_E_Threshold = 0 ; + + m_Take_E_Ring=false; + m_Take_T_Sector=true; + } + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::BuildSimplePhysicalEvent(){ + BuildPhysicalEvent(); +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::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 TTiaraHyballPhysics::PreTreat(){ + ClearPreTreatedData(); + + // Ring E + unsigned int sizeRingE = m_EventData->GetRingEMult(); + for(unsigned int i = 0 ; i < sizeRingE ; ++i){ + if( m_EventData->GetRingEEnergy(i)>m_StripRing_E_RAW_Threshold && IsValidChannel("Ring", m_EventData->GetRingEDetectorNbr(i), m_EventData->GetRingEStripNbr(i)) ){ + double Ring_E = fStrip_Ring_E(m_EventData , i); + if( Ring_E > m_StripRing_E_Threshold ){ + m_PreTreatedData->SetRingEDetectorNbr( m_EventData->GetRingEDetectorNbr(i) ); + m_PreTreatedData->SetRingEStripNbr( m_EventData->GetRingEStripNbr(i) ); + m_PreTreatedData->SetRingEEnergy( Ring_E ); + } + } + } + + // Ring T + unsigned int sizeRingT = m_EventData->GetRingTMult(); + for(unsigned int i = 0 ; i < sizeRingT ; ++i){ + if(IsValidChannel("Ring", m_EventData->GetRingTDetectorNbr(i), m_EventData->GetRingTStripNbr(i)) ){ + double Ring_T = fStrip_Ring_T(m_EventData , i); + m_PreTreatedData->SetRingTDetectorNbr( m_EventData->GetRingTDetectorNbr(i) ); + m_PreTreatedData->SetRingTStripNbr( m_EventData->GetRingTStripNbr(i) ); + m_PreTreatedData->SetRingTTime( Ring_T ); + } + } + + // Sector E + unsigned int sizeSectorE = m_EventData->GetSectorEMult() ; + for(unsigned int i = 0 ; i < sizeSectorE ; ++i){ + if( m_EventData->GetSectorEEnergy(i)>m_StripSector_E_RAW_Threshold && IsValidChannel("Sector", m_EventData->GetSectorEDetectorNbr(i), m_EventData->GetSectorEStripNbr(i)) ){ + double Sector_E = fStrip_Sector_E(m_EventData , i); + if( Sector_E > m_StripSector_E_Threshold ){ + m_PreTreatedData->SetSectorEDetectorNbr( m_EventData->GetSectorEDetectorNbr(i) ); + m_PreTreatedData->SetSectorEStripNbr( m_EventData->GetSectorEStripNbr(i) ); + m_PreTreatedData->SetSectorEEnergy( Sector_E ); + } + } + } + + // Sector T + unsigned int sizeSectorT = m_EventData->GetSectorTMult() ; + for(unsigned int i = 0 ; i < sizeSectorT ; ++i){ + if(IsValidChannel("Sector", m_EventData->GetSectorTDetectorNbr(i), m_EventData->GetSectorTStripNbr(i)) ){ + double Sector_T = fStrip_Sector_T(m_EventData , i); + m_PreTreatedData->SetSectorTDetectorNbr( m_EventData->GetSectorTDetectorNbr(i) ); + m_PreTreatedData->SetSectorTStripNbr( m_EventData->GetSectorTStripNbr(i) ); + m_PreTreatedData->SetSectorTTime( Sector_T ); + } + } + return; +} + + +/////////////////////////////////////////////////////////////////////////// +int TTiaraHyballPhysics :: CheckEvent(){ + // Check the size of the different elements + if(m_PreTreatedData->GetSectorEMult() == m_PreTreatedData->GetRingEMult() ) + return 1 ; // Regular Event + + else + return -1 ; // Rejected Event + +} + +/////////////////////////////////////////////////////////////////////////// +vector < TVector2 > TTiaraHyballPhysics :: Match_Ring_Sector(){ + 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 TTiaraHyballPhysics :: IsValidChannel(const string DetectorType, const int telescope , const int channel){ + + if(DetectorType == "Ring") + return *(m_RingChannelStatus[telescope-1].begin()+channel-1); + + else if(DetectorType == "Sector") + return *(m_SectorChannelStatus[telescope-1].begin()+channel-1); + + else return false; +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::ReadAnalysisConfig(){ + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigTiaraHyball.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigTiaraHyball.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigTiaraHyball.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigTiaraHyball.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, "ConfigTiaraHyball") == 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 TiaraHyball 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 TTiaraHyballPhysics::Clear(){ + EventMultiplicity = 0; + + // Provide a Classification of Event + EventType.clear() ; + + // Detector + DetectorNumber.clear() ; + + // DSSD + Strip_E.clear() ; + Strip_T.clear() ; + StripRing_E.clear() ; + StripRing_T.clear(); + StripSector_E.clear() ; + StripSector_T.clear() ; + Strip_Ring.clear() ; + Strip_Sector.clear() ; +} +/////////////////////////////////////////////////////////////////////////// + +//// Innherited from VDetector Class //// + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::ReadConfiguration(string Path){ + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + double R,Phi,Z; + R = 0 ; Phi = 0 ; Z = 0; + TVector3 Pos; + bool check_R = false ; + bool check_Phi = 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, "TiaraHyball") == 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' );} + + // Hyball case + if (DataBuffer=="TiaraHyballWedge"){ + if(VerboseLevel) cout << "///" << endl ; + if(VerboseLevel) cout << "Wedge found: " << endl ; + ReadingStatusWedge = true ; + } + + // Reading Block + while(ReadingStatusWedge){ + // Pickup Next Word + ConfigFile >> DataBuffer ; + + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + //Position method + else if (DataBuffer == "Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + Z= atof(DataBuffer.c_str()); + if(VerboseLevel) cout << " Z= " << Z << "mm" << endl; + } + + else if (DataBuffer == "R=") { + check_R = true; + ConfigFile >> DataBuffer ; + R= atof(DataBuffer.c_str()); + if(VerboseLevel) cout << " R= " << R << "mm" << endl; + } + + else if (DataBuffer == "Phi=") { + check_Phi = true; + ConfigFile >> DataBuffer ; + Phi= atof(DataBuffer.c_str()); + if(VerboseLevel) cout << " Phi= " << Phi << "deg" << endl; + } + + else if (DataBuffer == "ThicknessDector=") { + /*ignore that*/ + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else{ + ReadingStatusWedge = false; + cout << "Error: Wrong Token Sequence: Getting out " << DataBuffer << endl ; + exit(1); + } + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if (check_R && check_Phi && check_Z){ + + ReadingStatusWedge = false; + AddWedgeDetector(R,Phi,Z); + // Reinitialisation of Check Boolean + check_R = false ; + check_Phi = false ; + } + } + } + } + + InitializeStandardParameter(); + ReadAnalysisConfig(); +} +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::InitSpectra(){ + m_Spectra = new TTiaraHyballSpectra(); +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::FillSpectra(){ + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::CheckSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< vector<TString>,TH1* > TTiaraHyballPhysics::GetSpectra() { +return m_Spectra->GetMapHisto(); +} +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::AddParameterToCalibrationManager(){ + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + for( int j = 0 ; j < 24 ; ++j){ + Cal->AddParameter("TIARAHYBALL", "D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_E","TIARAHYBALL_D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_E") ; + Cal->AddParameter("TIARAHYBALL", "D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_T","TIARAHYBALL_D"+itoa(i+1)+"_STRIP_RING"+itoa(j+1)+"_T") ; + } + + for( int j = 0 ; j < 48 ; ++j){ + Cal->AddParameter("TIARAHYBALL", "D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_E","TIARAHYBALL_D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_E") ; + Cal->AddParameter("TIARAHYBALL", "D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_T","TIARAHYBALL_D"+itoa(i+1)+"_STRIP_SECTOR"+itoa(j+1)+"_T") ; + } + } + return; + +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::InitializeRootInputRaw(){ + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus( "TiaraHyball" , true ) ; + inputChain->SetBranchStatus( "fTiaraHyball_*" , true ) ; + inputChain->SetBranchAddress( "TiaraHyball" , &m_EventData ) ; +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::InitializeRootInputPhysics(){ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus( "EventMultiplicity" , true ); + inputChain->SetBranchStatus( "EventType" , true ); + inputChain->SetBranchStatus( "DetectorNumber" , true ); + inputChain->SetBranchStatus( "Strip_E" , true ); + inputChain->SetBranchStatus( "Strip_T" , true ); + inputChain->SetBranchStatus( "StripRing_E" , true ); + inputChain->SetBranchStatus( "StripSector_T" , true ); + inputChain->SetBranchStatus( "StripRing_E" , true ); + inputChain->SetBranchStatus( "StripSector_T" , true ); + inputChain->SetBranchStatus( "Strip_Ring" , true ); + inputChain->SetBranchStatus( "Strip_Sector" , true ); +} + +/////////////////////////////////////////////////////////////////////////// +void TTiaraHyballPhysics::InitializeRootOutput(){ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch( "TiaraHyball" , "TTiaraHyballPhysics" , &m_EventPhysics ); +} + +///// Specific to TiaraHyballArray //// +void TTiaraHyballPhysics::AddWedgeDetector( double R,double Phi,double Z){ + + double Wedge_R_Min = 32.6+R; + double Wedge_R_Max = 135.1+R; + double Wedge_Phi_Min = -27.2*deg/rad ; + double Wedge_Phi_Max = 27.2*deg/rad ; + Phi= Phi*deg/rad; + + int Wedge_Ring_NumberOfStrip = 16 ; + int Wedge_Sector_NumberOfStrip = 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 TTiaraHyballPhysics::GetDetectorNormal( const int i) const{ + + return (TVector3(0,0,i)); + +} + +TVector3 TTiaraHyballPhysics::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 TTiaraHyballPhysics::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 TiaraHyball_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 TTiaraHyballData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARAHYBALL/D" + itoa( m_EventData->GetRingEDetectorNbr(i) ) + "_STRIP_RING" + itoa( m_EventData->GetRingEStripNbr(i) ) + "_E", + m_EventData->GetRingEEnergy(i) ); + } + + double fStrip_Ring_T(const TTiaraHyballData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARAHYBALL/D" + itoa( m_EventData->GetRingTDetectorNbr(i) ) + "_STRIP_RING" + itoa( m_EventData->GetRingTStripNbr(i) ) +"_T", + m_EventData->GetRingTTime(i) ); + } + + // Sector + double fStrip_Sector_E(const TTiaraHyballData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARAHYBALL/D" + itoa( m_EventData->GetSectorTDetectorNbr(i) ) + "_STRIP_SECTOR" + itoa( m_EventData->GetSectorTStripNbr(i) ) +"_E", + m_EventData->GetSectorEEnergy(i) ); + } + + double fStrip_Sector_T(const TTiaraHyballData* m_EventData , const int i){ + return CalibrationManager::getInstance()->ApplyCalibration( "TIARAHYBALL/D" + itoa( m_EventData->GetSectorTDetectorNbr(i) ) + "_STRIP_SECTOR" + itoa( m_EventData->GetSectorTStripNbr(i) ) +"_T", + m_EventData->GetRingTTime(i) ); + } + +} + diff --git a/NPLib/Tiara/TTiaraHyballPhysics.h b/NPLib/Tiara/TTiaraHyballPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..7d79861eac74afca2bcd5296da9c06e5bc8eea3f --- /dev/null +++ b/NPLib/Tiara/TTiaraHyballPhysics.h @@ -0,0 +1,216 @@ +#ifndef TTIARAHYBALLPHYSICS_H +#define TTIARAHYBALLPHYSICS_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: matta@ipno.in2p3.fr * + * * + * Creation Date : November 2012 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TiaraHyball treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ +// STL +#include <vector> +#include <map> +// NPL +#include "TTiaraHyballData.h" +#include "TTiaraHyballSpectra.h" +#include "../include/CalibrationManager.h" +#include "../include/VDetector.h" + +// ROOT +#include "TVector2.h" +#include "TVector3.h" +#include "TObject.h" +#include "TH1.h" + +class TTiaraHyballSpectra; + +using namespace std ; + +class TTiaraHyballPhysics : public TObject, public NPA::VDetector{ + public: + TTiaraHyballPhysics(); + ~TTiaraHyballPhysics() {}; + + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: + vector < TVector2 > Match_Ring_Sector() ; + int CheckEvent(); + + public: + // Provide Physical Multiplicity + Int_t EventMultiplicity; + + // Provide a Classification of Event + vector<int> EventType ; + + // Detector + vector<int> DetectorNumber ; + + // DSSD + vector<double> Strip_E ; + vector<double> Strip_T ; + vector<double> StripRing_E ; + vector<double> StripRing_T ; + vector<double> StripSector_E ; + vector<double> StripSector_T ; + vector<int> Strip_Ring ; + vector<int> Strip_Sector ; + + 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 TiaraHyball 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 telescope , const int channel); + + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of telescope + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + // Add a Detector + void AddWedgeDetector( double R,double Phi,double Z); + + // Give and external TMustData object to TTiaraHyballPhysics. Needed for online analysis for example. + void SetRawDataPointer(TTiaraHyballData* rawDataPointer) {m_EventData = rawDataPointer;} + // Retrieve raw and pre-treated data + TTiaraHyballData* GetRawData() const {return m_EventData;} + TTiaraHyballData* GetPreTreatedData() const {return m_PreTreatedData;} + + // Use to access the strip position + double GetStripPositionX( const int N , const int Ring , const int Sector ) const{ return m_StripPositionX[N-1][Ring-1][Sector-1] ; } ; + double GetStripPositionY( const int N , const int Ring , const int Sector ) const{ return m_StripPositionY[N-1][Ring-1][Sector-1] ; } ; + double GetStripPositionZ( const int N , const int Ring , const int Sector ) const{ return m_StripPositionZ[N-1][Ring-1][Sector-1] ; } ; + + 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_Ring;//! + bool m_Take_T_Sector;//! + + // Event over this value after pre-treatment are not treated / avoid long treatment time on spurious event + unsigned int m_MaximumStripMultiplicityAllowed ;//! + // Give the allowance in percent of the difference in energy between X and Y + double m_StripEnergyMatchingSigma ; //! + double m_StripEnergyMatchingNumberOfSigma ; //! + + // Threshold + double m_StripRing_E_RAW_Threshold ;//! + double m_StripRing_E_Threshold ;//! + double m_StripSector_E_RAW_Threshold ;//! + double m_StripSector_E_Threshold ;//! + + private: // Root Input and Output tree classes + TTiaraHyballData* m_EventData;//! + TTiaraHyballData* m_PreTreatedData;//! + TTiaraHyballPhysics* m_EventPhysics;//! + + private: // Map of activated channel + map< int, vector<bool> > m_RingChannelStatus;//! + map< int, vector<bool> > m_SectorChannelStatus;//! + + private: // Spatial Position of Strip Calculated on bases of detector position + int m_NumberOfDetector;//! + vector< vector < vector < double > > > m_StripPositionX;//! + vector< vector < vector < double > > > m_StripPositionY;//! + vector< vector < vector < double > > > m_StripPositionZ;//! + + private: // Spectra + TTiaraHyballSpectra* m_Spectra;//! + + public: + map< vector<TString>,TH1* > GetSpectra(); + + ClassDef(TTiaraHyballPhysics,1) // SharcPhysics structure +}; + +namespace TiaraHyball_LOCAL{ + // tranform an integer to a string + string itoa(unsigned int value); + // DSSD + // Ring + double fStrip_Ring_E(const TTiaraHyballData* Data, const int i); + double fStrip_Ring_T(const TTiaraHyballData* Data, const int i); + + // Sector + double fStrip_Sector_E(const TTiaraHyballData* Data, const int i); + double fStrip_Sector_T(const TTiaraHyballData* Data, const int i); +} + +#endif diff --git a/NPLib/Tiara/TTiaraHyballSpectra.cxx b/NPLib/Tiara/TTiaraHyballSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..69b0c3b0b1420842966d0edefe1c2cfcee6a7bb3 --- /dev/null +++ b/NPLib/Tiara/TTiaraHyballSpectra.cxx @@ -0,0 +1,355 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Tiara/Hyball * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// NPL +#include "TTiaraHyballSpectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + +// ROOT +#include "TString.h" +#include "TDirectory.h" +#include "TFile.h" + +//////////////////////////////////////////////////////////////////////////////// +TTiaraHyballSpectra::TTiaraHyballSpectra(){ + if (NPOptionManager::getInstance()->GetVerboseLevel() > 0) { + cout << "************************************************" << endl; + cout << "TTiaraHyballSpectra: Initalising control spectra" << endl; + cout << "************************************************" << endl; + } + + fRingsNumber = 16; + fSectorsNumber = 8; + fWedgesNumber = 6; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TTiaraHyballSpectra::~TTiaraHyballSpectra(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::InitRawSpectra(){ + TString name; + + // HIT_RING_RAW + name = "HYB_HIT_RING_RAW"; + AddHisto1D(name, name, fWedgesNumber*fRingsNumber, 1, fWedgesNumber*fRingsNumber+1, "TIARA/HYBALL/RAW/HIT"); + + // HIT_SECTOR_RAW + name = "HYB_HIT_SECT_RAW"; + AddHisto1D(name, name, fWedgesNumber*fSectorsNumber, 1, fWedgesNumber*fSectorsNumber+1, "TIARA/HYBALL/RAW/HIT"); + + // RING_E_RAW + name = "HYB_RING_E_RAW"; + AddHisto2D(name, name, fWedgesNumber*fRingsNumber, 1, fWedgesNumber*fRingsNumber+1, 512, 0, 16384, "TIARA/HYBALL/RAW/ENERGY"); + + // SECTOR_E_RAW + name = "HYB_SECT_E_RAW"; + AddHisto2D(name, name, fWedgesNumber*fSectorsNumber, 1, fWedgesNumber*fSectorsNumber+1, 512, 0, 16384, "TIARA/HYBALL/RAW/ENERGY"); + + // MULT + for (unsigned int i = 0; i < fWedgesNumber; ++i) { // loop on number of wedges + // RING_RAW_MULT + name = Form("HYB_W%d_RING_E_RAW_MULT", i+1); + AddHisto1D(name, name, fRingsNumber, 1, fRingsNumber+1, "TIARA/HYBALL/RAW/MULT"); + + // SECTOR_RAW_MULT + name = Form("HYB_W%d_SECT_E_RAW_MULT", i+1); + AddHisto1D(name, name, fSectorsNumber, 1, fSectorsNumber+1, "TIARA/HYBALL/RAW/MULT"); + } // end loop on number of wedges +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::InitPreTreatedSpectra(){ + TString name; + + // HIT_RING_CAL + name = "HYB_HIT_RING_CAL"; + AddHisto1D(name, name, fWedgesNumber*fRingsNumber, 1, fWedgesNumber*fRingsNumber+1, "TIARA/HYBALL/CAL/HIT"); + + // HIT_SECTOR_CAL + name = "HYB_HIT_SECT_CAL"; + AddHisto1D(name, name, fWedgesNumber*fSectorsNumber, 1, fWedgesNumber*fSectorsNumber+1, "TIARA/HYBALL/CAL/HIT"); + + // RING_E_CAL + name = "HYB_RING_E_CAL"; + AddHisto2D(name, name, fWedgesNumber*fRingsNumber, 1, fWedgesNumber*fRingsNumber+1, 500, 0, 50, "TIARA/HYBALL/CAL/ENERGY"); + + // SECTOR_E_CAL + name = "HYB_SECT_E_CAL"; + AddHisto2D(name, name, fWedgesNumber*fSectorsNumber, 1, fWedgesNumber*fSectorsNumber+1, 500, 0, 50, "TIARA/HYBALL/CAL/ENERGY"); + + // MULT + for (unsigned int i = 0; i < fWedgesNumber; ++i) { // loop on number of wedges + // RING_CAL_MULT + name = Form("HYB_W%d_RING_E_CAL_MULT", i+1); + AddHisto1D(name, name, fRingsNumber, 1, fRingsNumber+1, "TIARA/HYBALL/CAL/MULT"); + + // SECTOR_CAL_MULT + name = Form("HYB_W%d_SECT_E_CAL_MULT", i+1); + AddHisto1D(name, name, fSectorsNumber, 1, fSectorsNumber+1, "TIARA/HYBALL/CAL/MULT"); + } // end loop on number of wedges +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::InitPhysicsSpectra(){ + TString name; + // X-Y Impact Matrix + name = "HYB_IMPACT_MATRIX"; + AddHisto2D(name, name, 500, -150, 150, 500, -150, 150, "TIARA/HYBALL/PHY"); + + // Kinematic line + name = "HYB_THETA_E"; + AddHisto2D(name, name, 360, 0, 180, 500, 0, 50, "TIARA/HYBALL/PHY"); + + // Ring v.s. Sector Energy Correlation + name = "HYB_XY_COR"; + AddHisto2D(name, name, 500, 0, 50, 500, 0, 50, "TIARA/HYBALL/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::FillRawSpectra(TTiaraHyballData* RawData){ + TString name; + TString family; + + // HIT_RING_RAW + family = "TIARA/HYBALL/RAW/HIT"; + name = "HYB_HIT_RING_RAW"; + for (unsigned int i = 0; i < RawData->GetRingEMult(); i++) { + unsigned short channel = (RawData->GetRingEDetectorNbr(i)-1) * fRingsNumber + RawData->GetRingEStripNbr(i); + GetHisto(family, name) -> Fill(channel); + } + + // HIT_SECT_RAW + family = "TIARA/HYBALL/RAW/HIT"; + name = "HYB_HIT_SECT_RAW"; + for (unsigned int i = 0; i < RawData->GetSectorEMult(); i++) { + unsigned short channel = (RawData->GetSectorEDetectorNbr(i)-1) * fSectorsNumber + RawData->GetSectorEStripNbr(i); + GetHisto(family, name) -> Fill(channel); + } + + // RING_E_RAW + family = "TIARA/HYBALL/RAW/ENERGY"; + name = "HYB_RING_E_RAW"; + for (unsigned int i = 0; i < RawData->GetRingEMult(); i++) { + unsigned short channel = (RawData->GetRingEDetectorNbr(i)-1) * fRingsNumber + RawData->GetRingEStripNbr(i); + GetHisto(family, name) -> Fill(channel, RawData->GetRingEEnergy(i)); + } + + // SECTOR_E_RAW + family = "TIARA/HYBALL/RAW/ENERGY"; + name = "HYB_SECT_E_RAW"; + for (unsigned int i = 0; i < RawData->GetSectorEMult(); i++) { + unsigned short channel = (RawData->GetSectorEDetectorNbr(i)-1) * fSectorsNumber + RawData->GetSectorEStripNbr(i); + GetHisto(family, name) -> Fill(channel, RawData->GetSectorEEnergy(i)); + } + + // RING_RAW_MULT + int myMULT[fWedgesNumber]; + for (unsigned int i = 0; i < fWedgesNumber; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < RawData->GetRingEMult(); i++) myMULT[(RawData->GetRingEDetectorNbr(i)-1)] += 1; + + for (unsigned int i = 0; i < fWedgesNumber; i++) { + name = Form("HYB_W%d_RING_E_RAW_MULT", i+1); + family = "TIARA/HYBALL/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // Sector_RAW_MULT + for (unsigned int i = 0; i < fWedgesNumber; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < RawData->GetSectorEMult(); i++) myMULT[(RawData->GetSectorEDetectorNbr(i)-1)] += 1; + + for (unsigned int i = 0; i < fWedgesNumber; i++) { + name = Form("HYB_W%d_SECT_E_RAW_MULT", i+1); + family = "TIARA/HYBALL/RAW/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::FillPreTreatedSpectra(TTiaraHyballData* PreTreatedData){ + TString name; + TString family; + + // HIT_RING_CAL + family = "TIARA/HYBALL/CAL/HIT"; + name = "HYB_HIT_RING_CAL"; + for (unsigned int i = 0; i < PreTreatedData->GetRingEMult(); i++) { + unsigned short channel = (PreTreatedData->GetRingEDetectorNbr(i)-1) * fRingsNumber + PreTreatedData->GetRingEStripNbr(i); + GetHisto(family, name) -> Fill(channel); + } + + // HIT_SECT_CAL + family = "TIARA/HYBALL/CAL/HIT"; + name = "HYB_HIT_SECT_CAL"; + for (unsigned int i = 0; i < PreTreatedData->GetSectorEMult(); i++) { + unsigned short channel = (PreTreatedData->GetSectorEDetectorNbr(i)-1) * fSectorsNumber + PreTreatedData->GetSectorEStripNbr(i); + GetHisto(family, name) -> Fill(channel); + } + + // RING_E_CAL + family = "TIARA/HYBALL/CAL/ENERGY"; + name = "HYB_RING_E_CAL"; + for (unsigned int i = 0; i < PreTreatedData->GetRingEMult(); i++) { + unsigned short channel = (PreTreatedData->GetRingEDetectorNbr(i)-1) * fRingsNumber + PreTreatedData->GetRingEStripNbr(i); + GetHisto(family, name) -> Fill(channel, PreTreatedData->GetRingEEnergy(i)); + } + + // SECTOR_E_CAL + family = "TIARA/HYBALL/CAL/ENERGY"; + name = "HYB_SECT_E_CAL"; + for (unsigned int i = 0; i < PreTreatedData->GetRingEMult(); i++) { + unsigned short channel = (PreTreatedData->GetRingEDetectorNbr(i)-1) * fSectorsNumber + PreTreatedData->GetSectorEStripNbr(i); + GetHisto(family, name) -> Fill(channel, PreTreatedData->GetRingEEnergy(i)); + } + + // RING_CAL_MULT + int myMULT[fWedgesNumber]; + for (unsigned int i = 0; i < fWedgesNumber; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < PreTreatedData->GetRingEMult(); i++) myMULT[(PreTreatedData->GetRingEDetectorNbr(i)-1)] += 1; + + for (unsigned int i = 0; i < fWedgesNumber; i++) { + name = Form("HYB_W%d_RING_E_CAL_MULT", i+1); + family = "TIARA/HYBALL/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // RING_CAL_MULT + for (unsigned int i = 0; i < fWedgesNumber; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < PreTreatedData->GetSectorEMult(); i++) myMULT[(PreTreatedData->GetSectorEDetectorNbr(i)-1)] += 1; + + for (unsigned int i = 0; i < fWedgesNumber; i++) { + name = Form("HYB_W%d_SECT_E_CAL_MULT", i+1); + family = "TIARA/HYBALL/CAL/MULT"; + GetHisto(family,name) -> Fill(myMULT[i]); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::FillPhysicsSpectra(TTiaraHyballPhysics* Physics){ + /* TString name; + TString family= "TIARA/HYBALL/PHY"; + // X-Y Impact Matrix + + for(unsigned int i = 0 ; i < Physics->Si_E.size(); i++){ + name = "MM_IMPACT_MATRIX"; + double x = Physics->GetPositionOfInteraction(i).x(); + double y = Physics->GetPositionOfInteraction(i).y(); + GetHisto(family,name)-> Fill(x,y); + + name = "MM_THETA_E"; + double Theta = Physics->GetPositionOfInteraction(i).Angle(TVector3(0,0,1)); + Theta = Theta/deg; + GetHisto(family,name)-> Fill(Theta,Physics->Si_E[i]); + + // STRX_E_CAL + name = Form("MM%d_XY_COR", Physics->TelescopeNumber[i]); + GetHisto(family,name)-> Fill(Physics->Si_EX[i],Physics->Si_EY[i]); + }*/ +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TTiaraHyballSpectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family){ + // create histo + TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup); + + vector<TString> index; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index] = hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TTiaraHyballSpectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family){ + // create histo + TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + + vector<TString> index; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index] = hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TTiaraHyballSpectra::GetHisto(TString family, TString name){ + vector<TString> index; + index.push_back(family); + index.push_back(name); + return fMapHisto.at(index); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTiaraHyballSpectra::WriteHisto(TString filename){ + TFile* f = NULL; + + if (filename != "VOID") { + f = new TFile(filename,"RECREATE"); + } + + map< vector<TString>, TH1* >::iterator it; + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) { + it->second->Write(); + } + + if (filename != "VOID") { + f->Close(); + delete f; + } +} diff --git a/NPLib/Tiara/TTiaraHyballSpectra.h b/NPLib/Tiara/TTiaraHyballSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..7d0e67b31be9c06ab247ebaef40dfed9571a5941 --- /dev/null +++ b/NPLib/Tiara/TTiaraHyballSpectra.h @@ -0,0 +1,84 @@ +#ifndef TTIARAHYBALLSPECTRA_H +#define TTIARAHYBALLSPECTRA_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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Tiara/Hyball * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// ROOT headers +#include "TObject.h" +#include <TH1.h> +#include <TH2.h> +#include <TString.h> + +// NPLib headers +#include "TTiaraHyballData.h" +#include "TTiaraHyballPhysics.h" + +// C++ STL headers +#include <map> +using namespace std; + + +// Forward Declaration +class TTiaraHyballPhysics; + + +class TTiaraHyballSpectra { + public: + // constructor and destructor + TTiaraHyballSpectra(); + ~TTiaraHyballSpectra(); + + private: + // Instantiate and register histo to maps + TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family); + TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, + Int_t nbinsy, Double_t ylow, Double_t yup, TString family); + + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TTiaraHyballData*); + void FillPreTreatedSpectra(TTiaraHyballData*); + void FillPhysicsSpectra(TTiaraHyballPhysics*); + + public: + // get map histo which will be used for GSpectra in GUser + map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;} + TH1* GetHisto(TString family, TString name); + void WriteHisto(TString filename = "VOID"); + + private: // Information on MUST2 + unsigned int fRingsNumber; + unsigned int fSectorsNumber; + unsigned int fWedgesNumber; + + private: + // map holding histo pointers and their family names + map< vector<TString>, TH1* > fMapHisto; +}; + +#endif diff --git a/NPLib/Tools/CalibrationManager.cxx b/NPLib/Tools/CalibrationManager.cxx index 0b96798ee9bfdd545a986eeab08adaf0d0da630d..a03478b2a61c9ae7b8be73053c8fb64a4997fd1e 100644 --- a/NPLib/Tools/CalibrationManager.cxx +++ b/NPLib/Tools/CalibrationManager.cxx @@ -62,8 +62,7 @@ CalibrationManager::CalibrationManager(string configFileName) return; } - else - { + else { cout << "Reading list of file from :" << configFileName << endl; while (!inputConfigFile.eof()) { getline(inputConfigFile, lineBuffer); @@ -175,16 +174,14 @@ void CalibrationManager::LoadParameterFromFile() // Search word in the token list it=fToken.find(DataBuffer); - - // if the word is find, values are read + // if the word is find, values are read if( it!=fToken.end() ) - { + { vector<double> Coeff ; - while( !theLine.eof() ) - { + while( !theLine.eof() ){ theLine >> DataBuffer ; Coeff.push_back( atof(DataBuffer.c_str()) ) ; - } - + } + // Check this parameter is not already define if( fCalibrationCoeff.find(it->second) != fCalibrationCoeff.end() ) cout << "WARNING: Parameter " << it->second << " Already found. It will be rewritted " << endl; @@ -214,9 +211,10 @@ double CalibrationManager::ApplyCalibration(const string& ParameterPath , const // If the find methods return the end iterator it's mean the parameter was not found if(it == fCalibrationCoeff.end() ) { - /* cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ; + /* cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ; cout << " ERROR: PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << endl ; - cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ;*/ + cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl; +exit(1); */ return RawValue ; } @@ -238,6 +236,38 @@ double CalibrationManager::ApplyCalibration(const string& ParameterPath , const } +////////////////////////////////////////////////////////////////// +double CalibrationManager::ApplyResistivePositionCalibration(const string& ParameterPath , const double& DeltaRawValue){ + map< string , vector<double> >::iterator it ; + + // Find the good parameter in the Map + // Using Find method of stl is the fastest way + it = fCalibrationCoeff.find(ParameterPath) ; + + // If the find methods return the end iterator it's mean the parameter was not found + if(it == fCalibrationCoeff.end() ) + { + /* cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ; + cout << " ERROR: PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << endl ; + cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl; +exit(1); */ + + return DeltaRawValue ; + } + + // Else we take the second part of the element (first is index, ie: parameter path) + // Second is the vector of Coeff + vector<double> Coeff = it->second ; + + // Check that the number of coeff is ok + if(Coeff.size()!=2) return DeltaRawValue ; + + double CalibratedValue = (DeltaRawValue-Coeff[0])/(Coeff[1]-Coeff[0]) ; + return CalibratedValue ; + + } + + ////////////////////////////////////////////////////////////////// bool CalibrationManager::ApplyThreshold(const string& ParameterPath, const double& RawValue) { diff --git a/NPLib/Tools/CalibrationManager.h b/NPLib/Tools/CalibrationManager.h index 02b82e75843d8deb51d573b33c979e4c72f500d8..df2c0a6052da7b68523db215e10a9fcaf8576587 100644 --- a/NPLib/Tools/CalibrationManager.h +++ b/NPLib/Tools/CalibrationManager.h @@ -59,12 +59,9 @@ class CalibrationManager // call like : myCalibrationManager->ApplyCalibration( "MUST2/Telescope5_Si_X38_E" , RawEnergy ) // return the Calibrated value double ApplyCalibration(const string& ParameterPath , const double& RawValue); - + double ApplyResistivePositionCalibration(const string& ParameterPath , const double& RawValue); bool ApplyThreshold(const string& ParameterPath, const double& RawValue); - double GetPedestal(const string& ParameterPath); - - public: // To be called after initialisation // Loop over the file list and catch the file used for calibration diff --git a/NPLib/Tools/NPOptionManager.cxx b/NPLib/Tools/NPOptionManager.cxx index 4922a5d4de4237cdf6541030e4c8857a21588c27..51ae2df4c2f1486c5be654525bda50a0cff7e603 100644 --- a/NPLib/Tools/NPOptionManager.cxx +++ b/NPLib/Tools/NPOptionManager.cxx @@ -61,6 +61,7 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ fVerboseLevel = 1; fDisableAllBranchOption = false; fInputPhysicalTreeOption = false; + fGenerateHistoOption = false ; fPROOFMode = false; for (int i = 0; i < argc; i++) { @@ -96,8 +97,16 @@ void NPOptionManager::ReadTheInputArgument(int argc, char** argv){ else if (argument == "--input-physical") fInputPhysicalTreeOption = true ; else if (argument == "-IP") fInputPhysicalTreeOption = true ; - - else if (argument == "--proof") fPROOFMode= true ; + + else if (argument == "-GH") fGenerateHistoOption = true ; + + else if (argument == "-CH") fCheckHistoOption = true ; + + else if (argument == "-check-histo") fCheckHistoOption = true ; + + else if (argument == "--generate-histo") fGenerateHistoOption = true ; + + else if (argument == "--proof") fPROOFMode = true ; //else ; } @@ -268,11 +277,13 @@ void NPOptionManager::DisplayHelp() cout << "\t --detector -D <arg>\t \t \t \t \t \t Set arg as the detector configuration file" << endl ; cout << "\t --event-generator -E <arg>\t \t \t \t \t Set arg as the event generator file" << endl ; cout << "\t --output -O <arg>\t \t \t \t \t \t Set arg as the Output File Name (output tree)" << endl ; - cout << "\t --verbose -V <arg>\t \t \t \t \t \t \t Set the verbose level of some of the object, 0 for nothing, 1 for normal printout. Error and warning are not affected" << endl ; + cout << "\t --verbose -V <arg>\t \t \t \t \t \t Set the verbose level of some of the object, 0 for nothing, 1 for normal printout. Error and warning are not affected" << endl ; cout << endl << "NPAnalysis only:"<<endl; cout << "\t --run -R <arg>\t \t \t \t \t \t \t Set arg as the run to read file list" << endl ; cout << "\t --cal -C <arg>\t \t \t \t \t \t \t Set arg as the calibration file list" << endl ; cout << "\t --disable-branch\t \t \t \t \t \t Disable of branch of Input tree except the one of the detector (faster)" << endl ; + cout << "\t --generate-histo -GH\t \t \t \t \t \t Instantiate the T*Spectra class of each detector" << endl ; + cout << "\t --check-histo -CH\t \t \t \t \t \t Check if the Histogram looks ok and change there color if not" << endl ; cout << "\t --input-physical -IP\t \t \t \t \t \t Consider the Input file is containing Physics Class instead of Data Class. Output branches associate to the detector are not activated" << endl ; cout << endl << endl ; diff --git a/NPLib/Tools/NPOptionManager.h b/NPLib/Tools/NPOptionManager.h index 605eb3c45f03ea22e283f59886fab8eb6f73c6d8..85b9ccd5d33f5539ea629e5fccbff0d375ceda09 100644 --- a/NPLib/Tools/NPOptionManager.h +++ b/NPLib/Tools/NPOptionManager.h @@ -92,6 +92,8 @@ class NPOptionManager string GetOutputFile() {return fOutputFileName;} bool GetDisableAllBranchOption() {return fDisableAllBranchOption;} bool GetInputPhysicalTreeOption() {return fInputPhysicalTreeOption;} + bool GetGenerateHistoOption() {return fGenerateHistoOption;} + bool GetCheckHistoOption() {return fCheckHistoOption;} bool GetPROOF() {return fPROOFMode;} int GetVerboseLevel() {return fVerboseLevel;} @@ -116,6 +118,8 @@ class NPOptionManager string fOutputFileName; bool fDisableAllBranchOption; bool fInputPhysicalTreeOption; + bool fGenerateHistoOption; + bool fCheckHistoOption; bool fPROOFMode; // if true, the system run in a pROOF environment int fVerboseLevel; // 0 for not talk, 1 for talking }; diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx index a898f3894ac5099b06c72cfc3c97a0ce8d182888..3bf62a3afb02dd0f4cb47cf23623f96821c9fd27 100644 --- a/NPLib/VDetector/DetectorManager.cxx +++ b/NPLib/VDetector/DetectorManager.cxx @@ -37,11 +37,15 @@ #include "TTrifoilPhysics.h" #include "TPlasticPhysics.h" #include "TTrifoilPhysics.h" +#include "TTiaraHyballPhysics.h" +#include "TTiaraBarrelPhysics.h" #include "TChateauCristalPhysics.h" #include "GaspardTracker.h" #include "Hyde2Tracker.h" #include "Paris.h" #include "TW1Physics.h" +#include "TS2Physics.h" +#include "TCharissaPhysics.h" #include "Shield.h" #include "TSpegPhysics.h" #include "TExlPhysics.h" @@ -52,32 +56,25 @@ #include "RootInput.h" ///////////////////////////////////////////////////////////////////////////////////////////////// // Default Constructor -DetectorManager::DetectorManager() -{ +DetectorManager::DetectorManager() { } - - ///////////////////////////////////////////////////////////////////////////////////////////////// // Default Desstructor -DetectorManager::~DetectorManager() -{ +DetectorManager::~DetectorManager(){ } - - ///////////////////////////////////////////////////////////////////////////////////////////////// // Read stream at ConfigFile and pick-up Token declaration of Detector -void DetectorManager::ReadConfigurationFile(string Path) -{ +void DetectorManager::ReadConfigurationFile(string Path) { - // Instantiate the Calibration Manager - // All The detector will then add to it their parameter (see AddDetector) - CalibrationManager::getInstance(NPOptionManager::getInstance()->GetCalibrationFile()); + // Instantiate the Calibration Manager + // All The detector will then add to it their parameter (see AddDetector) + CalibrationManager::getInstance(NPOptionManager::getInstance()->GetCalibrationFile()); - ////////General Reading needs//////// - string LineBuffer; - string DataBuffer; + ////////General Reading needs//////// + string LineBuffer; + string DataBuffer; /////////Boolean//////////////////// Bool_t MUST2 = false; @@ -89,200 +86,207 @@ void DetectorManager::ReadConfigurationFile(string Path) Bool_t ScintillatorPlastic = false; Bool_t IonisationChamber = false; Bool_t Trifoil = false; + Bool_t Charissa = false; Bool_t GeneralTarget = false; Bool_t GPDTracker = false; Bool_t HYD2Tracker = false; Bool_t ParisDet = false; Bool_t ShieldDet = false; Bool_t W1 = false; + Bool_t S2 = false; Bool_t SPEG = false; Bool_t EXL = false; Bool_t TAC = false; - - ////////////////////////////////////////////////////////////////////////////////////////// - string GlobalPath = getenv("NPTOOL"); - string StandardPath = GlobalPath + "/Inputs/DetectorConfiguration/" + Path; - ifstream ConfigFile; - ConfigFile.open(StandardPath.c_str()); - - if (ConfigFile.is_open()) - { - cout << endl << "/////////// Detector geometry ///////////" << endl; - cout << "Configuration file " << Path << " loading " << endl; - Path = StandardPath; - } - - else - { - ConfigFile.open( Path.c_str() ); - if(ConfigFile.is_open()) { - cout << endl << "/////////// Detector geometry ///////////" << endl; - cout << " Configuration file " << Path << " loading " << endl; - } - - else {cout << "Configuration File " << Path << " not found" << endl;return;} - } - - - while (!ConfigFile.eof()) { - // Pick-up next line - getline(ConfigFile, LineBuffer); - //Search for comment Symbol: % - if (LineBuffer.compare(0, 1, "%") == 0) { /*Do Nothing*/ ;} - - //////////////////////////////////////////// - //////////// Search for Gaspard //////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 14, "GaspardTracker") == 0 && GPDTracker == false) { + Bool_t TiaraHyball = false; + Bool_t TiaraBarrel = false; +////////////////////////////////////////////////////////////////////////////////////////// + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + + if (ConfigFile.is_open()) { + cout << endl << "/////////// Detector geometry ///////////" << endl; + cout << "Configuration file " << Path << " loading " << endl; + } + + while (!ConfigFile.eof()) { + // Pick-up next line + getline(ConfigFile, LineBuffer); + //Search for comment Symbol: % + if (LineBuffer.compare(0, 1, "%") == 0) { /*Do Nothing*/ ;} + + //////////////////////////////////////////// + //////////// Search for Gaspard //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 14, "GaspardTracker") == 0 && GPDTracker == false) { #ifdef INC_GASPARD - GPDTracker = true ; - cout << "//////// Gaspard Tracker ////////" << endl; + GPDTracker = true ; + cout << "//////// Gaspard Tracker ////////" << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new GaspardTracker(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new GaspardTracker(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("GASPARD", myDetector); + // Add array to the VDetector Vector + AddDetector("GASPARD", myDetector); #endif - } - //////////////////////////////////////////// - //////////// Search for Hyde2 /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 12, "Hyde2Tracker") == 0 && HYD2Tracker == false) { + } + //////////////////////////////////////////// + //////////// Search for Hyde2 /////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 12, "Hyde2Tracker") == 0 && HYD2Tracker == false) { #ifdef INC_HYDE2 - HYD2Tracker = true ; - cout << "//////// Hyde2 Tracker ////////" << endl; + HYD2Tracker = true ; + cout << "//////// Hyde2 Tracker ////////" << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Hyde2Tracker(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Hyde2Tracker(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("HYDE2", myDetector); + // Add array to the VDetector Vector + AddDetector("HYDE2", myDetector); #endif - } - //////////////////////////////////////////// - ///////////// Search for Paris ///////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 5, "Paris") == 0 && ParisDet == false) { + } + //////////////////////////////////////////// + ///////////// Search for Paris ///////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 5, "Paris") == 0 && ParisDet == false) { #ifdef INC_PARIS - ParisDet = true; - cout << "//////// Paris ////////" << endl << endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Paris(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector("PARIS", myDetector); + ParisDet = true; + cout << "//////// Paris ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Paris(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("PARIS", myDetector); #endif - } - //////////////////////////////////////////// - ///////////// Search for Paris' Shield ///// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 6, "Shield") == 0 && ShieldDet == false) { + } + //////////////////////////////////////////// + ///////////// Search for Paris' Shield ///// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 6, "Shield") == 0 && ShieldDet == false) { #ifdef INC_SHIELD - ShieldDet = true; - cout << "//////// Shield ////////" << endl << endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new Shield(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector("SHIELD", myDetector); + ShieldDet = true; + cout << "//////// Shield ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new Shield(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("SHIELD", myDetector); #endif - } + } - //////////////////////////////////////////// - //////// Search for MUST2 Array //////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 10, "MUST2Array") == 0 && MUST2 == false) { + //////////////////////////////////////////// + //////// Search for MUST2 Array //////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 10, "MUST2Array") == 0 && MUST2 == false) { #ifdef INC_MUST2 - MUST2 = true; - cout << "//////// MUST2 Array ////////" << endl << endl; + MUST2 = true; + cout << "//////// MUST2 Array ////////" << endl << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TMust2Physics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TMust2Physics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("MUST2", myDetector); + // Add array to the VDetector Vector + AddDetector("MUST2", myDetector); #endif - } + } + + //////////////////////////////////////////// + //////// Search for CHARISSA Array //////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 13, "CharissaArray") == 0 && Charissa == false) { +#ifdef INC_CHARISSA + Charissa = true; + cout << "//////// Charissa Array ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TCharissaPhysics(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Charissa", myDetector); +#endif + } - //////////////////////////////////////////// - //////// Search for CATS Array //////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "CATSArray") == 0 && CATS == false) { + //////////////////////////////////////////// + //////// Search for CATS Array //////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 9, "CATSArray") == 0 && CATS == false) { #ifdef INC_CATS - CATS = true; - cout << "//////// CATS Array ////////" << endl << endl; + CATS = true; + cout << "//////// CATS Array ////////" << endl << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TCATSPhysics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TCATSPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("CATS", myDetector); + // Add array to the VDetector Vector + AddDetector("CATS", myDetector); #endif - } - - //////////////////////////////////////////////////// - //////// Search for Chateau de Cristal //////// - //////////////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "ChateauCristal") == 14 && ChateauCristal == false) { + } + + //////////////////////////////////////////////////// + //////// Search for Chateau de Cristal //////// + //////////////////////////////////////////////////// + else if (LineBuffer.compare(0, 9, "ChateauCristal") == 14 && ChateauCristal == false) { #ifdef INC_CHATEAUCRISTAL - ChateauCristal = true; - cout << "//////// Chateau de Cristal Array ////////" << endl << endl; + ChateauCristal = true; + cout << "//////// Chateau de Cristal Array ////////" << endl << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TChateauCristalPhysics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TChateauCristalPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("ChateauCristal", myDetector); + // Add array to the VDetector Vector + AddDetector("ChateauCristal", myDetector); #endif } - //////////////////////////////////////////// - ////////// Search for W1 (Micron) ///////// + ////////// Search for S2 (Micron) ///////// //////////////////////////////////////////// - else if (LineBuffer.compare(0, 2, "W1") == 0 && W1 == false) { -#ifdef INC_W1 - W1 = true; - cout << "//////// W1 ////////" << endl; + else if (LineBuffer.compare(0, 2, "S2") == 0 && S2 == false) { +#ifdef INC_S2 + S2 = true; + cout << "//////// S2 ////////" << endl; // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TW1Physics(); + VDetector* myDetector = new TS2Physics(); // Read Position of Telescope ConfigFile.close(); @@ -290,423 +294,501 @@ void DetectorManager::ReadConfigurationFile(string Path) ConfigFile.open(Path.c_str()); // Add array to the VDetector Vector - AddDetector("W1", myDetector); + AddDetector("S2", myDetector); #endif } - + //////////////////////////////////////////// - ////////// Search for SSSD ///////// + ////////// Search for W1 (Micron) ///////// //////////////////////////////////////////// - else if (LineBuffer.compare(0, 9, "SSSDArray") == 0 && SSSD == false) { -#ifdef INC_SSSD - SSSD = true ; - cout << "//////// SSSD ////////" << endl << endl; + else if (LineBuffer.compare(0, 2, "W1") == 0 && W1 == false) { +#ifdef INC_W1 + W1 = true; + cout << "//////// W1 ////////" << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TSSSDPhysics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TW1Physics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("SSSD", myDetector); -#endif - } - - //////////////////////////////////////////// - ///////// Search for Sharc ///////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 5, "Sharc") == 0 && Sharc == false) { -#ifdef INC_SHARC - Sharc = true ; - cout << "//////// Sharc ////////" << endl << endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TSharcPhysics(); - - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector("Sharc", myDetector); + // Add array to the VDetector Vector + AddDetector("W1", myDetector); #endif - } - - ////////////////////////////////////////////// - ////////// Search for Exogam ///////// - ////////////////////////////////////////////// - else if (LineBuffer.compare(0, 11, "EXOGAMArray") == 0 && Exogam == false) { -#ifdef INC_EXOGAM - Exogam = true ; - cout << "//////// Exogam ////////" << endl << endl; + } - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TExogamPhysics(); + //////////////////////////////////////////// + ////////// Search for SSSD ///////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 9, "SSSDArray") == 0 && SSSD == false) { +#ifdef INC_SSSD + SSSD = true ; + cout << "//////// SSSD ////////" << endl << endl; - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TSSSDPhysics(); - // Add array to the VDetector Vector - AddDetector("EXOGAM", myDetector); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("SSSD", myDetector); #endif - } + } - //////////////////////////////////////////// - ///////////// Search for Plastic /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 19, "ScintillatorPlastic") == 0 && ScintillatorPlastic == false) { -#ifdef INC_PLASTIC - ScintillatorPlastic = true; - cout << "//////// Plastic ////////" << endl << endl; + //////////////////////////////////////////// + ///////// Search for Sharc ///////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 5, "Sharc") == 0 && Sharc == false) { +#ifdef INC_SHARC + Sharc = true ; + cout << "//////// Sharc ////////" << endl << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TPlasticPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TSharcPhysics(); - // Add array to the VDetector Vector - AddDetector("Plastic", myDetector); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Sharc", myDetector); #endif - } + } - /////////////////////////////////////////////////////// - ///////////// Search for Ionisation Chamber /////////// - /////////////////////////////////////////////////////// - else if (LineBuffer.compare(0, 17, "IonisationChamber") == 0 && IonisationChamber == false) { -#ifdef INC_CHIO - IonisationChamber = true; - cout << "//////// Ionisation Chamger ////////" << endl << endl; + ////////////////////////////////////////////// + ////////// Search for Exogam ///////// + ////////////////////////////////////////////// + else if (LineBuffer.compare(0, 11, "EXOGAMArray") == 0 && Exogam == false) { +#ifdef INC_EXOGAM + Exogam = true ; + cout << "//////// Exogam ////////" << endl << endl; - /////// Case with analog electronics - // Instantiate the new array as a VDetector Object - VDetector* myDetector_an = new TChio_anPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector_an->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TExogamPhysics(); - // Add array to the VDetector Vector - AddDetector("Chio_an", myDetector_an); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + // Add array to the VDetector Vector + AddDetector("EXOGAM", myDetector); +#endif + } - /////// Case with digital electronics - // Instantiate the new array as a VDetector Object - VDetector* myDetector_dig = new TChio_digPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector_dig->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + //////////////////////////////////////////// + ///////////// Search for Plastic /////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 19, "ScintillatorPlastic") == 0 && ScintillatorPlastic == false) { +#ifdef INC_PLASTIC + ScintillatorPlastic = true; + cout << "//////// Plastic ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TPlasticPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Plastic", myDetector); +#endif + } - // Add array to the VDetector Vector - AddDetector("Chio_dig", myDetector_dig); + /////////////////////////////////////////////////////// + ///////////// Search for Ionisation Chamber /////////// + /////////////////////////////////////////////////////// + else if (LineBuffer.compare(0, 17, "IonisationChamber") == 0 && IonisationChamber == false) { +#ifdef INC_CHIO + IonisationChamber = true; + cout << "//////// Ionisation Chamger ////////" << endl << endl; + + /////// Case with analog electronics + // Instantiate the new array as a VDetector Object + VDetector* myDetector_an = new TChio_anPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector_an->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Chio_an", myDetector_an); + + + /////// Case with digital electronics + // Instantiate the new array as a VDetector Object + VDetector* myDetector_dig = new TChio_digPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector_dig->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Chio_dig", myDetector_dig); #endif - } + } - //////////////////////////////////////////// - ///////////// Search for SPEG ////////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 4, "SPEG") == 0 && SPEG == false) { + //////////////////////////////////////////// + ///////////// Search for SPEG ////////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 4, "SPEG") == 0 && SPEG == false) { #ifdef INC_SPEG - SPEG = true ; - cout << "//////// SPEG Spectrometer ////////" << endl; + SPEG = true ; + cout << "//////// SPEG Spectrometer ////////" << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TSpegPhysics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TSpegPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("SPEG", myDetector); + // Add array to the VDetector Vector + AddDetector("SPEG", myDetector); #endif - } + } - /////////////////////////////////////////////////////////// - //////////// Search for EXL Csi gamma detector //////////// - /////////////////////////////////////////////////////////// - else if (LineBuffer.compare(0, 3, "EXL") == 0 && EXL == false) { + /////////////////////////////////////////////////////////// + //////////// Search for EXL Csi gamma detector //////////// + /////////////////////////////////////////////////////////// + else if (LineBuffer.compare(0, 3, "EXL") == 0 && EXL == false) { #ifdef INC_EXL - EXL = true ; - cout << "//////// EXL Csi gamma detector ////////" << endl; + EXL = true ; + cout << "//////// EXL Csi gamma detector ////////" << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TExlPhysics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TExlPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("EXL", myDetector); + // Add array to the VDetector Vector + AddDetector("EXL", myDetector); #endif - } + } - //////////////////////////////////////////// - ////////////// Search for TAC ////////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 3, "TAC") == 0 && TAC == false) { + //////////////////////////////////////////// + ////////////// Search for TAC ////////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 3, "TAC") == 0 && TAC == false) { #ifdef INC_MISC - TAC = true ; - cout << "//////// TAC ////////" << endl; + TAC = true ; + cout << "//////// TAC ////////" << endl; - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TTacPhysics(); + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TTacPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); - // Add array to the VDetector Vector - AddDetector("TAC", myDetector); + // Add array to the VDetector Vector + AddDetector("TAC", myDetector); #endif - } + } - //////////////////////////////////////////// - ///////////// Search for Trifoil /////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 7, "Trifoil") == 0 && Trifoil == false) { + //////////////////////////////////////////// + ///////////// Search for Trifoil /////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 7, "Trifoil") == 0 && Trifoil == false) { #ifdef INC_TRIFOIL - Trifoil = true; - cout << "//////// Trifoil ////////" << endl << endl; + Trifoil = true; + cout << "//////// Trifoil ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TTrifoilPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Trifoil", myDetector); +#endif + } + + //////////////////////////////////////////// + ///////////// Search for Hyball //////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 11, "TiaraHyball") == 0 && TiaraHyball == false) { +#ifdef INC_TIARA + TiaraHyball = true; + cout << "//////// Tiara Hyball ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TTiaraHyballPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("TiaraHyball", myDetector); +#endif + } + + //////////////////////////////////////////// + ///////// Search for Tiara barrel ////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 11, "TiaraBarrel") == 0 && TiaraBarrel == false) { +#ifdef INC_TIARA + TiaraBarrel = true; + cout << "//////// Tiara Barrel ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TTiaraBarrelPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("TiaraBarrel", myDetector); +#endif + } + //////////////////////////////////////////// + //////////// Search for Target ///////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && GeneralTarget == false) { + GeneralTarget = true ; + cout << "////////// Target ///////////" << endl; + + // jump one line + getline(ConfigFile, LineBuffer); + getline(ConfigFile, LineBuffer); - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TTrifoilPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); + bool check_Thickness = false; + // bool check_Angle = false; + bool check_Radius = false; + bool check_Material = false; + bool check_X = false; + bool check_Y = false; + bool check_Z = false; + + bool ReadingStatusTarget = true; + while (ReadingStatusTarget) { + ConfigFile >> DataBuffer; + + // Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) {ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );getline(ConfigFile, LineBuffer);} + + else if (DataBuffer.compare(0, 10, "THICKNESS=") == 0) { + check_Thickness = true ; + ConfigFile >> DataBuffer; + // m_TargetThickness = atof(DataBuffer.c_str()) * micrometer; + m_TargetThickness = atof(DataBuffer.c_str()); + cout << "Target Thickness: " << m_TargetThickness << endl; + } + + else if (DataBuffer.compare(0, 6, "ANGLE=") == 0) { + // check_Angle = true ; + ConfigFile >> DataBuffer; + // m_TargetAngle = atof(DataBuffer.c_str()) * deg; + m_TargetAngle = atof(DataBuffer.c_str()); + cout << "Target Angle: " << m_TargetAngle << endl; + } + + else if (DataBuffer.compare(0, 7, "RADIUS=") == 0) { + check_Radius = true ; + ConfigFile >> DataBuffer; + // m_TargetRadius = atof(DataBuffer.c_str()) * mm; + m_TargetRadius = atof(DataBuffer.c_str()); + cout << "Target Radius: " << m_TargetRadius << endl; + } + + else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { + check_Material = true ; + ConfigFile >> DataBuffer; + m_TargetMaterial = DataBuffer; + cout << "Target Material: " << m_TargetMaterial << endl; + } + + else if (DataBuffer.compare(0, 2, "X=") == 0) { + check_X = true ; + ConfigFile >> DataBuffer; + // m_TargetX = atoi(DataBuffer.c_str()) * mm; + m_TargetX = atoi(DataBuffer.c_str()); + cout << "Target Coordinates (mm): ( " << m_TargetX << " ; "; + } + + else if (DataBuffer.compare(0, 2, "Y=") == 0) { + check_Y = true ; + ConfigFile >> DataBuffer; + // m_TargetY = atoi(DataBuffer.c_str()) * mm; + m_TargetY = atoi(DataBuffer.c_str()); + cout << m_TargetY << " ; "; + } + + else if (DataBuffer.compare(0, 2, "Z=") == 0) { + check_Z = true ; + ConfigFile >> DataBuffer; + // m_TargetZ = atoi(DataBuffer.c_str()) * mm; + m_TargetZ = atoi(DataBuffer.c_str()); + cout << m_TargetZ << " )" << endl; + } + + /////////////////////////////////////////////////// + // If no Target Token and no comments, toggle out + else { + ReadingStatusTarget = false; + cout << "WARNING : Wrong Token Sequence: Getting out " << endl; + } + + /////////////////////////////////////////////////// + // If all Token found toggle out + if (check_Thickness && check_Radius && check_Material && check_X && check_Y && check_Z) + ReadingStatusTarget = false; - // Add array to the VDetector Vector - AddDetector("Trifoil", myDetector); -#endif } + } - //////////////////////////////////////////// - //////////// Search for Target ///////////// - //////////////////////////////////////////// - else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && GeneralTarget == false) { - GeneralTarget = true ; - cout << "////////// Target ///////////" << endl; - - // jump one line - getline(ConfigFile, LineBuffer); - getline(ConfigFile, LineBuffer); - - bool check_Thickness = false; -// bool check_Angle = false; - bool check_Radius = false; - bool check_Material = false; - bool check_X = false; - bool check_Y = false; - bool check_Z = false; - - bool ReadingStatusTarget = true; - while (ReadingStatusTarget) { - ConfigFile >> DataBuffer; - - // Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) {ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );getline(ConfigFile, LineBuffer);} - - else if (DataBuffer.compare(0, 10, "THICKNESS=") == 0) { - check_Thickness = true ; - ConfigFile >> DataBuffer; -// m_TargetThickness = atof(DataBuffer.c_str()) * micrometer; - m_TargetThickness = atof(DataBuffer.c_str()); - cout << "Target Thickness: " << m_TargetThickness << endl; - } - - else if (DataBuffer.compare(0, 6, "ANGLE=") == 0) { -// check_Angle = true ; - ConfigFile >> DataBuffer; -// m_TargetAngle = atof(DataBuffer.c_str()) * deg; - m_TargetAngle = atof(DataBuffer.c_str()); - cout << "Target Angle: " << m_TargetAngle << endl; - } - - else if (DataBuffer.compare(0, 7, "RADIUS=") == 0) { - check_Radius = true ; - ConfigFile >> DataBuffer; -// m_TargetRadius = atof(DataBuffer.c_str()) * mm; - m_TargetRadius = atof(DataBuffer.c_str()); - cout << "Target Radius: " << m_TargetRadius << endl; - } - - else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { - check_Material = true ; - ConfigFile >> DataBuffer; - m_TargetMaterial = DataBuffer; - cout << "Target Material: " << m_TargetMaterial << endl; - } - - else if (DataBuffer.compare(0, 2, "X=") == 0) { - check_X = true ; - ConfigFile >> DataBuffer; -// m_TargetX = atoi(DataBuffer.c_str()) * mm; - m_TargetX = atoi(DataBuffer.c_str()); - cout << "Target Coordinates (mm): ( " << m_TargetX << " ; "; - } - - else if (DataBuffer.compare(0, 2, "Y=") == 0) { - check_Y = true ; - ConfigFile >> DataBuffer; -// m_TargetY = atoi(DataBuffer.c_str()) * mm; - m_TargetY = atoi(DataBuffer.c_str()); - cout << m_TargetY << " ; "; - } - - else if (DataBuffer.compare(0, 2, "Z=") == 0) { - check_Z = true ; - ConfigFile >> DataBuffer; -// m_TargetZ = atoi(DataBuffer.c_str()) * mm; - m_TargetZ = atoi(DataBuffer.c_str()); - cout << m_TargetZ << " )" << endl; - } - - /////////////////////////////////////////////////// - // If no Target Token and no comments, toggle out - else { - ReadingStatusTarget = false; - cout << "WARNING : Wrong Token Sequence: Getting out " << endl; - } - - /////////////////////////////////////////////////// - // If all Token found toggle out - if (check_Thickness && check_Radius && check_Material && check_X && check_Y && check_Z) - ReadingStatusTarget = false; - - } - } + //Nothing understandable + //else ; + } - //Nothing understandable - //else ; - } + ConfigFile.close(); - ConfigFile.close(); + // Now that the detector are all added, they can initialise their Branch to the Root I/O + InitializeRootInput(); + InitializeRootOutput(); - // Now that the detector are all added, they can initialise their Branch to the Root I/O - InitializeRootInput(); - InitializeRootOutput(); + // If Requiered, they can also instiantiate their control histogramm + if(NPOptionManager::getInstance()->GetGenerateHistoOption()) + InitSpectra(); - // The calibration Manager got all the parameter added, so it can load them from the calibration file - CalibrationManager::getInstance()->LoadParameterFromFile(); + // The calibration Manager got all the parameter added, so it can load them from the calibration file + CalibrationManager::getInstance()->LoadParameterFromFile(); - return; + return; } ///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::BuildPhysicalEvent() -{ - map<string,VDetector*>::iterator it; - +void DetectorManager::BuildPhysicalEvent(){ + ClearEventPhysics(); + map<string,VDetector*>::iterator it; for (it = m_Detector.begin(); it != m_Detector.end(); ++it) { - it->second->BuildPhysicalEvent(); - } + it->second->BuildPhysicalEvent(); + if(NPOptionManager::getInstance()->GetGenerateHistoOption()){ + it->second->FillSpectra(); + if(NPOptionManager::getInstance()->GetCheckHistoOption()) + it->second->CheckSpectra(); + } + } } - - ///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::BuildSimplePhysicalEvent() -{ - map<string,VDetector*>::iterator it; - - for (it = m_Detector.begin(); it != m_Detector.end(); ++it) { - it->second->BuildSimplePhysicalEvent(); - } +void DetectorManager::BuildSimplePhysicalEvent(){ + ClearEventPhysics(); + map<string,VDetector*>::iterator it; + + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) { + it->second->BuildSimplePhysicalEvent(); + if(NPOptionManager::getInstance()->GetGenerateHistoOption()){ + it->second->FillSpectra(); + if(NPOptionManager::getInstance()->GetCheckHistoOption()) + it->second->CheckSpectra(); + } + } } - - ///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::InitializeRootInput() -{ +void DetectorManager::InitializeRootInput(){ if( NPOptionManager::getInstance()->GetDisableAllBranchOption() ) - RootInput::getInstance()->GetChain()->SetBranchStatus ( "*" , false ) ; - - map<string,VDetector*>::iterator it; + RootInput::getInstance()->GetChain()->SetBranchStatus ( "*" , false ) ; - if(NPOptionManager::getInstance()->GetInputPhysicalTreeOption()) - for (it = m_Detector.begin(); it != m_Detector.end(); ++it) - it->second->InitializeRootInputPhysics(); - - else // Default Case - for (it = m_Detector.begin(); it != m_Detector.end(); ++it) - it->second->InitializeRootInputRaw(); -} + map<string,VDetector*>::iterator it; + if(NPOptionManager::getInstance()->GetInputPhysicalTreeOption()) + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) + it->second->InitializeRootInputPhysics(); + else // Default Case + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) + it->second->InitializeRootInputRaw(); +} ///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::InitializeRootOutput() -{ - map<string,VDetector*>::iterator it; +void DetectorManager::InitializeRootOutput(){ + map<string,VDetector*>::iterator it; - if(!NPOptionManager::getInstance()->GetInputPhysicalTreeOption()) - for (it = m_Detector.begin(); it != m_Detector.end(); ++it) - it->second->InitializeRootOutput(); + if(!NPOptionManager::getInstance()->GetInputPhysicalTreeOption()) + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) + it->second->InitializeRootOutput(); } - +///////////////////////////////////////////////////////////////////////////////////////////////// +void DetectorManager::AddDetector(string DetectorName , VDetector* newDetector){ + m_Detector[DetectorName] = newDetector; + newDetector->AddParameterToCalibrationManager(); +} ///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::AddDetector(string DetectorName , VDetector* newDetector) -{ - m_Detector[DetectorName] = newDetector; - newDetector->AddParameterToCalibrationManager(); +VDetector* DetectorManager::GetDetector(string name){ + map<string,VDetector*>::iterator it; + it = m_Detector.find(name); + if ( it!=m_Detector.end() ) return it->second; + else{ + cout << endl; + cout << "********************************** Error **********************************" << endl; + cout << " No Detector " << name << " found in the Detector Manager" << endl; + cout << "***************************************************************************************" << endl; + cout << endl; + exit(1); + } + } ///////////////////////////////////////////////////////////////////////////////////////////////// -VDetector* DetectorManager::GetDetector(string name) -{ - map<string,VDetector*>::iterator it; - it = m_Detector.find(name); - if ( it!=m_Detector.end() ) return it->second; - else{ - cout << endl; - cout << "********************************** Error **********************************" << endl; - cout << " No Detector " << name << " found in the Detector Manager" << endl; - cout << "***************************************************************************************" << endl; - cout << endl; - exit(1); - } - +void DetectorManager::ClearEventPhysics(){ + map<string,VDetector*>::iterator it; + + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) + it->second->ClearEventPhysics(); + } ///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::ClearEventPhysics() -{ - map<string,VDetector*>::iterator it; +void DetectorManager::ClearEventData(){ + map<string,VDetector*>::iterator it; - for (it = m_Detector.begin(); it != m_Detector.end(); ++it) { - it->second->ClearEventPhysics(); - } + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) + it->second->ClearEventData(); + } +///////////////////////////////////////////////////////////////////////////////////////////////// +void DetectorManager::InitSpectra(){ + map<string,VDetector*>::iterator it; + for (it = m_Detector.begin(); it != m_Detector.end(); ++it) + it->second->InitSpectra(); +} -///////////////////////////////////////////////////////////////////////////////////////////////// -void DetectorManager::ClearEventData() +///////////////////////////////////////////////////////////////////////////////////////////////// +vector< map< vector<TString>, TH1* > > DetectorManager::GetSpectra() { - map<string,VDetector*>::iterator it; + vector< map< vector<TString>, TH1* > > myVector; + map<string,VDetector*>::iterator it; + // loop on detectors for (it = m_Detector.begin(); it != m_Detector.end(); ++it) { - it->second->ClearEventData(); + myVector.push_back(it->second->GetSpectra()); } + + return myVector; } - diff --git a/NPLib/VDetector/DetectorManager.h b/NPLib/VDetector/DetectorManager.h index 84f12df13057d5bcba033d99a28efb94711c465b..137bc7539710284710ad7fca60ad02b21ae922ef 100644 --- a/NPLib/VDetector/DetectorManager.h +++ b/NPLib/VDetector/DetectorManager.h @@ -23,60 +23,64 @@ // NPL #include "VDetector.h" +// ROOT +#include "TH1.h" +#include "TString.h" + // STL #include <string> #include <map> - using namespace std ; + using namespace NPA ; // This class manage a map of virtual detector -namespace NPA - { - class DetectorManager - { - public: - DetectorManager(); - ~DetectorManager(); +namespace NPA{ + class DetectorManager{ + public: + DetectorManager(); + ~DetectorManager(); - public: - // Read stream at Path and pick-up Token declaration of Detector - void ReadConfigurationFile(string Path); - void BuildPhysicalEvent(); - void BuildSimplePhysicalEvent(); - void InitializeRootInput(); - void InitializeRootOutput(); - void AddDetector(string,VDetector*); - VDetector* GetDetector(string); - void ClearEventPhysics(); - void ClearEventData(); + public: + // Read stream at Path and pick-up Token declaration of Detector + void ReadConfigurationFile(string Path); + void BuildPhysicalEvent(); + void BuildSimplePhysicalEvent(); + void InitializeRootInput(); + void InitializeRootOutput(); + void AddDetector(string,VDetector*); + VDetector* GetDetector(string); + void ClearEventPhysics(); + void ClearEventData(); + void InitSpectra(); + vector< map< vector<TString>, TH1* > > GetSpectra(); - private: - // The map containning all detectors - // Using a Map one can access to any detector using its name - map<string,VDetector*> m_Detector; + private: + // The map containning all detectors + // Using a Map one can access to any detector using its name + map<string,VDetector*> m_Detector; - // Special treatment for the target for the moment - // If necessary we should change it to treat it as - // a full "detector" - private: - double m_TargetThickness; - double m_TargetAngle; - double m_TargetRadius; - string m_TargetMaterial; - double m_TargetX; - double m_TargetY; - double m_TargetZ; + // Special treatment for the target for the moment + // If necessary we should change it to treat it as + // a full "detector" + private: + double m_TargetThickness; + double m_TargetAngle; + double m_TargetRadius; + string m_TargetMaterial; + double m_TargetX; + double m_TargetY; + double m_TargetZ; - public: - double GetTargetThickness() {return m_TargetThickness;} - string GetTargetMaterial() {return m_TargetMaterial;} - double GetTargetRadius() {return m_TargetRadius;} - double GetTargetAngle() {return m_TargetAngle;} - double GetTargetX() {return m_TargetX;} - double GetTargetY() {return m_TargetY;} - double GetTargetZ() {return m_TargetZ;} - }; - } + public: + double GetTargetThickness() {return m_TargetThickness;} + string GetTargetMaterial() {return m_TargetMaterial;} + double GetTargetRadius() {return m_TargetRadius;} + double GetTargetAngle() {return m_TargetAngle;} + double GetTargetX() {return m_TargetX;} + double GetTargetY() {return m_TargetY;} + double GetTargetZ() {return m_TargetZ;} + }; +} #endif diff --git a/NPLib/VDetector/VDetector.h b/NPLib/VDetector/VDetector.h index e8975008337146564ea336bdc5babe1897ed0bf4..6d36b74b11e354f5b1401c5e4f86d5b9bde31681 100644 --- a/NPLib/VDetector/VDetector.h +++ b/NPLib/VDetector/VDetector.h @@ -12,7 +12,7 @@ * Original Author : Adrien MATTA contact address: matta@ipno.in2p3.fr * * * * Creation Date : June 2009 * - * Last update : * + * Last update : Nov 2013 * *---------------------------------------------------------------------------* * Decription: Class VDetector (virtual) for NPAnalysis * * All detector class used in NPAnalysis should derived from this virtual * @@ -22,78 +22,95 @@ *---------------------------------------------------------------------------* * Comment: * * See MUST2 array for exemple of VDetector derived class * - * * + * * + * Adding Fill Spectra Method to fill control Histogramm * *****************************************************************************/ + +// ROOT headers +#include "TH1.h" + // STL header #include <string> +#include <vector> +#include <map> using namespace std; -namespace NPA - { - - class VDetector - { - public: - - // Default Constructor and destructor - VDetector() ; - virtual ~VDetector() ; - - // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token - virtual void ReadConfiguration(string) {} ; - - // Add Parameter to the CalibrationManger - virtual 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 - virtual 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 - virtual void InitializeRootInputPhysics() {} ; - - // Create associated branches and associated private member DetectorPhysics address - virtual 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. - virtual 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. - virtual void BuildSimplePhysicalEvent() {} ; - - // Those two method all to clear the Event Physics or Data - virtual void ClearEventPhysics() {} ; - virtual void ClearEventData() {} ; - - private: // The list below is here to help you building your own detector - /* - // GRU and Simulated Tree output are made of Data Object wich contain all the RAW parameter output by Detectors during an experiment. - // You need to add a pointer to those kind of object in order to received data from the Tree at each getEntry call. Just replace Detector - // by your Detector name, like Must2Data for Must2 - - DetectorData* EventData ; - - // Aime of analysis is to treat those raw data and output some physical data, during this process, Raw data will be calibrated, threshold applied, - // and whatever you need to do. Those Physical data are output in a DetectorPhysics object, attached in the output Tree - - DetectorPhysics* EventPhysics ; - - // Position of detector: An array which held geometric information of detector, such as Strip position,... - // Dimension must be suited for your need - - vector< vector <double > > DetectorPosition ; - - // Calibration are passed to the EventPhysics Object, so you don't need to store them here - - nothing noCalibration ; - - */ - - }; - - } +namespace NPA { + + class VDetector{ + public: + + // Default Constructor and destructor + VDetector() ; + virtual ~VDetector() ; + + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + virtual void ReadConfiguration(string) {} ; + + // Add Parameter to the CalibrationManger + virtual 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 + virtual 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 + virtual void InitializeRootInputPhysics() {} ; + + // Create associated branches and associated private member DetectorPhysics address + virtual 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. + virtual 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. + virtual void BuildSimplePhysicalEvent() {} ; + + // Those two method all to clear the Event Physics or Data + virtual void ClearEventPhysics() {} ; + virtual void ClearEventData() {} ; + + // Method related to the TSpectra classes, aimed at providing a framework for online applications + // Instantiate the Spectra class and the histogramm throught it + virtual void InitSpectra() {}; + // Fill the spectra hold by the spectra class + virtual void FillSpectra() {}; + // Used for Online mainly, perform check on the histo and for example change their color if issues are found + virtual void CheckSpectra() {}; + // Used for Online only, clear all the spectra hold by the Spectra class + virtual void ClearSpectra() {}; + // Used for Online only, get all the spectra hold by the Spectra class + virtual map< vector<TString> , TH1*> GetSpectra() {map< vector<TString>, TH1* > x; return x;}; + + private: // The list below is here to help you building your own detector + /* + // GRU and Simulated Tree output are made of Data Object wich contain all the RAW parameter output by Detectors during an experiment. + // You need to add a pointer to those kind of object in order to received data from the Tree at each getEntry call. Just replace Detector + // by your Detector name, like Must2Data for Must2 + + DetectorData* EventData ; + + // Aime of analysis is to treat those raw data and output some physical data, during this process, Raw data will be calibrated, threshold applied, + // and whatever you need to do. Those Physical data are output in a DetectorPhysics object, attached in the output Tree + + DetectorPhysics* EventPhysics ; + + // Position of detector: An array which held geometric information of detector, such as Strip position,... + // Dimension must be suited for your need + + vector< vector <double > > DetectorPosition ; + + // Calibration are passed to the EventPhysics Object, so you don't need to store them here + + nothing noCalibration ; + +*/ + + }; + +} #endif diff --git a/NPSimulation/Makefile b/NPSimulation/Makefile index 10c08a528aa629a5b7c9381fcf384f39b43766da..a2c7acc85650b1ed93aec0a69d81de90d568f5f4 100644 --- a/NPSimulation/Makefile +++ b/NPSimulation/Makefile @@ -12,7 +12,7 @@ DelIncSrcFiles: ./scripts/deletefiles.sh NPSimulation: - make -j -f Makefile.geant4 + make -j 10 -f Makefile.geant4 clean: ./scripts/deletefiles.sh diff --git a/NPSimulation/Tiara/Tiara.cc b/NPSimulation/Tiara/Tiara.cc index f9f8a4c2100b89675673f04305928e44cd6a1fcb..ed5d32bbc83dcffdd78736698e8505ecb2291fa3 100644 --- a/NPSimulation/Tiara/Tiara.cc +++ b/NPSimulation/Tiara/Tiara.cc @@ -28,7 +28,8 @@ #include "G4Tubs.hh" #include "G4Cons.hh" #include "G4UnionSolid.hh" - +#include "G4ExtrudedSolid.hh" +#include "G4TwoVector.hh" //G4 sensitive #include "G4SDManager.hh" @@ -60,7 +61,7 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... Tiara::Tiara(){ - //InitializeMaterial(); + InitializeMaterial(); m_EventBarrel = new TTiaraBarrelData(); m_EventHyball = new TTiaraHyballData(); @@ -72,9 +73,15 @@ Tiara::Tiara(){ PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; // Light Grey FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; - + // Light Blue + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.0, 0.8, 0.9)) ; } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... Tiara::~Tiara(){ + delete m_MaterialSilicon; + delete m_MaterialAl; + delete m_MaterialVacuum; + delete m_MaterialPCB; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -82,47 +89,47 @@ Tiara::~Tiara(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method void Tiara::ReadConfiguration(string Path){ -/* ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - + /* ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; - while (!ConfigFile.eof()){ - int VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); - - getline(ConfigFile, LineBuffer); - // cout << LineBuffer << endl; - if (LineBuffer.compare(0, 5, "Tiara") == 0) - ReadingStatus = true; - - while (ReadingStatus && !ConfigFile.eof()) { - ConfigFile >> DataBuffer ; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - // Tiara Chamber - if (DataBuffer=="TiaraChambe="){ - if(VerboseLevel==1) G4cout << "///" << G4endl ; - if(VerboseLevel==1) G4cout << "Chamber Found:: " << G4endl ; - bool bool_Chamber; - ConfigFile >> bool_Chamber; - } - - // Barrel case - else if (DataBuffer=="TiaraBarrel"){ - if(VerboseLevel==1) G4cout << "///" << G4endl ; - if(VerboseLevel==1) G4cout << "Barrel found: " << G4endl ; - // ReadingStatusBOX = true ; - } - - // Hyball case - else if (DataBuffer=="TiaraHyball") - if(VerboseLevel==1) G4cout << "///" << G4endl ; - if(VerboseLevel==1) G4cout << "Hyball found: " << G4endl ; - - } + + while (!ConfigFile.eof()){ + int VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); + + getline(ConfigFile, LineBuffer); + // cout << LineBuffer << endl; + if (LineBuffer.compare(0, 5, "Tiara") == 0) + ReadingStatus = true; + + while (ReadingStatus && !ConfigFile.eof()) { + ConfigFile >> DataBuffer ; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} + + // Tiara Chamber + if (DataBuffer=="TiaraChambe="){ + if(VerboseLevel==1) G4cout << "///" << G4endl ; + if(VerboseLevel==1) G4cout << "Chamber Found:: " << G4endl ; + bool bool_Chamber; + ConfigFile >> bool_Chamber; + } + + // Barrel case + else if (DataBuffer=="TiaraBarrel"){ + if(VerboseLevel==1) G4cout << "///" << G4endl ; + if(VerboseLevel==1) G4cout << "Barrel found: " << G4endl ; + // ReadingStatusBOX = true ; + } + + // Hyball case + else if (DataBuffer=="TiaraHyball") + if(VerboseLevel==1) G4cout << "///" << G4endl ; + if(VerboseLevel==1) G4cout << "Hyball found: " << G4endl ; + + } } @@ -133,15 +140,15 @@ void Tiara::ReadConfiguration(string Path){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method void Tiara::ConstructDetector(G4LogicalVolume* world){ - - - ConstructChamber(world); - + ConstructChamber(world); + ConstructInnerBarrel(world); + ConstructOuterBarrel(world); + ConstructHyball(world); } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion void Tiara::ReadSensitive(const G4Event* event){ - + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -152,6 +159,302 @@ void Tiara::InitializeScorers(){ void Tiara::InitializeRootOutput(){ } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ + // Tiara Barrel + // The Barrel is made of 8 identical resistive strip detector + // The PCB is made from a G4ExtrudeSolid, because it has beveled edge + // the pcb is a substracted volume + // the wafer goes into the hole, but a 15mm part is still covered by some PCB + // the whole things is design so the local reference is the one of the wafer + + // Start by making a full pcb + // We start by the definition of the point forming a PCB cross section + vector<G4TwoVector> PCBCrossSection; + double l1 = INNERBARREL_PCB_Thickness*0.5/tan(INNERBARREL_PCB_Bevel1_Theta); + double l2 = INNERBARREL_PCB_Thickness*0.5/tan(INNERBARREL_PCB_Bevel2_Theta); + + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.-l2,-INNERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.,0)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.-l1,INNERBARREL_PCB_Thickness*0.5)); + + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.+l1,INNERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.,0)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.+l2,-INNERBARREL_PCB_Thickness*0.5)); + + G4ExtrudedSolid* PCBFull = + new G4ExtrudedSolid("PCBFull", + PCBCrossSection, + INNERBARREL_PCB_Length/2., + G4TwoVector(0,0),1, + G4TwoVector(0,0),1); + + // A box having Wafer dimension but thicker than the PCB + // Will be used to remove material from the PCB to have space for the wafer + + // Calculate the hole shift within the PCB + G4ThreeVector HoleShift = G4ThreeVector( + 0, + 0, + INNERBARREL_PCB_Offset-(INNERBARREL_PCB_Length/2-INNERBARREL_PCB_HoleLength/2)); + + G4Box* HoleShape = new G4Box("HoleShape", + INNERBARREL_ActiveWafer_Width/2., + INNERBARREL_PCB_Thickness/2.+0.1*mm, + INNERBARREL_PCB_HoleLength/2.); + + G4Box* WaferShape = new G4Box("WaferShape", + INNERBARREL_InertWafer_Width/2., + INNERBARREL_PCB_Thickness/2., + INNERBARREL_InertWafer_Length/2.); + + // The Silicon Wafer itself + G4Box* InertWaferFull = new G4Box("InertWaferFull", + INNERBARREL_InertWafer_Width/2., + INNERBARREL_ActiveWafer_Thickness/2., + INNERBARREL_InertWafer_Length/2.); + + G4Box* ActiveWafer = new G4Box("ActiveWafer", + INNERBARREL_ActiveWafer_Width/2., + INNERBARREL_ActiveWafer_Thickness/2., + INNERBARREL_ActiveWafer_Length/2.); + + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", + INNERBARREL_ActiveWafer_Width/2., + INNERBARREL_PCB_Thickness/2., + INNERBARREL_ActiveWafer_Length/2.); + + + // Substracting the hole Shape from the Stock PCB + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, + new G4RotationMatrix,HoleShift); + + // Substracting the wafer space from the Stock PCB + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, + new G4RotationMatrix, + G4ThreeVector(0,INNERBARREL_PCB_Thickness/2.-INNERBARREL_PCB_WaferDepth,0)); + + // Substract active part from inert part of the Wafer + G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, + new G4RotationMatrix, + G4ThreeVector(0,0,0)); + + // Master Volume that encompass everything else + G4LogicalVolume* logicBarrelDetector = + new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); + logicBarrelDetector->SetVisAttributes(G4VisAttributes::Invisible); + + // Sub Volume PCB + G4LogicalVolume* logicPCB = + new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(PCBVisAtt); + + // Sub Volume Wafer + G4LogicalVolume* logicInertWafer = + new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + logicInertWafer->SetVisAttributes(GuardRingVisAtt); + + G4LogicalVolume* logicActiveWafer = + new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + logicActiveWafer->SetVisAttributes(SiliconVisAtt); + + // The Distance from target is given by half the lenght of a detector + // plus the length of a detector inclined by 45 deg. + G4double DistanceFromTarget = INNERBARREL_PCB_Width*(0.5+sin(45*deg)) ; + + for( unsigned int i = 0; i < 8; i ++){ + // Place the sub volumes in the master volume + // Last argument is the detector number, used in the scorer to get the + // revelant information + new G4PVPlacement(new G4RotationMatrix(0,0,0), + G4ThreeVector(0,0,0), + logicPCB,"Tiara_Barrel_PCB",logicBarrelDetector, + false,i+1); + + + G4ThreeVector WaferPosition(0,0.5*(INNERBARREL_PCB_Thickness-INNERBARREL_PCB_WaferDepth+INNERBARREL_ActiveWafer_Thickness),0); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + WaferPosition, + logicActiveWafer,"Barrel_Wafer", + logicBarrelDetector,false,i+1); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + WaferPosition, + logicInertWafer,"Barrel_Wafer_GuardRing", + logicBarrelDetector,false,i+1); + + + // The following build the barrel, with detector one at the top + // and going clowise looking upstrea + + // Detector are rotate by 45deg with each other + G4RotationMatrix* DetectorRotation = + new G4RotationMatrix(0*deg,0*deg,i*45*deg); + + // There center is also rotated by 45deg + G4ThreeVector DetectorPosition(0,DistanceFromTarget,0); + DetectorPosition.rotate(i*45*deg,G4ThreeVector(0,0,-1)); + + // Place the Master volume with its two daugther volume at the final place + new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), + logicBarrelDetector,"Tiara_Barrel_Detector", + world,false,i+1); + } + +} + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ + // Tiara Outer Barrel + // The outer Barrel is identical to the inner barrel but wider in terms of + // geometry. It feature four non resistive strip on the front face + + // Start by making a full pcb + // We start by the definition of the point forming a PCB cross section + vector<G4TwoVector> PCBCrossSection; + double l1 = OUTERBARREL_PCB_Thickness*0.5/tan(OUTERBARREL_PCB_Bevel1_Theta); + double l2 = OUTERBARREL_PCB_Thickness*0.5/tan(OUTERBARREL_PCB_Bevel2_Theta); + + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.-l2,-OUTERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.,0)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.-l1,OUTERBARREL_PCB_Thickness*0.5)); + + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.+l1,OUTERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.,0)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.+l2,-OUTERBARREL_PCB_Thickness*0.5)); + + G4ExtrudedSolid* PCBFull = + new G4ExtrudedSolid("PCBFull", + PCBCrossSection, + OUTERBARREL_PCB_Length/2., + G4TwoVector(0,0),1, + G4TwoVector(0,0),1); + + // A box having Wafer dimension but thicker than the PCB + // Will be used to remove material from the PCB to have space for the wafer + + // Calculate the hole shift within the PCB + G4ThreeVector HoleShift = G4ThreeVector( + 0, + 0, + OUTERBARREL_PCB_Offset-(OUTERBARREL_PCB_Length/2-OUTERBARREL_PCB_HoleLength/2)); + + G4Box* HoleShape = new G4Box("HoleShape", + OUTERBARREL_ActiveWafer_Width/2., + OUTERBARREL_PCB_Thickness/2.+0.1*mm, + OUTERBARREL_PCB_HoleLength/2.); + + G4Box* WaferShape = new G4Box("WaferShape", + OUTERBARREL_InertWafer_Width/2., + OUTERBARREL_PCB_Thickness/2., + OUTERBARREL_InertWafer_Length/2.); + + // The Silicon Wafer itself + G4Box* InertWaferFull = new G4Box("InertWaferFull", + OUTERBARREL_InertWafer_Width/2., + OUTERBARREL_ActiveWafer_Thickness/2., + OUTERBARREL_InertWafer_Length/2.); + + G4Box* ActiveWafer = new G4Box("ActiveWafer", + OUTERBARREL_ActiveWafer_Width/2., + OUTERBARREL_ActiveWafer_Thickness/2., + OUTERBARREL_ActiveWafer_Length/2.); + + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", + OUTERBARREL_ActiveWafer_Width/2., + OUTERBARREL_PCB_Thickness/2., + OUTERBARREL_ActiveWafer_Length/2.); + + + // Substracting the hole Shape from the Stock PCB + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, + new G4RotationMatrix,HoleShift); + + // Substracting the wafer space from the Stock PCB + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, + new G4RotationMatrix, + G4ThreeVector(0,OUTERBARREL_PCB_Thickness/2.-OUTERBARREL_PCB_WaferDepth,0)); + + // Substract active part from inert part of the Wafer + G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, + new G4RotationMatrix, + G4ThreeVector(0,0,0)); + + // Master Volume that encompass everything else + G4LogicalVolume* logicBarrelDetector = + new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); + logicBarrelDetector->SetVisAttributes(G4VisAttributes::Invisible); + + // Sub Volume PCB + G4LogicalVolume* logicPCB = + new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(PCBVisAtt); + + // Sub Volume Wafer + G4LogicalVolume* logicInertWafer = + new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + logicInertWafer->SetVisAttributes(GuardRingVisAtt); + + G4LogicalVolume* logicActiveWafer = + new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + logicActiveWafer->SetVisAttributes(SiliconVisAtt); + + // The Distance from target is given by half the lenght of a detector + // plus the length of a detector inclined by 45 deg. + G4double DistanceFromTarget = OUTERBARREL_PCB_Width*(0.5+sin(45*deg)) ; + + for( unsigned int i = 0; i < 8; i ++){ + // Place the sub volumes in the master volume + // Last argument is the detector number, used in the scorer to get the + // revelant information + new G4PVPlacement(new G4RotationMatrix(0,0,0), + G4ThreeVector(0,0,0), + logicPCB,"Tiara_Barrel_PCB",logicBarrelDetector, + false,i+1); + + + G4ThreeVector WaferPosition(0,0.5*(OUTERBARREL_PCB_Thickness-OUTERBARREL_PCB_WaferDepth+OUTERBARREL_ActiveWafer_Thickness),0); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + WaferPosition, + logicActiveWafer,"Barrel_Wafer", + logicBarrelDetector,false,i+1); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), + WaferPosition, + logicInertWafer,"Barrel_Wafer_GuardRing", + logicBarrelDetector,false,i+1); + + + // The following build the barrel, with detector one at the top + // and going clowise looking upstrea + + // Detector are rotate by 45deg with each other + G4RotationMatrix* DetectorRotation = + new G4RotationMatrix(0*deg,0*deg,i*45*deg); + + // There center is also rotated by 45deg + G4ThreeVector DetectorPosition(0,DistanceFromTarget,0); + DetectorPosition.rotate(i*45*deg,G4ThreeVector(0,0,-1)); + + // Place the Master volume with its two daugther volume at the final place + new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), + logicBarrelDetector,"Tiara_Barrel_Detector", + world,false,i+1); + } + +} + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Tiara::ConstructHyball(G4LogicalVolume* world){ + +// TO BE DONE // + +// Put the needed geometry parameter definition here instead of the namespace +// to facilitate the merge +// Respect Naming convention: example HYBALL_PCB_Radius / HYBALL_ActiveWafer_Radius +} + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Tiara::ConstructChamber(G4LogicalVolume* world){ // Vaccum Chamber of Tiara @@ -161,22 +464,6 @@ void Tiara::ConstructChamber(G4LogicalVolume* world){ // Hyball is hold on a back plate that close the Diabolo Shaped Chamber - // Geometry Information to be moved in Tiara Name Space // - // Central Tube - G4double CHAMBER_CentralTube_Inner_Radius = 4.86*cm; //4.05->Original Value for the Single stage barrel - G4double CHAMBER_CentralTube_Outer_Radius = 5.05*cm; //4.25->Original Value for the Single stage barrel - G4double CHAMBER_CentralTube_Length = 4.12*cm; - - // Outer Cone - G4double CHAMBER_OuterCone_Length = 4.94*cm; - G4double CHAMBER_OuterCone_Z_Pos = 9.06*cm; - - // Outer Cylinder - G4double CHAMBER_OuterCylinder_Inner_Radius = 24.6*cm; - G4double CHAMBER_OuterCylinder_Outer_Radius = 25.0*cm; - G4double CHAMBER_OuterCylinder_Length = 6.04*cm; - G4double CHAMBER_OuterCylinder_Z_Pos = 19.96*cm; - // Material to be moved in a Material Function // // Al G4double density = 2.702*g/cm3; @@ -187,62 +474,96 @@ void Tiara::ConstructChamber(G4LogicalVolume* world){ // We make the individual pieces, starting from the inside to the outside // Then we merge them together using the a G4AdditionSolid // The whole chamber is then placed - + // Central Tube G4Tubs* solidCentralTube = new G4Tubs("TiaraChamberCentralTube",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_CentralTube_Length, - 0*deg,360*deg); - + CHAMBER_CentralTube_Outer_Radius,CHAMBER_CentralTube_Length/2., + 0*deg,360*deg); + // Forward-Backward Cones G4Cons* solidOuterCone = new G4Cons("TiaraChamberOuterCone",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCone_Length, - 0*deg,360*deg); - + CHAMBER_CentralTube_Outer_Radius,CHAMBER_OuterCylinder_Inner_Radius, + CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCone_Length/2., + 0*deg,360*deg); + // Outer Cylinder G4Tubs* solidOuterCylinder = new G4Tubs("TiaraChamberOuterCylinder",CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCylinder_Length, - 0*deg,360*deg); + CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCylinder_Length/2., + 0*deg,360*deg); // Add the volume together G4UnionSolid* solidTiaraChamberStep1 = new G4UnionSolid("TiaraChamber", solidCentralTube, solidOuterCone, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCone_Z_Pos)); + new G4RotationMatrix, + G4ThreeVector(0,0,CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidTiaraChamberStep2 = new G4UnionSolid("TiaraChamber", solidTiaraChamberStep1, solidOuterCone, - new G4RotationMatrix(0,180*deg,0), - G4ThreeVector(0,0,-CHAMBER_OuterCone_Z_Pos)); - + new G4RotationMatrix(0,180*deg,0), + G4ThreeVector(0,0,-CHAMBER_OuterCone_Z_Pos)); + G4UnionSolid* solidTiaraChamberStep3 = new G4UnionSolid("TiaraChamber", solidTiaraChamberStep2, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCylinder_Z_Pos)); + new G4RotationMatrix, + G4ThreeVector(0,0,CHAMBER_OuterCylinder_Z_Pos)); G4UnionSolid* solidTiaraChamberStep4 = new G4UnionSolid("TiaraChamber", solidTiaraChamberStep3, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,-CHAMBER_OuterCylinder_Z_Pos)); + new G4RotationMatrix, + G4ThreeVector(0,0,-CHAMBER_OuterCylinder_Z_Pos)); - // Create Logic Volume - G4LogicalVolume* logicTiaraChamber = + // Create Logic Volume + G4LogicalVolume* logicTiaraChamber = new G4LogicalVolume(solidTiaraChamberStep4,Aluminium,"logicTiaraChamber", 0, 0, 0); - // Visual Attribute - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.6,0.6,0.6)); + // Visual Attribute + G4VisAttributes* ChamberVisAtt + = new G4VisAttributes(G4Colour(0.0,0.4,0.5)); - ChamberVisAtt->SetForceWireframe(true); - ChamberVisAtt->SetForceAuxEdgeVisible (true); - logicTiaraChamber->SetVisAttributes(ChamberVisAtt); + ChamberVisAtt->SetForceWireframe(true); + ChamberVisAtt->SetForceAuxEdgeVisible (true); + logicTiaraChamber->SetVisAttributes(ChamberVisAtt); // Place the whole chamber new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), - logicTiaraChamber,"TiaraChamber",world,false,0); + logicTiaraChamber,"TiaraChamber",world,false,0); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void Tiara::InitializeMaterial(){ + G4Element* H = new G4Element("Hydrogen" , "H" , 1 , 1.015 * g / mole); + G4Element* C = new G4Element("Carbon" , "C" , 6 , 12.011 * g / mole); + G4Element* N = new G4Element("Nitrogen" , "N" , 7 , 14.01 * g / mole); + G4Element* O = new G4Element("Oxygen" , "O" , 8 , 15.99 * g / mole); + + G4double a, z, density; + // Si + a = 28.0855 * g / mole; + density = 2.321 * g / cm3; + m_MaterialSilicon = new G4Material("Si", z = 14., a, density); + + // Al + density = 2.702 * g / cm3; + a = 26.98 * g / mole; + m_MaterialAl = new G4Material("Al", z = 13., a, density); + + // PCB (should be FR-4, I took Epoxy Molded from LISE++) + density = 1.85 * g / cm3; + m_MaterialPCB = new G4Material("PCB", density, 3); + m_MaterialPCB->AddElement(H, .475); + m_MaterialPCB->AddElement(C, .45); + m_MaterialPCB->AddElement(O, .075); + // Vacuum + density = 0.000000001 * mg / cm3; + m_MaterialVacuum = new G4Material("Vacuum", density, 2); + m_MaterialVacuum->AddElement(N, .7); + m_MaterialVacuum->AddElement(O, .3); +} + + + + diff --git a/NPSimulation/Tiara/Tiara.hh b/NPSimulation/Tiara/Tiara.hh index 76b6ff31ccbbe309b1dd46c5554409d4abc9e0a6..55ebdad918d7a1c22e2654eb2abdacb5a17fbf7d 100644 --- a/NPSimulation/Tiara/Tiara.hh +++ b/NPSimulation/Tiara/Tiara.hh @@ -50,8 +50,63 @@ namespace TIARA const G4double ResoTime = 0 ; //const G4double ResoEnergy = 0.035*MeV ;// = zzkeV of Resolution // Unit is MeV/2.35 const G4double ResoEnergy = 0.042*MeV ;// = zzkeV of Resolution // Unit is MeV/2.35 + + + // Geometric Information // + // Chanber // + // Central Tube + const G4double CHAMBER_CentralTube_Inner_Radius = 4.86*cm; //4.05->Original Value for the Single stage barrel + const G4double CHAMBER_CentralTube_Outer_Radius = 5.05*cm; //4.25->Original Value for the Single stage barrel + const G4double CHAMBER_CentralTube_Length = 8.24*cm; + + // Outer Cone + const G4double CHAMBER_OuterCone_Length = 9.88*cm; + const G4double CHAMBER_OuterCone_Z_Pos = 9.06*cm; + + // Outer Cylinder + const G4double CHAMBER_OuterCylinder_Inner_Radius = 24.6*cm; + const G4double CHAMBER_OuterCylinder_Outer_Radius = 25.0*cm; + const G4double CHAMBER_OuterCylinder_Length = 12.08*cm; + const G4double CHAMBER_OuterCylinder_Z_Pos = 19.96*cm; + + // Inner Barrel // + const G4double INNERBARREL_PCB_Length = 98.00*mm; + const G4double INNERBARREL_PCB_Width = 27.76*mm; + const G4double INNERBARREL_PCB_Thickness = 1.60*mm; + const G4double INNERBARREL_PCB_HoleLength = 82*mm; + const G4double INNERBARREL_PCB_WaferDepth = 1.1*mm; + const G4double INNERBARREL_PCB_Bevel1_Theta = 50*deg ; + const G4double INNERBARREL_PCB_Bevel2_Theta = 67.5*deg; + // offset between the edge of the PCB and the Edge of the hole + const G4double INNERBARREL_PCB_Offset = 15*mm; + const G4double INNERBARREL_ActiveWafer_Length = 94.80*mm; + const G4double INNERBARREL_ActiveWafer_Width = 24.0*mm; + const G4double INNERBARREL_ActiveWafer_Thickness =400*um; + const G4double INNERBARREL_InertWafer_Length = 97.00*mm; + const G4double INNERBARREL_InertWafer_Width = 24.80*mm; + + // Outer Barrel // + const G4double OUTERBARREL_PCB_Length = 98.00*mm; + const G4double OUTERBARREL_PCB_Width = 33.16*mm; + const G4double OUTERBARREL_PCB_Thickness = 1.60*mm; + const G4double OUTERBARREL_PCB_HoleLength = 82*mm; + const G4double OUTERBARREL_PCB_WaferDepth = 1.1*mm; + const G4double OUTERBARREL_PCB_Bevel1_Theta = 50*deg ; + const G4double OUTERBARREL_PCB_Bevel2_Theta = 67.5*deg; + // offset between the edge of the PCB and the Edge of the hole + const G4double OUTERBARREL_PCB_Offset = 15*mm; + // Different from Marc code, to be checked + const G4double OUTERBARREL_ActiveWafer_Length = 94.80*mm; + const G4double OUTERBARREL_ActiveWafer_Width = 29.4*mm; + const G4double OUTERBARREL_ActiveWafer_Thickness =700*um; + const G4double OUTERBARREL_InertWafer_Length = 97.00*mm; + const G4double OUTERBARREL_InertWafer_Width = 30.2*mm; + + + } + using namespace TIARA; class Tiara : public VDetector { @@ -68,7 +123,8 @@ public: public: // To add a box detector // Effectively construct Volume - void ConstructBarrel(G4LogicalVolume* world); + void ConstructInnerBarrel(G4LogicalVolume* world); + void ConstructOuterBarrel(G4LogicalVolume* world); void ConstructHyball(G4LogicalVolume* world); void ConstructChamber(G4LogicalVolume* world); @@ -100,20 +156,10 @@ private: TTiaraBarrelData* m_EventBarrel ; TTiaraHyballData* m_EventHyball ; - + //////////////////////////////////////////////////// - ///////////////// Scorer Related /////////////////// + /////////////////// Material /////////////////////// //////////////////////////////////////////////////// - -private: - // Initialize all Scorer - void InitializeScorers() ; - - // Scorer Associate to the Silicon - G4MultiFunctionalDetector* m_BOXScorer ; - G4MultiFunctionalDetector* m_PADScorer ; - G4MultiFunctionalDetector* m_QQQScorer ; - private: // Initialize material used in detector definition void InitializeMaterial(); @@ -123,7 +169,20 @@ private: G4Material* m_MaterialAl ; G4Material* m_MaterialVacuum ; G4Material* m_MaterialPCB ; + + //////////////////////////////////////////////////// + ///////////////// Scorer Related /////////////////// + //////////////////////////////////////////////////// + +private: + // Initialize all Scorer + void InitializeScorers() ; + // Scorer Associate with the Silicon + G4MultiFunctionalDetector* m_InnerBarrelScorer ; + G4MultiFunctionalDetector* m_OuterBarrelScorer ; + G4MultiFunctionalDetector* m_HyballScorer ; + //////////////////////////////////////////////////// ///////////////Private intern Data////////////////// //////////////////////////////////////////////////// @@ -152,6 +211,7 @@ private:/// Visualisation Attribute: G4VisAttributes* PADVisAtt ; // Light Grey G4VisAttributes* FrameVisAtt ; - + // Light Blue + G4VisAttributes* GuardRingVisAtt ; }; #endif diff --git a/NPSimulation/include/ResistiveStripScorers.hh b/NPSimulation/include/ResistiveStripScorers.hh new file mode 100644 index 0000000000000000000000000000000000000000..55f75cba749cb152114eb7c93fc8deedf7c8eb85 --- /dev/null +++ b/NPSimulation/include/ResistiveStripScorers.hh @@ -0,0 +1,76 @@ +#ifndef SharcScorers_h +#define SharcScorers_h 1 +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@ipno.in2p3.fr * + * * + * Creation Date : February 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * File old the scorer specific to the Sharc Detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * This new style of scorer is aim to become the standard way of doing scorer* + * in NPTool. * + *The index is build using the TrackID, Detector Number and Strip Number. * + *The scorer Hold Energy and time together * + *Only one scorer is needed for a detector * + *****************************************************************************/ +#include "G4VPrimitiveScorer.hh" +#include "G4THitsMap.hh" + +#include <map> +using namespace std; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class PS_Silicon_Resistive : public G4VPrimitiveScorer{ + + public: // with description + PS_Silicon_Resistive(G4String name, + G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripWidth,G4int depth=0); + + ~PS_Silicon_Resistive(); + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); + + private: // Threshold + G4double m_TriggerThreshold; + + private: // Geometry of the detector + G4double m_StripPlaneLength; + G4double m_StripPlaneWidth; + G4int m_NumberOfStripWidth; + G4double m_StripPitchWidth; + + private: // inherited from G4VPrimitiveScorer + G4int HCID; + G4THitsMap<G4double*>* EvtMap; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector m_Position ; + G4int m_DetectorNumber ; + G4int m_StripWidthNumber ; + G4int m_Index ; + +}; + + +#endif diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc index 6aaaf7bb8c3a397293b0ef144b516d556238eee0..dbc6c65a41ed7488386b0a3808df8add5a6a7b94 100644 --- a/NPSimulation/src/DetectorConstruction.cc +++ b/NPSimulation/src/DetectorConstruction.cc @@ -755,7 +755,7 @@ void DetectorConstruction::ReadConfigurationFile(string Path){ if(m_Target==NULL){ cout << "ERROR: No target define in detector file. Cannot perform simulation without target" << endl ; - exit(-1); + exit(1); } return ; diff --git a/NPSimulation/src/ParticleStack.cc b/NPSimulation/src/ParticleStack.cc index ec29658c4eb173ce4de90f9becbc05f26f300c69..5f036fa36f369c14bb4eb911479ff123759c0b71 100644 --- a/NPSimulation/src/ParticleStack.cc +++ b/NPSimulation/src/ParticleStack.cc @@ -109,7 +109,7 @@ void ParticleStack::AddBeamParticleToStack(Particle& particle){ m_InitialConditions-> SetIncidentFinalKineticEnergy (particle. GetParticleKineticEnergy()); m_InitialConditions-> SetIncidentPositionX (particle. GetParticlePosition().x()); m_InitialConditions-> SetIncidentPositionY (particle. GetParticlePosition().y()); - m_InitialConditions-> SetIncidentPositionZ (particle. GetParticlePosition().x()); + m_InitialConditions-> SetIncidentPositionZ (particle. GetParticlePosition().z()); m_First=false; } @@ -248,4 +248,4 @@ void ParticleStack::ShootAllParticle(G4Event* anEvent){ } m_ParticleStack.clear(); m_First=true; -} \ No newline at end of file +} diff --git a/NPSimulation/src/ResistiveStripScorers.cc b/NPSimulation/src/ResistiveStripScorers.cc new file mode 100644 index 0000000000000000000000000000000000000000..c32d97472160dcd2dc82ef5cafb44a8c3e8c9d4e --- /dev/null +++ b/NPSimulation/src/ResistiveStripScorers.cc @@ -0,0 +1,121 @@ + /**************************************************************************** + * 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 : December 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Generic scorer for Resistive Strip Silicon detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * Energy Sharing and Balistic deficit effect. * + * * + *****************************************************************************/ +#include "ResistiveStripScorers.hh" +#include "G4UnitsTable.hh" + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +PS_Silicon_Resistive::PS_Silicon_Resistive(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripWidth,G4int depth) +:G4VPrimitiveScorer(name, depth),HCID(-1){ + m_StripPlaneLength = StripPlaneLength; + m_StripPlaneWidth = StripPlaneWidth; + m_NumberOfStripWidth = NumberOfStripWidth; + m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; + + m_Position = G4ThreeVector(-1000,-1000,-1000); + m_DetectorNumber = -1; + m_StripWidthNumber = -1; + m_Index = -1 ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +PS_Silicon_Resistive::~PS_Silicon_Resistive(){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4bool PS_Silicon_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*){ + + // contain Energy Total, E1, E2, Time, DetNbr, and StripWidth + G4double* EnergyAndTime = new G4double[10]; + EnergyAndTime[0] = aStep->GetTotalEnergyDeposit(); + + EnergyAndTime[1] = aStep->GetPreStepPoint()->GetGlobalTime(); + + m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(0); + m_Position = aStep->GetPreStepPoint()->GetPosition(); + + // Interaction coordinates (used to fill the InteractionCoordinates branch) + EnergyAndTime[5] = m_Position.x(); + EnergyAndTime[6] = m_Position.y(); + EnergyAndTime[7] = m_Position.z(); + EnergyAndTime[8] = m_Position.theta(); + EnergyAndTime[9] = m_Position.phi(); + + m_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(m_Position); + + m_StripWidthNumber = (int)((m_Position.y() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + m_StripWidthNumber = m_NumberOfStripWidth - m_StripWidthNumber + 1 ; + + EnergyAndTime[2] = m_DetectorNumber; + EnergyAndTime[4] = m_StripWidthNumber; + + //Rare case where particle is close to edge of silicon plan + if (m_StripWidthNumber > m_NumberOfStripWidth) m_StripWidthNumber = m_NumberOfStripWidth; + + m_Index = aStep->GetTrack()->GetTrackID() + m_DetectorNumber * 1e3 + m_StripWidthNumber * 1e6; + + // Check if the particle has interact before, if yes, add up the energies. + map<G4int, G4double**>::iterator it; + it= EvtMap->GetMap()->find(m_Index); + if(it!=EvtMap->GetMap()->end()){ + G4double* dummy = *(it->second); + EnergyAndTime[0]+=dummy[0]; + } + + EvtMap->set(m_Index, EnergyAndTime); + return TRUE; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_Silicon_Resistive::Initialize(G4HCofThisEvent* HCE){ + EvtMap = new G4THitsMap<G4double*>(GetMultiFunctionalDetector()->GetName(), GetName()); + if (HCID < 0) { + HCID = GetCollectionID(0); + } + HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_Silicon_Resistive::EndOfEvent(G4HCofThisEvent*){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_Silicon_Resistive::clear(){ + std::map<G4int, G4double**>::iterator MapIterator; + for (MapIterator = EvtMap->GetMap()->begin() ; MapIterator != EvtMap->GetMap()->end() ; MapIterator++){ + delete *(MapIterator->second); + } + + EvtMap->clear(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_Silicon_Resistive::DrawAll(){ + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_Silicon_Resistive::PrintAll(){ + G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl ; + G4cout << " PrimitiveScorer " << GetName() << G4endl ; + G4cout << " Number of entries " << EvtMap->entries() << G4endl ; +} + diff --git a/NPSimulation/src/Target.cc b/NPSimulation/src/Target.cc index 1ccdaa85d4b3c7878ffd615de642b4c4eaca286e..8b80e8194546c366f63b9ed796ed9084a3a6db43 100644 --- a/NPSimulation/src/Target.cc +++ b/NPSimulation/src/Target.cc @@ -77,8 +77,14 @@ G4Material* Target::GetMaterialFromLibrary(G4String MaterialName, G4double Tempe if (MaterialName == "D2") { G4double density = 0; - - if (Pressure == 1) { + + if(Pressure == 0 ) + if (Temperature == 0) { + density = 0.000083771* g / cm3; + G4cout << "CryoTarget temp set to 300K with P = 1bar" << G4endl; + } + + else if (Pressure == 1) { G4cout << "CryoTarget pressure set to 1 bar" << G4endl; if (Temperature == 24) { @@ -101,6 +107,12 @@ G4Material* Target::GetMaterialFromLibrary(G4String MaterialName, G4double Tempe G4cout << "CryoTarget temp set to 30K" << G4endl; } + else if (Temperature == 300) { + density = 8.3771e-5* g / cm3; + G4cout << "CryoTarget temp set to 30K" << G4endl; + } + + else { G4cout << ">>> !!!!WARNING INVALID TEMP FOR CRYOGENIC TARGET!!!! <<<" << G4endl; }