ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondTest
src
NswPassivationTestAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
NswPassivationTestAlg.h
"
6
7
// STL
8
#include <stdio.h>
9
10
#include <chrono>
11
#include <ctime>
12
#include <iostream>
13
#include <fstream>
14
#include <sstream>
15
#include <vector>
16
17
// Gaudi and Athena
18
#include "
AthenaKernel/IOVInfiniteRange.h
"
19
#include "CoralBase/Blob.h"
20
#include "
CoralUtilities/blobaccess.h
"
21
#include "Identifier/Identifier.h"
22
23
// constructor
24
NswPassivationTestAlg::NswPassivationTestAlg
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm
(name, pSvcLocator) {}
25
26
// destructor
27
NswPassivationTestAlg::~NswPassivationTestAlg
() =
default
;
28
29
// initialize
30
StatusCode
NswPassivationTestAlg::initialize
() {
31
ATH_MSG_INFO
(
"Calling initialize"
);
32
ATH_CHECK
(
m_readKey
.initialize());
33
ATH_CHECK
(
m_idHelperSvc
.retrieve());
34
return
StatusCode::SUCCESS;
35
}
36
37
// execute
38
StatusCode
NswPassivationTestAlg::execute
(
const
EventContext& ctx)
const
{
39
ATH_MSG_INFO
(
"Calling execute"
);
40
41
// setup parameters
42
std::chrono::duration<double> retrieving{};
43
44
// retrieve all folders
45
if
(!
retrieve
(ctx, retrieving).isSuccess())
return
StatusCode::FAILURE;
46
47
// postprocess
48
ATH_MSG_INFO
(
"Retrieving time = "
<< (std::chrono::duration_cast<std::chrono::microseconds>(retrieving).
count
() * 1.0) <<
"s "
);
49
50
ATH_MSG_INFO
(
"MADE IT TO THE END!!"
);
51
return
StatusCode::SUCCESS;
52
}
53
54
// retrieveVmm
55
StatusCode
NswPassivationTestAlg::retrieve
(
const
EventContext& ctx, std::chrono::duration<double>& timer)
const
{
56
ATH_MSG_INFO
(
"Starting retrieval "
<<
timestamp
());
57
auto
start1 = std::chrono::high_resolution_clock::now();
58
59
// Start with an infinte range and narrow it down as needed
60
EventIDRange rangeW =
IOVInfiniteRange::infiniteMixed
();
61
62
// Retrieve Data Object
63
SG::ReadCondHandle<NswPassivationDbData>
readHandle{
m_readKey
, ctx};
64
const
NswPassivationDbData
* readCdo{*readHandle};
65
if
(!readCdo) {
66
ATH_MSG_ERROR
(
"Null pointer to the read conditions object"
);
67
return
StatusCode::FAILURE;
68
}
69
70
EventIDRange range;
71
if
(!readHandle.
range
(range)) {
72
ATH_MSG_ERROR
(
"Failed to retrieve validity range for "
<< readHandle.
key
());
73
return
StatusCode::FAILURE;
74
}
75
76
// Intersect validity range of this obj with the validity of already-loaded objs
77
rangeW = EventIDRange::intersect(range, rangeW);
78
79
// retrieve all channels
80
std::vector<Identifier> channelIds = readCdo->
getChannelIds
();
81
ATH_MSG_INFO
(
"Found data for "
<< channelIds.size() <<
" channels!"
);
82
ATH_MSG_INFO
(
"Going to display passivation params for all channels (left, right, top, bottom)"
);
83
84
std::ofstream
fout
;
85
fout
.open(
"passivationDump.txt"
);
86
fout
<<
"athenaId,PCB,stationName,stationEta,stationPhi,multiLayer,gasGap,left,right,top,bottom\n"
;
87
88
// retrieve data for the first channel
89
for
(
unsigned
int
i=0; i<channelIds.size(); ++i){
90
const
Identifier
& channel = channelIds[i];
91
NswPassivationDbData::PCBPassivation
passiv = readCdo->
getPassivation
(channel);
92
int
eta
=
m_idHelperSvc
->mmIdHelper().stationEta(channel);
93
int
chnl =
m_idHelperSvc
->mmIdHelper().channel (channel);
94
int
pcb = (chnl-1)/1024+1;
// int division should round downwards
95
if
(std::abs(
eta
)>1) pcb+=5;
96
ATH_MSG_INFO
(
"Board "
<<i<<
" ("
<<channel.get_compact()<<
"): "
<<passiv.
left
<<
", "
<<passiv.
right
<<
", "
<<passiv.
top
<<
", "
<<passiv.
bottom
);
97
fout
<< channel.get_compact()<<
","
<<pcb<<
","
<<
m_idHelperSvc
->toString(channel)<<
","
<<passiv.
left
<<
","
<<passiv.
right
<<
","
<<passiv.
top
<<
","
<<passiv.
bottom
<<std::endl;
98
}
99
100
fout
.close();
101
102
auto
end1 = std::chrono::high_resolution_clock::now();
103
timer += end1 - start1;
104
ATH_MSG_INFO
(
"Ending at "
<<
timestamp
());
105
return
StatusCode::SUCCESS;
106
}
107
108
std::string
NswPassivationTestAlg::timestamp
()
const
{
109
auto
now = std::chrono::system_clock::now();
110
std::time_t time_now = std::chrono::system_clock::to_time_t(now);
111
std::tm local_tm;
112
localtime_r(&time_now, &local_tm);
113
auto
duration_since_epoch = now.time_since_epoch();
114
auto
milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration_since_epoch) % 1000;
115
std::ostringstream oss;
116
oss << std::put_time(&local_tm,
"%H:%M:%S"
) <<
'.'
<< std::setw(3) << std::setfill(
'0'
) << milliseconds.count();
117
return
oss.str();
118
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
IOVInfiniteRange.h
NswPassivationTestAlg.h
blobaccess.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition
IOVInfiniteRange.h:55
NswPassivationDbData
Definition
NswPassivationDbData.h:20
NswPassivationDbData::getChannelIds
std::vector< Identifier > getChannelIds() const
Definition
NswPassivationDbData.cxx:38
NswPassivationDbData::getPassivation
const PCBPassivation & getPassivation(const Identifier &id) const
Definition
NswPassivationDbData.cxx:47
NswPassivationTestAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition
NswPassivationTestAlg.cxx:38
NswPassivationTestAlg::~NswPassivationTestAlg
virtual ~NswPassivationTestAlg() override
NswPassivationTestAlg::NswPassivationTestAlg
NswPassivationTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
NswPassivationTestAlg.cxx:24
NswPassivationTestAlg::retrieve
StatusCode retrieve(const EventContext &, std::chrono::duration< double > &) const
Definition
NswPassivationTestAlg.cxx:55
NswPassivationTestAlg::m_readKey
SG::ReadCondHandleKey< NswPassivationDbData > m_readKey
Definition
NswPassivationTestAlg.h:31
NswPassivationTestAlg::timestamp
std::string timestamp() const
Definition
NswPassivationTestAlg.cxx:108
NswPassivationTestAlg::initialize
virtual StatusCode initialize() override
Definition
NswPassivationTestAlg.cxx:30
NswPassivationTestAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
NswPassivationTestAlg.h:34
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition
ReadCondHandle.h:223
SG::ReadCondHandle::key
const std::string & key() const
Definition
ReadCondHandle.h:59
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
fout
static TFile * fout
Definition
listroot.cxx:40
Identifier
Definition
IdentifierFieldParser.cxx:14
NswPassivationDbData::PCBPassivation
Helper struct to save the four passivation values of each PCB.
Definition
NswPassivationDbData.h:24
NswPassivationDbData::PCBPassivation::bottom
double bottom
Definition
NswPassivationDbData.h:28
NswPassivationDbData::PCBPassivation::top
double top
Definition
NswPassivationDbData.h:27
NswPassivationDbData::PCBPassivation::right
double right
Definition
NswPassivationDbData.h:26
NswPassivationDbData::PCBPassivation::left
double left
Definition
NswPassivationDbData.h:25
Generated on
for ATLAS Offline Software by
1.17.0