ATLAS Offline Software
L2OverlapRemoverMon.icc
Go to the documentation of this file.
1 /* -*- mode:c++ -*-
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 template<class T>
6 StatusCode L2OverlapRemoverMon :: fillVariablesOverlapRemoverPlots(const std::string &chain, std::string &&trigstep) const
7 {
8 
9  auto NInMuon = Monitored::Scalar<int>(trigstep+"_"+chain+"_NInMuon", -999.);
10  auto NOutMuon = Monitored::Scalar<int>(trigstep+"_"+chain+"_NOutMuon", -999.);
11  auto NRemovedMuon = Monitored::Scalar<int>(trigstep+"_"+chain+"_NRemovedMuon", -999.);
12 
13  using CONTAINER = DataVector<T>;
14  std::vector< TrigCompositeUtils::LinkInfo<CONTAINER> > featureCont = getTrigDecisionTool()->features<CONTAINER>( chain, TrigDefs::includeFailedDecisions );
15  NInMuon = featureCont.size();
16 
17 
18  // Check overlap
19  std::vector<int> vec_OverlapInsonsistent;
20  auto OverlapInsonsistent = Monitored::Collection(trigstep+"_"+chain+"_OverlapInsonsistent", vec_OverlapInsonsistent);
21 
22  unsigned int i,j;
23  std::vector<unsigned int> muResult;
24  bool errorWhenIdentifyingOverlap = false;
25 
26 
27  for(i=0; i<featureCont.size(); i++) muResult.emplace_back(i);
28  for(i=0; i<featureCont.size(); i++){
29  ATH_CHECK( featureCont[i].isValid() );
30  for(j=i+1; j<featureCont.size(); j++){
31  ATH_CHECK( featureCont[j].isValid() );
32  bool overlapped = isOverlap(chain, featureCont[i].link, featureCont[j].link);
33  if( !overlapped ){ // judged as different
34  if( muResult[i] == muResult[j] ) { // but marked as same by someone
35  ATH_MSG_DEBUG( "inconsistentency in muFast overlap removal for more than two objects" );
36  ATH_MSG_DEBUG( "two objects are judged as different but both were already marked as identical by someone else as: " );
37  ATH_MSG_DEBUG( "i/j/result[i]/result[j]=" << i << " / " << j << " / " << muResult[i] << " / " << muResult[j] );
38  vec_OverlapInsonsistent.push_back(0);
39  errorWhenIdentifyingOverlap = true;
40  }
41  }
42  else{ // judged as overlap
43  if( (muResult[j] != j && muResult[i] != muResult[j]) || (muResult[j] == j && muResult[i] != i) ){
44  ATH_MSG_DEBUG( "inconsistentency in muFast overlap removal for more than two objects" );
45  ATH_MSG_DEBUG( "two objects are judged as overlap but only either was already marked as overlap to someone else: " );
46  ATH_MSG_DEBUG( "i/j/result[i]/result[j]=" << i << " / " << j << " / " << muResult[i] << " / " << muResult[j] );
47  vec_OverlapInsonsistent.push_back(1);
48  errorWhenIdentifyingOverlap = true;
49  }
50  if( muResult[i] == i ) {
51  ATH_MSG_DEBUG( " i is not yet marked as overlap. so, it is a newly found overlap" );
52  ATH_MSG_DEBUG( " -> marking muResult[j] as i..." );
53  muResult[j] = i;
54  } else {
55  ATH_MSG_DEBUG( " both i/j already marked as overlap by: muResult[i]=" << muResult[i] );
56  ATH_MSG_DEBUG( " -> do nothing..." );
57  }
58  }
59  }
60  }
61 
62 
63  // If there is inconsistency in the overlap judgment, input becomes output as it is.
64  if( errorWhenIdentifyingOverlap ) {
65  NOutMuon = featureCont.size();
66  NRemovedMuon = 0;
67  fill(m_group+"_"+chain, NInMuon, NOutMuon, NRemovedMuon);
68  return StatusCode::SUCCESS;
69  }
70 
71  // check number of unique muon
72  unsigned int NUniqueMuon = 0;
73  for(i=0; i<featureCont.size(); i++) {
74  if( muResult[i] == i ) NUniqueMuon++;
75  }
76  ATH_MSG_DEBUG( "number of unique Muons after overlap removal=" << NUniqueMuon );
77 
78 
79  if( featureCont.size() != NUniqueMuon ){
80  ATH_CHECK( chooseBestMuon(chain, featureCont, muResult) );
81  NOutMuon = NUniqueMuon;
82  } else {
83  NOutMuon = featureCont.size();
84  }
85 
86  NRemovedMuon = featureCont.size() - NUniqueMuon;
87 
88  fill(m_group+"_"+chain, NInMuon, NOutMuon, NRemovedMuon);
89 
90  return StatusCode::SUCCESS;
91 
92 }