80 {
82
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();
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{};
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 }
128
129 if (stc) {
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];
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()<<
","
150 <<validflag<<
","<<
stat<<
",";
151
152 for (int ii = -2; ii < 35; ii++) {
153 if (ii == -2) {
154 ftube<<chi2tdc<<",";
155 } else if (ii == 0) {
157 } else if (ii == 4) {
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 }