37 void DuplicateChecker ::
38 testInvariant ()
const
47 : m_eventInfoName (
"EventInfo")
54 const std::string& DuplicateChecker ::
55 eventInfoName ()
const
58 return m_eventInfoName;
63 void DuplicateChecker ::
64 setEventInfoName (
const std::string& val_eventInfoName)
67 m_eventInfoName = val_eventInfoName;
72 const std::string& DuplicateChecker ::
73 outputTreeName ()
const
76 return m_outputTreeName;
81 void DuplicateChecker ::
82 setOutputTreeName (
const std::string& val_outputTreeName)
85 m_outputTreeName = val_outputTreeName;
90 void DuplicateChecker ::
91 addKnownDuplicate (
const std::string& sampleName,
97 m_duplicates[std::make_pair (sampleName,
fileName)].insert
103 void DuplicateChecker ::
104 addKnownDuplicatesFile (
const std::string& duplicatesFile)
106 std::ifstream
file (duplicatesFile);
110 if (!
line.empty() &&
line[0] !=
'#')
125 bool DuplicateChecker ::
126 processSummary (
const std::string& submitdir,
const std::string&
treeName)
129 sh.load (submitdir +
"/hist");
131 return processSummary (
sh, submitdir +
"/duplicates");
136 bool DuplicateChecker ::
143 std::set<std::pair<number_type,number_type>> known_list;
144 std::set<std::pair<number_type,number_type>> processed_list;
146 std::unique_ptr<TChain>
tree (
sample->makeTChain());
147 std::string *inputFileName =
nullptr;
148 tree->SetBranchAddress (
"fileName", &inputFileName);
149 Long64_t inputFileIndex;
150 tree->SetBranchAddress (
"fileIndex", &inputFileIndex);
156 tree->SetBranchAddress (
"processed", &processed);
164 if (known_list.find (
id) == known_list.end())
165 known_list.insert (
id);
168 file <<
sample->name() <<
" " << *inputFileName <<
" "
169 << inputFileIndex <<
" " <<
runNumber <<
" "
175 if (processed_list.find (
id) == processed_list.end())
176 processed_list.insert (
id);
180 std::cout <<
"ERROR: duplicate event processed: "
186 if (known_list.size() != processed_list.size())
188 RCU_ASSERT (processed_list.size() < known_list.size());
190 for (
auto&
id : known_list)
192 if (processed_list.find (
id) == processed_list.end())
194 std::cout <<
"ERROR: event never processed: "
211 return StatusCode::SUCCESS;
220 m_inputFileName = wk()->inputFileName();
222 auto iter = m_duplicates.find
224 if (iter != m_duplicates.end())
225 m_currentDuplicates = &iter->second;
227 m_currentDuplicates =
nullptr;
228 return StatusCode::SUCCESS;
238 m_event = wk()->xaodEvent();
240 if (!m_outputTreeName.empty())
242 m_outputTree =
new TTree (m_outputTreeName.c_str(),
"DuplicateChecker tree");
243 wk()->addOutput (m_outputTree);
244 m_outputTree->Branch (
"fileName", &m_inputFileName);
245 m_outputTree->Branch (
"fileIndex", &m_inputFileIndex,
"inputFileIndex/L");
246 m_outputTree->Branch (
"runNumber", &m_runNumber,
"runNumber/i");
247 m_outputTree->Branch (
"eventNumber", &m_eventNumber,
"eventNumber/i");
248 m_outputTree->Branch (
"processed", &m_processEvent,
"processed/O");
251 return StatusCode::SUCCESS;
261 read_run_event_number ();
262 m_processEvent =
true;
264 const std::pair<number_type,number_type>
id (m_runNumber, m_eventNumber);
266 if (m_currentDuplicates !=
nullptr)
268 auto iter = m_currentDuplicates->find (wk()->treeEntry());
269 if (iter != m_currentDuplicates->end())
271 if (
id != iter->second)
273 ATH_MSG_FATAL (
"expected duplicate event at entry " << iter->first
274 <<
" to be run=" << iter->second.first <<
",event="
275 << iter->second.second <<
" but found run="
276 <<
id.first <<
",event=" <<
id.second);
277 return StatusCode::FAILURE;
279 m_processEvent =
false;
286 if (m_processed.find (
id) != m_processed.end())
289 <<
" event=" <<
id.
second <<
" in file "
290 << wk()->inputFileName() <<
" at event "
291 << wk()->treeEntry());
292 m_processEvent =
false;
294 m_processed.insert (
id);
296 if (m_processEvent ==
false)
300 m_inputFileIndex = wk()->treeEntry ();
301 m_outputTree->Fill ();
305 return StatusCode::SUCCESS;
310 void DuplicateChecker ::
311 read_run_event_number ()
314 if (m_event->retrieve (
info, m_eventInfoName).isFailure())
317 m_runNumber =
info->runNumber();
318 m_eventNumber =
info->eventNumber();