ATLAS Offline Software
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"
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 
126  return s_cabling->s2h_channel_id(m_pmt_id);
127 }
128 
130  return s_cabling->pmt2tt_id(m_pmt_id);
131 }
132 
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 }
TileHit::scale
void scale(float coeff)
Scale energy of all sub-hits in a hit
Definition: TileHit.cxx:117
TileHit::frag_ID
int frag_ID(void) const
Return frag ID (like in BS file)
Definition: TileHit.cxx:137
TileHit::mt_ID
Identifier mt_ID(void) const
Return muon trigger ID
Definition: TileHit.cxx:133
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
TileHit::TileHit
TileHit()
Default constructor needed for POOL.
Definition: TileSimEvent/TileSimEvent/TileHit.h:34
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
TileCablingService::getInstance
static const TileCablingService * getInstance()
get pointer to service instance
Definition: TileCablingService.cxx:24
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
TileSimHit
Definition: TileSimHit.h:31
HWIdentifier
Definition: HWIdentifier.h:13
TileHit::size
int size(void) const
Return length of energy/time vectors
Definition: TileSimEvent/TileSimEvent/TileHit.h:94
TileID.h
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
TileCablingService.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
TileHit::add
int add(float energy, float time)
Add sub-hit to a given hit.
Definition: TileHit.cxx:74
TileSimHit::time
double time(int ind=0) const
Return time of ind-th sub-hit
Definition: TileSimHit.h:53
TileHit::print
void print(void) const
Dump contents of the hit to std::out
Definition: TileHit.cxx:141
TileCablingService
Definition: TileCablingService.h:23
TileHit.h
TileSimHit::energy
double energy(int ind=0) const
Return energy of ind-th sub-hit
Definition: TileSimHit.h:51
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
TileSimHit::size
int size(void) const
Return length of energy/time vectors
Definition: TileSimHit.h:55
TileSimHit.h
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
TileHit::tt_ID
Identifier tt_ID(void) const
Return trigger tower ID
Definition: TileHit.cxx:129
TileHit::m_pmt_id
Identifier m_pmt_id
Logical ID of the pmt
Definition: TileSimEvent/TileSimEvent/TileHit.h:112
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
TileHit::pmt_HWID
HWIdentifier pmt_HWID(void) const
Return pmt hardware ID (== channel ID)
Definition: TileHit.cxx:125
TileHit::energy
float energy(int ind=0) const
Return energy of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:90
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
TileHit::time
float time(int ind=0) const
Return time of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:92
TileHit::m_time
std::vector< float > m_time
Time of the energy deposition relative to BC
Definition: TileSimEvent/TileSimEvent/TileHit.h:116
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:114