ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelVerify.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*****************************************************************************
6// Filename : TileRawChannelVerify.cxx
7// Author : Zhifang
8// Created : May, 2002
9//
10// DESCRIPTION:
11// Implement the TileRawChannelVerify class
12//
13// HISTORY:
14//
15// BUGS:
16//
17//*****************************************************************************
18
19// Tile includes
23
24// Atlas includes
25// access all RawChannels inside container
28
29// Gaudi includes
30#include "GaudiKernel/Bootstrap.h"
31#include "GaudiKernel/ISvcLocator.h"
32
33// C++ STL includes
34#include <vector>
35#include <algorithm>
36
37// C includes
38#include <cmath>
39
40using namespace std;
41
42
49 public:
50 bool operator()(const TileRawChannel* p1, const TileRawChannel* p2) {
51 return p1->amplitude() < p2->amplitude();
52 }
53};
54
55//==========================================================================
56// TileRawChannelVerify's implementations
57//==========================================================================
58
59// Constructor
60TileRawChannelVerify::TileRawChannelVerify(const std::string& name, ISvcLocator* pSvcLocator)
61 : AthAlgorithm(name, pSvcLocator)
62 , m_tileHWID(0)
63{
64}
65
68
69// Alg standard interfacw function
71
72 // retrieve TileHWID helper from det store
73 CHECK( detStore()->retrieve(m_tileHWID) );
74
77
78 ATH_MSG_INFO( "TileRawChannelVerify initialization completed" );
79
80 return StatusCode::SUCCESS;
81}
82
83StatusCode TileRawChannelVerify::execute(const EventContext& ctx) {
84
85 // step1: read two cell containers from TES
88
89 SelectAllObject<TileRawChannelContainer> selAll1(rawChannelContainer1.cptr());
90 SelectAllObject<TileRawChannelContainer>::const_iterator rawItr1 = selAll1.begin();
91 SelectAllObject<TileRawChannelContainer>::const_iterator end1 = selAll1.end();
92
93 SelectAllObject<TileRawChannelContainer> selAll2(rawChannelContainer2.cptr());
94 SelectAllObject<TileRawChannelContainer>::const_iterator rawItr2 = selAll2.begin();
95 SelectAllObject<TileRawChannelContainer>::const_iterator end2 = selAll2.end();
96
97 // step2: first compare the number of cells in the two containers
98 int nSize1 = 0;
99 for (; rawItr1 != end1; ++rawItr1) ++nSize1;
100
101 int nSize2 = 0;
102 for (; rawItr2 != end2; ++rawItr2) ++nSize2;
103
104 ATH_MSG_INFO( "The number of cells in " << m_rawChannelContainer1Key.key() << " is " << nSize1 );
105 ATH_MSG_INFO( "The number of cells in " << m_rawChannelContainer2Key.key() << " is " << nSize2 );
106
107 if (nSize1 != nSize2) {
108 ATH_MSG_ERROR( "The number of rawChannels is not equal in the two containers" );
109 return (StatusCode::SUCCESS);
110 }
111
112 // step3: to sort the cells in the containers by amplitude
113 vector<const TileRawChannel*> rawChannels1;
114 vector<const TileRawChannel*> rawChannels2;
115 const TileRawChannel* rawChannel1;
116 const TileRawChannel* rawChannel2;
117 if (m_sortFlag) {
118 rawItr1 = selAll1.begin();
119 end1 = selAll1.end();
120 for (; rawItr1 != end1; ++rawItr1)
121 rawChannels1.push_back((*rawItr1));
122
123 sort(rawChannels1.begin(), rawChannels1.end(), CompRawChannel());
124
125 rawItr2 = selAll2.begin();
126 end2 = selAll2.end();
127 for (; rawItr2 != end2; ++rawItr2)
128 rawChannels2.push_back((*rawItr2));
129
130 sort(rawChannels2.begin(), rawChannels2.end(), CompRawChannel());
131 }
132
133 rawItr1 = selAll1.begin();
134 end1 = selAll1.end();
135
136 rawItr2 = selAll2.begin();
137 end2 = selAll2.end();
138
139 // step4: then compare every cell-pair in the containers
140 bool bErrorFlag = false;
141 bool bHeaderFlag = true;
142 for (int i = 0; i < nSize1; ++i) {
143 if (m_sortFlag) {
144 rawChannel1 = rawChannels1[i];
145 rawChannel2 = rawChannels2[i];
146 } else {
147 rawChannel1 = (*rawItr1);
148 ++rawItr1;
149 rawChannel2 = (*rawItr2);
150 ++rawItr2;
151 }
152 HWIdentifier id1 = rawChannel1->adc_HWID();
153 HWIdentifier id2 = rawChannel2->adc_HWID();
154 double amp1 = rawChannel1->amplitude();
155 double amp2 = rawChannel2->amplitude();
156 double diff = fabs(amp1 - amp2);
157 if (id1 != id2 || diff > m_precision) bErrorFlag = true;
158 if (msgLvl(MSG::VERBOSE) && (m_dumpRawChannels || bErrorFlag)) {
159 if (bHeaderFlag) {
160 msg(MSG::VERBOSE) << " ===" << m_rawChannelContainer1Key.key()
161 << "=== ===" << m_rawChannelContainer2Key.key() << "===" << endmsg;
162 msg(MSG::VERBOSE) << " Index e1 id1 | e2 id2" << endmsg;
163 msg(MSG::VERBOSE) << "--------------------------------------------------------------------------------" << endmsg;
164 bHeaderFlag = false;
165 }
166 msg(MSG::VERBOSE) << setw(5) << i
167 << " " << setw(12) << amp1
168 << " [" << m_tileHWID->to_string(id1) << "]"
169 << " | " << setw(12) << amp2
170 << " [" << m_tileHWID->to_string(id2) << "]";
171 if (diff > m_precision) {
172 msg(MSG::VERBOSE) << " A* ";
173 }
174 if (id1 != id2) {
175 msg(MSG::VERBOSE) << " I* ";
176 }
177 msg(MSG::VERBOSE) << endmsg;
178 } else if (bErrorFlag) {
179 break;
180 }
181 }
182 if (!bHeaderFlag) {
183 msg(MSG::VERBOSE) << "--------------------------------------------------------------------------------" << endmsg;
184 }
185 if (!bErrorFlag) {
186 ATH_MSG_INFO( "The two cellContainers (" << m_rawChannelContainer1Key.key()
187 << " and " << m_rawChannelContainer2Key.key() << ") are the same!!!" );
188 } else {
189 ATH_MSG_INFO( "The two cellContainers (" << m_rawChannelContainer1Key.key()
190 << " and " << m_rawChannelContainer2Key.key() << ") are not the same!!!" );
191 }
192
193 // Execution completed.
194 ATH_MSG_INFO( "TileRawChannelVerify execution completed successfully" );
195
196 return StatusCode::SUCCESS;
197}
198
200
201 ATH_MSG_INFO( "TileRawChannelVerify finalized successfully" );
202
203 return StatusCode::SUCCESS;
204}
205
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Handle class for reading from StoreGate.
void diff(const TrigInDetTrack &a, const TrigInDetTrack &b, std::map< std::string, double > &variableChange)
comparison with feedback Function compares two objects and returns "semi verbose" output in the form ...
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
Small class holding a single method to compare two different TileRawChannel.
bool operator()(const TileRawChannel *p1, const TileRawChannel *p2)
const_pointer_type cptr()
Dereference the pointer.
const_iterator end()
const_iterator begin()
StatusCode finalize()
finalize method
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainer1Key
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainer2Key
Gaudi::Property< double > m_precision
StatusCode execute(const EventContext &ctx)
execute method
Gaudi::Property< bool > m_dumpRawChannels
Gaudi::Property< bool > m_sortFlag
virtual ~TileRawChannelVerify()
Destructor.
const TileHWID * m_tileHWID
Pointer to TileHWID.
TileRawChannelVerify(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
StatusCode initialize()
initialize method
float amplitude(int ind=0) const
HWIdentifier adc_HWID(void) const
Definition TileRawData.h:53
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.