ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
MuonCalib::TubeDataFromFile Class Reference

#include <TubeDataFromFile.h>

Collaboration diagram for MuonCalib::TubeDataFromFile:

Public Types

using TubeData = std::vector< const MdtTubeFitContainer * >
 

Public Member Functions

 TubeDataFromFile ()=default
 
 ~TubeDataFromFile ()=default
 
unsigned int nRegions () const
 return number of regions More...
 
const MdtTubeFitContainergetTubes (unsigned int regionId) const
 retrieve MdtTubeFitContainer for a give regionId More...
 
void setNRegions (unsigned int n)
 set total number of regions More...
 
bool addTubes (int regionId, const MdtTubeFitContainer *tubes)
 TubeDataFromFile takes ownership of the MdtTubeFitContainer. More...
 
std::ostream & write (std::ostream &os) const
 
std::ostream & write_forDB (std::ostream &ftube, int mdt_head, int lowrun, int uprun) const
 

Private Attributes

unsigned int m_regions {0}
 total number of regions More...
 
TubeData m_tubeData
 data More...
 

Detailed Description

Manage the I/O of MdtTubeFitContainer objects.

Author
domiz.nosp@m.ia.o.nosp@m.resta.nosp@m.no@c.nosp@m.ern.c.nosp@m.h
Date
july 2005

Definition at line 24 of file TubeDataFromFile.h.

Member Typedef Documentation

◆ TubeData

Definition at line 26 of file TubeDataFromFile.h.

Constructor & Destructor Documentation

◆ TubeDataFromFile()

MuonCalib::TubeDataFromFile::TubeDataFromFile ( )
default

◆ ~TubeDataFromFile()

MuonCalib::TubeDataFromFile::~TubeDataFromFile ( )
default

Member Function Documentation

◆ addTubes()

bool MuonCalib::TubeDataFromFile::addTubes ( int  regionId,
const MdtTubeFitContainer tubes 
)
inline

TubeDataFromFile takes ownership of the MdtTubeFitContainer.

Definition at line 53 of file TubeDataFromFile.h.

53  {
54  if (regionId < 0 || regionId >= (int)m_regions) {
55  MsgStream log(Athena::getMessageSvc(), "MdtTubeFitContainer");
56  log << MSG::WARNING << "TubeDataFromFile::addTubes: <regionId out of range> " << regionId << " size " << m_regions
57  << endmsg;
58  return false;
59  }
60  if (m_tubeData[regionId] != 0) {
61  MsgStream log(Athena::getMessageSvc(), "MdtTubeFitContainer");
62  log << MSG::WARNING << "TubeDataFromFile::addTubes: <tubes already set>" << endmsg;
63  return false;
64  }
65 
66  m_tubeData[regionId] = tubes;
67 
68  return true;
69  }

◆ getTubes()

const MdtTubeFitContainer* MuonCalib::TubeDataFromFile::getTubes ( unsigned int  regionId) const
inline

retrieve MdtTubeFitContainer for a give regionId

Definition at line 36 of file TubeDataFromFile.h.

36  {
37  if (regionId >= (unsigned int)m_regions) {
38  MsgStream log(Athena::getMessageSvc(), "MdtTubeFitContainer");
39  log << MSG::WARNING << "TubeDataFromFile::getTubes: <regionId out of range> " << regionId << " size " << m_regions
40  << endmsg;
41  return nullptr;
42  }
43  return m_tubeData[regionId];
44  }

◆ nRegions()

unsigned int MuonCalib::TubeDataFromFile::nRegions ( ) const
inline

return number of regions

Definition at line 33 of file TubeDataFromFile.h.

33 { return m_regions; }

◆ setNRegions()

void MuonCalib::TubeDataFromFile::setNRegions ( unsigned int  n)
inline

set total number of regions

Definition at line 47 of file TubeDataFromFile.h.

47  {
48  m_regions = n;
49  m_tubeData.resize(n);
50  }

◆ write()

std::ostream & MuonCalib::TubeDataFromFile::write ( std::ostream &  os) const

Definition at line 17 of file TubeDataFromFile.cxx.

