ATLAS Offline Software
Loading...
Searching...
No Matches
TilePulseShape Class Reference

#include <TilePulseShape.h>

Inheritance diagram for TilePulseShape:
Collaboration diagram for TilePulseShape:

Public Member Functions

 TilePulseShape (IMessageSvc *msgSvc, const std::string &name)
 TilePulseShape (IMessageSvc *msgSvc, const std::string &name, const TString &fileName)
 TilePulseShape (IMessageSvc *msgSvc, const std::string &name, const std::vector< double > &shapevec)
virtual ~TilePulseShape ()
void loadPulseShape (const TString &fileName)
void setPulseShape (const std::vector< double > &shapevec)
void setUndershootParameters (double amplitude, double decayTime)
double undershootAmplitude () const
double undershootDecayTime () const
double effectiveStartTime () const
double effectiveEndTime () const
TGraph * getGraph (double t0=0., double ped=0., double amp=1.)
double eval (double x, bool useSpline=true, bool useUndershoot=false)
void resetDeformation ()
int scalePulse (double leftSF=1., double rightSF=1.)
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

TGraph * m_pulseShape {nullptr}
TGraph * m_deformedShape {nullptr}
TSpline * m_deformedSpline {nullptr}
bool m_useConfiguredUndershoot {false}
double m_undershootAmplitude {}
double m_undershootDecayTime {}
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging).

Detailed Description

Definition at line 17 of file TilePulseShape.h.

Constructor & Destructor Documentation

◆ TilePulseShape() [1/3]

TilePulseShape::TilePulseShape ( IMessageSvc * msgSvc,
const std::string & name )

Definition at line 19 of file TilePulseShape.cxx.

20 : AthMessaging(msgSvc, name)
21{
22}
AthMessaging()
Default constructor:

◆ TilePulseShape() [2/3]

TilePulseShape::TilePulseShape ( IMessageSvc * msgSvc,
const std::string & name,
const TString & fileName )

Definition at line 25 of file TilePulseShape.cxx.

26 : AthMessaging(msgSvc, name)
27{
28 loadPulseShape(fileName);
29}
void loadPulseShape(const TString &fileName)

◆ TilePulseShape() [3/3]

TilePulseShape::TilePulseShape ( IMessageSvc * msgSvc,
const std::string & name,
const std::vector< double > & shapevec )

Definition at line 32 of file TilePulseShape.cxx.

33 : AthMessaging(msgSvc, name)
34{
35 setPulseShape(shapevec);
36}
void setPulseShape(const std::vector< double > &shapevec)

◆ ~TilePulseShape()

TilePulseShape::~TilePulseShape ( )
virtual

Definition at line 39 of file TilePulseShape.cxx.

40{
42 if(m_pulseShape) delete m_pulseShape;
44}
TGraph * m_pulseShape
TSpline * m_deformedSpline

Member Function Documentation

◆ effectiveEndTime()

double TilePulseShape::effectiveEndTime ( ) const

Definition at line 86 of file TilePulseShape.cxx.

87{
88 return m_deformedShape->GetX()[m_deformedShape->GetN() - 1];
89}
TGraph * m_deformedShape

◆ effectiveStartTime()

double TilePulseShape::effectiveStartTime ( ) const

Definition at line 80 of file TilePulseShape.cxx.

81{
82 return m_deformedShape->GetX()[0];
83}

◆ eval()

double TilePulseShape::eval ( double x,
bool useSpline = true,
bool useUndershoot = false )

Definition at line 95 of file TilePulseShape.cxx.

96{
97
98 //=== make sure pulseshape is available
99 if(!m_deformedShape){
100 ATH_MSG_ERROR("No pulseshape loaded!");
101 return 0.;
102 }
103
104 //=== interpolate pulseShape value, TMath::BinarySearch returns
105 //=== index of value smaller or equal to the search value.
106 //=== -> Need to catch boundary values
107 double y(0.);
108 int n(m_deformedShape->GetN());
109 int idx = TMath::BinarySearch(n,m_deformedShape->GetX(),x);
110 if(idx<0){
111 //=== left out of bounds, return leftmost value
112// y = (_deformedShape->GetY())[0];
113 y = 0;
114 ATH_MSG_DEBUG("Left out of bounds. Replacing y = " << (m_deformedShape->GetY())[0] << " with y = 0. (idx = " << idx << ", x = " << x << ")");
115 }
116 else if(idx>=n-1){
117 //=== right out of bounds, return rightmost value
118// y = (_deformedShape->GetY())[n-1];
119 if(useUndershoot){
122 } else {
123 y = 0.00196 * (1 - exp(- x / 20664.59) ) - 0.00217;
124 }
125 }
126 else{
127 y = 0;
128 ATH_MSG_DEBUG("Right out of bounds. Replacing y = " << (m_deformedShape->GetY())[0] << " with y = 0. (idx = " << idx << ", x = " << x << ")");
129 }
130 }
131 else{
132 //=== linear interpolation
133 double xLo = (m_deformedShape->GetX())[idx ];
134 double xHi = (m_deformedShape->GetX())[idx+1];
135 double yLo = (m_deformedShape->GetY())[idx ];
136 double yHi = (m_deformedShape->GetY())[idx+1];
137 double yLinear = yLo + (yHi-yLo)/(xHi-xLo) * (x-xLo);
138 //=== spline interpolation
139 double ySpline = m_deformedSpline->Eval(x);
140
141 if(useSpline) y = ySpline;
142 else y = yLinear;
143 }
144
145 return y;
146}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define y
#define x
double m_undershootAmplitude
double m_undershootDecayTime
bool m_useConfiguredUndershoot

