ATLAS Offline Software
CompareCells.cxx
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4  */
5 
6 #include "CompareCells.h"
8 
9 #include <iostream>
10 CompareCells::CompareCells( const std::string& name,
11  ISvcLocator* pSvcLocator ) :
12  ::AthReentrantAlgorithm( name, pSvcLocator ),
13  m_dataAccessSvc( "TrigCaloDataAccessSvc/TrigCaloDataAccessSvc", name )
14 {
15  declareProperty("TrigDataAccessMT",m_dataAccessSvc,"Data Access for LVL2 Calo Algorithms in MT");
16  m_calocellcollectionKey = "AllCalo";
17 }
18 
20  CHECK( m_dataAccessSvc.retrieve() );
24  return StatusCode::SUCCESS;
25 }
26 
27 StatusCode CompareCells::execute( const EventContext& context ) const {
28  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
29 
31  m_dataAccessSvc->loadFullCollections( context, c).ignore();
32 
33  std::vector<const TileCell*> mbts; // testing
34  m_dataAccessSvc->loadMBTS( context, mbts).ignore();
35 
36  ATH_MSG_DEBUG("MBTS Dump");
37  for (size_t i=0;i<mbts.size(); ++i)
38  ATH_MSG_DEBUG(mbts[i]->eta() << " " << mbts[i]->phi() << " " << mbts[i]->caloDDE()->getSampling() << " " << mbts[i]->energy() );
39 
40 
42 
43  const EventIDBase eventInfo = context.eventID();
44  uint32_t lumiBlock = eventInfo.lumi_block();
45  uint32_t runNumber = eventInfo.run_number();
46  uint32_t bcid = eventInfo.bunch_crossing_id();
47  uint32_t eventn = eventInfo.event_number();
48 
49  ATH_MSG_DEBUG("EVENT INFO : " << lumiBlock << " " << runNumber << " " << bcid << " " << eventn);
50 
51  float max_diff=-999.0;
52  float max_diff_restricted_et=-999.0;
53  float max_diff_restricted_samp=-999.0;
54  float mean_diff=0.0;
55  float mean_sum1=0.0;
56  float mean_sum2=0.0;
57  float mean_diff_n=0.0;
58  float mean_diff_restricted_et=0.0;
59  float mean_sum1_restricted_et=0.0;
60  float mean_sum2_restricted_et=0.0;
61  float mean_diff_restricted_et_n=0.0;
62  float mean_diff_restricted_samp=0.0;
63  float mean_sum1_restricted_samp=0.0;
64  float mean_sum2_restricted_samp=0.0;
65  float mean_diff_restricted_samp_n=0.0;
66  for( auto offcell : *off ) {
67  Identifier id = offcell->ID();
68  if ( offcell->caloDDE()->is_tile() ) continue;
69  for ( auto hltcell : c) {
70  const CaloDetDescrElement* hltdde = hltcell->caloDDE();
71  if ( hltdde && hltdde->is_tile() ) continue;
72  if ( id == hltcell->ID() ) {
73  int samp = hltdde->getSampling();
74  if ( offcell->et() > 5e3 )
75  ATH_MSG_DEBUG("CHECK Cell " << hltcell->energy() << " " << offcell->energy() << " " << hltcell->eta() << " " << hltcell->phi() << " " << samp);
76  float diff = hltcell->energy() - offcell->energy();
77  float diff_et = hltcell->et() - offcell->et();
78  if ( diff < 0 ) diff = -diff;
79  if ( diff > max_diff ) max_diff = diff;
80  mean_diff += diff;
81  mean_sum1 += hltcell->energy();
82  mean_sum2 += offcell->energy();
83  mean_diff_n++;
84  if ( diff_et > 2e3 )
85  ATH_MSG_DEBUG("CHECK Diff et " << diff_et << " " << hltcell->energy() << " " << offcell->energy() << " " << hltcell->eta() << " " << hltcell->phi() << " " << samp);
86  if ( diff > 10e3 )
87  ATH_MSG_DEBUG("CHECK Diff " << diff << " " << hltcell->energy() << " " << offcell->energy() << " " << hltcell->eta() << " " << hltcell->phi() << " " << samp);
88  if ( offcell->et() < 3e3 ) {
89  if ( diff > max_diff_restricted_et ) max_diff_restricted_et = diff;
90  mean_sum1_restricted_et+=hltcell->energy();
91  mean_sum2_restricted_et+=offcell->energy();
92  mean_diff_restricted_et+=diff;
93  mean_diff_restricted_et_n++;
94  }
95  if ( samp < 21 ) {
96  if ( diff > max_diff_restricted_samp ) max_diff_restricted_samp = diff;
97  mean_sum1_restricted_samp+=hltcell->energy();
98  mean_sum2_restricted_samp+=offcell->energy();
99  mean_diff_restricted_samp+=diff;
100  mean_diff_restricted_samp_n++;
101  }
102  break;
103  } // end of if hltcell ID
104  } // end of for hltcell
105  } // end of for offcell
106  ATH_MSG_DEBUG( "RESULTS : " << bcid << " " << eventn << " " << max_diff << " " << max_diff_restricted_et << " " << mean_diff << " " << mean_diff_n << " " << mean_diff_restricted_et << " " << mean_diff_restricted_et_n << " " << mean_diff_restricted_samp << " " << mean_diff_restricted_samp_n << " " << mean_sum1 << " " << mean_sum2 << " " << mean_sum1_restricted_et << " " << mean_sum2_restricted_et << " " << mean_sum1_restricted_samp << " " << mean_sum2_restricted_samp);
107 
108 
109  return StatusCode::SUCCESS;
110 
111 }
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CompareCells::m_dataAccessSvc
ServiceHandle< ITrigCaloDataAccessSvc > m_dataAccessSvc
Definition: CompareCells.h:26
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CompareCells::m_bcidAvgKey
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Definition: CompareCells.h:30
CompareCells::initialize
virtual StatusCode initialize() override
Definition: CompareCells.cxx:19
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
CompareCells::m_calocellcollectionKey
SG::ReadHandleKey< CaloCellContainer > m_calocellcollectionKey
Definition: CompareCells.h:28
RunTileMonitoring.mbts
mbts
Definition: RunTileMonitoring.py:133
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CompareCells::CompareCells
CompareCells(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CompareCells.cxx:10
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloDetDescrElement::is_tile
bool is_tile() const
cell belongs to Tile
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:442
CompareCells::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: CompareCells.cxx:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CompareCells::m_mcsymKey
SG::ReadCondHandleKey< LArMCSym > m_mcsymKey
Definition: CompareCells.h:34
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
CaloConstCellContainer
CaloCellContainer that can accept const cell pointers.
Definition: CaloConstCellContainer.h:45
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
CompareCells.h
CaloConstCellContainer.h
CaloCellContainer that can accept const cell pointers.
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
python.compressB64.c
def c
Definition: compressB64.py:93