File indexing completed on 2021-02-14 12:50:09
0001 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0002 #include "CommonTools/TrackerMap/interface/TmModule.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/ParameterSet/interface/FileInPath.h"
0005 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0006 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
0007 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0008 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0009 #include "CommonTools/TrackerMap/interface/TmApvPair.h"
0010 #include "CommonTools/TrackerMap/interface/TmCcu.h"
0011 #include "CommonTools/TrackerMap/interface/TmPsu.h"
0012 #include <fstream>
0013 #include <vector>
0014 #include <iostream>
0015 #include <sstream>
0016 #include "TCanvas.h"
0017 #include "TPolyLine.h"
0018 #include "TStyle.h"
0019 #include "TColor.h"
0020 #include "TROOT.h"
0021 #include "TGaxis.h"
0022 #include "TLatex.h"
0023 #include "TArrow.h"
0024 #include "TLegend.h"
0025 #include "TH1F.h"
0026
0027
0028
0029
0030
0031
0032
0033 TrackerMap::TrackerMap(const edm::ParameterSet &tkmapPset,
0034 const SiStripFedCabling *tkFed,
0035 const TrackerTopology *const topology) {
0036 psetAvailable = true;
0037 xsize = 340;
0038 ysize = 200;
0039
0040 title = " ";
0041 jsPath = "";
0042 jsfilename = "CommonTools/TrackerMap/data/trackermap.txt";
0043 infilename = "CommonTools/TrackerMap/data/tracker.dat";
0044 saveAsSingleLayer = false;
0045 tkMapLog = false;
0046
0047 jsPath = tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath", "CommonTools/TrackerMap/data/");
0048 jsfilename = jsPath + "trackermap.txt";
0049 std::cout << jsfilename << std::endl;
0050 infilename =
0051 tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "CommonTools/TrackerMap/data/") + "tracker.dat";
0052 std::cout << infilename << std::endl;
0053 saveWebInterface = tkmapPset.getUntrackedParameter<bool>("saveWebInterface", false);
0054 saveGeoTrackerMap = tkmapPset.getUntrackedParameter<bool>("saveGeoTrackerMap", true);
0055 ncrates = 0;
0056 firstcrate = 0;
0057 enableFedProcessing = tkmapPset.getUntrackedParameter<bool>("loadFedCabling", false);
0058 if (tkFed == nullptr && enableFedProcessing) {
0059 enableFedProcessing = false;
0060 std::cout << "ERROR:fed trackermap requested but no valid fedCabling is available!!!" << std::endl;
0061 }
0062 nfeccrates = 0;
0063 enableFecProcessing = tkmapPset.getUntrackedParameter<bool>("loadFecCabling", false);
0064 if (tkFed == nullptr && enableFecProcessing) {
0065 enableFecProcessing = false;
0066 std::cout << "ERROR:fec trackermap requested but no valid fedCabling is available!!!" << std::endl;
0067 }
0068
0069 npsuracks = 0;
0070 enableLVProcessing = tkmapPset.getUntrackedParameter<bool>("loadLVCabling", false);
0071
0072 enableHVProcessing = tkmapPset.getUntrackedParameter<bool>("loadHVCabling", false);
0073
0074 tkMapLog = tkmapPset.getUntrackedParameter<bool>("logScale", false);
0075
0076
0077 init();
0078
0079 if (enableFedProcessing) {
0080 auto feds = tkFed->fedIds();
0081 std::cout << "SiStripFedCabling has " << feds.size() << " active FEDS" << std::endl;
0082
0083
0084 for (std::vector<unsigned short>::const_iterator ifed = feds.begin(); ifed < feds.end(); ifed++) {
0085 auto theconn = tkFed->fedConnections(*ifed);
0086 int num_conn = 0;
0087 for (auto iconn = theconn.begin(); iconn < theconn.end(); iconn++) {
0088 if (iconn->fedId() == sistrip::invalid_ || iconn->detId() == sistrip::invalid_ ||
0089 iconn->detId() == sistrip::invalid32_ || iconn->apvPairNumber() == sistrip::invalid_ ||
0090 iconn->nApvPairs() == sistrip::invalid_) {
0091 continue;
0092 }
0093
0094 TmModule *imod = imoduleMap[iconn->detId()];
0095 int key = iconn->fedId() * 1000 + iconn->fedCh();
0096 TmApvPair *apvpair = apvMap[key];
0097 if (apvpair != nullptr)
0098 std::cout << "Fed " << iconn->fedId() << " channel " << iconn->fedCh() << " seem to be already loaded!"
0099 << std::endl;
0100 else {
0101 num_conn++;
0102 if (num_conn == 1) {
0103
0104 if (fedMap[iconn->fedId()] == 0) {
0105 fedMap[iconn->fedId()] = iconn->fedCrate();
0106 }
0107 if (slotMap[iconn->fedId()] == 0) {
0108 slotMap[iconn->fedId()] = iconn->fedSlot();
0109 }
0110 if (ncrates == 0 || ncrates < iconn->fedCrate())
0111 ncrates = iconn->fedCrate();
0112 if (firstcrate == 0 || firstcrate > iconn->fedCrate())
0113 firstcrate = iconn->fedCrate();
0114 }
0115
0116
0117 apvpair = new TmApvPair(key, iconn->fedCrate());
0118 apvpair->mod = imod;
0119 apvpair->mpos = iconn->apvPairNumber();
0120 apvMap[key] = apvpair;
0121 apvModuleMap.insert(std::make_pair(iconn->detId(), apvpair));
0122 std::stringstream s;
0123 iconn->print(s);
0124 apvpair->text = s.str();
0125 }
0126 }
0127 }
0128
0129 std::cout << "from " << firstcrate << " to " << ncrates << " crates used " << std::endl;
0130
0131 std::map<int, TmModule *>::iterator i_mod;
0132 for (i_mod = imoduleMap.begin(); i_mod != imoduleMap.end(); i_mod++) {
0133 TmModule *mod = i_mod->second;
0134 if (mod != nullptr) {
0135 std::ostringstream outs, outs1;
0136 outs << " connected to ";
0137 outs1 << "(";
0138
0139 int idmod = mod->idex;
0140 int nchan = 0;
0141 std::multimap<const int, TmApvPair *>::iterator pos;
0142 for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
0143 TmApvPair *apvpair = pos->second;
0144 if (apvpair != nullptr) {
0145 outs << apvpair->mpos << " " << apvpair->getFedId() << "/" << apvpair->getFedCh() << " ";
0146 outs1 << apvpair->idex + apvpair->crate * 1000000 << ",";
0147 nchan++;
0148 }
0149 }
0150 outs << "(" << nchan << ")";
0151 mod->name = mod->name + outs.str();
0152 std::string s = outs1.str();
0153 s.erase(s.end() - 1, s.end());
0154 mod->capvids = s + ")";
0155 }
0156 }
0157 }
0158
0159 if (enableFecProcessing) {
0160 int nfec = 0;
0161 int nccu;
0162 int nmod;
0163 int crate, slot, ring, addr, pos;
0164 SiStripFecCabling *fecCabling_;
0165 fecCabling_ = new SiStripFecCabling(*tkFed);
0166 std::string Ccufilename = tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "") + "cculist.txt";
0167 std::ifstream Ccufile(edm::FileInPath(Ccufilename).fullPath().c_str(), std::ios::in);
0168 std::string dummys;
0169 while (!Ccufile.eof()) {
0170 Ccufile >> crate >> slot >> ring >> addr >> pos;
0171 getline(Ccufile, dummys);
0172 int key = crate * 10000000 + slot * 100000 + ring * 1000 + addr;
0173 TmCcu *ccu = ccuMap[key];
0174 if (ccu == nullptr) {
0175 ccu = new TmCcu(crate, slot, ring, addr);
0176 ccu->mpos = pos, ccuMap[key] = ccu;
0177 }
0178 }
0179
0180 for (std::vector<SiStripFecCrate>::const_iterator icrate = fecCabling_->crates().begin();
0181 icrate != fecCabling_->crates().end();
0182 icrate++) {
0183 for (std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end();
0184 ifec++) {
0185 for (std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end();
0186 iring++) {
0187 nccu = 0;
0188 nfec++;
0189 for (std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end();
0190 iccu++) {
0191 nccu++;
0192 nmod = 0;
0193 int key =
0194 icrate->fecCrate() * 10000000 + ifec->fecSlot() * 100000 + iring->fecRing() * 1000 + iccu->ccuAddr();
0195 int layer = 0;
0196 TmCcu *ccu = ccuMap[key];
0197 for (std::vector<SiStripModule>::const_iterator imod = iccu->modules().begin();
0198 imod != iccu->modules().end();
0199 imod++) {
0200 nmod++;
0201 TmModule *imod1 = imoduleMap[imod->detId()];
0202 layer = imod1->layer;
0203 fecModuleMap.insert(std::make_pair(ccu, imod1));
0204 if (imod1 != nullptr)
0205 imod1->CcuId = key;
0206 }
0207 if (ccu == nullptr)
0208 std::cout << key << " This ccu seems to have not been stored! " << std::endl;
0209 else {
0210 ccu->nmod = nmod;
0211 ccu->layer = layer;
0212 }
0213
0214 }
0215 }
0216 }
0217 }
0218
0219 std::map<int, TmCcu *>::iterator i_ccu;
0220 std::multimap<TmCcu *, TmModule *>::iterator it;
0221 std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
0222 nccu = 0;
0223 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
0224 TmCcu *ccu = i_ccu->second;
0225 nccu++;
0226 if (ccu != nullptr) {
0227 std::ostringstream outs;
0228 std::ostringstream outs1;
0229 outs << "CCU " << ccu->idex << " connected to fec,ring " << ccu->getCcuSlot() << "," << ccu->getCcuRing()
0230 << " in crate " << ccu->getCcuCrate() << " at position " << ccu->mpos << " with " << ccu->nmod
0231 << " modules: ";
0232 outs1 << "(";
0233 ret = fecModuleMap.equal_range(ccu);
0234 for (it = ret.first; it != ret.second; ++it) {
0235 outs << (*it).second->idex << " ";
0236 outs1 << (*it).second->getKey() << ",";
0237 }
0238 outs1 << ")";
0239 ccu->text = outs.str();
0240 ccu->cmodid = outs1.str();
0241
0242 }
0243 }
0244 nfeccrates = 4;
0245 std::cout << nccu << " ccu stored in " << nfeccrates << " crates" << std::endl;
0246
0247 delete fecCabling_;
0248 }
0249
0250
0251 if (enableLVProcessing || enableHVProcessing) {
0252 SiStripDetCabling *detCabling = nullptr;
0253 if (enableFedProcessing)
0254 detCabling = new SiStripDetCabling(*tkFed, topology);
0255
0256 int npsu = 0;
0257 int nmod, nmodHV2, nmodHV3;
0258 int modId1, dcuId;
0259 int dcs, branch, crate, board;
0260 int rack = 0;
0261 std::string channelstr1;
0262 short int channel;
0263 std::string psinfo;
0264 std::string psIdinfo;
0265 int rack_order[54] = {0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0,
0266 11, 12, 0, 13, 14, 0, 15, 0, 0, 0, 0, 0, 0, 16, 0, 17, 18, 0,
0267 19, 20, 0, 21, 0, 22, 0, 23, 0, 24, 25, 0, 26, 27, 0, 28, 0, 29};
0268
0269
0270
0271 std::string LVfilename =
0272 tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "CommonTools/TrackerMap/data/") + "psdcumap.dat";
0273
0274
0275 std::ifstream LVfile(edm::FileInPath(LVfilename).fullPath().c_str(), std::ios::in);
0276
0277 std::cout << LVfilename << std::endl;
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295 while (!LVfile.eof()) {
0296 LVfile >> modId1 >> dcuId >> psIdinfo >> psinfo;
0297
0298 if (detCabling && detCabling->getConnections(modId1).empty())
0299 continue;
0300
0301
0302 std::string dcsinfo = psinfo.substr(39, 1);
0303 std::string branchinfo = psinfo.substr(57, 2);
0304 std::string crateinfo = psinfo.substr(69, 1);
0305 std::string boardinfo = psinfo.substr(80, 2);
0306 std::string channelinfo = psinfo.substr(90, 3);
0307
0308 dcs = atoi(dcsinfo.c_str());
0309 branch = atoi(branchinfo.c_str());
0310 crate = atoi(crateinfo.c_str()) + 1;
0311 board = atoi(boardinfo.c_str()) + 1;
0312 rack = (branch + 1) + (dcs - 1) * 6;
0313 rack = rack_order[rack];
0314 channel = atoi(channelinfo.c_str());
0315
0316 int key = rack * 1000 + crate * 100 + board;
0317
0318 TmPsu *psu = psuMap[key];
0319 TmModule *imod = imoduleMap[modId1];
0320 if (psu == nullptr) {
0321 psu = new TmPsu(dcs, branch, rack, crate, board);
0322 psuMap[key] = psu;
0323 psu->psId = psIdinfo;
0324 }
0325
0326 psuModuleMap.insert(std::make_pair(psu, imod));
0327 if (imod != nullptr) {
0328 imod->PsuId = psIdinfo;
0329 imod->psuIdex = psu->idex;
0330 imod->HVchannel = channel;
0331 }
0332 }
0333
0334
0335 std::map<int, TmPsu *>::iterator ipsu;
0336 std::multimap<TmPsu *, TmModule *>::iterator it;
0337 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
0338 npsu = 0;
0339
0340 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
0341 TmPsu *psu = ipsu->second;
0342 npsu++;
0343
0344 if (psu != nullptr) {
0345 std::ostringstream outs;
0346 std::ostringstream outs1;
0347
0348 std::ostringstream outs3;
0349 std::ostringstream outs4;
0350
0351 std::ostringstream outs5;
0352 std::ostringstream outs6;
0353
0354 outs << "PSU " << psu->psId << " connected to Mainframe " << psu->getPsuDcs() << " BranchController "
0355 << psu->getPsuBranch() << " (Rack " << psu->getPsuRack() << "), crate " << psu->getPsuCrate()
0356 << " in position " << psu->getPsuBoard() << " with modules: ";
0357 outs1 << "(";
0358
0359 if (enableHVProcessing) {
0360 outs3 << "PSU " << psu->psId << " connected to Mainframe " << psu->getPsuDcs() << " BranchController "
0361 << psu->getPsuBranch() << " (Rack " << psu->getPsuRack() << "),crate " << psu->getPsuCrate()
0362 << " in position " << psu->getPsuBoard() << " and HV channel 002 with modules: ";
0363 outs4 << "(";
0364
0365 outs5 << "PSU " << psu->psId << " connected to Mainframe " << psu->getPsuDcs() << " BranchController "
0366 << psu->getPsuBranch() << " (Rack " << psu->getPsuRack() << "), crate " << psu->getPsuCrate()
0367 << " in position " << psu->getPsuBoard() << " and HV channel 002 with modules: ";
0368 outs6 << "(";
0369 }
0370
0371 ret = psuModuleMap.equal_range(psu);
0372 nmod = 0;
0373 nmodHV2 = 0;
0374 nmodHV3 = 0;
0375 for (it = ret.first; it != ret.second; ++it) {
0376 nmod++;
0377 outs << (*it).second->idex << ", ";
0378 outs1 << (*it).second->getKey() << ",";
0379
0380 if (enableHVProcessing) {
0381 if ((*it).second->HVchannel == 2) {
0382 nmodHV2++;
0383 outs3 << (*it).second->idex << ", ";
0384 outs4 << (*it).second->getKey() << ",";
0385 } else if ((*it).second->HVchannel == 3) {
0386 nmodHV3++;
0387 outs5 << (*it).second->idex << ", ";
0388 outs6 << (*it).second->getKey() << ",";
0389 }
0390 }
0391 }
0392
0393 outs1 << ")";
0394 psu->nmod = nmod;
0395 outs << "(" << psu->nmod << ")";
0396 psu->text = outs.str();
0397 psu->cmodid_LV = outs1.str();
0398 if (enableHVProcessing) {
0399 outs4 << ")";
0400 outs6 << ")";
0401 psu->nmodHV2 = nmodHV2;
0402 psu->nmodHV3 = nmodHV3;
0403 outs3 << "(" << psu->nmodHV2 << ")";
0404 outs5 << "(" << psu->nmodHV3 << ")";
0405 psu->textHV2 = outs3.str();
0406 psu->textHV3 = outs5.str();
0407 psu->cmodid_HV2 = outs4.str();
0408 psu->cmodid_HV3 = outs6.str();
0409 }
0410 }
0411 }
0412
0413 npsuracks = 29;
0414 std::cout << npsu << " psu stored in " << npsuracks << " racks" << std::endl;
0415 }
0416 }
0417
0418 TrackerMap::TrackerMap(const edm::ParameterSet &tkmapPset) {
0419 psetAvailable = true;
0420 xsize = 340;
0421 ysize = 200;
0422 title = " ";
0423 jsfilename = "CommonTools/TrackerMap/data/trackermap.txt";
0424 infilename = "CommonTools/TrackerMap/data/tracker.dat";
0425 enableFedProcessing = true;
0426 ncrates = 0;
0427 firstcrate = 0;
0428 saveAsSingleLayer = false;
0429 tkMapLog = tkmapPset.getUntrackedParameter<bool>("logScale", false);
0430 saveWebInterface = tkmapPset.getUntrackedParameter<bool>("saveWebInterface", false);
0431 saveGeoTrackerMap = tkmapPset.getUntrackedParameter<bool>("saveGeoTrackerMap", true);
0432
0433 jsfilename = tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath", "CommonTools/TrackerMap/data/") +
0434 "trackermap.txt";
0435 std::cout << jsfilename << std::endl;
0436 infilename =
0437 tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "CommonTools/TrackerMap/data/") + "tracker.dat";
0438 std::cout << infilename << std::endl;
0439
0440 init();
0441 }
0442
0443 TrackerMap::TrackerMap(std::string s, int xsize1, int ysize1) {
0444 psetAvailable = false;
0445 xsize = xsize1;
0446 ysize = ysize1;
0447 title = s;
0448 jsfilename = "CommonTools/TrackerMap/data/trackermap.txt";
0449 infilename = "CommonTools/TrackerMap/data/tracker.dat";
0450 saveWebInterface = false;
0451 saveGeoTrackerMap = true;
0452 tkMapLog = false;
0453 jsPath = "CommonTools/TrackerMap/data/";
0454 enableFedProcessing = false;
0455 enableFecProcessing = false;
0456 enableLVProcessing = false;
0457 enableHVProcessing = false;
0458 saveAsSingleLayer = false;
0459 init();
0460 }
0461
0462 void TrackerMap::reset() {
0463 std::map<int, TmModule *>::iterator i_mod;
0464 for (i_mod = imoduleMap.begin(); i_mod != imoduleMap.end(); i_mod++) {
0465 TmModule *mod = i_mod->second;
0466 mod->count = 0;
0467 mod->value = 0;
0468 mod->red = -1;
0469 }
0470 }
0471
0472 void TrackerMap::init() {
0473 int ntotmod = 0;
0474 ix = 0;
0475 iy = 0;
0476 firstcall = true;
0477 minvalue = 0.;
0478 maxvalue = minvalue;
0479 posrel = true;
0480 palette = 1;
0481 printflag = true;
0482 addPixelFlag = false;
0483 onlyPixelFlag = false;
0484 temporary_file = false;
0485 gminvalue = 0.;
0486 gmaxvalue = 0.;
0487
0488 ndet = 3;
0489 npart = 3;
0490
0491
0492 for (int subdet = 1; subdet < ndet + 1; subdet++) {
0493 for (int detpart = 1; detpart < npart + 1; detpart++) {
0494 int nlayers = getlayerCount(subdet, detpart);
0495 for (int layer = 1; layer < nlayers + 1; layer++) {
0496 int nrings = getringCount(subdet, detpart, layer);
0497
0498 int layer_g = nlayer(subdet, detpart, layer);
0499 ntotRing[layer_g - 1] = nrings;
0500 firstRing[layer_g - 1] = 1;
0501 if (subdet == 3 && detpart != 2)
0502 firstRing[layer_g - 1] = 8 - nrings;
0503 for (int ring = firstRing[layer_g - 1]; ring < ntotRing[layer_g - 1] + firstRing[layer_g - 1];
0504 ring++) {
0505 int nmodules = getmoduleCount(subdet, detpart, layer, ring);
0506 int key = 0;
0507 TmModule *smodule;
0508 for (int module = 1; module < nmodules + 1; module++) {
0509 smodule = new TmModule(module, ring, layer_g);
0510 key = layer_g * 100000 + ring * 1000 + module;
0511 smoduleMap[key] = smodule;
0512 ntotmod++;
0513 }
0514 if (isRingStereo(key))
0515 for (int module = 1; module < nmodules + 1; module++) {
0516 smodule = new TmModule(module + 100, ring, layer_g);
0517 int key = layer_g * 100000 + ring * 1000 + module + 100;
0518 smoduleMap[key] = smodule;
0519 ntotmod++;
0520 }
0521 }
0522 }
0523 }
0524 }
0525 build();
0526 }
0527
0528 TrackerMap::~TrackerMap() {
0529 for (int layer = 1; layer < 44; layer++) {
0530 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
0531 for (int module = 1; module < 200; module++) {
0532 int key = layer * 100000 + ring * 1000 + module;
0533 TmModule *mod = smoduleMap[key];
0534 if (mod != nullptr)
0535 delete mod;
0536 }
0537 }
0538 }
0539
0540
0541
0542
0543
0544
0545 std::map<int, TmApvPair *>::iterator i_apv;
0546 for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
0547 TmApvPair *apvPair = i_apv->second;
0548 delete apvPair;
0549 }
0550
0551 std::map<int, TmCcu *>::iterator i_ccu;
0552 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
0553 TmCcu *ccu = i_ccu->second;
0554 delete ccu;
0555 }
0556
0557 std::map<int, TmPsu *>::iterator ipsu;
0558 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
0559 TmPsu *psu = ipsu->second;
0560 delete psu;
0561 }
0562
0563 gROOT->Reset();
0564
0565
0566
0567 }
0568
0569 void TrackerMap::drawModule(TmModule *mod, int key, int mlay, bool print_total, std::ofstream *svgfile) {
0570
0571 nlay = mlay;
0572 double phi, r, dx, dy, dy1;
0573 double xp[4], yp[4], xp1, yp1;
0574 double vhbot, vhtop, vhapo;
0575 double rmedio[] = {0.041, 0.0701, 0.0988, 0.255, 0.340, 0.430, 0.520, 0.610, 0.696, 0.782, 0.868, 0.965, 1.080};
0576 double xt1, yt1, xs1 = 0., ys1 = 0., xt2, yt2, xs2, ys2, pv1, pv2;
0577 int green = 0;
0578 int red = 0;
0579 int blue = 0;
0580 double xd[4], yd[4];
0581 int np = 4;
0582
0583 int numod = 0;
0584 phi = phival(mod->posx, mod->posy);
0585 r = sqrt(mod->posx * mod->posx + mod->posy * mod->posy);
0586 vhtop = mod->width;
0587 vhapo = mod->length;
0588 if (mlay < 31) {
0589 vhbot = mod->widthAtHalfLength / 2. - (mod->width / 2. - mod->widthAtHalfLength / 2.);
0590 vhtop = mod->width / 2.;
0591 vhapo = mod->length / 2.;
0592 if (mlay > 12 && mlay < 19) {
0593 if (posrel)
0594 r = r + r;
0595 xp[0] = r - vhtop;
0596 yp[0] = -vhapo;
0597 xp[1] = r + vhtop;
0598 yp[1] = -vhapo;
0599 xp[2] = r + vhtop;
0600 yp[2] = vhapo;
0601 xp[3] = r - vhtop;
0602 yp[3] = vhapo;
0603 } else {
0604 if (posrel)
0605 r = r + r / 3.;
0606 xp[0] = r - vhapo;
0607 yp[0] = -vhbot;
0608 xp[1] = r + vhapo;
0609 yp[1] = -vhtop;
0610 xp[2] = r + vhapo;
0611 yp[2] = vhtop;
0612 xp[3] = r - vhapo;
0613 yp[3] = vhbot;
0614 }
0615 for (int j = 0; j < 4; j++) {
0616 xp1 = xp[j] * cos(phi) - yp[j] * sin(phi);
0617 yp1 = xp[j] * sin(phi) + yp[j] * cos(phi);
0618 xp[j] = xp1;
0619 yp[j] = yp1;
0620 }
0621 } else {
0622 numod = mod->idModule;
0623 if (numod > 100)
0624 numod = numod - 100;
0625 int vane = mod->ring;
0626 if (posrel) {
0627 dx = vhapo;
0628 phi = M_PI;
0629 xt1 = rmedio[mlay - 31];
0630 yt1 = -vhtop / 2.;
0631 xs1 = xt1 * cos(phi) - yt1 * sin(phi);
0632 ys1 = xt1 * sin(phi) + yt1 * cos(phi);
0633 xt2 = rmedio[mlay - 31];
0634 yt2 = vhtop / 2.;
0635 xs2 = xt2 * cos(phi) - yt2 * sin(phi);
0636 ys2 = xt2 * sin(phi) + yt2 * cos(phi);
0637 dy = phival(xs2, ys2) - phival(xs1, ys1);
0638 dy1 = dy;
0639 if (mlay == 31)
0640 dy1 = 0.39;
0641 if (mlay == 32)
0642 dy1 = 0.23;
0643 if (mlay == 33)
0644 dy1 = 0.16;
0645 xp[0] = vane * (dx + dx / 8.);
0646 yp[0] = numod * (dy1);
0647 xp[1] = vane * (dx + dx / 8.) + dx;
0648 yp[1] = numod * (dy1);
0649 xp[2] = vane * (dx + dx / 8.) + dx;
0650 yp[2] = numod * (dy1) + dy;
0651 xp[3] = vane * (dx + dx / 8.);
0652 yp[3] = numod * (dy1) + dy;
0653 } else {
0654 xt1 = r;
0655 yt1 = -vhtop / 2.;
0656 xs1 = xt1 * cos(phi) - yt1 * sin(phi);
0657 ys1 = xt1 * sin(phi) + yt1 * cos(phi);
0658 xt2 = r;
0659 yt2 = vhtop / 2.;
0660 xs2 = xt2 * cos(phi) - yt2 * sin(phi);
0661 ys2 = xt2 * sin(phi) + yt2 * cos(phi);
0662 pv1 = phival(xs1, ys1);
0663 pv2 = phival(xs2, ys2);
0664 if (fabs(pv1 - pv2) > M_PI && numod == 1)
0665 pv1 = pv1 - 2. * M_PI;
0666 if (fabs(pv1 - pv2) > M_PI && numod != 1)
0667 pv2 = pv2 + 2. * M_PI;
0668 xp[0] = mod->posz - vhapo / 2.;
0669 yp[0] = 4.2 * pv1;
0670 xp[1] = mod->posz + vhapo / 2.;
0671 yp[1] = 4.2 * pv1;
0672 xp[2] = mod->posz + vhapo / 2.;
0673 yp[2] = 4.2 * pv2;
0674 xp[3] = mod->posz - vhapo / 2.;
0675 yp[3] = 4.2 * pv2;
0676 }
0677 }
0678 if (isRingStereo(key)) {
0679 np = 3;
0680 if (mod->idModule > 100) {
0681 for (int j = 0; j < 3; j++) {
0682 xd[j] = xdpixel(xp[j]);
0683 yd[j] = ydpixel(yp[j]);
0684 }
0685 } else {
0686 xd[0] = xdpixel(xp[2]);
0687 yd[0] = ydpixel(yp[2]);
0688 xd[1] = xdpixel(xp[3]);
0689 yd[1] = ydpixel(yp[3]);
0690 xd[2] = xdpixel(xp[0]);
0691 yd[2] = ydpixel(yp[0]);
0692 }
0693 } else {
0694 for (int j = 0; j < 4; j++) {
0695 xd[j] = xdpixel(xp[j]);
0696 yd[j] = ydpixel(yp[j]);
0697 }
0698 }
0699 char buffer[20];
0700 sprintf(buffer, "%X", mod->idex);
0701
0702 if (mod->red < 0) {
0703 int color = getcolor(mod->value, palette);
0704 red = (color >> 16) & 0xFF;
0705 green = (color >> 8) & 0xFF;
0706 blue = (color)&0xFF;
0707
0708 if (!print_total)
0709 mod->value = mod->value * mod->count;
0710
0711 if (mod->count > 0)
0712 if (temporary_file)
0713 *svgfile << red << " " << green << " " << blue << " ";
0714 else
0715 *svgfile
0716 << "<svg:polygon detid=\"" << mod->idex << "\" count=\"" << mod->count << "\" value=\"" << mod->value
0717 << "\" id=\"" << key << "\" capvids=\"" << mod->capvids << "\" lv=\"" << mod->psuIdex << "\" hv=\""
0718 << mod->psuIdex * 10 + mod->HVchannel << "\" fec=\"" << mod->CcuId
0719 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
0720 << mod->text << "\" POS=\"" << mod->name << " \" fill=\"rgb(" << red << "," << green << "," << blue
0721 << ")\" points=\"";
0722 else if (temporary_file)
0723 *svgfile << 255 << " " << 255 << " " << 255 << " ";
0724 else
0725 *svgfile
0726 << "<svg:polygon detid=\"" << mod->idex << "\" count=\"" << mod->count << "\" value=\"" << mod->value
0727 << "\" id=\"" << key << "\" capvids=\"" << mod->capvids << "\" lv=\"" << mod->psuIdex << "\" hv=\""
0728 << mod->psuIdex * 10 + mod->HVchannel << "\" fec=\"" << mod->CcuId
0729 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
0730 << mod->text << "\" POS=\"" << mod->name << " \" fill=\"white\" points=\"";
0731 if (temporary_file)
0732 *svgfile << np << " ";
0733 for (int k = 0; k < np; k++) {
0734 if (temporary_file)
0735 *svgfile << xd[k] << " " << yd[k] << " ";
0736 else
0737 *svgfile << xd[k] << "," << yd[k] << " ";
0738 }
0739 if (temporary_file)
0740 *svgfile << std::endl;
0741 else
0742 *svgfile << "\" />" << std::endl;
0743 } else {
0744 if (mod->red > 255)
0745 mod->red = 255;
0746 if (mod->green > 255)
0747 mod->green = 255;
0748 if (mod->blue > 255)
0749 mod->blue = 255;
0750 if (temporary_file)
0751 *svgfile << mod->red << " " << mod->green << " " << mod->blue << " ";
0752 else
0753 *svgfile
0754 << "<svg:polygon detid=\"" << mod->idex << "\" count=\"" << mod->count << "\" value=\"" << mod->value
0755 << "\" id=\"" << key << "\" capvids=\"" << mod->capvids << "\" lv=\"" << mod->psuIdex << "\" hv=\""
0756 << mod->psuIdex * 10 + mod->HVchannel << "\" fec=\"" << mod->CcuId
0757 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
0758 << mod->text << "\" POS=\"" << mod->name << " \" fill=\"rgb(" << mod->red << "," << mod->green << ","
0759 << mod->blue << ")\" points=\"";
0760 if (temporary_file)
0761 *svgfile << np << " ";
0762 for (int k = 0; k < np; k++) {
0763 if (temporary_file)
0764 *svgfile << xd[k] << " " << yd[k] << " ";
0765 else
0766 *svgfile << xd[k] << "," << yd[k] << " ";
0767 }
0768 if (temporary_file)
0769 *svgfile << std::endl;
0770 else
0771 *svgfile << "\" />" << std::endl;
0772 }
0773 }
0774 void TrackerMap::setRange(float min, float max) {
0775 gminvalue = min;
0776 gmaxvalue = max;
0777 if (tkMapLog) {
0778 gminvalue = pow(10., min);
0779 gmaxvalue = pow(10., max);
0780 }
0781 }
0782
0783 std::pair<float, float> TrackerMap::getAutomaticRange() {
0784 float minval, maxval;
0785 minval = 9999999.;
0786 maxval = -9999999.;
0787 for (int layer = 1; layer < 44; layer++) {
0788 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
0789 for (int module = 1; module < 200; module++) {
0790 int key = layer * 100000 + ring * 1000 + module;
0791 TmModule *mod = smoduleMap[key];
0792 if (mod != nullptr && !mod->notInUse() && mod->count > 0) {
0793 if (minval > mod->value)
0794 minval = mod->value;
0795 if (maxval < mod->value)
0796 maxval = mod->value;
0797 }
0798 }
0799 }
0800 }
0801 if (tkMapLog) {
0802 minval = log(minval) / log(10);
0803 maxval = log(maxval) / log(10);
0804 }
0805 return std::make_pair(minval, maxval);
0806 }
0807
0808
0809
0810
0811 void TrackerMap::save(bool print_total, float minval, float maxval, std::string s, int width, int height) {
0812 printflag = true;
0813 bool rangefound = true;
0814 if (saveGeoTrackerMap) {
0815 std::string filetype = s, outputfilename = s;
0816 std::vector<TPolyLine *> vp;
0817 TGaxis *axis = nullptr;
0818 size_t found = filetype.find_last_of('.');
0819 filetype = filetype.substr(found + 1);
0820 found = outputfilename.find_last_of('.');
0821 outputfilename = outputfilename.substr(0, found);
0822
0823 temporary_file = true;
0824 if (filetype == "svg")
0825 temporary_file = false;
0826 std::ostringstream outs;
0827 minvalue = minval;
0828 maxvalue = maxval;
0829 outs << outputfilename << ".coor";
0830 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
0831 if (!print_total) {
0832 for (int layer = 1; layer < 44; layer++) {
0833 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
0834 for (int module = 1; module < 200; module++) {
0835 int key = layer * 100000 + ring * 1000 + module;
0836 TmModule *mod = smoduleMap[key];
0837 if (mod != nullptr && !mod->notInUse()) {
0838 mod->value = mod->value / mod->count;
0839 }
0840 }
0841 }
0842 }
0843 }
0844
0845 if (minvalue >= maxvalue) {
0846 minvalue = 9999999.;
0847 maxvalue = -9999999.;
0848 rangefound = false;
0849 for (int layer = 1; layer < 44; layer++) {
0850 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
0851 for (int module = 1; module < 200; module++) {
0852 int key = layer * 100000 + ring * 1000 + module;
0853 TmModule *mod = smoduleMap[key];
0854 if (mod != nullptr && !mod->notInUse() && mod->count > 0) {
0855 rangefound = true;
0856 if (minvalue > mod->value)
0857 minvalue = mod->value;
0858 if (maxvalue < mod->value)
0859 maxvalue = mod->value;
0860 }
0861 }
0862 }
0863 }
0864 }
0865 if ((title.find("QTestAlarm") != std::string::npos) || (maxvalue == minvalue) || !rangefound)
0866 printflag = false;
0867 if (!temporary_file) {
0868 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
0869 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
0870 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
0871 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
0872 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3100 1600"
0873 << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
0874 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3100\" height=\"1600\" /> "
0875 << std::endl;
0876 *savefile << "<svg:g id=\"tracker\" transform=\"translate(10,1500) rotate(270)\" "
0877 "style=\"fill:none;stroke:black;stroke-width:0;\"> "
0878 << std::endl;
0879 }
0880 for (int layer = 1; layer < 44; layer++) {
0881
0882 defwindow(layer);
0883 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
0884 for (int module = 1; module < 200; module++) {
0885 int key = layer * 100000 + ring * 1000 + module;
0886 TmModule *mod = smoduleMap[key];
0887 if (mod != nullptr && !mod->notInUse()) {
0888 drawModule(mod, key, layer, print_total, savefile);
0889 }
0890 }
0891 }
0892 }
0893
0894 if (!temporary_file) {
0895 *savefile << "</svg:g>" << std::endl;
0896 *savefile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">" << title << "</svg:text>"
0897 << std::endl;
0898 }
0899
0900 if (printflag) {
0901 if (onlyPixelFlag) {
0902 drawPalette(savefile, -30);
0903 } else {
0904 drawPalette(savefile);
0905 }
0906 }
0907 if (!temporary_file) {
0908 *savefile << "</svg:svg>" << std::endl;
0909 *savefile << "</svg>" << std::endl;
0910 }
0911 savefile->close();
0912 delete savefile;
0913
0914 const char *command1;
0915 std::string tempfilename = outputfilename + ".coor";
0916 if (filetype == "svg") {
0917 std::string command = "mv " + tempfilename + " " + outputfilename + ".svg";
0918 command1 = command.c_str();
0919 std::cout << "Executing " << command1 << std::endl;
0920 system(command1);
0921 }
0922
0923 if (temporary_file) {
0924 int red, green, blue, npoints, colindex, ncolor;
0925 double x[4], y[4];
0926 std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
0927 TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
0928 gPad->SetFillColor(38);
0929
0930 if (addPixelFlag) {
0931 gPad->Range(0, 0, 3800, 1600);
0932 } else if (onlyPixelFlag) {
0933 gPad->Range(-100, 0, 800, 1600);
0934 } else {
0935 gPad->Range(800, 0, 3800, 1600);
0936 }
0937
0938
0939 ncolor = 0;
0940 typedef std::map<int, int> ColorList;
0941 ColorList colorList;
0942 ColorList::iterator pos;
0943 TColor *col, *c;
0944 std::cout << "tempfilename " << tempfilename << std::endl;
0945 while (!tempfile.eof()) {
0946 tempfile >> red >> green >> blue >> npoints;
0947 colindex = red + green * 1000 + blue * 1000000;
0948 pos = colorList.find(colindex);
0949 if (pos == colorList.end()) {
0950 colorList[colindex] = ncolor + 100;
0951 col = gROOT->GetColor(ncolor + 100);
0952 if (col)
0953 col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
0954 else
0955 c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
0956 vc.push_back(c);
0957 ncolor++;
0958 }
0959 for (int i = 0; i < npoints; i++) {
0960 tempfile >> x[i] >> y[i];
0961 }
0962 }
0963
0964 if (ncolor > 0 && ncolor < 10000) {
0965 Int_t colors[10000];
0966 for (int i = 0; i < ncolor; i++) {
0967 colors[i] = i + 100;
0968 }
0969 gStyle->SetPalette(ncolor, colors);
0970 }
0971
0972 tempfile.clear();
0973 tempfile.seekg(0, std::ios::beg);
0974 std::cout << "created palette with " << ncolor << " colors" << std::endl;
0975
0976 while (!tempfile.eof()) {
0977 tempfile >> red >> green >> blue >> npoints;
0978 for (int i = 0; i < npoints; i++) {
0979 tempfile >> x[i] >> y[i];
0980 }
0981 colindex = red + green * 1000 + blue * 1000000;
0982 pos = colorList.find(colindex);
0983 if (pos != colorList.end()) {
0984 TPolyLine *pline = new TPolyLine(npoints, y, x);
0985 vp.push_back(pline);
0986 pline->SetFillColor(colorList[colindex]);
0987 pline->SetLineWidth(0);
0988 pline->Draw("f");
0989 }
0990 }
0991 if (printflag) {
0992 float lminvalue = minvalue;
0993 float lmaxvalue = maxvalue;
0994 if (tkMapLog) {
0995 lminvalue = log(minvalue) / log(10);
0996 lmaxvalue = log(maxvalue) / log(10);
0997 }
0998 if (onlyPixelFlag) {
0999 axis = new TGaxis(-30, 36, -30, 1530, lminvalue, lmaxvalue, 510, "+L");
1000 } else {
1001 axis = new TGaxis(3660, 36, 3660, 1530, lminvalue, lmaxvalue, 510, "+L");
1002 }
1003 axis->SetLabelSize(0.02);
1004 axis->Draw();
1005 }
1006 TLatex l;
1007 l.SetTextSize(0.03);
1008 l.DrawLatex(950, 1330, "TID");
1009 l.DrawLatex(2300, 1330, "TEC");
1010 l.DrawLatex(300, 1330, "FPIX");
1011 l.DrawLatex(20, 560, "BPIX L1");
1012 l.DrawLatex(500, 385, "BPIX L2");
1013 l.DrawLatex(500, 945, "BPIX L3");
1014 l.SetTextSize(0.04);
1015 std::string fulltitle = title;
1016 if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
1017 fulltitle += ": Log10 scale";
1018 if (onlyPixelFlag) {
1019 l.DrawLatex(30, 1500, fulltitle.c_str());
1020 } else {
1021 l.DrawLatex(850, 1500, fulltitle.c_str());
1022 }
1023 if (onlyPixelFlag) {
1024 l.DrawLatex(380, 40, "-z");
1025 } else {
1026 l.DrawLatex(1730, 40, "-z");
1027 }
1028 if (onlyPixelFlag) {
1029 l.DrawLatex(380, 1330, "+z");
1030 } else {
1031 l.DrawLatex(1730, 1360, "+z");
1032 }
1033 l.DrawLatex(1085, 330, "TIB L1");
1034 l.DrawLatex(1085, 1000, "TIB L2");
1035 l.DrawLatex(1585, 330, "TIB L3");
1036 l.DrawLatex(1585, 1000, "TIB L4");
1037 l.DrawLatex(2085, 330, "TOB L1");
1038 l.DrawLatex(2085, 1000, "TOB L2");
1039 l.DrawLatex(2585, 330, "TOB L3");
1040 l.DrawLatex(2585, 1000, "TOB L4");
1041 l.DrawLatex(3085, 330, "TOB L5");
1042 l.DrawLatex(3085, 1000, "TOB L6");
1043 TArrow arx(3448, 1190, 3448, 1350, 0.01, "|>");
1044 l.DrawLatex(3460, 1350, "x");
1045 TArrow ary(3448, 1190, 3312, 1190, 0.01, "|>");
1046 l.DrawLatex(3312, 1210, "y");
1047 TArrow arz(3485, 373, 3485, 676, 0.01, "|>");
1048 l.DrawLatex(3510, 667, "z");
1049 TArrow arphi(3485, 511, 3037, 511, 0.01, "|>");
1050 l.DrawLatex(3023, 520, "#Phi");
1051 arx.SetLineWidth(3);
1052 ary.SetLineWidth(3);
1053 arz.SetLineWidth(3);
1054 arphi.SetLineWidth(3);
1055 if (onlyPixelFlag) {
1056 arx.SetX1(570);
1057 arx.SetX2(570);
1058 arx.SetY1(1190);
1059 arx.SetY2(1350);
1060 l.DrawLatex(570 + 12, 1190 + 160, "x");
1061 ary.SetX1(570);
1062 ary.SetX2(570 - 160);
1063 ary.SetY1(1190);
1064 ary.SetY2(1190);
1065 l.DrawLatex(570 - 160, 1190 + 30, "y");
1066 arz.SetX1(380);
1067 arz.SetX2(380);
1068 arz.SetY1(683 - 100);
1069 arz.SetY2(683 + 100);
1070 l.DrawLatex(380 + 15, 683 + 100 - 9, "z");
1071 arphi.SetX1(380);
1072 arphi.SetX2(380 - 390);
1073 arphi.SetY1(683);
1074 arphi.SetY2(683);
1075 l.DrawLatex(380 - 390 - 14, 683 + 9, "#Phi");
1076 }
1077 arx.Draw();
1078 ary.Draw();
1079 arz.Draw();
1080 arphi.Draw();
1081 TLegend *MyL = buildLegend();
1082
1083 if (title.find("QTestAlarm") != std::string::npos) {
1084 MyL->Draw();
1085 }
1086 MyC->Update();
1087 if (filetype == "png") {
1088 std::string filename = outputfilename + ".png";
1089 std::cout << "printing " << filename << std::endl;
1090 MyC->Print(filename.c_str());
1091 }
1092 if (filetype == "jpg") {
1093 std::string filename = outputfilename + ".jpg";
1094 MyC->Print(filename.c_str());
1095 }
1096 if (filetype == "pdf") {
1097 std::string filename = outputfilename + ".pdf";
1098 MyC->Print(filename.c_str());
1099 }
1100 std::string command = "rm " + tempfilename;
1101 command1 = command.c_str();
1102 std::cout << "Executing " << command1 << std::endl;
1103 system(command1);
1104 MyC->Clear();
1105 delete MyC;
1106 delete MyL;
1107 if (printflag)
1108 delete axis;
1109 for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
1110 delete (*pos1);
1111 }
1112 }
1113 }
1114 return;
1115 }
1116 void TrackerMap::drawApvPair(
1117 int crate, int numfed_incrate, bool print_total, TmApvPair *apvPair, std::ofstream *svgfile, bool useApvPairValue) {
1118 double xp[4], yp[4];
1119 int color;
1120 int green = 0;
1121 int red = 0;
1122 int blue = 0;
1123 double xd[4], yd[4];
1124 int np = 4;
1125 double boxinitx = 0., boxinity = 0.;
1126 double dx = .9, dy = .9;
1127
1128
1129
1130
1131
1132
1133 boxinitx = boxinitx + (NUMFED_INCOLUMN - 1 - (numfed_incrate - 1) / NUMFED_INROW) * (NUMFEDCH_INCOLUMN + 2);
1134 boxinity = boxinity + (NUMFED_INROW - 1 - (numfed_incrate - 1) % NUMFED_INROW) * (NUMFEDCH_INROW + 1);
1135 boxinity = boxinity + NUMFEDCH_INROW - (apvPair->getFedCh() / NUMFEDCH_INCOLUMN);
1136 boxinitx = boxinitx + NUMFEDCH_INCOLUMN - (int)(apvPair->getFedCh() % NUMFEDCH_INCOLUMN);
1137
1138 xp[0] = boxinitx;
1139 yp[0] = boxinity;
1140 xp[1] = boxinitx + dx;
1141 yp[1] = boxinity;
1142 xp[2] = boxinitx + dx;
1143 yp[2] = boxinity + dy;
1144 xp[3] = boxinitx;
1145 yp[3] = boxinity + dy;
1146 for (int j = 0; j < 4; j++) {
1147 xd[j] = xdpixelc(xp[j]);
1148 yd[j] = ydpixelc(yp[j]);
1149
1150 }
1151
1152 char buffer[20];
1153 sprintf(buffer, "%X", apvPair->mod->idex);
1154 std::string s = apvPair->mod->name;
1155 s.erase(s.begin() + s.find("connected"), s.end());
1156
1157 if (useApvPairValue) {
1158 if (apvPair->red < 0) {
1159 if (apvPair->count > 0) {
1160 color = getcolor(apvPair->value, palette);
1161 red = (color >> 16) & 0xFF;
1162 green = (color >> 8) & 0xFF;
1163 blue = (color)&0xFF;
1164 if (!print_total)
1165 apvPair->value = apvPair->value * apvPair->count;
1166 if (temporary_file)
1167 *svgfile << red << " " << green << " " << blue << " ";
1168 else
1169 *svgfile
1170 << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1171 << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1172 << apvPair->mod->getKey()
1173 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1174 "\" POS=\"Fed/Ch "
1175 << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1176 << " \" fill=\"rgb(" << red << "," << green << "," << blue << ")\" points=\"";
1177 } else {
1178 if (temporary_file)
1179 *svgfile << 255 << " " << 255 << " " << 255 << " ";
1180 else
1181 *svgfile
1182 << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1183 << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1184 << apvPair->mod->getKey()
1185 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1186 "\" POS=\"Fed/Ch "
1187 << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1188 << " \" fill=\"white\" points=\"";
1189 }
1190 } else {
1191 if (apvPair->red > 255)
1192 apvPair->red = 255;
1193 if (apvPair->green > 255)
1194 apvPair->green = 255;
1195 if (apvPair->blue > 255)
1196 apvPair->blue = 255;
1197 if (temporary_file)
1198 *svgfile << apvPair->red << " " << apvPair->green << " " << apvPair->blue << " ";
1199 else
1200 *svgfile
1201 << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1202 << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1203 << apvPair->mod->getKey()
1204 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1205 "\" POS=\"Fed/Ch "
1206 << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1207 << " \" fill=\"rgb(" << apvPair->red << "," << apvPair->green << "," << apvPair->blue << ")\" points=\"";
1208 }
1209 } else {
1210 if (apvPair->mod->red < 0) {
1211 if (apvPair->mod->count > 0) {
1212 color = getcolor(apvPair->mod->value, palette);
1213 red = (color >> 16) & 0xFF;
1214 green = (color >> 8) & 0xFF;
1215 blue = (color)&0xFF;
1216 if (temporary_file)
1217 *svgfile << red << " " << green << " " << blue << " ";
1218 else
1219 *svgfile
1220 << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1221 << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1222 << apvPair->mod->getKey()
1223 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1224 "\" POS=\"Fed/Ch "
1225 << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1226 << " \" fill=\"rgb(" << red << "," << green << "," << blue << ")\" points=\"";
1227 } else {
1228 if (temporary_file)
1229 *svgfile << 255 << " " << 255 << " " << 255 << " ";
1230 else
1231 *svgfile
1232 << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1233 << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1234 << apvPair->mod->getKey()
1235 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1236 "\" POS=\"Fed/Ch "
1237 << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1238 << " \" fill=\"white\" points=\"";
1239 }
1240 } else {
1241 if (apvPair->mod->red > 255)
1242 apvPair->mod->red = 255;
1243 if (apvPair->mod->green > 255)
1244 apvPair->mod->green = 255;
1245 if (apvPair->mod->blue > 255)
1246 apvPair->mod->blue = 255;
1247 if (temporary_file)
1248 *svgfile << apvPair->mod->red << " " << apvPair->mod->green << " " << apvPair->mod->blue << " ";
1249 else
1250 *svgfile
1251 << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1252 << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1253 << apvPair->mod->getKey()
1254 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1255 "\" POS=\"Fed/Ch "
1256 << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1257 << " \" fill=\"rgb(" << apvPair->mod->red << "," << apvPair->mod->green << "," << apvPair->mod->blue
1258 << ")\" points=\"";
1259 }
1260 }
1261 if (temporary_file)
1262 *svgfile << np << " ";
1263 for (int k = 0; k < np; k++) {
1264 if (temporary_file)
1265 *svgfile << xd[k] << " " << yd[k] << " ";
1266 else
1267 *svgfile << xd[k] << "," << yd[k] << " ";
1268 }
1269 if (temporary_file)
1270 *svgfile << std::endl;
1271 else
1272 *svgfile << "\" />" << std::endl;
1273 }
1274 void TrackerMap::drawCcu(
1275 int crate, int numfec_incrate, bool print_total, TmCcu *ccu, std::ofstream *svgfile, bool useCcuValue) {
1276 double xp[4], yp[4];
1277 int color;
1278 int green = 0;
1279 int red = 0;
1280 int blue = 0;
1281 double xd[4], yd[4];
1282 int np = 4;
1283 double boxinitx = 0., boxinity = 0.;
1284 double dx = .9, dy = .9;
1285 int numccu_incolumn = 8;
1286 int numccu_inrow = 15;
1287 int numfec_incolumn = 5;
1288 int numfec_inrow = 4;
1289 boxinitx = boxinitx + (numfec_incolumn - (numfec_incrate - 1) / numfec_inrow) * 14.;
1290 boxinity = boxinity + (numfec_inrow - (numfec_incrate - 1) % numfec_inrow) * 16.;
1291 boxinity = boxinity + numccu_inrow - ccu->mpos;
1292 boxinitx = boxinitx + numccu_incolumn - (int)(ccu->getCcuRing() % numccu_incolumn);
1293
1294 xp[0] = boxinitx;
1295 yp[0] = boxinity;
1296 xp[1] = boxinitx + dx;
1297 yp[1] = boxinity;
1298 xp[2] = boxinitx + dx;
1299 yp[2] = boxinity + dy;
1300 xp[3] = boxinitx;
1301 yp[3] = boxinity + dy;
1302 for (int j = 0; j < 4; j++) {
1303 xd[j] = xdpixelfec(xp[j]);
1304 yd[j] = ydpixelfec(yp[j]);
1305
1306 }
1307
1308 char buffer[20];
1309 sprintf(buffer, "%X", ccu->idex);
1310
1311
1312 std::string s = ccu->text;
1313 s.erase(s.begin() + s.find("connected"), s.end());
1314
1315 if (ccu->red < 0) {
1316 if (ccu->count > 0) {
1317 color = getcolor(ccu->value, palette);
1318 red = (color >> 16) & 0xFF;
1319 green = (color >> 8) & 0xFF;
1320 blue = (color)&0xFF;
1321 if (!print_total)
1322 ccu->value = ccu->value * ccu->count;
1323 if (temporary_file)
1324 *svgfile << red << " " << green << " " << blue << " ";
1325 else
1326 *svgfile
1327 << "<svg:polygon detid=\"" << ccu->idex << "\" count=\"" << ccu->count << "\" value=\"" << ccu->value
1328 << "\" id=\"" << ccu->idex + crate * 1000000 << "\" cmodid=\"" << ccu->cmodid << "\" layer=\"" << ccu->layer
1329 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1330 "\" POS=\"Slot/Ring"
1331 << ccu->getCcuSlot() << "/" << ccu->getCcuRing() << " connected to " << s << " Id " << buffer
1332 << " \" fill=\"rgb(" << red << "," << green << "," << blue << ")\" points=\"";
1333 } else {
1334 if (temporary_file)
1335 *svgfile << 255 << " " << 255 << " " << 255 << " ";
1336 else
1337 *svgfile
1338 << "<svg:polygon detid=\"" << ccu->idex << "\" count=\"" << ccu->count << "\" value=\"" << ccu->value
1339 << "\" id=\"" << ccu->idex + crate * 1000000 << "\" cmodid=\"" << ccu->cmodid << "\" layer=\""
1340 << ccu->layer
1341 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1342 "\" POS=\"Slot/Ring "
1343 << ccu->getCcuSlot() << "/" << ccu->getCcuRing() << " connected to " << s << " Id " << buffer
1344 << " \" fill=\"white\" points=\"";
1345 }
1346 } else {
1347 if (ccu->red > 255)
1348 ccu->red = 255;
1349 if (ccu->green > 255)
1350 ccu->green = 255;
1351 if (ccu->blue > 255)
1352 ccu->blue = 255;
1353 if (temporary_file)
1354 *svgfile << ccu->red << " " << ccu->green << " " << ccu->blue << " ";
1355 else
1356 *svgfile
1357 << "<svg:polygon detid=\"" << ccu->idex << "\" count=\"" << ccu->count << "\" value=\"" << ccu->value
1358 << "\" id=\"" << ccu->idex + crate * 1000000 << "\" cmodid=\"" << ccu->cmodid << "\" layer=\"" << ccu->layer
1359 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1360 "\" POS=\"Slot/Ring "
1361 << ccu->getCcuSlot() << "/" << ccu->getCcuRing() << " connected to " << s << " Id " << buffer
1362 << " \" fill=\"rgb(" << ccu->red << "," << ccu->green << "," << ccu->blue << ")\" points=\"";
1363 }
1364 if (temporary_file)
1365 *svgfile << np << " ";
1366 for (int k = 0; k < np; k++) {
1367 if (temporary_file)
1368 *svgfile << xd[k] << " " << yd[k] << " ";
1369 else
1370 *svgfile << xd[k] << "," << yd[k] << " ";
1371 }
1372 if (temporary_file)
1373 *svgfile << std::endl;
1374 else
1375 *svgfile << "\" />" << std::endl;
1376 }
1377 void TrackerMap::drawPsu(
1378 int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue) {
1379 double xp[4], yp[4];
1380 int color;
1381 int green = 0;
1382 int red = 0;
1383 int blue = 0;
1384 double xd[4], yd[4];
1385 int np = 4;
1386 double boxinitx = 0., boxinity = 0.;
1387 double dx = .9, dy = .9;
1388
1389 boxinitx = boxinitx + (NUMPSUCRATE_INCOLUMN - psu->getPsuCrate()) * 1.5;
1390 boxinity = boxinity + (NUMPSUCH_INROW - psu->getPsuBoard());
1391
1392 xp[0] = boxinitx;
1393 yp[0] = boxinity;
1394 xp[1] = boxinitx + dx;
1395 yp[1] = boxinity;
1396 xp[2] = boxinitx + dx;
1397 yp[2] = boxinity + dy;
1398 xp[3] = boxinitx;
1399 yp[3] = boxinity + dy;
1400
1401 for (int j = 0; j < 4; j++) {
1402 xd[j] = xdpixelpsu(xp[j]);
1403 yd[j] = ydpixelpsu(yp[j]);
1404
1405 }
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418 char buffer[20];
1419 sprintf(buffer, "%X", psu->idex);
1420 std::string s = psu->text;
1421 s.erase(s.begin() + s.find("connected"), s.end());
1422
1423 if (psu->red < 0) {
1424 if (psu->count > 0) {
1425 color = getcolor(psu->value, palette);
1426 red = (color >> 16) & 0xFF;
1427 green = (color >> 8) & 0xFF;
1428 blue = (color)&0xFF;
1429 if (!print_total)
1430 psu->value = psu->value * psu->count;
1431 if (temporary_file)
1432 *svgfile << red << " " << green << " " << blue << " ";
1433 else
1434 *svgfile
1435 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->count << "\" value=\"" << psu->value
1436 << "\" id=\"" << psu->idex << "\" cmodid=\"" << psu->cmodid_LV
1437 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1438 "\" POS=\"easyCrate/easyBoard "
1439 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << red
1440 << "," << green << "," << blue << ")\" points=\"";
1441 } else {
1442 if (temporary_file)
1443 *svgfile << 255 << " " << 255 << " " << 255 << " ";
1444 else
1445 *svgfile
1446 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->count << "\" value=\"" << psu->value
1447 << "\" id=\"" << psu->idex << "\" cmodid=\"" << psu->cmodid_LV
1448 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1449 "\" POS=\"easyCrate/easyBoard "
1450 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s
1451 << " \" fill=\"white\" points=\"";
1452 }
1453 }
1454
1455 else {
1456 if (psu->red > 255)
1457 psu->red = 255;
1458 if (psu->green > 255)
1459 psu->green = 255;
1460 if (psu->blue > 255)
1461 psu->blue = 255;
1462 if (temporary_file)
1463 *svgfile << psu->red << " " << psu->green << " " << psu->blue << " ";
1464 else
1465 *svgfile
1466 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->count << "\" value=\"" << psu->value
1467 << "\" id=\"" << psu->idex << "\" cmodid=\"" << psu->cmodid_LV
1468 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1469 "\" POS=\"easyCrate/easyBoard "
1470 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << psu->red
1471 << "," << psu->green << "," << psu->blue << ")\" points=\"";
1472 }
1473
1474 if (temporary_file)
1475 *svgfile << np << " ";
1476 for (int k = 0; k < np; k++) {
1477 if (temporary_file)
1478 *svgfile << xd[k] << " " << yd[k] << " ";
1479 else
1480 *svgfile << xd[k] << "," << yd[k] << " ";
1481 }
1482 if (temporary_file)
1483 *svgfile << std::endl;
1484 else
1485 *svgfile << "\" />" << std::endl;
1486 }
1487
1488 void TrackerMap::drawHV2(
1489 int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue) {
1490 double xp[4], yp[4];
1491 int color;
1492 int greenHV2 = 0;
1493 int redHV2 = 0;
1494 int blueHV2 = 0;
1495 double xd[4], yd[4];
1496 int np = 4;
1497 double boxinitx = 35, boxinity = 12;
1498 double dx = 1.1, dy = 1.3;
1499
1500 boxinitx = boxinitx + (5 - psu->getPsuCrate()) * 5;
1501 boxinity = boxinity + (18 - psu->getPsuBoard()) * 1.75;
1502
1503 xp[0] = boxinitx;
1504 yp[0] = boxinity;
1505 xp[1] = boxinitx + dx;
1506 yp[1] = boxinity;
1507 xp[2] = boxinitx + dx;
1508 yp[2] = boxinity + dy;
1509 xp[3] = boxinitx;
1510 yp[3] = boxinity + dy;
1511
1512 for (int j = 0; j < 4; j++) {
1513 xd[j] = xdpixelpsu(xp[j]);
1514 yd[j] = ydpixelpsu(yp[j]);
1515
1516 }
1517
1518 char buffer[20];
1519 sprintf(buffer, "%X", psu->idex);
1520 std::string s = psu->textHV2;
1521 s.erase(s.begin() + s.find("connected"), s.end());
1522
1523 if (psu->redHV2 < 0) {
1524
1525 if (psu->valueHV2 > 0) {
1526 color = getcolor(psu->valueHV2, palette);
1527 redHV2 = (color >> 16) & 0xFF;
1528 greenHV2 = (color >> 8) & 0xFF;
1529 blueHV2 = (color)&0xFF;
1530 if (!print_total)
1531 psu->valueHV2 = psu->valueHV2 * psu->countHV2;
1532 if (temporary_file)
1533 *svgfile << redHV2 << " " << greenHV2 << " " << blueHV2 << " ";
1534 else
1535 *svgfile
1536 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV2 << "\" value=\"" << psu->valueHV2
1537 << "\" id=\"" << psu->idex * 10 + 2 << "\" cmodid=\"" << psu->cmodid_HV2
1538 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1539 "\" POS=\"easyCrate/easyBoard "
1540 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << redHV2
1541 << "," << greenHV2 << "," << blueHV2 << ")\" points=\"";
1542 } else {
1543 if (temporary_file)
1544 *svgfile << 255 << " " << 255 << " " << 255 << " ";
1545 else
1546 *svgfile
1547 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV2 << "\" value=\"" << psu->valueHV2
1548 << "\" id=\"" << psu->idex * 10 + 2 << "\" cmodid=\"" << psu->cmodid_HV2
1549 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1550 "\" POS=\"easyCrate/easyBoard "
1551 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s
1552 << " \" fill=\"white\" points=\"";
1553 }
1554 }
1555
1556 else {
1557 if (psu->redHV2 > 255)
1558 psu->redHV2 = 255;
1559 if (psu->greenHV2 > 255)
1560 psu->greenHV2 = 255;
1561 if (psu->blueHV2 > 255)
1562 psu->blueHV2 = 255;
1563 if (temporary_file)
1564 *svgfile << psu->redHV2 << " " << psu->greenHV2 << " " << psu->blueHV2 << " ";
1565 else
1566 *svgfile
1567 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV2 << "\" value=\"" << psu->valueHV2
1568 << "\" id=\"" << psu->idex * 10 + 2 << "\" cmodid=\"" << psu->cmodid_HV2
1569 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1570 "\" POS=\"easyCrate/easyBoard "
1571 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb("
1572 << psu->redHV2 << "," << psu->greenHV2 << "," << psu->blueHV2 << ")\" points=\"";
1573 }
1574
1575 if (temporary_file)
1576 *svgfile << np << " ";
1577 for (int k = 0; k < np; k++) {
1578 if (temporary_file)
1579 *svgfile << xd[k] << " " << yd[k] << " ";
1580 else
1581 *svgfile << xd[k] << "," << yd[k] << " ";
1582 }
1583 if (temporary_file)
1584 *svgfile << std::endl;
1585 else
1586 *svgfile << "\" />" << std::endl;
1587 }
1588
1589 void TrackerMap::drawHV3(
1590 int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue) {
1591 double xp[4], yp[4];
1592 int color;
1593 int greenHV3 = 0;
1594 int redHV3 = 0;
1595 int blueHV3 = 0;
1596 double xd[4], yd[4];
1597 int np = 4;
1598 double boxinitx = 36.5, boxinity = 12;
1599 double dx = 1.1, dy = 1.3;
1600
1601 boxinitx = boxinitx + (5 - psu->getPsuCrate()) * 5;
1602 boxinity = boxinity + (18 - psu->getPsuBoard()) * 1.75;
1603
1604 xp[0] = boxinitx;
1605 yp[0] = boxinity;
1606 xp[1] = boxinitx + dx;
1607 yp[1] = boxinity;
1608 xp[2] = boxinitx + dx;
1609 yp[2] = boxinity + dy;
1610 xp[3] = boxinitx;
1611 yp[3] = boxinity + dy;
1612
1613 for (int j = 0; j < 4; j++) {
1614 xd[j] = xdpixelpsu(xp[j]);
1615 yd[j] = ydpixelpsu(yp[j]);
1616
1617 }
1618
1619 char buffer[20];
1620 sprintf(buffer, "%X", psu->idex);
1621 std::string s = psu->textHV3;
1622 s.erase(s.begin() + s.find("connected"), s.end());
1623
1624 if (psu->redHV3 < 0) {
1625 if (psu->valueHV3 > 0) {
1626 color = getcolor(psu->valueHV3, palette);
1627 redHV3 = (color >> 16) & 0xFF;
1628 greenHV3 = (color >> 8) & 0xFF;
1629 blueHV3 = (color)&0xFF;
1630 if (!print_total)
1631 psu->valueHV3 = psu->valueHV3 * psu->countHV3;
1632 if (temporary_file)
1633 *svgfile << redHV3 << " " << greenHV3 << " " << blueHV3 << " ";
1634 else
1635 *svgfile
1636 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV3 << "\" value=\"" << psu->valueHV3
1637 << "\" id=\"" << psu->idex * 10 + 3 << "\" cmodid=\"" << psu->cmodid_HV3
1638 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1639 "\" POS=\"easyCrate/easyBoard"
1640 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << redHV3
1641 << "," << greenHV3 << "," << blueHV3 << ")\" points=\"";
1642 } else {
1643 if (temporary_file)
1644 *svgfile << 255 << " " << 255 << " " << 255 << " ";
1645 else
1646 *svgfile
1647 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV3 << "\" value=\"" << psu->valueHV3
1648 << "\" id=\"" << psu->idex * 10 + 3 << "\" cmodid=\"" << psu->cmodid_HV3
1649 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1650 "\" POS=\"easyCrate/easyBoard "
1651 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s
1652 << " \" fill=\"white\" points=\"";
1653 }
1654 }
1655
1656 else {
1657 if (psu->redHV3 > 255)
1658 psu->redHV3 = 255;
1659 if (psu->greenHV3 > 255)
1660 psu->greenHV3 = 255;
1661 if (psu->blueHV3 > 255)
1662 psu->blueHV3 = 255;
1663 if (temporary_file)
1664 *svgfile << psu->redHV3 << " " << psu->greenHV3 << " " << psu->blueHV3 << " ";
1665 else
1666 *svgfile
1667 << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV3 << "\" value=\"" << psu->valueHV3
1668 << "\" id=\"" << psu->idex * 10 + 3 << "\" cmodid=\"" << psu->cmodid_HV3
1669 << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1670 "\" POS=\"easyCrate/easyBoard "
1671 << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb("
1672 << psu->redHV3 << "," << psu->greenHV3 << "," << psu->blueHV3 << ")\" points=\"";
1673 }
1674
1675 if (temporary_file)
1676 *svgfile << np << " ";
1677 for (int k = 0; k < np; k++) {
1678 if (temporary_file)
1679 *svgfile << xd[k] << " " << yd[k] << " ";
1680 else
1681 *svgfile << xd[k] << "," << yd[k] << " ";
1682 }
1683 if (temporary_file)
1684 *svgfile << std::endl;
1685 else
1686 *svgfile << "\" />" << std::endl;
1687 }
1688
1689 void TrackerMap::save_as_fectrackermap(
1690 bool print_total, float minval, float maxval, std::string s, int width, int height) {
1691 if (enableFecProcessing) {
1692 std::string filetype = s, outputfilename = s;
1693 std::vector<TPolyLine *> vp;
1694 TGaxis *axis = nullptr;
1695 size_t found = filetype.find_last_of('.');
1696 filetype = filetype.substr(found + 1);
1697 found = outputfilename.find_last_of('.');
1698 outputfilename = outputfilename.substr(0, found);
1699 temporary_file = true;
1700 if (filetype == "xml" || filetype == "svg")
1701 temporary_file = false;
1702 std::ostringstream outs;
1703 minvalue = minval;
1704 maxvalue = maxval;
1705 outs << outputfilename << ".coor";
1706 if (temporary_file)
1707 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1708 std::map<int, TmCcu *>::iterator i_ccu;
1709 std::multimap<TmCcu *, TmModule *>::iterator it;
1710 std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
1711
1712 bool useCcuValue = false;
1713
1714 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1715 TmCcu *ccu = i_ccu->second;
1716 if (ccu != nullptr) {
1717 if (ccu->count > 0 || ccu->red != -1) {
1718 useCcuValue = true;
1719 break;
1720 }
1721 }
1722 }
1723
1724 if (!useCcuValue)
1725 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1726 TmCcu *ccu = i_ccu->second;
1727 if (ccu != nullptr) {
1728 ret = fecModuleMap.equal_range(ccu);
1729 for (it = ret.first; it != ret.second; ++it) {
1730 if ((*it).second->count > 0) {
1731 ccu->value = ccu->value + (*it).second->value;
1732 ccu->count++;
1733 }
1734 }
1735 if (ccu->count > 0)
1736 ccu->value = ccu->value / ccu->count;
1737 if (ccu->nmod == 0) {
1738 ccu->red = 0;
1739 ccu->green = 0;
1740 ccu->blue = 0;
1741 }
1742 }
1743 }
1744
1745 if (title.find("QTestAlarm") != std::string::npos) {
1746 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1747 TmCcu *ccu = i_ccu->second;
1748 if (ccu != nullptr) {
1749 ret = fecModuleMap.equal_range(ccu);
1750 ccu->red = 0;
1751 ccu->green = 255;
1752 ccu->blue = 0;
1753 for (it = ret.first; it != ret.second; ++it) {
1754 if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
1755 !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
1756 ccu->red = 255;
1757 ccu->green = 0;
1758 ccu->blue = 0;
1759 }
1760 }
1761 }
1762 }
1763 }
1764
1765 if (!print_total) {
1766 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1767 TmCcu *ccu = i_ccu->second;
1768 if (ccu != nullptr) {
1769 if (useCcuValue)
1770 ccu->value = ccu->value / ccu->count;
1771 }
1772 }
1773 }
1774
1775 if (minvalue >= maxvalue) {
1776 minvalue = 9999999.;
1777 maxvalue = -9999999.;
1778 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1779 TmCcu *ccu = i_ccu->second;
1780 if (ccu != nullptr && ccu->count > 0) {
1781 if (minvalue > ccu->value)
1782 minvalue = ccu->value;
1783 if (maxvalue < ccu->value)
1784 maxvalue = ccu->value;
1785 }
1786 }
1787 }
1788
1789 if (filetype == "svg") {
1790 saveAsSingleLayer = false;
1791 std::ostringstream outs;
1792 outs << outputfilename << ".svg";
1793 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1794 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
1795 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
1796 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
1797 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
1798 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
1799 << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
1800 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
1801 << std::endl;
1802 *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" "
1803 "style=\"fill:none;stroke:black;stroke-width:0;\"> "
1804 << std::endl;
1805 }
1806 for (int crate = 1; crate < (nfeccrates + 1); crate++) {
1807 if (filetype == "xml") {
1808 saveAsSingleLayer = true;
1809 std::ostringstream outs;
1810 outs << outputfilename << "feccrate" << crate << ".xml";
1811 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1812 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
1813 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
1814 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
1815 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
1816 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"feccrate.js\" />" << std::endl;
1817 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
1818 "onload=\"TrackerCrate.init()\">"
1819 << std::endl;
1820 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
1821 << std::endl;
1822 *savefile << "<g id=\"crate\" transform=\" translate(280,580) rotate(270) scale(.7,.8)\" > " << std::endl;
1823 }
1824
1825 deffecwindow(crate);
1826
1827 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1828 TmCcu *ccu = i_ccu->second;
1829 if (ccu != nullptr) {
1830 if (ccu->getCcuCrate() == crate) {
1831 drawCcu(crate, ccu->getCcuSlot() - 2, print_total, ccu, savefile, useCcuValue);
1832 }
1833 }
1834 }
1835
1836 if (!temporary_file) {
1837 if (filetype == "xml") {
1838 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
1839 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
1840 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
1841 *savefile << " </text> </svg>" << std::endl;
1842 savefile->close();
1843 saveAsSingleLayer = false;
1844 }
1845 }
1846 }
1847 if (filetype == "svg") {
1848 *savefile << "</g> </svg> </svg> " << std::endl;
1849 savefile->close();
1850 }
1851 if (!print_total && !useCcuValue) {
1852
1853 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1854 TmCcu *ccu = i_ccu->second;
1855 if (ccu != nullptr) {
1856 ccu->value = ccu->value * ccu->count;
1857 }
1858 }
1859 }
1860 if (temporary_file) {
1861 if (printflag && !saveWebInterface)
1862 drawPalette(savefile);
1863 savefile->close();
1864
1865 const char *command1;
1866 std::string tempfilename = outputfilename + ".coor";
1867 int red, green, blue, npoints, colindex, ncolor;
1868 double x[4], y[4];
1869 std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
1870 TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
1871 gPad->SetFillColor(38);
1872
1873 if (saveWebInterface)
1874 gPad->Range(0, 0, 3700, 1600);
1875 else
1876 gPad->Range(0, 0, 3800, 1600);
1877
1878
1879 ncolor = 0;
1880 typedef std::map<int, int> ColorList;
1881 ColorList colorList;
1882 ColorList::iterator pos;
1883 TColor *col, *c;
1884 while (!tempfile.eof()) {
1885 tempfile >> red >> green >> blue >> npoints;
1886 colindex = red + green * 1000 + blue * 1000000;
1887 pos = colorList.find(colindex);
1888 if (pos == colorList.end()) {
1889 colorList[colindex] = ncolor + 100;
1890 col = gROOT->GetColor(ncolor + 100);
1891 if (col)
1892 col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
1893 else {
1894 c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
1895 vc.push_back(c);
1896 }
1897 ncolor++;
1898 }
1899 for (int i = 0; i < npoints; i++) {
1900 tempfile >> x[i] >> y[i];
1901 }
1902 }
1903 if (ncolor > 0 && ncolor < 10000) {
1904 Int_t colors[10000];
1905 for (int i = 0; i < ncolor; i++) {
1906 colors[i] = i + 100;
1907 }
1908 gStyle->SetPalette(ncolor, colors);
1909 }
1910 tempfile.clear();
1911 tempfile.seekg(0, std::ios::beg);
1912 std::cout << "created palette with " << ncolor << " colors" << std::endl;
1913 while (!tempfile.eof()) {
1914 tempfile >> red >> green >> blue >> npoints;
1915 for (int i = 0; i < npoints; i++) {
1916 tempfile >> x[i] >> y[i];
1917 }
1918 colindex = red + green * 1000 + blue * 1000000;
1919 pos = colorList.find(colindex);
1920 if (pos != colorList.end()) {
1921 TPolyLine *pline = new TPolyLine(npoints, y, x);
1922 vp.push_back(pline);
1923 pline->SetFillColor(colorList[colindex]);
1924 pline->SetLineWidth(0);
1925 pline->Draw("f");
1926 }
1927 }
1928 if (printflag && !saveWebInterface) {
1929 float lminvalue = minvalue;
1930 float lmaxvalue = maxvalue;
1931 if (tkMapLog) {
1932 lminvalue = log(minvalue) / log(10);
1933 lmaxvalue = log(maxvalue) / log(10);
1934 }
1935 axis = new TGaxis(3660, 36, 3660, 1530, lminvalue, lmaxvalue, 510, "+L");
1936 axis->SetLabelSize(0.02);
1937 axis->Draw();
1938 }
1939
1940 if (!saveWebInterface) {
1941 TLatex l;
1942 l.SetTextSize(0.05);
1943 std::string fulltitle = title;
1944 if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
1945 fulltitle += ": Log10 scale";
1946 l.DrawLatex(50, 1530, fulltitle.c_str());
1947 }
1948 MyC->Update();
1949 std::cout << "Filetype " << filetype << std::endl;
1950 if (filetype == "png") {
1951 std::string filename = outputfilename + ".png";
1952 MyC->Print(filename.c_str());
1953 }
1954 if (filetype == "jpg") {
1955 std::string filename = outputfilename + ".jpg";
1956 MyC->Print(filename.c_str());
1957 }
1958 if (filetype == "pdf") {
1959 std::string filename = outputfilename + ".pdf";
1960 MyC->Print(filename.c_str());
1961 }
1962 std::string command = "rm " + tempfilename;
1963 command1 = command.c_str();
1964 std::cout << "Executing " << command1 << std::endl;
1965 system(command1);
1966 MyC->Clear();
1967 delete MyC;
1968 if (printflag && !saveWebInterface)
1969 delete axis;
1970 for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
1971 delete (*pos1);
1972 }
1973
1974 }
1975 }
1976 }
1977 void TrackerMap::save_as_HVtrackermap(
1978 bool print_total, float minval, float maxval, std::string s, int width, int height) {
1979 if (enableHVProcessing) {
1980 std::string filetype = s, outputfilename = s;
1981 std::vector<TPolyLine *> vp;
1982 TGaxis *axis = nullptr;
1983 size_t found = filetype.find_last_of('.');
1984 filetype = filetype.substr(found + 1);
1985 found = outputfilename.find_last_of('.');
1986 outputfilename = outputfilename.substr(0, found);
1987
1988 temporary_file = true;
1989
1990 if (filetype == "xml" || filetype == "svg")
1991 temporary_file = false;
1992
1993 std::ostringstream outs;
1994 minvalue = minval;
1995 maxvalue = maxval;
1996 outs << outputfilename << ".coor";
1997 if (temporary_file)
1998 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1999
2000 std::map<int, TmPsu *>::iterator ipsu;
2001 std::multimap<TmPsu *, TmModule *>::iterator it;
2002 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
2003
2004 bool usePsuValue = false;
2005
2006 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2007 TmPsu *psu = ipsu->second;
2008 if (psu != nullptr) {
2009 if (psu->countHV2 > 0 || psu->redHV2 != -1 || psu->countHV3 > 0 || psu->redHV3 != -1) {
2010 usePsuValue = true;
2011 break;
2012 }
2013 }
2014 }
2015
2016 if (!usePsuValue) {
2017
2018 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2019 TmPsu *psu = ipsu->second;
2020 if (psu != nullptr) {
2021 ret = psuModuleMap.equal_range(psu);
2022 int nconn1 = 0;
2023 int nconn2 = 0;
2024 for (it = ret.first; it != ret.second; ++it) {
2025 if ((*it).second->HVchannel == 2 && (*it).second->count > 0) {
2026 nconn1++;
2027 psu->valueHV2 = psu->valueHV2 + (*it).second->value;
2028 }
2029 if ((*it).second->HVchannel == 3 && (*it).second->count > 0) {
2030 nconn2++;
2031 psu->valueHV3 = psu->valueHV3 + (*it).second->value;
2032 }
2033 }
2034 if (psu->nmodHV2 != 0 && nconn1 > 0) {
2035 psu->valueHV2 = psu->valueHV2 / psu->nmodHV2;
2036 psu->countHV2 = 1;
2037 }
2038 if (psu->nmodHV3 != 0 && nconn2 > 0) {
2039 psu->valueHV3 = psu->valueHV3 / psu->nmodHV3;
2040 psu->countHV3 = 1;
2041 }
2042 }
2043 }
2044 }
2045
2046 if (title.find("QTestAlarm") != std::string::npos) {
2047 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2048 TmPsu *psu = ipsu->second;
2049 if (psu != nullptr) {
2050 ret = psuModuleMap.equal_range(psu);
2051 psu->redHV2 = 0;
2052 psu->greenHV2 = 255;
2053 psu->blueHV2 = 0;
2054 psu->redHV3 = 0;
2055 psu->greenHV3 = 255;
2056 psu->blueHV3 = 0;
2057 for (it = ret.first; it != ret.second; ++it) {
2058 if ((*it).second->HVchannel == 2) {
2059 if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
2060 !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
2061 psu->redHV2 = 255;
2062 psu->greenHV2 = 0;
2063 psu->blueHV2 = 0;
2064 }
2065 }
2066 if ((*it).second->HVchannel == 3) {
2067 if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
2068 !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
2069 psu->redHV3 = 255;
2070 psu->greenHV3 = 0;
2071 psu->blueHV3 = 0;
2072 }
2073 }
2074 }
2075 }
2076 }
2077 }
2078
2079 if (!print_total) {
2080 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2081 TmPsu *psu = ipsu->second;
2082 if (psu != nullptr) {
2083 if (usePsuValue) {
2084 psu->valueHV2 = psu->valueHV2 / psu->countHV2;
2085 psu->valueHV3 = psu->valueHV3 / psu->countHV3;
2086 }
2087 }
2088 }
2089 }
2090
2091 if (minvalue >= maxvalue) {
2092 minvalue = 9999999.;
2093 maxvalue = -9999999.;
2094
2095 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2096 TmPsu *psu = ipsu->second;
2097 if (psu != nullptr && psu->countHV2 > 0 && psu->countHV3 > 0) {
2098 if (minvalue > psu->valueHV2 || minvalue > psu->valueHV3)
2099 minvalue = std::min(psu->valueHV2, psu->valueHV3);
2100 if (maxvalue < psu->valueHV2 || maxvalue < psu->valueHV3)
2101 maxvalue = std::max(psu->valueHV2, psu->valueHV3);
2102 }
2103 }
2104 }
2105
2106 if (filetype == "svg") {
2107 saveAsSingleLayer = false;
2108 std::ostringstream outs;
2109 outs << outputfilename << ".svg";
2110 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2111 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
2112 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2113 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
2114 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
2115 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
2116 << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
2117 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
2118 << std::endl;
2119 *savefile << "<svg:g id=\"HVtrackermap\" transform=\"translate(10,1500) rotate(270)\" "
2120 "style=\"fill:none;stroke:black;stroke-width:0;\"> "
2121 << std::endl;
2122 }
2123
2124 for (int irack = 1; irack < (npsuracks + 1); irack++) {
2125 if (filetype == "xml") {
2126 saveAsSingleLayer = true;
2127 std::ostringstream outs;
2128 outs << outputfilename << "HVrack" << irack << ".xml";
2129 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2130 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
2131 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2132 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
2133 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
2134 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rackhv.js\" />" << std::endl;
2135 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
2136 "onload=\"TrackerRackhv.init()\">"
2137 << std::endl;
2138 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
2139 << std::endl;
2140 *savefile << "<g id=\"rackhv\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > " << std::endl;
2141 }
2142
2143
2144 defpsuwindow(irack);
2145 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2146 TmPsu *psu = ipsu->second;
2147 if (psu->getPsuRack() == irack) {
2148 drawHV2(irack, psu->getPsuCrate(), print_total, psu, savefile, usePsuValue);
2149 drawHV3(irack, psu->getPsuCrate(), print_total, psu, savefile, usePsuValue);
2150 }
2151 }
2152
2153 if (!temporary_file) {
2154 if (filetype == "xml") {
2155 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2156 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2157 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2158 *savefile << " </text> </svg>" << std::endl;
2159 savefile->close();
2160 saveAsSingleLayer = false;
2161 }
2162 }
2163 }
2164 if (filetype == "svg") {
2165 *savefile << "</g> </svg> </svg> " << std::endl;
2166 savefile->close();
2167 }
2168
2169
2170 if (!print_total && !usePsuValue) {
2171 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2172 TmPsu *psu = ipsu->second;
2173 if (psu != nullptr) {
2174 psu->valueHV2 = psu->valueHV2 * psu->countHV2;
2175 psu->valueHV3 = psu->valueHV3 * psu->countHV3;
2176 }
2177 }
2178 }
2179
2180 if (temporary_file) {
2181 if (printflag && !saveWebInterface)
2182 drawPalette(savefile);
2183 savefile->close();
2184
2185 const char *command1;
2186 std::string tempfilename = outputfilename + ".coor";
2187 int red, green, blue, npoints, colindex, ncolor;
2188 double x[4], y[4];
2189 std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2190 TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2191 gPad->SetFillColor(38);
2192
2193 if (saveWebInterface)
2194 gPad->Range(0, 0, 3700, 1600);
2195 else
2196 gPad->Range(0, 0, 3800, 1600);
2197
2198
2199 ncolor = 0;
2200 typedef std::map<int, int> ColorList;
2201 ColorList colorList;
2202 ColorList::iterator pos;
2203 TColor *col, *c;
2204 while (!tempfile.eof()) {
2205 tempfile >> red >> green >> blue >> npoints;
2206 colindex = red + green * 1000 + blue * 1000000;
2207 pos = colorList.find(colindex);
2208 if (pos == colorList.end()) {
2209 colorList[colindex] = ncolor + 100;
2210 col = gROOT->GetColor(ncolor + 100);
2211 if (col)
2212 col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2213 else {
2214 c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2215 vc.push_back(c);
2216 }
2217 ncolor++;
2218 }
2219 for (int i = 0; i < npoints; i++) {
2220 tempfile >> x[i] >> y[i];
2221 }
2222 }
2223 if (ncolor > 0 && ncolor < 10000) {
2224 Int_t colors[10000];
2225 for (int i = 0; i < ncolor; i++) {
2226 colors[i] = i + 100;
2227 }
2228 gStyle->SetPalette(ncolor, colors);
2229 }
2230 tempfile.clear();
2231 tempfile.seekg(0, std::ios::beg);
2232 std::cout << "created palette with " << ncolor << " colors" << std::endl;
2233 while (!tempfile.eof()) {
2234 tempfile >> red >> green >> blue >> npoints;
2235 for (int i = 0; i < npoints; i++) {
2236 tempfile >> x[i] >> y[i];
2237 }
2238 colindex = red + green * 1000 + blue * 1000000;
2239 pos = colorList.find(colindex);
2240 if (pos != colorList.end()) {
2241 TPolyLine *pline = new TPolyLine(npoints, y, x);
2242 vp.push_back(pline);
2243 pline->SetFillColor(colorList[colindex]);
2244 pline->SetLineWidth(0);
2245 pline->Draw("f");
2246 }
2247 }
2248 if (printflag && !saveWebInterface) {
2249 float lminvalue = minvalue;
2250 float lmaxvalue = maxvalue;
2251 if (tkMapLog) {
2252 lminvalue = log(minvalue) / log(10);
2253 lmaxvalue = log(maxvalue) / log(10);
2254 }
2255 axis = new TGaxis(3660, 36, 3660, 1530, lminvalue, lmaxvalue, 510, "+L");
2256 axis->SetLabelSize(0.02);
2257 axis->Draw();
2258 }
2259
2260 if (!saveWebInterface) {
2261 TLatex l;
2262 l.SetTextSize(0.05);
2263 std::string fulltitle = title;
2264 if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
2265 fulltitle += ": Log10 scale";
2266 l.DrawLatex(50, 1530, fulltitle.c_str());
2267 }
2268 MyC->Update();
2269 std::cout << "Filetype " << filetype << std::endl;
2270 if (filetype == "png") {
2271 std::string filename = outputfilename + ".png";
2272 MyC->Print(filename.c_str());
2273 }
2274 if (filetype == "jpg") {
2275 std::string filename = outputfilename + ".jpg";
2276 MyC->Print(filename.c_str());
2277 }
2278 if (filetype == "pdf") {
2279 std::string filename = outputfilename + ".pdf";
2280 MyC->Print(filename.c_str());
2281 }
2282 std::string command = "rm " + tempfilename;
2283 command1 = command.c_str();
2284 std::cout << "Executing " << command1 << std::endl;
2285 system(command1);
2286 MyC->Clear();
2287 delete MyC;
2288 if (printflag && !saveWebInterface)
2289 delete axis;
2290 for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
2291 delete (*pos1);
2292 }
2293
2294 }
2295 }
2296 }
2297
2298 void TrackerMap::save_as_psutrackermap(
2299 bool print_total, float minval, float maxval, std::string s, int width, int height) {
2300 if (enableLVProcessing) {
2301 printflag = true;
2302 bool rangefound = true;
2303 std::string filetype = s, outputfilename = s;
2304 std::vector<TPolyLine *> vp;
2305 TGaxis *axis = nullptr;
2306
2307 size_t found = filetype.find_last_of('.');
2308 filetype = filetype.substr(found + 1);
2309 found = outputfilename.find_last_of('.');
2310 outputfilename = outputfilename.substr(0, found);
2311
2312 temporary_file = true;
2313
2314 if (filetype == "xml" || filetype == "svg")
2315 temporary_file = false;
2316
2317 std::ostringstream outs;
2318 minvalue = minval;
2319 maxvalue = maxval;
2320 outs << outputfilename << ".coor";
2321 if (temporary_file)
2322 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2323
2324 std::map<int, TmPsu *>::iterator ipsu;
2325 std::multimap<TmPsu *, TmModule *>::iterator it;
2326 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
2327
2328
2329 bool usePsuValue = false;
2330
2331 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2332 TmPsu *psu = ipsu->second;
2333 if (psu != nullptr) {
2334 if (psu->count > 0 || psu->red != -1) {
2335 usePsuValue = true;
2336 break;
2337 }
2338 }
2339 }
2340
2341 if (!usePsuValue) {
2342 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2343 TmPsu *psu = ipsu->second;
2344 if (psu != nullptr) {
2345 ret = psuModuleMap.equal_range(psu);
2346 int nconn = 0;
2347 for (it = ret.first; it != ret.second; ++it) {
2348 if ((*it).second->count > 0) {
2349 nconn++;
2350 psu->value = psu->value + (*it).second->value;
2351 }
2352 }
2353 if (nconn > 0) {
2354 psu->value = psu->value / psu->nmod;
2355 psu->count = 1;
2356 }
2357 }
2358 }
2359 }
2360
2361 if (title.find("QTestAlarm") != std::string::npos) {
2362 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2363 TmPsu *psu = ipsu->second;
2364 if (psu != nullptr) {
2365 ret = psuModuleMap.equal_range(psu);
2366
2367 psu->red = -1;
2368 int nconn = 0;
2369 for (it = ret.first; it != ret.second; ++it) {
2370 if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
2371 !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
2372 nconn++;
2373 psu->value++;
2374 }
2375 }
2376 if (nconn > 0) {
2377 psu->value = psu->value / psu->nmod;
2378 psu->count = 1;
2379 }
2380 }
2381 }
2382 }
2383
2384 if (!print_total) {
2385 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2386 TmPsu *psu = ipsu->second;
2387 if (psu != nullptr) {
2388 if (usePsuValue)
2389 psu->value = psu->value / psu->count;
2390 }
2391 }
2392 }
2393
2394 if (minvalue >= maxvalue) {
2395 minvalue = 9999999.;
2396 maxvalue = -9999999.;
2397 rangefound = false;
2398 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2399 TmPsu *psu = ipsu->second;
2400 if (psu != nullptr && psu->count > 0) {
2401 rangefound = true;
2402 if (minvalue > psu->value)
2403 minvalue = psu->value;
2404 if (maxvalue < psu->value)
2405 maxvalue = psu->value;
2406 }
2407 }
2408 }
2409 if ((maxvalue == minvalue) || !rangefound)
2410 printflag = false;
2411
2412 if (filetype == "svg") {
2413 saveAsSingleLayer = false;
2414 std::ostringstream outs;
2415 outs << outputfilename << ".svg";
2416 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2417 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
2418 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2419 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
2420 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
2421 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
2422 << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
2423 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
2424 << std::endl;
2425 *savefile << "<svg:g id=\"psutrackermap\" transform=\"translate(10,1500) rotate(270)\" "
2426 "style=\"fill:none;stroke:black;stroke-width:0;\"> "
2427 << std::endl;
2428 }
2429
2430 for (int irack = 1; irack < (npsuracks + 1); irack++) {
2431 if (filetype == "xml") {
2432 saveAsSingleLayer = true;
2433 std::ostringstream outs;
2434 outs << outputfilename << "psurack" << irack << ".xml";
2435 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2436 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
2437 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2438 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
2439 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
2440 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rack.js\" />" << std::endl;
2441 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
2442 "onload=\"TrackerCrate.init()\">"
2443 << std::endl;
2444 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
2445 << std::endl;
2446 *savefile << "<g id=\"rack\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > " << std::endl;
2447 }
2448
2449
2450 defpsuwindow(irack);
2451 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2452 TmPsu *psu = ipsu->second;
2453 if (psu->getPsuRack() == irack) {
2454 drawPsu(irack, psu->getPsuCrate(), print_total, psu, savefile, usePsuValue);
2455 }
2456 }
2457
2458 if (!temporary_file) {
2459 if (filetype == "xml") {
2460 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2461 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2462 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2463 *savefile << " </text> </svg>" << std::endl;
2464 savefile->close();
2465 saveAsSingleLayer = false;
2466 }
2467 }
2468 }
2469 if (filetype == "svg") {
2470 *savefile << "</g> </svg> </svg> " << std::endl;
2471 savefile->close();
2472 }
2473
2474
2475 if (!print_total && !usePsuValue) {
2476 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2477 TmPsu *psu = ipsu->second;
2478 if (psu != nullptr) {
2479 psu->value = psu->value * psu->count;
2480 }
2481 }
2482 }
2483
2484 int rangex = YPSUOFFSET + (YPSURSIZE + YPSUOFFSET) * NUMPSURACK_INROW + 300;
2485 int rangey = XPSUOFFSET + (XPSURSIZE + XPSUOFFSET) * NUMPSURACK_INCOLUMN + 300;
2486
2487 if (temporary_file) {
2488 if (printflag && !saveWebInterface)
2489 drawPalette(savefile, rangex - 140, rangey - 100);
2490 savefile->close();
2491
2492 const char *command1;
2493 std::string tempfilename = outputfilename + ".coor";
2494 int red, green, blue, npoints, colindex, ncolor;
2495 double x[4], y[4];
2496 std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2497 TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2498 gPad->SetFillColor(38);
2499
2500
2501 std::cout << " range x " << rangex << std::endl;
2502 std::cout << " range y " << rangey << std::endl;
2503 gPad->Range(0, 0, rangex, rangey);
2504
2505
2506 ncolor = 0;
2507 typedef std::map<int, int> ColorList;
2508 ColorList colorList;
2509 ColorList::iterator pos;
2510 TColor *col, *c;
2511 while (!tempfile.eof()) {
2512 tempfile >> red >> green >> blue >> npoints;
2513 colindex = red + green * 1000 + blue * 1000000;
2514 pos = colorList.find(colindex);
2515 if (pos == colorList.end()) {
2516 colorList[colindex] = ncolor + 100;
2517 col = gROOT->GetColor(ncolor + 100);
2518 if (col)
2519 col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2520 else
2521 c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2522 vc.push_back(c);
2523 ncolor++;
2524 }
2525 for (int i = 0; i < npoints; i++) {
2526 tempfile >> x[i] >> y[i];
2527 }
2528 }
2529 if (ncolor > 0 && ncolor < 10000) {
2530 Int_t colors[10000];
2531 for (int i = 0; i < ncolor; i++) {
2532 colors[i] = i + 100;
2533 }
2534 gStyle->SetPalette(ncolor, colors);
2535 }
2536 tempfile.clear();
2537 tempfile.seekg(0, std::ios::beg);
2538 std::cout << "created palette with " << ncolor << " colors" << std::endl;
2539 while (!tempfile.eof()) {
2540 tempfile >> red >> green >> blue >> npoints;
2541 for (int i = 0; i < npoints; i++) {
2542 tempfile >> x[i] >> y[i];
2543 }
2544 colindex = red + green * 1000 + blue * 1000000;
2545 pos = colorList.find(colindex);
2546 if (pos != colorList.end()) {
2547 TPolyLine *pline = new TPolyLine(npoints, y, x);
2548 vp.push_back(pline);
2549 pline->SetFillColor(colorList[colindex]);
2550 pline->SetLineWidth(0);
2551 pline->Draw("f");
2552 }
2553 }
2554 if (printflag && !saveWebInterface) {
2555 float lminvalue = minvalue;
2556 float lmaxvalue = maxvalue;
2557 if (tkMapLog) {
2558 lminvalue = log(minvalue) / log(10);
2559 lmaxvalue = log(maxvalue) / log(10);
2560 }
2561 axis = new TGaxis(rangex - 140, 34, rangex - 140, rangey - 106, lminvalue, lmaxvalue, 510, "+L");
2562 axis->SetLabelSize(0.02);
2563 axis->Draw();
2564 }
2565
2566 if (!saveWebInterface) {
2567 TLatex l;
2568 l.SetTextSize(0.05);
2569 std::string fulltitle = title;
2570 if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
2571 fulltitle += ": Log10 scale";
2572 l.DrawLatex(50, rangey - 200, fulltitle.c_str());
2573 }
2574 MyC->Update();
2575 std::cout << "Filetype " << filetype << std::endl;
2576 if (filetype == "png") {
2577 std::string filename = outputfilename + ".png";
2578 MyC->Print(filename.c_str());
2579 }
2580 if (filetype == "jpg") {
2581 std::string filename = outputfilename + ".jpg";
2582 MyC->Print(filename.c_str());
2583 }
2584 if (filetype == "pdf") {
2585 std::string filename = outputfilename + ".pdf";
2586 MyC->Print(filename.c_str());
2587 }
2588 std::string command = "rm " + tempfilename;
2589 command1 = command.c_str();
2590 std::cout << "Executing " << command1 << std::endl;
2591 system(command1);
2592 MyC->Clear();
2593 delete MyC;
2594 if (printflag && !saveWebInterface)
2595 delete axis;
2596 for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
2597 delete (*pos1);
2598 }
2599
2600 }
2601 }
2602 }
2603
2604 void TrackerMap::save_as_fedtrackermap(
2605 bool print_total, float minval, float maxval, std::string s, int width, int height) {
2606 if (enableFedProcessing) {
2607 printflag = true;
2608 bool rangefound = true;
2609 std::string filetype = s, outputfilename = s;
2610 std::vector<TPolyLine *> vp;
2611 TGaxis *axis = nullptr;
2612
2613 size_t found = filetype.find_last_of('.');
2614 filetype = filetype.substr(found + 1);
2615 found = outputfilename.find_last_of('.');
2616 outputfilename = outputfilename.substr(0, found);
2617
2618 temporary_file = true;
2619 if (filetype == "xml" || filetype == "svg")
2620 temporary_file = false;
2621 std::ostringstream outs;
2622 minvalue = minval;
2623 maxvalue = maxval;
2624 outs << outputfilename << ".coor";
2625 if (temporary_file)
2626 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2627 std::map<int, TmApvPair *>::iterator i_apv;
2628 std::map<int, int>::iterator i_fed;
2629
2630 bool useApvPairValue = false;
2631 for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2632 TmApvPair *apvPair = i_apv->second;
2633 if (apvPair != nullptr) {
2634 TmModule *apv_mod = apvPair->mod;
2635 if (apv_mod != nullptr && !apv_mod->notInUse()) {
2636 if (apvPair->count > 0 || apvPair->red != -1) {
2637 useApvPairValue = true;
2638 break;
2639 }
2640 }
2641 }
2642 }
2643 if (!print_total) {
2644 for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2645 TmApvPair *apvPair = i_apv->second;
2646 if (apvPair != nullptr) {
2647 TmModule *apv_mod = apvPair->mod;
2648 if (apv_mod != nullptr && !apv_mod->notInUse()) {
2649 if (useApvPairValue)
2650 apvPair->value = apvPair->value / apvPair->count;
2651 else if (apvPair->mpos == 0 && apv_mod->count > 0)
2652 apv_mod->value = apv_mod->value / apv_mod->count;
2653 }
2654 }
2655 }
2656 }
2657 if (minvalue >= maxvalue) {
2658 minvalue = 9999999.;
2659 maxvalue = -9999999.;
2660 rangefound = false;
2661 for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2662 TmApvPair *apvPair = i_apv->second;
2663 if (apvPair != nullptr) {
2664 TmModule *apv_mod = apvPair->mod;
2665 if (apv_mod != nullptr && !apv_mod->notInUse()) {
2666 if (useApvPairValue) {
2667 rangefound = true;
2668 if (minvalue > apvPair->value)
2669 minvalue = apvPair->value;
2670 if (maxvalue < apvPair->value)
2671 maxvalue = apvPair->value;
2672 } else {
2673 if (apv_mod->count > 0) {
2674 rangefound = true;
2675 if (minvalue > apv_mod->value)
2676 minvalue = apv_mod->value;
2677 if (maxvalue < apv_mod->value)
2678 maxvalue = apv_mod->value;
2679 }
2680 }
2681 }
2682 }
2683 }
2684 }
2685 if ((title.find("QTestAlarm") != std::string::npos) || (maxvalue == minvalue) || !rangefound)
2686 printflag = false;
2687
2688 if (filetype == "svg") {
2689 saveAsSingleLayer = false;
2690 std::ostringstream outs;
2691 outs << outputfilename << ".svg";
2692 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2693 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
2694 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2695 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
2696 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
2697 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
2698 << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
2699 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
2700 << std::endl;
2701 *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" "
2702 "style=\"fill:none;stroke:black;stroke-width:0;\"> "
2703 << std::endl;
2704 }
2705 for (int crate = firstcrate; crate < (ncrates + 1); crate++) {
2706 if (filetype == "xml") {
2707 saveAsSingleLayer = true;
2708 std::ostringstream outs;
2709 outs << outputfilename << "crate" << crate << ".xml";
2710 savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2711 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
2712 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2713 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
2714 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
2715 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"crate.js\" />" << std::endl;
2716 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
2717 "onload=\"TrackerCrate.init()\">"
2718 << std::endl;
2719 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
2720 << std::endl;
2721 *savefile << "<g id=\"crate\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > " << std::endl;
2722 }
2723
2724 defcwindow(crate);
2725 int numfed_incrate = 0;
2726 for (i_fed = fedMap.begin(); i_fed != fedMap.end(); i_fed++) {
2727 if (i_fed->second == crate) {
2728 int fedId = i_fed->first;
2729
2730 numfed_incrate = slotMap[fedId];
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746 for (int nconn = 0; nconn < 96; nconn++) {
2747 int key = fedId * 1000 + nconn;
2748 TmApvPair *apvPair = apvMap[key];
2749 if (apvPair != nullptr) {
2750 TmModule *apv_mod = apvPair->mod;
2751 if (apv_mod != nullptr && !apv_mod->notInUse()) {
2752 drawApvPair(crate, numfed_incrate, print_total, apvPair, savefile, useApvPairValue);
2753 }
2754 }
2755 }
2756 }
2757 }
2758 if (!temporary_file) {
2759 if (filetype == "xml") {
2760 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2761 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2762 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2763 *savefile << " </text> </svg>" << std::endl;
2764 savefile->close();
2765 delete savefile;
2766 saveAsSingleLayer = false;
2767 }
2768 }
2769 }
2770 if (filetype == "svg") {
2771 *savefile << "</g> </svg> </svg> " << std::endl;
2772 savefile->close();
2773 delete savefile;
2774 }
2775 if (!print_total && !useApvPairValue) {
2776
2777 for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2778 TmApvPair *apvPair = i_apv->second;
2779 if (apvPair != nullptr) {
2780 TmModule *apv_mod = apvPair->mod;
2781 if (apv_mod != nullptr && apvPair->mpos == 0 && !apv_mod->notInUse()) {
2782 apv_mod->value = apv_mod->value * apv_mod->count;
2783 }
2784 }
2785 }
2786 }
2787
2788 int rangex = YFEDOFFSET + (YFEDCSIZE + YFEDOFFSET) * NUMFEDCRATE_INROW + 300;
2789 int rangey = XFEDOFFSET + (XFEDCSIZE + XFEDOFFSET) * NUMFEDCRATE_INCOLUMN + 300;
2790
2791 if (temporary_file) {
2792 if (printflag && !saveWebInterface)
2793 drawPalette(savefile, rangex - 140, rangey - 100);
2794 savefile->close();
2795 delete savefile;
2796
2797 const char *command1;
2798 std::string tempfilename = outputfilename + ".coor";
2799 int red, green, blue, npoints, colindex, ncolor;
2800 double x[4], y[4];
2801 std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2802 TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2803 gPad->SetFillColor(38);
2804
2805
2806 std::cout << " range x " << rangex << std::endl;
2807 std::cout << " range y " << rangey << std::endl;
2808 gPad->Range(0, 0, rangex, rangey);
2809
2810
2811 ncolor = 0;
2812 typedef std::map<int, int> ColorList;
2813 ColorList colorList;
2814 ColorList::iterator pos;
2815 TColor *col, *c;
2816 while (!tempfile.eof()) {
2817 tempfile >> red >> green >> blue >> npoints;
2818 colindex = red + green * 1000 + blue * 1000000;
2819 pos = colorList.find(colindex);
2820 if (pos == colorList.end()) {
2821 colorList[colindex] = ncolor + 100;
2822 col = gROOT->GetColor(ncolor + 100);
2823 if (col)
2824 col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2825 else
2826 c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2827 vc.push_back(c);
2828 ncolor++;
2829 }
2830 for (int i = 0; i < npoints; i++) {
2831 tempfile >> x[i] >> y[i];
2832 }
2833 }
2834 if (ncolor > 0 && ncolor < 10000) {
2835 Int_t colors[10000];
2836 for (int i = 0; i < ncolor; i++) {
2837 colors[i] = i + 100;
2838 }
2839 gStyle->SetPalette(ncolor, colors);
2840 }
2841 tempfile.clear();
2842 tempfile.seekg(0, std::ios::beg);
2843 std::cout << "created palette with " << ncolor << " colors" << std::endl;
2844 while (!tempfile.eof()) {
2845 tempfile >> red >> green >> blue >> npoints;
2846 for (int i = 0; i < npoints; i++) {
2847 tempfile >> x[i] >> y[i];
2848 }
2849 colindex = red + green * 1000 + blue * 1000000;
2850 pos = colorList.find(colindex);
2851 if (pos != colorList.end()) {
2852 TPolyLine *pline = new TPolyLine(npoints, y, x);
2853 vp.push_back(pline);
2854 pline->SetFillColor(colorList[colindex]);
2855 pline->SetLineWidth(0);
2856 pline->Draw("f");
2857 }
2858 }
2859 if (printflag && !saveWebInterface) {
2860 float lminvalue = minvalue;
2861 float lmaxvalue = maxvalue;
2862 if (tkMapLog) {
2863 lminvalue = log(minvalue) / log(10);
2864 lmaxvalue = log(maxvalue) / log(10);
2865 }
2866 axis = new TGaxis(rangex - 140, 34, rangex - 140, rangey - 106, lminvalue, lmaxvalue, 510, "+L");
2867 axis->SetLabelSize(0.02);
2868 axis->Draw();
2869 }
2870
2871 if (!saveWebInterface) {
2872 TLatex l;
2873 l.SetTextSize(0.05);
2874 std::string fulltitle = title;
2875 if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
2876 fulltitle += ": Log10 scale";
2877 l.DrawLatex(50, rangey - 200, fulltitle.c_str());
2878 }
2879 MyC->Update();
2880 std::cout << "Filetype " << filetype << std::endl;
2881 if (filetype == "png") {
2882 std::string filename = outputfilename + ".png";
2883 MyC->Print(filename.c_str());
2884 }
2885 if (filetype == "jpg") {
2886 std::string filename = outputfilename + ".jpg";
2887 MyC->Print(filename.c_str());
2888 }
2889 if (filetype == "pdf") {
2890 std::string filename = outputfilename + ".pdf";
2891 MyC->Print(filename.c_str());
2892 }
2893 std::string command = "rm " + tempfilename;
2894 command1 = command.c_str();
2895 std::cout << "Executing " << command1 << std::endl;
2896 system(command1);
2897 MyC->Clear();
2898 delete MyC;
2899 if (printflag && !saveWebInterface)
2900 delete axis;
2901 for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
2902 delete (*pos1);
2903 }
2904
2905 }
2906 }
2907 }
2908
2909 void TrackerMap::load(std::string inputfilename) {
2910 inputfile = new std::ifstream(inputfilename.c_str(), std::ios::in);
2911 std::string line, value;
2912 int ipos, ipos1, ipos2, id = 0, val = 0;
2913 int nline = 0;
2914 while (getline(*inputfile, line)) {
2915 ipos1 = line.find("value=\"");
2916 if (ipos1 > 0) {
2917 value = line.substr(ipos1 + 7, 10);
2918 ipos = value.find('\"');
2919 value = value.substr(0, ipos);
2920 val = atoi(value.c_str());
2921 }
2922 ipos2 = line.find("detid=\"");
2923 if (ipos2 > 0) {
2924 value = line.substr(ipos2 + 7, 10);
2925 ipos = value.find('\"');
2926 value = value.substr(0, ipos);
2927 id = atoi(value.c_str());
2928 }
2929 if (ipos1 > 0 && ipos2 > 0 && val > 0)
2930 this->fill(id, val);
2931 if (ipos1 > 0 && ipos2 > 0)
2932 nline++;
2933
2934 }
2935 std::cout << nline << " modules found in this svg file " << std::endl;
2936 inputfile->close();
2937 delete inputfile;
2938 }
2939
2940
2941
2942
2943 void TrackerMap::print(bool print_total, float minval, float maxval, std::string outputfilename) {
2944 temporary_file = false;
2945 std::ostringstream outs;
2946 minvalue = minval;
2947 maxvalue = maxval;
2948 outs << outputfilename << ".xml";
2949 svgfile = new std::ofstream(outs.str().c_str(), std::ios::out);
2950 jsfile = new std::ifstream(edm::FileInPath(jsfilename).fullPath().c_str(), std::ios::in);
2951
2952
2953 std::string line;
2954 while (getline(*jsfile, line)) {
2955 *svgfile << line << std::endl;
2956 }
2957 jsfile->close();
2958 delete jsfile;
2959
2960 if (!print_total) {
2961 for (int layer = 1; layer < 44; layer++) {
2962 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
2963 for (int module = 1; module < 200; module++) {
2964 int key = layer * 100000 + ring * 1000 + module;
2965 TmModule *mod = smoduleMap[key];
2966 if (mod != nullptr && !mod->notInUse()) {
2967 mod->value = mod->value / mod->count;
2968 }
2969 }
2970 }
2971 }
2972 }
2973 if (minvalue >= maxvalue) {
2974 minvalue = 9999999.;
2975 maxvalue = -9999999.;
2976 for (int layer = 1; layer < 44; layer++) {
2977 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
2978 for (int module = 1; module < 200; module++) {
2979 int key = layer * 100000 + ring * 1000 + module;
2980 TmModule *mod = smoduleMap[key];
2981 if (mod != nullptr && !mod->notInUse()) {
2982 if (minvalue > mod->value)
2983 minvalue = mod->value;
2984 if (maxvalue < mod->value)
2985 maxvalue = mod->value;
2986 }
2987 }
2988 }
2989 }
2990 }
2991 for (int layer = 1; layer < 44; layer++) {
2992
2993 defwindow(layer);
2994 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
2995 for (int module = 1; module < 200; module++) {
2996 int key = layer * 100000 + ring * 1000 + module;
2997 TmModule *mod = smoduleMap[key];
2998 if (mod != nullptr && !mod->notInUse()) {
2999 drawModule(mod, key, layer, print_total, svgfile);
3000 }
3001 }
3002 }
3003 }
3004 *svgfile << "</svg:g></svg:svg>" << std::endl;
3005 *svgfile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">" << title << "</svg:text>" << std::endl;
3006 if (printflag)
3007 drawPalette(svgfile);
3008 *svgfile << "</svg:svg>" << std::endl;
3009 *svgfile << "</body></html>" << std::endl;
3010 svgfile->close();
3011 delete svgfile;
3012 }
3013
3014 void TrackerMap::drawPalette(std::ofstream *svgfile, int xoffset, int yoffset) {
3015 std::cout << "preparing the palette" << std::endl;
3016 int color, red, green, blue;
3017 float val = minvalue;
3018 int paletteLength = 250;
3019 int width = 50 * (yoffset - 40) / 1500;
3020 float dval = (maxvalue - minvalue) / (float)paletteLength;
3021 bool rtkMapLog = tkMapLog;
3022 if (tkMapLog)
3023 tkMapLog = false;
3024 float step = float(yoffset - 40) / float(paletteLength);
3025 for (int i = 1; i < paletteLength + 1; i++) {
3026 color = getcolor(val, palette);
3027 red = (color >> 16) & 0xFF;
3028 green = (color >> 8) & 0xFF;
3029 blue = (color)&0xFF;
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040 if (!temporary_file)
3041 *svgfile << "<svg:rect x=\"3610\" y=\"" << (1550 - 6 * i) << "\" width=\"50\" height=\"6\" fill=\"rgb(" << red
3042 << "," << green << "," << blue << ")\" />\n";
3043 else
3044 *svgfile << red << " " << green << " " << blue << " 4 " << int(step * i) + 34 << " " << xoffset - width << ". "
3045 <<
3046 int(step * i) + 34 << " " << xoffset << ". " <<
3047 int(step * (i - 1)) + 34 << " " << xoffset << ". " <<
3048 int(step * (i - 1)) + 34 << " " << xoffset - width << ". " << std::endl;
3049
3050 if (i % 50 == 0) {
3051 if (!temporary_file)
3052 *svgfile << "<svg:rect x=\"3610\" y=\"" << (1550 - 6 * i)
3053 << "\" width=\"50\" height=\"1\" fill=\"black\" />\n";
3054 if (i % 50 == 0 && !temporary_file)
3055 *svgfile << " <svg:text class=\"normalText\" x=\"3660\" y=\"" << (1560 - 6 * i) << "\">" << val
3056 << "</svg:text>" << std::endl;
3057 }
3058 val = val + dval;
3059 }
3060 tkMapLog = rtkMapLog;
3061 }
3062 void TrackerMap::fillc_fed_channel(int fedId, int fedCh, int red, int green, int blue) {
3063 int key = fedId * 1000 + fedCh;
3064 TmApvPair *apvpair = apvMap[key];
3065
3066 if (apvpair != nullptr) {
3067 apvpair->red = red;
3068 apvpair->green = green;
3069 apvpair->blue = blue;
3070 return;
3071 }
3072 std::cout << "*** error in FedTrackerMap fillc method ***";
3073 }
3074
3075 void TrackerMap::fill_fed_channel(int idmod, float qty) {
3076 std::multimap<const int, TmApvPair *>::iterator pos;
3077 for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
3078 TmApvPair *apvpair = pos->second;
3079 if (apvpair != nullptr) {
3080 apvpair->value = apvpair->value + qty;
3081 apvpair->count++;
3082 }
3083 }
3084 return;
3085 std::cout << "*** error in FedTrackerMap fill by module method ***";
3086 }
3087
3088 void TrackerMap::fill_current_val_fed_channel(int fedId, int fedCh, float current_val) {
3089 int key = fedId * 1000 + fedCh;
3090 TmApvPair *apvpair = apvMap[key];
3091
3092 if (apvpair != nullptr) {
3093 apvpair->value = current_val;
3094 apvpair->count = 1;
3095 apvpair->red = -1;
3096 } else
3097 std::cout << "*** error in FedTrackerMap fill_current_val method ***";
3098 }
3099
3100 void TrackerMap::fillc_fec_channel(int crate, int slot, int ring, int addr, int red, int green, int blue) {
3101 int key = crate * 10000000 + slot * 100000 + ring * 1000 + addr;
3102
3103 TmCcu *ccu = ccuMap[key];
3104
3105 if (ccu != nullptr) {
3106 ccu->red = red;
3107 ccu->green = green;
3108 ccu->blue = blue;
3109 return;
3110 }
3111 std::cout << "*** error in FecTrackerMap fillc method ***";
3112 }
3113
3114 void TrackerMap::fill_fec_channel(int crate, int slot, int ring, int addr, float qty) {
3115 int key = crate * 10000000 + slot * 100000 + ring * 1000 + addr;
3116 TmCcu *ccu = ccuMap[key];
3117 if (ccu != nullptr) {
3118 ccu->count++;
3119 ccu->value = ccu->value + qty;
3120 return;
3121 }
3122
3123 std::cout << "*** error in FecTrackerMap fill by module method ***";
3124 }
3125
3126 void TrackerMap::fillc_lv_channel(int rack, int crate, int board, int red, int green, int blue) {
3127 int key = rack * 1000 + crate * 100 + board;
3128
3129 TmPsu *psu = psuMap[key];
3130
3131 if (psu != nullptr) {
3132 psu->red = red;
3133 psu->green = green;
3134 psu->blue = blue;
3135 return;
3136 }
3137 std::cout << "*** error in LVTrackerMap fillc method ***";
3138 }
3139
3140 void TrackerMap::fill_lv_channel(int rack, int crate, int board, float qty) {
3141 int key = rack * 1000 + crate * 100 + board;
3142 TmPsu *psu = psuMap[key];
3143 if (psu != nullptr) {
3144 psu->count++;
3145 psu->value = psu->value + qty;
3146 return;
3147 }
3148
3149 std::cout << "*** error in LVTrackerMap fill by module method ***";
3150 }
3151
3152 void TrackerMap::fillc_hv_channel2(int rack, int crate, int board, int red, int green, int blue) {
3153 int key = rack * 1000 + crate * 100 + board;
3154
3155 TmPsu *psu = psuMap[key];
3156
3157 if (psu != nullptr) {
3158 psu->redHV2 = red;
3159 psu->greenHV2 = green;
3160 psu->blueHV2 = blue;
3161 return;
3162 }
3163 std::cout << "*** error in HVTrackerMap (channel 2) fillc method ***";
3164 }
3165 void TrackerMap::fillc_hv_channel3(int rack, int crate, int board, int red, int green, int blue) {
3166 int key = rack * 1000 + crate * 100 + board;
3167
3168 TmPsu *psu = psuMap[key];
3169
3170 if (psu != nullptr) {
3171 psu->redHV3 = red;
3172 psu->greenHV3 = green;
3173 psu->blueHV3 = blue;
3174 return;
3175 }
3176 std::cout << "*** error in HVTrackerMap (channel 3) fillc method ***";
3177 }
3178
3179 void TrackerMap::fill_hv_channel2(int rack, int crate, int board, float qty) {
3180 int key = rack * 1000 + crate * 100 + board;
3181 TmPsu *psu = psuMap[key];
3182 if (psu != nullptr) {
3183 psu->countHV2++;
3184 psu->valueHV2 = psu->valueHV2 + qty;
3185 return;
3186 }
3187
3188 std::cout << "*** error in HVTrackerMap fill by module method ***";
3189 }
3190 void TrackerMap::fill_hv_channel3(int rack, int crate, int board, float qty) {
3191 int key = rack * 1000 + crate * 100 + board;
3192 TmPsu *psu = psuMap[key];
3193 if (psu != nullptr) {
3194 psu->countHV3++;
3195 psu->valueHV3 = psu->valueHV3 + qty;
3196 return;
3197 }
3198
3199 std::cout << "*** error in HVTrackerMap fill by module method ***";
3200 }
3201
3202 int TrackerMap::module(int fedId, int fedCh) {
3203 int key = fedId * 1000 + fedCh;
3204 TmApvPair *apvpair = apvMap[key];
3205 if (apvpair != nullptr) {
3206 return (apvpair->mod->idex);
3207 }
3208 return (0);
3209 std::cout << "*** error in FedTrackerMap module method ***";
3210 }
3211 void TrackerMap::fill_fed_channel(int fedId, int fedCh, float qty) {
3212 int key = fedId * 1000 + fedCh;
3213 TmApvPair *apvpair = apvMap[key];
3214 if (apvpair != nullptr) {
3215 apvpair->value = apvpair->value + qty;
3216 apvpair->count++;
3217 return;
3218 }
3219 std::cout << "*** error inFedTrackerMap fill method ***";
3220 }
3221
3222 void TrackerMap::fillc(int idmod, int red, int green, int blue) {
3223 TmModule *mod = imoduleMap[idmod];
3224 if (mod != nullptr) {
3225 mod->red = red;
3226 mod->green = green;
3227 mod->blue = blue;
3228 return;
3229 }
3230 std::cout << "**************************error in fill method **************module " << idmod << std::endl;
3231 }
3232 void TrackerMap::fillc(int layer, int ring, int nmod, int red, int green, int blue) {
3233 int key = layer * 10000 + ring * 1000 + nmod;
3234 TmModule *mod = smoduleMap[key];
3235
3236 if (mod != nullptr) {
3237 mod->red = red;
3238 mod->green = green;
3239 mod->blue = blue;
3240 return;
3241 }
3242 std::cout << "**************************error in fill method **************" << std::endl;
3243 }
3244
3245 void TrackerMap::fillc_all_blank() {
3246 std::map<const int, TmModule *>::iterator imod;
3247 for (imod = imoduleMap.begin(); imod != imoduleMap.end(); imod++) {
3248 fillc(imod->first, 255, 255, 255);
3249 }
3250 }
3251
3252 void TrackerMap::fill_all_blank() {
3253 std::map<const int, TmModule *>::iterator imod;
3254 for (imod = imoduleMap.begin(); imod != imoduleMap.end(); imod++) {
3255 fill_current_val(imod->first, 0);
3256 }
3257 }
3258
3259 void TrackerMap::fill_current_val(int idmod, float current_val) {
3260 TmModule *mod = imoduleMap[idmod];
3261 if (mod != nullptr) {
3262 mod->value = current_val;
3263 mod->count = 1;
3264 mod->red = -1;
3265 } else
3266 std::cout << "**error in fill_current_val method ***module " << idmod << std::endl;
3267 }
3268
3269 void TrackerMap::fill(int idmod, float qty) {
3270 TmModule *mod = imoduleMap[idmod];
3271 if (mod != nullptr) {
3272 mod->value = mod->value + qty;
3273 mod->count++;
3274 return;
3275 } else {
3276 TmModule *mod1 = imoduleMap[idmod + 1];
3277 TmModule *mod2 = imoduleMap[idmod + 2];
3278 if (mod1 != nullptr && mod2 != nullptr) {
3279 mod1->value = mod1->value + qty;
3280 mod1->count++;
3281 mod2->value = mod2->value + qty;
3282 mod2->count++;
3283 return;
3284 }
3285 }
3286 std::cout << "**************************error in fill method **************module " << idmod << std::endl;
3287 }
3288
3289 void TrackerMap::fill(int layer, int ring, int nmod, float qty) {
3290 int key = layer * 100000 + ring * 1000 + nmod;
3291 TmModule *mod = smoduleMap[key];
3292 if (mod != nullptr) {
3293 mod->value = mod->value + qty;
3294 mod->count++;
3295 } else
3296 std::cout << "**************************error in SvgModuleMap **************";
3297 }
3298
3299 void TrackerMap::setText(int idmod, std::string s) {
3300 TmModule *mod = imoduleMap[idmod];
3301 if (mod != nullptr) {
3302 mod->text = s;
3303 } else
3304 std::cout << "**************************error in IdModuleMap **************";
3305 }
3306
3307 void TrackerMap::setText(int layer, int ring, int nmod, std::string s) {
3308 int key = layer * 100000 + ring * 1000 + nmod;
3309 TmModule *mod = smoduleMap[key];
3310 if (mod != nullptr) {
3311 mod->text = s;
3312 } else
3313 std::cout << "**************************error in SvgModuleMap **************";
3314 }
3315
3316 void TrackerMap::build() {
3317
3318
3319 int nmods, pix_sil, fow_bar, ring, nmod, layer;
3320 unsigned int idex;
3321 float posx, posy, posz, length, width, thickness, widthAtHalfLength;
3322 int iModule = 0, old_layer = 0, ntotMod = 0;
3323 std::string name, dummys;
3324 std::ifstream infile(edm::FileInPath(infilename).fullPath().c_str(), std::ios::in);
3325 while (!infile.eof()) {
3326 infile >> nmods >> pix_sil >> fow_bar >> layer >> ring >> nmod >> posx >> posy >> posz >> length >> width >>
3327 thickness >> widthAtHalfLength >> idex;
3328 getline(infile, dummys);
3329 getline(infile, name);
3330 if (old_layer != layer) {
3331 old_layer = layer;
3332 iModule = 0;
3333 }
3334 iModule++;
3335 ntotMod++;
3336 int key = layer * 100000 + ring * 1000 + nmod;
3337 TmModule *mod = smoduleMap[key];
3338
3339 imoduleMap[idex] = mod;
3340
3341 if (mod == nullptr)
3342 std::cout << "error in module " << key << std::endl;
3343 else {
3344 mod->posx = posx;
3345 mod->posy = posy;
3346 mod->setUsed();
3347 mod->value = 0;
3348 mod->count = 0;
3349 mod->posz = posz;
3350 mod->length = length;
3351 mod->width = width;
3352 mod->thickness = thickness;
3353 mod->widthAtHalfLength = widthAtHalfLength;
3354 mod->idex = idex;
3355 mod->name = name;
3356 }
3357 }
3358 infile.close();
3359 number_modules = ntotMod - 1;
3360 }
3361 int TrackerMap::getcolor(float value, int palette) {
3362 int red, green, blue;
3363 float lminvalue, lmaxvalue;
3364 lminvalue = minvalue;
3365 lmaxvalue = maxvalue;
3366 if (tkMapLog) {
3367 lminvalue = log(minvalue) / log(10);
3368 lmaxvalue = log(maxvalue) / log(10);
3369 value = log(value) / log(10);
3370 }
3371
3372 red = 0;
3373 green = 0;
3374 blue = 0;
3375 if (palette == 1) {
3376 float delta = (lmaxvalue - lminvalue);
3377 float x = (value - lminvalue);
3378 if (value < lminvalue) {
3379 red = 0;
3380 green = 0;
3381 blue = 255;
3382 }
3383 if (value > lmaxvalue) {
3384 red = 255;
3385 green = 0;
3386 blue = 0;
3387 }
3388 if (value >= lminvalue && value <= lmaxvalue) {
3389 red = (int)(x < (delta / 2) ? 0 : (x > ((3. / 4.) * delta) ? 255 : 255 / (delta / 4) * (x - (2. / 4.) * delta)));
3390 green =
3391 (int)(x < delta / 4 ? (x * 255 / (delta / 4))
3392 : (x > ((3. / 4.) * delta) ? 255 - 255 / (delta / 4) * (x - (3. / 4.) * delta) : 255));
3393 blue = (int)(x < delta / 4 ? 255
3394 : (x > ((1. / 2.) * delta) ? 0 : 255 - 255 / (delta / 4) * (x - (1. / 4.) * delta)));
3395 }
3396 }
3397 if (palette == 2) {
3398 green = (int)((value - lminvalue) / (lmaxvalue - lminvalue) * 256.);
3399 if (green > 255)
3400 green = 255;
3401 red = 255;
3402 blue = 0;
3403 green = 255 - green;
3404 }
3405
3406 return (blue | (green << 8) | (red << 16));
3407 }
3408 void TrackerMap::printonline() {
3409
3410 std::ofstream *ofilename;
3411 std::ifstream *ifilename;
3412 std::ostringstream ofname;
3413 std::string ifname;
3414 std::string command;
3415 std::string line;
3416 std::string outputfilename = "dqmtmap";
3417 ifilename = findfile("viewerHeader.xhtml");
3418 ofname << outputfilename << "viewer.html";
3419 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3420 while (getline(*ifilename, line)) {
3421 *ofilename << line << std::endl;
3422 }
3423 *ofilename << " var tmapname=\"" << outputfilename << "\"" << std::endl;
3424 *ofilename << " var tmaptitle=\"" << title << "\"" << std::endl;
3425 *ofilename << " var ncrates=" << ncrates << ";" << std::endl;
3426 *ofilename << " var nfeccrates=" << nfeccrates << ";" << std::endl;
3427 *ofilename << " var npsuracks=" << npsuracks << ";" << std::endl;
3428
3429 ifilename->close();
3430 delete ifilename;
3431
3432 ifilename = findfile("viewerTrailer.xhtml");
3433 while (getline(*ifilename, line)) {
3434 *ofilename << line << std::endl;
3435 }
3436 ofilename->close();
3437 delete ofilename;
3438 command = "sed -i \"s/XtmapnameX/" + outputfilename + "/g\" " + ofname.str();
3439 std::cout << "Executing " << command << std::endl;
3440 system(command.c_str());
3441 command = "sed -i \"s/XtmaptitleX/" + title + "/g\" " + ofname.str();
3442 std::cout << "Executing " << command << std::endl;
3443 system(command.c_str());
3444 ofname.str("");
3445 ifilename->close();
3446 delete ifilename;
3447
3448 ifilename = findfile("jqviewer.js");
3449 ofname << "jqviewer.js";
3450 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3451 while (getline(*ifilename, line)) {
3452 *ofilename << line << std::endl;
3453 }
3454 ofname.str("");
3455 ofilename->close();
3456 delete ofilename;
3457 ifilename->close();
3458 delete ifilename;
3459
3460 ifilename = findfile("crate.js");
3461 ofname << "crate.js";
3462 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3463 while (getline(*ifilename, line)) {
3464 *ofilename << line << std::endl;
3465 }
3466 ofname.str("");
3467 ofilename->close();
3468 delete ofilename;
3469 ifilename->close();
3470 delete ifilename;
3471
3472 ifilename = findfile("feccrate.js");
3473 ofname << "feccrate.js";
3474 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3475 while (getline(*ifilename, line)) {
3476 *ofilename << line << std::endl;
3477 }
3478 ofname.str("");
3479 ofilename->close();
3480 delete ofilename;
3481 ifilename->close();
3482 delete ifilename;
3483
3484 ifilename = findfile("layer.js");
3485 ofname << "layer.js";
3486 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3487 while (getline(*ifilename, line)) {
3488 *ofilename << line << std::endl;
3489 }
3490 ofname.str("");
3491 ofilename->close();
3492 delete ofilename;
3493 ifilename->close();
3494 delete ifilename;
3495
3496 ifilename = findfile("rack.js");
3497 ofname << "rack.js";
3498 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3499 while (getline(*ifilename, line)) {
3500 *ofilename << line << std::endl;
3501 }
3502 ofname.str("");
3503 ofilename->close();
3504 delete ofilename;
3505 ifilename->close();
3506 delete ifilename;
3507 ofname.str("");
3508
3509 ifilename = findfile("rackhv.js");
3510 ofname << "rackhv.js";
3511 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3512 while (getline(*ifilename, line)) {
3513 *ofilename << line << std::endl;
3514 }
3515 ofname.str("");
3516 ofilename->close();
3517 delete ofilename;
3518 ifilename->close();
3519 delete ifilename;
3520
3521 std::ostringstream outs, outs1, outs2;
3522 outs << outputfilename << ".png";
3523 save(true, gminvalue, gmaxvalue, outs.str(), 3000, 1600);
3524 temporary_file = false;
3525 printlayers(true, gminvalue, gmaxvalue, outputfilename);
3526
3527
3528 std::ofstream *txtfile;
3529 for (int layer = 1; layer < 44; layer++) {
3530 std::ostringstream outs;
3531 outs << outputfilename << "layer" << layer << ".html";
3532 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3533 *txtfile << "<html><head></head> <body>" << std::endl;
3534 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
3535 for (int module = 1; module < 200; module++) {
3536 int key = layer * 100000 + ring * 1000 + module;
3537 TmModule *mod = smoduleMap[key];
3538 if (mod != nullptr && !mod->notInUse()) {
3539 int idmod = mod->idex;
3540 int nchan = 0;
3541 *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3542 std::multimap<const int, TmApvPair *>::iterator pos;
3543 for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
3544 TmApvPair *apvpair = pos->second;
3545 if (apvpair != nullptr) {
3546 nchan++;
3547 *txtfile << apvpair->text << std::endl;
3548 }
3549 }
3550 *txtfile << "</pre><h3>" << mod->name << "</h3>" << std::endl;
3551 }
3552 }
3553 }
3554 *txtfile << "</body></html>" << std::endl;
3555 txtfile->close();
3556 delete txtfile;
3557 }
3558 if (enableFedProcessing) {
3559 outs1 << outputfilename << "fed.png";
3560 save_as_fedtrackermap(true, gminvalue, gmaxvalue, outs1.str(), 6000, 3200);
3561 outs2 << outputfilename << ".xml";
3562 save_as_fedtrackermap(true, gminvalue, gmaxvalue, outs2.str(), 3000, 1600);
3563
3564 std::map<int, int>::iterator i_fed;
3565 std::ofstream *txtfile;
3566 for (int crate = firstcrate; crate < (ncrates + 1); crate++) {
3567 std::ostringstream outs;
3568 outs << outputfilename << "crate" << crate << ".html";
3569 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3570 *txtfile << "<html><head></head> <body>" << std::endl;
3571 for (i_fed = fedMap.begin(); i_fed != fedMap.end(); i_fed++) {
3572 if (i_fed->second == crate) {
3573 int fedId = i_fed->first;
3574 for (int nconn = 0; nconn < 96; nconn++) {
3575 int key = fedId * 1000 + nconn;
3576 TmApvPair *apvPair = apvMap[key];
3577 if (apvPair != nullptr) {
3578 int idmod = apvPair->idex;
3579 *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3580 *txtfile << apvPair->text << std::endl;
3581 std::ostringstream outs;
3582 outs << "fedchannel " << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connects to module "
3583 << apvPair->mod->idex;
3584 *txtfile << "</pre><h3>" << outs.str() << "</h3>" << std::endl;
3585 }
3586 }
3587 }
3588 }
3589 *txtfile << "</body></html>" << std::endl;
3590 txtfile->close();
3591 delete txtfile;
3592 }
3593 }
3594 if (enableFecProcessing) {
3595 std::ostringstream outs1, outs2;
3596 outs1 << outputfilename << "fec.png";
3597 save_as_fectrackermap(true, gminvalue, gmaxvalue, outs1.str(), 6000, 3200);
3598 outs2 << outputfilename << ".xml";
3599 save_as_fectrackermap(true, gminvalue, gmaxvalue, outs2.str(), 3000, 1600);
3600
3601 std::ofstream *txtfile;
3602 std::map<int, TmCcu *>::iterator i_ccu;
3603 std::multimap<TmCcu *, TmModule *>::iterator it;
3604 std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
3605 for (int crate = 1; crate < (nfeccrates + 1); crate++) {
3606 std::ostringstream outs;
3607 outs << outputfilename << "feccrate" << crate << ".html";
3608 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3609 *txtfile << "<html><head></head> <body>" << std::endl;
3610 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
3611 TmCcu *ccu = i_ccu->second;
3612 if (ccu != nullptr && ccu->getCcuCrate() == crate) {
3613 int idmod = ccu->idex;
3614 *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3615 *txtfile << ccu->text << std::endl;
3616 std::ostringstream outs;
3617 if (ccu->nmod == 0)
3618 outs << "ccu is in position" << ccu->mpos << "in ring but doesn't seem to have any module connected";
3619 else {
3620 outs << "ccu is in position " << ccu->mpos << " in ring and connects " << ccu->nmod << " modules"
3621 << std::endl;
3622 ret = fecModuleMap.equal_range(ccu);
3623 for (it = ret.first; it != ret.second; ++it) {
3624 outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << "\n\n";
3625 }
3626
3627 *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
3628 }
3629 }
3630 }
3631 *txtfile << "</body></html>" << std::endl;
3632 txtfile->close();
3633 delete txtfile;
3634 }
3635 }
3636 if (enableLVProcessing) {
3637 std::ostringstream outs3, outs4;
3638 outs3 << outputfilename << "psu.png";
3639 save_as_psutrackermap(true, gminvalue, gmaxvalue, outs3.str(), 6000, 3200);
3640
3641 outs4 << outputfilename << ".xml";
3642 save_as_psutrackermap(true, gminvalue, gmaxvalue, outs4.str(), 3000, 1600);
3643
3644
3645 std::ofstream *txtfile;
3646 std::map<int, TmPsu *>::iterator ipsu;
3647 std::multimap<TmPsu *, TmModule *>::iterator it;
3648 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
3649 for (int rack = 1; rack < (npsuracks + 1); rack++) {
3650 std::ostringstream outs;
3651
3652 outs << outputfilename << "psurack" << rack << ".html";
3653 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3654 *txtfile << "<html><head></head> <body>" << std::endl;
3655 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
3656 TmPsu *psu = ipsu->second;
3657 if (psu != nullptr && psu->getPsuRack() == rack) {
3658 *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
3659 *txtfile << psu->text << std::endl;
3660 std::ostringstream outs;
3661 if (psu->nmod == 0)
3662 outs << "Ps is in position" << psu->getPsuBoard()
3663 << "in crate but doesn't seem to have any module connected";
3664 else {
3665 outs << "PS is in position " << psu->getPsuBoard() << " in crate and connects to " << psu->nmod
3666 << " modules. " << std::endl;
3667
3668 ret = psuModuleMap.equal_range(psu);
3669 for (it = ret.first; it != ret.second; ++it) {
3670 outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << " <br>"
3671 << std::endl;
3672 }
3673 *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
3674 }
3675 }
3676 }
3677 *txtfile << "</body></html>" << std::endl;
3678 txtfile->close();
3679 delete txtfile;
3680 }
3681 }
3682
3683 if (enableHVProcessing) {
3684 std::ostringstream outs5, outs6;
3685 outs5 << outputfilename << "hv.png";
3686 save_as_HVtrackermap(true, gminvalue, gmaxvalue, outs5.str(), 6000, 3200);
3687
3688 outs6 << outputfilename << ".xml";
3689 save_as_HVtrackermap(true, gminvalue, gmaxvalue, outs6.str(), 3000, 1600);
3690
3691
3692 std::ofstream *txtfile;
3693 std::map<int, TmPsu *>::iterator ipsu;
3694 std::multimap<TmPsu *, TmModule *>::iterator it;
3695 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
3696 for (int rack = 1; rack < (npsuracks + 1); rack++) {
3697 std::ostringstream outs;
3698
3699 outs << outputfilename << "HVrack" << rack << ".html";
3700 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3701 *txtfile << "<html><head></head> <body>" << std::endl;
3702 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
3703 TmPsu *psu = ipsu->second;
3704 if (psu != nullptr && psu->getPsuRack() == rack) {
3705 *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
3706 *txtfile << psu->textHV2 << std::endl;
3707 std::ostringstream outsHV2;
3708 if (psu->nmodHV2 == 0)
3709 outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()
3710 << "in crate but doesn't seem to have any module connected";
3711 else {
3712 outsHV2 << "HV Channel002 is in position " << psu->getPsuBoard() << " in crate and connects to "
3713 << psu->nmodHV2 << " modules. "
3714 << " <br>" << std::endl;
3715
3716 ret = psuModuleMap.equal_range(psu);
3717 for (it = ret.first; it != ret.second; ++it) {
3718 if ((*it).second->HVchannel == 2) {
3719 outsHV2 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
3720 << " <br>" << std::endl;
3721 }
3722 }
3723 *txtfile << "</pre><h4>" << outsHV2.str() << "</h4>" << std::endl;
3724 }
3725
3726 *txtfile << psu->textHV3 << std::endl;
3727 std::ostringstream outsHV3;
3728 if (psu->nmodHV3 == 0)
3729 outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()
3730 << "in crate but doesn't seem to have any module connected";
3731 else {
3732 outsHV3 << "HV Channel003 is in position " << psu->getPsuBoard() << " in crate and connects to "
3733 << psu->nmodHV3 << " modules. "
3734 << " <br>" << std::endl;
3735
3736 ret = psuModuleMap.equal_range(psu);
3737 for (it = ret.first; it != ret.second; ++it) {
3738 if ((*it).second->HVchannel == 3) {
3739 outsHV3 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
3740 << " <br>" << std::endl;
3741 }
3742 }
3743 *txtfile << "</pre><h4>" << outsHV3.str() << "</h4>" << std::endl;
3744 }
3745 }
3746 }
3747 *txtfile << "</body></html>" << std::endl;
3748 txtfile->close();
3749 delete txtfile;
3750 }
3751 }
3752 }
3753 void TrackerMap::printall(bool print_total, float minval1, float maxval1, std::string s, int width, int height) {
3754
3755 float minval, maxval;
3756 minval = minval1;
3757 maxval = maxval1;
3758 if (tkMapLog && (minval < maxval)) {
3759 minval = pow(10., minval1);
3760 maxval = pow(10., maxval1);
3761 }
3762 std::string filetype = s, outputfilename = s;
3763 if (saveWebInterface) {
3764 width = 6000;
3765 height = 3200;
3766 } else {
3767 size_t found = filetype.find_last_of('.');
3768 filetype = filetype.substr(found + 1);
3769 found = outputfilename.find_last_of('.');
3770 outputfilename = outputfilename.substr(0, found);
3771 }
3772 std::ofstream *ofilename;
3773 std::ifstream *ifilename;
3774 std::ostringstream ofname;
3775 std::string ifname;
3776 std::string line;
3777 std::string command;
3778 if (saveWebInterface) {
3779 ifilename = findfile("viewerHeader.xhtml");
3780 ofname << outputfilename << "viewer.html";
3781 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3782 while (getline(*ifilename, line)) {
3783 *ofilename << line << std::endl;
3784 }
3785 *ofilename << " var tmapname=\"" << outputfilename << "\"" << std::endl;
3786 *ofilename << " var tmaptitle=\"" << title << "\"" << std::endl;
3787 *ofilename << " var ncrates=" << ncrates << ";" << std::endl;
3788 *ofilename << " var nfeccrates=" << nfeccrates << ";" << std::endl;
3789 *ofilename << " var npsuracks=" << npsuracks << ";" << std::endl;
3790 ifilename->close();
3791 delete ifilename;
3792 ifilename = findfile("viewerTrailer.xhtml");
3793 while (getline(*ifilename, line)) {
3794 *ofilename << line << std::endl;
3795 }
3796 ofilename->close();
3797 delete ofilename;
3798 ifilename->close();
3799 delete ifilename;
3800 command = "sed -i \"s/XtmapnameX/" + outputfilename + "/g\" " + ofname.str();
3801 std::cout << "Executing " << command << std::endl;
3802 system(command.c_str());
3803 command = "sed -i \"s/XtmaptitleX/" + title + "/g\" " + ofname.str();
3804 std::cout << "Executing " << command << std::endl;
3805 system(command.c_str());
3806 ofname.str("");
3807
3808 ifilename = findfile("jqviewer.js");
3809 ofname << "jqviewer.js";
3810 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3811 while (getline(*ifilename, line)) {
3812 *ofilename << line << std::endl;
3813 }
3814 ofilename->close();
3815 delete ofilename;
3816 ifilename->close();
3817 delete ifilename;
3818
3819 ofname.str("");
3820 ifilename = findfile("crate.js");
3821 ofname << "crate.js";
3822 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3823 while (getline(*ifilename, line)) {
3824 *ofilename << line << std::endl;
3825 }
3826 ofilename->close();
3827 delete ofilename;
3828 ifilename->close();
3829 delete ifilename;
3830
3831 ofname.str("");
3832 ifilename = findfile("feccrate.js");
3833 ofname << "feccrate.js";
3834 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3835 while (getline(*ifilename, line)) {
3836 *ofilename << line << std::endl;
3837 }
3838 ofilename->close();
3839 delete ofilename;
3840 ifilename->close();
3841 delete ifilename;
3842
3843 ofname.str("");
3844 ifilename = findfile("rack.js");
3845 ofname << "rack.js";
3846 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3847 while (getline(*ifilename, line)) {
3848 *ofilename << line << std::endl;
3849 }
3850 ofilename->close();
3851 delete ofilename;
3852 ifilename->close();
3853 delete ifilename;
3854
3855 ofname.str("");
3856 ifilename = findfile("rackhv.js");
3857 ofname << "rackhv.js";
3858 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3859 while (getline(*ifilename, line)) {
3860 *ofilename << line << std::endl;
3861 }
3862 ofilename->close();
3863 delete ofilename;
3864 ifilename->close();
3865 delete ifilename;
3866
3867 ofname.str("");
3868 ifilename = findfile("layer.js");
3869 ofname << "layer.js";
3870 ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3871 while (getline(*ifilename, line)) {
3872 *ofilename << line << std::endl;
3873 }
3874 ofilename->close();
3875 delete ofilename;
3876 ifilename->close();
3877 delete ifilename;
3878
3879 command = "scp -r ../../DQM/TrackerCommon/test/jquery/ .";
3880 std::cout << "Executing " << command << std::endl;
3881 system(command.c_str());
3882 command = "scp -r ../../CommonTools/TrackerMap/data/images/ .";
3883 std::cout << "Executing " << command << std::endl;
3884 system(command.c_str());
3885 }
3886
3887 std::ostringstream outs;
3888 outs << outputfilename << ".png";
3889 if (saveWebInterface)
3890 save(true, minval, maxval, outs.str(), 3000, 1600);
3891 else {
3892 if (saveGeoTrackerMap)
3893 save(true, minval, maxval, s, width, height);
3894 }
3895 if (saveWebInterface) {
3896 std::ostringstream outs;
3897 outs << outputfilename << ".png";
3898 temporary_file = false;
3899 printlayers(true, minval, maxval, outputfilename);
3900
3901
3902 std::ofstream *txtfile;
3903 for (int layer = 1; layer < 44; layer++) {
3904 std::ostringstream outs;
3905 outs << outputfilename << "layer" << layer << ".html";
3906 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3907 *txtfile << "<html><head></head> <body>" << std::endl;
3908 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
3909 for (int module = 1; module < 200; module++) {
3910 int key = layer * 100000 + ring * 1000 + module;
3911 TmModule *mod = smoduleMap[key];
3912 if (mod != nullptr && !mod->notInUse()) {
3913 int idmod = mod->idex;
3914 int nchan = 0;
3915 *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3916 std::multimap<const int, TmApvPair *>::iterator pos;
3917 for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
3918 TmApvPair *apvpair = pos->second;
3919 if (apvpair != nullptr) {
3920 nchan++;
3921 *txtfile << apvpair->text << std::endl;
3922 }
3923 }
3924 *txtfile << "</pre><h3>" << mod->name << "</h3>" << std::endl;
3925 }
3926 }
3927 }
3928 *txtfile << "</body></html>" << std::endl;
3929 txtfile->close();
3930 delete txtfile;
3931 }
3932 }
3933 if (enableFedProcessing) {
3934 std::ostringstream outs1, outs2;
3935 if (saveWebInterface)
3936 outs1 << outputfilename << "fed.png";
3937 else
3938 outs1 << outputfilename << "fed." << filetype;
3939 save_as_fedtrackermap(true, 0., 0., outs1.str(), width, height);
3940 if (saveWebInterface) {
3941 outs2 << outputfilename << ".xml";
3942 save_as_fedtrackermap(true, 0., 0., outs2.str(), 3000, 1600);
3943
3944 std::map<int, int>::iterator i_fed;
3945 std::ofstream *txtfile;
3946 for (int crate = firstcrate; crate < (ncrates + 1); crate++) {
3947 std::ostringstream outs;
3948 outs << outputfilename << "crate" << crate << ".html";
3949 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3950 *txtfile << "<html><head></head> <body>" << std::endl;
3951 for (i_fed = fedMap.begin(); i_fed != fedMap.end(); i_fed++) {
3952 if (i_fed->second == crate) {
3953 int fedId = i_fed->first;
3954 for (int nconn = 0; nconn < 96; nconn++) {
3955 int key = fedId * 1000 + nconn;
3956 TmApvPair *apvPair = apvMap[key];
3957 if (apvPair != nullptr) {
3958 int idmod = apvPair->idex;
3959 *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3960 *txtfile << apvPair->text << std::endl;
3961 std::ostringstream outs;
3962 outs << "fedchannel " << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connects to module "
3963 << apvPair->mod->idex;
3964 *txtfile << "</pre><h3>" << outs.str() << "</h3>" << std::endl;
3965 }
3966 }
3967 }
3968 }
3969 *txtfile << "</body></html>" << std::endl;
3970 txtfile->close();
3971 delete txtfile;
3972 }
3973 }
3974 }
3975 if (enableFecProcessing) {
3976 std::ostringstream outs1, outs2;
3977 if (saveWebInterface)
3978 outs1 << outputfilename << "fec.png";
3979 else
3980 outs1 << outputfilename << "fec." << filetype;
3981 save_as_fectrackermap(true, 0., 0., outs1.str(), width, height);
3982 if (saveWebInterface) {
3983 outs2 << outputfilename << ".xml";
3984 save_as_fectrackermap(true, 0., 0., outs2.str(), 3000, 1600);
3985
3986 std::ofstream *txtfile;
3987 std::map<int, TmCcu *>::iterator i_ccu;
3988 std::multimap<TmCcu *, TmModule *>::iterator it;
3989 std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
3990 for (int crate = 1; crate < (nfeccrates + 1); crate++) {
3991 std::ostringstream outs;
3992 outs << outputfilename << "feccrate" << crate << ".html";
3993 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3994 *txtfile << "<html><head></head> <body>" << std::endl;
3995 for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
3996 TmCcu *ccu = i_ccu->second;
3997 if (ccu != nullptr && ccu->getCcuCrate() == crate) {
3998 int idmod = ccu->idex;
3999 *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
4000 *txtfile << ccu->text << std::endl;
4001 std::ostringstream outs;
4002 if (ccu->nmod == 0)
4003 outs << "ccu is in position" << ccu->mpos << "in ring but doesn't seem to have any module connected";
4004 else {
4005 outs << "ccu is in position " << ccu->mpos << " in ring and connects " << ccu->nmod << " modules"
4006 << std::endl;
4007 ret = fecModuleMap.equal_range(ccu);
4008 for (it = ret.first; it != ret.second; ++it) {
4009 outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << "\n\n";
4010 }
4011
4012 *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
4013 }
4014 }
4015 }
4016 *txtfile << "</body></html>" << std::endl;
4017 txtfile->close();
4018 }
4019 }
4020 }
4021 if (enableLVProcessing) {
4022 std::ostringstream outs3, outs4;
4023 if (saveWebInterface)
4024 outs3 << outputfilename << "psu.png";
4025 else
4026 outs3 << outputfilename << "psu." << filetype;
4027 save_as_psutrackermap(true, 0., 0., outs3.str(), width, height);
4028 if (saveWebInterface) {
4029 outs4 << outputfilename << ".xml";
4030 save_as_psutrackermap(true, 0., 0., outs4.str(), 3000, 1600);
4031
4032
4033 std::ofstream *txtfile;
4034 std::map<int, TmPsu *>::iterator ipsu;
4035 std::multimap<TmPsu *, TmModule *>::iterator it;
4036 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
4037 for (int rack = 1; rack < (npsuracks + 1); rack++) {
4038 std::ostringstream outs;
4039
4040 outs << outputfilename << "psurack" << rack << ".html";
4041 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4042 *txtfile << "<html><head></head> <body>" << std::endl;
4043 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
4044 TmPsu *psu = ipsu->second;
4045 if (psu != nullptr && psu->getPsuRack() == rack) {
4046 *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
4047 *txtfile << psu->text << std::endl;
4048 std::ostringstream outs;
4049 if (psu->nmod == 0)
4050 outs << "Ps is in position" << psu->getPsuBoard()
4051 << "in crate but doesn't seem to have any module connected";
4052 else {
4053 outs << "PS is in position " << psu->getPsuBoard() << " in crate and connects to " << psu->nmod
4054 << " modules. " << std::endl;
4055
4056 ret = psuModuleMap.equal_range(psu);
4057 for (it = ret.first; it != ret.second; ++it) {
4058 outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << " <br>"
4059 << std::endl;
4060 }
4061 *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
4062 }
4063 }
4064 }
4065 *txtfile << "</body></html>" << std::endl;
4066 txtfile->close();
4067 }
4068 }
4069 }
4070
4071 if (enableHVProcessing) {
4072 std::ostringstream outs5, outs6;
4073 if (saveWebInterface)
4074 outs5 << outputfilename << "hv.png";
4075 else
4076 outs5 << outputfilename << "hv." << filetype;
4077 save_as_HVtrackermap(true, 0., 0., outs5.str(), width, height);
4078 if (saveWebInterface) {
4079 outs6 << outputfilename << ".xml";
4080 save_as_HVtrackermap(true, 0., 0., outs6.str(), 3000, 1600);
4081
4082
4083 std::ofstream *txtfile;
4084 std::map<int, TmPsu *>::iterator ipsu;
4085 std::multimap<TmPsu *, TmModule *>::iterator it;
4086 std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
4087 for (int rack = 1; rack < (npsuracks + 1); rack++) {
4088 std::ostringstream outs;
4089
4090 outs << outputfilename << "HVrack" << rack << ".html";
4091 txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4092 *txtfile << "<html><head></head> <body>" << std::endl;
4093 for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
4094 TmPsu *psu = ipsu->second;
4095 if (psu != nullptr && psu->getPsuRack() == rack) {
4096 *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
4097 *txtfile << psu->textHV2 << std::endl;
4098 std::ostringstream outsHV2;
4099 if (psu->nmodHV2 == 0)
4100 outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()
4101 << "in crate but doesn't seem to have any module connected";
4102 else {
4103 outsHV2 << "HV Channel002 is in position " << psu->getPsuBoard() << " in crate and connects to "
4104 << psu->nmodHV2 << " modules. "
4105 << " <br>" << std::endl;
4106
4107 ret = psuModuleMap.equal_range(psu);
4108 for (it = ret.first; it != ret.second; ++it) {
4109 if ((*it).second->HVchannel == 2) {
4110 outsHV2 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
4111 << " <br>" << std::endl;
4112 }
4113 }
4114 *txtfile << "</pre><h4>" << outsHV2.str() << "</h4>" << std::endl;
4115 }
4116
4117 *txtfile << psu->textHV3 << std::endl;
4118 std::ostringstream outsHV3;
4119 if (psu->nmodHV3 == 0)
4120 outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()
4121 << "in crate but doesn't seem to have any module connected";
4122 else {
4123 outsHV3 << "HV Channel003 is in position " << psu->getPsuBoard() << " in crate and connects to "
4124 << psu->nmodHV3 << " modules. "
4125 << " <br>" << std::endl;
4126
4127 ret = psuModuleMap.equal_range(psu);
4128 for (it = ret.first; it != ret.second; ++it) {
4129 if ((*it).second->HVchannel == 3) {
4130 outsHV3 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
4131 << " <br>" << std::endl;
4132 }
4133 }
4134 *txtfile << "</pre><h4>" << outsHV3.str() << "</h4>" << std::endl;
4135 }
4136 }
4137 }
4138 *txtfile << "</body></html>" << std::endl;
4139 txtfile->close();
4140 }
4141 }
4142 }
4143 }
4144
4145 std::ifstream *TrackerMap::findfile(std::string filename) {
4146 std::ifstream *ifilename;
4147 std::string ifname;
4148 if (!jsPath.empty()) {
4149 ifname = jsPath + filename;
4150 ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(), std::ios::in);
4151 if (!ifilename) {
4152 ifname = "CommonTools/TrackerMap/data/" + filename;
4153 ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(), std::ios::in);
4154 }
4155 } else {
4156 ifname = "CommonTools/TrackerMap/data/" + filename;
4157 ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(), std::ios::in);
4158 }
4159 if (!ifilename)
4160 std::cout << "File " << filename << " missing" << std::endl;
4161 return ifilename;
4162 }
4163 void TrackerMap::printlayers(bool print_total, float minval, float maxval, std::string outputfilename) {
4164 std::ofstream *xmlfile;
4165 saveAsSingleLayer = true;
4166 if (!print_total) {
4167 for (int layer = 1; layer < 44; layer++) {
4168 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4169 for (int module = 1; module < 200; module++) {
4170 int key = layer * 100000 + ring * 1000 + module;
4171 TmModule *mod = smoduleMap[key];
4172 if (mod != nullptr && !mod->notInUse()) {
4173 mod->value = mod->value / mod->count;
4174 }
4175 }
4176 }
4177 }
4178 }
4179 if (minvalue >= maxvalue) {
4180 minvalue = 9999999.;
4181 maxvalue = -9999999.;
4182 for (int layer = 1; layer < 44; layer++) {
4183 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4184 for (int module = 1; module < 200; module++) {
4185 int key = layer * 100000 + ring * 1000 + module;
4186 TmModule *mod = smoduleMap[key];
4187 if (mod != nullptr && !mod->notInUse()) {
4188 if (minvalue > mod->value)
4189 minvalue = mod->value;
4190 if (maxvalue < mod->value)
4191 maxvalue = mod->value;
4192 }
4193 }
4194 }
4195 }
4196 }
4197 for (int layer = 1; layer < 44; layer++) {
4198 std::ostringstream outs;
4199 outs << outputfilename << "layer" << layer << ".xml";
4200 xmlfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4201 *xmlfile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
4202 *xmlfile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
4203 *xmlfile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
4204 *xmlfile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
4205 *xmlfile << "<script type=\"text/ecmascript\" xlink:href=\"layer.js\" />" << std::endl;
4206 *xmlfile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
4207 "onload=\"TrackerLayer.init()\">"
4208 << std::endl;
4209 if (layer < 31)
4210 *xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,1.)\" > " << std::endl;
4211 else
4212 *xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,0.8)\" > " << std::endl;
4213 *xmlfile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />" << std::endl;
4214 *xmlfile << "<svg:polygon id=\"fed\" mapAttribute=\"fed\" points=\"250,40 250,10 230,10 230,40\" "
4215 "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4216 "fill=\"rgb(0,127,255)\"/>"
4217 << std::endl;
4218 *xmlfile << "<svg:polygon id=\"fec\" mapAttribute=\"fec\" points=\"228,40 228,10 208,10 208,40\" "
4219 "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4220 "fill=\"rgb(0,127,255)\"/>"
4221 << std::endl;
4222 *xmlfile << "<svg:polygon id=\"lv\" mapAttribute=\"lv\" points=\"206,40 206,10 186,10 186,40\" "
4223 "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4224 "fill=\"rgb(0,127,255)\"/>"
4225 << std::endl;
4226 *xmlfile << "<svg:polygon id=\"hv\" mapAttribute=\"hv\" points=\"184,40 184,10 164,10 164,40\" "
4227 "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4228 "fill=\"rgb(0,127,255)\"/>"
4229 << std::endl;
4230 *xmlfile << "<svg:polygon id=\"plot\" mapAttribute=\"plot\" points=\"155,45 155,5 135,5 135,45\" "
4231 "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4232 "fill=\"rgb(200,0,0)\"/>"
4233 << std::endl;
4234
4235
4236 defwindow(layer);
4237 for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4238 for (int module = 1; module < 200; module++) {
4239 int key = layer * 100000 + ring * 1000 + module;
4240 TmModule *mod = smoduleMap[key];
4241 if (mod != nullptr && !mod->notInUse()) {
4242 drawModule(mod, key, layer, print_total, xmlfile);
4243 }
4244 }
4245 }
4246 *xmlfile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\">" << std::endl;
4247 *xmlfile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
4248 *xmlfile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
4249 *xmlfile << "<tspan id=\"line3\" x=\"40\" y=\"90\"> </tspan> " << std::endl;
4250 *xmlfile << "<tspan id=\"line4\" x=\"40\" y=\"120\"> </tspan> " << std::endl;
4251 if (layer > 33) {
4252 *xmlfile << "<tspan mapAttribute=\"fed\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4253 "onmouseout=\"chooseMap(evt);\" x=\"15\" y=\"228\" font-size=\"12\" font-family=\"arial\" "
4254 "fill=\"white\">FED</tspan> "
4255 << std::endl;
4256 *xmlfile << "<tspan mapAttribute=\"fec\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4257 "onmouseout=\"chooseMap(evt);\" x=\"15\" y=\"258\" font-size=\"12\" font-family=\"arial\" "
4258 "fill=\"white\">FEC</tspan> "
4259 << std::endl;
4260 *xmlfile << "<tspan mapAttribute=\"lv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4261 "onmouseout=\"chooseMap(evt);\" x=\"18\" y=\"289\" font-size=\"12\" font-family=\"arial\" "
4262 "fill=\"white\">LV</tspan> "
4263 << std::endl;
4264 *xmlfile << "<tspan mapAttribute=\"hv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4265 "onmouseout=\"chooseMap(evt);\" x=\"18\" y=\"319\" font-size=\"12\" font-family=\"arial\" "
4266 "fill=\"white\">HV</tspan> "
4267 << std::endl;
4268 *xmlfile << "<tspan mapAttribute=\"plot\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4269 "onmouseout=\"chooseMap(evt);\" x=\"12\" y=\"360\" font-size=\"12\" font-family=\"arial\" "
4270 "fill=\"white\">PLOT</tspan> "
4271 << std::endl;
4272 } else {
4273 *xmlfile << "<tspan mapAttribute=\"fed\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4274 "onmouseout=\"chooseMap(evt);\" x=\"21\" y=\"228\" font-size=\"12\" font-family=\"arial\" "
4275 "fill=\"white\">FED</tspan> "
4276 << std::endl;
4277 *xmlfile << "<tspan mapAttribute=\"fec\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4278 "onmouseout=\"chooseMap(evt);\" x=\"21\" y=\"258\" font-size=\"12\" font-family=\"arial\" "
4279 "fill=\"white\">FEC</tspan> "
4280 << std::endl;
4281 *xmlfile << "<tspan mapAttribute=\"lv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4282 "onmouseout=\"chooseMap(evt);\" x=\"24\" y=\"289\" font-size=\"12\" font-family=\"arial\" "
4283 "fill=\"white\">LV</tspan> "
4284 << std::endl;
4285 *xmlfile << "<tspan mapAttribute=\"hv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4286 "onmouseout=\"chooseMap(evt);\" x=\"24\" y=\"319\" font-size=\"12\" font-family=\"arial\" "
4287 "fill=\"white\">HV</tspan> "
4288 << std::endl;
4289 *xmlfile << "<tspan mapAttribute=\"plot\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4290 "onmouseout=\"chooseMap(evt);\" x=\"17\" y=\"360\" font-size=\"12\" font-family=\"arial\" "
4291 "fill=\"white\">PLOT</tspan> "
4292 << std::endl;
4293 }
4294 *xmlfile << " </text> </svg>" << std::endl;
4295 xmlfile->close();
4296 delete xmlfile;
4297 }
4298 saveAsSingleLayer = false;
4299 }
4300
4301 TLegend *TrackerMap::buildLegend() {
4302 if (legInfos_.empty()) {
4303 legInfos_.reserve(8);
4304
4305 legInfos_.push_back(new TPolyLine(0));
4306 legInfos_.back()->SetFillColor(kGreen);
4307 legInfos_.push_back(new TPolyLine(0));
4308 legInfos_.back()->SetFillColor(kBlue - 9);
4309 legInfos_.push_back(new TPolyLine(0));
4310 legInfos_.back()->SetFillColor(kRed + 2);
4311 legInfos_.push_back(new TPolyLine(0));
4312 legInfos_.back()->SetFillColor(kPink - 9);
4313 legInfos_.push_back(new TPolyLine(0));
4314 legInfos_.back()->SetFillColor(kOrange + 2);
4315 legInfos_.push_back(new TPolyLine(0));
4316 legInfos_.back()->SetFillColor(kYellow);
4317 legInfos_.push_back(new TPolyLine(0));
4318 legInfos_.back()->SetFillColor(kRed + 1);
4319 legInfos_.push_back(new TPolyLine(0));
4320 legInfos_.back()->SetFillColor(kViolet - 5);
4321 legKeys_ = {"Good Modules",
4322 "Excluded FED",
4323 "FED errors",
4324 "# Clusters",
4325 "# Digis",
4326 "PCL bad",
4327 "# Clusters & Digis",
4328 "DCS Error"};
4329 }
4330
4331 TLegend *myL = new TLegend(0.56, 0.87, 0.95, 0.99);
4332 myL->SetNColumns(2);
4333 myL->SetBorderSize(0);
4334 myL->SetFillColor(38);
4335 for (unsigned int i = 0; i < legInfos_.size(); i++) {
4336 myL->AddEntry((TObject *)legInfos_[i], legKeys_[i].c_str(), "f");
4337 }
4338
4339 return myL;
4340 }