17  {
18  if (m_regions != m_tubeData.size()) {
19  MsgStream log(Athena::getMessageSvc(), "MdtTubeFitContainer");
20  log << MSG::WARNING << "TubeDataFromFile::write: <inconsistent count>" << endmsg;
21  }
22 
23  os << "v0.0 " << m_regions << " ";
24  unsigned int counter{0};
25  for (const MdtTubeFitContainer* container : m_tubeData) {
26  if (!container) continue;
27  const unsigned int nml = container->numMultilayers();
28  const unsigned int nl = container->numLayers();
29  const unsigned int nt = container->numTubes();
30  const std::string datatype = container->name();
31  const std::string implementation = container->implementation();
32  const int stnEta = container->idHelperSvc()->stationEta(container->identify());
33  const int stnPhi = container->idHelperSvc()->stationPhi(container->identify());
34  const std::string stnName = container->idHelperSvc()->stationNameString(container->identify());
35  os << datatype << " " << implementation << " " << counter << " " << container->size() << std::endl;
36  ++counter;
37  const MdtIdHelper& id_helper{container->idHelperSvc()->mdtIdHelper()};
38  for (unsigned int km = 1; km <= nml; ++km) {
39  for (unsigned int kl = 1; kl <= nl; ++kl) {
40  for (unsigned int kt = 1; kt <= nt; ++kt) {
41  const Identifier chId{id_helper.channelID(container->identify(),km ,kl ,kt)};
42  const MdtTubeFitContainer::SingleTubeCalib* stc = container->getCalib(chId);
43  const MdtTubeFitContainer::SingleTubeFit* stf = container->getFit(chId);
44  double t0 = 999.;
45  if (stc) {
46  t0 = stc->t0;
47  if (std::isnan(t0) != 0) t0 = -99999.;
48  }
49  constexpr int technology = 0;
50  os << " " << stnName << " " << stnPhi << " " << stnEta
51  << " " << technology << " " << km << " " << kl << " " << kt;
52  if (stc) {
53  os << " " << t0 << " " << stc->adcCal << " " << stc->statusCode;
54  } else{
55  os << " " << 0 << " " << 0 << " " << 0;
56 
57  }
58  if (stf)
59  os << " " << stf->statistics << " " << stf->chi2Tdc << " " << stf->cov[4] // stf->t0Err
60  << " " << stf->par[5] // stf->tMax
61  << " " << stf->cov[5] // stf->tMaxErr
62  << " " << stf->par[0] // stf->noise
63  << " " << stf->cov[0] // stf->noiseErr
64  << " " << stf->par[6] // stf->slope
65  << " " << stf->cov[6]; // stf->slopeErr;
66  else {
67  os << " " << -1 << " " << 0 << " " << 0 << " " << 0 << " "
68  << 0 << " " << 0 << " " << 0 << " " << 0 << " "
69  << 0;
70  }
71  os << std::endl;
72  }
73  }
74  }
75  }
76  return os;
77  }

◆ write_forDB()

std::ostream & MuonCalib::TubeDataFromFile::write_forDB ( std::ostream &  ftube,
int  mdt_head,
int  lowrun,
int  uprun 
) const

Definition at line 80 of file TubeDataFromFile.cxx.

