ATLAS Offline Software
Loading...
Searching...
No Matches
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
31TileLaserCalibAlg::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
45
47
49
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 auto event = m_RobSvc->getEvent(Gaudi::Hive::currentContext());
79
80 if (m_runNo == 0) {
81 m_runNo = static_cast<uint32_t>(event->run_no());
82 m_runType = static_cast<uint32_t>(event->run_type());
83 }
84
85 // Then check that we are dealing with a LASER event
86 //
87 // If run_type is 0,1 or 2, the correct trigger type (52) should be there
88 // If run_type is 15 (Test) trigger type is not available
89
90 int trig_type = static_cast<uint32_t>(event->lvl1_trigger_type());
91
92 if (trig_type != 52 && m_runType != 15) {
93 ATH_MSG_DEBUG( "This is not a LASER event : skip it !!" );
94 return StatusCode::SUCCESS;
95 }
96
98
99 lastools_t::iterator fTool = m_lasTools.begin();
100
101 for (; fTool != m_lasTools.end(); ++fTool) {
102 CHECK( (*fTool)->execute() );
103 }
104
105 return StatusCode::SUCCESS;
106}
107
109
111
112 ATH_MSG_INFO( "Finalizing TileLaserCalibAlg" );
113
114 // Writing the corresponding ROOTfile
115 m_outfile = new TFile(m_fileName.c_str(), "recreate");
116
118
119 lastools_t::iterator fTool = m_lasTools.begin();
120
121 for (; fTool != m_lasTools.end(); ++fTool) {
122 CHECK( (*fTool)->finalizeCalculations() ); // Perform the calibration
123 CHECK( (*fTool)->writeNtuple(m_runNo, 2, m_outfile) ); // Fill the nTuple
124 }
125
126 m_outfile->Write();
127 m_outfile->Close();
128
129 return StatusCode::SUCCESS;
130}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StatusCode initialize()
implementing the Gaudi Hooks
ServiceHandle< IROBDataProviderSvc > m_RobSvc
TileLaserCalibAlg(const std::string &name, ISvcLocator *pSvcLocator)