ATLAS Offline Software
Loading...
Searching...
No Matches
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
26
27#include <iostream>
28#include <sstream>
29#include <iomanip>
30#include <cmath>
31
32
33namespace {
34// get cabling
35const TileCablingService * const s_cabling = TileCablingService::getInstance();
36}
37
38TileHit::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
47TileHit::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
62TileHit::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
74int TileHit::add(float energy, float time)
75{
76 m_energy.push_back(energy);
77 m_time.push_back(time);
78 return 1;
79}
80
81int 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
107int 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
117void 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
137int TileHit::frag_ID(void) const {
138 return s_cabling->frag(m_pmt_id);
139}
140
141void TileHit::print() const
142{
143 std::cout << (std::string) (*this) << std::endl;
144}
145
146TileHit::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
157void 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}
static const TileCablingService * getInstance()
get pointer to service instance
Identifier m_pmt_id
Logical ID of the pmt.
HWIdentifier pmt_HWID(void) const
Return pmt hardware ID (== channel ID)
Definition TileHit.cxx:125
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
int frag_ID(void) const
Return frag ID (like in BS file)
Definition TileHit.cxx:137
std::string whoami(void) const
Return name of this object.
float time(int ind=0) const
Return time of ind-th sub-hit.
Identifier tt_ID(void) const
Return trigger tower ID.
Definition TileHit.cxx:129
void scale(float coeff)
Scale energy of all sub-hits in a hit.
Definition TileHit.cxx:117
TileHit()
Default constructor needed for POOL.
void print(void) const
Dump contents of the hit to std::out.
Definition TileHit.cxx:141
std::vector< float > m_time
Time of the energy deposition relative to BC.
float energy(int ind=0) const
Return energy of ind-th sub-hit.
Identifier identify(void) const
Return logical ID of the pmt.
int add(float energy, float time)
Add sub-hit to a given hit.
Definition TileHit.cxx:74
std::vector< float > m_energy
Energy deposited in scint, as seen by pmt in sepatate time bins.
Identifier mt_ID(void) const
Return muon trigger ID.
Definition TileHit.cxx:133
int size(void) const
Return length of energy/time vectors.
double time(int ind=0) const
Return time of ind-th sub-hit.
Definition TileSimHit.h:53
double energy(int ind=0) const
Return energy of ind-th sub-hit.
Definition TileSimHit.h:51
int size(void) const
Return length of energy/time vectors.
Definition TileSimHit.h:55
std::string label(const std::string &format, int i)
Definition label.h:19