Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
np
nptool
Commits
7dcb3734
Commit
7dcb3734
authored
Jun 08, 2021
by
Adrien Matta
☠
Browse files
Merge branch 'NPTool.2.dev' of gitlab.in2p3.fr:np/nptool into NPTool.2.dev
parents
2f0218c1
db65046f
Pipeline
#123230
passed with stages
in 12 minutes and 4 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1269 additions
and
161 deletions
+1269
-161
NPLib/Detectors/Sofia/CMakeLists.txt
NPLib/Detectors/Sofia/CMakeLists.txt
+5
-2
NPLib/Detectors/Sofia/TSofBeamID.cxx
NPLib/Detectors/Sofia/TSofBeamID.cxx
+74
-0
NPLib/Detectors/Sofia/TSofBeamID.h
NPLib/Detectors/Sofia/TSofBeamID.h
+95
-0
NPLib/Detectors/Sofia/TSofSciData.h
NPLib/Detectors/Sofia/TSofSciData.h
+8
-8
NPLib/Detectors/Sofia/TSofSciPhysics.cxx
NPLib/Detectors/Sofia/TSofSciPhysics.cxx
+485
-0
NPLib/Detectors/Sofia/TSofSciPhysics.h
NPLib/Detectors/Sofia/TSofSciPhysics.h
+173
-0
NPLib/Detectors/Sofia/TSofTrimPhysics.cxx
NPLib/Detectors/Sofia/TSofTrimPhysics.cxx
+224
-16
NPLib/Detectors/Sofia/TSofTrimPhysics.h
NPLib/Detectors/Sofia/TSofTrimPhysics.h
+25
-4
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx
+53
-74
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h
+127
-57
No files found.
NPLib/Detectors/Sofia/CMakeLists.txt
View file @
7dcb3734
add_custom_command
(
OUTPUT TSofSciDataDict.cxx COMMAND
${
CMAKE_BINARY_DIR
}
/scripts/build_dict.sh TSofSciData.h TSofSciDataDict.cxx TSofSciData.rootmap libNPSofia.dylib DEPENDS TSofSciData.h
)
add_custom_command
(
OUTPUT TSofSciPhysicsDict.cxx COMMAND
${
CMAKE_BINARY_DIR
}
/scripts/build_dict.sh TSofSciPhysics.h TSofSciPhysicsDict.cxx TSofSciPhysics.rootmap libNPSofia.dylib DEPENDS TSofSciPhysics.h
)
add_custom_command
(
OUTPUT TSofTofWDataDict.cxx COMMAND
${
CMAKE_BINARY_DIR
}
/scripts/build_dict.sh TSofTofWData.h TSofTofWDataDict.cxx TSofTofWData.rootmap libNPSofia.dylib DEPENDS TSofTofWData.h
)
add_custom_command
(
OUTPUT TSofTofWPhysicsDict.cxx COMMAND
${
CMAKE_BINARY_DIR
}
/scripts/build_dict.sh TSofTofWPhysics.h TSofTofWPhysicsDict.cxx TSofTofWPhysics.rootmap libNPSofia.dylib DEPENDS TSofTofWPhysics.h
)
...
...
@@ -12,9 +13,11 @@ add_custom_command(OUTPUT TSofTrimPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/sc
add_custom_command
(
OUTPUT TSofTwimDataDict.cxx COMMAND
${
CMAKE_BINARY_DIR
}
/scripts/build_dict.sh TSofTwimData.h TSofTwimDataDict.cxx TSofTwimData.rootmap libNPSofia.dylib DEPENDS TSofTwimData.h
)
add_library
(
NPSofia SHARED TSofSciData.cxx TSofSciDataDict.cxx TSofMwpcData.cxx TSofMwpcDataDict.cxx TSofAtData.cxx TSofAtDataDict.cxx TSofTrimData.cxx TSofTrimDataDict.cxx TSofTrimPhysics.cxx TSofTrimPhysicsDict.cxx TSofTwimData.cxx TSofTwimDataDict.cxx TSofTofWData.cxx TSofTofWDataDict.cxx TSofTofWPhysics.cxx TSofTofWPhysicsDict.cxx
)
add_custom_command
(
OUTPUT TSofBeamIDDict.cxx COMMAND
${
CMAKE_BINARY_DIR
}
/scripts/build_dict.sh TSofBeamID.h TSofBeamIDDict.cxx TSofBeamID.rootmap libNPSofia.dylib DEPENDS TSofBeamID.h
)
add_library
(
NPSofia SHARED TSofSciData.cxx TSofSciDataDict.cxx TSofSciPhysics.cxx TSofSciPhysicsDict.cxx TSofMwpcData.cxx TSofMwpcDataDict.cxx TSofAtData.cxx TSofAtDataDict.cxx TSofTrimData.cxx TSofTrimDataDict.cxx TSofTrimPhysics.cxx TSofTrimPhysicsDict.cxx TSofTwimData.cxx TSofTwimDataDict.cxx TSofTofWData.cxx TSofTofWDataDict.cxx TSofTofWPhysics.cxx TSofTofWPhysicsDict.cxx TSofBeamID.cxx TSofBeamIDDict.cxx
)
target_link_libraries
(
NPSofia
${
ROOT_LIBRARIES
}
NPCore NPPhysics
)
install
(
FILES TSofSciData.h TSofMwpcData.h TSofAtData.h TSofTrimData.h TSofTrimPhysics.h TSofTwimData.h TSofTofWData.h TSofTofWPhysics.h DESTINATION
${
CMAKE_INCLUDE_OUTPUT_DIRECTORY
}
)
install
(
FILES TSofSciData.h
TSofSciPhysics.h
TSofMwpcData.h TSofAtData.h TSofTrimData.h TSofTrimPhysics.h TSofTwimData.h TSofTofWData.h TSofTofWPhysics.h
TSofBeamID.h
DESTINATION
${
CMAKE_INCLUDE_OUTPUT_DIRECTORY
}
)
NPLib/Detectors/Sofia/TSofBeamID.cxx
0 → 100644
View file @
7dcb3734
/*****************************************************************************
* Copyright (C) 2009-2020 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: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* Creation Date : May 2021 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold SofBeamID Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TSofBeamID.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using
namespace
std
;
ClassImp
(
TSofBeamID
)
//////////////////////////////////////////////////////////////////////
TSofBeamID
::
TSofBeamID
()
{
}
//////////////////////////////////////////////////////////////////////
TSofBeamID
::~
TSofBeamID
()
{
}
//////////////////////////////////////////////////////////////////////
void
TSofBeamID
::
Clear
()
{
Zbeam
=
-
1
;
Qmax
=
-
1
;
AoQ
=
-
1
;
Abeam
=
-
1
;
Beta
=
-
1
;
Gamma
=
-
1
;
Brho
=
-
1
;
XS2
=
-
1000
;
XCC
=
-
1000
;
}
//////////////////////////////////////////////////////////////////////
void
TSofBeamID
::
Dump
()
const
{
// This method is very useful for debuging and worth the dev.
cout
<<
"XXXXXXXXXXXXXXXXXXXXXXXX New Event [TSofBeamID::Dump()] XXXXXXXXXXXXXXXXX"
<<
endl
;
cout
<<
"Zbeam: "
<<
Zbeam
<<
endl
;
cout
<<
"AoQ: "
<<
AoQ
<<
endl
;
cout
<<
"Abeam: "
<<
Abeam
<<
endl
;
cout
<<
"Beta: "
<<
Beta
<<
endl
;
cout
<<
"Gamma: "
<<
Gamma
<<
endl
;
cout
<<
"Brho: "
<<
Brho
<<
endl
;
cout
<<
"XS2: "
<<
XS2
<<
endl
;
cout
<<
"XCC: "
<<
XCC
<<
endl
;
}
NPLib/Detectors/Sofia/TSofBeamID.h
0 → 100644
View file @
7dcb3734
#ifndef __SofBeamIDDATA__
#define __SofBeamIDDATA__
/*****************************************************************************
* Copyright (C) 2009-2020 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: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* *
* Creation Date : May 2021 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold SofBeamID Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// STL
#include <vector>
using
namespace
std
;
// ROOT
#include "TObject.h"
class
TSofBeamID
:
public
TObject
{
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
double
Zbeam
;
double
Qmax
;
double
AoQ
;
double
Abeam
;
double
Beta
;
double
Gamma
;
double
Brho
;
double
XS2
;
double
XCC
;
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TSofBeamID
();
~
TSofBeamID
();
//////////////////////////////////////////////////////////////
// Inherited from TObject and overriden to avoid warnings
public:
void
Clear
();
void
Clear
(
const
Option_t
*
)
{};
void
Dump
()
const
;
//////////////////////////////////////////////////////////////
// Getters and Setters
// Prefer inline declaration to avoid unnecessary called of
// frequently used methods
// add //! to avoid ROOT creating dictionnary for the methods
public:
////////////////////// SETTERS ////////////////////////
inline
void
SetZbeam
(
double
val
){
Zbeam
=
val
;};
//!
inline
void
SetQmax
(
double
val
){
Qmax
=
val
;};
//!
inline
void
SetAoQ
(
double
val
){
AoQ
=
val
;};
//!
inline
void
SetAbeam
(
double
val
){
Abeam
=
val
;};
//!
inline
void
SetBeta
(
double
val
){
Beta
=
val
;};
//!
inline
void
SetGamma
(
double
val
){
Gamma
=
val
;};
//!
inline
void
SetBrho
(
double
val
){
Brho
=
val
;};
//!
inline
void
SetXS2
(
double
val
){
XS2
=
val
;};
//!
inline
void
SetXCC
(
double
val
){
XCC
=
val
;};
//!
////////////////////// GETTERS ////////////////////////
inline
double
GetZbeam
()
const
{
return
Zbeam
;}
//!
inline
double
GetQmax
()
const
{
return
Qmax
;}
//!
inline
double
GetAoQ
()
const
{
return
AoQ
;}
//!
inline
double
GetAbeam
()
const
{
return
Abeam
;}
//!
inline
double
GetBeta
()
const
{
return
Beta
;}
//!
inline
double
GetGamma
()
const
{
return
Gamma
;}
//!
inline
double
GetBrho
()
const
{
return
Brho
;}
//!
inline
double
GetXS2
()
const
{
return
XS2
;}
//!
inline
double
GetXCC
()
const
{
return
XCC
;}
//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef
(
TSofBeamID
,
1
)
// SofBeamID structure
};
#endif
NPLib/Detectors/Sofia/TSofSciData.h
View file @
7dcb3734
...
...
@@ -34,10 +34,10 @@ class TSofSciData : public TObject {
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
vector
<
int
>
fSofSci_DetNbr
;
vector
<
int
>
fSofSci_Pmt
;
vector
<
double
>
fSofSci_CT
;
vector
<
double
>
fSofSci_FT
;
vector
<
int
>
fSofSci_DetNbr
;
vector
<
int
>
fSofSci_Pmt
;
vector
<
int
>
fSofSci_CT
;
vector
<
int
>
fSofSci_FT
;
//////////////////////////////////////////////////////////////
// Constructor and destructor
...
...
@@ -63,15 +63,15 @@ class TSofSciData : public TObject {
////////////////////// SETTERS ////////////////////////
inline
void
SetDetectorNbr
(
int
det
){
fSofSci_DetNbr
.
push_back
(
det
);};
//!
inline
void
SetPmt
(
int
pmt
){
fSofSci_Pmt
.
push_back
(
pmt
);};
//!
inline
void
SetCoarseTime
(
double
Time
){
fSofSci_CT
.
push_back
(
Time
);};
//!
inline
void
SetFineTime
(
double
Time
){
fSofSci_FT
.
push_back
(
Time
);};
//!
inline
void
SetCoarseTime
(
int
Time
){
fSofSci_CT
.
push_back
(
Time
);};
//!
inline
void
SetFineTime
(
int
Time
){
fSofSci_FT
.
push_back
(
Time
);};
//!
////////////////////// GETTERS ////////////////////////
inline
int
GetMultiplicity
()
const
{
return
fSofSci_DetNbr
.
size
();}
//!
inline
int
GetDetectorNbr
(
const
unsigned
int
&
i
)
const
{
return
fSofSci_DetNbr
[
i
];}
//!
inline
int
GetPmt
(
const
unsigned
int
&
i
)
const
{
return
fSofSci_Pmt
[
i
];}
//!
inline
double
GetCoarseTime
(
const
unsigned
int
&
i
)
const
{
return
fSofSci_CT
[
i
];}
//!
inline
double
GetFineTime
(
const
unsigned
int
&
i
)
const
{
return
fSofSci_FT
[
i
];}
//!
inline
int
GetCoarseTime
(
const
unsigned
int
&
i
)
const
{
return
fSofSci_CT
[
i
];}
//!
inline
int
GetFineTime
(
const
unsigned
int
&
i
)
const
{
return
fSofSci_FT
[
i
];}
//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
...
...
NPLib/Detectors/Sofia/TSofSciPhysics.cxx
0 → 100644
View file @
7dcb3734
/*****************************************************************************
* Copyright (C) 2009-2020 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: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* *
* Creation Date : November 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold SofSci Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TSofSciPhysics.h"
// STL
#include <sstream>
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <limits>
using
namespace
std
;
// NPL
#include "RootInput.h"
#include "RootOutput.h"
#include "NPDetectorFactory.h"
#include "NPOptionManager.h"
#include "NPPhysicalConstants.h"
#include "NPGlobalSystemOfUnits.h"
// ROOT
#include "TChain.h"
ClassImp
(
TSofSciPhysics
)
///////////////////////////////////////////////////////////////////////////
TSofSciPhysics
::
TSofSciPhysics
()
:
m_EventData
(
new
TSofSciData
),
m_PreTreatedData
(
new
TSofSciData
),
m_EventPhysics
(
this
),
m_DET1_PosNs_Min
(
-
20
),
m_DET1_PosNs_Max
(
20
),
m_DET2_PosNs_Min
(
-
20
),
m_DET2_PosNs_Max
(
20
),
m_RawTof_Min
(
0
),
m_RawTof_Max
(
2000
),
m_NumberOfSignals
(
3
),
m_NumberOfPmts
(
2
),
m_NumberOfDetectors
(
0
){
}
///////////////////////////////////////////////////////////////////////////
/// A usefull method to bundle all operation to add a detector
void
TSofSciPhysics
::
AddDetector
(
TVector3
){
// In That simple case nothing is done
// Typically for more complex detector one would calculate the relevant
// positions (stripped silicon) or angles (gamma array)
m_NumberOfDetectors
++
;
}
///////////////////////////////////////////////////////////////////////////
void
TSofSciPhysics
::
AddDetector
(
double
R
,
double
Theta
,
double
Phi
){
// Compute the TVector3 corresponding
TVector3
Pos
(
R
*
sin
(
Theta
)
*
cos
(
Phi
),
R
*
sin
(
Theta
)
*
sin
(
Phi
),
R
*
cos
(
Theta
));
// Call the cartesian method
AddDetector
(
Pos
);
}
///////////////////////////////////////////////////////////////////////////
void
TSofSciPhysics
::
BuildSimplePhysicalEvent
()
{
BuildPhysicalEvent
();
}
///////////////////////////////////////////////////////////////////////////
void
TSofSciPhysics
::
BuildPhysicalEvent
()
{
Clear
();
// apply thresholds and calibration
//PreTreat();
const
int
N
=
m_NumberOfDetectors
;
vector
<
double
>
S2_pmtL
;
vector
<
double
>
S2_pmtR
;
vector
<
double
>
S2_pmtTref
;
vector
<
double
>
S2_pos
;
vector
<
double
>
S2_time
;
vector
<
double
>
CC_pmtL
;
vector
<
double
>
CC_pmtR
;
vector
<
double
>
CC_pmtTref
;
vector
<
double
>
CC_pos
;
vector
<
double
>
CC_time
;
unsigned
int
mysizeE
=
m_EventData
->
GetMultiplicity
();
for
(
UShort_t
e
=
0
;
e
<
mysizeE
;
e
++
)
{
int
det
=
m_EventData
->
GetDetectorNbr
(
e
);
int
pmt
=
m_EventData
->
GetPmt
(
e
);
int
FT
=
m_EventData
->
GetFineTime
(
e
);
int
CT
=
m_EventData
->
GetCoarseTime
(
e
);
double
T
=
CalculateTimeNs
(
det
,
pmt
,
FT
,
CT
);
if
(
m_NumberOfDetectors
==
2
){
if
(
det
==
1
){
if
(
pmt
==
1
)
S2_pmtR
.
push_back
(
T
);
else
if
(
pmt
==
2
)
S2_pmtL
.
push_back
(
T
);
else
if
(
pmt
==
3
)
S2_pmtTref
.
push_back
(
T
);
}
else
if
(
det
==
2
){
if
(
pmt
==
1
)
CC_pmtR
.
push_back
(
T
);
else
if
(
pmt
==
2
)
CC_pmtL
.
push_back
(
T
);
else
if
(
pmt
==
3
)
CC_pmtTref
.
push_back
(
T
);
}
}
else
if
(
m_NumberOfDetectors
==
1
){
if
(
pmt
==
1
)
CC_pmtR
.
push_back
(
T
);
else
if
(
pmt
==
2
)
CC_pmtL
.
push_back
(
T
);
else
if
(
pmt
==
3
)
CC_pmtTref
.
push_back
(
T
);
}
}
if
(
m_NumberOfDetectors
==
2
){
double
CC_rawpos
;
double
S2_rawpos
;
double
CC_calpos
;
double
S2_calpos
;
double
CC_rawtime
;
double
S2_rawtime
;
double
rawtof
;
static
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
if
(
S2_pmtTref
.
size
()
==
1
&&
CC_pmtTref
.
size
()
==
1
){
for
(
unsigned
int
i
=
0
;
i
<
CC_pmtR
.
size
();
i
++
){
for
(
unsigned
int
j
=
0
;
j
<
CC_pmtL
.
size
();
j
++
){
CC_rawpos
=
CC_pmtR
[
i
]
-
CC_pmtL
[
j
];
CC_calpos
=
Cal
->
ApplyCalibration
(
"SofSci/DET2_POSPAR"
,
CC_rawpos
);
CC_rawtime
=
0.5
*
(
CC_pmtR
[
i
]
+
CC_pmtL
[
j
]);
if
(
CC_rawpos
<
m_DET2_PosNs_Min
||
CC_rawpos
>
m_DET2_PosNs_Max
)
continue
;
for
(
int
p
=
0
;
p
<
S2_pmtR
.
size
();
p
++
){
for
(
int
k
=
0
;
k
<
S2_pmtL
.
size
();
k
++
){
S2_rawpos
=
S2_pmtR
[
p
]
-
S2_pmtL
[
k
];
S2_calpos
=
Cal
->
ApplyCalibration
(
"SofSci/DET1_POSPAR"
,
S2_rawpos
);
S2_rawtime
=
0.5
*
(
S2_pmtR
[
p
]
+
S2_pmtL
[
k
]);
if
(
S2_rawpos
<
m_DET1_PosNs_Min
||
S2_rawpos
>
m_DET1_PosNs_Max
)
continue
;
/*CC_pos.push_back(CC_rawpos);
CC_time.push_back(CC_rawtime);
S2_pos.push_back(S2_rawpos);
S2_time.push_back(S2_rawtime); */
rawtof
=
CC_rawtime
-
CC_pmtTref
[
0
]
-
(
S2_rawtime
-
S2_pmtTref
[
0
]);
if
(
rawtof
<
m_RawTof_Min
||
rawtof
>
m_RawTof_Max
)
continue
;
double
velocity_mns
;
double
caltof
;
double
betaS2
;
/*cout << "*** Printing physics calibration parameter:" << endl;
cout << Cal->GetValue("SofSci/TOF2INV_V",0) << endl;
cout << Cal->GetValue("SofSci/TOF2INV_V",1) << endl;
cout << Cal->GetValue("SofSci/LENGTH_S2",0) << endl;*/
velocity_mns
=
1.
/
Cal
->
ApplyCalibration
(
"SofSci/TOF2INV_V"
,
rawtof
);
caltof
=
Cal
->
GetValue
(
"SofSci/LENGTH_S2"
,
0
)
/
velocity_mns
;
betaS2
=
velocity_mns
*
m
/
ns
/
NPUNITS
::
c_light
;
// Filling ouput Tree;
DetectorNbr
.
push_back
(
1
);
TimeNs
.
push_back
(
S2_rawtime
);
PosNs
.
push_back
(
S2_rawpos
);
PosMm
.
push_back
(
S2_calpos
);
DetectorNbr
.
push_back
(
2
);
TimeNs
.
push_back
(
CC_rawtime
);
PosNs
.
push_back
(
CC_rawpos
);
PosMm
.
push_back
(
CC_calpos
);
RawTof
.
push_back
(
rawtof
);
CalTof
.
push_back
(
caltof
);
VelocityMNs
.
push_back
(
velocity_mns
);
Beta
.
push_back
(
betaS2
);
}
}
}
}
}
}
else
if
(
m_NumberOfDetectors
==
1
){
double
CC_rawpos
;
double
CC_rawtime
;
if
(
CC_pmtTref
.
size
()
==
1
){
for
(
unsigned
int
i
=
0
;
i
<
CC_pmtR
.
size
();
i
++
){
for
(
unsigned
int
j
=
0
;
j
<
CC_pmtL
.
size
();
j
++
){
CC_rawpos
=
CC_pmtR
[
i
]
-
CC_pmtL
[
j
];
CC_rawtime
=
0.5
*
(
CC_pmtR
[
i
]
+
CC_pmtL
[
j
]);
if
(
CC_rawpos
<
m_DET2_PosNs_Min
||
CC_rawpos
>
m_DET2_PosNs_Max
)
continue
;
//Filling output Tree;
DetectorNbr
.
push_back
(
1
);
TimeNs
.
push_back
(
CC_rawtime
);
PosNs
.
push_back
(
CC_rawpos
);
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////
double
TSofSciPhysics
::
CalculateTimeNs
(
int
det
,
int
pmt
,
int
ft
,
int
ct
){
static
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
//ft = ft+1;
double
par
=
Cal
->
GetValue
(
"SofSci/DET"
+
NPL
::
itoa
(
det
)
+
"_SIGNAL"
+
NPL
::
itoa
(
pmt
)
+
"_TIME"
,
ft
);
double
r
=
(
double
)
rand
.
Rndm
()
-
0.5
;
double
ClockOffset
=
Cal
->
GetValue
(
"SofSci/DET"
+
NPL
::
itoa
(
det
)
+
"_SIGNAL"
+
NPL
::
itoa
(
pmt
)
+
"_CLOCKOFFSET"
,
0
);
double
ict_ns
=
((
double
)
ct
-
ClockOffset
)
*
5.
;
// to do... take care of the clock offset
double
ift_ns
;
if
(
r
<
0
){
double
par_prev
=
Cal
->
GetValue
(
"SofSci/DET"
+
NPL
::
itoa
(
det
)
+
"_SIGNAL"
+
NPL
::
itoa
(
pmt
)
+
"_TIME"
,
ft
-
1
);
ift_ns
=
par
+
r
*
(
par
-
par_prev
);
}
else
{
double
par_next
=
Cal
->
GetValue
(
"SofSci/DET"
+
NPL
::
itoa
(
det
)
+
"_SIGNAL"
+
NPL
::
itoa
(
pmt
)
+
"_TIME"
,
ft
+
1
);
ift_ns
=
par
+
r
*
(
par_next
-
par
);
}
double
time_ns
=
(
double
)
ict_ns
-
ift_ns
;
return
time_ns
;
}
///////////////////////////////////////////////////////////////////////////
void
TSofSciPhysics
::
PreTreat
()
{
// This method typically applies thresholds and calibrations
// Might test for disabled channels for more complex detector
// clear pre-treated object
ClearPreTreatedData
();
// instantiate CalibrationManager
static
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
unsigned
int
mysize
=
m_EventData
->
GetMultiplicity
();
for
(
unsigned
int
i
=
0
;
i
<
mysize
;
++
i
)
{
m_PreTreatedData
->
SetDetectorNbr
(
m_EventData
->
GetDetectorNbr
(
i
));
m_PreTreatedData
->
SetPmt
(
m_EventData
->
GetPmt
(
i
));
m_PreTreatedData
->
SetCoarseTime
(
m_EventData
->
GetCoarseTime
(
i
));
m_PreTreatedData
->
SetFineTime
(
m_EventData
->
GetFineTime
(
i
));
}
}
///////////////////////////////////////////////////////////////////////////
void
TSofSciPhysics
::
ReadAnalysisConfig
()
{
bool
ReadingStatus
=
false
;
// path to file
string
FileName
=
"./configs/ConfigSofSci.dat"
;
// open analysis config file
ifstream
AnalysisConfigFile
;
AnalysisConfigFile
.
open
(
FileName
.
c_str
());
if
(
!
AnalysisConfigFile
.
is_open
())
{
cout
<<
" No ConfigSofSci.dat found: Default parameter loaded for Analayis "
<<
FileName
<<
endl
;
return
;
}
cout
<<
" Loading user parameter for Analysis from ConfigSofSci.dat "
<<
endl
;
// Save it in a TAsciiFile
TAsciiFile
*
asciiConfig
=
RootOutput
::
getInstance
()
->
GetAsciiFileAnalysisConfig
();
asciiConfig
->
AppendLine
(
"%%% ConfigSofSci.dat %%%"
);
asciiConfig
->
Append
(
FileName
.
c_str
());
asciiConfig
->
AppendLine
(
""
);
// read analysis config file
string
LineBuffer
,
DataBuffer
,
whatToDo
;
while
(
!
AnalysisConfigFile
.
eof
())
{
// Pick-up next line
getline
(
AnalysisConfigFile
,
LineBuffer
);
// search for "header"
string
name
=
"ConfigSofSci"
;
if
(
LineBuffer
.
compare
(
0
,
name
.
length
(),
name
)
==
0
)
ReadingStatus
=
true
;
// loop on tokens and data
while
(
ReadingStatus
)
{
whatToDo
=
""
;
AnalysisConfigFile
>>
whatToDo
;
// Search for comment symbol (%)
if
(
whatToDo
.
compare
(
0
,
1
,
"%"
)
==
0
)
{
AnalysisConfigFile
.
ignore
(
numeric_limits
<
streamsize
>::
max
(),
'\n'
);
}
else
if
(
whatToDo
==
"E_THRESHOLD"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_E_Threshold
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_E_Threshold
<<
endl
;
}
else
if
(
whatToDo
==
"DET1_POSNS_MIN"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_DET1_PosNs_Min
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_DET1_PosNs_Min
<<
endl
;
}
else
if
(
whatToDo
==
"DET1_POSNS_MAX"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_DET1_PosNs_Max
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_DET1_PosNs_Max
<<
endl
;
}
else
if
(
whatToDo
==
"DET2_POSNS_MIN"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_DET2_PosNs_Min
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_DET2_PosNs_Min
<<
endl
;
}
else
if
(
whatToDo
==
"DET2_POSNS_MAX"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_DET2_PosNs_Max
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_DET2_PosNs_Max
<<
endl
;
}
else
if
(
whatToDo
==
"RAWTOF_MIN"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_RawTof_Min
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_RawTof_Min
<<
endl
;
}
else
if
(
whatToDo
==
"RAWTOF_MAX"
)
{
AnalysisConfigFile
>>
DataBuffer
;
m_RawTof_Max
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_RawTof_Max
<<
endl
;
}
else
{
ReadingStatus
=
false
;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void
TSofSciPhysics
::
Clear
()
{
DetectorNbr
.
clear
();
TimeNs
.
clear
();
PosNs
.
clear
();
PosMm
.
clear
();