From 40d31725cb9a7f1bee2b3c0893d6e5d5efa83ccb Mon Sep 17 00:00:00 2001 From: Nicolas de Sereville <deserevi@ipno.in2p3.fr> Date: Mon, 7 Dec 2015 13:26:35 +0100 Subject: [PATCH] + Update ReadAnalysisConfig in TSplitPolePhysics with new tokens + Add calibration to SplitPole position signal (add corresponding rho spectrum) + Minor performance fix in SplitPoleNMR + Cosmetic changes in SplitPoleData --- NPAnalysis/SPcoincW1/Calibration.txt | 1 + NPAnalysis/SPcoincW1/RunToTreat.txt | 2 +- .../SPcoincW1/calibs/SplitPoleCalibration.txt | 1 + NPLib/SplitPole/TSplitPoleData.cxx | 2 +- NPLib/SplitPole/TSplitPoleData.h | 2 +- NPLib/SplitPole/TSplitPoleNMR.cxx | 32 ++-- NPLib/SplitPole/TSplitPoleNMR.h | 4 + NPLib/SplitPole/TSplitPolePhysics.cxx | 157 ++++++++++-------- NPLib/SplitPole/TSplitPolePhysics.h | 20 +-- NPLib/SplitPole/TSplitPoleSpectra.cxx | 9 + 10 files changed, 133 insertions(+), 97 deletions(-) create mode 100644 NPAnalysis/SPcoincW1/calibs/SplitPoleCalibration.txt diff --git a/NPAnalysis/SPcoincW1/Calibration.txt b/NPAnalysis/SPcoincW1/Calibration.txt index b818e0ecc..985a566db 100644 --- a/NPAnalysis/SPcoincW1/Calibration.txt +++ b/NPAnalysis/SPcoincW1/Calibration.txt @@ -2,3 +2,4 @@ CalibrationFilePath % ./calibs/W1CalibrationBefore.txt ./calibs/W1CalibrationAfter.txt ./calibs/W1CalibrationTime_runs50-74.txt + ./calibs/SplitPoleCalibration.txt diff --git a/NPAnalysis/SPcoincW1/RunToTreat.txt b/NPAnalysis/SPcoincW1/RunToTreat.txt index 3fd8d3e5e..75b09f79e 100644 --- a/NPAnalysis/SPcoincW1/RunToTreat.txt +++ b/NPAnalysis/SPcoincW1/RunToTreat.txt @@ -8,5 +8,5 @@ RootFileName % /scratch/gypaos/data/al27pp/oct2015/midas/root/R131_0_test.root % /scratch/gypaos/data/al27pp/oct2015/midas/root/R108_0_test.root /scratch/gypaos/data/al27pp/oct2015/midas/root/R74_0.root - /scratch/gypaos/data/al27pp/oct2015/midas/root/R72_0.root +% /scratch/gypaos/data/al27pp/oct2015/midas/root/R72_0.root diff --git a/NPAnalysis/SPcoincW1/calibs/SplitPoleCalibration.txt b/NPAnalysis/SPcoincW1/calibs/SplitPoleCalibration.txt new file mode 100644 index 000000000..1b07fa6b5 --- /dev/null +++ b/NPAnalysis/SPcoincW1/calibs/SplitPoleCalibration.txt @@ -0,0 +1 @@ +POSITION 6.21221e-01 1.73257e-05 diff --git a/NPLib/SplitPole/TSplitPoleData.cxx b/NPLib/SplitPole/TSplitPoleData.cxx index 5088a44e7..31712e1b7 100644 --- a/NPLib/SplitPole/TSplitPoleData.cxx +++ b/NPLib/SplitPole/TSplitPoleData.cxx @@ -53,9 +53,9 @@ void TSplitPoleData::Clear() fWire = -1; fPlasticP = -1; fPlasticG = -1; + fTick = -1; fTime1.clear(); fTime2.clear(); - fTick = -1; } diff --git a/NPLib/SplitPole/TSplitPoleData.h b/NPLib/SplitPole/TSplitPoleData.h index 970d2c2b7..2d70f3874 100644 --- a/NPLib/SplitPole/TSplitPoleData.h +++ b/NPLib/SplitPole/TSplitPoleData.h @@ -37,9 +37,9 @@ class TSplitPoleData : public TObject Double_t fWire; Double_t fPlasticP; Double_t fPlasticG; + Double_t fTick; // data from scaler vector<Double_t> fTime1; // ch 117 vector<Double_t> fTime2; // ch 126 - Double_t fTick; // data from scaler public: diff --git a/NPLib/SplitPole/TSplitPoleNMR.cxx b/NPLib/SplitPole/TSplitPoleNMR.cxx index ecf588ae6..02981098d 100644 --- a/NPLib/SplitPole/TSplitPoleNMR.cxx +++ b/NPLib/SplitPole/TSplitPoleNMR.cxx @@ -40,7 +40,9 @@ TSplitPoleNMR::TSplitPoleNMR() fIsLargeField(0), fMean(-1), fMin(10), - fMax(-1) + fMax(-1), + fTMin(0), + fTMax(0) { } @@ -56,7 +58,9 @@ TSplitPoleNMR::TSplitPoleNMR(const char* fileName) fIsLargeField(0), fMean(-1), fMin(10), - fMax(-1) + fMax(-1), + fTMin(0), + fTMax(0) { ReadRmnFile(); } @@ -73,7 +77,9 @@ TSplitPoleNMR::TSplitPoleNMR(const char* fileName, Double_t delay) fIsLargeField(0), fMean(-1), fMin(10), - fMax(-1) + fMax(-1), + fTMin(0), + fTMax(0) { ReadRmnFile(); } @@ -93,9 +99,7 @@ Int_t TSplitPoleNMR::ReadRmnFile() { ifstream in_rmn; Double_t old_x=-10.; - std::cout<<"\nReading Rmn data file: "<<fFileName<<"..."<<std::flush; -// DeleteRmnGraph(); -// fRmn= new TGraph(); +// std::cout<<"\nReading Rmn data file: "<<fFileName<<"..."<<std::flush; in_rmn.open(fFileName); if(!in_rmn.is_open()){ @@ -117,7 +121,7 @@ Int_t TSplitPoleNMR::ReadRmnFile() in_rmn>>hour;in_rmn>>ch_tmp;in_rmn>>minutes;in_rmn>>ch_tmp;in_rmn>>seconds; fOpenFileTime.Set(year,month,day,hour,minutes,seconds, 0, 1, 0); - fOpenFileTime.Print(); +// fOpenFileTime.Print(); Double_t time=fOpenFileTime.AsDouble(),x=1.,y; Int_t i=0; @@ -159,13 +163,16 @@ Int_t TSplitPoleNMR::ReadRmnFile() } in_rmn.close(); - std::cout<<" Ok!"<<std::flush; - std::cout << std::endl; +// std::cout<<" Ok!"<<std::flush; +// std::cout << std::endl; // set mean, min and max field values fMin = ymin; fMax = ymax; fMean = ymean / fRmnRelativeTime->GetN(); + // set min and max absolute time + fTMin = fRmn->GetX()[0]; + fTMax = fRmn->GetX()[fRmn->GetN()-1]; return 0; } @@ -242,12 +249,9 @@ void TSplitPoleNMR::Dump() Double_t TSplitPoleNMR::EvalB(Double_t Time) const { - if(!fRmn) return 0.; - Double_t *x; - x=fRmn->GetX(); - Int_t n= fRmn->GetN(); + if (!fRmn) return 0; - if( Time>=x[0] && Time<=x[n-1]) + if (Time >= fTMin && Time <= fTMax) return fRmn->Eval(Time); else return fRmn->GetMean(2); diff --git a/NPLib/SplitPole/TSplitPoleNMR.h b/NPLib/SplitPole/TSplitPoleNMR.h index 0e78cbbe5..ac67a1c38 100644 --- a/NPLib/SplitPole/TSplitPoleNMR.h +++ b/NPLib/SplitPole/TSplitPoleNMR.h @@ -48,6 +48,8 @@ class TSplitPoleNMR : public TObject Double_t fMean; // mean value for field Double_t fMin; // min value for field Double_t fMax; // max value for field + Double_t fTMin; // min value for absolute time + Double_t fTMax; // max value for absolute time public: @@ -65,6 +67,8 @@ class TSplitPoleNMR : public TObject Double_t GetMean() {return fMean;} Double_t GetMin() {return fMin;} Double_t GetMax() {return fMax;} + Double_t GetTMin() {return fTMin;} + Double_t GetTMax() {return fTMax;} TString GetFileName() {return fFileName;} Int_t ReadRmnFile(); diff --git a/NPLib/SplitPole/TSplitPolePhysics.cxx b/NPLib/SplitPole/TSplitPolePhysics.cxx index 200ac8343..271233d02 100644 --- a/NPLib/SplitPole/TSplitPolePhysics.cxx +++ b/NPLib/SplitPole/TSplitPolePhysics.cxx @@ -21,6 +21,7 @@ *****************************************************************************/ // NPL #include "TSplitPolePhysics.h" +using namespace SplitPole_LOCAL; // C++ headers #include <iostream> @@ -36,6 +37,7 @@ using namespace std; #include "RootOutput.h" #include "RootInput.h" #include "NPDetectorFactory.h" +#include "NPCalibrationManager.h" // ROOT #include "TChain.h" @@ -64,12 +66,10 @@ TSplitPolePhysics::TSplitPolePhysics() m_CurrentNMR(new TSplitPoleNMR), m_MagneticFieldCorrection(0), m_TimeDelay(6500), - m_CalibP0(0.65), - m_CalibP1(6e-6) + m_LargeField(0), + m_NmrFilePath("./") { Clear(); - ReadTimeTable(); - ReadNMR(); } @@ -86,12 +86,14 @@ TSplitPolePhysics::~TSplitPolePhysics() /////////////////////////////////////////////////////////////////////////// void TSplitPolePhysics::Clear() { - fPosition = -1; - fBrho = -1; - fDeltaE = -1; - fWire = -1; - fPlasticP = -1; - fPlasticG = -1; + fPosition = -1; + fBrho = -1; + fDeltaE = -1; + fWire = -1; + fPlasticP = -1; + fPlasticG = -1; + fTick = -1; + fAbsoluteTick = -1; fTime1.clear(); fTime2.clear(); } @@ -107,17 +109,13 @@ void TSplitPolePhysics::ReadConfiguration(string Path) bool ReadingStatus = false; - cout << "SP read configuration" << endl; - while (!ConfigFile.eof()) { getline(ConfigFile, LineBuffer); - cout << LineBuffer << endl; // If SplitPole detector found, toggle Reading Block Status if (LineBuffer.compare(0, 9, "SplitPole") == 0) { cout << "Detector found: " << endl; ReadingStatus = true; - return; } // else don't toggle to Reading Block Status else ReadingStatus = false; @@ -139,13 +137,19 @@ void TSplitPolePhysics::ReadConfiguration(string Path) // If no Detector Token and no comment, toggle out else { ReadingStatus = false; - cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl; +// cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl; } } } - InitializeStandardParameters(); + // read specific SplitPole configuration parameters ReadAnalysisConfig(); + + // read run time table + ReadTimeTable(); + + // read NMR files + ReadNMR(); } @@ -153,6 +157,8 @@ void TSplitPolePhysics::ReadConfiguration(string Path) /////////////////////////////////////////////////////////////////////////// void TSplitPolePhysics::ReadTimeTable() { + cout << "\tReading time table file..." << endl; + ifstream file("TimeTable.txt"); // define variables @@ -162,7 +168,7 @@ void TSplitPolePhysics::ReadTimeTable() pair<TTimeStamp, TTimeStamp> ptime; // read file - while(file >> run_narval >> run_midas >> date1 >> time1 >> date2 >> time2) { + while (file >> run_narval >> run_midas >> date1 >> time1 >> date2 >> time2) { start.Set(date1, time1, 0, 1, 0); stop.Set(date2, time2, 0, 1, 0); ptime.first = start; @@ -181,11 +187,13 @@ void TSplitPolePhysics::ReadTimeTable() /////////////////////////////////////////////////////////////////////////// void TSplitPolePhysics::ReadNMR() { + cout << "\tReading NMR files..." << endl; + // current directory where npanalysis is executed string currentpath = gSystem->Getenv("PWD"); // go to directory with all nmr files and get a list of them - TSystemDirectory libdir("libdir", "/scratch/gypaos/data/al27pp/oct2015/rmn"); + TSystemDirectory libdir("libdir", m_NmrFilePath); TList* listfile = libdir.GetListOfFiles(); // check whether directory is empty or not if (listfile->GetEntries() > 2) { @@ -199,9 +207,10 @@ void TSplitPolePhysics::ReadNMR() Int_t run = 0; // if substring is digit only if (sub.IsDigit()) { + // narval run number run = sub.Atoi(); // fill map - m_NMRTable[m_NarvalMidasTable[run]] = new TSplitPoleNMR(libname.Data()); + m_NMRTable[m_NarvalMidasTable[run]] = new TSplitPoleNMR(libname.Data(), m_TimeDelay); } } } @@ -228,6 +237,10 @@ Bool_t TSplitPolePhysics::IsSameRun() /////////////////////////////////////////////////////////////////////////// void TSplitPolePhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + + // position + Cal->AddParameter("SplitPole", "POSITION", "POSITION"); } @@ -289,37 +302,43 @@ void TSplitPolePhysics::BuildSimplePhysicalEvent() PreTreat(); // Fill TSplitPolePhysics private members - fPosition = m_EventData->GetPosition(); - fDeltaE = m_EventData->GetDeltaE(); - fWire = m_EventData->GetWire(); - fPlasticP = m_EventData->GetPlasticP(); - fPlasticG = m_EventData->GetPlasticG(); - - for (UShort_t i = 0; i < m_EventData->GetTime1Multiplicity(); ++i) { // loop on multiplicity - fTime1.push_back(m_EventData->GetTime1(i)); + fPosition = m_PreTreatedData->GetPosition(); + fDeltaE = m_PreTreatedData->GetDeltaE(); + fWire = m_PreTreatedData->GetWire(); + fPlasticP = m_PreTreatedData->GetPlasticP(); + fPlasticG = m_PreTreatedData->GetPlasticG(); + fTick = m_PreTreatedData->GetTick(); + + for (UShort_t i = 0; i < m_PreTreatedData->GetTime1Multiplicity(); ++i) { // loop on multiplicity + fTime1.push_back(m_PreTreatedData->GetTime1(i)); } // end loop on multiplicity - for (UShort_t i = 0; i < m_EventData->GetTime2Multiplicity(); ++i) { // loop on multiplicity - fTime2.push_back(m_EventData->GetTime2(i)); + for (UShort_t i = 0; i < m_PreTreatedData->GetTime2Multiplicity(); ++i) { // loop on multiplicity + fTime2.push_back(m_PreTreatedData->GetTime2(i)); } // end loop on multiplicity // Magnetic field correction // store localy run number, run start and stop times and rmn data - if (!IsSameRun()) { + Bool_t isSameRun = IsSameRun(); + if (!isSameRun) { m_CurrentRunNumber = m_RunNumber; m_RunStart = m_TimeTable[m_CurrentRunNumber].first; m_RunStop = m_TimeTable[m_CurrentRunNumber].second; m_RunLength = m_RunStop.AsDouble() - m_RunStart.AsDouble(); m_CurrentNMR = m_NMRTable[m_CurrentRunNumber]; - cout << m_CurrentRunNumber << endl; - cout << m_CurrentNMR->GetMean() << endl; } // Correct for magnetic field variation + fAbsoluteTick = m_RunStart.AsDouble() + m_PreTreatedData->GetTick()/m_FrequenceClock; if (m_MagneticFieldCorrection) { + fBrho = m_PreTreatedData->GetPlasticG() * m_CurrentNMR->EvalB(fAbsoluteTick); } else { - fBrho = (m_CalibP0 + m_CalibP1*m_EventData->GetPlasticG()) * m_CurrentNMR->GetMean(); + if (!isSameRun) { + cout << "\tSplitPole Warning!!! run " << m_CurrentRunNumber << " will be treated with mean magnetic field value " + << m_CurrentNMR->GetMean() << " T.m." << endl; + } + fBrho = m_PreTreatedData->GetPlasticG() * m_CurrentNMR->GetMean(); } } @@ -331,33 +350,21 @@ void TSplitPolePhysics::PreTreat() // Clear pre treated object ClearPreTreatedData(); - // pre treated object is the same as the raw data object -} - - - - -bool TSplitPolePhysics::IsValidChannel(string Type, int detector, int channel) -{ - return true; - -/* vector<bool>::iterator it; - if (Type == "Front") - return *(m_FrontChannelStatus[detector].begin()+channel); - - else if (Type == "Back") - return *(m_BackChannelStatus[detector].begin()+channel); - - else - return false; -*/ -} - + // Fill pre treated object + m_PreTreatedData->SetPosition(m_EventData->GetPosition()); + m_PreTreatedData->SetDeltaE(m_EventData->GetDeltaE()); + m_PreTreatedData->SetWire(m_EventData->GetWire()); + m_PreTreatedData->SetPlasticP(m_EventData->GetPlasticP()); + m_PreTreatedData->SetPlasticG(fCalibPosition(m_EventData)); + m_PreTreatedData->SetTick(m_EventData->GetTick()); + for (UShort_t i = 0; i < m_EventData->GetTime1Multiplicity(); ++i) { // loop on multiplicity + m_PreTreatedData->SetTime1(m_EventData->GetTime1(i)); + } // end loop on multiplicity -/////////////////////////////////////////////////////////////////////////// -void TSplitPolePhysics::InitializeStandardParameters() -{ + for (UShort_t i = 0; i < m_EventData->GetTime2Multiplicity(); ++i) { // loop on multiplicity + m_PreTreatedData->SetTime2(m_EventData->GetTime2(i)); + } // end loop on multiplicity } @@ -407,18 +414,6 @@ void TSplitPolePhysics::ReadAnalysisConfig() AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); } - else if (whatToDo == "CALIBRATION_P0") { - AnalysisConfigFile >> DataBuffer; - m_CalibP0 = atoi(DataBuffer.c_str()); - cout << "\t" << whatToDo << "\t" << m_CalibP0 << endl; - } - - else if (whatToDo == "CALIBRATION_P1") { - AnalysisConfigFile >> DataBuffer; - m_CalibP1 = atof(DataBuffer.c_str()); - cout << "\t" << whatToDo << "\t" << m_CalibP1 << endl; - } - else if (whatToDo == "MAGNETIC_FIELD_CORRECTION") { AnalysisConfigFile >> DataBuffer; m_MagneticFieldCorrection = false; @@ -432,6 +427,18 @@ void TSplitPolePhysics::ReadAnalysisConfig() cout << "\t" << whatToDo << "\t" << m_TimeDelay << endl; } + else if (whatToDo == "NMR_FILE_PATH") { + AnalysisConfigFile >> DataBuffer; + m_NmrFilePath = DataBuffer; + cout << "\t" << whatToDo << "\t" << m_NmrFilePath << endl; + } + + else if (whatToDo == "NMR_LARGE_FIELD") { + AnalysisConfigFile >> DataBuffer; + m_LargeField = atof(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_LargeField << endl; + } + else { ReadingStatus = false; } @@ -497,6 +504,16 @@ map<string, TH1*> TSplitPolePhysics::GetSpectra() +/////////////////////////////////////////////////////////////////////////// +namespace SplitPole_LOCAL { + Double_t fCalibPosition(const TSplitPoleData* m_EventData) + { + return CalibrationManager::getInstance()->ApplyCalibration("SplitPole/POSITION", m_EventData->GetPlasticG()); + } +} + + + //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// diff --git a/NPLib/SplitPole/TSplitPolePhysics.h b/NPLib/SplitPole/TSplitPolePhysics.h index 70b9c0eee..02bb01798 100644 --- a/NPLib/SplitPole/TSplitPolePhysics.h +++ b/NPLib/SplitPole/TSplitPolePhysics.h @@ -60,6 +60,8 @@ class TSplitPolePhysics : public TObject, public NPL::VDetector Double_t fWire; Double_t fPlasticP; Double_t fPlasticG; + Double_t fTick; + Double_t fAbsoluteTick; vector<Double_t> fTime1; vector<Double_t> fTime2; @@ -138,14 +140,6 @@ class TSplitPolePhysics : public TObject, public NPL::VDetector // Clear the pre treated object void ClearPreTreatedData() {m_PreTreatedData->Clear();} - // Return false if the channel is disabled by user - // Frist argument is either "Front" or "Back" - bool IsValidChannel(string Type, int detector, int channel); - - // Initialize the standard parameters for analysis, i.e.: all channel enable, - // maximum multiplicity for strip = number of telescope - void InitializeStandardParameters(); - // Read the user configuration file; if no file found, load standard one void ReadAnalysisConfig(); @@ -181,8 +175,8 @@ class TSplitPolePhysics : public TObject, public NPL::VDetector private: // Parameters used in the analysis Bool_t m_MagneticFieldCorrection; //! Double_t m_TimeDelay; //! - Double_t m_CalibP0; //! - Double_t m_CalibP1; //! + Double_t m_LargeField; //! + TString m_NmrFilePath; //! // methods for magnetic field correction public: // called once @@ -205,4 +199,10 @@ class TSplitPolePhysics : public TObject, public NPL::VDetector ClassDef(TSplitPolePhysics,1) // TSplitPolePhysics }; + +namespace SplitPole_LOCAL +{ + Double_t fCalibPosition(const TSplitPoleData* EventData); +} + #endif diff --git a/NPLib/SplitPole/TSplitPoleSpectra.cxx b/NPLib/SplitPole/TSplitPoleSpectra.cxx index 0a8f8168a..a4bfa9989 100644 --- a/NPLib/SplitPole/TSplitPoleSpectra.cxx +++ b/NPLib/SplitPole/TSplitPoleSpectra.cxx @@ -121,6 +121,11 @@ void TSplitPoleSpectra::InitRawSpectra() //////////////////////////////////////////////////////////////////////////////// void TSplitPoleSpectra::InitPreTreatedSpectra() { + static string name; + // POSITION + name = "SplitPole_RHO"; + AddHisto1D(name, name, 4096, 0.62, 0.85, "SplitPole/CAL"); + } @@ -207,6 +212,10 @@ void TSplitPoleSpectra::FillRawSpectra(TSplitPoleData* RawData) //////////////////////////////////////////////////////////////////////////////// void TSplitPoleSpectra::FillPreTreatedSpectra(TSplitPoleData* PreTreatedData) { + // RHO + static string index; + index = "SplitPole/CAL/SplitPole_RHO"; + GetHisto(index)->Fill(PreTreatedData->GetPlasticG()); } -- GitLab