30 {
31
32 namespace Experimental {
33
35 static std::map< SG::auxid_t, ::TClass* > s_dictCache =
36 std::map< SG::auxid_t, ::TClass* >();
37
38 RFileChecker::RFileChecker()
39 : ::TObject(), m_stopOnError( kFALSE ), m_ignoredVariables(),
40 m_orpannedContainers() {
41
42 }
43
44 StatusCode RFileChecker::check( REvent& event ) {
45
46
47
48
49 m_orpannedContainers.clear();
50
51
52 if( !
event.getEntries() ) {
53 return StatusCode::SUCCESS;
54 }
55
56 if(
event.getEntry( 0 ) < 0 ) {
58 XAOD_MESSAGE(
"Couldn't load event 0 from the input" ) );
59 return StatusCode::FAILURE;
60 }
61
62
63 std::set< std::string > containerNames;
65 EventFormat::const_iterator ef_itr =
ef->begin();
66 EventFormat::const_iterator ef_end =
ef->end();
67
68
69
70 for( ; ef_itr != ef_end; ++ef_itr ) {
71
72
73 if( ef_itr->first.find( "Aux." ) == ( ef_itr->first.size() - 4 ) ) {
74 continue;
75 }
76 if( ef_itr->second.parentName() != "" ) {
77 continue;
78 }
79
80
82 continue;
83 }
84
85
86 containerNames.insert( ef_itr->first );
87 }
88
89
90 const ::Long64_t
entries =
event.getEntries();
92
93
94 if(
event.getEntry( entry ) < 0 ) {
96 XAOD_MESSAGE(
"Failed to load event %i from the input" ),
97 static_cast< int >( entry ) );
98 return StatusCode::FAILURE;
99 }
100
101
102 if( ! ( entry % 100 ) ) {
103 Info(
"check",
"Now validating entry %i / %i",
104 static_cast< int >( entry ),
static_cast< int >(
entries ) );
105 }
106
107
108 for( const std::string& cname : containerNames ) {
109
110
114
115
116 if( m_stopOnError ) {
118 checkContainer( *
vec, cname ) );
119 } else {
120 if( checkContainer( *
vec, cname ).isFailure() ) {
123 "event %i" ),
124 cname.c_str(),
static_cast< int >( entry ) );
125 }
126 }
127 }
128 }
129
130
131 return StatusCode::SUCCESS;
132 }
133
134 void RFileChecker::setStopOnError( ::Bool_t value ) {
135
136 m_stopOnError =
value;
137 return;
138 }
139
140 ::Bool_t RFileChecker::stopOnError() const {
141
142 return m_stopOnError;
143 }
144
145 void RFileChecker::addIgnoredVariable( const std::string& name ) {
146
147 m_ignoredVariables.insert( name );
148 return;
149 }
150
151 void
152 RFileChecker::setIgnoredVariables( const std::set< std::string >& value ) {
153
154 m_ignoredVariables =
value;
155 return;
156 }
157
158 const std::set< std::string >& RFileChecker::ignoredVariables() const {
159
160 return m_ignoredVariables;
161 }
162
164 const std::string& name ) {
165
166
170 if( ! ioStore ) {
171 if( ! cStore ) {
172
173
174 if( m_orpannedContainers.find( name ) ==
175 m_orpannedContainers.end() ) {
176 Error(
"checkContainer",
178 "container: %s" ),
180 m_orpannedContainers.insert( name );
181 return StatusCode::FAILURE;
182 }
183 return StatusCode::SUCCESS;
184 } else {
185
186
187
188
189
190 return StatusCode::SUCCESS;
191 }
192 }
193
194
195 const size_t size =
vec.size_v();
196
197
200
201
203
204
205
206 const void* vecPtr = ioStore->
getIOData( auxid );
207 if( ! vecPtr ) {
208 Error(
"checkContainer",
210 name.c_str(),
reg.getName( auxid ).c_str() );
211 return StatusCode::FAILURE;
212 }
213
214
216 auto itr = s_dictCache.find( auxid );
217 if( itr != s_dictCache.end() ) {
219 } else {
220 const std::type_info* typeId =
reg.getVecType( auxid );
221 if( ! typeId ) {
222 Error(
"checkContainer",
224 "variable %s" ),
225 reg.getName( auxid ).c_str() );
226 return StatusCode::FAILURE;
227 }
228 cl = ::TClass::GetClass( *typeId );
229 s_dictCache[ auxid ] =
cl;
230 }
231 if( ! cl ) {
232 Error(
"checkContainer",
233 XAOD_MESSAGE(
"Couldn't get dictionary for variable %s" ),
234 reg.getName( auxid ).c_str() );
235 return StatusCode::FAILURE;
236 }
237
238
239 ::TVirtualCollectionProxy*
proxy =
cl->GetCollectionProxy();
240 if( ! proxy ) {
241 Error(
"checkContainer",
243 "variable %s" ),
244 reg.getName( auxid ).c_str() );
245 return StatusCode::FAILURE;
246 }
247
248
249 proxy->PushProxy( (
void* ) vecPtr );
250 const size_t varSize =
static_cast< size_t >(
proxy->Size() );
252
253
254 if( ( size != varSize ) &&
255 ( m_ignoredVariables.find(
reg.getName( auxid ) ) ==
256 m_ignoredVariables.end() ) ) {
257 Error(
"checkContainer",
258 XAOD_MESSAGE(
"%s.size() (%i) != %sAux.%s.size() (%i)" ),
259 name.c_str(),
static_cast< int >( size ),
260 name.c_str(),
reg.getName( auxid ).c_str(),
261 static_cast< int >( varSize ) );
262 return StatusCode::FAILURE;
263 }
264 }
265
266
267 return StatusCode::SUCCESS;
268 }
269
270 }
271
272}
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.