ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AFP::SiGlobAlignDBTool Class Reference

Tool providing local alignment of silicon detectors from the conditions database. More...

#include <SiGlobAlignDBTool.h>

Inheritance diagram for AFP::SiGlobAlignDBTool:
Collaboration diagram for AFP::SiGlobAlignDBTool:

Public Member Functions

 SiGlobAlignDBTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~SiGlobAlignDBTool () override
 Does nothing. More...
 
virtual StatusCode initialize () override
 Does nothing. More...
 
virtual StatusCode finalize () override
 Does nothing. More...
 
nlohmann::json alignmentData (const EventContext &ctx) const override
 Provide alignment parameters for a given station. Returns nullptr if no data available. More...
 
const SiGlobAlignData alignment (const nlohmann::json &jsondata, const int stationID) const override
 

Private Attributes

SG::ReadCondHandleKey< CondAttrListCollectionm_rch_glob {this, "glob_align_key", "/FWD/Onl/AFP/Align/Global", "read condition handle for global alignement"}
 

Detailed Description

Tool providing local alignment of silicon detectors from the conditions database.

Definition at line 33 of file SiGlobAlignDBTool.h.

Constructor & Destructor Documentation

◆ SiGlobAlignDBTool()

AFP::SiGlobAlignDBTool::SiGlobAlignDBTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 18 of file SiGlobAlignDBTool.cxx.

18  :
19  base_class(type, name, parent)
20  {
21  }

◆ ~SiGlobAlignDBTool()

virtual AFP::SiGlobAlignDBTool::~SiGlobAlignDBTool ( )
inlineoverridevirtual

Does nothing.

Definition at line 39 of file SiGlobAlignDBTool.h.

39 {}

Member Function Documentation

◆ alignment()

const SiGlobAlignData AFP::SiGlobAlignDBTool::alignment ( const nlohmann::json jsondata,
const int  stationID 
) const
override

Definition at line 59 of file SiGlobAlignDBTool.cxx.

