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