ATLAS Offline Software
ZdcLEDAnalysisTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ZDCANALYSIS_ZDCLEDANALYSISTOOL_H
6 #define ZDCANALYSIS_ZDCLEDANALYSISTOOL_H
7 
8 #include "AsgTools/AsgTool.h"
14 
17 
19 #include "ZdcAnalysis/ZDCMsg.h"
20 #include <TH1.h>
21 #include <array>
22 
23 namespace ZDC
24 {
25 
27 {
28  unsigned int m_presampleADC{};
29  int m_ADCsum{};
30  int m_maxADC{};
31  unsigned int m_maxSample{};
32  float m_avgTime{};
33 
34 public:
35  ZDCLEDModuleResults(unsigned int presampleADC, unsigned int ADCsum, unsigned int maxADC, unsigned int maxSample, float avgTime) :
36  m_presampleADC(presampleADC),
37  m_ADCsum(ADCsum),
38  m_maxADC(maxADC),
39  m_maxSample(maxSample),
40  m_avgTime(avgTime)
41  {}
42 
44  m_presampleADC(0),
45  m_ADCsum(0),
46  m_maxADC(0),
47  m_maxSample(0),
48  m_avgTime(0)
49  {}
50 
51  unsigned int getPresampleADC() const {return m_presampleADC;}
52  int getADCSum() const {return m_ADCsum;}
53  int getMaxADC() const {return m_maxADC;}
54  unsigned int getMaxSample() const {return m_maxSample;}
55  float getAvgTime() const {return m_avgTime;}
56 
57 };
58 
60 {
61 
63 
64 public:
65  ZdcLEDAnalysisTool(const std::string& name);
66  virtual ~ZdcLEDAnalysisTool() override;
67 
68  //interface from AsgTool
69  StatusCode initialize() override;
70 
71  StatusCode recoZdcModules(const xAOD::ZdcModuleContainer& moduleContainer, const xAOD::ZdcModuleContainer& moduleSumContainer) override;
72  StatusCode reprocessZdc() override;
73 
75  {
76  std::function<bool(int, std::string)> msgFunction = [this](int messageZdcLevel, const std::string& message)-> bool
77  {
78  MSG::Level messageAthenaLevel = static_cast<MSG::Level>(messageZdcLevel);
79  bool passesStreamOutputLevel = messageAthenaLevel >= this->msg().level();
80  if (passesStreamOutputLevel) {
81  this->msg(messageAthenaLevel) << message << endmsg;
82  }
83  return passesStreamOutputLevel;
84  };
85 
86  return ZDCMsg::MessageFunctionPtr(new ZDCMsg::MessageFunction(msgFunction));
87  }
88 
89 private:
90 
91  // Provide methods
92  //
93  void initialize_ppPbPb2023();
94  void initialize_ppALFA2023();
95  void initialize_zdcStandalone();
96 
97  ZDCLEDModuleResults processZDCModule(const xAOD::ZdcModule& module);
98  ZDCLEDModuleResults processRPDModule(const xAOD::ZdcModule& module);
99  ZDCLEDModuleResults processModuleData(int iside, int imod, const std::vector<unsigned short>& data,
100  unsigned int startSample, unsigned int endSample, float gainScale);
101 
102  bool m_init{false};
103 
104  // Job properties
105  //
106  std::string m_name;
107  Gaudi::Property<std::string> m_configuration{this, "Configuration", "ppPbPb2023", "Which config files to use"};
108  bool m_writeAux{false};
109 
110  Gaudi::Property<std::string> m_auxSuffix{this, "AuxSuffix", "", "Append this tag onto end of AuxData"};
111 
112  // Configuration settings based on mConfiguration
113  //
114  Gaudi::Property<bool> m_doRPD{this, "doRPD", true, "Process RPD Data?"};
115  Gaudi::Property<bool> m_doZDC{this, "doZDC", true, "Process ZDC Data?"};
116 
117  // Configuration for LED identification
118  //
119  std::vector<unsigned int> m_LEDCalreqIdx;
120  std::vector<unsigned int> m_LEDBCID;
121 
122  const std::vector<std::string> m_LEDNames = {"Blue1", "Green", "Blue2"};
123  const std::vector<std::string> m_calreqNames = {"CalReq1", "CalReq2", "CalReq3"};
124 
125  unsigned int m_HGADCOverflow{4095};
126  unsigned int m_numSamples{24};
127  unsigned int m_preSample{0};
128  float m_deltaTSample{3.125};
129  unsigned int m_sampleAnaStartZDC{0};
130  unsigned int m_sampleAnaEndZDC{23};
131  unsigned int m_sampleAnaStartRPD{0};
132  unsigned int m_sampleAnaEndRPD{23};
133 
134  float m_ZdcLowGainScale{10};
135 
136  // Module container names
137  //
138  Gaudi::Property<std::string> m_zdcModuleContainerName {this, "ZdcModuleContainerName", "ZdcModules", "Location of ZDC processed data"};
139  const xAOD::ZdcModuleContainer* m_zdcModules {nullptr};
140  Gaudi::Property<std::string> m_zdcSumContainerName {this, "ZdcSumContainerName", "ZdcSums", "Location of ZDC processed sums"};
141  const xAOD::ZdcModuleContainer* m_zdcSums {nullptr};
142 
143  // Storegate keys
144  //
146  this, "EventInfoKey", "EventInfo", "Location of the event info."};
147 
149  this, "ZdcEventTypeKey", "", "ZDC Event type"};
150 
152  this, "ROBBCIDKey", "", "BCID from LUCROD ROB headers"};
153 
155  this, "ZdcDAQModeKey", "", "ZDC DAQ mode"};
156 
157  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_ZdcLEDType{this, "ZdcLEDType", "", "ZDC LED Type (0-Blue1, 1-Green, 2-Blue2}"};
158  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_ZdcLEDPresampleADC{this, "ZdcLEDPresampleADC", "", "ZDC LED presample"};
159  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_ZdcLEDADCSum{this, "ZdcLEDADCSum", "", "ZDC LED pulse FADC sum"};
160  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_ZdcLEDMaxADC{this, "ZdcLEDMaxADC", "", "ZDC LED pulse max FADC value"};
161  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_ZdcLEDMaxSample{this, "ZdcLEDMaxSample", "", "ZDC LED max FADC sample"};
162  SG::WriteDecorHandleKey<xAOD::ZdcModuleContainer> m_ZdcLEDAvgTime{this, "ZdcLEDAvgTime", "", "ZDC LED average time"};
163 
164  // Provide a historam that provides per-ADC channel correction factors for integral and differential
165  // non-linearities
166  //
167  bool m_doFADCCorr{};
168  unsigned int m_runNumber{};
169  int m_forceCalibRun{};
170  std::array< std::array<std::unique_ptr<const TH1>,4>,2> m_FADCCorrHG;
171  std::array< std::array<std::unique_ptr<const TH1>,4>,2> m_FADCCorrLG;
172  double getAmplitudeCorrection(int iside, int imod, bool highGain, float fitAmp);
173  void setFADCCorrections(unsigned int runNumber);
174 
175 };
176 
177 } // namespace ZDC
178 
179 #endif
180 
181 
182 
183 
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition: StoreGate/StoreGate/WriteDecorHandleKey.h:89
ZDC::ZDCLEDModuleResults::ZDCLEDModuleResults
ZDCLEDModuleResults()
Definition: ZdcLEDAnalysisTool.h:43
ZDC::ZdcLEDAnalysisTool
Definition: ZdcLEDAnalysisTool.h:60
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
PropertyWrapper.h
ZDC::ZdcLEDAnalysisTool::m_FADCCorrLG
std::array< std::array< std::unique_ptr< const TH1 >, 4 >, 2 > m_FADCCorrLG
Definition: ZdcLEDAnalysisTool.h:171
ZDC::ZDCLEDModuleResults::m_maxADC
int m_maxADC
Definition: ZdcLEDAnalysisTool.h:30
ZDC::ZdcLEDAnalysisTool::MakeMessageFunction
ZDCMsg::MessageFunctionPtr MakeMessageFunction()
Definition: ZdcLEDAnalysisTool.h:74
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
initialize
void initialize()
Definition: run_EoverP.cxx:894
xAOD::ZdcModule_v1
Class containing ZDC Module information.
Definition: ZdcModule_v1.h:25
ZDC::ZdcLEDAnalysisTool::m_FADCCorrHG
std::array< std::array< std::unique_ptr< const TH1 >, 4 >, 2 > m_FADCCorrHG
Definition: ZdcLEDAnalysisTool.h:170
IZdcAnalysisTool.h
SG::ReadHandleKey< xAOD::EventInfo >
ReweightUtils.message
message
Definition: ReweightUtils.py:15
ZDC::IZdcAnalysisTool
Definition: IZdcAnalysisTool.h:15
ZDC::ZDCLEDModuleResults::getPresampleADC
unsigned int getPresampleADC() const
Definition: ZdcLEDAnalysisTool.h:51
ReadDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
python.PyAthena.module
module
Definition: PyAthena.py:131
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ZDC::ZdcLEDAnalysisTool::m_LEDBCID
std::vector< unsigned int > m_LEDBCID
Definition: ZdcLEDAnalysisTool.h:120
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
ZDC::ZDCLEDModuleResults::m_maxSample
unsigned int m_maxSample
Definition: ZdcLEDAnalysisTool.h:31
ZDC::ZDCLEDModuleResults::m_presampleADC
unsigned int m_presampleADC
Definition: ZdcLEDAnalysisTool.h:28
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ZDC::ZdcLEDAnalysisTool::m_name
std::string m_name
Definition: ZdcLEDAnalysisTool.h:106
ZDC::ZDCLEDModuleResults::getADCSum
int getADCSum() const
Definition: ZdcLEDAnalysisTool.h:52
ZDCMsg.h
ZDC::ZDCLEDModuleResults
Definition: ZdcLEDAnalysisTool.h:27
ZDCMsg::MessageFunction
std::function< bool(int, std::string)> MessageFunction
Definition: ZDCMsg.h:12
ZDC::ZDCLEDModuleResults::m_avgTime
float m_avgTime
Definition: ZdcLEDAnalysisTool.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ZDC::ZDCLEDModuleResults::getAvgTime
float getAvgTime() const
Definition: ZdcLEDAnalysisTool.h:55
ZDC::ZDCLEDModuleResults::getMaxSample
unsigned int getMaxSample() const
Definition: ZdcLEDAnalysisTool.h:54
ZDC::ZDCLEDModuleResults::m_ADCsum
int m_ADCsum
Definition: ZdcLEDAnalysisTool.h:29
ZDC::ZDCLEDModuleResults::getMaxADC
int getMaxADC() const
Definition: ZdcLEDAnalysisTool.h:53
ZDC::ZdcLEDAnalysisTool::m_LEDCalreqIdx
std::vector< unsigned int > m_LEDCalreqIdx
Definition: ZdcLEDAnalysisTool.h:119
ZDCMsg::MessageFunctionPtr
std::shared_ptr< MessageFunction > MessageFunctionPtr
Definition: ZDCMsg.h:14
EventInfo.h
WriteDecorHandleKey.h
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
ZDC
Definition: RPDAnalysisTool.cxx:12
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition: StoreGate/StoreGate/ReadDecorHandleKey.h:85
AsgTool.h
checker_macros.h
Define macros for attributes used to control the static checker.
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
ZdcModuleContainer.h
ZDC::ZDCLEDModuleResults::ZDCLEDModuleResults
ZDCLEDModuleResults(unsigned int presampleADC, unsigned int ADCsum, unsigned int maxADC, unsigned int maxSample, float avgTime)
Definition: ZdcLEDAnalysisTool.h:35
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7