30 {
31
33 static std::map< SG::auxid_t, ::TClass* > s_dictCache =
34 std::map< SG::auxid_t, ::TClass* >();
35
36 TFileChecker::TFileChecker()
37 : ::TObject(), m_stopOnError( kFALSE ), m_ignoredVariables(),
38 m_orpannedContainers() {
39
40 }
41
42 StatusCode TFileChecker::check( TEvent& event ) {
43
44
45 m_orpannedContainers.clear();
46
47
48 if( !
event.getEntries() ) {
49 return StatusCode::SUCCESS;
50 }
51
52
53 if(
event.getEntry( 0 ) < 0 ) {
55 XAOD_MESSAGE(
"Couldn't load event 0 from the input" ) );
56 return StatusCode::FAILURE;
57 }
58
59
60 std::set< std::string > containerNames;
62 EventFormat::const_iterator ef_itr =
ef->begin();
63 EventFormat::const_iterator ef_end =
ef->end();
64 for( ; ef_itr != ef_end; ++ef_itr ) {
65
66
67 if( ef_itr->first.find( "Aux." ) == ( ef_itr->first.size() - 4 ) ) {
68 continue;
69 }
70 if( ef_itr->second.parentName() != "" ) {
71 continue;
72 }
73
74
76 continue;
77 }
78
79
80 containerNames.insert( ef_itr->first );
81 }
82
83
84 const ::Long64_t
entries =
event.getEntries();
86
87
88 if(
event.getEntry( entry ) < 0 ) {
90 XAOD_MESSAGE(
"Failed to load event %i from the input" ),
91 static_cast< int >( entry ) );
92 return StatusCode::FAILURE;
93 }
94
95
96 if( ! ( entry % 100 ) ) {
97 Info(
"check",
"Now validating entry %i / %i",
98 static_cast< int >( entry ),
static_cast< int >(
entries ) );
99 }
100
101
102 for( const std::string& cname : containerNames ) {
103
104
108
109
110 if( m_stopOnError ) {
112 checkContainer( *
vec, cname ) );
113 } else {
114 if( checkContainer( *
vec, cname ).isFailure() ) {
117 "event %i" ),
118 cname.c_str(),
static_cast< int >( entry ) );
119 }
120 }
121 }
122 }
123
124
125 return StatusCode::SUCCESS;
126 }
127
128 void TFileChecker::setStopOnError( ::Bool_t value ) {
129
130 m_stopOnError =
value;
131 return;
132 }
133
134 ::Bool_t TFileChecker::stopOnError() const {
135
136 return m_stopOnError;
137 }
138
139 void TFileChecker::addIgnoredVariable( const std::string& name ) {
140
141 m_ignoredVariables.insert( name );
142 return;
143 }
144
145 void
146 TFileChecker::setIgnoredVariables( const std::set< std::string >& value ) {
147
148 m_ignoredVariables =
value;
149 return;
150 }
151
152 const std::set< std::string >& TFileChecker::ignoredVariables() const {
153
154 return m_ignoredVariables;
155 }
156
158 const std::string& name ) {
159
160
164 if( ! ioStore ) {
165 if( ! cStore ) {
166
167
168 if( m_orpannedContainers.find( name ) ==
169 m_orpannedContainers.end() ) {
170 Error(
"checkContainer",
172 "container: %s" ),
174 m_orpannedContainers.insert( name );
175 return StatusCode::FAILURE;
176 }
177 return StatusCode::SUCCESS;
178 } else {
179
180
181
182
183
184 return StatusCode::SUCCESS;
185 }
186 }
187
188
189 const size_t size =
vec.size_v();
190
191
194
195
197
198
199
200 const void* vecPtr = ioStore->
getIOData( auxid );
201 if( ! vecPtr ) {
202 Error(
"checkContainer",
204 name.c_str(),
reg.getName( auxid ).c_str() );
205 return StatusCode::FAILURE;
206 }
207
208
210 auto itr = s_dictCache.find( auxid );
211 if( itr != s_dictCache.end() ) {
213 } else {
214 const std::type_info* typeId =
reg.getVecType( auxid );
215 if( ! typeId ) {
216 Error(
"checkContainer",
218 "variable %s" ),
219 reg.getName( auxid ).c_str() );
220 return StatusCode::FAILURE;
221 }
222 cl = ::TClass::GetClass( *typeId );
223 s_dictCache[ auxid ] =
cl;
224 }
225 if( ! cl ) {
226 Error(
"checkContainer",
227 XAOD_MESSAGE(
"Couldn't get dictionary for variable %s" ),
228 reg.getName( auxid ).c_str() );
229 return StatusCode::FAILURE;
230 }
231
232
233 ::TVirtualCollectionProxy*
proxy =
cl->GetCollectionProxy();
234 if( ! proxy ) {
235 Error(
"checkContainer",
237 "variable %s" ),
238 reg.getName( auxid ).c_str() );
239 return StatusCode::FAILURE;
240 }
241
242
243 proxy->PushProxy( (
void* ) vecPtr );
244 const size_t varSize =
static_cast< size_t >(
proxy->Size() );
246
247
248 if( ( size != varSize ) &&
249 ( m_ignoredVariables.find(
reg.getName( auxid ) ) ==
250 m_ignoredVariables.end() ) ) {
251 Error(
"checkContainer",
252 XAOD_MESSAGE(
"%s.size() (%i) != %sAux.%s.size() (%i)" ),
253 name.c_str(),
static_cast< int >( size ),
254 name.c_str(),
reg.getName( auxid ).c_str(),
255 static_cast< int >( varSize ) );
256 return StatusCode::FAILURE;
257 }
258 }
259
260
261 return StatusCode::SUCCESS;
262 }
263
264}
std::vector< size_t > vec
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Manage index tracking and synchronization of auxiliary data.
Interface providing I/O for a generic auxiliary store.
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.
Interface for const operations on an auxiliary store.
A set of aux data identifiers.
Error
The different types of error that can be flagged in the L1TopoRDO.
size_t auxid_t
Identifier for a particular aux data item.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
EventFormat_v1 EventFormat
Definition of the current event format version.