diff --git a/NPAnalysis/newTAMU/Analysis.cxx b/NPAnalysis/newTAMU/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..276bafb7c31a7f1bdc8cdaa3fc186f47f2d749da --- /dev/null +++ b/NPAnalysis/newTAMU/Analysis.cxx @@ -0,0 +1,262 @@ +/***************************************************************************** + * Copyright (C) 2009-2014 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 : march 2025 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +#include"NPOptionManager.h" +#include"RootOutput.h" +#include"RootInput.h" +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + TH = (TTiaraHyballPhysics*) m_DetectorManager -> GetDetector("TiaraHyball"); + TB = (TTiaraBarrelPhysics*) m_DetectorManager -> GetDetector("TiaraBarrel"); + proton_CD2 = EnergyLoss("proton_CD2.G4table","G4Table",100 ); + proton_Al = EnergyLoss("proton_Al.G4table","G4Table",10); + proton_Si = EnergyLoss("proton_Si.G4table","G4Table",10); + P30_CD2 = EnergyLoss("P30[0.0]_CD2.G4table","G4Table",100); + Initial = new TInitialConditions(); + + + Rand = new TRandom3(); + ThetaNormalTarget = 0 ; + ThetaTHSurface = 0; + ThetaTBSurface = 0; + Si_E_TH = 0 ; + Si_E_TB = 0 ; + Energy = 0; + TargetThickness = m_DetectorManager->GetTargetThickness()*micrometer; + + XTarget = 0; + YTarget =0; + BeamDirection = TVector3(0,0,1); + P30dpReaction = new Reaction ; + P30dpReaction -> ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()) ; + + InitOutputBranch(); + InitInputBranch(); + +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + // Reinitiate calculated variable + ReInitValue(); + + // Beam energy is measured using F3 and F2 plastic TOF (time of flight) + double BeamEnergy = Rand->Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5); + BeamEnergy = P30_CD2.Slow(BeamEnergy,TargetThickness/2.,0); + P30dpReaction->SetBeamEnergy(BeamEnergy); + +////////////////////////////////////////// LOOP on TiaraHyball + SSSD Hit ////////////////////////////////////////// + for(unsigned int countTiaraHyball = 0 ; countTiaraHyball < TH->Strip_E.size() ; countTiaraHyball++){ + /************************************************/ + + // TiaraHyball + + /************************************************/ + + // Part 1 : Impact Angle + ThetaTHSurface = 0; + ThetaNormalTarget = 0; + if(XTarget>-1000 && YTarget>-1000){ + TVector3 BeamImpact(XTarget,YTarget,0); + TVector3 HitDirection = TH -> GetPositionOfInteraction(countTiaraHyball) - BeamImpact ; + ThetaLab = HitDirection.Angle( BeamDirection ); + ThetaTHSurface = HitDirection.Angle(TVector3(0,0,-1) ); + ThetaNormalTarget = HitDirection.Angle( TVector3(0,0,1) ) ; + } + else{ + BeamDirection = TVector3(-1000,-1000,-1000); + ThetaTHSurface = -1000 ; + ThetaNormalTarget = -1000 ; + } + + /************************************************/ + + // Part 2 : Impact Energy + Energy = ELab = 0; + Si_E_TH = TH->Strip_E[countTiaraHyball]; + Energy = Si_E_TH; + + // Evaluate energy using the thickness + ELab = proton_Al.EvaluateInitialEnergy( Energy ,0.4*micrometer , ThetaTHSurface); + // Target Correction + ELab = proton_CD2.EvaluateInitialEnergy( ELab ,TargetThickness/2., ThetaNormalTarget); + + /************************************************/ + + // Part 3 : Excitation Energy Calculation + Ex = P30dpReaction -> ReconstructRelativistic( ELab , ThetaLab ); + + /************************************************/ + + // Part 4 : Theta CM Calculation + ThetaCM = P30dpReaction -> EnergyLabToThetaCM( ELab , ThetaLab)/deg; + ThetaLab=ThetaLab/deg; + + /************************************************/ + + // Part 5 : Implementing impact matrix for the entire Hyball (all 6 wedges) + /*TVector3 HyballImpactPosition = TH -> GetPositionOfInteraction(countTiaraHyball); + HyballIMX = HyballImpactPosition.X(); + HyballIMY = HyballImpactPosition.Y(); + HyballIMZ = HyballImpactPosition.Z();*/ + + /************************************************/ + + // Part 6 : Implementing randomised position impact matrix for the Hyball + TVector3 HyballRandomImpactPosition = TH -> GetRandomisedPositionOfInteraction(countTiaraHyball); + TiaraIMX = HyballRandomImpactPosition.X(); + TiaraIMY = HyballRandomImpactPosition.Y(); + TiaraIMZ = HyballRandomImpactPosition.Z(); + + /************************************************/ + + } // end loop TiaraHyball + +////////////////////////////////////////// LOOP on TiaraBarrel ///////////////////////////////////////////////////// + for(unsigned int countTiaraBarrel = 0 ; countTiaraBarrel < TB->Strip_E.size() ; countTiaraBarrel++){ + /************************************************/ + + //TiaraBarrel + + /************************************************/ + + // Part 1 : Impact Angle + ThetaTBSurface = 0; + ThetaNormalTarget = 0; + if(XTarget>-1000 && YTarget>-1000){ + TVector3 BeamImpact(XTarget,YTarget,0); + TVector3 HitDirection = TB -> GetPositionOfInteraction(countTiaraBarrel) - BeamImpact ; + ThetaLab = HitDirection.Angle( BeamDirection ); + ThetaTBSurface = HitDirection.Angle(TVector3(0,0,-1) ); + ThetaNormalTarget = HitDirection.Angle( TVector3(0,0,1) ) ; + } + else{ + BeamDirection = TVector3(-1000,-1000,-1000); + ThetaTBSurface = -1000 ; + ThetaNormalTarget = -1000 ; + } + /************************************************/ + + // Part 2 : Impact Energy + Energy = ELab = 0; + Si_E_TB = TB->Strip_E[countTiaraBarrel]; + Energy = Si_E_TB; + + // Evaluate energy using the thickness + ELab = proton_Al.EvaluateInitialEnergy( Energy ,0.4*micrometer , ThetaTBSurface); + // Target Correction + ELab = proton_CD2.EvaluateInitialEnergy( ELab ,TargetThickness/2., ThetaNormalTarget); + + /************************************************/ + + // Part 3 : Excitation Energy Calculation + Ex = P30dpReaction -> ReconstructRelativistic( ELab , ThetaLab ); + + /************************************************/ + + // Part 4 : Theta CM Calculation + ThetaCM = P30dpReaction -> EnergyLabToThetaCM( ELab , ThetaLab)/deg; + ThetaLab=ThetaLab/deg; + + /************************************************/ + + // Part 5 : Implementing impact matrix for the Tiara Barrel (all 8 detecting strips) + /*TVector3 BarrelImpactPosition = TB -> GetPositionOfInteraction(countTiaraBarrel); + BarrelIMX = BarrelImpactPosition.X(); + BarrelIMY = BarrelImpactPosition.Y(); + BarrelIMZ = BarrelImpactPosition.Z();*/ + + /************************************************/ + + // Part 6 : Implementing randomised position impact matrix for both the entire Barrel (all 8 strips) and each strip making up the octagonal Barrel individually + TVector3 BarrelRandomImpactPosition = TB -> GetRandomisedPositionOfInteraction(countTiaraBarrel); + TiaraIMX = BarrelRandomImpactPosition.X(); + TiaraIMY = BarrelRandomImpactPosition.Y(); + TiaraIMZ = BarrelRandomImpactPosition.Z(); + + /************************************************/ + + } // end loop TiaraBarrel +///////////////////////////////////////////////////////////////////////////////////////////////////////// +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} + + +void Analysis::ReInitValue(){ + Ex = -1000 ; + ELab = -1000; + ThetaLab = -1000; + ThetaCM = -1000; +} +///////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch() { + RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex,"Ex/D"); + RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab,"ELab/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM,"ThetaCM/D"); + RootOutput::getInstance()->GetTree()->Branch("TiaraImpactMatrixX",&TiaraIMX,"TiaraImpactMatrixX/D"); + RootOutput::getInstance()->GetTree()->Branch("TiaraImpactMatrixY",&TiaraIMY,"TiaraImpactMatrixY/D"); + RootOutput::getInstance()->GetTree()->Branch("TiaraImpactMatrixZ",&TiaraIMZ,"TiaraImpactMatrixZ/D"); +} +///////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch(){ + RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial ); + RootInput:: getInstance()->GetChain()->SetBranchStatus("InitialConditions",true ); + RootInput:: getInstance()->GetChain()->SetBranchStatus("fIC_*",true ); +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPA::VAnalysis* Analysis::Construct(){ + return (NPA::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPA::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } +}; + +proxy p; +} + diff --git a/NPAnalysis/newTAMU/Analysis.h b/NPAnalysis/newTAMU/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..c5ebecfdd0d2259b67a334a08a070bcaceee4584 --- /dev/null +++ b/NPAnalysis/newTAMU/Analysis.h @@ -0,0 +1,88 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2014 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 : march 2025 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include"NPVAnalysis.h" +#include "TTiaraHyballPhysics.h" +#include "TTiaraBarrelPhysics.h" +#include "TInitialConditions.h" +#include "NPEnergyLoss.h" +#include "NPReaction.h" +#include <TVector3.h> +#include <TRandom3.h> +#include <TMath.h> +#include <TObject.h> + + + + +class Analysis: public NPA::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + void ReInitValue(); + void InitOutputBranch(); + void InitInputBranch(); + static NPA::VAnalysis* Construct(); + + private: + + double Ex; + double ELab; + double ThetaLab; + double ThetaCM; + double TiaraIMX; + double TiaraIMY; + double TiaraIMZ; + TInitialConditions* Initial; + NPL::Reaction* P30dpReaction; + + // Energy loss table: the G4Table are generated by the simulation + EnergyLoss proton_CD2; + EnergyLoss proton_Al ; + EnergyLoss proton_Si; + EnergyLoss P30_CD2 ; + + TTiaraHyballPhysics* TH; + TTiaraBarrelPhysics* TB; + + TRandom *Rand ; + double ThetaNormalTarget ; + double ThetaTHSurface ; + double ThetaTBSurface ; + double Si_E_TH ; + double Si_E_TB ; + double Energy ; + double TargetThickness ; + + double XTarget ; + double YTarget ; + TVector3 BeamDirection ; + + +}; +#endif diff --git a/NPAnalysis/newTAMU/CMakeLists.txt b/NPAnalysis/newTAMU/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1d6a34417c73bce95f165aa644967bd249e9b521 --- /dev/null +++ b/NPAnalysis/newTAMU/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.8) +#Finding NPTool +set(NPTOOL "$ENV{NPTOOL}") +set(NPLIB "${NPTOOL}/NPLib") +set(NPTOOL_INCLUDE_DIR "${NPLIB}/include") +set(NPTOOL_LIB_DIR "${NPLIB}/lib") + +include("${NPLIB}/FindROOT.cmake") + +project (NPAnalysis) +set(CMAKE_BUILD_TYPE Release) +# Add root to the link and include directories +include_directories( ${ROOT_INCLUDE_DIR}) +link_directories( ${ROOT_LIBRARY_DIR}) +include_directories( ${NPTOOL_INCLUDE_DIR}) +link_directories( ${NPTOOL_LIB_DIR}) + +# Get the compilator flag from root to assure consistancy +EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} + ARGS "--cflags" + OUTPUT_VARIABLE root_cflags ) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${root_cflags}") + +# If the compiler is Clang, silence the unrecognised flags +if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -undefined dynamic_lookup") +endif() + +add_library(NPAnalysis SHARED Analysis.cxx) +target_link_libraries(NPAnalysis ${ROOT_LIBRARIES} -L${NPLIB}/lib -lNPCore -lNPPhysics) diff --git a/NPLib/Utility/npanalysis.cxx b/NPLib/Utility/npanalysis.cxx index 05c32dbcd9b96b2ee33aadaa155caacbd5384604..21827565c7c5c344376e1aaf604c22ccc0508fc7 100644 --- a/NPLib/Utility/npanalysis.cxx +++ b/NPLib/Utility/npanalysis.cxx @@ -69,6 +69,9 @@ int main(int argc , char** argv){ UserAnalysis->SetDetectorManager(myDetector); UserAnalysis->Init(); } + else{ + std::cout <<"Info: Not loading libNPAnalysis because : " << error << std::endl; + } std::cout << std::endl << "///////// Starting Analysis ///////// "<< std::endl; TChain* Chain = RootInput:: getInstance()->GetChain();