60  {
61  ATH_MSG_DEBUG("will get global alignment for station "<<stationID);
62  nlohmann::json channeldata=jsondata["data"];
63 
64  // first, try to guess the channel nr.
65  SiGlobAlignData GA_guess(stationID);
66  std::vector<int> guess_ch_vec{stationID*4, stationID*4+1, stationID*4+2, stationID*4+3};
67  int guess_ch_correct=0;
68  for(auto guess_ch : guess_ch_vec)
69  {
70  nlohmann::json aligndata=channeldata.at(std::to_string(guess_ch)); // because using int would be too simple
71  int st=aligndata["stationID"];
72  std::string alignType=aligndata["alignType"];
73  if(stationID==st)
74  {
75  if(alignType=="tracker" && !(guess_ch_correct&1))
76  {
77  ATH_MSG_DEBUG("channel guessed correctly, stationID "<<st<<", alignType "<<alignType<<", channel guess "<<guess_ch);
78  GA_guess.setTracker(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
79  guess_ch_correct+=1;
80  }
81  else if(alignType=="beam" && !(guess_ch_correct&2))
82  {
83  ATH_MSG_DEBUG("channel guessed correctly, stationID "<<st<<", alignType "<<alignType<<", channel guess "<<guess_ch);
84  GA_guess.setBeam(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
85  guess_ch_correct+=2;
86  }
87  else if(alignType=="RP" && !(guess_ch_correct&4))
88  {
89  ATH_MSG_DEBUG("channel guessed correctly, stationID "<<st<<", alignType "<<alignType<<", channel guess "<<guess_ch);
90  GA_guess.setRP(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
91  guess_ch_correct+=4;
92  }
93  else if(alignType=="correction" && !(guess_ch_correct&8))
94  {
95  ATH_MSG_DEBUG("channel guessed correctly, stationID "<<st<<", alignType "<<alignType<<", channel guess "<<guess_ch);
96  GA_guess.setCorr(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
97  guess_ch_correct+=8;
98  }
99  else ATH_MSG_DEBUG("alignType or channel is probably incorrect, stationID "<<stationID<<", alignType "<<alignType<<", channel guess "<<guess_ch<<", guess_ch_correct "<<guess_ch_correct);
100  }
101  }
102 
103  if(guess_ch_correct==15)
104  {
105  ATH_MSG_DEBUG("channels guessed correctly, stationID "<<stationID);
106  return GA_guess;
107  }
108  else
109  {
110  ATH_MSG_DEBUG("channels were not guessed correctly, stationID "<<stationID);
111  }
112 
113  // if guess is not correct, loop over all channels
114  SiGlobAlignData GA_loop(stationID);
115  int loop_ch_correct=0;
116  for(auto& chan : channeldata.items())
117  {
118  // channels are ordered alphabetically: 0,1,10,...,15,2,3,...,9
119  nlohmann::json aligndata=chan.value();
120 
121  int st=aligndata["stationID"];
122  std::string alignType=aligndata["alignType"];
123 
124  if(stationID==st)
125  {
126  if(alignType=="tracker" && !(loop_ch_correct&1))
127  {
128  ATH_MSG_DEBUG("channel found for stationID "<<st<<", alignType "<<alignType<<", channel nr. "<<chan.key());
129  GA_loop.setTracker(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
130  loop_ch_correct+=1;
131  }
132  else if(alignType=="beam" && !(loop_ch_correct&2))
133  {
134  ATH_MSG_DEBUG("channel found for stationID "<<st<<", alignType "<<alignType<<", channel nr. "<<chan.key());
135  GA_loop.setBeam(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
136  loop_ch_correct+=2;
137  }
138  else if(alignType=="RP" && !(loop_ch_correct&4))
139  {
140  ATH_MSG_DEBUG("channel found for stationID "<<st<<", alignType "<<alignType<<", channel nr. "<<chan.key());
141  GA_loop.setRP(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
142  loop_ch_correct+=4;
143  }
144  else if(alignType=="correction" && !(loop_ch_correct&8))
145  {
146  ATH_MSG_DEBUG("channel found for stationID "<<st<<", alignType "<<alignType<<", channel nr. "<<chan.key());
147  GA_loop.setCorr(aligndata["shiftX"], aligndata["shiftY"], aligndata["shiftZ"], aligndata["alpha"], aligndata["beta"], aligndata["gamma"]);
148  loop_ch_correct+=8;
149  }
150  else ATH_MSG_DEBUG("alignType is probably incorrect, stationID "<<stationID<<", alignType "<<alignType<<", channel nr. "<<chan.key()<<", loop_ch_correct "<<loop_ch_correct);
151  }
152 
153  if(loop_ch_correct==15)
154  {
155  ATH_MSG_DEBUG("channels found correctly, stationID "<<stationID);
156  return GA_loop;
157  }
158  else
159  {
160  ATH_MSG_DEBUG("channels were not found correctly, stationID "<<stationID);
161  }
162  }
163 
164  ATH_MSG_WARNING("global alignment data stationID "<<stationID<<" not found in any channels, returning zeros");
165  return SiGlobAlignData(stationID);
166  }

◆ alignmentData()

nlohmann::json AFP::SiGlobAlignDBTool::alignmentData ( const EventContext &  ctx) const
override

Provide alignment parameters for a given station. Returns nullptr if no data available.

Definition at line 37 of file SiGlobAlignDBTool.cxx.

38  {
39  ATH_MSG_DEBUG("will get global alignment for run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", event "<<ctx.eventID().event_number());
40 
42  const CondAttrListCollection* attrGlobList { *ch_glob};
43  if ( attrGlobList == nullptr )
44  {
45  ATH_MSG_WARNING("global alignment data for key " << m_rch_glob.fullKey() << " not found, returning empty string");
46  return nlohmann::json::parse("");
47  }
48 
49  if(attrGlobList->size()>1) ATH_MSG_INFO("there should be only one real channel in "<< m_rch_glob.fullKey() <<", there are "<<attrGlobList->size()<<" real channels, only the first one will be used ");
50 
51  CondAttrListCollection::const_iterator itr = attrGlobList->begin();
52  const coral::AttributeList &atr = itr->second;
53  std::string data = *(static_cast<const std::string *>((atr["data"]).addressOfData()));
54 
56  }

◆ finalize()

StatusCode AFP::SiGlobAlignDBTool::finalize ( )
overridevirtual

Does nothing.

Definition at line 30 of file SiGlobAlignDBTool.cxx.

31  {
32  ATH_MSG_DEBUG("in the finalize of SiGlobAlignDBTool, bye bye");
33  return StatusCode::SUCCESS;
34  }

◆ initialize()

StatusCode AFP::SiGlobAlignDBTool::initialize ( )
overridevirtual

Does nothing.

Definition at line 23 of file SiGlobAlignDBTool.cxx.

24  {
26  ATH_MSG_DEBUG( "using DB with key " << m_rch_glob.fullKey() );
27  return StatusCode::SUCCESS;
28  }

Member Data Documentation

◆ m_rch_glob

SG::ReadCondHandleKey<CondAttrListCollection> AFP::SiGlobAlignDBTool::m_rch_glob {this, "glob_align_key", "/FWD/Onl/AFP/Align/Global", "read condition handle for global alignement"}
private

Definition at line 52 of file SiGlobAlignDBTool.h.


The documentation for this class was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
json
nlohmann::json json
Definition: HistogramDef.cxx:9
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AFP::SiGlobAlignDBTool::m_rch_glob
SG::ReadCondHandleKey< CondAttrListCollection > m_rch_glob
Definition: SiGlobAlignDBTool.h:52
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Muon::nsw::STGTPSegments::moduleIDBits::stationID
constexpr uint8_t stationID
Large or Small wedge.
Definition: NSWSTGTPDecodeBitmaps.h:152
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78