1 #include "l3EmcCalibration.h"
20 l3EmcTowerInfo::l3EmcTowerInfo() {
21 set(0., 0., 0., 0., 0., 1.0, -1, -1);
25 l3EmcCalibration::l3EmcCalibration(
int nTow) {
29 daq2id =
new int[nTowers];
32 l3EmcCalibration::~l3EmcCalibration() {
38 int l3EmcCalibration::loadMap(
const char* filename)
41 LOG(ERR,
"Binary maps are no longer supported. Where did you find one?",0,0,0,0,0);
50 int l3EmcCalibration::loadTextMap(
const char* filename) {
52 ifstream txtmap(filename);
56 enum colDesc { col_phi, col_eta,
57 col_ped, col_threshold, col_gain,
58 col_id, col_daqId, col_ignore };
63 if (s !=
"EmcCalib") {
64 LOG(ERR,
"No EMC calibration map in text format in %s\n", filename,0,0,0,0);
69 if (s !=
"columns:") {
70 LOG(ERR,
"No EMC calibration map in text format in %s\n", filename,0,0,0,0);
78 colDesc *colTarget =
new colDesc[nCols];
81 colTarget[0] = col_id;
82 colTarget[1] = col_daqId;
83 colTarget[2] = col_phi;
84 colTarget[3] = col_eta;
85 colTarget[4] = col_ped;
86 colTarget[5] = col_gain;
87 colTarget[6] = col_threshold;
90 for (
int i=0; i<nTowers; i++) {
102 for (
int col=0; col<nCols; col++) {
104 switch (colTarget[col]) {
123 txtmap >> threshold ;
146 if ( (
id < 0) || (
id >= 4800) ) {
147 LOG(ERR,
"%s contains info for tower %i!!!\n",filename,
id,0,0,0);
152 tower[id].set(phi, eta, ped, gain,
id, daqId);
160 int l3EmcCalibration::loadTextMap(
const char* filename)
170 ifstream txtmap(filename);
176 if (s !=
"columns:") {
177 LOG(ERR,
"No EMC calibration found in %s\n", filename,0,0,0,0);
182 colDef.set(0,-1,-1,-1,-1,-1,-1,-1,-1);
185 txtmap >> colDef.nCols;
187 if (type ==
"EmcCalib") {
189 colDef.set(7,0,1,2,3,-1,-1,4,5);
193 if (s !=
"format:")
return -1;
195 for (
int i=0; i<colDef.nCols; i++) {
198 if (s==
"id") colDef.id = i;
199 if (s==
"daq") colDef.daqId = i;
200 if (s==
"phi") colDef.phi = i;
201 if (s==
"eta") colDef.eta = i;
202 if (s==
"etamin") colDef.etamin = i;
203 if (s==
"etamax") colDef.etamax = i;
204 if (s==
"ped") colDef.ped = i;
205 if (s==
"gain") colDef.gain = i;
211 int nRead = readCalib(&txtmap, colDef);
224 int l3EmcCalibration::readCalib(ifstream *from, colDef_t colDef)
229 for (
int t=0; t<nTowers; t++) {
230 float phi=0.0, eta=0.0, etamin=-999.0, etamax=-999.0;
231 float ped=0.0, gain=1.0;
238 for (
int i=0; i<colDef.nCols; i++) {
239 if (i == colDef.id) *from >> id;
else
240 if (i == colDef.daqId) *from >> daqId;
else
241 if (i == colDef.eta) *from >> eta;
else
242 if (i == colDef.etamin) *from >> etamin;
else
243 if (i == colDef.etamax) *from >> etamax;
else
244 if (i == colDef.phi) *from >> phi;
else
245 if (i == colDef.ped) *from >> ped;
else
246 if (i == colDef.gain) *from >> gain;
else
251 if(from->eof())
break;
254 if (nTowers == 4800) {
256 etamin = floor(eta*20.)/20.;
259 etamax = ceil(eta*20.)/20.;
262 tower[
id-1].set(phi, eta, etamin, etamax, ped, gain,
id, daqId);
263 daq2id[daqId] =
id-1;
275 int l3EmcCalibration::saveTextMap(
const char* filename)
277 ofstream txtmap(filename);
279 txtmap <<
"EmcCalib" << endl
280 <<
"columns: 7" << endl;
282 for (
int i=0; i<nTowers; i++) {
283 txtmap << tower[i].getID() <<
" "
284 << tower[i].getDaqID() <<
" "
285 << tower[i].getPhi() <<
" "
286 << tower[i].getEta() <<
" "
287 << tower[i].getPed() <<
" "
288 << tower[i].getGain() <<
" "