◆ getGraph()

TGraph * TilePulseShape::getGraph ( double t0 = 0.,
double ped = 0.,
double amp = 1. )

Definition at line 189 of file TilePulseShape.cxx.

190{
191 TGraph* gr = (TGraph*) m_deformedShape->Clone();
192 for(int i=0; i<gr->GetN(); i++){
193 double x,y;
194 gr->GetPoint(i,x,y);
195 y*=amp;
196 y+=ped;
197 x+=t0;
198 gr->SetPoint(i,x,y);
199 }
200 return gr;
201}
#define gr
static Double_t t0

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ loadPulseShape()

void TilePulseShape::loadPulseShape ( const TString & fileName)

Definition at line 47 of file TilePulseShape.cxx.

48{
50 if(m_pulseShape) delete m_pulseShape;
51 m_pulseShape = new TGraph(fileName.Data());
52 if(m_pulseShape->IsZombie()) {
53 throw GaudiException(std::string("could not load pulseshape from file: ") + fileName.Data(),
54 "TilePulseShape", StatusCode::FAILURE);
55 } else ATH_MSG_INFO("Loaded pulseshape from file: " << fileName);
57}
#define ATH_MSG_INFO(x,...)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ resetDeformation()

void TilePulseShape::resetDeformation ( )

Definition at line 150 of file TilePulseShape.cxx.

151{
152 if(m_deformedShape==m_pulseShape) return;
153
154 delete m_deformedShape;
155 delete m_deformedSpline;
157 m_deformedSpline = new TSpline3("deformedSpline",m_deformedShape);
158}

◆ scalePulse()

int TilePulseShape::scalePulse ( double leftSF = 1.,
double rightSF = 1. )

Definition at line 162 of file TilePulseShape.cxx.

163{
164
166 if(!m_pulseShape) {
167 ATH_MSG_WARNING("Attempted pulse shape scaling before loading pulse shape");
168 return 1;
169 } else {
170 m_deformedShape = (TGraph*) m_pulseShape->Clone();
171
172 for(int i=0; i<m_deformedShape->GetN(); ++i){
173 double x,y;
174 m_deformedShape->GetPoint(i,x,y);
175 if(x<0.) x*= leftSF;
176 else if(x>0.) x*=rightSF;
177 m_deformedShape->SetPoint(i,x,y);
178 }
179
180 delete m_deformedSpline;
181 m_deformedSpline = new TSpline3("deformedSpline",m_deformedShape);
182 return 0;
183 }
184
185}
#define ATH_MSG_WARNING(x,...)

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setPulseShape()

void TilePulseShape::setPulseShape ( const std::vector< double > & shapevec)

Definition at line 60 of file TilePulseShape.cxx.

61{
63 if(m_pulseShape) delete m_pulseShape;
64 m_pulseShape = new TGraph(shapevec.size());
65 for(std::vector<double>::size_type i = 0; i != shapevec.size(); i++) {
66 m_pulseShape->SetPoint(i, -75.5+i*0.5, shapevec.at(i));
67 }
69}

◆ setUndershootParameters()

void TilePulseShape::setUndershootParameters ( double amplitude,
double decayTime )

Definition at line 72 of file TilePulseShape.cxx.

73{
74 m_undershootAmplitude = amplitude;
75 m_undershootDecayTime = decayTime;
77}

◆ undershootAmplitude()

double TilePulseShape::undershootAmplitude ( ) const
inline

Definition at line 26 of file TilePulseShape.h.

26{ return m_undershootAmplitude; }

◆ undershootDecayTime()

double TilePulseShape::undershootDecayTime ( ) const
inline

Definition at line 27 of file TilePulseShape.h.

27{ return m_undershootDecayTime; }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_deformedShape

TGraph* TilePulseShape::m_deformedShape {nullptr}
private

Definition at line 41 of file TilePulseShape.h.

41{nullptr};

◆ m_deformedSpline

TSpline* TilePulseShape::m_deformedSpline {nullptr}
private

Definition at line 42 of file TilePulseShape.h.

42{nullptr};

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_pulseShape

TGraph* TilePulseShape::m_pulseShape {nullptr}
private

Definition at line 40 of file TilePulseShape.h.

40{nullptr};

◆ m_undershootAmplitude

double TilePulseShape::m_undershootAmplitude {}
private

Definition at line 44 of file TilePulseShape.h.

44{};

◆ m_undershootDecayTime

double TilePulseShape::m_undershootDecayTime {}
private

Definition at line 45 of file TilePulseShape.h.

45{};

◆ m_useConfiguredUndershoot

bool TilePulseShape::m_useConfiguredUndershoot {false}
private

Definition at line 43 of file TilePulseShape.h.

43{false};

The documentation for this class was generated from the following files: