ATLAS Offline Software
TileLaserCalibAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Gaudi includes
6 #include "GaudiKernel/ISvcLocator.h"
7 
8 // Athena includes
11 
12 
13 // Tile includes
14 #include "TileLaserCalibAlg.h"
15 
16 #include "TFile.h"
17 #include <iostream>
18 
19 /****************************************************/
20 /* TileLaserCalibAlg.cxx March 5th 2008 */
21 /* */
22 /* M.Cascella michele.cascella@cern.ch */
23 /* I.Vivarelli iacopo.vivarelli@cern.ch */
24 /* A.Dotti andrea.dotti@cern.ch */
25 /* */
26 /* S. Viret (25/06/2008) : */
27 /* Code cleaning to fit with the new */
28 /* conditions stuff */
29 /****************************************************/
30 
31 TileLaserCalibAlg::TileLaserCalibAlg(const std::string& name, ISvcLocator* pSvcLocator)
32  : AthAlgorithm(name, pSvcLocator)
33  , m_RobSvc("ROBDataProviderSvc" , name)
34  , m_outfile(nullptr)
35  , m_fileName("LaserCalib.root")
36  , m_runNo(0)
37  , m_runType(0)
38 {
39 
40  declareProperty("FileName", m_fileName);
41 }
42 
44 }
45 
47 
51 
52  ATH_MSG_INFO( "Initializing TileLaserCalibAlg" );
53 
54  // Find necessary services
55  CHECK( m_RobSvc.retrieve() );
56 
57  m_runNo = 0;
58 
60  CHECK( m_lasTools.retrieve() );
61 
63  lastools_t::iterator fTool = m_lasTools.begin();
64  for (; fTool != m_lasTools.end(); ++fTool) {
65  CHECK( (*fTool)->initialize() );
66  }
67 
68  return StatusCode::SUCCESS;
69 }
70 
72 
74 
75  ATH_MSG_DEBUG( "Running on execute! TileLaserCalibAlg" );
76 
77  // Get the run number and type once for all
78 
79  if (m_runNo == 0) {
80  m_runNo = static_cast<uint32_t>(m_RobSvc->getEvent()->run_no());
81  m_runType = static_cast<uint32_t>(m_RobSvc->getEvent()->run_type());
82  }
83 
84  // Then check that we are dealing with a LASER event
85  //
86  // If run_type is 0,1 or 2, the correct trigger type (52) should be there
87  // If run_type is 15 (Test) trigger type is not available
88 
89  int trig_type = static_cast<uint32_t>(m_RobSvc->getEvent()->lvl1_trigger_type());
90 
91  if (trig_type != 52 && m_runType != 15) {
92  ATH_MSG_DEBUG( "This is not a LASER event : skip it !!" );
93  return StatusCode::SUCCESS;
94  }
95 
98  lastools_t::iterator fTool = m_lasTools.begin();
99 
100  for (; fTool != m_lasTools.end(); ++fTool) {
101  CHECK( (*fTool)->execute() );
102  }
103 
104  return StatusCode::SUCCESS;
105 }
106 
108 
110 
111  ATH_MSG_INFO( "Finalizing TileLaserCalibAlg" );
112 
113  // Writing the corresponding ROOTfile
114  m_outfile = new TFile(m_fileName.c_str(), "recreate");
115 
118  lastools_t::iterator fTool = m_lasTools.begin();
119 
120  for (; fTool != m_lasTools.end(); ++fTool) {
121  CHECK( (*fTool)->finalizeCalculations() ); // Perform the calibration
122  CHECK( (*fTool)->writeNtuple(m_runNo, 2, m_outfile) ); // Fill the nTuple
123  }
124 
125  m_outfile->Write();
126  m_outfile->Close();
127 
128  return StatusCode::SUCCESS;
129 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TileLaserCalibAlg::m_fileName
std::string m_fileName
Definition: TileLaserCalibAlg.h:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TileLaserCalibAlg::~TileLaserCalibAlg
virtual ~TileLaserCalibAlg()
Definition: TileLaserCalibAlg.cxx:43
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TileLaserCalibAlg::TileLaserCalibAlg
TileLaserCalibAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileLaserCalibAlg.cxx:31
ROBDataProviderSvc.h
TileLaserCalibAlg.h
TileLaserCalibAlg::m_lasTools
lastools_t m_lasTools
Definition: TileLaserCalibAlg.h:36
TileLaserCalibAlg::m_runNo
int m_runNo
Definition: TileLaserCalibAlg.h:57
TileLaserCalibAlg::finalize
StatusCode finalize()
Definition: TileLaserCalibAlg.cxx:109
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
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileLaserCalibAlg::execute
StatusCode execute()
Definition: TileLaserCalibAlg.cxx:73
TileLaserCalibAlg::m_RobSvc
ServiceHandle< IROBDataProviderSvc > m_RobSvc
Definition: TileLaserCalibAlg.h:39
TileLaserCalibAlg::m_runType
int m_runType
Definition: TileLaserCalibAlg.h:58
TileLaserCalibAlg::initialize
StatusCode initialize()
implementing the Gaudi Hooks
Definition: TileLaserCalibAlg.cxx:50
TileLaserCalibAlg::m_outfile
TFile * m_outfile
Definition: TileLaserCalibAlg.h:46