ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileSimEvent
src
TileHit.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//********************************************************************
6
// Filename : TileHit.cxx
7
// Author : UC-ATLAS TileCal Group
8
// Created : April, 2002
9
//
10
// DESCRIPTION:
11
// A TileHit is from simulation(G3), and represents the
12
// total energy visible by one PMT
13
//
14
// HISTORY:
15
// 02Feb03: Inherit from TileSimData now
16
// 09Nov03: Inheritace removed, class moved to TileSimEvent
17
//
18
// BUGS:
19
//
20
// *******************************************************************
21
22
#include "
TileSimEvent/TileHit.h
"
23
#include "
TileSimEvent/TileSimHit.h
"
24
#include "
TileConditions/TileCablingService.h
"
25
#include "
CaloIdentifier/TileID.h
"
26
27
#include <iostream>
28
#include <sstream>
29
#include <iomanip>
30
#include <cmath>
31
32
33
namespace
{
34
// get cabling
35
const
TileCablingService
*
const
s_cabling =
TileCablingService::getInstance
();
36
}
37
38
TileHit::TileHit
(
const
Identifier
&
id
,
float
energy
,
float
time
)
39
:
m_pmt_id
( id )
40
,
m_energy
(1)
41
,
m_time
(1)
42
{
43
m_energy
[0] =
energy
;
44
m_time
[0] =
time
;
45
}
46
47
TileHit::TileHit
(
const
Identifier
&
id
,
float
energy
,
float
time
,
float
delta)
48
:
m_pmt_id
( id )
49
,
m_energy
(1)
50
,
m_time
(1)
51
{
52
m_energy
[0] =
energy
;
53
if
(delta>0){
54
m_time
[0] = delta*nearbyint(
time
/delta);
55
}
56
else
{
57
// ignore time completely if delta is zero
58
m_time
[0]=0.0;
59
}
60
}
61
62
TileHit::TileHit
(
const
TileSimHit
* hitInp )
63
:
m_pmt_id
( hitInp->
identify
() )
64
{
65
int
size
= hitInp->
size
();
66
m_energy
.reserve(
size
);
67
m_time
.reserve(
size
);
68
for
(
int
i=0; i<
size
; ++i) {
69
m_energy
.push_back((
float
)hitInp->
energy
(i));
70
m_time
.push_back((
float
)hitInp->
time
(i));
71
}
72
}
73
74
int
TileHit::add
(
float
energy
,
float
time
)
75
{
76
m_energy
.push_back(
energy
);
77
m_time
.push_back(
time
);
78
return
1;
79
}
80
81
int
TileHit::add
(
float
energy
,
float
time
,
float
delta)
82
{
83
if
(delta>0) {
84
int
size
=
m_time
.size();
85
for
(
int
i=0; i<
size
; ++i) {
86
float
dt =
time
-
m_time
[i];
87
if
(fabs(dt)<delta/2.) {
88
m_energy
[i]+=
energy
;
89
//if ( (m_energy[i] += energy) > 0.0)
90
// m_time[i] += dt * energy / m_energy[i];
91
return
0;
92
}
93
}
94
95
m_energy
.push_back(
energy
);
96
m_time
.push_back(delta*nearbyint(
time
/delta));
97
98
}
else
{
99
// ignore time completely if delta is zero
100
m_energy
[0] +=
energy
;
101
return
0;
102
}
103
104
return
1;
105
}
106
107
int
TileHit::add
(
const
TileHit
* hitInp,
float
delta)
108
{
109
int
result=0;
110
int
sizeInp = hitInp->
size
();
111
for
(
int
i=0; i<sizeInp; ++i) {
112
result +=
add
(hitInp->
energy
(i),hitInp->
time
(i),delta);
113
}
114
return
result;
115
}
116
117
void
TileHit::scale
(
float
coeff)
118
{
119
int
i,s;
120
s =
m_energy
.size();
121
for
(i=0; i<s; i++)
122
m_energy
[i] = coeff*
m_energy
[i];
123
}
124
125
HWIdentifier
TileHit::pmt_HWID
(
void
)
const
{
126
return
s_cabling->s2h_channel_id(
m_pmt_id
);
127
}
128
129
Identifier
TileHit::tt_ID
(
void
)
const
{
130
return
s_cabling->pmt2tt_id(
m_pmt_id
);
131
}
132
133
Identifier
TileHit::mt_ID
(
void
)
const
{
134
return
s_cabling->pmt2mt_id(
m_pmt_id
);
135
}
136
137
int
TileHit::frag_ID
(
void
)
const
{
138
return
s_cabling->frag(
m_pmt_id
);
139
}
140
141
void
TileHit::print
()
const
142
{
143
std::cout << (std::string) (*
this
) << std::endl;
144
}
145
146
TileHit::operator std::string()
const
147
{
148
std::ostringstream text;
149
150
text <<
whoami
();
151
text <<
" Id = "
+ s_cabling->getTileID()->to_string(
m_pmt_id
,-1);
// pmt_id => -1 level from adc_id
152
print_to_stream
(
m_energy
,
" ener ="
, text);
153
print_to_stream
(
m_time
,
" time ="
, text);
154
return
text.str();
155
}
156
157
void
TileHit::print_to_stream
(
const
std::vector<float>& val,
158
const
std::string &
label
,
159
std::ostringstream & text)
160
{
161
text <<
label
;
162
163
std::vector<float>::const_iterator it1=val.begin();
164
std::vector<float>::const_iterator it2=val.end();
165
166
for
( ; it1!=it2; ++it1) text <<
" "
<< (*it1);
167
}
TileCablingService.h
TileID.h
TileHit.h
TileSimHit.h
HWIdentifier
Definition
HWIdentifier.h:13
TileCablingService
Definition
TileCablingService.h:23
TileCablingService::getInstance
static const TileCablingService * getInstance()
get pointer to service instance
Definition
TileCablingService.cxx:24
TileHit::m_pmt_id
Identifier m_pmt_id
Logical ID of the pmt.
Definition
TileSimEvent/TileSimEvent/TileHit.h:117
TileHit::pmt_HWID
HWIdentifier pmt_HWID(void) const
Return pmt hardware ID (== channel ID).
Definition
TileHit.cxx:125
TileHit::print_to_stream
static void print_to_stream(const std::vector< float > &val, const std::string &label, std::ostringstream &text)
Print contents of one vector to output stream.
Definition
TileHit.cxx:157
TileHit::frag_ID
int frag_ID(void) const
Return frag ID (like in BS file).
Definition
TileHit.cxx:137
TileHit::whoami
std::string whoami(void) const
Return name of this object.
Definition
TileSimEvent/TileSimEvent/TileHit.h:102
TileHit::time
float time(int ind=0) const
Return time of ind-th sub-hit.
Definition
TileSimEvent/TileSimEvent/TileHit.h:97
TileHit::tt_ID
Identifier tt_ID(void) const
Return trigger tower ID.
Definition
TileHit.cxx:129
TileHit::scale
void scale(float coeff)
Scale energy of all sub-hits in a hit.
Definition
TileHit.cxx:117
TileHit::TileHit
TileHit()
Default constructor needed for POOL.
Definition
TileSimEvent/TileSimEvent/TileHit.h:34
TileHit::print
void print(void) const
Dump contents of the hit to std::out.
Definition
TileHit.cxx:141
TileHit::m_time
std::vector< float > m_time
Time of the energy deposition relative to BC.
Definition
TileSimEvent/TileSimEvent/TileHit.h:121
TileHit::energy
float energy(int ind=0) const
Return energy of ind-th sub-hit.
Definition
TileSimEvent/TileSimEvent/TileHit.h:95
TileHit::identify
Identifier identify(void) const
Return logical ID of the pmt.
Definition
TileSimEvent/TileSimEvent/TileHit.h:81
TileHit::add
int add(float energy, float time)
Add sub-hit to a given hit.
Definition
TileHit.cxx:74
TileHit::m_energy
std::vector< float > m_energy
Energy deposited in scint, as seen by pmt in sepatate time bins.
Definition
TileSimEvent/TileSimEvent/TileHit.h:119
TileHit::mt_ID
Identifier mt_ID(void) const
Return muon trigger ID.
Definition
TileHit.cxx:133
TileHit::size
int size(void) const
Return length of energy/time vectors.
Definition
TileSimEvent/TileSimEvent/TileHit.h:99
TileSimHit
Definition
TileSimHit.h:31
TileSimHit::time
double time(int ind=0) const
Return time of ind-th sub-hit.
Definition
TileSimHit.h:53
TileSimHit::energy
double energy(int ind=0) const
Return energy of ind-th sub-hit.
Definition
TileSimHit.h:51
TileSimHit::size
int size(void) const
Return length of energy/time vectors.
Definition
TileSimHit.h:55
label
std::string label(const std::string &format, int i)
Definition
label.h:19
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0