ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelVerify.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 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 declareProperty("Precision", m_precision = 0);
65 declareProperty("DumpRawChannels", m_dumpRawChannels = false);
66 declareProperty("SortFlag", m_sortFlag = false);
67}
68
71
72// Alg standard interfacw function
74
75 // retrieve TileHWID helper from det store
76 CHECK( detStore()->retrieve(m_tileHWID) );
77
80
81 ATH_MSG_INFO( "TileRawChannelVerify initialization completed" );
82
83 return StatusCode::SUCCESS;
84}
85
87
88 // step1: read two cell containers from TES
91
92 SelectAllObject<TileRawChannelContainer> selAll1(rawChannelContainer1.cptr());
93 SelectAllObject<TileRawChannelContainer>::const_iterator rawItr1 = selAll1.begin();
94 SelectAllObject<TileRawChannelContainer>::const_iterator end1 = selAll1.end();
95
96 SelectAllObject<TileRawChannelContainer> selAll2(rawChannelContainer2.cptr());
97 SelectAllObject<TileRawChannelContainer>::const_iterator rawItr2 = selAll2.begin();
98 SelectAllObject<TileRawChannelContainer>::const_iterator end2 = selAll2.end();
99
100 // step2: first compare the number of cells in the two containers
101 int nSize1 = 0;
102 for (; rawItr1 != end1; ++rawItr1) ++nSize1;
103
104 int nSize2 = 0;
105 for (; rawItr2 != end2; ++rawItr2) ++nSize2;
106
107 ATH_MSG_INFO( "The number of cells in " << m_rawChannelContainer1Key.key() << " is " << nSize1 );
108 ATH_MSG_INFO( "The number of cells in " << m_rawChannelContainer2Key.key() << " is " << nSize2 );
109
110 if (nSize1 != nSize2) {
111 ATH_MSG_ERROR( "The number of rawChannels is not equal in the two containers" );
112 return (StatusCode::SUCCESS);
113 }
114
115 // step3: to sort the cells in the containers by amplitude
116 vector<const TileRawChannel*> rawChannels1;
117 vector<const TileRawChannel*> rawChannels2;
118 const TileRawChannel* rawChannel1;
119 const TileRawChannel* rawChannel2;
120 if (m_sortFlag) {
121 rawItr1 = selAll1.begin();
122 end1 = selAll1.end();
123 for (; rawItr1 != end1; ++rawItr1)
124 rawChannels1.push_back((*rawItr1));
125
126 sort(rawChannels1.begin(), rawChannels1.end(), CompRawChannel());
127
128 rawItr2 = selAll2.begin();
129 end2 = selAll2.end();
130 for (; rawItr2 != end2; ++rawItr2)
131 rawChannels2.push_back((*rawItr2));
132
133 sort(rawChannels2.begin(), rawChannels2.end(), CompRawChannel());
134 }
135
136 rawItr1 = selAll1.begin();
137 end1 = selAll1.end();
138
139 rawItr2 = selAll2.begin();
140 end2 = selAll2.end();
141
142 // step4: then compare every cell-pair in the containers
143 bool bErrorFlag = false;
144 bool bHeaderFlag = true;
145 for (int i = 0; i < nSize1; ++i) {
146 if (m_sortFlag) {
147 rawChannel1 = rawChannels1[i];
148 rawChannel2 = rawChannels2[i];
149 } else {
150 rawChannel1 = (*rawItr1);
151 ++rawItr1;
152 rawChannel2 = (*rawItr2);
153 ++rawItr2;
154 }
155 HWIdentifier id1 = rawChannel1->adc_HWID();
156 HWIdentifier id2 = rawChannel2->adc_HWID();
157 double amp1 = rawChannel1->amplitude();
158 double amp2 = rawChannel2->amplitude();
159 double diff = fabs(amp1 - amp2);
160 if (id1 != id2 || diff > m_precision) bErrorFlag = true;
161 if (msgLvl(MSG::VERBOSE) && (m_dumpRawChannels || bErrorFlag)) {
162 if (bHeaderFlag) {
163 msg(MSG::VERBOSE) << " ===" << m_rawChannelContainer1Key.key()
164 << "=== ===" << m_rawChannelContainer2Key.key() << "===" << endmsg;
165 msg(MSG::VERBOSE) << " Index e1 id1 | e2 id2" << endmsg;
166 msg(MSG::VERBOSE) << "--------------------------------------------------------------------------------" << endmsg;
167 bHeaderFlag = false;
168 }
169 msg(MSG::VERBOSE) << setw(5) << i
170 << " " << setw(12) << amp1
171 << " [" << m_tileHWID->to_string(id1) << "]"
172 << " | " << setw(12) << amp2
173 << " [" << m_tileHWID->to_string(id2) << "]";
174 if (diff > m_precision) {
175 msg(MSG::VERBOSE) << " A* ";
176 }
177 if (id1 != id2) {
178 msg(MSG::VERBOSE) << " I* ";
179 }
180 msg(MSG::VERBOSE) << endmsg;
181 } else if (bErrorFlag) {
182 break;
183 }
184 }
185 if (!bHeaderFlag) {
186 msg(MSG::VERBOSE) << "--------------------------------------------------------------------------------" << endmsg;
187 }
188 if (!bErrorFlag) {
189 ATH_MSG_INFO( "The two cellContainers (" << m_rawChannelContainer1Key.key()
190 << " and " << m_rawChannelContainer2Key.key() << ") are the same!!!" );
191 } else {
192 ATH_MSG_INFO( "The two cellContainers (" << m_rawChannelContainer1Key.key()
193 << " and " << m_rawChannelContainer2Key.key() << ") are not the same!!!" );
194 }
195
196 // Execution completed.
197 ATH_MSG_INFO( "TileRawChannelVerify execution completed successfully" );
198
199 return StatusCode::SUCCESS;
200}
201
203
204 ATH_MSG_INFO( "TileRawChannelVerify finalized successfully" );
205
206 return StatusCode::SUCCESS;
207}
208
#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.
HWIdentifier id2
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Handle class for reading from StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() 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
StatusCode execute()
execute method
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainer2Key
bool m_dumpRawChannels
if true=> Differences found in the TileRawChannels are dumped on the screen
double m_precision
maximum difference between the amplitudes of the TileRawChannels to be compared
virtual ~TileRawChannelVerify()
Destructor.
const TileHWID * m_tileHWID
Pointer to TileHWID.
TileRawChannelVerify(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
bool m_sortFlag
if true=> TileRawChannels are sorted by amplitude
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.