From 35fe4d753d5486b96e2c6a9149d4c00a26981cd4 Mon Sep 17 00:00:00 2001 From: deserevi <deserevi@nptool> Date: Fri, 4 Feb 2011 09:39:38 +0000 Subject: [PATCH] * Update Analysis.cc for Template and Gaspard analysis * Add resolution of 30 keV (FWHM) for W1 --- Inputs/DetectorConfiguration/W1.detector | 2 +- Inputs/DetectorConfiguration/e530.detector | 2 +- Inputs/EventGenerator/132Sndp.reaction | 2 +- NPAnalysis/Gaspard/src/Analysis.cc | 26 +++-- NPAnalysis/Template/RunToTreat.txt | 2 +- NPAnalysis/Template/src/Analysis.cc | 116 +++++++++++---------- NPAnalysis/must2/RunToTreat.txt | 3 +- NPSimulation/include/W1.hh | 5 +- 8 files changed, 89 insertions(+), 69 deletions(-) diff --git a/Inputs/DetectorConfiguration/W1.detector b/Inputs/DetectorConfiguration/W1.detector index 860401f3b..bf59637e8 100644 --- a/Inputs/DetectorConfiguration/W1.detector +++ b/Inputs/DetectorConfiguration/W1.detector @@ -2,7 +2,7 @@ GeneralTarget %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Target - THICKNESS= 0.001 + THICKNESS= 10 RADIUS= 7.5 MATERIAL= CD2 X= 0 diff --git a/Inputs/DetectorConfiguration/e530.detector b/Inputs/DetectorConfiguration/e530.detector index 083261fa0..c2afc6058 100644 --- a/Inputs/DetectorConfiguration/e530.detector +++ b/Inputs/DetectorConfiguration/e530.detector @@ -25,7 +25,7 @@ Target ANGLE= 0 X= 0 Y= 0 - Z= -50 + Z= 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AnnularS1 Z= -158.7 diff --git a/Inputs/EventGenerator/132Sndp.reaction b/Inputs/EventGenerator/132Sndp.reaction index dc220bd6c..3da1777b7 100644 --- a/Inputs/EventGenerator/132Sndp.reaction +++ b/Inputs/EventGenerator/132Sndp.reaction @@ -8,7 +8,7 @@ Transfert Light= 1H Heavy= 133Sn ExcitationEnergyLight= 0.0 - ExcitationEnergyHeavy= 5.0 + ExcitationEnergyHeavy= 0.0 BeamEnergy= 1320 BeamEnergySpread= 0 SigmaX= 0 diff --git a/NPAnalysis/Gaspard/src/Analysis.cc b/NPAnalysis/Gaspard/src/Analysis.cc index 9289bfaea..89f73c390 100644 --- a/NPAnalysis/Gaspard/src/Analysis.cc +++ b/NPAnalysis/Gaspard/src/Analysis.cc @@ -52,7 +52,7 @@ int main(int argc,char** argv) GaspardTracker* GPDTrack = (GaspardTracker*) myDetector->m_Detector["GASPARD"]; // Get the input TChain and treat it - TChain* chain = RootInput:: getInstance() -> GetChain(); + TChain* chain = RootInput:: getInstance()->GetChain(); // Connect TInitialConditions branch TInitialConditions *initCond = 0; @@ -64,11 +64,6 @@ int main(int argc,char** argv) chain->SetBranchAddress("InteractionCoordinates", &interCoord); chain->SetBranchStatus("InteractionCoordinates", 0); - // Analysis is here! - int nentries = chain->GetEntries(); - cout << "/////////// Loop information ///////////" << endl; - cout << "Number of entries to be analysed: " << nentries << endl; - // Default initialization double XTarget = 0; double YTarget = 0; @@ -78,9 +73,26 @@ int main(int argc,char** argv) // random generator TRandom3 *gene = new TRandom3(); + // 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; + // Loop on all events for (int i = 0; i < nentries; i ++) { - if (i%10000 == 0 && i!=0) cout << "\r" << i << " analyzed events" << flush; + 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 << "\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); // Treat Gaspard event diff --git a/NPAnalysis/Template/RunToTreat.txt b/NPAnalysis/Template/RunToTreat.txt index 008354fd1..698f27aa2 100644 --- a/NPAnalysis/Template/RunToTreat.txt +++ b/NPAnalysis/Template/RunToTreat.txt @@ -1,4 +1,4 @@ TTreeName SimulatedTree RootFileName - ../../Outputs/Simulation/mySimul.root + ../../Outputs/Simulation/myResult.root diff --git a/NPAnalysis/Template/src/Analysis.cc b/NPAnalysis/Template/src/Analysis.cc index e5b365dbe..dc93cb4a1 100644 --- a/NPAnalysis/Template/src/Analysis.cc +++ b/NPAnalysis/Template/src/Analysis.cc @@ -2,59 +2,69 @@ using namespace std; -int main(int argc,char** argv) -{ - - NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv) ; - string detectorfileName = myOptionManager->GetDetectorFilePath() ; - string reactionfileName = myOptionManager->GetCalibrationFilePath() ; - string calibrationfileName = myOptionManager->GetCalibrationFilePath() ; - string runToReadfileName = myOptionManager->GetRunToReadFilePath() ; - - // First of All instantiate RootInput and Output - // Detector will be attached later - RootInput:: getInstance(runToReadfileName) ; - RootOutput::getInstance("Analysis/Template_AnalyzedData", "AnalyzedTree") ; - - // Instantiate a Reaction - NPL::Reaction* myReaction = new Reaction ; - myReaction -> ReadConfigurationFile(reactionfileName) ; - - // Instantiate the detector using a file - NPA::DetectorManager* myDetector = new DetectorManager ; - myDetector -> ReadConfigurationFile(detectorfileName) ; - - // Instantiate the Calibration Manger using a file - CalibrationManager* myCalibration = CalibrationManager::getInstance(calibrationfileName) ; - - // Get the formed Chained Tree and Treat it - TChain* Chain = RootInput:: getInstance() -> GetChain() ; - int i; - for ( i = 0 ; i < Chain -> GetEntries() ; i ++ ) - { - if( i%10000 == 0 && i!=0) cout << "\r Event Analyzed:" << i << flush; - Chain -> GetEntry(i); - - myDetector -> ClearEventPhysics() ; - myDetector -> BuildPhysicalEvent() ; - - /************************************************ - - Put your code here - - ************************************************/ - RootOutput::getInstance()->GetTree()->Fill() ; - } - cout << "A total of " << i << " event has been annalysed " << endl ; - - RootOutput::getInstance()->Destroy(); - return 0 ; -} +int main(int argc, char** argv) +{ + // Parse command line + NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc, argv); + string detectorfileName = myOptionManager->GetDetectorFile(); + string reactionfileName = myOptionManager->GetCalibrationFile(); + string calibrationfileName = myOptionManager->GetCalibrationFile(); + string runToReadfileName = myOptionManager->GetRunToReadFile(); + + // First of All instantiate RootInput and Output + // Detector will be attached later + RootInput:: getInstance(runToReadfileName); + RootOutput::getInstance("Analysis/Template_AnalyzedData", "AnalyzedTree"); + + // Instantiate a Reaction + NPL::Reaction* myReaction = new Reaction(); + myReaction->ReadConfigurationFile(reactionfileName); + + // Instantiate the detector using a file + NPA::DetectorManager* myDetector = new DetectorManager(); + myDetector->ReadConfigurationFile(detectorfileName); + + // Instantiate the Calibration Manger using a file + CalibrationManager* myCalibration = CalibrationManager::getInstance(calibrationfileName); + + // 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 << "\r Progression:" << percent*100 << " % \t | \t Remaining time : ~" << TimeToWait <<"s"<< flush; + } + else if (i == nentries-1) cout << "\r Progression:" << " 100% " <<endl; -double ThetaCalculation (TVector3 A , TVector3 B) - { - double Theta = acos( (A.Dot(B)) / (A.Mag()*B.Mag()) ) ; - return Theta ; - } + // 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(); + return 0 ; +} diff --git a/NPAnalysis/must2/RunToTreat.txt b/NPAnalysis/must2/RunToTreat.txt index 28febc902..467f8c6b3 100644 --- a/NPAnalysis/must2/RunToTreat.txt +++ b/NPAnalysis/must2/RunToTreat.txt @@ -1,6 +1,5 @@ TTreeName SimulatedTree RootFileName -% ../../Outputs/Simulation/myResult.root - ../../Outputs/Simulation/dummy.root + ../../Outputs/Simulation/myResult.root % ../../Outputs/Simulation/fe60dp_1mg.root diff --git a/NPSimulation/include/W1.hh b/NPSimulation/include/W1.hh index 57eaf8dec..af8fe7f0d 100644 --- a/NPSimulation/include/W1.hh +++ b/NPSimulation/include/W1.hh @@ -151,9 +151,8 @@ private: namespace W1SQUARE { // Energy/Time resolutions for the different layers - const G4double EnergyResolution = 0; // = 52keV of Resolution // Unit is MeV/2.35 -// const G4double ResoFirstStage = 0.0106 ;// = 52keV of Resolution // Unit is MeV/2.35 - const G4double TimeResolution = 0.638; // 1.5 ns (FWHM) + const G4double EnergyResolution = 12.8e-3; // 30 keV FWHM + const G4double TimeResolution = 0.638; // 1.5 ns (FWHM) // Geometry const G4double FaceFront = 50*mm; -- GitLab