From 598e4a5d84852e7492898c42b3633b58a1a6b151 Mon Sep 17 00:00:00 2001 From: Adrien Matta <matta@lpccaen.in2p3.fr> Date: Fri, 21 May 2021 12:36:59 +0200 Subject: [PATCH] * Adding token for XYZ offset and inversion XY in BDC --- .../Detectors/Samurai/TSamuraiBDCPhysics.cxx | 48 ++++++++++++++----- NPLib/Detectors/Samurai/TSamuraiBDCPhysics.h | 5 ++ Projects/S034/s034.detector | 45 ++++++++--------- 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.cxx b/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.cxx index 9855830ba..75ae729ff 100644 --- a/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.cxx +++ b/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.cxx @@ -76,13 +76,14 @@ void TSamuraiBDCPhysics::BuildPhysicalEvent(){ static vector<TVector3> C ; static vector<double > W ; // weight based on D static double PosX100,PosY100,norm; - unsigned int count = 0 ; + int count = 0 ; for(auto it = m_DCHit.begin(); it!=m_DCHit.end(); it++){ // Each entry in the map is a detector det = it->first; Detector.push_back(det); PosX.push_back(0); PosY.push_back(0); + PosZ.push_back(0); ThetaX.push_back(0); PhiY.push_back(0); devX.push_back(0); @@ -194,7 +195,7 @@ void TSamuraiBDCPhysics::BuildPhysicalEvent(){ // Mean position at Z=100 PosX100/=norm; PosY100/=norm; - + for(unsigned int i = 0 ; i < size ; i++){ devX[count]+=W[i]*(C[i].X()-PosX[count])*(C[i].X()-PosX[count]); devY[count]+=W[i]*(C[i].Y()-PosY[count])*(C[i].Y()-PosY[count]); @@ -210,14 +211,25 @@ void TSamuraiBDCPhysics::BuildPhysicalEvent(){ // the Z axis PhiY[count]=(PosY100-PosY[count])/100.; Dir[count]=TVector3(PosX100-PosX[count],PosY100-PosY[count],100).Unit(); + if(m_invertX[det]) + PosX[count]*=-1; + if(m_invertY[det]) + PosY[count]*=-1; + + PosX[count]+=m_offset[det].X(); + PosY[count]+=m_offset[det].Y(); + PosZ[count]=m_offset[det].Z(); } } - if(PosX[count]==0){ - PosX[count]=-10000; - PosY[count]=-10000; - ThetaX[count]=-10000; - PhiY[count]=-10000; + if(PosX[count]==0&&PosY[count]==0){ + PosX.erase(PosX.begin()+count); + PosY.erase(PosY.begin()+count); + PosZ.erase(PosZ.begin()+count); + ThetaX.erase(ThetaX.begin()+count); + PhiY.erase(PhiY.begin()+count); + Detector.erase(Detector.begin()+count); + count--; } count++; @@ -272,6 +284,7 @@ void TSamuraiBDCPhysics::Clear(){ // Computed variable PosX.clear(); PosY.clear(); + PosZ.clear(); ThetaX.clear(); PhiY.clear(); devX.clear(); @@ -290,14 +303,23 @@ void TSamuraiBDCPhysics::ReadConfiguration(NPL::InputParser parser){ if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detector(s) found " << endl; - vector<string> token= {"XML"}; + vector<string> token= {"XML","Offset","InvertX","InvertY"}; for(unsigned int i = 0 ; i < blocks.size() ; i++){ - cout << endl << "//// Samurai BDC (" << i+1 << ")" << endl; - string xmlpath = blocks[i]->GetString("XML"); - NPL::XmlParser xml; - xml.LoadFile(xmlpath); - AddDC(std::atoi(blocks[i]->GetMainValue().c_str()),xml); + if(blocks[i]->HasTokenList(token)){ + cout << endl << "//// Samurai BDC (" << i+1 << ")" << endl; + unsigned int det = std::atoi(blocks[i]->GetMainValue().c_str()); + string xmlpath = blocks[i]->GetString("XML"); + NPL::XmlParser xml; + xml.LoadFile(xmlpath); + AddDC(det,xml); + TVector3 offset = blocks[i]->GetTVector3("Offset","mm"); + bool invertX = blocks[i]->GetInt("InvertX"); + bool invertY = blocks[i]->GetInt("InvertY"); + m_offset[det] = offset; + m_invertX[det] = invertX; + m_invertY[det] = invertY; + } } #if __cplusplus > 199711L && NPMULTITHREADING diff --git a/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.h b/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.h index 85c9c5971..bfa9c5b9d 100644 --- a/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.h +++ b/NPLib/Detectors/Samurai/TSamuraiBDCPhysics.h @@ -88,6 +88,7 @@ class TSamuraiBDCPhysics : public TObject, public NPL::VDetector{ // Computed variable std::vector<double> PosX; std::vector<double> PosY; + std::vector<double> PosZ; std::vector<double> ThetaX; std::vector<double> PhiY; std::vector<double> devX; @@ -194,6 +195,10 @@ class TSamuraiBDCPhysics : public TObject, public NPL::VDetector{ TSamuraiBDCData* m_PreTreatedData;//! TSamuraiBDCPhysics* m_EventPhysics;//! + private: // offset and inversion + std::map<unsigned int, TVector3> m_offset;//! + std::map<unsigned int, bool> m_invertX;//! + std::map<unsigned int, bool> m_invertY;//! private: // Spectra Class // TSamuraiBDCSpectra* m_Spectra; // ! diff --git a/Projects/S034/s034.detector b/Projects/S034/s034.detector index 63439949e..0702014cf 100644 --- a/Projects/S034/s034.detector +++ b/Projects/S034/s034.detector @@ -1,17 +1,30 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Target - Thickness= 18 micrometer - Radius= 30 mm - Material= CD2 - Angle= 0 deg - X= 0 mm - Y= 0 mm - Z= 0 mm -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SAMURAIBDC 1 XML= db/SAMURAIBDC1.xml + Offset= 0 0 0 mm + InvertX= 0 + InvertY= 0 + +%%%%%%%%%%%% SAMURAIBDC 2 XML= db/SAMURAIBDC2.xml + Offset= 0 0 0 mm + InvertX= 0 + InvertY= 0 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Minos + Position= 0 0 0 mm + ZRotation= 35 deg + TargetLength= 152.76 mm + TargetMaterial= LH2 + CellMaterial= Mylar + TPCOnly= 0 + TimeBin= 30 ns + ShapingTime= 333.9 ns + BaseLine= 250 + Sampling= 10 + XML= db/MINOS.xml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SAMURAIFDC2 XML= db/SAMURAIFDC2.xml @@ -21,16 +34,4 @@ SAMURAIFDC0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SAMURAIHOD XML= db/SAMURAIHOD_s034_all40mV_s037_20170702.xml -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%Minos -% Position= 0 0 0 mm -% ZRotation= 35 deg -% TargetLength= 152.76 mm -% TargetMaterial= LH2 -% CellMaterial= Mylar -% TPCOnly= 0 -% TimeBin= 30 ns -% ShapingTime= 333.9 ns -% BaseLine= 250 -% Sampling= 10 -% XML= db/MINOS.xml + -- GitLab