80  {
82  // write out ascii files for Calibration DB //
84  if (m_regions != m_tubeData.size()) {
85  MsgStream log(Athena::getMessageSvc(), "MdtTubeFitContainer");
86  log << MSG::WARNING << "TubeDataFromFile::write_forDB: <inconsistent count>" << endmsg;
87  }
88 
89  for (const MdtTubeFitContainer* container : m_tubeData) {
90  if (!container) continue;
91  const unsigned int nml = container->numMultilayers();
92  const unsigned int nl = container->numLayers();
93  const unsigned int nt = container->numTubes();
94  const std::string datatype = container->name();
95  const std::string implementation = container->implementation();
96  const int stnEta = container->idHelperSvc()->stationEta(container->identify());
97  const int stnPhi = container->idHelperSvc()->stationPhi(container->identify());
98  const std::string stnName = container->idHelperSvc()->stationNameString(container->identify());
99 
100  const MdtIdHelper& id_helper{container->idHelperSvc()->mdtIdHelper()};
101  for (unsigned int km = 1; km <= nml; ++km) {
102  for (unsigned int kl = 1; kl <= nl; ++kl) {
103  for (unsigned int kt = 1; kt <= nt; ++kt) {
104  const Identifier chId{id_helper.channelID(container->identify(),km ,kl ,kt)};
105  const MdtTubeFitContainer::SingleTubeCalib* stc = container->getCalib(chId);
106  const MdtTubeFitContainer::SingleTubeFit* stf = container->getFit(chId);
107  constexpr int technology = 0;
108 
109  MuonFixedId fixId{};
110  int sc{0}, stat{-1};
111  double t0{0.}, adcm{0.}, chi2tdc{0.}, t0err{0.},
112  tmax{0.}, tmaxerr{0.}, noise{0.}, noiseerr{0.},
113  slope{0.}, sloperr{0.};
114  int tube_id{0}, runflag{0}, validflag{0};
115 
116  if (!fixId.setTechnology(technology) ||
117  !fixId.setStationName(fixId.stationStringToFixedStationNumber(stnName)) ||
118  !fixId.setStationEta(stnEta) ||
119  !fixId.setStationPhi(stnPhi) ||
120  !fixId.setMdtTube(kt) ||
121  !fixId.setMdtTubeLayer(kl) ||
122  !fixId.setMdtMultilayer(km)) {
123  std::stringstream except{};
124  except<<__FILE__<<":"<<__LINE__<<"nTubeDataFromFile::write_forDB() - Setting identifier failed!";
125  throw std::runtime_error(except.str());
126  }
127  tube_id = fixId.getIdInt();
128 
129  if (stc) {
130  t0 = stc->t0;
131  adcm = stc->adcCal;
132  sc = stc->statusCode;
133  }
134  if (stf) {
135  stat = stf->statistics;
136  chi2tdc = stf->chi2Tdc;
137  t0err = stf->cov[4];
138  tmax = stf->par[5];
139  tmaxerr = stf->cov[5];
140  noise = stf->par[0];
141  noiseerr = stf->cov[0];
142  slope = stf->par[6];
143  sloperr = stf->cov[6];
144  }
145 
146  if (std::isnan(t0) != 0) t0 = -99999.;
147 
148  ftube<<mdt_head<<","<<tube_id<<","<<fixId.mdtChamberId().getIdInt()<<","
149  <<","<<lowrun<<","<<uprun<<","<<runflag<<","<<sc
150  <<validflag<<","<<stat<<",";
151 
152  for (int ii = -2; ii < 35; ii++) {
153  if (ii == -2) {
154  ftube<<chi2tdc<<",";
155  } else if (ii == 0) {
156  ftube<<noise<<",";
157  } else if (ii == 4) {
158  ftube<<t0<<",";
159  } else if (ii == 5) {
160  ftube<<tmax<<",";
161  } else if (ii == 6) {
162  ftube<<slope<<",";
163  } else if (ii == 10) {
164  ftube<<t0err<<",";
165  } else if (ii == 11) {
166  ftube<<tmaxerr<<",";
167  } else if (ii == 12) {
168  ftube<<noiseerr<<",";
169  } else if (ii == 13) {
170  ftube<<sloperr<<",";
171  } else if (ii == 14) {
172  ftube<<adcm<<",";
173  } else {
174  ftube<<0.0<<",";
175  }
176  }
177  ftube<<"0,0,algoflag,tubegrpgr"<<std::endl;
178  }
179  }
180  }
181  }
182  return ftube;
183  }

Member Data Documentation

◆ m_regions

unsigned int MuonCalib::TubeDataFromFile::m_regions {0}
private

total number of regions

Definition at line 77 of file TubeDataFromFile.h.

◆ m_tubeData

TubeData MuonCalib::TubeDataFromFile::m_tubeData
private

data

Definition at line 80 of file TubeDataFromFile.h.


The documentation for this class was generated from the following files:
MuonCalib::TubeDataFromFile::m_regions
unsigned int m_regions
total number of regions
Definition: TubeDataFromFile.h:77
SingleTubeCalib
MuonCalib::MdtTubeCalibContainer::SingleTubeCalib SingleTubeCalib
Definition: MdtCalibrationTool.cxx:30
MuonCalib::SingleTubeFit
MdtTubeFitContainer::SingleTubeFit SingleTubeFit
Definition: MdtTubeFitContainer.cxx:7
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
ParticleJetParams::kt
@ kt
Definition: ParticleJetParamDefs.h:43
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
keylayer_zslicemap.kl
kl
Definition: keylayer_zslicemap.py:109
calibdata.tube_id
tube_id
Definition: calibdata.py:30
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
calibdata.uprun
uprun
Definition: calibdata.py:34
MdtIdHelper
Definition: MdtIdHelper.h:61
beamspotman.stat
stat
Definition: beamspotman.py:266
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
MuonCalib::TubeDataFromFile::m_tubeData
TubeData m_tubeData
data
Definition: TubeDataFromFile.h:80
calibdata.lowrun
lowrun
Definition: calibdata.py:33
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
calibdata.implementation
implementation
Definition: calibdata.py:43
beamspotnt.nt
def nt
Definition: bin/beamspotnt.py:1063
test_pyathena.counter
counter
Definition: test_pyathena.py:15
python.SystemOfUnits.km
int km
Definition: SystemOfUnits.py:95
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
Identifier
Definition: IdentifierFieldParser.cxx:14