ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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)
 
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. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

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

Private Attributes

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

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.

21 {
22 }

◆ TilePulseShape() [2/3]

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

Definition at line 25 of file TilePulseShape.cxx.

27 {
29 }

◆ TilePulseShape() [3/3]

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

Definition at line 32 of file TilePulseShape.cxx.

34 {
35  setPulseShape(shapevec);
36 }

◆ ~TilePulseShape()

TilePulseShape::~TilePulseShape ( )
virtual

Definition at line 39 of file TilePulseShape.cxx.

40 {
42  if(m_pulseShape) delete m_pulseShape;
44 }

Member Function Documentation

◆ eval()

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

Definition at line 75 of file TilePulseShape.cxx.

76 {
77 
78  //=== make sure pulseshape is available
79  if(!m_deformedShape){
80  ATH_MSG_ERROR("No pulseshape loaded!");
81  return 0.;
82  }
83 
84  //=== interpolate pulseShape value, TMath::BinarySearch returns
85  //=== index of value smaller or equal to the search value.
86  //=== -> Need to catch boundary values
87  double y(0.);
88  int n(m_deformedShape->GetN());
89  int idx = TMath::BinarySearch(n,m_deformedShape->GetX(),x);
90  if(idx<0){
91  //=== left out of bounds, return leftmost value
92 // y = (_deformedShape->GetY())[0];
93  y = 0;
94  ATH_MSG_DEBUG("Left out of bounds. Replacing y = " << (m_deformedShape->GetY())[0] << " with y = 0. (idx = " << idx << ", x = " << x << ")");
95  }
96  else if(idx>=n-1){
97  //=== right out of bounds, return rightmost value
98 // y = (_deformedShape->GetY())[n-1];
99  if(useUndershoot){
100  y = 0.00196 * (1 - exp(- x / 20664.59) ) - 0.00217;
101  }
102  else{
103  y = 0;
104  ATH_MSG_DEBUG("Right out of bounds. Replacing y = " << (m_deformedShape->GetY())[0] << " with y = 0. (idx = " << idx << ", x = " << x << ")");
105  }
106  }
107  else{
108  //=== linear interpolation
109  double xLo = (m_deformedShape->GetX())[idx ];
110  double xHi = (m_deformedShape->GetX())[idx+1];
111  double yLo = (m_deformedShape->GetY())[idx ];
112  double yHi = (m_deformedShape->GetY())[idx+1];
113  double yLinear = yLo + (yHi-yLo)/(xHi-xLo) * (x-xLo);
114  //=== spline interpolation
115  double ySpline = m_deformedSpline->Eval(x);
116 
117  if(useSpline) y = ySpline;
118  else y = yLinear;
119  }
120 
121  return y;
122 }

◆ getGraph()

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

Definition at line 165 of file TilePulseShape.cxx.

166 {
167  TGraph* gr = (TGraph*) m_deformedShape->Clone();
168  for(int i=0; i<gr->GetN(); i++){
169  double x,y;
170  gr->GetPoint(i,x,y);
171  y*=amp;
172  y+=ped;
173  x+=t0;
174  gr->SetPoint(i,x,y);
175  }
176  return gr;
177 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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 }

◆ 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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 (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ resetDeformation()

void TilePulseShape::resetDeformation ( )

Definition at line 126 of file TilePulseShape.cxx.

127 {
128  if(m_deformedShape==m_pulseShape) return;
129 
130  delete m_deformedShape;
131  delete m_deformedSpline;
133  m_deformedSpline = new TSpline3("deformedSpline",m_deformedShape);
134 }

◆ scalePulse()

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

Definition at line 138 of file TilePulseShape.cxx.

139 {
140 
142  if(!m_pulseShape) {
143  ATH_MSG_WARNING("Attempted pulse shape scaling before loading pulse shape");
144  return 1;
145  } else {
146  m_deformedShape = (TGraph*) m_pulseShape->Clone();
147 
148  for(int i=0; i<m_deformedShape->GetN(); ++i){
149  double x,y;
150  m_deformedShape->GetPoint(i,x,y);
151  if(x<0.) x*= leftSF;
152  else if(x>0.) x*=rightSF;
153  m_deformedShape->SetPoint(i,x,y);
154  }
155 
156  delete m_deformedSpline;
157  m_deformedSpline = new TSpline3("deformedSpline",m_deformedShape);
158  return 0;
159  }
160 
161 }

◆ 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 }

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 36 of file TilePulseShape.h.

◆ m_deformedSpline

TSpline* TilePulseShape::m_deformedSpline {nullptr}
private

Definition at line 37 of file TilePulseShape.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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 35 of file TilePulseShape.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
gr
#define gr
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
x
#define x
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TilePulseShape::m_deformedSpline
TSpline * m_deformedSpline
Definition: TilePulseShape.h:37
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
TilePulseShape::loadPulseShape
void loadPulseShape(const TString &fileName)
Definition: TilePulseShape.cxx:47
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
rootconvert.yLo
yLo
Definition: rootconvert.py:33
rootconvert.xLo
xLo
Definition: rootconvert.py:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
rootconvert.yHi
yHi
Definition: rootconvert.py:33
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
TilePulseShape::resetDeformation
void resetDeformation()
Definition: TilePulseShape.cxx:126
rootconvert.xHi
xHi
Definition: rootconvert.py:32
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TilePulseShape::m_deformedShape
TGraph * m_deformedShape
Definition: TilePulseShape.h:36
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
TilePulseShape::m_pulseShape
TGraph * m_pulseShape
Definition: TilePulseShape.h:35
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
TilePulseShape::setPulseShape
void setPulseShape(const std::vector< double > &shapevec)
Definition: TilePulseShape.cxx:60