diff --git a/NPLib/LaBr3/Makefile b/NPLib/LaBr3/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3f597ea01fddb85e459ddd414b47a95fca60b242 --- /dev/null +++ b/NPLib/LaBr3/Makefile @@ -0,0 +1,39 @@ +include ../Makefile.arch + +#------------------------------------------------------------------------------ +SHARELIB = libLaBr3.so + +all: $(SHARELIB) +#------------------------------------------------------------------------------ +############### Detector ############## + +## LaBr3 ## +libLaBr3.so: TLaBr3Data.o TLaBr3DataDict.o TLaBr3Physics.o TLaBr3PhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +TLaBr3DataDict.cxx: TLaBr3Data.h + rootcint -f $@ -c $^ + +TLaBr3PhysicsDict.cxx: TLaBr3Physics.h + rootcint -f $@ -c $^ + +# dependances +TLaBr3Data.o: TLaBr3Data.cxx TLaBr3Data.h +TLaBr3Physics.o: TLaBr3Physics.cxx TLaBr3Physics.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/LaBr3/TLaBr3Data.cxx b/NPLib/LaBr3/TLaBr3Data.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2d8417346a59c793169c641e3c3406b04f6b5371 --- /dev/null +++ b/NPLib/LaBr3/TLaBr3Data.cxx @@ -0,0 +1,58 @@ +/***************************************************************************** + * 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 : * + *---------------------------------------------------------------------------* + * Decription: * + * * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include <iostream> +#include "TLaBr3Data.h" + + +ClassImp(TLaBr3Data) + +TLaBr3Data::TLaBr3Data() +{ +} + + + +TLaBr3Data::~TLaBr3Data() +{ +} + + + +void TLaBr3Data::Clear() +{ + fLaBr3_Energy.clear(); + fLaBr3_Number.clear(); + fLaBr3_Time.clear(); +} + + + +void TLaBr3Data::Dump() const +{ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event XXXXXXXXXXXXXXXXX" << endl; + + for(unsigned short i = 0 ; i<fLaBr3_Energy.size() ; i ++) + { + cout << "LaBr3 Number " << fLaBr3_Number[i] << " Energy: " << fLaBr3_Energy[i] << " Time: "<< fLaBr3_Time[i] << endl; + + } + +} diff --git a/NPLib/LaBr3/TLaBr3Data.h b/NPLib/LaBr3/TLaBr3Data.h new file mode 100644 index 0000000000000000000000000000000000000000..7eb32a6e03c180fc35e0f5c0df4c0f4c915ffa7f --- /dev/null +++ b/NPLib/LaBr3/TLaBr3Data.h @@ -0,0 +1,69 @@ +#ifndef __LABR3DATA__ +#define __LABR3DATA__ +/***************************************************************************** + * 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: contact address: * + * * + * Creation Date : * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include <vector> + +#include "TObject.h" +using namespace std ; + + +class TLaBr3Data : public TObject { + private: + // ADC + vector<double> fLaBr3_Energy; + vector<double> fLaBr3_Time ; + vector<short> fLaBr3_Number ; + + public: + TLaBr3Data(); + virtual ~TLaBr3Data(); + + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + ///////////////////// GETTERS //////////////////////// + // (E) + double GetEnergy(int i) {return fLaBr3_Energy[i];} + // (T) + double GetTime(int i) {return fLaBr3_Time[i];} + // (N) + int GetLaBr3Number(int i) {return fLaBr3_Number[i];} + + //Mult + // E + double GetEnergyMult() {return fLaBr3_Energy.size();} + // (T) + double GetTimeMult() {return fLaBr3_Time.size();} + // (N) + int GetLaBr3NumberMult() {return fLaBr3_Number.size();} + + ///////////////////// SETTERS //////////////////////// + // (E) + void SetEnergy(double E) {fLaBr3_Energy.push_back(E);} + void SetTime(double T) {fLaBr3_Time.push_back(T);} + void SetLaBr3Number(int N) {fLaBr3_Number.push_back(N);} + // + ClassDef(TLaBr3Data,1) // LaBr3Data structure +}; + +#endif diff --git a/NPLib/LaBr3/TLaBr3Physics.cxx b/NPLib/LaBr3/TLaBr3Physics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4834f256b9dab568e8614922994f04cf108534b9 --- /dev/null +++ b/NPLib/LaBr3/TLaBr3Physics.cxx @@ -0,0 +1,298 @@ +/***************************************************************************** + * 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 2009 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LaBr3 Physics * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPL +#include "TLaBr3Physics.h" +#include "../include/RootOutput.h" +#include "../include/RootInput.h" + +// STL +#include <iostream> +#include <sstream> +#include <fstream> +#include <limits> +#include <stdlib.h> +using namespace std; + +// ROOT +#include "TChain.h" + +// tranform an integer to a string +string itoa(int value) +{ + char buffer [33]; + sprintf(buffer,"%d",value); + return buffer; +} + +ClassImp(TLaBr3Physics) +/////////////////////////////////////////////////////////////////////////// +TLaBr3Physics::TLaBr3Physics() + { + NumberOfDetector = 0 ; + EventData = new TLaBr3Data ; + EventPhysics = this ; + } + +/////////////////////////////////////////////////////////////////////////// +TLaBr3Physics::~TLaBr3Physics() + {} + +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::Clear() + { + DetectorNumber.clear() ; + Energy.clear() ; + Time.clear() ; + } + +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::ReadConfiguration(string Path) + { + ifstream ConfigFile ; + ConfigFile.open(Path.c_str()) ; + string LineBuffer ; + string DataBuffer ; + + bool check_Theta = false ; + bool check_Phi = false ; + bool check_R = false ; + bool check_Thickness = false ; + bool check_Radius = false ; + bool check_LeadThickness = false ; + bool check_Scintillator = false ; + bool check_Height = false ; + bool check_Width = false ; + bool check_Shape = false ; + bool check_X = false ; + bool check_Y = false ; + bool check_Z = false ; + bool ReadingStatus = false ; + + while (!ConfigFile.eof()) + { + + getline(ConfigFile, LineBuffer); + + // If line is a Start Up LaBr3 bloc, Reading toggle to true + if (LineBuffer.compare(0, 5, "LaBr3") == 0) + { + cout << "///" << endl ; + cout << "Platic found: " << endl ; + ReadingStatus = true ; + } + + // Else don't toggle to Reading Block Status + else ReadingStatus = false ; + + // Reading Block + while(ReadingStatus) + { + // Pickup Next Word + 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, 5, "LaBr3") == 0) { + cout << "WARNING: Another Detector is find before standard sequence of Token, Error may occured in Telecope definition" << endl ; + ReadingStatus = false ; + } + + //Angle method + else if (DataBuffer=="THETA=") { + check_Theta = true; + ConfigFile >> DataBuffer ; + cout << "Theta: " << atof(DataBuffer.c_str()) << "deg" << endl; + } + + else if (DataBuffer=="PHI=") { + check_Phi = true; + ConfigFile >> DataBuffer ; + cout << "Phi: " << atof( DataBuffer.c_str() ) << "deg" << endl; + } + + else if (DataBuffer=="R=") { + check_R = true; + ConfigFile >> DataBuffer ; + cout << "R: " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + //Position method + else if (DataBuffer=="X=") { + check_X = true; + ConfigFile >> DataBuffer ; + cout << "X: " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + else if (DataBuffer=="Y=") { + check_Y = true; + ConfigFile >> DataBuffer ; + cout << "Y: " << atof( DataBuffer.c_str() ) << "mm"<< endl; + } + + else if (DataBuffer=="Z=") { + check_Z = true; + ConfigFile >> DataBuffer ; + cout << "Z: " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + + //General + else if (DataBuffer=="Shape=") { + check_Shape = true; + ConfigFile >> DataBuffer ; + cout << "Shape: " << DataBuffer << endl; + } + + // Cylindrical shape + else if (DataBuffer== "Radius=") { + check_Radius = true; + ConfigFile >> DataBuffer ; + cout << "LaBr3 Radius: " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + // Squared shape + else if (DataBuffer=="Width=") { + check_Width = true; + ConfigFile >> DataBuffer ; + cout << "LaBr3 Width: " <<atof( DataBuffer.c_str() ) << "mm" << endl; + } + + else if (DataBuffer== "Height=") { + check_Height = true; + ConfigFile >> DataBuffer ; + cout << "LaBr3 Height: " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + // Common + else if (DataBuffer=="Thickness=") { + check_Thickness = true; + ConfigFile >> DataBuffer ; + cout << "LaBr3 Thickness: " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + else if (DataBuffer== "Scintillator=") { + check_Scintillator = true ; + ConfigFile >> DataBuffer ; + cout << "LaBr3 Scintillator type: " << DataBuffer << endl; + } + + else if (DataBuffer=="LeadThickness=") { + check_LeadThickness = true; + ConfigFile >> DataBuffer ; + cout << "Lead Thickness : " << atof( DataBuffer.c_str() ) << "mm" << endl; + } + + /////////////////////////////////////////////////// + // If no Detector Token and no comment, toggle out + else + {ReadingStatus = false; cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl ;} + + ///////////////////////////////////////////////// + // If All necessary information there, toggle out + + if ( check_Theta && check_Phi && check_R && check_Thickness && check_Radius && check_LeadThickness && check_Scintillator && check_Height && check_Width && check_Shape && check_X && check_Y && check_Z ) + { + NumberOfDetector++; + + // Reinitialisation of Check Boolean + check_Theta = false ; + check_Phi = false ; + check_R = false ; + check_Thickness = false ; + check_Radius = false ; + check_LeadThickness = false ; + check_Scintillator = false ; + check_Height = false ; + check_Width = false ; + check_Shape = false ; + check_X = false ; + check_Y = false ; + check_Z = false ; + ReadingStatus = false ; + cout << "///"<< endl ; + } + } + } + } + +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::AddParameterToCalibrationManager() + { + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < NumberOfDetector ; i++) + { + for( int j = 0 ; j < 16 ; j++) + { + Cal->AddParameter("LaBr3", "Detector"+itoa(i+1)+"_E","LaBr3_Detector"+itoa(i+1)+"_E") ; + Cal->AddParameter("LaBr3", "Detector"+itoa(i+1)+"_T","LaBr3_Detector"+itoa(i+1)+"_T") ; + } + + } + } + +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::InitializeRootInputRaw() + { + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus ( "LaBr3" , true ) ; + inputChain->SetBranchStatus ( "fLaBr3_*" , true ) ; + inputChain->SetBranchAddress( "LaBr3" , &EventData ) ; + } +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::InitializeRootInputPhysics() + { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus ( "LaBr3", true ); + inputChain->SetBranchStatus ( "DetectorNumber", true ); + inputChain->SetBranchStatus ( "Energy", true ); + inputChain->SetBranchStatus ( "Time", true ); + inputChain->SetBranchAddress( "LaBr3", &EventPhysics ); + } +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::InitializeRootOutput() + { + TTree* outputTree = RootOutput::getInstance()->GetTree() ; + outputTree->Branch( "LaBr3" , "TLaBr3Physics" , &EventPhysics ) ; + } + +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::BuildPhysicalEvent() + { + BuildSimplePhysicalEvent() ; + } + +/////////////////////////////////////////////////////////////////////////// +void TLaBr3Physics::BuildSimplePhysicalEvent() + { + for(unsigned int i = 0 ; i < EventData->GetEnergyMult() ; i++) + { + DetectorNumber.push_back( EventData->GetLaBr3Number(i) ) ; + Energy.push_back( CalibrationManager::getInstance()->ApplyCalibration("LaBr3/Detector" + itoa( EventData->GetLaBr3Number(i) ) +"_E",EventData->GetEnergy(i) ) ); + Time.push_back( CalibrationManager::getInstance()->ApplyCalibration( "LaBr3/Detector" + itoa( EventData->GetLaBr3Number(i) ) +"_T",EventData->GetTime(i) ) ); + } + + } + diff --git a/NPLib/LaBr3/TLaBr3Physics.h b/NPLib/LaBr3/TLaBr3Physics.h new file mode 100644 index 0000000000000000000000000000000000000000..8637d3d0a365e445acd5836f3cc2c30c1eaf014c --- /dev/null +++ b/NPLib/LaBr3/TLaBr3Physics.h @@ -0,0 +1,97 @@ +#ifndef __LaBr3Physics__ +#define __LaBr3Physics__ +/***************************************************************************** + * 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 2009 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold theLaBr3 Detector Physics * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std ; + +// ROOT +#include "TObject.h" + +// NPL +#include "TLaBr3Data.h" +#include "../include/VDetector.h" +#include "../include/CalibrationManager.h" + +class TLaBr3Physics : public TObject, public NPA::VDetector +{ + public: // Constructor and Destructor + TLaBr3Physics(); + ~TLaBr3Physics(); + + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: // Calibrated Data + vector<UShort_t> DetectorNumber ; + vector<Double_t> Energy; + vector<Double_t> Time; + + public: // inherrited from VDetector + // 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();}; + + // Give and external TLaBr3Data object to TLaBr3Physics. Needed for online analysis for example. + void SetRawDataPointer(TLaBr3Data* rawDataPointer) {EventData = rawDataPointer;} + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() {Clear();} + void ClearEventData() {EventData->Clear();} + + private: // Data not writted in the tree + int NumberOfDetector ;//! + TLaBr3Data* EventData ;//! + TLaBr3Physics* EventPhysics ;//! + + ClassDef(TLaBr3Physics,1) // LaBr3Physics structure +}; + +#endif