diff --git a/Inputs/DetectorConfiguration/Tiara.detector b/Inputs/DetectorConfiguration/Tiara.detector index 57c30e53c35d73590515d69c193887d4611b96ea..53c11b848480fab074a0486ce8e5abc8b0dcc7f3 100644 --- a/Inputs/DetectorConfiguration/Tiara.detector +++ b/Inputs/DetectorConfiguration/Tiara.detector @@ -33,11 +33,11 @@ Tiara Z= -147 R= 0 Phi= 180 - %TiaraHyballWedge + TiaraHyballWedge Z= -147 R= 0 Phi= 240 - %TiaraHyballWedge + TiaraHyballWedge Z= -147 R= 0 Phi= 300 diff --git a/NPAnalysis/MakePhysicalTree/RunToTreat.txt b/NPAnalysis/MakePhysicalTree/RunToTreat.txt index b620b3931e9eaa0be6a5d2f58d3dee0ff3e4c525..3eb76adf7ce4dda2d86908859ba2d79dfb68fb24 100644 --- a/NPAnalysis/MakePhysicalTree/RunToTreat.txt +++ b/NPAnalysis/MakePhysicalTree/RunToTreat.txt @@ -1,9 +1,10 @@ TTreeName - AutoTree -RootFileName + SimulatedTree +RootFileName + ../../Outputs/Simulation/Test1.root % /data/e628X/e628/acquisition/run_root/run_1352.1.root % /data/e628X/e628/acquisition/run_root/run_1353.0.root - /data/e628X/e628/acquisition/run_root/run_1354.0.root +% /data/e628X/e628/acquisition/run_root/run_1354.0.root % /data/e628X/e628/acquisition/run_root/run_1354.1.root % /data/e628X/e628/acquisition/run_root/run_1355.0.root % /data/e628X/e628/acquisition/run_root/run_1356.0.root diff --git a/NPAnalysis/TAMU/Analysis b/NPAnalysis/TAMU/Analysis new file mode 100755 index 0000000000000000000000000000000000000000..51b49831b4f26db0704d1cf57f594d163074da92 Binary files /dev/null and b/NPAnalysis/TAMU/Analysis differ diff --git a/NPAnalysis/TAMU/Analysis.cxx b/NPAnalysis/TAMU/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..12ee9b6fbf18f349f4fbd1855f5d80f2a0ff705f --- /dev/null +++ b/NPAnalysis/TAMU/Analysis.cxx @@ -0,0 +1,78 @@ +#include "Analysis.h" +using namespace std; + +int main(int argc, char** argv) +{ + // command line parsing + NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); + + // Instantiate RootInput + string runToReadfileName = myOptionManager->GetRunToReadFile(); + RootInput:: getInstance(runToReadfileName); + + // if input files are not given, use those from TAsciiFile + if (myOptionManager->IsDefault("DetectorConfiguration")) { + string name = RootInput::getInstance()->DumpAsciiFile("DetectorConfiguration"); + myOptionManager->SetDetectorFile(name); + } + + // get input files from NPOptionManager + string detectorfileName = myOptionManager->GetDetectorFile(); + string calibrationfileName = myOptionManager->GetCalibrationFile(); + string OutputfileName = myOptionManager->GetOutputFile(); + + // Instantiate RootOutput + RootOutput::getInstance("Analysis/"+OutputfileName, "AnalysedTree"); + + // Instantiate the detector using a file + NPA::DetectorManager* myDetector = new DetectorManager(); + myDetector->ReadConfigurationFile(detectorfileName); + double EGammaDC[4]; + RootOutput::getInstance()->GetTree()->Branch("EGammaDC", &EGammaDC, "EGammaDC[4]/D"); + float beta=0.17; + + // Get the formed Chained Tree and Treat it + TChain* Chain = RootInput:: getInstance() -> GetChain(); + + // Get number of events to treat + cout << endl << "///////// Starting Analysis ///////// "<< endl; + int nentries = Chain->GetEntries(); + cout << " Number of Event to be treated : " << nentries << endl; + clock_t begin = clock(); + clock_t end = begin; + + // main loop on entries + for (int i = 0; i < nentries; i++) { + if (i%10000 == 0 && i!=0) { + cout.precision(5); + end = clock(); + double TimeElapsed = (end-begin) / CLOCKS_PER_SEC; + double percent = (double)i/nentries; + double TimeToWait = (TimeElapsed/percent) - TimeElapsed; + cout << " "<< flush; + cout << "\r Progression:" << percent*100 << " % \t | \t Remaining time : ~" << TimeToWait <<"s"<< flush; + } + else if (i == nentries-1) cout << "\r Progression:" << " 100% " <<endl; + + // get data + Chain -> GetEntry(i); + + myDetector->ClearEventPhysics(); + myDetector->BuildPhysicalEvent(); + + /************************************************ + + Put your code here + + ************************************************/ + RootOutput::getInstance()->GetTree()->Fill(); + } + + cout << "A total of " << nentries << " event has been annalysed " << endl ; + + RootOutput::getInstance()->Destroy(); + RootInput::getInstance()->Destroy(); + NPOptionManager::getInstance()->Destroy(); + + return 0 ; +} diff --git a/NPAnalysis/TAMU/Analysis.h b/NPAnalysis/TAMU/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..d5ca8c305a8f3b7d788651234860e30edb569327 --- /dev/null +++ b/NPAnalysis/TAMU/Analysis.h @@ -0,0 +1,124 @@ +// You can use this file to declare your spectra, file, energy loss , ... and whatever you want. +// This way you can remove all unnecessary declaration in the main programm. +// In order to help debugging and organizing we use Name Space. + +///////////////////////////////////////////////////////////////////////////////////////////////// +// -------------------------------------- VARIOUS INCLUDE --------------------------------------- + +// NPA +#include "DetectorManager.h" +#include "NPOptionManager.h" + +// STL C++ +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +#include <cmath> +#include <cstdlib> + +// ROOT +#include <TROOT.h> +#include <TChain.h> +#include <TFile.h> +#include <TLeaf.h> +#include <TVector3.h> +#include <TRandom.h> + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPReaction.h" +#include "TInitialConditions.h" +#include "TPlasticData.h" +#include "TMust2Data.h" +#include "TMust2Physics.h" +#include "TExogamPhysics.h" +#include "TSSSDPhysics.h" +#include "TPlasticPhysics.h" +#include "GaspardTracker.h" + +// Use CLHEP System of unit and Physical Constant +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" + + +// ---------------------------------------------------------------------------------------------- +double ThetaCalculation (TVector3 A , TVector3 B) ; +///////////////////////////////////////////////////////////////////////////////////////////////// +// ----------------------------------- DOUBLE, INT, BOOL AND MORE ------------------------------- +namespace VARIABLE + { + // Declare your Variable here: + + double X1,Y1,Z1 ; + int N1,N2 = 0 ; + bool check= false ; + + // A Usefull Simple Random Generator + TRandom Rand; + } + +using namespace VARIABLE ; +// ---------------------------------------------------------------------------------------------- + + + +///////////////////////////////////////////////////////////////////////////////////////////////// +// -----------------------------------GRAPH------------------------------------------------------ +#include <TObject.h> +#include <TH1.h> +#include <TH1F.h> +#include <TH2.h> +#include <TH2F.h> +#include <TGraph2D.h> + +namespace GRAPH + { + // Declare your Spectra here: + + TH1F *myHist1D = new TH1F("Hist1D","Histogramm 1D ; x ; count", 1000 , -5 , 5 ) ; + + TH2F *myHist2D = new TH2F("Hist2D","Histogramm 2D ; x ; y ", 128 , 1 , 128 , 128 , 1 , 128 ) ; + + } + +using namespace GRAPH ; +// -------------------------------------------------------------------------------------------- + + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// -----------------------------------CUT------------------------------------------------------ +#include <TCutG.h> +namespace CUT + { + // Declare your Cut here: + + } + +using namespace CUT ; +// -------------------------------------------------------------------------------------------- + + + +//////////////////////////////////////////////////////////////////////////////////////////////// +// -----------------------------------ENERGY LOSS---------------------------------------------- +#include "NPEnergyLoss.h" +using namespace NPL ; +namespace ENERGYLOSS + { + + // Declare your Energy loss here : + /* EnergyLoss ProtonTarget = EnergyLoss ( "CD2.txt" , + 100 , + 1, + 1 ); + */ + } + +using namespace ENERGYLOSS ; +// ---------------------------------------------------------------------------------------------- +///////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/NPAnalysis/TAMU/Analysis.o b/NPAnalysis/TAMU/Analysis.o new file mode 100644 index 0000000000000000000000000000000000000000..862bc1a8688665f0eed43491fc185c9ccceed7fa Binary files /dev/null and b/NPAnalysis/TAMU/Analysis.o differ diff --git a/NPAnalysis/TAMU/Makefile b/NPAnalysis/TAMU/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..bdfccb1e4ff94a2d3dfe6398de9f70c90b206d31 --- /dev/null +++ b/NPAnalysis/TAMU/Makefile @@ -0,0 +1,30 @@ +# include same architecture file than for NPLib +# so that consistency is ensured +include $(NPTOOL)/NPLib/Makefile.arch + +# additional libraries +LIBRARY = `$(NPTOOL)/NPLib/liblist` + +PROGRAMS = Analysis + +all: $(PROGRAMS) + +Analysis: Analysis.o + $(LD) $(LDFLAGS) $^ $(LIBS) $(LIBRARY) $(OutPutOpt) $@ + @echo "$@ done" + + +# rule for creating .o from .cxx +.SUFFIXES: .$(SrcSuf) +.$(SrcSuf).$(ObjSuf): + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< + +# some cleaning +clean: + rm -rf *.o + +distclean: + make clean; rm $(PROGRAMS) + +# dependences +Analysis.o: Analysis.cxx Analysis.h diff --git a/NPAnalysis/TAMU/RunToTreat.txt b/NPAnalysis/TAMU/RunToTreat.txt new file mode 100644 index 0000000000000000000000000000000000000000..3eb76adf7ce4dda2d86908859ba2d79dfb68fb24 --- /dev/null +++ b/NPAnalysis/TAMU/RunToTreat.txt @@ -0,0 +1,14 @@ +TTreeName + SimulatedTree +RootFileName + ../../Outputs/Simulation/Test1.root +% /data/e628X/e628/acquisition/run_root/run_1352.1.root +% /data/e628X/e628/acquisition/run_root/run_1353.0.root +% /data/e628X/e628/acquisition/run_root/run_1354.0.root +% /data/e628X/e628/acquisition/run_root/run_1354.1.root +% /data/e628X/e628/acquisition/run_root/run_1355.0.root +% /data/e628X/e628/acquisition/run_root/run_1356.0.root +% /data/e628X/e628/acquisition/run_root/run_1357.0.root +% /data/e628X/e628/acquisition/run_root/run_1357.1.root +% /data/e628X/e628/acquisition/run_root/run_1358.0.root +% /data/e628X/e628/acquisition/run_root/run_1358.1.root diff --git a/NPLib/Tiara/TTiaraHyballPhysics.cxx b/NPLib/Tiara/TTiaraHyballPhysics.cxx index 3faf224b084803b064e59a21c67a97db49fbd986..453e8c9a1487a567ab9174ab2930ea2cb7683909 100644 --- a/NPLib/Tiara/TTiaraHyballPhysics.cxx +++ b/NPLib/Tiara/TTiaraHyballPhysics.cxx @@ -428,7 +428,7 @@ void TTiaraHyballPhysics::ReadConfiguration(string Path){ getline(ConfigFile, LineBuffer); // cout << LineBuffer << endl; - if (LineBuffer.compare(0, 11, "TiaraHyball") == 0) + if (LineBuffer.compare(0, 5, "Tiara") == 0) ReadingStatus = true; while (ReadingStatus && !ConfigFile.eof()) { diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx index 9027d06d8fd2da6b6608e18046b1cb2fc68be038..030b8733905edc8f2934c3e829f7d2919873b3e3 100644 --- a/NPLib/VDetector/DetectorManager.cxx +++ b/NPLib/VDetector/DetectorManager.cxx @@ -581,7 +581,7 @@ void DetectorManager::ReadConfigurationFile(string Path) { //////////////////////////////////////////// ////////// Search for Tiara Hyball ///////// //////////////////////////////////////////// - else if (LineBuffer.compare(0, 11, "TiaraHyball") == 0 && TiaraHyball == false) { + else if (LineBuffer.compare(0, 5, "Tiara") == 0 && TiaraHyball == false) { #ifdef INC_TIARA TiaraHyball = true; cout << "//////// Tiara Hyball ////////" << endl << endl; diff --git a/NPSimulation/AnnularS1/AnnularS1.cc b/NPSimulation/AnnularS1/AnnularS1.cc index 9aa7ec0473a46e87f1ebfe17dddb2161b4f56924..638858822cfa3d93819a2c12f9f5bac5d3e44920 100644 --- a/NPSimulation/AnnularS1/AnnularS1.cc +++ b/NPSimulation/AnnularS1/AnnularS1.cc @@ -335,6 +335,7 @@ void AnnularS1::InitializeRootOutput(){ RootOutput *pAnalysis = RootOutput::getInstance(); TTree *pTree = pAnalysis->GetTree(); pTree->Branch("AnnularS1", "TS1Data", &m_Event); + pTree->SetBranchAddress("AnnularS1",&m_Event); } // Read sensitive part and fill the Root tree. @@ -393,9 +394,10 @@ void AnnularS1::ReadSensitive(const G4Event* event){ // Initilize the Scorer use to read out the sensitive volume void AnnularS1::InitializeScorers() { + bool already_exist = false; // Associate Scorer - m_Scorer = new G4MultiFunctionalDetector("AnnularS1_Scorer"); - + m_Scorer = CheckScorer("AnnularS1_Scorer",already_exist); + if(already_exist) return; G4VPrimitiveScorer* AnnularScorer = new SILICONSCORERS::PS_Silicon_Annular("AnnularS1_Scorer", diff --git a/NPSimulation/ComptonTelescope/ComptonTelescope.cc b/NPSimulation/ComptonTelescope/ComptonTelescope.cc index 2d23c028832ac2e7f8eb320152e3a66d0695ec5a..c1b14b2fb24ebd52007caf8e0636da94ce1f45a9 100755 --- a/NPSimulation/ComptonTelescope/ComptonTelescope.cc +++ b/NPSimulation/ComptonTelescope/ComptonTelescope.cc @@ -614,6 +614,9 @@ void ComptonTelescope::InitializeRootOutput() TTree *pTree = pAnalysis->GetTree(); pTree->Branch("ComptonTelescope", "TComptonTelescopeData", &m_Event); pTree->Branch("ComptonTelescopeProcess", "TComptonTelescopeProcessData", &m_ProcessEvent); + pTree->SetBranchAddress("ComptonTelescope", &m_Event); + pTree->SetBranchAddress("ComptonTelescopeProcess", &m_ProcessEvent); + } @@ -972,8 +975,12 @@ void ComptonTelescope::InitializeMaterial() void ComptonTelescope::InitializeScorers() { + + bool already_exist = false; // First stage Associate Scorer - m_TrackerScorer = new G4MultiFunctionalDetector("TrackerScorerComptonTelescope"); + m_TrackerScorer = CheckScorer("TrackerScorerComptonTelescope",already_exist); + if(already_exist) return; + G4VPrimitiveScorer* TowerNbr = new ComptonTelescopeScorerTrackerTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); G4VPrimitiveScorer* DSSSDNbr = new ComptonTelescopeScorerTrackerDSSSDNumber("DSSSDNumber", "ComptonTelescopeTower", 0); G4VPrimitiveScorer* Energy = new ComptonTelescopeScorerTrackerEnergy("Energy", "ComptonTelescopeTower", 0); diff --git a/NPSimulation/DummyDetector/DummyDetector.cc b/NPSimulation/DummyDetector/DummyDetector.cc index 5eca7277217bd7931f670f66cf606eab1c6b1cfa..84849c60ab88203d3aab8490398344bb6e22a94e 100644 --- a/NPSimulation/DummyDetector/DummyDetector.cc +++ b/NPSimulation/DummyDetector/DummyDetector.cc @@ -317,6 +317,7 @@ void DUMMYDetector::InitializeRootOutput() RootOutput *pAnalysis = RootOutput::getInstance(); TTree *pTree = pAnalysis->GetTree(); pTree->Branch("DUMMYDetector", "TDUMMYDetectorData", &m_Event) ; + pTree->SetBranchAddress("DUMMYDetector", &m_Event) ; } // Read sensitive part and fill the Root tree. @@ -424,9 +425,10 @@ void DUMMYDetector::InitializeMaterial() //////////////////////////////////////////////////////////////// void DUMMYDetector::InitializeScorers() - { - m_DUMMYDetectorScorer = new G4MultiFunctionalDetector("DUMMYDetectorScorer") ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_DUMMYDetectorScorer); + { + bool already_exist = false; + m_DUMMYDetectorScorer = CheckScorer("DUMMYDetectorScorer",already_exist) ; + if(already_exist) return; G4VPrimitiveScorer* DetNbr = new PSDetectorNumber("DUMMYDetectorNumber","DUMMYDetector", 0) ; G4VPrimitiveScorer* Energy = new PSEnergy("Energy","DUMMYDetector", 0); @@ -436,7 +438,7 @@ void DUMMYDetector::InitializeScorers() m_DUMMYDetectorScorer->RegisterPrimitive(DetNbr); m_DUMMYDetectorScorer->RegisterPrimitive(Energy); m_DUMMYDetectorScorer->RegisterPrimitive(Time); - - + + G4SDManager::GetSDMpointer()->AddNewDetector(m_DUMMYDetectorScorer); } //////////////////////////////////////////////////////////////// diff --git a/NPSimulation/SSSD/ThinSi.cc b/NPSimulation/SSSD/ThinSi.cc index 79184184d9a32115a1e0b727662b7ab964a3eb0f..33ae2498fe509cb19531c1dfe6176e7b18eed436 100644 --- a/NPSimulation/SSSD/ThinSi.cc +++ b/NPSimulation/SSSD/ThinSi.cc @@ -62,6 +62,7 @@ using namespace CLHEP; ThinSi::ThinSi(){ InitializeMaterial(); m_Event = new TSSSDData(); + m_StripScorer=0; } ThinSi::~ThinSi(){ diff --git a/NPSimulation/Tigress/Tigress.cc b/NPSimulation/Tigress/Tigress.cc index ecc02a84d4349fbf47177d6fc41c63dff27a1db9..4ab25dba9d0341af209a4028ac87ab095e1d0f13 100644 --- a/NPSimulation/Tigress/Tigress.cc +++ b/NPSimulation/Tigress/Tigress.cc @@ -766,6 +766,7 @@ void Tigress::InitializeRootOutput(){ RootOutput *pAnalysis = RootOutput::getInstance(); TTree *pTree = pAnalysis->GetTree(); pTree->Branch("Tigress", "TTigressData", &m_Event) ; + pTree->SetBranchAddress("Tigress", &m_Event) ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/src/ParticleStack.cc b/NPSimulation/src/ParticleStack.cc index 38b38facff509ccc88e06376c30f92735c5c3b3e..f2138e61432553329fb9499c1d03f0060ce769bc 100644 --- a/NPSimulation/src/ParticleStack.cc +++ b/NPSimulation/src/ParticleStack.cc @@ -25,7 +25,8 @@ // G4 headers #include "G4ParticleTable.hh" - +#include "G4RunManager.hh" +#include "G4Run.hh" // NPL #include "RootOutput.h" @@ -243,6 +244,7 @@ void ParticleStack::ShootAllParticle(G4Event* anEvent){ // Write the DEDX table for charged particle and // all material used in the simulation if( anEvent->GetEventID()==0 + && G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID()==0 && m_ParticleStack[i].GetParticleDefinition()->GetPDGCharge()!=0){ MaterialManager::getInstance() ->WriteDEDXTable(m_ParticleStack[i].GetParticleDefinition(), diff --git a/NPSimulation/src/VDetector.cc b/NPSimulation/src/VDetector.cc index bba2ac02e4ff11dd46049add0094d351324a5d6d..7e613a2dd6b267ea8a9aa4ef9959beaa0e3c5ccc 100644 --- a/NPSimulation/src/VDetector.cc +++ b/NPSimulation/src/VDetector.cc @@ -47,6 +47,9 @@ void VDetector::InitializeRootOutput(){ // if the branch does not exist yet, create it if (!pTree->GetBranch("InteractionCoordinates")) pTree->Branch("InteractionCoordinates", "TInteractionCoordinates", &ms_InterCoord); + + pTree->SetBranchAddress("InteractionCoordinates", &ms_InterCoord); + } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......