CMS 3D CMS Logo

TrackerMap.cc
Go to the documentation of this file.
12 #include <fstream>
13 #include <vector>
14 #include <iostream>
15 #include <sstream>
16 #include "TCanvas.h"
17 #include "TPolyLine.h"
18 #include "TStyle.h"
19 #include "TColor.h"
20 #include "TROOT.h"
21 #include "TGaxis.h"
22 #include "TLatex.h"
23 #include "TArrow.h"
24 #include "TLegend.h"
25 #include "TH1F.h"
26 #include "TH2Poly.h"
27 #include "TGraph.h"
28 #include "TPaletteAxis.h"
29 
30 /**********************************************************
31 Allocate all the modules in a map of TmModule
32 The filling of the values for each module is done later
33 when the user starts to fill it.
34 **********************************************************/
35 
37  const SiStripFedCabling *tkFed,
38  const TrackerTopology *const topology) {
39  psetAvailable = true;
40  xsize = 340;
41  ysize = 200;
42 
43  title = " ";
44  jsPath = "";
45  jsfilename = "CommonTools/TrackerMap/data/trackermap.txt";
46  infilename = "CommonTools/TrackerMap/data/tracker.dat";
47  saveAsSingleLayer = false;
48  tkMapLog = false;
49  // if(tkmapPset.exists("trackermaptxtPath")){
50  jsPath = tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath", "CommonTools/TrackerMap/data/");
51  jsfilename = jsPath + "trackermap.txt";
52  std::cout << jsfilename << std::endl;
53  infilename =
54  tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "CommonTools/TrackerMap/data/") + "tracker.dat";
55  std::cout << infilename << std::endl;
56  saveWebInterface = tkmapPset.getUntrackedParameter<bool>("saveWebInterface", false);
57  saveGeoTrackerMap = tkmapPset.getUntrackedParameter<bool>("saveGeoTrackerMap", true);
58  ncrates = 0;
59  firstcrate = 0;
60  enableFedProcessing = tkmapPset.getUntrackedParameter<bool>("loadFedCabling", false);
61  if (tkFed == nullptr && enableFedProcessing) {
62  enableFedProcessing = false;
63  std::cout << "ERROR:fed trackermap requested but no valid fedCabling is available!!!" << std::endl;
64  }
65  nfeccrates = 0;
66  enableFecProcessing = tkmapPset.getUntrackedParameter<bool>("loadFecCabling", false);
67  if (tkFed == nullptr && enableFecProcessing) {
68  enableFecProcessing = false;
69  std::cout << "ERROR:fec trackermap requested but no valid fedCabling is available!!!" << std::endl;
70  }
71  // std::cout << "loadFecCabling " << enableFecProcessing << std::endl;
72  npsuracks = 0;
73  enableLVProcessing = tkmapPset.getUntrackedParameter<bool>("loadLVCabling", false);
74  // std::cout << "loadLVCabling " << enableLVProcessing << std::endl;
75  enableHVProcessing = tkmapPset.getUntrackedParameter<bool>("loadHVCabling", false);
76  // std::cout << "loadHVCabling " << enableHVProcessing << std::endl;
77  tkMapLog = tkmapPset.getUntrackedParameter<bool>("logScale", false);
78  // } else std::cout << "no parameters found" << std::endl;
79 
80  init();
81  // Now load fed cabling information
82  if (enableFedProcessing) {
83  auto feds = tkFed->fedIds();
84  std::cout << "SiStripFedCabling has " << feds.size() << " active FEDS" << std::endl;
85  // int num_board=0;
86  // int num_crate=0;
87  for (std::vector<unsigned short>::const_iterator ifed = feds.begin(); ifed < feds.end(); ifed++) {
88  auto theconn = tkFed->fedConnections(*ifed);
89  int num_conn = 0;
90  for (auto iconn = theconn.begin(); iconn < theconn.end(); iconn++) {
91  if (iconn->fedId() == sistrip::invalid_ || iconn->detId() == sistrip::invalid_ ||
92  iconn->detId() == sistrip::invalid32_ || iconn->apvPairNumber() == sistrip::invalid_ ||
93  iconn->nApvPairs() == sistrip::invalid_) {
94  continue;
95  }
96 
97  TmModule *imod = imoduleMap[iconn->detId()];
98  int key = iconn->fedId() * 1000 + iconn->fedCh();
99  TmApvPair *apvpair = apvMap[key];
100  if (apvpair != nullptr)
101  std::cout << "Fed " << iconn->fedId() << " channel " << iconn->fedCh() << " seem to be already loaded!"
102  << std::endl;
103  else {
104  num_conn++;
105  if (num_conn == 1) {
106  // if(fedMap[iconn->fedId()]==0){num_crate=num_board/18+1;fedMap[iconn->fedId()]=num_crate;num_board++;}
107  if (fedMap[iconn->fedId()] == 0) {
108  fedMap[iconn->fedId()] = iconn->fedCrate();
109  }
110  if (slotMap[iconn->fedId()] == 0) {
111  slotMap[iconn->fedId()] = iconn->fedSlot();
112  }
113  if (ncrates == 0 || ncrates < iconn->fedCrate())
114  ncrates = iconn->fedCrate();
115  if (firstcrate == 0 || firstcrate > iconn->fedCrate())
116  firstcrate = iconn->fedCrate();
117  }
118 
119  // apvpair = new TmApvPair(key,num_crate);
120  apvpair = new TmApvPair(key, iconn->fedCrate());
121  apvpair->mod = imod;
122  apvpair->mpos = iconn->apvPairNumber();
123  apvMap[key] = apvpair;
124  apvModuleMap.insert(std::make_pair(iconn->detId(), apvpair));
125  std::stringstream s;
126  iconn->print(s);
127  apvpair->text = s.str();
128  }
129  }
130  }
131  // ncrates=num_crate;
132  std::cout << "from " << firstcrate << " to " << ncrates << " crates used " << std::endl;
133  //Now add APv information to module name
134  std::map<int, TmModule *>::iterator i_mod;
135  for (i_mod = imoduleMap.begin(); i_mod != imoduleMap.end(); i_mod++) {
136  TmModule *mod = i_mod->second;
137  if (mod != nullptr) {
138  std::ostringstream outs, outs1;
139  outs << " connected to ";
140  outs1 << "(";
141 
142  int idmod = mod->idex;
143  int nchan = 0;
144  std::multimap<const int, TmApvPair *>::iterator pos;
145  for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
146  TmApvPair *apvpair = pos->second;
147  if (apvpair != nullptr) {
148  outs << apvpair->mpos << " " << apvpair->getFedId() << "/" << apvpair->getFedCh() << " ";
149  outs1 << apvpair->idex + apvpair->crate * 1000000 << ",";
150  nchan++;
151  }
152  }
153  outs << "(" << nchan << ")";
154  mod->name = mod->name + outs.str();
155  std::string s = outs1.str();
156  s.erase(s.end() - 1, s.end());
157  mod->capvids = s + ")";
158  }
159  }
160  }
161  // Now load fec cabling information
162  if (enableFecProcessing) {
163  int nccu;
164  int nmod;
165  int crate, slot, ring, addr, pos;
166  SiStripFecCabling *fecCabling_;
167  fecCabling_ = new SiStripFecCabling(*tkFed);
168  std::string Ccufilename = tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "") + "cculist.txt";
169  std::ifstream Ccufile(edm::FileInPath(Ccufilename).fullPath().c_str(), std::ios::in);
170  std::string dummys;
171  while (!Ccufile.eof()) {
172  Ccufile >> crate >> slot >> ring >> addr >> pos;
173  getline(Ccufile, dummys);
174  int key = crate * 10000000 + slot * 100000 + ring * 1000 + addr;
175  TmCcu *ccu = ccuMap[key];
176  if (ccu == nullptr) {
177  ccu = new TmCcu(crate, slot, ring, addr);
178  ccu->mpos = pos, ccuMap[key] = ccu;
179  }
180  }
181 
182  for (std::vector<SiStripFecCrate>::const_iterator icrate = fecCabling_->crates().begin();
183  icrate != fecCabling_->crates().end();
184  icrate++) {
185  for (std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end();
186  ifec++) {
187  for (std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end();
188  iring++) {
189  nccu = 0;
190  for (std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end();
191  iccu++) {
192  nccu++;
193  nmod = 0;
194  int key =
195  icrate->fecCrate() * 10000000 + ifec->fecSlot() * 100000 + iring->fecRing() * 1000 + iccu->ccuAddr();
196  int layer = 0;
197  TmCcu *ccu = ccuMap[key];
198  for (std::vector<SiStripModule>::const_iterator imod = iccu->modules().begin();
199  imod != iccu->modules().end();
200  imod++) {
201  nmod++;
202  TmModule *imod1 = imoduleMap[imod->detId()];
203  layer = imod1->layer;
204  fecModuleMap.insert(std::make_pair(ccu, imod1));
205  if (imod1 != nullptr)
206  imod1->CcuId = key; //imod1->ccuId=key+Crate*1000000
207  }
208  if (ccu == nullptr)
209  std::cout << key << " This ccu seems to have not been stored! " << std::endl;
210  else {
211  ccu->nmod = nmod;
212  ccu->layer = layer;
213  }
214  }
215  }
216  }
217  }
218 
219  std::map<int, TmCcu *>::iterator i_ccu;
220  std::multimap<TmCcu *, TmModule *>::iterator it;
221  std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
222  nccu = 0;
223  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
224  TmCcu *ccu = i_ccu->second;
225  nccu++;
226  if (ccu != nullptr) {
227  std::ostringstream outs;
228  std::ostringstream outs1;
229  outs << "CCU " << ccu->idex << " connected to fec,ring " << ccu->getCcuSlot() << "," << ccu->getCcuRing()
230  << " in crate " << ccu->getCcuCrate() << " at position " << ccu->mpos << " with " << ccu->nmod
231  << " modules: ";
232  outs1 << "(";
233  ret = fecModuleMap.equal_range(ccu);
234  for (it = ret.first; it != ret.second; ++it) {
235  outs << (*it).second->idex << " ";
236  outs1 << (*it).second->getKey() << ",";
237  }
238  outs1 << ")";
239  ccu->text = outs.str();
240  ccu->cmodid = outs1.str();
241  //std::cout << ccu->text << std::endl;
242  }
243  }
244  nfeccrates = 4;
245  std::cout << nccu << " ccu stored in " << nfeccrates << " crates" << std::endl;
246 
247  delete fecCabling_;
248  }
249  //load Psu cabling info
250  //load Psu cabling info
252  SiStripDetCabling *detCabling = nullptr;
254  detCabling = new SiStripDetCabling(*tkFed, topology);
255 
256  int npsu = 0;
257  int nmod, nmodHV2, nmodHV3;
258  int modId1, dcuId; // ,modId2;
259  int dcs, branch, crate, board;
260  int rack = 0;
261  std::string channelstr1;
262  short int channel;
263  std::string psinfo;
264  std::string psIdinfo;
265  int rack_order[54] = {0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0,
266  11, 12, 0, 13, 14, 0, 15, 0, 0, 0, 0, 0, 0, 16, 0, 17, 18, 0,
267  19, 20, 0, 21, 0, 22, 0, 23, 0, 24, 25, 0, 26, 27, 0, 28, 0, 29};
268  // std::ifstream *LVfile;
269  // std::ifstream *HVfile;
270 
271  std::string LVfilename =
272  tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "CommonTools/TrackerMap/data/") + "psdcumap.dat";
273  //std::string HVfilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"hvmap.dat";
274 
275  std::ifstream LVfile(edm::FileInPath(LVfilename).fullPath().c_str(), std::ios::in);
276 
277  std::cout << LVfilename << std::endl;
278 
279  /*
280  if(enableHVProcessing){
281  std::ifstream HVfile(edm::FileInPath(HVfilename).fullPath().c_str(),std::ios::in);
282  while(!HVfile.eof()) {
283  HVfile >> modId2 >> channelstr1;
284  std::string channelstr2 = channelstr1.substr(9,1);
285  channel= atoi(channelstr2.c_str());
286  TmModule *imod = imoduleMap[modId2];
287  // if(modId1==modId2){
288  imod->HVchannel=channel;
289 
290  }
291 
292  }
293 */
294 
295  while (!LVfile.eof()) {
296  LVfile >> modId1 >> dcuId >> psIdinfo >> psinfo;
297 
298  if (detCabling && detCabling->getConnections(modId1).empty())
299  continue;
300 
301  // int length=psinfo.length();
302  std::string dcsinfo = psinfo.substr(39, 1);
303  std::string branchinfo = psinfo.substr(57, 2);
304  std::string crateinfo = psinfo.substr(69, 1);
305  std::string boardinfo = psinfo.substr(80, 2);
306  std::string channelinfo = psinfo.substr(90, 3);
307 
308  dcs = atoi(dcsinfo.c_str());
309  branch = atoi(branchinfo.c_str());
310  crate = atoi(crateinfo.c_str()) + 1;
311  board = atoi(boardinfo.c_str()) + 1;
312  rack = (branch + 1) + (dcs - 1) * 6;
313  rack = rack_order[rack];
314  channel = atoi(channelinfo.c_str());
315  // std::cout << dcs << " " << branch<< " " <<crate<< " " << board<<" " << rack << std::endl;
316  int key = rack * 1000 + crate * 100 + board;
317 
318  TmPsu *psu = psuMap[key];
319  TmModule *imod = imoduleMap[modId1];
320  if (psu == nullptr) {
321  psu = new TmPsu(dcs, branch, rack, crate, board);
322  psuMap[key] = psu;
323  psu->psId = psIdinfo;
324  }
325 
326  psuModuleMap.insert(std::make_pair(psu, imod));
327  if (imod != nullptr) {
328  imod->PsuId = psIdinfo;
329  imod->psuIdex = psu->idex;
330  imod->HVchannel = channel;
331  }
332  }
333 
334  // int nmax=0;
335  std::map<int, TmPsu *>::iterator ipsu;
336  std::multimap<TmPsu *, TmModule *>::iterator it;
337  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
338  npsu = 0;
339 
340  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
341  TmPsu *psu = ipsu->second;
342  npsu++;
343 
344  if (psu != nullptr) {
345  std::ostringstream outs;
346  std::ostringstream outs1;
347 
348  std::ostringstream outs3;
349  std::ostringstream outs4;
350 
351  std::ostringstream outs5;
352  std::ostringstream outs6;
353 
354  outs << "PSU " << psu->psId << " connected to Mainframe " << psu->getPsuDcs() << " BranchController "
355  << psu->getPsuBranch() << " (Rack " << psu->getPsuRack() << "), crate " << psu->getPsuCrate()
356  << " in position " << psu->getPsuBoard() << " with modules: ";
357  outs1 << "(";
358 
359  if (enableHVProcessing) {
360  outs3 << "PSU " << psu->psId << " connected to Mainframe " << psu->getPsuDcs() << " BranchController "
361  << psu->getPsuBranch() << " (Rack " << psu->getPsuRack() << "),crate " << psu->getPsuCrate()
362  << " in position " << psu->getPsuBoard() << " and HV channel 002 with modules: ";
363  outs4 << "(";
364 
365  outs5 << "PSU " << psu->psId << " connected to Mainframe " << psu->getPsuDcs() << " BranchController "
366  << psu->getPsuBranch() << " (Rack " << psu->getPsuRack() << "), crate " << psu->getPsuCrate()
367  << " in position " << psu->getPsuBoard() << " and HV channel 002 with modules: ";
368  outs6 << "(";
369  }
370 
371  ret = psuModuleMap.equal_range(psu);
372  nmod = 0;
373  nmodHV2 = 0;
374  nmodHV3 = 0;
375  for (it = ret.first; it != ret.second; ++it) {
376  nmod++;
377  outs << (*it).second->idex << ", ";
378  outs1 << (*it).second->getKey() << ",";
379 
380  if (enableHVProcessing) {
381  if ((*it).second->HVchannel == 2) {
382  nmodHV2++;
383  outs3 << (*it).second->idex << ", ";
384  outs4 << (*it).second->getKey() << ",";
385  } else if ((*it).second->HVchannel == 3) {
386  nmodHV3++;
387  outs5 << (*it).second->idex << ", ";
388  outs6 << (*it).second->getKey() << ",";
389  }
390  }
391  }
392 
393  outs1 << ")";
394  psu->nmod = nmod;
395  outs << "(" << psu->nmod << ")";
396  psu->text = outs.str();
397  psu->cmodid_LV = outs1.str();
398  if (enableHVProcessing) {
399  outs4 << ")";
400  outs6 << ")";
401  psu->nmodHV2 = nmodHV2;
402  psu->nmodHV3 = nmodHV3;
403  outs3 << "(" << psu->nmodHV2 << ")";
404  outs5 << "(" << psu->nmodHV3 << ")";
405  psu->textHV2 = outs3.str();
406  psu->textHV3 = outs5.str();
407  psu->cmodid_HV2 = outs4.str();
408  psu->cmodid_HV3 = outs6.str();
409  }
410  }
411  }
412 
413  npsuracks = 29;
414  std::cout << npsu << " psu stored in " << npsuracks << " racks" << std::endl;
415  }
416 }
417 
419  psetAvailable = true;
420  xsize = 340;
421  ysize = 200;
422  title = " ";
423  jsfilename = "CommonTools/TrackerMap/data/trackermap.txt";
424  infilename = "CommonTools/TrackerMap/data/tracker.dat";
425  enableFedProcessing = true;
426  ncrates = 0;
427  firstcrate = 0;
428  saveAsSingleLayer = false;
429  tkMapLog = tkmapPset.getUntrackedParameter<bool>("logScale", false);
430  saveWebInterface = tkmapPset.getUntrackedParameter<bool>("saveWebInterface", false);
431  saveGeoTrackerMap = tkmapPset.getUntrackedParameter<bool>("saveGeoTrackerMap", true);
432  // if(tkmapPset.exists("trackermaptxtPath")){
433  jsfilename = tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath", "CommonTools/TrackerMap/data/") +
434  "trackermap.txt";
435  std::cout << jsfilename << std::endl;
436  infilename =
437  tkmapPset.getUntrackedParameter<std::string>("trackerdatPath", "CommonTools/TrackerMap/data/") + "tracker.dat";
438  std::cout << infilename << std::endl;
439  // } else std::cout << "no parameters found" << std::endl;
440  init();
441 }
442 
443 TrackerMap::TrackerMap(std::string s, int xsize1, int ysize1) {
444  psetAvailable = false;
445  xsize = xsize1;
446  ysize = ysize1;
447  title = s;
448  jsfilename = "CommonTools/TrackerMap/data/trackermap.txt";
449  infilename = "CommonTools/TrackerMap/data/tracker.dat";
450  saveWebInterface = false;
451  saveGeoTrackerMap = true;
452  tkMapLog = false;
453  jsPath = "CommonTools/TrackerMap/data/";
454  enableFedProcessing = false;
455  enableFecProcessing = false;
456  enableLVProcessing = false;
457  enableHVProcessing = false;
458  saveAsSingleLayer = false;
459  init();
460 }
461 
463  std::map<int, TmModule *>::iterator i_mod;
464  for (i_mod = imoduleMap.begin(); i_mod != imoduleMap.end(); i_mod++) {
465  TmModule *mod = i_mod->second;
466  mod->count = 0;
467  mod->value = 0;
468  mod->red = -1;
469  }
470 }
471 
473  ix = 0;
474  iy = 0; //used to compute the place of each layer in the tracker map
475  firstcall = true;
476  minvalue = 0.;
477  maxvalue = minvalue;
478  posrel = true;
479  palette = 1;
480  printflag = true;
481  addPixelFlag = false;
482  onlyPixelFlag = false;
483  temporary_file = false;
484  gminvalue = 0.;
485  gmaxvalue = 0.; //default global range for online rendering
486 
487  int constexpr ndet = 3; // number of detectors: pixel, inner silicon, outer silicon
488  int constexpr npart = 3; // number of detector parts: endcap -z, barrel, endcap +z
489 
490  //allocate module map
491  for (int subdet = 1; subdet < ndet + 1; subdet++) { //loop on subdetectors
492  for (int detpart = 1; detpart < npart + 1; detpart++) { //loop on subdetectors parts
493  int nlayers = getlayerCount(subdet, detpart); // compute number of layers
494  for (int layer = 1; layer < nlayers + 1; layer++) { //loop on layers
495  int nrings = getringCount(subdet, detpart, layer); // compute number of rings
496  //fill arrays used to do the loop on the rings
497  int layer_g = nlayer(subdet, detpart, layer);
498  ntotRing[layer_g - 1] = nrings;
499  firstRing[layer_g - 1] = 1;
500  if (subdet == 3 && detpart != 2)
501  firstRing[layer_g - 1] = 8 - nrings; //special numbering for TEC
502  for (int ring = firstRing[layer_g - 1]; ring < ntotRing[layer_g - 1] + firstRing[layer_g - 1];
503  ring++) { //loop on rings
504  int nmodules = getmoduleCount(subdet, detpart, layer, ring); // compute number of modules
505  int key = 0;
506  TmModule *smodule;
507  for (int module = 1; module < nmodules + 1; module++) { //loop on modules
508  smodule = new TmModule(module, ring, layer_g);
509  key = layer_g * 100000 + ring * 1000 + module; //key identifying module
510  smoduleMap[key] = smodule;
511  }
512  if (isRingStereo(key))
513  for (int module = 1; module < nmodules + 1; module++) { //loop on stereo modules
514  smodule = new TmModule(module + 100, ring, layer_g);
515  int key = layer_g * 100000 + ring * 1000 + module + 100;
516  smoduleMap[key] = smodule;
517  }
518  }
519  }
520  }
521  }
522  build();
523 }
524 
526  for (int layer = 1; layer < 44; layer++) {
527  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
528  for (int module = 1; module < 200; module++) {
529  int key = layer * 100000 + ring * 1000 + module;
531  if (mod != nullptr)
532  delete mod;
533  }
534  }
535  }
536 
537  //std::map<int , TmModule *>::iterator i_mod;
538  // for( i_mod=imoduleMap.begin();i_mod !=imoduleMap.end(); i_mod++){
539  // TmModule * mod= i_mod->second;
540  // delete mod;
541  // }
542  std::map<int, TmApvPair *>::iterator i_apv;
543  for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
544  TmApvPair *apvPair = i_apv->second;
545  delete apvPair;
546  }
547 
548  std::map<int, TmCcu *>::iterator i_ccu;
549  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
550  TmCcu *ccu = i_ccu->second;
551  delete ccu;
552  }
553 
554  std::map<int, TmPsu *>::iterator ipsu;
555  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
556  TmPsu *psu = ipsu->second;
557  delete psu;
558  }
559 }
560 
561 void TrackerMap::drawModule(TmModule *mod, int key, int mlay, bool print_total, std::ofstream *svgfile) {
562  //int x,y;
563  nlay = mlay;
564  double phi, r, dx, dy, dy1;
565  double xp[4], yp[4], xp1, yp1;
566  double vhbot, vhtop, vhapo;
567  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};
568  double xt1, yt1, xs1 = 0., ys1 = 0., xt2, yt2, xs2, ys2, pv1, pv2;
569  int green = 0;
570  int red = 0;
571  int blue = 0;
572  double xd[4], yd[4];
573  int np = 4;
574  //int numrec=0;
575  int numod = 0;
576  phi = phival(mod->posx, mod->posy);
577  r = sqrt(mod->posx * mod->posx + mod->posy * mod->posy);
578  vhtop = mod->width;
579  vhapo = mod->length;
580  if (mlay < 31) { //endcap
581  vhbot = mod->widthAtHalfLength / 2. - (mod->width / 2. - mod->widthAtHalfLength / 2.);
582  vhtop = mod->width / 2.;
583  vhapo = mod->length / 2.;
584  if (mlay > 12 && mlay < 19) {
585  if (posrel)
586  r = r + r;
587  xp[0] = r - vhtop;
588  yp[0] = -vhapo;
589  xp[1] = r + vhtop;
590  yp[1] = -vhapo;
591  xp[2] = r + vhtop;
592  yp[2] = vhapo;
593  xp[3] = r - vhtop;
594  yp[3] = vhapo;
595  } else {
596  if (posrel)
597  r = r + r / 3.;
598  xp[0] = r - vhapo;
599  yp[0] = -vhbot;
600  xp[1] = r + vhapo;
601  yp[1] = -vhtop;
602  xp[2] = r + vhapo;
603  yp[2] = vhtop;
604  xp[3] = r - vhapo;
605  yp[3] = vhbot;
606  }
607  for (int j = 0; j < 4; j++) {
608  xp1 = xp[j] * cos(phi) - yp[j] * sin(phi);
609  yp1 = xp[j] * sin(phi) + yp[j] * cos(phi);
610  xp[j] = xp1;
611  yp[j] = yp1;
612  }
613  } else { //barrel
614  numod = mod->idModule;
615  if (numod > 100)
616  numod = numod - 100;
617  int vane = mod->ring;
618  if (posrel) {
619  dx = vhapo;
620  phi = M_PI;
621  xt1 = rmedio[mlay - 31];
622  yt1 = -vhtop / 2.;
623  xs1 = xt1 * cos(phi) - yt1 * sin(phi);
624  ys1 = xt1 * sin(phi) + yt1 * cos(phi);
625  xt2 = rmedio[mlay - 31];
626  yt2 = vhtop / 2.;
627  xs2 = xt2 * cos(phi) - yt2 * sin(phi);
628  ys2 = xt2 * sin(phi) + yt2 * cos(phi);
629  dy = phival(xs2, ys2) - phival(xs1, ys1);
630  dy1 = dy;
631  if (mlay == 31)
632  dy1 = 0.39;
633  if (mlay == 32)
634  dy1 = 0.23;
635  if (mlay == 33)
636  dy1 = 0.16;
637  xp[0] = vane * (dx + dx / 8.);
638  yp[0] = numod * (dy1);
639  xp[1] = vane * (dx + dx / 8.) + dx;
640  yp[1] = numod * (dy1);
641  xp[2] = vane * (dx + dx / 8.) + dx;
642  yp[2] = numod * (dy1) + dy;
643  xp[3] = vane * (dx + dx / 8.);
644  yp[3] = numod * (dy1) + dy;
645  } else {
646  xt1 = r;
647  yt1 = -vhtop / 2.;
648  xs1 = xt1 * cos(phi) - yt1 * sin(phi);
649  ys1 = xt1 * sin(phi) + yt1 * cos(phi);
650  xt2 = r;
651  yt2 = vhtop / 2.;
652  xs2 = xt2 * cos(phi) - yt2 * sin(phi);
653  ys2 = xt2 * sin(phi) + yt2 * cos(phi);
654  pv1 = phival(xs1, ys1);
655  pv2 = phival(xs2, ys2);
656  if (fabs(pv1 - pv2) > M_PI && numod == 1)
657  pv1 = pv1 - 2. * M_PI;
658  if (fabs(pv1 - pv2) > M_PI && numod != 1)
659  pv2 = pv2 + 2. * M_PI;
660  xp[0] = mod->posz - vhapo / 2.;
661  yp[0] = 4.2 * pv1;
662  xp[1] = mod->posz + vhapo / 2.;
663  yp[1] = 4.2 * pv1;
664  xp[2] = mod->posz + vhapo / 2.;
665  yp[2] = 4.2 * pv2;
666  xp[3] = mod->posz - vhapo / 2.;
667  yp[3] = 4.2 * pv2;
668  }
669  }
670  if (isRingStereo(key)) {
671  np = 3;
672  if (mod->idModule > 100) {
673  for (int j = 0; j < 3; j++) {
674  xd[j] = xdpixel(xp[j]);
675  yd[j] = ydpixel(yp[j]);
676  }
677  } else {
678  xd[0] = xdpixel(xp[2]);
679  yd[0] = ydpixel(yp[2]);
680  xd[1] = xdpixel(xp[3]);
681  yd[1] = ydpixel(yp[3]);
682  xd[2] = xdpixel(xp[0]);
683  yd[2] = ydpixel(yp[0]);
684  }
685  } else {
686  for (int j = 0; j < 4; j++) {
687  xd[j] = xdpixel(xp[j]);
688  yd[j] = ydpixel(yp[j]);
689  }
690  }
691  char buffer[20];
692  sprintf(buffer, "%X", mod->idex);
693 
694  //Get value and name for TH2Poly bin
695  float vals = mod->value;
696  if (std::isnan(vals))
697  vals = 0; //Avoid nan values
698  std::string nams = mod->name;
699 
700  //Format TH2Poly bin name = short_name_(detId)_FED
701  //Original name = TOB- Layer 5 Rod 61 Module 6 r-phi (436295608) connected to 0 413/48 1 413/49 2 413/50 (3)^C
702  //Bin name = TOB-_L_5_R_61_M_6_(436295608)_413
703  nams.erase(std::remove_if(nams.begin(), nams.end(), [](char c) { return std::islower(c); }), nams.end());
704  size_t found = nams.find('/');
705  if (found != std::string::npos) {
706  nams.erase(found, nams.length() - found);
707  } else {
708  found = nams.find(')');
709  nams.erase(found + 1, nams.length() - found);
710  }
711  found = nams.find(") ");
712  while (found != std::string::npos) {
713  nams.erase(found + 1, 4);
714  found = nams.find(") ", found);
715  }
716  found = nams.find(" -");
717  while (found != std::string::npos) {
718  nams.erase(found, 2);
719  found = nams.find(" -", found);
720  }
721  found = nams.find(" ");
722  while (found != std::string::npos) {
723  nams.erase(found, 2);
724  found = nams.find(" ", found);
725  }
726  found = nams.find(" ");
727  while (found != std::string::npos) {
728  nams.erase(found, 1);
729  found = nams.find(" ", found);
730  }
731  std::replace_if(nams.begin(), nams.end(), [](char c) { return c == ' '; }, '_');
732 
733  if (mod->red < 0) { //use count to compute color
734  int color = getcolor(mod->value, palette);
735  red = (color >> 16) & 0xFF;
736  green = (color >> 8) & 0xFF;
737  blue = (color) & 0xFF;
738 
739  if (!print_total)
740  mod->value = mod->value * mod->count; //restore mod->value
741 
742  if (mod->count > 0)
743  if (temporary_file)
744  //Add TH2Poly bin name and value to temporary .coor file
745  *svgfile << nams << " " << vals << " " << red << " " << green << " " << blue << " ";
746  else
747  *svgfile
748  << "<svg:polygon detid=\"" << mod->idex << "\" count=\"" << mod->count << "\" value=\"" << mod->value
749  << "\" id=\"" << key << "\" capvids=\"" << mod->capvids << "\" lv=\"" << mod->psuIdex << "\" hv=\""
750  << mod->psuIdex * 10 + mod->HVchannel << "\" fec=\"" << mod->CcuId
751  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
752  << mod->text << "\" POS=\"" << mod->name << " \" fill=\"rgb(" << red << "," << green << "," << blue
753  << ")\" points=\"";
754  else if (temporary_file)
755  *svgfile << nams << " " << vals << " " << 255 << " " << 255 << " " << 255 << " ";
756  else
757  *svgfile
758  << "<svg:polygon detid=\"" << mod->idex << "\" count=\"" << mod->count << "\" value=\"" << mod->value
759  << "\" id=\"" << key << "\" capvids=\"" << mod->capvids << "\" lv=\"" << mod->psuIdex << "\" hv=\""
760  << mod->psuIdex * 10 + mod->HVchannel << "\" fec=\"" << mod->CcuId
761  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
762  << mod->text << "\" POS=\"" << mod->name << " \" fill=\"white\" points=\"";
763  if (temporary_file)
764  *svgfile << np << " ";
765  for (int k = 0; k < np; k++) {
766  if (temporary_file)
767  *svgfile << xd[k] << " " << yd[k] << " ";
768  else
769  *svgfile << xd[k] << "," << yd[k] << " ";
770  }
771  if (temporary_file)
772  *svgfile << std::endl;
773  else
774  *svgfile << "\" />" << std::endl;
775  } else { //color defined with fillc
776  if (mod->red > 255)
777  mod->red = 255;
778  if (mod->green > 255)
779  mod->green = 255;
780  if (mod->blue > 255)
781  mod->blue = 255;
782  if (temporary_file)
783  *svgfile << nams << " " << vals << " " << mod->red << " " << mod->green << " " << mod->blue << " ";
784  else
785  *svgfile
786  << "<svg:polygon detid=\"" << mod->idex << "\" count=\"" << mod->count << "\" value=\"" << mod->value
787  << "\" id=\"" << key << "\" capvids=\"" << mod->capvids << "\" lv=\"" << mod->psuIdex << "\" hv=\""
788  << mod->psuIdex * 10 + mod->HVchannel << "\" fec=\"" << mod->CcuId
789  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
790  << mod->text << "\" POS=\"" << mod->name << " \" fill=\"rgb(" << mod->red << "," << mod->green << ","
791  << mod->blue << ")\" points=\"";
792  if (temporary_file)
793  *svgfile << np << " ";
794  for (int k = 0; k < np; k++) {
795  if (temporary_file)
796  *svgfile << xd[k] << " " << yd[k] << " ";
797  else
798  *svgfile << xd[k] << "," << yd[k] << " ";
799  }
800  if (temporary_file)
801  *svgfile << std::endl;
802  else
803  *svgfile << "\" />" << std::endl;
804  }
805 }
806 void TrackerMap::setRange(float min, float max) {
807  gminvalue = min;
808  gmaxvalue = max;
809  if (tkMapLog) {
810  gminvalue = pow(10., min);
811  gmaxvalue = pow(10., max);
812  }
813 }
814 
815 std::pair<float, float> TrackerMap::getAutomaticRange() {
816  float minval, maxval;
817  minval = 9999999.;
818  maxval = -9999999.;
819  for (int layer = 1; layer < 44; layer++) {
820  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
821  for (int module = 1; module < 200; module++) {
822  int key = layer * 100000 + ring * 1000 + module;
824  if (mod != nullptr && !mod->notInUse() && mod->count > 0) {
825  if (minval > mod->value)
826  minval = mod->value;
827  if (maxval < mod->value)
828  maxval = mod->value;
829  }
830  }
831  }
832  }
833  if (tkMapLog) {
834  minval = log(minval) / log(10);
835  maxval = log(maxval) / log(10);
836  }
837  return std::make_pair(minval, maxval);
838 }
839 
840 //export tracker map
841 //print_total = true represent in color the total stored in the module
842 //print_total = false represent in color the average
843 void TrackerMap::save(bool print_total, float minval, float maxval, std::string s, int width, int height) {
844  printflag = true;
845  bool rangefound = true;
846  if (saveGeoTrackerMap) {
848  std::vector<TPolyLine *> vp;
849  TGaxis *axis = nullptr;
850  size_t found = filetype.find_last_of('.');
851  filetype = filetype.substr(found + 1);
852  found = outputfilename.find_last_of('.');
853  outputfilename = outputfilename.substr(0, found);
854  //outputfilename.erase(outputfilename.begin()+outputfilename.find("."),outputfilename.end());
855  temporary_file = true;
856 
857  //Dev option to produce only one plot
858  //if(outputfilename != "StoNCorrOnTrack")
859  // return;
860 
861  if (filetype == "svg")
862  temporary_file = false;
863  std::ostringstream outs;
864  minvalue = minval;
865  maxvalue = maxval;
866  outs << outputfilename << ".coor";
867  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
868  if (!print_total) {
869  for (int layer = 1; layer < 44; layer++) {
870  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
871  for (int module = 1; module < 200; module++) {
872  int key = layer * 100000 + ring * 1000 + module;
874  if (mod != nullptr && !mod->notInUse()) {
875  mod->value = mod->value / mod->count;
876  }
877  }
878  }
879  }
880  }
881 
882  if (minvalue >= maxvalue) {
883  minvalue = 9999999.;
884  maxvalue = -9999999.;
885  rangefound = false;
886  for (int layer = 1; layer < 44; layer++) {
887  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
888  for (int module = 1; module < 200; module++) {
889  int key = layer * 100000 + ring * 1000 + module;
891  if (mod != nullptr && !mod->notInUse() && mod->count > 0) {
892  rangefound = true;
893  if (minvalue > mod->value)
894  minvalue = mod->value;
895  if (maxvalue < mod->value)
896  maxvalue = mod->value;
897  }
898  }
899  }
900  }
901  }
902  if ((title.find("QTestAlarm") != std::string::npos) || (maxvalue == minvalue) || !rangefound)
903  printflag = false;
904  if (!temporary_file) {
905  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
906  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
907  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
908  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
909  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3100 1600"
910  << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
911  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3100\" height=\"1600\" /> "
912  << std::endl;
913  *savefile << "<svg:g id=\"tracker\" transform=\"translate(10,1500) rotate(270)\" "
914  "style=\"fill:none;stroke:black;stroke-width:0;\"> "
915  << std::endl;
916  }
917  for (int layer = 1; layer < 44; layer++) {
918  // nlay=layer;
919  defwindow(layer);
920  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
921  for (int module = 1; module < 200; module++) {
922  int key = layer * 100000 + ring * 1000 + module;
924  if (mod != nullptr && !mod->notInUse()) {
925  drawModule(mod, key, layer, print_total, savefile);
926  }
927  }
928  }
929  }
930 
931  if (!temporary_file) {
932  *savefile << "</svg:g>" << std::endl;
933  *savefile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">" << title << "</svg:text>"
934  << std::endl;
935  }
936 
937  if (printflag) {
938  if (onlyPixelFlag) {
939  drawPalette(savefile, -30);
940  } else {
942  }
943  }
944  if (!temporary_file) {
945  *savefile << "</svg:svg>" << std::endl;
946  *savefile << "</svg>" << std::endl;
947  }
948  savefile->close();
949  delete savefile;
950 
951  const char *command1;
952  std::string tempfilename = outputfilename + ".coor";
953  if (filetype == "svg") {
954  std::string command = "mv " + tempfilename + " " + outputfilename + ".svg";
955  command1 = command.c_str();
956  std::cout << "Executing " << command1 << std::endl;
957  system(command1);
958  }
959 
960  if (temporary_file) { // create root trackermap image
961  //Variables for TH2Poly bin content and name from temporary .coor file
962  float content;
963  std::string named;
964 
965  int red, green, blue, npoints, colindex, ncolor;
966  double x[4], y[4];
967  std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
968  TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
969  gPad->SetFillColor(38);
970 
971  if (addPixelFlag) {
972  gPad->Range(0, 0, 3800, 1600);
973  } else if (onlyPixelFlag) {
974  gPad->Range(-100, 0, 800, 1600);
975  } else {
976  gPad->Range(800, 0, 3800, 1600);
977  }
978 
979  //First build palette
980  ncolor = 0;
981  typedef std::map<int, int> ColorList;
982  ColorList colorList;
983  ColorList::iterator pos;
984  TColor *col, *c;
985  std::cout << "tempfilename " << tempfilename << std::endl;
986  while (!tempfile.eof()) {
987  tempfile >> named >> content >> red >> green >> blue >> npoints;
988  colindex = red + green * 1000 + blue * 1000000;
989  pos = colorList.find(colindex);
990  if (pos == colorList.end()) {
991  colorList[colindex] = ncolor + 100;
992  col = gROOT->GetColor(ncolor + 100);
993  if (col)
994  col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
995  else
996  c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
997  vc.push_back(c);
998  ncolor++;
999  }
1000  for (int i = 0; i < npoints; i++) {
1001  tempfile >> x[i] >> y[i];
1002  }
1003  }
1004 
1005  if (ncolor > 0 && ncolor < 10000) {
1006  Int_t colors[10000];
1007  for (int i = 0; i < ncolor; i++) {
1008  colors[i] = i + 100;
1009  }
1010  gStyle->SetPalette(ncolor, colors);
1011  }
1012 
1013  tempfile.clear();
1014  tempfile.seekg(0, std::ios::beg);
1015  std::cout << "created palette with " << ncolor << " colors" << std::endl;
1016 
1017  //TH2Poly Tracker Map for Strip
1018  TH2Poly *StripMap = new TH2Poly("StripSummary", "", 775, 3600, 0, 1350);
1019  StripMap->SetFloat(true);
1020  StripMap->GetXaxis()->SetTitle("");
1021  StripMap->GetYaxis()->SetTitle("");
1022  StripMap->SetStats(false);
1023  int siterator = 0;
1024 
1025  while (!tempfile.eof()) { //create polylines
1026  siterator++;
1027  //Get TH2Poly bin name and content from temporary .coor file
1028  tempfile >> named >> content >> red >> green >> blue >> npoints;
1029 
1030  for (int i = 0; i < npoints; i++) {
1031  tempfile >> x[i] >> y[i];
1032  }
1033  colindex = red + green * 1000 + blue * 1000000;
1034  pos = colorList.find(colindex);
1035  if (pos != colorList.end()) {
1036  TPolyLine *pline = new TPolyLine(npoints, y, x);
1037  vp.push_back(pline);
1038  pline->SetFillColor(colorList[colindex]);
1039 
1040  TGraph *bin = new TGraph(npoints, y, x);
1041  //Fill only 15145 TH2Poly bins (Strip only), instead of 16588 bins (Pixel+Strip, old)
1042  if ((siterator >= 1 && siterator <= 3608) || (siterator >= 4281 && siterator <= 7888) ||
1043  (siterator >= 8657 && siterator <= 16588)) {
1044  bin->SetName(named.c_str());
1045  StripMap->AddBin(bin);
1046  StripMap->Fill(named.c_str(), content);
1047  }
1048 
1049  pline->SetLineWidth(0);
1050  pline->Draw("f");
1051  }
1052  }
1053  if (printflag) {
1054  float lminvalue = minvalue;
1055  float lmaxvalue = maxvalue;
1056  if (tkMapLog) {
1057  lminvalue = log(minvalue) / log(10);
1058  lmaxvalue = log(maxvalue) / log(10);
1059  }
1060  if (onlyPixelFlag) {
1061  axis = new TGaxis(-30, 36, -30, 1530, lminvalue, lmaxvalue, 510, "+L");
1062  } else {
1063  axis = new TGaxis(3660, 36, 3660, 1530, lminvalue, lmaxvalue, 510, "+L");
1064  }
1065  axis->SetLabelSize(0.02);
1066  axis->Draw();
1067  }
1068  TLatex l;
1069  l.SetTextSize(0.03);
1070  l.DrawLatex(950, 1330, "TID");
1071  l.DrawLatex(2300, 1330, "TEC");
1072  l.DrawLatex(300, 1330, "FPIX");
1073  l.DrawLatex(20, 560, "BPIX L1");
1074  l.DrawLatex(500, 385, "BPIX L2");
1075  l.DrawLatex(500, 945, "BPIX L3");
1076  l.SetTextSize(0.04);
1077  std::string fulltitle = title;
1078  if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
1079  fulltitle += ": Log10 scale";
1080  if (onlyPixelFlag) {
1081  l.DrawLatex(30, 1500, fulltitle.c_str());
1082  } else {
1083  l.DrawLatex(850, 1500, fulltitle.c_str());
1084  }
1085  if (onlyPixelFlag) {
1086  l.DrawLatex(380, 40, "-z");
1087  } else {
1088  l.DrawLatex(1730, 40, "-z");
1089  }
1090  if (onlyPixelFlag) {
1091  l.DrawLatex(380, 1330, "+z");
1092  } else {
1093  l.DrawLatex(1730, 1360, "+z");
1094  }
1095  l.DrawLatex(1085, 330, "TIB L1");
1096  l.DrawLatex(1085, 1000, "TIB L2");
1097  l.DrawLatex(1585, 330, "TIB L3");
1098  l.DrawLatex(1585, 1000, "TIB L4");
1099  l.DrawLatex(2085, 330, "TOB L1");
1100  l.DrawLatex(2085, 1000, "TOB L2");
1101  l.DrawLatex(2585, 330, "TOB L3");
1102  l.DrawLatex(2585, 1000, "TOB L4");
1103  l.DrawLatex(3085, 330, "TOB L5");
1104  l.DrawLatex(3085, 1000, "TOB L6");
1105  TArrow arx(3448, 1190, 3448, 1350, 0.01, "|>");
1106  l.DrawLatex(3460, 1350, "x");
1107  TArrow ary(3448, 1190, 3312, 1190, 0.01, "|>");
1108  l.DrawLatex(3312, 1210, "y");
1109  TArrow arz(3485, 373, 3485, 676, 0.01, "|>");
1110  l.DrawLatex(3510, 667, "z");
1111  TArrow arphi(3485, 511, 3037, 511, 0.01, "|>");
1112  l.DrawLatex(3023, 520, "#Phi");
1113  arx.SetLineWidth(3);
1114  ary.SetLineWidth(3);
1115  arz.SetLineWidth(3);
1116  arphi.SetLineWidth(3);
1117  if (onlyPixelFlag) {
1118  arx.SetX1(570);
1119  arx.SetX2(570);
1120  arx.SetY1(1190);
1121  arx.SetY2(1350);
1122  l.DrawLatex(570 + 12, 1190 + 160, "x");
1123  ary.SetX1(570);
1124  ary.SetX2(570 - 160);
1125  ary.SetY1(1190);
1126  ary.SetY2(1190);
1127  l.DrawLatex(570 - 160, 1190 + 30, "y");
1128  arz.SetX1(380);
1129  arz.SetX2(380);
1130  arz.SetY1(683 - 100);
1131  arz.SetY2(683 + 100);
1132  l.DrawLatex(380 + 15, 683 + 100 - 9, "z");
1133  arphi.SetX1(380);
1134  arphi.SetX2(380 - 390);
1135  arphi.SetY1(683);
1136  arphi.SetY2(683);
1137  l.DrawLatex(380 - 390 - 14, 683 + 9, "#Phi");
1138  }
1139  arx.Draw();
1140  ary.Draw();
1141  arz.Draw();
1142  arphi.Draw();
1143  TLegend *MyL = buildLegend();
1144 
1145  if (title.find("QTestAlarm") != std::string::npos) {
1146  MyL->Draw();
1147  }
1148  MyC->Update();
1149  if (filetype == "png") {
1150  std::string filename = outputfilename + ".png";
1151  std::cout << "printing " << filename << std::endl;
1152  MyC->Print(filename.c_str());
1153  }
1154  if (filetype == "jpg") {
1155  std::string filename = outputfilename + ".jpg";
1156  MyC->Print(filename.c_str());
1157  }
1158  if (filetype == "pdf") {
1159  std::string filename = outputfilename + ".pdf";
1160  MyC->Print(filename.c_str());
1161  }
1162  std::string command = "rm " + tempfilename;
1163  command1 = command.c_str();
1164  std::cout << "Executing " << command1 << std::endl;
1165  system(command1);
1166  MyC->Clear();
1167  delete MyC;
1168  delete MyL;
1169 
1170  //Canvas name = MyT for both Pixel and Strip Tracker Maps
1171  TCanvas *MyT = new TCanvas("MyT", "MyT", 3500, 1500);
1172  //gPad->SetFillColor(38);//Fill pad
1173  StripMap->SetLineColor(kBlack);
1174  StripMap->SetLineWidth(0);
1175  StripMap->Draw("AL COLZ");
1176  MyT->Update();
1177 
1178  //Rainbow palette, fix pad margin and palette position
1179  gStyle->SetPalette(kRainBow);
1180  TPaletteAxis *realPalette = (TPaletteAxis *)StripMap->GetListOfFunctions()->FindObject("palette");
1181  realPalette->SetX1NDC(0.92);
1182  realPalette->SetX2NDC(0.94);
1183  realPalette->SetY1NDC(0.02);
1184  realPalette->SetY2NDC(0.91);
1185  gPad->SetRightMargin(0.08);
1186  gPad->SetLeftMargin(0.01);
1187  gPad->SetTopMargin(0.09);
1188  gPad->SetBottomMargin(0.02);
1189  gPad->Update();
1190 
1191  //Fill pad with text and arrows
1192  TLatex l2;
1193  l2.SetTextSize(0.06);
1195  for (char c : title)
1196  if (std::isdigit(c))
1197  runnumber.push_back(c);
1198  std::string striptitle = "Run " + runnumber + ": Strip " + outputfilename;
1199  l2.DrawLatex(800, 1380, striptitle.c_str());
1200  l2.SetTextSize(0.05);
1201  l2.DrawLatex(1200, 40, "-z");
1202  l2.DrawLatex(1200, 1300, "+z");
1203  l2.DrawLatex(1085, 310, "TIB L1");
1204  l2.DrawLatex(1085, 1000, "TIB L2");
1205  l2.DrawLatex(1585, 310, "TIB L3");
1206  l2.DrawLatex(1585, 1000, "TIB L4");
1207  l2.DrawLatex(2085, 310, "TOB L1");
1208  l2.DrawLatex(2085, 1000, "TOB L2");
1209  l2.DrawLatex(2585, 310, "TOB L3");
1210  l2.DrawLatex(2585, 1000, "TOB L4");
1211  l2.DrawLatex(3085, 310, "TOB L5");
1212  l2.DrawLatex(3085, 1000, "TOB L6");
1213  l2.DrawLatex(3460, 1320, "x");
1214  l2.DrawLatex(3315, 1210, "y");
1215  l2.DrawLatex(3510, 667, "z");
1216  l2.DrawLatex(3023, 530, "#Phi");
1217  arx.SetY2(1320);
1218  ary.SetX2(3320);
1219  arz.SetX1(3490);
1220  arz.SetX2(3490);
1221  arphi.SetX1(3490);
1222  arx.Draw();
1223  ary.Draw();
1224  arz.Draw();
1225  arphi.Draw();
1226  MyT->Update();
1227 
1228  std::string filename = outputfilename + ".root";
1229  MyT->Print(filename.c_str());
1230  delete MyT;
1231 
1232  if (printflag)
1233  delete axis;
1234  for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
1235  delete (*pos1);
1236  }
1237  }
1238  }
1239  return;
1240 }
1242  int crate, int numfed_incrate, bool print_total, TmApvPair *apvPair, std::ofstream *svgfile, bool useApvPairValue) {
1243  double xp[4], yp[4];
1244  int color;
1245  int green = 0;
1246  int red = 0;
1247  int blue = 0;
1248  double xd[4], yd[4];
1249  int np = 4;
1250  double boxinitx = 0., boxinity = 0.;
1251  double dx = .9, dy = .9;
1252  /*
1253  int numfedch_incolumn = 12;
1254  int numfedch_inrow = 8;
1255  int numfed_incolumn = 6;
1256  int numfed_inrow = 4;
1257  */
1258  boxinitx = boxinitx + (NUMFED_INCOLUMN - 1 - (numfed_incrate - 1) / NUMFED_INROW) * (NUMFEDCH_INCOLUMN + 2);
1259  boxinity = boxinity + (NUMFED_INROW - 1 - (numfed_incrate - 1) % NUMFED_INROW) * (NUMFEDCH_INROW + 1);
1260  boxinity = boxinity + NUMFEDCH_INROW - (apvPair->getFedCh() / NUMFEDCH_INCOLUMN);
1261  boxinitx = boxinitx + NUMFEDCH_INCOLUMN - (int)(apvPair->getFedCh() % NUMFEDCH_INCOLUMN);
1262  // std::cout << crate << " " << numfed_incrate << " " << apvPair->getFedCh()<<" "<<boxinitx<< " " << boxinity << std::endl; ;
1263  xp[0] = boxinitx;
1264  yp[0] = boxinity;
1265  xp[1] = boxinitx + dx;
1266  yp[1] = boxinity;
1267  xp[2] = boxinitx + dx;
1268  yp[2] = boxinity + dy;
1269  xp[3] = boxinitx;
1270  yp[3] = boxinity + dy;
1271  for (int j = 0; j < 4; j++) {
1272  xd[j] = xdpixelc(xp[j]);
1273  yd[j] = ydpixelc(yp[j]);
1274  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1275  }
1276 
1277  char buffer[20];
1278  sprintf(buffer, "%X", apvPair->mod->idex);
1279  std::string s = apvPair->mod->name;
1280  s.erase(s.begin() + s.find("connected"), s.end());
1281 
1282  if (useApvPairValue) {
1283  if (apvPair->red < 0) { //use count to compute color
1284  if (apvPair->count > 0) {
1285  float vals = apvPair->value;
1286  std::string nams = "nams_apv";
1287 
1288  color = getcolor(apvPair->value, palette);
1289  red = (color >> 16) & 0xFF;
1290  green = (color >> 8) & 0xFF;
1291  blue = (color) & 0xFF;
1292  if (!print_total)
1293  apvPair->value = apvPair->value * apvPair->count; //restore mod->value
1294  if (temporary_file)
1295  *svgfile << nams << " " << vals << " " << red << " " << green << " " << blue << " ";
1296  else
1297  *svgfile
1298  << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1299  << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1300  << apvPair->mod->getKey()
1301  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1302  "\" POS=\"Fed/Ch "
1303  << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1304  << " \" fill=\"rgb(" << red << "," << green << "," << blue << ")\" points=\"";
1305  } else {
1306  if (temporary_file)
1307  *svgfile << 0 << " " << 0 << " " << 255 << " " << 255 << " " << 255 << " ";
1308  else
1309  *svgfile
1310  << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1311  << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1312  << apvPair->mod->getKey()
1313  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1314  "\" POS=\"Fed/Ch "
1315  << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1316  << " \" fill=\"white\" points=\"";
1317  }
1318  } else { //color defined with fillc
1319  if (apvPair->red > 255)
1320  apvPair->red = 255;
1321  if (apvPair->green > 255)
1322  apvPair->green = 255;
1323  if (apvPair->blue > 255)
1324  apvPair->blue = 255;
1325  if (temporary_file)
1326  *svgfile << 0 << " " << 0 << " " << apvPair->red << " " << apvPair->green << " " << apvPair->blue << " ";
1327  else
1328  *svgfile
1329  << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1330  << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1331  << apvPair->mod->getKey()
1332  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1333  "\" POS=\"Fed/Ch "
1334  << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1335  << " \" fill=\"rgb(" << apvPair->red << "," << apvPair->green << "," << apvPair->blue << ")\" points=\"";
1336  }
1337  } else {
1338  if (apvPair->mod->red < 0) { //use count to compute color
1339  if (apvPair->mod->count > 0) {
1340  float vals = apvPair->mod->value;
1341  std::string nams = "nams_apv2";
1342 
1343  color = getcolor(apvPair->mod->value, palette);
1344  red = (color >> 16) & 0xFF;
1345  green = (color >> 8) & 0xFF;
1346  blue = (color) & 0xFF;
1347  if (temporary_file)
1348  *svgfile << nams << " " << vals << " " << red << " " << green << " " << blue << " ";
1349  else
1350  *svgfile
1351  << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1352  << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1353  << apvPair->mod->getKey()
1354  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1355  "\" POS=\"Fed/Ch "
1356  << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1357  << " \" fill=\"rgb(" << red << "," << green << "," << blue << ")\" points=\"";
1358  } else {
1359  if (temporary_file)
1360  *svgfile << 0 << " " << 0 << " " << 255 << " " << 255 << " " << 255 << " ";
1361  else
1362  *svgfile
1363  << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1364  << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1365  << apvPair->mod->getKey()
1366  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1367  "\" POS=\"Fed/Ch "
1368  << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1369  << " \" fill=\"white\" points=\"";
1370  }
1371  } else { //color defined with fillc
1372  if (apvPair->mod->red > 255)
1373  apvPair->mod->red = 255;
1374  if (apvPair->mod->green > 255)
1375  apvPair->mod->green = 255;
1376  if (apvPair->mod->blue > 255)
1377  apvPair->mod->blue = 255;
1378  if (temporary_file)
1379  *svgfile << 0 << " " << 0 << " " << apvPair->mod->red << " " << apvPair->mod->green << " " << apvPair->mod->blue
1380  << " ";
1381  else
1382  *svgfile
1383  << "<svg:polygon detid=\"" << apvPair->idex << "\" count=\"" << apvPair->count << "\" value=\""
1384  << apvPair->value << "\" id=\"" << apvPair->idex + crate * 1000000 << "\" cmodid=\""
1385  << apvPair->mod->getKey()
1386  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1387  "\" POS=\"Fed/Ch "
1388  << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connected to " << s << " Id " << buffer
1389  << " \" fill=\"rgb(" << apvPair->mod->red << "," << apvPair->mod->green << "," << apvPair->mod->blue
1390  << ")\" points=\"";
1391  }
1392  }
1393  if (temporary_file)
1394  *svgfile << np << " ";
1395  for (int k = 0; k < np; k++) {
1396  if (temporary_file)
1397  *svgfile << xd[k] << " " << yd[k] << " ";
1398  else
1399  *svgfile << xd[k] << "," << yd[k] << " ";
1400  }
1401  if (temporary_file)
1402  *svgfile << std::endl;
1403  else
1404  *svgfile << "\" />" << std::endl;
1405 }
1407  int crate, int numfec_incrate, bool print_total, TmCcu *ccu, std::ofstream *svgfile, bool useCcuValue) {
1408  double xp[4], yp[4];
1409  int color;
1410  int green = 0;
1411  int red = 0;
1412  int blue = 0;
1413  double xd[4], yd[4];
1414  int np = 4;
1415  double boxinitx = 0., boxinity = 0.;
1416  double dx = .9, dy = .9;
1417  int numccu_incolumn = 8;
1418  int numccu_inrow = 15;
1419  int numfec_incolumn = 5;
1420  int numfec_inrow = 4;
1421  boxinitx = boxinitx + (numfec_incolumn - (numfec_incrate - 1) / numfec_inrow) * 14.;
1422  boxinity = boxinity + (numfec_inrow - (numfec_incrate - 1) % numfec_inrow) * 16.;
1423  boxinity = boxinity + numccu_inrow - ccu->mpos;
1424  boxinitx = boxinitx + numccu_incolumn - (int)(ccu->getCcuRing() % numccu_incolumn);
1425  //std::cout << crate << " " << numfec_incrate << " " << ccu->getCcuRing()<<" "<<ccu->mpos<<" "<<boxinitx<< " " << boxinity << std::endl; ;
1426  xp[0] = boxinitx;
1427  yp[0] = boxinity;
1428  xp[1] = boxinitx + dx;
1429  yp[1] = boxinity;
1430  xp[2] = boxinitx + dx;
1431  yp[2] = boxinity + dy;
1432  xp[3] = boxinitx;
1433  yp[3] = boxinity + dy;
1434  for (int j = 0; j < 4; j++) {
1435  xd[j] = xdpixelfec(xp[j]);
1436  yd[j] = ydpixelfec(yp[j]);
1437  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1438  }
1439 
1440  char buffer[20];
1441  sprintf(buffer, "%X", ccu->idex);
1442  //sprintf(buffer,"%X",ccu->mod->idex);
1443  //std::string s = ccu->mod->name;
1444  std::string s = ccu->text;
1445  s.erase(s.begin() + s.find("connected"), s.end());
1446 
1447  if (ccu->red < 0) { //use count to compute color
1448  if (ccu->count > 0) {
1449  float vals = ccu->value;
1450  std::string nams = "nams_ccu";
1451 
1452  color = getcolor(ccu->value, palette);
1453  red = (color >> 16) & 0xFF;
1454  green = (color >> 8) & 0xFF;
1455  blue = (color) & 0xFF;
1456  if (!print_total)
1457  ccu->value = ccu->value * ccu->count; //restore mod->value
1458  if (temporary_file)
1459  *svgfile << nams << " " << vals << " " << red << " " << green << " " << blue << " ";
1460  else
1461  *svgfile
1462  << "<svg:polygon detid=\"" << ccu->idex << "\" count=\"" << ccu->count << "\" value=\"" << ccu->value
1463  << "\" id=\"" << ccu->idex + crate * 1000000 << "\" cmodid=\"" << ccu->cmodid << "\" layer=\"" << ccu->layer
1464  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1465  "\" POS=\"Slot/Ring"
1466  << ccu->getCcuSlot() << "/" << ccu->getCcuRing() << " connected to " << s << " Id " << buffer
1467  << " \" fill=\"rgb(" << red << "," << green << "," << blue << ")\" points=\"";
1468  } else {
1469  if (temporary_file)
1470  *svgfile << 0 << " " << 0 << " " << 255 << " " << 255 << " " << 255 << " ";
1471  else
1472  *svgfile
1473  << "<svg:polygon detid=\"" << ccu->idex << "\" count=\"" << ccu->count << "\" value=\"" << ccu->value
1474  << "\" id=\"" << ccu->idex + crate * 1000000 << "\" cmodid=\"" << ccu->cmodid << "\" layer=\""
1475  << ccu->layer
1476  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1477  "\" POS=\"Slot/Ring "
1478  << ccu->getCcuSlot() << "/" << ccu->getCcuRing() << " connected to " << s << " Id " << buffer
1479  << " \" fill=\"white\" points=\"";
1480  }
1481  } else { //color defined with fillc
1482  if (ccu->red > 255)
1483  ccu->red = 255;
1484  if (ccu->green > 255)
1485  ccu->green = 255;
1486  if (ccu->blue > 255)
1487  ccu->blue = 255;
1488  if (temporary_file)
1489  *svgfile << 0 << " " << 0 << " " << ccu->red << " " << ccu->green << " " << ccu->blue << " ";
1490  else
1491  *svgfile
1492  << "<svg:polygon detid=\"" << ccu->idex << "\" count=\"" << ccu->count << "\" value=\"" << ccu->value
1493  << "\" id=\"" << ccu->idex + crate * 1000000 << "\" cmodid=\"" << ccu->cmodid << "\" layer=\"" << ccu->layer
1494  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1495  "\" POS=\"Slot/Ring "
1496  << ccu->getCcuSlot() << "/" << ccu->getCcuRing() << " connected to " << s << " Id " << buffer
1497  << " \" fill=\"rgb(" << ccu->red << "," << ccu->green << "," << ccu->blue << ")\" points=\"";
1498  }
1499  if (temporary_file)
1500  *svgfile << np << " ";
1501  for (int k = 0; k < np; k++) {
1502  if (temporary_file)
1503  *svgfile << xd[k] << " " << yd[k] << " ";
1504  else
1505  *svgfile << xd[k] << "," << yd[k] << " ";
1506  }
1507  if (temporary_file)
1508  *svgfile << std::endl;
1509  else
1510  *svgfile << "\" />" << std::endl;
1511 }
1513  int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue) {
1514  double xp[4], yp[4];
1515  int color;
1516  int green = 0;
1517  int red = 0;
1518  int blue = 0;
1519  double xd[4], yd[4];
1520  int np = 4;
1521  double boxinitx = 0., boxinity = 0.;
1522  double dx = .9, dy = .9;
1523 
1524  boxinitx = boxinitx + (NUMPSUCRATE_INCOLUMN - psu->getPsuCrate()) * 1.5;
1525  boxinity = boxinity + (NUMPSUCH_INROW - psu->getPsuBoard());
1526 
1527  xp[0] = boxinitx;
1528  yp[0] = boxinity;
1529  xp[1] = boxinitx + dx;
1530  yp[1] = boxinity;
1531  xp[2] = boxinitx + dx;
1532  yp[2] = boxinity + dy;
1533  xp[3] = boxinitx;
1534  yp[3] = boxinity + dy;
1535 
1536  for (int j = 0; j < 4; j++) {
1537  xd[j] = xdpixelpsu(xp[j]);
1538  yd[j] = ydpixelpsu(yp[j]);
1539  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1540  }
1541 
1542  // lines needed to prepare the clickable maps: understand why I get twice the full list of channels (HV1 and HV0?)
1543  /*
1544  double scalex=2695./2700.;
1545  double scaley=1520./1550.;
1546  std::cout << "<area shape=\"rect\" coords=\" "
1547  << int(scalex*yd[2]) << "," << int(1520-scaley*xd[2])
1548  << "," << int(scalex*yd[0]) << "," << int(1520-scaley*xd[0])
1549  << "\" title=\" " << psu->psId << "\" /> " << std::endl;
1550  */
1551  //
1552 
1553  char buffer[20];
1554  sprintf(buffer, "%X", psu->idex);
1555  std::string s = psu->text;
1556  s.erase(s.begin() + s.find("connected"), s.end());
1557 
1558  if (psu->red < 0) { //use count to compute color
1559  if (psu->count > 0) {
1560  float vals = psu->value;
1561  std::string nams = "nams_psu";
1562 
1563  color = getcolor(psu->value, palette);
1564  red = (color >> 16) & 0xFF;
1565  green = (color >> 8) & 0xFF;
1566  blue = (color) & 0xFF;
1567  if (!print_total)
1568  psu->value = psu->value * psu->count; //restore mod->value
1569  if (temporary_file)
1570  *svgfile << nams << " " << vals << " " << red << " " << green << " " << blue << " ";
1571  else
1572  *svgfile
1573  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->count << "\" value=\"" << psu->value
1574  << "\" id=\"" << psu->idex << "\" cmodid=\"" << psu->cmodid_LV
1575  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1576  "\" POS=\"easyCrate/easyBoard "
1577  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << red
1578  << "," << green << "," << blue << ")\" points=\"";
1579  } else {
1580  if (temporary_file)
1581  *svgfile << 0 << " " << 0 << " " << 255 << " " << 255 << " " << 255 << " ";
1582  else
1583  *svgfile
1584  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->count << "\" value=\"" << psu->value
1585  << "\" id=\"" << psu->idex << "\" cmodid=\"" << psu->cmodid_LV
1586  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1587  "\" POS=\"easyCrate/easyBoard "
1588  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s
1589  << " \" fill=\"white\" points=\"";
1590  }
1591  }
1592 
1593  else { //color defined with fillc
1594  if (psu->red > 255)
1595  psu->red = 255;
1596  if (psu->green > 255)
1597  psu->green = 255;
1598  if (psu->blue > 255)
1599  psu->blue = 255;
1600  if (temporary_file)
1601  *svgfile << 0 << " " << 0 << " " << psu->red << " " << psu->green << " " << psu->blue << " ";
1602  else
1603  *svgfile
1604  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->count << "\" value=\"" << psu->value
1605  << "\" id=\"" << psu->idex << "\" cmodid=\"" << psu->cmodid_LV
1606  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1607  "\" POS=\"easyCrate/easyBoard "
1608  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << psu->red
1609  << "," << psu->green << "," << psu->blue << ")\" points=\"";
1610  }
1611 
1612  if (temporary_file)
1613  *svgfile << np << " ";
1614  for (int k = 0; k < np; k++) {
1615  if (temporary_file)
1616  *svgfile << xd[k] << " " << yd[k] << " ";
1617  else
1618  *svgfile << xd[k] << "," << yd[k] << " ";
1619  }
1620  if (temporary_file)
1621  *svgfile << std::endl;
1622  else
1623  *svgfile << "\" />" << std::endl;
1624 }
1625 
1627  int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue) {
1628  double xp[4], yp[4];
1629  int color;
1630  int greenHV2 = 0;
1631  int redHV2 = 0;
1632  int blueHV2 = 0;
1633  double xd[4], yd[4];
1634  int np = 4;
1635  double boxinitx = 35, boxinity = 12;
1636  double dx = 1.1, dy = 1.3;
1637 
1638  boxinitx = boxinitx + (5 - psu->getPsuCrate()) * 5;
1639  boxinity = boxinity + (18 - psu->getPsuBoard()) * 1.75;
1640 
1641  xp[0] = boxinitx;
1642  yp[0] = boxinity;
1643  xp[1] = boxinitx + dx;
1644  yp[1] = boxinity;
1645  xp[2] = boxinitx + dx;
1646  yp[2] = boxinity + dy;
1647  xp[3] = boxinitx;
1648  yp[3] = boxinity + dy;
1649 
1650  for (int j = 0; j < 4; j++) {
1651  xd[j] = xdpixelpsu(xp[j]);
1652  yd[j] = ydpixelpsu(yp[j]);
1653  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1654  }
1655 
1656  char buffer[20];
1657  sprintf(buffer, "%X", psu->idex);
1658  std::string s = psu->textHV2;
1659  s.erase(s.begin() + s.find("connected"), s.end());
1660 
1661  if (psu->redHV2 < 0) { //use count to compute color
1662 
1663  if (psu->valueHV2 > 0) {
1664  float vals = psu->valueHV2;
1665  std::string nams = "nams_hv2";
1666 
1667  color = getcolor(psu->valueHV2, palette);
1668  redHV2 = (color >> 16) & 0xFF;
1669  greenHV2 = (color >> 8) & 0xFF;
1670  blueHV2 = (color) & 0xFF;
1671  if (!print_total)
1672  psu->valueHV2 = psu->valueHV2 * psu->countHV2; //restore mod->value
1673  if (temporary_file)
1674  *svgfile << nams << " " << vals << " " << redHV2 << " " << greenHV2 << " " << blueHV2 << " ";
1675  else
1676  *svgfile
1677  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV2 << "\" value=\"" << psu->valueHV2
1678  << "\" id=\"" << psu->idex * 10 + 2 << "\" cmodid=\"" << psu->cmodid_HV2
1679  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1680  "\" POS=\"easyCrate/easyBoard "
1681  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << redHV2
1682  << "," << greenHV2 << "," << blueHV2 << ")\" points=\"";
1683  } else {
1684  if (temporary_file)
1685  *svgfile << 0 << " " << 0 << " " << 255 << " " << 255 << " " << 255 << " ";
1686  else
1687  *svgfile
1688  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV2 << "\" value=\"" << psu->valueHV2
1689  << "\" id=\"" << psu->idex * 10 + 2 << "\" cmodid=\"" << psu->cmodid_HV2
1690  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1691  "\" POS=\"easyCrate/easyBoard "
1692  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s
1693  << " \" fill=\"white\" points=\"";
1694  }
1695  }
1696 
1697  else { //color defined with fillc
1698  if (psu->redHV2 > 255)
1699  psu->redHV2 = 255;
1700  if (psu->greenHV2 > 255)
1701  psu->greenHV2 = 255;
1702  if (psu->blueHV2 > 255)
1703  psu->blueHV2 = 255;
1704  if (temporary_file)
1705  *svgfile << 0 << " " << 0 << " " << psu->redHV2 << " " << psu->greenHV2 << " " << psu->blueHV2 << " ";
1706  else
1707  *svgfile
1708  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV2 << "\" value=\"" << psu->valueHV2
1709  << "\" id=\"" << psu->idex * 10 + 2 << "\" cmodid=\"" << psu->cmodid_HV2
1710  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1711  "\" POS=\"easyCrate/easyBoard "
1712  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb("
1713  << psu->redHV2 << "," << psu->greenHV2 << "," << psu->blueHV2 << ")\" points=\"";
1714  }
1715 
1716  if (temporary_file)
1717  *svgfile << np << " ";
1718  for (int k = 0; k < np; k++) {
1719  if (temporary_file)
1720  *svgfile << xd[k] << " " << yd[k] << " ";
1721  else
1722  *svgfile << xd[k] << "," << yd[k] << " ";
1723  }
1724  if (temporary_file)
1725  *svgfile << std::endl;
1726  else
1727  *svgfile << "\" />" << std::endl;
1728 }
1729 
1731  int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue) {
1732  double xp[4], yp[4];
1733  int color;
1734  int greenHV3 = 0;
1735  int redHV3 = 0;
1736  int blueHV3 = 0;
1737  double xd[4], yd[4];
1738  int np = 4;
1739  double boxinitx = 36.5, boxinity = 12;
1740  double dx = 1.1, dy = 1.3;
1741 
1742  boxinitx = boxinitx + (5 - psu->getPsuCrate()) * 5;
1743  boxinity = boxinity + (18 - psu->getPsuBoard()) * 1.75;
1744 
1745  xp[0] = boxinitx;
1746  yp[0] = boxinity;
1747  xp[1] = boxinitx + dx;
1748  yp[1] = boxinity;
1749  xp[2] = boxinitx + dx;
1750  yp[2] = boxinity + dy;
1751  xp[3] = boxinitx;
1752  yp[3] = boxinity + dy;
1753 
1754  for (int j = 0; j < 4; j++) {
1755  xd[j] = xdpixelpsu(xp[j]);
1756  yd[j] = ydpixelpsu(yp[j]);
1757  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1758  }
1759 
1760  char buffer[20];
1761  sprintf(buffer, "%X", psu->idex);
1762  std::string s = psu->textHV3;
1763  s.erase(s.begin() + s.find("connected"), s.end());
1764 
1765  if (psu->redHV3 < 0) { //use count to compute color
1766  if (psu->valueHV3 > 0) {
1767  float vals = psu->valueHV3;
1768  std::string nams = "nams_hv3";
1769 
1770  color = getcolor(psu->valueHV3, palette);
1771  redHV3 = (color >> 16) & 0xFF;
1772  greenHV3 = (color >> 8) & 0xFF;
1773  blueHV3 = (color) & 0xFF;
1774  if (!print_total)
1775  psu->valueHV3 = psu->valueHV3 * psu->countHV3; //restore mod->value
1776  if (temporary_file)
1777  *svgfile << nams << " " << vals << " " << redHV3 << " " << greenHV3 << " " << blueHV3 << " ";
1778  else
1779  *svgfile
1780  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV3 << "\" value=\"" << psu->valueHV3
1781  << "\" id=\"" << psu->idex * 10 + 3 << "\" cmodid=\"" << psu->cmodid_HV3
1782  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1783  "\" POS=\"easyCrate/easyBoard"
1784  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb(" << redHV3
1785  << "," << greenHV3 << "," << blueHV3 << ")\" points=\"";
1786  } else {
1787  if (temporary_file)
1788  *svgfile << 0 << " " << 255 << " " << 255 << " " << 255 << " ";
1789  else
1790  *svgfile
1791  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV3 << "\" value=\"" << psu->valueHV3
1792  << "\" id=\"" << psu->idex * 10 + 3 << "\" cmodid=\"" << psu->cmodid_HV3
1793  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1794  "\" POS=\"easyCrate/easyBoard "
1795  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s
1796  << " \" fill=\"white\" points=\"";
1797  }
1798  }
1799 
1800  else { //color defined with fillc
1801  if (psu->redHV3 > 255)
1802  psu->redHV3 = 255;
1803  if (psu->greenHV3 > 255)
1804  psu->greenHV3 = 255;
1805  if (psu->blueHV3 > 255)
1806  psu->blueHV3 = 255;
1807  if (temporary_file)
1808  *svgfile << 0 << " " << 0 << " " << psu->redHV3 << " " << psu->greenHV3 << " " << psu->blueHV3 << " ";
1809  else
1810  *svgfile
1811  << "<svg:polygon detid=\"" << psu->idex << "\" count=\"" << psu->countHV3 << "\" value=\"" << psu->valueHV3
1812  << "\" id=\"" << psu->idex * 10 + 3 << "\" cmodid=\"" << psu->cmodid_HV3
1813  << "\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""
1814  "\" POS=\"easyCrate/easyBoard "
1815  << psu->getPsuCrate() << "/" << psu->getPsuBoard() << " connected to " << s << " \" fill=\"rgb("
1816  << psu->redHV3 << "," << psu->greenHV3 << "," << psu->blueHV3 << ")\" points=\"";
1817  }
1818 
1819  if (temporary_file)
1820  *svgfile << np << " ";
1821  for (int k = 0; k < np; k++) {
1822  if (temporary_file)
1823  *svgfile << xd[k] << " " << yd[k] << " ";
1824  else
1825  *svgfile << xd[k] << "," << yd[k] << " ";
1826  }
1827  if (temporary_file)
1828  *svgfile << std::endl;
1829  else
1830  *svgfile << "\" />" << std::endl;
1831 }
1832 
1834  bool print_total, float minval, float maxval, std::string s, int width, int height) {
1835  if (enableFecProcessing) {
1837  std::vector<TPolyLine *> vp;
1838  TGaxis *axis = nullptr;
1839  size_t found = filetype.find_last_of('.');
1840  filetype = filetype.substr(found + 1);
1841  found = outputfilename.find_last_of('.');
1842  outputfilename = outputfilename.substr(0, found);
1843  temporary_file = true;
1844  if (filetype == "xml" || filetype == "svg")
1845  temporary_file = false;
1846  std::ostringstream outs;
1847  minvalue = minval;
1848  maxvalue = maxval;
1849  outs << outputfilename << ".coor";
1850  if (temporary_file)
1851  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1852  std::map<int, TmCcu *>::iterator i_ccu;
1853  std::multimap<TmCcu *, TmModule *>::iterator it;
1854  std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
1855  //Decide if we must use Module or Ccu value
1856  bool useCcuValue = false;
1857 
1858  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1859  TmCcu *ccu = i_ccu->second;
1860  if (ccu != nullptr) {
1861  if (ccu->count > 0 || ccu->red != -1) {
1862  useCcuValue = true;
1863  break;
1864  }
1865  }
1866  }
1867 
1868  if (!useCcuValue) //store mean of connected modules value{
1869  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1870  TmCcu *ccu = i_ccu->second;
1871  if (ccu != nullptr) {
1872  ret = fecModuleMap.equal_range(ccu);
1873  for (it = ret.first; it != ret.second; ++it) {
1874  if ((*it).second->count > 0) {
1875  ccu->value = ccu->value + (*it).second->value;
1876  ccu->count++;
1877  }
1878  }
1879  if (ccu->count > 0)
1880  ccu->value = ccu->value / ccu->count;
1881  if (ccu->nmod == 0) {
1882  ccu->red = 0;
1883  ccu->green = 0;
1884  ccu->blue = 0;
1885  }
1886  }
1887  }
1888 
1889  if (title.find("QTestAlarm") != std::string::npos) {
1890  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1891  TmCcu *ccu = i_ccu->second;
1892  if (ccu != nullptr) {
1893  ret = fecModuleMap.equal_range(ccu);
1894  ccu->red = 0;
1895  ccu->green = 255;
1896  ccu->blue = 0;
1897  for (it = ret.first; it != ret.second; ++it) {
1898  if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
1899  !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
1900  ccu->red = 255;
1901  ccu->green = 0;
1902  ccu->blue = 0;
1903  }
1904  }
1905  }
1906  }
1907  }
1908 
1909  if (!print_total) {
1910  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1911  TmCcu *ccu = i_ccu->second;
1912  if (ccu != nullptr) {
1913  if (useCcuValue)
1914  ccu->value = ccu->value / ccu->count;
1915  }
1916  }
1917  }
1918 
1919  if (minvalue >= maxvalue) {
1920  minvalue = 9999999.;
1921  maxvalue = -9999999.;
1922  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1923  TmCcu *ccu = i_ccu->second;
1924  if (ccu != nullptr && ccu->count > 0) {
1925  if (minvalue > ccu->value)
1926  minvalue = ccu->value;
1927  if (maxvalue < ccu->value)
1928  maxvalue = ccu->value;
1929  }
1930  }
1931  }
1932 
1933  if (filetype == "svg") {
1934  saveAsSingleLayer = false;
1935  std::ostringstream outs;
1936  outs << outputfilename << ".svg";
1937  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1938  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
1939  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
1940  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
1941  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
1942  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
1943  << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
1944  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
1945  << std::endl;
1946  *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" "
1947  "style=\"fill:none;stroke:black;stroke-width:0;\"> "
1948  << std::endl;
1949  }
1950  for (int crate = 1; crate < (nfeccrates + 1); crate++) {
1951  if (filetype == "xml") {
1952  saveAsSingleLayer = true;
1953  std::ostringstream outs;
1954  outs << outputfilename << "feccrate" << crate << ".xml";
1955  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
1956  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
1957  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
1958  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
1959  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
1960  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"feccrate.js\" />" << std::endl;
1961  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
1962  "onload=\"TrackerCrate.init()\">"
1963  << std::endl;
1964  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
1965  << std::endl;
1966  *savefile << "<g id=\"crate\" transform=\" translate(280,580) rotate(270) scale(.7,.8)\" > " << std::endl;
1967  }
1968  // ncrate=crate;
1970 
1971  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1972  TmCcu *ccu = i_ccu->second;
1973  if (ccu != nullptr) {
1974  if (ccu->getCcuCrate() == crate) {
1975  drawCcu(crate, ccu->getCcuSlot() - 2, print_total, ccu, savefile, useCcuValue);
1976  }
1977  }
1978  }
1979 
1980  if (!temporary_file) {
1981  if (filetype == "xml") {
1982  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
1983  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
1984  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
1985  *savefile << " </text> </svg>" << std::endl;
1986  savefile->close();
1987  saveAsSingleLayer = false;
1988  }
1989  }
1990  }
1991  if (filetype == "svg") {
1992  *savefile << "</g> </svg> </svg> " << std::endl;
1993  savefile->close();
1994  }
1995  if (!print_total && !useCcuValue) {
1996  //Restore ccu value
1997  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
1998  TmCcu *ccu = i_ccu->second;
1999  if (ccu != nullptr) {
2000  ccu->value = ccu->value * ccu->count;
2001  }
2002  }
2003  }
2004  if (temporary_file) {
2005  if (printflag && !saveWebInterface)
2007  savefile->close();
2008 
2009  float content;
2010  std::string named;
2011  const char *command1;
2012  std::string tempfilename = outputfilename + ".coor";
2013  int red, green, blue, npoints, colindex, ncolor;
2014  double x[4], y[4];
2015  std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2016  TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2017  gPad->SetFillColor(38);
2018 
2019  if (saveWebInterface)
2020  gPad->Range(0, 0, 3700, 1600);
2021  else
2022  gPad->Range(0, 0, 3800, 1600);
2023 
2024  //First build palette
2025  ncolor = 0;
2026  typedef std::map<int, int> ColorList;
2027  ColorList colorList;
2028  ColorList::iterator pos;
2029  TColor *col, *c;
2030  while (!tempfile.eof()) {
2031  tempfile >> named >> content >> red >> green >> blue >> npoints;
2032  colindex = red + green * 1000 + blue * 1000000;
2033  pos = colorList.find(colindex);
2034  if (pos == colorList.end()) {
2035  colorList[colindex] = ncolor + 100;
2036  col = gROOT->GetColor(ncolor + 100);
2037  if (col)
2038  col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2039  else {
2040  c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2041  vc.push_back(c);
2042  }
2043  ncolor++;
2044  }
2045  for (int i = 0; i < npoints; i++) {
2046  tempfile >> x[i] >> y[i];
2047  }
2048  }
2049  if (ncolor > 0 && ncolor < 10000) {
2050  Int_t colors[10000];
2051  for (int i = 0; i < ncolor; i++) {
2052  colors[i] = i + 100;
2053  }
2054  gStyle->SetPalette(ncolor, colors);
2055  }
2056  tempfile.clear();
2057  tempfile.seekg(0, std::ios::beg);
2058  std::cout << "created palette with " << ncolor << " colors" << std::endl;
2059  while (!tempfile.eof()) { //create polylines
2060  tempfile >> named >> content >> red >> green >> blue >> npoints;
2061  for (int i = 0; i < npoints; i++) {
2062  tempfile >> x[i] >> y[i];
2063  }
2064  colindex = red + green * 1000 + blue * 1000000;
2065  pos = colorList.find(colindex);
2066  if (pos != colorList.end()) {
2067  TPolyLine *pline = new TPolyLine(npoints, y, x);
2068  vp.push_back(pline);
2069  pline->SetFillColor(colorList[colindex]);
2070  pline->SetLineWidth(0);
2071  pline->Draw("f");
2072  }
2073  }
2074  if (printflag && !saveWebInterface) {
2075  float lminvalue = minvalue;
2076  float lmaxvalue = maxvalue;
2077  if (tkMapLog) {
2078  lminvalue = log(minvalue) / log(10);
2079  lmaxvalue = log(maxvalue) / log(10);
2080  }
2081  axis = new TGaxis(3660, 36, 3660, 1530, lminvalue, lmaxvalue, 510, "+L");
2082  axis->SetLabelSize(0.02);
2083  axis->Draw();
2084  }
2085 
2086  if (!saveWebInterface) {
2087  TLatex l;
2088  l.SetTextSize(0.05);
2089  std::string fulltitle = title;
2090  if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
2091  fulltitle += ": Log10 scale";
2092  l.DrawLatex(50, 1530, fulltitle.c_str());
2093  }
2094  MyC->Update();
2095  std::cout << "Filetype " << filetype << std::endl;
2096  if (filetype == "png") {
2097  std::string filename = outputfilename + ".png";
2098  MyC->Print(filename.c_str());
2099  }
2100  if (filetype == "jpg") {
2101  std::string filename = outputfilename + ".jpg";
2102  MyC->Print(filename.c_str());
2103  }
2104  if (filetype == "pdf") {
2105  std::string filename = outputfilename + ".pdf";
2106  MyC->Print(filename.c_str());
2107  }
2108  std::string command = "rm " + tempfilename;
2109  command1 = command.c_str();
2110  std::cout << "Executing " << command1 << std::endl;
2111  system(command1);
2112  MyC->Clear();
2113  delete MyC;
2114  if (printflag && !saveWebInterface)
2115  delete axis;
2116  for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
2117  delete (*pos1);
2118  }
2119 
2120  } //if(temporary_file)
2121  } //if(enabledFecProcessing)
2122 }
2124  bool print_total, float minval, float maxval, std::string s, int width, int height) {
2125  if (enableHVProcessing) {
2127  std::vector<TPolyLine *> vp;
2128  TGaxis *axis = nullptr;
2129  size_t found = filetype.find_last_of('.');
2130  filetype = filetype.substr(found + 1);
2131  found = outputfilename.find_last_of('.');
2132  outputfilename = outputfilename.substr(0, found);
2133 
2134  temporary_file = true;
2135 
2136  if (filetype == "xml" || filetype == "svg")
2137  temporary_file = false;
2138 
2139  std::ostringstream outs;
2140  minvalue = minval;
2141  maxvalue = maxval;
2142  outs << outputfilename << ".coor";
2143  if (temporary_file)
2144  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2145 
2146  std::map<int, TmPsu *>::iterator ipsu;
2147  std::multimap<TmPsu *, TmModule *>::iterator it;
2148  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
2149 
2150  bool usePsuValue = false;
2151 
2152  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2153  TmPsu *psu = ipsu->second;
2154  if (psu != nullptr) {
2155  if (psu->countHV2 > 0 || psu->redHV2 != -1 || psu->countHV3 > 0 || psu->redHV3 != -1) {
2156  usePsuValue = true;
2157  break;
2158  }
2159  }
2160  }
2161 
2162  if (!usePsuValue) { //store mean of connected modules value{
2163 
2164  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2165  TmPsu *psu = ipsu->second;
2166  if (psu != nullptr) {
2167  ret = psuModuleMap.equal_range(psu);
2168  int nconn1 = 0;
2169  int nconn2 = 0;
2170  for (it = ret.first; it != ret.second; ++it) {
2171  if ((*it).second->HVchannel == 2 && (*it).second->count > 0) {
2172  nconn1++;
2173  psu->valueHV2 = psu->valueHV2 + (*it).second->value;
2174  }
2175  if ((*it).second->HVchannel == 3 && (*it).second->count > 0) {
2176  nconn2++;
2177  psu->valueHV3 = psu->valueHV3 + (*it).second->value;
2178  }
2179  }
2180  if (psu->nmodHV2 != 0 && nconn1 > 0) {
2181  psu->valueHV2 = psu->valueHV2 / psu->nmodHV2;
2182  psu->countHV2 = 1;
2183  }
2184  if (psu->nmodHV3 != 0 && nconn2 > 0) {
2185  psu->valueHV3 = psu->valueHV3 / psu->nmodHV3;
2186  psu->countHV3 = 1;
2187  }
2188  }
2189  }
2190  }
2191 
2192  if (title.find("QTestAlarm") != std::string::npos) {
2193  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2194  TmPsu *psu = ipsu->second;
2195  if (psu != nullptr) {
2196  ret = psuModuleMap.equal_range(psu);
2197  psu->redHV2 = 0;
2198  psu->greenHV2 = 255;
2199  psu->blueHV2 = 0;
2200  psu->redHV3 = 0;
2201  psu->greenHV3 = 255;
2202  psu->blueHV3 = 0;
2203  for (it = ret.first; it != ret.second; ++it) {
2204  if ((*it).second->HVchannel == 2) {
2205  if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
2206  !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
2207  psu->redHV2 = 255;
2208  psu->greenHV2 = 0;
2209  psu->blueHV2 = 0;
2210  }
2211  }
2212  if ((*it).second->HVchannel == 3) {
2213  if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
2214  !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
2215  psu->redHV3 = 255;
2216  psu->greenHV3 = 0;
2217  psu->blueHV3 = 0;
2218  }
2219  }
2220  }
2221  }
2222  }
2223  }
2224 
2225  if (!print_total) {
2226  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2227  TmPsu *psu = ipsu->second;
2228  if (psu != nullptr) {
2229  if (usePsuValue) {
2230  psu->valueHV2 = psu->valueHV2 / psu->countHV2;
2231  psu->valueHV3 = psu->valueHV3 / psu->countHV3;
2232  }
2233  }
2234  }
2235  }
2236 
2237  if (minvalue >= maxvalue) {
2238  minvalue = 9999999.;
2239  maxvalue = -9999999.;
2240 
2241  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2242  TmPsu *psu = ipsu->second;
2243  if (psu != nullptr && psu->countHV2 > 0 && psu->countHV3 > 0) {
2244  if (minvalue > psu->valueHV2 || minvalue > psu->valueHV3)
2245  minvalue = std::min(psu->valueHV2, psu->valueHV3);
2246  if (maxvalue < psu->valueHV2 || maxvalue < psu->valueHV3)
2247  maxvalue = std::max(psu->valueHV2, psu->valueHV3);
2248  }
2249  }
2250  }
2251 
2252  if (filetype == "svg") {
2253  saveAsSingleLayer = false;
2254  std::ostringstream outs;
2255  outs << outputfilename << ".svg";
2256  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2257  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
2258  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2259  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
2260  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
2261  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
2262  << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
2263  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
2264  << std::endl;
2265  *savefile << "<svg:g id=\"HVtrackermap\" transform=\"translate(10,1500) rotate(270)\" "
2266  "style=\"fill:none;stroke:black;stroke-width:0;\"> "
2267  << std::endl;
2268  }
2269 
2270  for (int irack = 1; irack < (npsuracks + 1); irack++) {
2271  if (filetype == "xml") {
2272  saveAsSingleLayer = true;
2273  std::ostringstream outs;
2274  outs << outputfilename << "HVrack" << irack << ".xml";
2275  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2276  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
2277  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2278  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
2279  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
2280  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rackhv.js\" />" << std::endl;
2281  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
2282  "onload=\"TrackerRackhv.init()\">"
2283  << std::endl;
2284  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
2285  << std::endl;
2286  *savefile << "<g id=\"rackhv\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > " << std::endl;
2287  }
2288 
2289  // nrack=irack;
2290  defpsuwindow(irack);
2291  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2292  TmPsu *psu = ipsu->second;
2293  if (psu->getPsuRack() == irack) {
2294  drawHV2(irack, psu->getPsuCrate(), print_total, psu, savefile, usePsuValue);
2295  drawHV3(irack, psu->getPsuCrate(), print_total, psu, savefile, usePsuValue);
2296  }
2297  }
2298 
2299  if (!temporary_file) {
2300  if (filetype == "xml") {
2301  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2302  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2303  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2304  *savefile << " </text> </svg>" << std::endl;
2305  savefile->close();
2306  saveAsSingleLayer = false;
2307  }
2308  }
2309  }
2310  if (filetype == "svg") {
2311  *savefile << "</g> </svg> </svg> " << std::endl;
2312  savefile->close();
2313  }
2314 
2315  //Restore psu value
2316  if (!print_total && !usePsuValue) {
2317  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2318  TmPsu *psu = ipsu->second;
2319  if (psu != nullptr) {
2320  psu->valueHV2 = psu->valueHV2 * psu->countHV2;
2321  psu->valueHV3 = psu->valueHV3 * psu->countHV3;
2322  }
2323  }
2324  }
2325 
2326  if (temporary_file) {
2327  if (printflag && !saveWebInterface)
2329  savefile->close();
2330 
2331  float content;
2332  std::string named;
2333  const char *command1;
2334  std::string tempfilename = outputfilename + ".coor";
2335  int red, green, blue, npoints, colindex, ncolor;
2336  double x[4], y[4];
2337  std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2338  TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2339  gPad->SetFillColor(38);
2340 
2341  if (saveWebInterface)
2342  gPad->Range(0, 0, 3700, 1600);
2343  else
2344  gPad->Range(0, 0, 3800, 1600);
2345 
2346  //First build palette
2347  ncolor = 0;
2348  typedef std::map<int, int> ColorList;
2349  ColorList colorList;
2350  ColorList::iterator pos;
2351  TColor *col, *c;
2352  while (!tempfile.eof()) {
2353  tempfile >> named >> content >> red >> green >> blue >> npoints;
2354  colindex = red + green * 1000 + blue * 1000000;
2355  pos = colorList.find(colindex);
2356  if (pos == colorList.end()) {
2357  colorList[colindex] = ncolor + 100;
2358  col = gROOT->GetColor(ncolor + 100);
2359  if (col)
2360  col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2361  else {
2362  c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2363  vc.push_back(c);
2364  }
2365  ncolor++;
2366  }
2367  for (int i = 0; i < npoints; i++) {
2368  tempfile >> x[i] >> y[i];
2369  }
2370  }
2371  if (ncolor > 0 && ncolor < 10000) {
2372  Int_t colors[10000];
2373  for (int i = 0; i < ncolor; i++) {
2374  colors[i] = i + 100;
2375  }
2376  gStyle->SetPalette(ncolor, colors);
2377  }
2378  tempfile.clear();
2379  tempfile.seekg(0, std::ios::beg);
2380  std::cout << "created palette with " << ncolor << " colors" << std::endl;
2381  while (!tempfile.eof()) { //create polylines
2382  tempfile >> named >> content >> red >> green >> blue >> npoints;
2383  for (int i = 0; i < npoints; i++) {
2384  tempfile >> x[i] >> y[i];
2385  }
2386  colindex = red + green * 1000 + blue * 1000000;
2387  pos = colorList.find(colindex);
2388  if (pos != colorList.end()) {
2389  TPolyLine *pline = new TPolyLine(npoints, y, x);
2390  vp.push_back(pline);
2391  pline->SetFillColor(colorList[colindex]);
2392  pline->SetLineWidth(0);
2393  pline->Draw("f");
2394  }
2395  }
2396  if (printflag && !saveWebInterface) {
2397  float lminvalue = minvalue;
2398  float lmaxvalue = maxvalue;
2399  if (tkMapLog) {
2400  lminvalue = log(minvalue) / log(10);
2401  lmaxvalue = log(maxvalue) / log(10);
2402  }
2403  axis = new TGaxis(3660, 36, 3660, 1530, lminvalue, lmaxvalue, 510, "+L");
2404  axis->SetLabelSize(0.02);
2405  axis->Draw();
2406  }
2407 
2408  if (!saveWebInterface) {
2409  TLatex l;
2410  l.SetTextSize(0.05);
2411  std::string fulltitle = title;
2412  if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
2413  fulltitle += ": Log10 scale";
2414  l.DrawLatex(50, 1530, fulltitle.c_str());
2415  }
2416  MyC->Update();
2417  std::cout << "Filetype " << filetype << std::endl;
2418  if (filetype == "png") {
2419  std::string filename = outputfilename + ".png";
2420  MyC->Print(filename.c_str());
2421  }
2422  if (filetype == "jpg") {
2423  std::string filename = outputfilename + ".jpg";
2424  MyC->Print(filename.c_str());
2425  }
2426  if (filetype == "pdf") {
2427  std::string filename = outputfilename + ".pdf";
2428  MyC->Print(filename.c_str());
2429  }
2430  std::string command = "rm " + tempfilename;
2431  command1 = command.c_str();
2432  std::cout << "Executing " << command1 << std::endl;
2433  system(command1);
2434  MyC->Clear();
2435  delete MyC;
2436  if (printflag && !saveWebInterface)
2437  delete axis;
2438  for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
2439  delete (*pos1);
2440  }
2441 
2442  } //if(temporary_file)
2443  } //if(enabledHVProcessing)
2444 }
2445 
2447  bool print_total, float minval, float maxval, std::string s, int width, int height) {
2448  if (enableLVProcessing) {
2449  printflag = true;
2450  bool rangefound = true;
2452  std::vector<TPolyLine *> vp;
2453  TGaxis *axis = nullptr;
2454 
2455  size_t found = filetype.find_last_of('.');
2456  filetype = filetype.substr(found + 1);
2457  found = outputfilename.find_last_of('.');
2458  outputfilename = outputfilename.substr(0, found);
2459 
2460  temporary_file = true;
2461 
2462  if (filetype == "xml" || filetype == "svg")
2463  temporary_file = false;
2464 
2465  std::ostringstream outs;
2466  minvalue = minval;
2467  maxvalue = maxval;
2468  outs << outputfilename << ".coor";
2469  if (temporary_file)
2470  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2471 
2472  std::map<int, TmPsu *>::iterator ipsu;
2473  std::multimap<TmPsu *, TmModule *>::iterator it;
2474  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
2475 
2476  //Decide if we must use Module or Power Psupply value
2477  bool usePsuValue = false;
2478 
2479  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2480  TmPsu *psu = ipsu->second;
2481  if (psu != nullptr) {
2482  if (psu->count > 0 || psu->red != -1) {
2483  usePsuValue = true;
2484  break;
2485  }
2486  }
2487  }
2488 
2489  if (!usePsuValue) { //store mean of connected modules value{
2490  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2491  TmPsu *psu = ipsu->second;
2492  if (psu != nullptr) {
2493  ret = psuModuleMap.equal_range(psu);
2494  int nconn = 0;
2495  for (it = ret.first; it != ret.second; ++it) {
2496  if ((*it).second->count > 0) {
2497  nconn++;
2498  psu->value = psu->value + (*it).second->value;
2499  }
2500  }
2501  if (nconn > 0) {
2502  psu->value = psu->value / psu->nmod;
2503  psu->count = 1;
2504  }
2505  }
2506  }
2507  }
2508 
2509  if (title.find("QTestAlarm") != std::string::npos) {
2510  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2511  TmPsu *psu = ipsu->second;
2512  if (psu != nullptr) {
2513  ret = psuModuleMap.equal_range(psu);
2514  // psu->red=255;psu->green=255;psu->blue=255;
2515  psu->red = -1;
2516  int nconn = 0;
2517  for (it = ret.first; it != ret.second; ++it) {
2518  if (!((*it).second->red == 0 && (*it).second->green == 255 && (*it).second->blue == 0) &&
2519  !((*it).second->red == 255 && (*it).second->green == 255 && (*it).second->blue == 255)) {
2520  nconn++;
2521  psu->value++;
2522  }
2523  }
2524  if (nconn > 0) {
2525  psu->value = psu->value / psu->nmod;
2526  psu->count = 1;
2527  }
2528  }
2529  }
2530  }
2531 
2532  if (!print_total) {
2533  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2534  TmPsu *psu = ipsu->second;
2535  if (psu != nullptr) {
2536  if (usePsuValue)
2537  psu->value = psu->value / psu->count;
2538  }
2539  }
2540  }
2541 
2542  if (minvalue >= maxvalue) {
2543  minvalue = 9999999.;
2544  maxvalue = -9999999.;
2545  rangefound = false;
2546  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2547  TmPsu *psu = ipsu->second;
2548  if (psu != nullptr && psu->count > 0) {
2549  rangefound = true;
2550  if (minvalue > psu->value)
2551  minvalue = psu->value;
2552  if (maxvalue < psu->value)
2553  maxvalue = psu->value;
2554  }
2555  }
2556  }
2557  if ((maxvalue == minvalue) || !rangefound)
2558  printflag = false;
2559 
2560  if (filetype == "svg") {
2561  saveAsSingleLayer = false;
2562  std::ostringstream outs;
2563  outs << outputfilename << ".svg";
2564  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2565  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
2566  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2567  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
2568  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
2569  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
2570  << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
2571  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
2572  << std::endl;
2573  *savefile << "<svg:g id=\"psutrackermap\" transform=\"translate(10,1500) rotate(270)\" "
2574  "style=\"fill:none;stroke:black;stroke-width:0;\"> "
2575  << std::endl;
2576  }
2577 
2578  for (int irack = 1; irack < (npsuracks + 1); irack++) {
2579  if (filetype == "xml") {
2580  saveAsSingleLayer = true;
2581  std::ostringstream outs;
2582  outs << outputfilename << "psurack" << irack << ".xml";
2583  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2584  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
2585  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2586  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
2587  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
2588  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rack.js\" />" << std::endl;
2589  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
2590  "onload=\"TrackerCrate.init()\">"
2591  << std::endl;
2592  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
2593  << std::endl;
2594  *savefile << "<g id=\"rack\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > " << std::endl;
2595  }
2596 
2597  // nrack=irack;
2598  defpsuwindow(irack);
2599  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2600  TmPsu *psu = ipsu->second;
2601  if (psu->getPsuRack() == irack) {
2602  drawPsu(irack, psu->getPsuCrate(), print_total, psu, savefile, usePsuValue);
2603  }
2604  }
2605 
2606  if (!temporary_file) {
2607  if (filetype == "xml") {
2608  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2609  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2610  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2611  *savefile << " </text> </svg>" << std::endl;
2612  savefile->close();
2613  saveAsSingleLayer = false;
2614  }
2615  }
2616  }
2617  if (filetype == "svg") {
2618  *savefile << "</g> </svg> </svg> " << std::endl;
2619  savefile->close();
2620  }
2621 
2622  //Restore psu value
2623  if (!print_total && !usePsuValue) {
2624  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
2625  TmPsu *psu = ipsu->second;
2626  if (psu != nullptr) {
2627  psu->value = psu->value * psu->count;
2628  }
2629  }
2630  }
2631 
2632  int rangex = YPSUOFFSET + (YPSURSIZE + YPSUOFFSET) * NUMPSURACK_INROW + 300;
2633  int rangey = XPSUOFFSET + (XPSURSIZE + XPSUOFFSET) * NUMPSURACK_INCOLUMN + 300;
2634 
2635  if (temporary_file) {
2636  if (printflag && !saveWebInterface)
2637  drawPalette(savefile, rangex - 140, rangey - 100);
2638  savefile->close();
2639 
2640  float content;
2641  std::string named;
2642  const char *command1;
2643  std::string tempfilename = outputfilename + ".coor";
2644  int red, green, blue, npoints, colindex, ncolor;
2645  double x[4], y[4];
2646  std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2647  TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2648  gPad->SetFillColor(38);
2649 
2650  // if(saveWebInterface)gPad->Range(0,0,3700,1600); else gPad->Range(0,0,3800,1600);
2651  std::cout << " range x " << rangex << std::endl;
2652  std::cout << " range y " << rangey << std::endl;
2653  gPad->Range(0, 0, rangex, rangey);
2654 
2655  //First build palette
2656  ncolor = 0;
2657  typedef std::map<int, int> ColorList;
2658  ColorList colorList;
2659  ColorList::iterator pos;
2660  TColor *col, *c;
2661  while (!tempfile.eof()) {
2662  tempfile >> named >> content >> red >> green >> blue >> npoints;
2663  colindex = red + green * 1000 + blue * 1000000;
2664  pos = colorList.find(colindex);
2665  if (pos == colorList.end()) {
2666  colorList[colindex] = ncolor + 100;
2667  col = gROOT->GetColor(ncolor + 100);
2668  if (col)
2669  col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2670  else
2671  c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2672  vc.push_back(c);
2673  ncolor++;
2674  }
2675  for (int i = 0; i < npoints; i++) {
2676  tempfile >> x[i] >> y[i];
2677  }
2678  }
2679  if (ncolor > 0 && ncolor < 10000) {
2680  Int_t colors[10000];
2681  for (int i = 0; i < ncolor; i++) {
2682  colors[i] = i + 100;
2683  }
2684  gStyle->SetPalette(ncolor, colors);
2685  }
2686  tempfile.clear();
2687  tempfile.seekg(0, std::ios::beg);
2688  std::cout << "created palette with " << ncolor << " colors" << std::endl;
2689  while (!tempfile.eof()) { //create polylines
2690  tempfile >> named >> content >> red >> green >> blue >> npoints;
2691  for (int i = 0; i < npoints; i++) {
2692  tempfile >> x[i] >> y[i];
2693  }
2694  colindex = red + green * 1000 + blue * 1000000;
2695  pos = colorList.find(colindex);
2696  if (pos != colorList.end()) {
2697  TPolyLine *pline = new TPolyLine(npoints, y, x);
2698  vp.push_back(pline);
2699  pline->SetFillColor(colorList[colindex]);
2700  pline->SetLineWidth(0);
2701  pline->Draw("f");
2702  }
2703  }
2704  if (printflag && !saveWebInterface) {
2705  float lminvalue = minvalue;
2706  float lmaxvalue = maxvalue;
2707  if (tkMapLog) {
2708  lminvalue = log(minvalue) / log(10);
2709  lmaxvalue = log(maxvalue) / log(10);
2710  }
2711  axis = new TGaxis(rangex - 140, 34, rangex - 140, rangey - 106, lminvalue, lmaxvalue, 510, "+L");
2712  axis->SetLabelSize(0.02);
2713  axis->Draw();
2714  }
2715 
2716  if (!saveWebInterface) {
2717  TLatex l;
2718  l.SetTextSize(0.05);
2719  std::string fulltitle = title;
2720  if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
2721  fulltitle += ": Log10 scale";
2722  l.DrawLatex(50, rangey - 200, fulltitle.c_str());
2723  }
2724  MyC->Update();
2725  std::cout << "Filetype " << filetype << std::endl;
2726  if (filetype == "png") {
2727  std::string filename = outputfilename + ".png";
2728  MyC->Print(filename.c_str());
2729  }
2730  if (filetype == "jpg") {
2731  std::string filename = outputfilename + ".jpg";
2732  MyC->Print(filename.c_str());
2733  }
2734  if (filetype == "pdf") {
2735  std::string filename = outputfilename + ".pdf";
2736  MyC->Print(filename.c_str());
2737  }
2738  std::string command = "rm " + tempfilename;
2739  command1 = command.c_str();
2740  std::cout << "Executing " << command1 << std::endl;
2741  system(command1);
2742  MyC->Clear();
2743  delete MyC;
2744  if (printflag && !saveWebInterface)
2745  delete axis;
2746  for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
2747  delete (*pos1);
2748  }
2749 
2750  } //if(temporary_file)
2751  } //if(enabledFedProcessing)
2752 }
2753 
2755  bool print_total, float minval, float maxval, std::string s, int width, int height) {
2756  if (enableFedProcessing) {
2757  printflag = true;
2758  bool rangefound = true;
2760  std::vector<TPolyLine *> vp;
2761  TGaxis *axis = nullptr;
2762 
2763  size_t found = filetype.find_last_of('.');
2764  filetype = filetype.substr(found + 1);
2765  found = outputfilename.find_last_of('.');
2766  outputfilename = outputfilename.substr(0, found);
2767 
2768  temporary_file = true;
2769  if (filetype == "xml" || filetype == "svg")
2770  temporary_file = false;
2771  std::ostringstream outs;
2772  minvalue = minval;
2773  maxvalue = maxval;
2774  outs << outputfilename << ".coor";
2775  if (temporary_file)
2776  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2777  std::map<int, TmApvPair *>::iterator i_apv;
2778  std::map<int, int>::iterator i_fed;
2779  //Decide if we must use Module or ApvPair value
2780  bool useApvPairValue = false;
2781  for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2782  TmApvPair *apvPair = i_apv->second;
2783  if (apvPair != nullptr) {
2784  TmModule *apv_mod = apvPair->mod;
2785  if (apv_mod != nullptr && !apv_mod->notInUse()) {
2786  if (apvPair->count > 0 || apvPair->red != -1) {
2787  useApvPairValue = true;
2788  break;
2789  }
2790  }
2791  }
2792  }
2793  if (!print_total) {
2794  for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2795  TmApvPair *apvPair = i_apv->second;
2796  if (apvPair != nullptr) {
2797  TmModule *apv_mod = apvPair->mod;
2798  if (apv_mod != nullptr && !apv_mod->notInUse()) {
2799  if (useApvPairValue)
2800  apvPair->value = apvPair->value / apvPair->count;
2801  else if (apvPair->mpos == 0 && apv_mod->count > 0)
2802  apv_mod->value = apv_mod->value / apv_mod->count;
2803  }
2804  }
2805  }
2806  }
2807  if (minvalue >= maxvalue) {
2808  minvalue = 9999999.;
2809  maxvalue = -9999999.;
2810  rangefound = false;
2811  for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2812  TmApvPair *apvPair = i_apv->second;
2813  if (apvPair != nullptr) {
2814  TmModule *apv_mod = apvPair->mod;
2815  if (apv_mod != nullptr && !apv_mod->notInUse()) {
2816  if (useApvPairValue) {
2817  rangefound = true;
2818  if (minvalue > apvPair->value)
2819  minvalue = apvPair->value;
2820  if (maxvalue < apvPair->value)
2821  maxvalue = apvPair->value;
2822  } else {
2823  if (apv_mod->count > 0) {
2824  rangefound = true;
2825  if (minvalue > apv_mod->value)
2826  minvalue = apv_mod->value;
2827  if (maxvalue < apv_mod->value)
2828  maxvalue = apv_mod->value;
2829  }
2830  }
2831  }
2832  }
2833  }
2834  }
2835  if ((title.find("QTestAlarm") != std::string::npos) || (maxvalue == minvalue) || !rangefound)
2836  printflag = false;
2837 
2838  if (filetype == "svg") {
2839  saveAsSingleLayer = false;
2840  std::ostringstream outs;
2841  outs << outputfilename << ".svg";
2842  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2843  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>" << std::endl;
2844  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2845  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" " << std::endl;
2846  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
2847  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"
2848  << "\" width=\"" << width << "\" height=\"" << height << "\">" << std::endl;
2849  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "
2850  << std::endl;
2851  *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" "
2852  "style=\"fill:none;stroke:black;stroke-width:0;\"> "
2853  << std::endl;
2854  }
2855  for (int crate = firstcrate; crate < (ncrates + 1); crate++) {
2856  if (filetype == "xml") {
2857  saveAsSingleLayer = true;
2858  std::ostringstream outs;
2859  outs << outputfilename << "crate" << crate << ".xml";
2860  savefile = new std::ofstream(outs.str().c_str(), std::ios::out);
2861  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
2862  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
2863  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
2864  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
2865  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"crate.js\" />" << std::endl;
2866  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
2867  "onload=\"TrackerCrate.init()\">"
2868  << std::endl;
2869  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"
2870  << std::endl;
2871  *savefile << "<g id=\"crate\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > " << std::endl;
2872  }
2873  // ncrate=crate;
2874  defcwindow(crate);
2875  int numfed_incrate = 0;
2876  for (i_fed = fedMap.begin(); i_fed != fedMap.end(); i_fed++) {
2877  if (i_fed->second == crate) {
2878  int fedId = i_fed->first;
2879  // numfed_incrate++;
2880  numfed_incrate = slotMap[fedId];
2881  // the following piece of code is used to prepare the HTML clickable map
2882  /*
2883  double scalex=6285./6290.;
2884  double scaley=3510./3540.;
2885  double boxinitix=(NUMFED_INCOLUMN-1-(numfed_incrate-1)/NUMFED_INROW)*(NUMFEDCH_INCOLUMN+2)+NUMFEDCH_INCOLUMN+0.9;
2886  double boxinitiy=(NUMFED_INROW-1-(numfed_incrate-1)%NUMFED_INROW)*(NUMFEDCH_INROW+1)+NUMFEDCH_INROW+0.9;
2887  double boxendix=boxinitix-(NUMFEDCH_INCOLUMN-1)-0.9;
2888  double boxendiy=boxinitiy-(NUMFEDCH_INROW-1)-0.9;
2889 
2890  std::cout << "<area shape=\"rect\" coords=\" "
2891  << int(scalex*ydpixelc(boxinitiy)) << "," << int(3510-scaley*xdpixelc(boxinitix))
2892  << "," << int(scalex*ydpixelc(boxendiy)) << "," << int(3510-scaley*xdpixelc(boxendix))
2893  << "\" href=\"\" title=\"crate " << crate << " slot " << numfed_incrate << " FED " << fedId << "\" /> " << std::endl;
2894  */
2895  //
2896  for (int nconn = 0; nconn < 96; nconn++) {
2897  int key = fedId * 1000 + nconn;
2898  TmApvPair *apvPair = apvMap[key];
2899  if (apvPair != nullptr) {
2900  TmModule *apv_mod = apvPair->mod;
2901  if (apv_mod != nullptr && !apv_mod->notInUse()) {
2902  drawApvPair(crate, numfed_incrate, print_total, apvPair, savefile, useApvPairValue);
2903  }
2904  }
2905  }
2906  }
2907  }
2908  if (!temporary_file) {
2909  if (filetype == "xml") {
2910  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2911  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2912  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2913  *savefile << " </text> </svg>" << std::endl;
2914  savefile->close();
2915  delete savefile;
2916  saveAsSingleLayer = false;
2917  }
2918  }
2919  }
2920  if (filetype == "svg") {
2921  *savefile << "</g> </svg> </svg> " << std::endl;
2922  savefile->close();
2923  delete savefile;
2924  }
2925  if (!print_total && !useApvPairValue) {
2926  //Restore module value
2927  for (i_apv = apvMap.begin(); i_apv != apvMap.end(); i_apv++) {
2928  TmApvPair *apvPair = i_apv->second;
2929  if (apvPair != nullptr) {
2930  TmModule *apv_mod = apvPair->mod;
2931  if (apv_mod != nullptr && apvPair->mpos == 0 && !apv_mod->notInUse()) {
2932  apv_mod->value = apv_mod->value * apv_mod->count;
2933  }
2934  }
2935  }
2936  }
2937 
2938  int rangex = YFEDOFFSET + (YFEDCSIZE + YFEDOFFSET) * NUMFEDCRATE_INROW + 300;
2939  int rangey = XFEDOFFSET + (XFEDCSIZE + XFEDOFFSET) * NUMFEDCRATE_INCOLUMN + 300;
2940 
2941  if (temporary_file) {
2942  if (printflag && !saveWebInterface)
2943  drawPalette(savefile, rangex - 140, rangey - 100);
2944  savefile->close();
2945  delete savefile;
2946 
2947  float content;
2948  std::string named;
2949  const char *command1;
2950  std::string tempfilename = outputfilename + ".coor";
2951  int red, green, blue, npoints, colindex, ncolor;
2952  double x[4], y[4];
2953  std::ifstream tempfile(tempfilename.c_str(), std::ios::in);
2954  TCanvas *MyC = new TCanvas("MyC", "TrackerMap", width, height);
2955  gPad->SetFillColor(38);
2956 
2957  // if(saveWebInterface)gPad->Range(0,0,3750,1600); else gPad->Range(0,0,3800,1600);
2958  std::cout << " range x " << rangex << std::endl;
2959  std::cout << " range y " << rangey << std::endl;
2960  gPad->Range(0, 0, rangex, rangey);
2961 
2962  //First build palette
2963  ncolor = 0;
2964  typedef std::map<int, int> ColorList;
2965  ColorList colorList;
2966  ColorList::iterator pos;
2967  TColor *col, *c;
2968  while (!tempfile.eof()) {
2969  tempfile >> named >> content >> red >> green >> blue >> npoints;
2970  colindex = red + green * 1000 + blue * 1000000;
2971  pos = colorList.find(colindex);
2972  if (pos == colorList.end()) {
2973  colorList[colindex] = ncolor + 100;
2974  col = gROOT->GetColor(ncolor + 100);
2975  if (col)
2976  col->SetRGB((Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2977  else
2978  c = new TColor(ncolor + 100, (Double_t)(red / 255.), (Double_t)(green / 255.), (Double_t)(blue / 255.));
2979  vc.push_back(c);
2980  ncolor++;
2981  }
2982  for (int i = 0; i < npoints; i++) {
2983  tempfile >> x[i] >> y[i];
2984  }
2985  }
2986  if (ncolor > 0 && ncolor < 10000) {
2987  Int_t colors[10000];
2988  for (int i = 0; i < ncolor; i++) {
2989  colors[i] = i + 100;
2990  }
2991  gStyle->SetPalette(ncolor, colors);
2992  }
2993  tempfile.clear();
2994  tempfile.seekg(0, std::ios::beg);
2995  std::cout << "created palette with " << ncolor << " colors" << std::endl;
2996  while (!tempfile.eof()) { //create polylines
2997  tempfile >> named >> content >> red >> green >> blue >> npoints;
2998  for (int i = 0; i < npoints; i++) {
2999  tempfile >> x[i] >> y[i];
3000  }
3001  colindex = red + green * 1000 + blue * 1000000;
3002  pos = colorList.find(colindex);
3003  if (pos != colorList.end()) {
3004  TPolyLine *pline = new TPolyLine(npoints, y, x);
3005  vp.push_back(pline);
3006  pline->SetFillColor(colorList[colindex]);
3007  pline->SetLineWidth(0);
3008  pline->Draw("f");
3009  }
3010  }
3011  if (printflag && !saveWebInterface) {
3012  float lminvalue = minvalue;
3013  float lmaxvalue = maxvalue;
3014  if (tkMapLog) {
3015  lminvalue = log(minvalue) / log(10);
3016  lmaxvalue = log(maxvalue) / log(10);
3017  }
3018  axis = new TGaxis(rangex - 140, 34, rangex - 140, rangey - 106, lminvalue, lmaxvalue, 510, "+L");
3019  axis->SetLabelSize(0.02);
3020  axis->Draw();
3021  }
3022 
3023  if (!saveWebInterface) {
3024  TLatex l;
3025  l.SetTextSize(0.05);
3026  std::string fulltitle = title;
3027  if (tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos))
3028  fulltitle += ": Log10 scale";
3029  l.DrawLatex(50, rangey - 200, fulltitle.c_str());
3030  }
3031  MyC->Update();
3032  std::cout << "Filetype " << filetype << std::endl;
3033  if (filetype == "png") {
3034  std::string filename = outputfilename + ".png";
3035  MyC->Print(filename.c_str());
3036  }
3037  if (filetype == "jpg") {
3038  std::string filename = outputfilename + ".jpg";
3039  MyC->Print(filename.c_str());
3040  }
3041  if (filetype == "pdf") {
3042  std::string filename = outputfilename + ".pdf";
3043  MyC->Print(filename.c_str());
3044  }
3045  std::string command = "rm " + tempfilename;
3046  command1 = command.c_str();
3047  std::cout << "Executing " << command1 << std::endl;
3048  system(command1);
3049  MyC->Clear();
3050  delete MyC;
3051  if (printflag && !saveWebInterface)
3052  delete axis;
3053  for (std::vector<TPolyLine *>::iterator pos1 = vp.begin(); pos1 != vp.end(); pos1++) {
3054  delete (*pos1);
3055  }
3056 
3057  } //if(temporary_file)
3058  } //if(enabledFedProcessing)
3059 }
3060 
3061 void TrackerMap::load(std::string inputfilename) {
3062  inputfile = new std::ifstream(inputfilename.c_str(), std::ios::in);
3064  int ipos, ipos1, ipos2, id = 0, val = 0;
3065  int nline = 0;
3066  while (getline(*inputfile, line)) {
3067  ipos1 = line.find("value=\"");
3068  if (ipos1 > 0) {
3069  value = line.substr(ipos1 + 7, 10);
3070  ipos = value.find('\"');
3071  value = value.substr(0, ipos);
3072  val = atoi(value.c_str());
3073  }
3074  ipos2 = line.find("detid=\"");
3075  if (ipos2 > 0) {
3076  value = line.substr(ipos2 + 7, 10);
3077  ipos = value.find('\"');
3078  value = value.substr(0, ipos);
3079  id = atoi(value.c_str());
3080  }
3081  if (ipos1 > 0 && ipos2 > 0 && val > 0)
3082  this->fill(id, val);
3083  if (ipos1 > 0 && ipos2 > 0)
3084  nline++;
3085  //if(ipos1>0 && ipos2>0)std::cout << nline << " " << id << " " << val << std::endl;
3086  }
3087  std::cout << nline << " modules found in this svg file " << std::endl;
3088  inputfile->close();
3089  delete inputfile;
3090 }
3091 
3092 //print in svg format tracker map
3093 //print_total = true represent in color the total stored in the module
3094 //print_total = false represent in color the average
3095 void TrackerMap::print(bool print_total, float minval, float maxval, std::string outputfilename) {
3096  temporary_file = false;
3097  std::ostringstream outs;
3098  minvalue = minval;
3099  maxvalue = maxval;
3100  outs << outputfilename << ".xml";
3101  svgfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3102  jsfile = new std::ifstream(edm::FileInPath(jsfilename).fullPath().c_str(), std::ios::in);
3103 
3104  //copy javascript interface from trackermap.txt file
3105  std::string line;
3106  while (getline(*jsfile, line)) {
3107  *svgfile << line << std::endl;
3108  }
3109  jsfile->close();
3110  delete jsfile;
3111  //
3112  if (!print_total) {
3113  for (int layer = 1; layer < 44; layer++) {
3114  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
3115  for (int module = 1; module < 200; module++) {
3116  int key = layer * 100000 + ring * 1000 + module;
3117  TmModule *mod = smoduleMap[key];
3118  if (mod != nullptr && !mod->notInUse()) {
3119  mod->value = mod->value / mod->count;
3120  }
3121  }
3122  }
3123  }
3124  }
3125  if (minvalue >= maxvalue) {
3126  minvalue = 9999999.;
3127  maxvalue = -9999999.;
3128  for (int layer = 1; layer < 44; layer++) {
3129  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
3130  for (int module = 1; module < 200; module++) {
3131  int key = layer * 100000 + ring * 1000 + module;
3132  TmModule *mod = smoduleMap[key];
3133  if (mod != nullptr && !mod->notInUse()) {
3134  if (minvalue > mod->value)
3135  minvalue = mod->value;
3136  if (maxvalue < mod->value)
3137  maxvalue = mod->value;
3138  }
3139  }
3140  }
3141  }
3142  }
3143  for (int layer = 1; layer < 44; layer++) {
3144  // nlay=layer;
3145  defwindow(layer);
3146  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
3147  for (int module = 1; module < 200; module++) {
3148  int key = layer * 100000 + ring * 1000 + module;
3149  TmModule *mod = smoduleMap[key];
3150  if (mod != nullptr && !mod->notInUse()) {
3151  drawModule(mod, key, layer, print_total, svgfile);
3152  }
3153  }
3154  }
3155  }
3156  *svgfile << "</svg:g></svg:svg>" << std::endl;
3157  *svgfile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">" << title << "</svg:text>" << std::endl;
3158  if (printflag)
3160  *svgfile << "</svg:svg>" << std::endl;
3161  *svgfile << "</body></html>" << std::endl;
3162  svgfile->close();
3163  delete svgfile;
3164 }
3165 
3166 void TrackerMap::drawPalette(std::ofstream *svgfile, int xoffset, int yoffset) {
3167  std::cout << "preparing the palette" << std::endl;
3168 
3169  int color, red, green, blue;
3170  float val = minvalue;
3171  int paletteLength = 250;
3172  int width = 50 * (yoffset - 40) / 1500;
3173  float dval = (maxvalue - minvalue) / (float)paletteLength;
3174  bool rtkMapLog = tkMapLog;
3175  if (tkMapLog)
3176  tkMapLog = false;
3177  float step = float(yoffset - 40) / float(paletteLength);
3178  for (int i = 1; i < paletteLength + 1; i++) {
3179  color = getcolor(val, palette);
3180  red = (color >> 16) & 0xFF;
3181  green = (color >> 8) & 0xFF;
3182  blue = (color) & 0xFF;
3183  // if(!temporary_file)*svgfile <<"<svg:rect x=\"3010\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"6\" fill=\"rgb("<<red<<","<<green<<","<<blue<<")\" />\n";
3184  // else *svgfile << red << " " << green << " " << blue << " 4 " << (6*i)+40 << " 3010. " <<//
3185  // (6*i)+40 << " 3060. " <<//
3186  // (6*(i-1))+40 << " 3060. " <<//
3187  // (6*(i-1))+40 <<" 3010. " << std::endl; //
3188 
3189  // if(i%50 == 0){
3190  // if(!temporary_file)*svgfile <<"<svg:rect x=\"3010\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"1\" fill=\"black\" />\n";
3191  // if(i%50==0&&!temporary_file)*svgfile << " <svg:text class=\"normalText\" x=\"3060\" y=\""<<(1560-6*i)<<"\">" <<val<<"</svg:text>"<<std::endl;
3192 
3193  if (!temporary_file)
3194  *svgfile << "<svg:rect x=\"3610\" y=\"" << (1550 - 6 * i) << "\" width=\"50\" height=\"6\" fill=\"rgb(" << red
3195  << "," << green << "," << blue << ")\" />\n";
3196  else
3197  *svgfile << 0 << " " << 0 << " " << red << " " << green << " " << blue << " 4 " << int(step * i) + 34 << " "
3198  << xoffset - width << ". " << //
3199  int(step * i) + 34 << " " << xoffset << ". " << //
3200  int(step * (i - 1)) + 34 << " " << xoffset << ". " << //
3201  int(step * (i - 1)) + 34 << " " << xoffset - width << ". " << std::endl; //
3202 
3203  if (i % 50 == 0) {
3204  if (!temporary_file)
3205  *svgfile << "<svg:rect x=\"3610\" y=\"" << (1550 - 6 * i)
3206  << "\" width=\"50\" height=\"1\" fill=\"black\" />\n";
3207  if (i % 50 == 0 && !temporary_file)
3208  *svgfile << " <svg:text class=\"normalText\" x=\"3660\" y=\"" << (1560 - 6 * i) << "\">" << val
3209  << "</svg:text>" << std::endl;
3210  }
3211  val = val + dval;
3212  }
3213  tkMapLog = rtkMapLog;
3214 }
3215 void TrackerMap::fillc_fed_channel(int fedId, int fedCh, int red, int green, int blue) {
3216  int key = fedId * 1000 + fedCh;
3217  TmApvPair *apvpair = apvMap[key];
3218 
3219  if (apvpair != nullptr) {
3220  apvpair->red = red;
3221  apvpair->green = green;
3222  apvpair->blue = blue;
3223  return;
3224  }
3225  std::cout << "*** error in FedTrackerMap fillc method ***";
3226 }
3227 
3228 void TrackerMap::fill_fed_channel(int idmod, float qty) {
3229  std::multimap<const int, TmApvPair *>::iterator pos;
3230  for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
3231  TmApvPair *apvpair = pos->second;
3232  if (apvpair != nullptr) {
3233  apvpair->value = apvpair->value + qty;
3234  apvpair->count++;
3235  }
3236  }
3237  return;
3238  std::cout << "*** error in FedTrackerMap fill by module method ***";
3239 }
3240 
3241 void TrackerMap::fill_current_val_fed_channel(int fedId, int fedCh, float current_val) {
3242  int key = fedId * 1000 + fedCh;
3243  TmApvPair *apvpair = apvMap[key];
3244 
3245  if (apvpair != nullptr) {
3246  apvpair->value = current_val;
3247  apvpair->count = 1;
3248  apvpair->red = -1;
3249  } else
3250  std::cout << "*** error in FedTrackerMap fill_current_val method ***";
3251 }
3252 
3253 void TrackerMap::fillc_fec_channel(int crate, int slot, int ring, int addr, int red, int green, int blue) {
3254  int key = crate * 10000000 + slot * 100000 + ring * 1000 + addr;
3255 
3256  TmCcu *ccu = ccuMap[key];
3257 
3258  if (ccu != nullptr) {
3259  ccu->red = red;
3260  ccu->green = green;
3261  ccu->blue = blue;
3262  return;
3263  }
3264  std::cout << "*** error in FecTrackerMap fillc method ***";
3265 }
3266 
3267 void TrackerMap::fill_fec_channel(int crate, int slot, int ring, int addr, float qty) {
3268  int key = crate * 10000000 + slot * 100000 + ring * 1000 + addr;
3269  TmCcu *ccu = ccuMap[key];
3270  if (ccu != nullptr) {
3271  ccu->count++;
3272  ccu->value = ccu->value + qty;
3273  return;
3274  }
3275 
3276  std::cout << "*** error in FecTrackerMap fill by module method ***";
3277 }
3278 
3279 void TrackerMap::fillc_lv_channel(int rack, int crate, int board, int red, int green, int blue) {
3280  int key = rack * 1000 + crate * 100 + board;
3281 
3282  TmPsu *psu = psuMap[key];
3283 
3284  if (psu != nullptr) {
3285  psu->red = red;
3286  psu->green = green;
3287  psu->blue = blue;
3288  return;
3289  }
3290  std::cout << "*** error in LVTrackerMap fillc method ***";
3291 }
3292 
3293 void TrackerMap::fill_lv_channel(int rack, int crate, int board, float qty) {
3294  int key = rack * 1000 + crate * 100 + board;
3295  TmPsu *psu = psuMap[key];
3296  if (psu != nullptr) {
3297  psu->count++;
3298  psu->value = psu->value + qty;
3299  return;
3300  }
3301 
3302  std::cout << "*** error in LVTrackerMap fill by module method ***";
3303 }
3304 
3305 void TrackerMap::fillc_hv_channel2(int rack, int crate, int board, int red, int green, int blue) {
3306  int key = rack * 1000 + crate * 100 + board;
3307 
3308  TmPsu *psu = psuMap[key];
3309 
3310  if (psu != nullptr) {
3311  psu->redHV2 = red;
3312  psu->greenHV2 = green;
3313  psu->blueHV2 = blue;
3314  return;
3315  }
3316  std::cout << "*** error in HVTrackerMap (channel 2) fillc method ***";
3317 }
3318 void TrackerMap::fillc_hv_channel3(int rack, int crate, int board, int red, int green, int blue) {
3319  int key = rack * 1000 + crate * 100 + board;
3320 
3321  TmPsu *psu = psuMap[key];
3322 
3323  if (psu != nullptr) {
3324  psu->redHV3 = red;
3325  psu->greenHV3 = green;
3326  psu->blueHV3 = blue;
3327  return;
3328  }
3329  std::cout << "*** error in HVTrackerMap (channel 3) fillc method ***";
3330 }
3331 
3332 void TrackerMap::fill_hv_channel2(int rack, int crate, int board, float qty) {
3333  int key = rack * 1000 + crate * 100 + board;
3334  TmPsu *psu = psuMap[key];
3335  if (psu != nullptr) {
3336  psu->countHV2++;
3337  psu->valueHV2 = psu->valueHV2 + qty;
3338  return;
3339  }
3340 
3341  std::cout << "*** error in HVTrackerMap fill by module method ***";
3342 }
3343 void TrackerMap::fill_hv_channel3(int rack, int crate, int board, float qty) {
3344  int key = rack * 1000 + crate * 100 + board;
3345  TmPsu *psu = psuMap[key];
3346  if (psu != nullptr) {
3347  psu->countHV3++;
3348  psu->valueHV3 = psu->valueHV3 + qty;
3349  return;
3350  }
3351 
3352  std::cout << "*** error in HVTrackerMap fill by module method ***";
3353 }
3354 
3355 int TrackerMap::module(int fedId, int fedCh) {
3356  int key = fedId * 1000 + fedCh;
3357  TmApvPair *apvpair = apvMap[key];
3358  if (apvpair != nullptr) {
3359  return (apvpair->mod->idex);
3360  }
3361  return (0);
3362 }
3363 void TrackerMap::fill_fed_channel(int fedId, int fedCh, float qty) {
3364  int key = fedId * 1000 + fedCh;
3365  TmApvPair *apvpair = apvMap[key];
3366  if (apvpair != nullptr) {
3367  apvpair->value = apvpair->value + qty;
3368  apvpair->count++;
3369  return;
3370  }
3371  std::cout << "*** error inFedTrackerMap fill method ***";
3372 }
3373 
3374 void TrackerMap::fillc(int idmod, int red, int green, int blue) {
3376  if (mod != nullptr) {
3377  mod->red = red;
3378  mod->green = green;
3379  mod->blue = blue;
3380  return;
3381  }
3382  std::cout << "**************************error in fill method **************module " << idmod << std::endl;
3383 }
3384 void TrackerMap::fillc(int layer, int ring, int nmod, int red, int green, int blue) {
3385  int key = layer * 10000 + ring * 1000 + nmod;
3386  TmModule *mod = smoduleMap[key];
3387 
3388  if (mod != nullptr) {
3389  mod->red = red;
3390  mod->green = green;
3391  mod->blue = blue;
3392  return;
3393  }
3394  std::cout << "**************************error in fill method **************" << std::endl;
3395 }
3396 
3398  std::map<const int, TmModule *>::iterator imod;
3399  for (imod = imoduleMap.begin(); imod != imoduleMap.end(); imod++) {
3400  fillc(imod->first, 255, 255, 255);
3401  }
3402 }
3403 
3405  std::map<const int, TmModule *>::iterator imod;
3406  for (imod = imoduleMap.begin(); imod != imoduleMap.end(); imod++) {
3407  fill_current_val(imod->first, 0);
3408  }
3409 }
3410 
3411 void TrackerMap::fill_current_val(int idmod, float current_val) {
3413  if (mod != nullptr) {
3414  mod->value = current_val;
3415  mod->count = 1;
3416  mod->red = -1;
3417  } else
3418  std::cout << "**error in fill_current_val method ***module " << idmod << std::endl;
3419 }
3420 
3421 void TrackerMap::fill(int idmod, float qty) {
3423  if (mod != nullptr) {
3424  mod->value = mod->value + qty;
3425  mod->count++;
3426  return;
3427  } else {
3428  TmModule *mod1 = imoduleMap[idmod + 1];
3429  TmModule *mod2 = imoduleMap[idmod + 2];
3430  if (mod1 != nullptr && mod2 != nullptr) {
3431  mod1->value = mod1->value + qty;
3432  mod1->count++;
3433  mod2->value = mod2->value + qty;
3434  mod2->count++;
3435  return;
3436  }
3437  }
3438  std::cout << "**************************error in fill method **************module " << idmod << std::endl;
3439 }
3440 
3441 void TrackerMap::fill(int layer, int ring, int nmod, float qty) {
3442  int key = layer * 100000 + ring * 1000 + nmod;
3443  TmModule *mod = smoduleMap[key];
3444  if (mod != nullptr) {
3445  mod->value = mod->value + qty;
3446  mod->count++;
3447  } else
3448  std::cout << "**************************error in SvgModuleMap **************";
3449 }
3450 
3453  if (mod != nullptr) {
3454  mod->text = s;
3455  } else
3456  std::cout << "**************************error in IdModuleMap **************";
3457 }
3458 
3459 void TrackerMap::setText(int layer, int ring, int nmod, std::string s) {
3460  int key = layer * 100000 + ring * 1000 + nmod;
3461  TmModule *mod = smoduleMap[key];
3462  if (mod != nullptr) {
3463  mod->text = s;
3464  } else
3465  std::cout << "**************************error in SvgModuleMap **************";
3466 }
3467 
3469  // std::ifstream* infile;
3470 
3471  int nmods, pix_sil, fow_bar, ring, nmod, layer;
3472  unsigned int idex;
3473  float posx, posy, posz, length, width, thickness, widthAtHalfLength;
3474  int old_layer = 0, ntotMod = 0;
3475  std::string name, dummys;
3476  std::ifstream infile(edm::FileInPath(infilename).fullPath().c_str(), std::ios::in);
3477  while (!infile.eof()) {
3478  infile >> nmods >> pix_sil >> fow_bar >> layer >> ring >> nmod >> posx >> posy >> posz >> length >> width >>
3479  thickness >> widthAtHalfLength >> idex;
3480  getline(infile, dummys); //necessary to reach end of record
3481  getline(infile, name);
3482  if (old_layer != layer) {
3483  old_layer = layer;
3484  }
3485  ntotMod++;
3486  int key = layer * 100000 + ring * 1000 + nmod;
3487  TmModule *mod = smoduleMap[key];
3488 
3489  imoduleMap[idex] = mod;
3490 
3491  if (mod == nullptr)
3492  std::cout << "error in module " << key << std::endl;
3493  else {
3494  mod->posx = posx;
3495  mod->posy = posy;
3496  mod->setUsed();
3497  mod->value = 0;
3498  mod->count = 0;
3499  mod->posz = posz;
3500  mod->length = length;
3501  mod->width = width;
3502  mod->thickness = thickness;
3503  mod->widthAtHalfLength = widthAtHalfLength;
3504  mod->idex = idex;
3505  mod->name = name;
3506  }
3507  }
3508  infile.close();
3509  number_modules = ntotMod - 1;
3510 }
3512  int red, green, blue;
3513  float lminvalue, lmaxvalue;
3514  lminvalue = minvalue;
3515  lmaxvalue = maxvalue;
3516  if (tkMapLog) {
3517  lminvalue = log(minvalue) / log(10);
3518  lmaxvalue = log(maxvalue) / log(10);
3519  value = log(value) / log(10);
3520  }
3521 
3522  red = 0;
3523  green = 0;
3524  blue = 0;
3525  if (palette == 1) { //palette1 1 - raibow
3526  float delta = (lmaxvalue - lminvalue);
3527  float x = (value - lminvalue);
3528  if (value < lminvalue) {
3529  red = 0;
3530  green = 0;
3531  blue = 255;
3532  }
3533  if (value > lmaxvalue) {
3534  red = 255;
3535  green = 0;
3536  blue = 0;
3537  }
3538  if (value >= lminvalue && value <= lmaxvalue) {
3539  red = (int)(x < (delta / 2) ? 0 : (x > ((3. / 4.) * delta) ? 255 : 255 / (delta / 4) * (x - (2. / 4.) * delta)));
3540  green =
3541  (int)(x < delta / 4 ? (x * 255 / (delta / 4))
3542  : (x > ((3. / 4.) * delta) ? 255 - 255 / (delta / 4) * (x - (3. / 4.) * delta) : 255));
3543  blue = (int)(x < delta / 4 ? 255
3544  : (x > ((1. / 2.) * delta) ? 0 : 255 - 255 / (delta / 4) * (x - (1. / 4.) * delta)));
3545  }
3546  }
3547  if (palette == 2) { //palette 2 yellow-green
3548  green = (int)((value - lminvalue) / (lmaxvalue - lminvalue) * 256.);
3549  if (green > 255)
3550  green = 255;
3551  red = 255;
3552  blue = 0;
3553  green = 255 - green;
3554  }
3555  // std::cout<<red<<" "<<green<<" "<<blue<<" "<<value <<" "<<lminvalue<<" "<< lmaxvalue<<std::endl;
3556  return (blue | (green << 8) | (red << 16));
3557 }
3559  //Copy interface
3560  std::ofstream *ofilename;
3561  std::ifstream *ifilename;
3562  std::ostringstream ofname;
3563  std::string ifname;
3565  std::string line;
3566  std::string outputfilename = "dqmtmap";
3567  ifilename = findfile("viewerHeader.xhtml");
3568  ofname << outputfilename << "viewer.html";
3569  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3570  while (getline(*ifilename, line)) {
3571  *ofilename << line << std::endl;
3572  }
3573  *ofilename << " var tmapname=\"" << outputfilename << "\"" << std::endl;
3574  *ofilename << " var tmaptitle=\"" << title << "\"" << std::endl;
3575  *ofilename << " var ncrates=" << ncrates << ";" << std::endl;
3576  *ofilename << " var nfeccrates=" << nfeccrates << ";" << std::endl;
3577  *ofilename << " var npsuracks=" << npsuracks << ";" << std::endl;
3578 
3579  ifilename->close();
3580  delete ifilename;
3581 
3582  ifilename = findfile("viewerTrailer.xhtml");
3583  while (getline(*ifilename, line)) {
3584  *ofilename << line << std::endl;
3585  }
3586  ofilename->close();
3587  delete ofilename;
3588  command = "sed -i \"s/XtmapnameX/" + outputfilename + "/g\" " + ofname.str();
3589  std::cout << "Executing " << command << std::endl;
3590  system(command.c_str());
3591  command = "sed -i \"s/XtmaptitleX/" + title + "/g\" " + ofname.str();
3592  std::cout << "Executing " << command << std::endl;
3593  system(command.c_str());
3594  ofname.str("");
3595  ifilename->close();
3596  delete ifilename;
3597 
3598  ifilename = findfile("jqviewer.js");
3599  ofname << "jqviewer.js";
3600  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3601  while (getline(*ifilename, line)) {
3602  *ofilename << line << std::endl;
3603  }
3604  ofname.str("");
3605  ofilename->close();
3606  delete ofilename;
3607  ifilename->close();
3608  delete ifilename;
3609 
3610  ifilename = findfile("crate.js");
3611  ofname << "crate.js";
3612  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3613  while (getline(*ifilename, line)) {
3614  *ofilename << line << std::endl;
3615  }
3616  ofname.str("");
3617  ofilename->close();
3618  delete ofilename;
3619  ifilename->close();
3620  delete ifilename;
3621 
3622  ifilename = findfile("feccrate.js");
3623  ofname << "feccrate.js";
3624  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3625  while (getline(*ifilename, line)) {
3626  *ofilename << line << std::endl;
3627  }
3628  ofname.str("");
3629  ofilename->close();
3630  delete ofilename;
3631  ifilename->close();
3632  delete ifilename;
3633 
3634  ifilename = findfile("layer.js");
3635  ofname << "layer.js";
3636  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3637  while (getline(*ifilename, line)) {
3638  *ofilename << line << std::endl;
3639  }
3640  ofname.str("");
3641  ofilename->close();
3642  delete ofilename;
3643  ifilename->close();
3644  delete ifilename;
3645 
3646  ifilename = findfile("rack.js");
3647  ofname << "rack.js";
3648  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3649  while (getline(*ifilename, line)) {
3650  *ofilename << line << std::endl;
3651  }
3652  ofname.str("");
3653  ofilename->close();
3654  delete ofilename;
3655  ifilename->close();
3656  delete ifilename;
3657  ofname.str("");
3658 
3659  ifilename = findfile("rackhv.js");
3660  ofname << "rackhv.js";
3661  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3662  while (getline(*ifilename, line)) {
3663  *ofilename << line << std::endl;
3664  }
3665  ofname.str("");
3666  ofilename->close();
3667  delete ofilename;
3668  ifilename->close();
3669  delete ifilename;
3670 
3671  std::ostringstream outs, outs1, outs2;
3672  outs << outputfilename << ".png";
3673  save(true, gminvalue, gmaxvalue, outs.str(), 3000, 1600);
3674  temporary_file = false;
3676 
3677  //Now print a text file for each layer
3678  std::ofstream *txtfile;
3679  for (int layer = 1; layer < 44; layer++) {
3680  std::ostringstream outs;
3681  outs << outputfilename << "layer" << layer << ".html";
3682  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3683  *txtfile << "<html><head></head> <body>" << std::endl;
3684  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
3685  for (int module = 1; module < 200; module++) {
3686  int key = layer * 100000 + ring * 1000 + module;
3687  TmModule *mod = smoduleMap[key];
3688  if (mod != nullptr && !mod->notInUse()) {
3689  int idmod = mod->idex;
3690  *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3691  std::multimap<const int, TmApvPair *>::iterator pos;
3692  for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
3693  TmApvPair *apvpair = pos->second;
3694  if (apvpair != nullptr) {
3695  *txtfile << apvpair->text << std::endl;
3696  }
3697  }
3698  *txtfile << "</pre><h3>" << mod->name << "</h3>" << std::endl;
3699  }
3700  }
3701  }
3702  *txtfile << "</body></html>" << std::endl;
3703  txtfile->close();
3704  delete txtfile;
3705  }
3706  if (enableFedProcessing) {
3707  outs1 << outputfilename << "fed.png";
3708  save_as_fedtrackermap(true, gminvalue, gmaxvalue, outs1.str(), 6000, 3200);
3709  outs2 << outputfilename << ".xml";
3710  save_as_fedtrackermap(true, gminvalue, gmaxvalue, outs2.str(), 3000, 1600);
3711  //And a text file for each crate
3712  std::map<int, int>::iterator i_fed;
3713  std::ofstream *txtfile;
3714  for (int crate = firstcrate; crate < (ncrates + 1); crate++) {
3715  std::ostringstream outs;
3716  outs << outputfilename << "crate" << crate << ".html";
3717  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3718  *txtfile << "<html><head></head> <body>" << std::endl;
3719  for (i_fed = fedMap.begin(); i_fed != fedMap.end(); i_fed++) {
3720  if (i_fed->second == crate) {
3721  int fedId = i_fed->first;
3722  for (int nconn = 0; nconn < 96; nconn++) {
3723  int key = fedId * 1000 + nconn;
3724  TmApvPair *apvPair = apvMap[key];
3725  if (apvPair != nullptr) {
3726  int idmod = apvPair->idex;
3727  *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3728  *txtfile << apvPair->text << std::endl;
3729  std::ostringstream outs;
3730  outs << "fedchannel " << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connects to module "
3731  << apvPair->mod->idex;
3732  *txtfile << "</pre><h3>" << outs.str() << "</h3>" << std::endl;
3733  }
3734  }
3735  }
3736  }
3737  *txtfile << "</body></html>" << std::endl;
3738  txtfile->close();
3739  delete txtfile;
3740  }
3741  }
3742  if (enableFecProcessing) {
3743  std::ostringstream outs1, outs2;
3744  outs1 << outputfilename << "fec.png";
3745  save_as_fectrackermap(true, gminvalue, gmaxvalue, outs1.str(), 6000, 3200);
3746  outs2 << outputfilename << ".xml";
3747  save_as_fectrackermap(true, gminvalue, gmaxvalue, outs2.str(), 3000, 1600);
3748  //And a text file for each crate
3749  std::ofstream *txtfile;
3750  std::map<int, TmCcu *>::iterator i_ccu;
3751  std::multimap<TmCcu *, TmModule *>::iterator it;
3752  std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
3753  for (int crate = 1; crate < (nfeccrates + 1); crate++) {
3754  std::ostringstream outs;
3755  outs << outputfilename << "feccrate" << crate << ".html";
3756  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3757  *txtfile << "<html><head></head> <body>" << std::endl;
3758  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
3759  TmCcu *ccu = i_ccu->second;
3760  if (ccu != nullptr && ccu->getCcuCrate() == crate) {
3761  int idmod = ccu->idex;
3762  *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
3763  *txtfile << ccu->text << std::endl;
3764  std::ostringstream outs;
3765  if (ccu->nmod == 0)
3766  outs << "ccu is in position" << ccu->mpos << "in ring but doesn't seem to have any module connected";
3767  else {
3768  outs << "ccu is in position " << ccu->mpos << " in ring and connects " << ccu->nmod << " modules"
3769  << std::endl;
3770  ret = fecModuleMap.equal_range(ccu);
3771  for (it = ret.first; it != ret.second; ++it) {
3772  outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << "\n\n";
3773  }
3774 
3775  *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
3776  } //ifccu->nmod==0
3777  } //if ccu!=0
3778  } //for i_ccu
3779  *txtfile << "</body></html>" << std::endl;
3780  txtfile->close();
3781  delete txtfile;
3782  } //for int crate
3783  }
3784  if (enableLVProcessing) {
3785  std::ostringstream outs3, outs4;
3786  outs3 << outputfilename << "psu.png";
3787  save_as_psutrackermap(true, gminvalue, gmaxvalue, outs3.str(), 6000, 3200);
3788 
3789  outs4 << outputfilename << ".xml";
3790  save_as_psutrackermap(true, gminvalue, gmaxvalue, outs4.str(), 3000, 1600);
3791  //And a text file for each rack
3792 
3793  std::ofstream *txtfile;
3794  std::map<int, TmPsu *>::iterator ipsu;
3795  std::multimap<TmPsu *, TmModule *>::iterator it;
3796  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
3797  for (int rack = 1; rack < (npsuracks + 1); rack++) {
3798  std::ostringstream outs;
3799 
3800  outs << outputfilename << "psurack" << rack << ".html";
3801  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3802  *txtfile << "<html><head></head> <body>" << std::endl;
3803  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
3804  TmPsu *psu = ipsu->second;
3805  if (psu != nullptr && psu->getPsuRack() == rack) {
3806  *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
3807  *txtfile << psu->text << std::endl;
3808  std::ostringstream outs;
3809  if (psu->nmod == 0)
3810  outs << "Ps is in position" << psu->getPsuBoard()
3811  << "in crate but doesn't seem to have any module connected";
3812  else {
3813  outs << "PS is in position " << psu->getPsuBoard() << " in crate and connects to " << psu->nmod
3814  << " modules. " << std::endl;
3815 
3816  ret = psuModuleMap.equal_range(psu);
3817  for (it = ret.first; it != ret.second; ++it) {
3818  outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << " <br>"
3819  << std::endl;
3820  }
3821  *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
3822  }
3823  }
3824  }
3825  *txtfile << "</body></html>" << std::endl;
3826  txtfile->close();
3827  delete txtfile;
3828  }
3829  }
3830 
3831  if (enableHVProcessing) {
3832  std::ostringstream outs5, outs6;
3833  outs5 << outputfilename << "hv.png";
3834  save_as_HVtrackermap(true, gminvalue, gmaxvalue, outs5.str(), 6000, 3200);
3835 
3836  outs6 << outputfilename << ".xml";
3837  save_as_HVtrackermap(true, gminvalue, gmaxvalue, outs6.str(), 3000, 1600);
3838  //And a text file for each rack
3839 
3840  std::ofstream *txtfile;
3841  std::map<int, TmPsu *>::iterator ipsu;
3842  std::multimap<TmPsu *, TmModule *>::iterator it;
3843  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
3844  for (int rack = 1; rack < (npsuracks + 1); rack++) {
3845  std::ostringstream outs;
3846 
3847  outs << outputfilename << "HVrack" << rack << ".html";
3848  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
3849  *txtfile << "<html><head></head> <body>" << std::endl;
3850  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
3851  TmPsu *psu = ipsu->second;
3852  if (psu != nullptr && psu->getPsuRack() == rack) {
3853  *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
3854  *txtfile << psu->textHV2 << std::endl;
3855  std::ostringstream outsHV2;
3856  if (psu->nmodHV2 == 0)
3857  outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()
3858  << "in crate but doesn't seem to have any module connected";
3859  else {
3860  outsHV2 << "HV Channel002 is in position " << psu->getPsuBoard() << " in crate and connects to "
3861  << psu->nmodHV2 << " modules. "
3862  << " <br>" << std::endl;
3863 
3864  ret = psuModuleMap.equal_range(psu);
3865  for (it = ret.first; it != ret.second; ++it) {
3866  if ((*it).second->HVchannel == 2) {
3867  outsHV2 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
3868  << " <br>" << std::endl;
3869  }
3870  }
3871  *txtfile << "</pre><h4>" << outsHV2.str() << "</h4>" << std::endl;
3872  }
3873 
3874  *txtfile << psu->textHV3 << std::endl;
3875  std::ostringstream outsHV3;
3876  if (psu->nmodHV3 == 0)
3877  outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()
3878  << "in crate but doesn't seem to have any module connected";
3879  else {
3880  outsHV3 << "HV Channel003 is in position " << psu->getPsuBoard() << " in crate and connects to "
3881  << psu->nmodHV3 << " modules. "
3882  << " <br>" << std::endl;
3883 
3884  ret = psuModuleMap.equal_range(psu);
3885  for (it = ret.first; it != ret.second; ++it) {
3886  if ((*it).second->HVchannel == 3) {
3887  outsHV3 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
3888  << " <br>" << std::endl;
3889  }
3890  }
3891  *txtfile << "</pre><h4>" << outsHV3.str() << "</h4>" << std::endl;
3892  }
3893  }
3894  }
3895  *txtfile << "</body></html>" << std::endl;
3896  txtfile->close();
3897  delete txtfile;
3898  }
3899  }
3900 }
3901 void TrackerMap::printall(bool print_total, float minval1, float maxval1, std::string s, int width, int height) {
3902  //Copy interface
3903  float minval, maxval;
3904  minval = minval1;
3905  maxval = maxval1;
3906  if (tkMapLog && (minval < maxval)) {
3907  minval = pow(10., minval1);
3908  maxval = pow(10., maxval1);
3909  }
3911  if (saveWebInterface) {
3912  width = 6000;
3913  height = 3200;
3914  } else {
3915  size_t found = filetype.find_last_of('.');
3916  filetype = filetype.substr(found + 1);
3917  found = outputfilename.find_last_of('.');
3918  outputfilename = outputfilename.substr(0, found);
3919  }
3920  std::ofstream *ofilename;
3921  std::ifstream *ifilename;
3922  std::ostringstream ofname;
3923  std::string ifname;
3924  std::string line;
3926  if (saveWebInterface) {
3927  ifilename = findfile("viewerHeader.xhtml");
3928  ofname << outputfilename << "viewer.html";
3929  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3930  while (getline(*ifilename, line)) {
3931  *ofilename << line << std::endl;
3932  }
3933  *ofilename << " var tmapname=\"" << outputfilename << "\"" << std::endl;
3934  *ofilename << " var tmaptitle=\"" << title << "\"" << std::endl;
3935  *ofilename << " var ncrates=" << ncrates << ";" << std::endl;
3936  *ofilename << " var nfeccrates=" << nfeccrates << ";" << std::endl;
3937  *ofilename << " var npsuracks=" << npsuracks << ";" << std::endl;
3938  ifilename->close();
3939  delete ifilename;
3940  ifilename = findfile("viewerTrailer.xhtml");
3941  while (getline(*ifilename, line)) {
3942  *ofilename << line << std::endl;
3943  }
3944  ofilename->close();
3945  delete ofilename;
3946  ifilename->close();
3947  delete ifilename;
3948  command = "sed -i \"s/XtmapnameX/" + outputfilename + "/g\" " + ofname.str();
3949  std::cout << "Executing " << command << std::endl;
3950  system(command.c_str());
3951  command = "sed -i \"s/XtmaptitleX/" + title + "/g\" " + ofname.str();
3952  std::cout << "Executing " << command << std::endl;
3953  system(command.c_str());
3954  ofname.str("");
3955 
3956  ifilename = findfile("jqviewer.js");
3957  ofname << "jqviewer.js";
3958  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3959  while (getline(*ifilename, line)) {
3960  *ofilename << line << std::endl;
3961  }
3962  ofilename->close();
3963  delete ofilename;
3964  ifilename->close();
3965  delete ifilename;
3966 
3967  ofname.str("");
3968  ifilename = findfile("crate.js");
3969  ofname << "crate.js";
3970  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3971  while (getline(*ifilename, line)) {
3972  *ofilename << line << std::endl;
3973  }
3974  ofilename->close();
3975  delete ofilename;
3976  ifilename->close();
3977  delete ifilename;
3978 
3979  ofname.str("");
3980  ifilename = findfile("feccrate.js");
3981  ofname << "feccrate.js";
3982  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3983  while (getline(*ifilename, line)) {
3984  *ofilename << line << std::endl;
3985  }
3986  ofilename->close();
3987  delete ofilename;
3988  ifilename->close();
3989  delete ifilename;
3990 
3991  ofname.str("");
3992  ifilename = findfile("rack.js");
3993  ofname << "rack.js";
3994  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
3995  while (getline(*ifilename, line)) {
3996  *ofilename << line << std::endl;
3997  }
3998  ofilename->close();
3999  delete ofilename;
4000  ifilename->close();
4001  delete ifilename;
4002 
4003  ofname.str("");
4004  ifilename = findfile("rackhv.js");
4005  ofname << "rackhv.js";
4006  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
4007  while (getline(*ifilename, line)) {
4008  *ofilename << line << std::endl;
4009  }
4010  ofilename->close();
4011  delete ofilename;
4012  ifilename->close();
4013  delete ifilename;
4014 
4015  ofname.str("");
4016  ifilename = findfile("layer.js");
4017  ofname << "layer.js";
4018  ofilename = new std::ofstream(ofname.str().c_str(), std::ios::out);
4019  while (getline(*ifilename, line)) {
4020  *ofilename << line << std::endl;
4021  }
4022  ofilename->close();
4023  delete ofilename;
4024  ifilename->close();
4025  delete ifilename;
4026 
4027  command = "scp -r ../../DQM/TrackerCommon/test/jquery/ .";
4028  std::cout << "Executing " << command << std::endl;
4029  system(command.c_str());
4030  command = "scp -r ../../CommonTools/TrackerMap/data/images/ .";
4031  std::cout << "Executing " << command << std::endl;
4032  system(command.c_str());
4033  }
4034 
4035  std::ostringstream outs;
4036  outs << outputfilename << ".png";
4037  if (saveWebInterface)
4038  save(true, minval, maxval, outs.str(), 3000, 1600);
4039  else {
4040  if (saveGeoTrackerMap)
4041  save(true, minval, maxval, s, width, height);
4042  }
4043  if (saveWebInterface) {
4044  std::ostringstream outs;
4045  outs << outputfilename << ".png";
4046  temporary_file = false;
4047  printlayers(true, minval, maxval, outputfilename);
4048 
4049  //Now print a text file for each layer
4050  std::ofstream *txtfile;
4051  for (int layer = 1; layer < 44; layer++) {
4052  std::ostringstream outs;
4053  outs << outputfilename << "layer" << layer << ".html";
4054  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4055  *txtfile << "<html><head></head> <body>" << std::endl;
4056  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4057  for (int module = 1; module < 200; module++) {
4058  int key = layer * 100000 + ring * 1000 + module;
4059  TmModule *mod = smoduleMap[key];
4060  if (mod != nullptr && !mod->notInUse()) {
4061  int idmod = mod->idex;
4062  *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
4063  std::multimap<const int, TmApvPair *>::iterator pos;
4064  for (pos = apvModuleMap.lower_bound(idmod); pos != apvModuleMap.upper_bound(idmod); ++pos) {
4065  TmApvPair *apvpair = pos->second;
4066  if (apvpair != nullptr) {
4067  *txtfile << apvpair->text << std::endl;
4068  }
4069  }
4070  *txtfile << "</pre><h3>" << mod->name << "</h3>" << std::endl;
4071  }
4072  }
4073  }
4074  *txtfile << "</body></html>" << std::endl;
4075  txtfile->close();
4076  delete txtfile;
4077  }
4078  }
4079  if (enableFedProcessing) {
4080  std::ostringstream outs1, outs2;
4081  if (saveWebInterface)
4082  outs1 << outputfilename << "fed.png";
4083  else
4084  outs1 << outputfilename << "fed." << filetype;
4085  save_as_fedtrackermap(true, 0., 0., outs1.str(), width, height);
4086  if (saveWebInterface) {
4087  outs2 << outputfilename << ".xml";
4088  save_as_fedtrackermap(true, 0., 0., outs2.str(), 3000, 1600);
4089  //And a text file for each crate
4090  std::map<int, int>::iterator i_fed;
4091  std::ofstream *txtfile;
4092  for (int crate = firstcrate; crate < (ncrates + 1); crate++) {
4093  std::ostringstream outs;
4094  outs << outputfilename << "crate" << crate << ".html";
4095  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4096  *txtfile << "<html><head></head> <body>" << std::endl;
4097  for (i_fed = fedMap.begin(); i_fed != fedMap.end(); i_fed++) {
4098  if (i_fed->second == crate) {
4099  int fedId = i_fed->first;
4100  for (int nconn = 0; nconn < 96; nconn++) {
4101  int key = fedId * 1000 + nconn;
4102  TmApvPair *apvPair = apvMap[key];
4103  if (apvPair != nullptr) {
4104  int idmod = apvPair->idex;
4105  *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
4106  *txtfile << apvPair->text << std::endl;
4107  std::ostringstream outs;
4108  outs << "fedchannel " << apvPair->getFedId() << "/" << apvPair->getFedCh() << " connects to module "
4109  << apvPair->mod->idex;
4110  *txtfile << "</pre><h3>" << outs.str() << "</h3>" << std::endl;
4111  }
4112  }
4113  }
4114  }
4115  *txtfile << "</body></html>" << std::endl;
4116  txtfile->close();
4117  delete txtfile;
4118  }
4119  }
4120  }
4121  if (enableFecProcessing) {
4122  std::ostringstream outs1, outs2;
4123  if (saveWebInterface)
4124  outs1 << outputfilename << "fec.png";
4125  else
4126  outs1 << outputfilename << "fec." << filetype;
4127  save_as_fectrackermap(true, 0., 0., outs1.str(), width, height);
4128  if (saveWebInterface) {
4129  outs2 << outputfilename << ".xml";
4130  save_as_fectrackermap(true, 0., 0., outs2.str(), 3000, 1600);
4131  //And a text file for each crate
4132  std::ofstream *txtfile;
4133  std::map<int, TmCcu *>::iterator i_ccu;
4134  std::multimap<TmCcu *, TmModule *>::iterator it;
4135  std::pair<std::multimap<TmCcu *, TmModule *>::iterator, std::multimap<TmCcu *, TmModule *>::iterator> ret;
4136  for (int crate = 1; crate < (nfeccrates + 1); crate++) {
4137  std::ostringstream outs;
4138  outs << outputfilename << "feccrate" << crate << ".html";
4139  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4140  *txtfile << "<html><head></head> <body>" << std::endl;
4141  for (i_ccu = ccuMap.begin(); i_ccu != ccuMap.end(); i_ccu++) {
4142  TmCcu *ccu = i_ccu->second;
4143  if (ccu != nullptr && ccu->getCcuCrate() == crate) {
4144  int idmod = ccu->idex;
4145  *txtfile << "<a name=" << idmod << "><pre>" << std::endl;
4146  *txtfile << ccu->text << std::endl;
4147  std::ostringstream outs;
4148  if (ccu->nmod == 0)
4149  outs << "ccu is in position" << ccu->mpos << "in ring but doesn't seem to have any module connected";
4150  else {
4151  outs << "ccu is in position " << ccu->mpos << " in ring and connects " << ccu->nmod << " modules"
4152  << std::endl;
4153  ret = fecModuleMap.equal_range(ccu);
4154  for (it = ret.first; it != ret.second; ++it) {
4155  outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << "\n\n";
4156  }
4157 
4158  *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
4159  } //ifccu->nmod==0
4160  } //if ccu!=0
4161  } //for i_ccu
4162  *txtfile << "</body></html>" << std::endl;
4163  txtfile->close();
4164  } //for int crate
4165  }
4166  }
4167  if (enableLVProcessing) {
4168  std::ostringstream outs3, outs4;
4169  if (saveWebInterface)
4170  outs3 << outputfilename << "psu.png";
4171  else
4172  outs3 << outputfilename << "psu." << filetype;
4173  save_as_psutrackermap(true, 0., 0., outs3.str(), width, height);
4174  if (saveWebInterface) {
4175  outs4 << outputfilename << ".xml";
4176  save_as_psutrackermap(true, 0., 0., outs4.str(), 3000, 1600);
4177  //And a text file for each rack
4178 
4179  std::ofstream *txtfile;
4180  std::map<int, TmPsu *>::iterator ipsu;
4181  std::multimap<TmPsu *, TmModule *>::iterator it;
4182  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
4183  for (int rack = 1; rack < (npsuracks + 1); rack++) {
4184  std::ostringstream outs;
4185 
4186  outs << outputfilename << "psurack" << rack << ".html";
4187  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4188  *txtfile << "<html><head></head> <body>" << std::endl;
4189  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
4190  TmPsu *psu = ipsu->second;
4191  if (psu != nullptr && psu->getPsuRack() == rack) {
4192  *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
4193  *txtfile << psu->text << std::endl;
4194  std::ostringstream outs;
4195  if (psu->nmod == 0)
4196  outs << "Ps is in position" << psu->getPsuBoard()
4197  << "in crate but doesn't seem to have any module connected";
4198  else {
4199  outs << "PS is in position " << psu->getPsuBoard() << " in crate and connects to " << psu->nmod
4200  << " modules. " << std::endl;
4201 
4202  ret = psuModuleMap.equal_range(psu);
4203  for (it = ret.first; it != ret.second; ++it) {
4204  outs << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value << " <br>"
4205  << std::endl;
4206  }
4207  *txtfile << "</pre><h4>" << outs.str() << "</h4>" << std::endl;
4208  }
4209  }
4210  }
4211  *txtfile << "</body></html>" << std::endl;
4212  txtfile->close();
4213  }
4214  }
4215  }
4216 
4217  if (enableHVProcessing) {
4218  std::ostringstream outs5, outs6;
4219  if (saveWebInterface)
4220  outs5 << outputfilename << "hv.png";
4221  else
4222  outs5 << outputfilename << "hv." << filetype;
4223  save_as_HVtrackermap(true, 0., 0., outs5.str(), width, height);
4224  if (saveWebInterface) {
4225  outs6 << outputfilename << ".xml";
4226  save_as_HVtrackermap(true, 0., 0., outs6.str(), 3000, 1600);
4227  //And a text file for each rack
4228 
4229  std::ofstream *txtfile;
4230  std::map<int, TmPsu *>::iterator ipsu;
4231  std::multimap<TmPsu *, TmModule *>::iterator it;
4232  std::pair<std::multimap<TmPsu *, TmModule *>::iterator, std::multimap<TmPsu *, TmModule *>::iterator> ret;
4233  for (int rack = 1; rack < (npsuracks + 1); rack++) {
4234  std::ostringstream outs;
4235 
4236  outs << outputfilename << "HVrack" << rack << ".html";
4237  txtfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4238  *txtfile << "<html><head></head> <body>" << std::endl;
4239  for (ipsu = psuMap.begin(); ipsu != psuMap.end(); ipsu++) {
4240  TmPsu *psu = ipsu->second;
4241  if (psu != nullptr && psu->getPsuRack() == rack) {
4242  *txtfile << "<a name=" << psu->idex << "><pre>" << std::endl;
4243  *txtfile << psu->textHV2 << std::endl;
4244  std::ostringstream outsHV2;
4245  if (psu->nmodHV2 == 0)
4246  outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()
4247  << "in crate but doesn't seem to have any module connected";
4248  else {
4249  outsHV2 << "HV Channel002 is in position " << psu->getPsuBoard() << " in crate and connects to "
4250  << psu->nmodHV2 << " modules. "
4251  << " <br>" << std::endl;
4252 
4253  ret = psuModuleMap.equal_range(psu);
4254  for (it = ret.first; it != ret.second; ++it) {
4255  if ((*it).second->HVchannel == 2) {
4256  outsHV2 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
4257  << " <br>" << std::endl;
4258  }
4259  }
4260  *txtfile << "</pre><h4>" << outsHV2.str() << "</h4>" << std::endl;
4261  }
4262 
4263  *txtfile << psu->textHV3 << std::endl;
4264  std::ostringstream outsHV3;
4265  if (psu->nmodHV3 == 0)
4266  outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()
4267  << "in crate but doesn't seem to have any module connected";
4268  else {
4269  outsHV3 << "HV Channel003 is in position " << psu->getPsuBoard() << " in crate and connects to "
4270  << psu->nmodHV3 << " modules. "
4271  << " <br>" << std::endl;
4272 
4273  ret = psuModuleMap.equal_range(psu);
4274  for (it = ret.first; it != ret.second; ++it) {
4275  if ((*it).second->HVchannel == 3) {
4276  outsHV3 << (*it).second->idex << " " << (*it).second->name << " value= " << (*it).second->value
4277  << " <br>" << std::endl;
4278  }
4279  }
4280  *txtfile << "</pre><h4>" << outsHV3.str() << "</h4>" << std::endl;
4281  }
4282  }
4283  }
4284  *txtfile << "</body></html>" << std::endl;
4285  txtfile->close();
4286  }
4287  }
4288  }
4289 }
4290 
4292  std::ifstream *ifilename;
4293  std::string ifname;
4294  if (!jsPath.empty()) {
4295  ifname = jsPath + filename;
4296  ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(), std::ios::in);
4297  if (!ifilename) {
4298  ifname = "CommonTools/TrackerMap/data/" + filename;
4299  ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(), std::ios::in);
4300  }
4301  } else {
4302  ifname = "CommonTools/TrackerMap/data/" + filename;
4303  ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(), std::ios::in);
4304  }
4305  if (!ifilename)
4306  std::cout << "File " << filename << " missing" << std::endl;
4307  return ifilename;
4308 }
4309 void TrackerMap::printlayers(bool print_total, float minval, float maxval, std::string outputfilename) {
4310  std::ofstream *xmlfile;
4311  saveAsSingleLayer = true;
4312  if (!print_total) {
4313  for (int layer = 1; layer < 44; layer++) {
4314  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4315  for (int module = 1; module < 200; module++) {
4316  int key = layer * 100000 + ring * 1000 + module;
4317  TmModule *mod = smoduleMap[key];
4318  if (mod != nullptr && !mod->notInUse()) {
4319  mod->value = mod->value / mod->count;
4320  }
4321  }
4322  }
4323  }
4324  }
4325  if (minvalue >= maxvalue) {
4326  minvalue = 9999999.;
4327  maxvalue = -9999999.;
4328  for (int layer = 1; layer < 44; layer++) {
4329  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4330  for (int module = 1; module < 200; module++) {
4331  int key = layer * 100000 + ring * 1000 + module;
4332  TmModule *mod = smoduleMap[key];
4333  if (mod != nullptr && !mod->notInUse()) {
4334  if (minvalue > mod->value)
4335  minvalue = mod->value;
4336  if (maxvalue < mod->value)
4337  maxvalue = mod->value;
4338  }
4339  }
4340  }
4341  }
4342  }
4343  for (int layer = 1; layer < 44; layer++) {
4344  std::ostringstream outs;
4345  outs << outputfilename << "layer" << layer << ".xml";
4346  xmlfile = new std::ofstream(outs.str().c_str(), std::ios::out);
4347  *xmlfile << "<?xml version=\"1.0\" standalone=\"no\"?>" << std::endl;
4348  *xmlfile << "<svg xmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
4349  *xmlfile << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
4350  *xmlfile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >" << std::endl;
4351  *xmlfile << "<script type=\"text/ecmascript\" xlink:href=\"layer.js\" />" << std::endl;
4352  *xmlfile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" "
4353  "onload=\"TrackerLayer.init()\">"
4354  << std::endl;
4355  if (layer < 31)
4356  *xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,1.)\" > " << std::endl;
4357  else
4358  *xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,0.8)\" > " << std::endl;
4359  *xmlfile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />" << std::endl;
4360  *xmlfile << "<svg:polygon id=\"fed\" mapAttribute=\"fed\" points=\"250,40 250,10 230,10 230,40\" "
4361  "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4362  "fill=\"rgb(0,127,255)\"/>"
4363  << std::endl;
4364  *xmlfile << "<svg:polygon id=\"fec\" mapAttribute=\"fec\" points=\"228,40 228,10 208,10 208,40\" "
4365  "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4366  "fill=\"rgb(0,127,255)\"/>"
4367  << std::endl;
4368  *xmlfile << "<svg:polygon id=\"lv\" mapAttribute=\"lv\" points=\"206,40 206,10 186,10 186,40\" "
4369  "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4370  "fill=\"rgb(0,127,255)\"/>"
4371  << std::endl;
4372  *xmlfile << "<svg:polygon id=\"hv\" mapAttribute=\"hv\" points=\"184,40 184,10 164,10 164,40\" "
4373  "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4374  "fill=\"rgb(0,127,255)\"/>"
4375  << std::endl;
4376  *xmlfile << "<svg:polygon id=\"plot\" mapAttribute=\"plot\" points=\"155,45 155,5 135,5 135,45\" "
4377  "onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" onmouseout=\"chooseMap(evt);\" "
4378  "fill=\"rgb(200,0,0)\"/>"
4379  << std::endl;
4380 
4381  // nlay=layer;
4382  defwindow(layer);
4383  for (int ring = firstRing[layer - 1]; ring < ntotRing[layer - 1] + firstRing[layer - 1]; ring++) {
4384  for (int module = 1; module < 200; module++) {
4385  int key = layer * 100000 + ring * 1000 + module;
4386  TmModule *mod = smoduleMap[key];
4387  if (mod != nullptr && !mod->notInUse()) {
4388  drawModule(mod, key, layer, print_total, xmlfile);
4389  }
4390  }
4391  }
4392  *xmlfile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\">" << std::endl;
4393  *xmlfile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
4394  *xmlfile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
4395  *xmlfile << "<tspan id=\"line3\" x=\"40\" y=\"90\"> </tspan> " << std::endl;
4396  *xmlfile << "<tspan id=\"line4\" x=\"40\" y=\"120\"> </tspan> " << std::endl;
4397  if (layer > 33) {
4398  *xmlfile << "<tspan mapAttribute=\"fed\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4399  "onmouseout=\"chooseMap(evt);\" x=\"15\" y=\"228\" font-size=\"12\" font-family=\"arial\" "
4400  "fill=\"white\">FED</tspan> "
4401  << std::endl;
4402  *xmlfile << "<tspan mapAttribute=\"fec\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4403  "onmouseout=\"chooseMap(evt);\" x=\"15\" y=\"258\" font-size=\"12\" font-family=\"arial\" "
4404  "fill=\"white\">FEC</tspan> "
4405  << std::endl;
4406  *xmlfile << "<tspan mapAttribute=\"lv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4407  "onmouseout=\"chooseMap(evt);\" x=\"18\" y=\"289\" font-size=\"12\" font-family=\"arial\" "
4408  "fill=\"white\">LV</tspan> "
4409  << std::endl;
4410  *xmlfile << "<tspan mapAttribute=\"hv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4411  "onmouseout=\"chooseMap(evt);\" x=\"18\" y=\"319\" font-size=\"12\" font-family=\"arial\" "
4412  "fill=\"white\">HV</tspan> "
4413  << std::endl;
4414  *xmlfile << "<tspan mapAttribute=\"plot\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4415  "onmouseout=\"chooseMap(evt);\" x=\"12\" y=\"360\" font-size=\"12\" font-family=\"arial\" "
4416  "fill=\"white\">PLOT</tspan> "
4417  << std::endl;
4418  } else {
4419  *xmlfile << "<tspan mapAttribute=\"fed\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4420  "onmouseout=\"chooseMap(evt);\" x=\"21\" y=\"228\" font-size=\"12\" font-family=\"arial\" "
4421  "fill=\"white\">FED</tspan> "
4422  << std::endl;
4423  *xmlfile << "<tspan mapAttribute=\"fec\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4424  "onmouseout=\"chooseMap(evt);\" x=\"21\" y=\"258\" font-size=\"12\" font-family=\"arial\" "
4425  "fill=\"white\">FEC</tspan> "
4426  << std::endl;
4427  *xmlfile << "<tspan mapAttribute=\"lv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4428  "onmouseout=\"chooseMap(evt);\" x=\"24\" y=\"289\" font-size=\"12\" font-family=\"arial\" "
4429  "fill=\"white\">LV</tspan> "
4430  << std::endl;
4431  *xmlfile << "<tspan mapAttribute=\"hv\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4432  "onmouseout=\"chooseMap(evt);\" x=\"24\" y=\"319\" font-size=\"12\" font-family=\"arial\" "
4433  "fill=\"white\">HV</tspan> "
4434  << std::endl;
4435  *xmlfile << "<tspan mapAttribute=\"plot\" onclick=\"chooseMap(evt);\" onmouseover=\"chooseMap(evt);\" "
4436  "onmouseout=\"chooseMap(evt);\" x=\"17\" y=\"360\" font-size=\"12\" font-family=\"arial\" "
4437  "fill=\"white\">PLOT</tspan> "
4438  << std::endl;
4439  }
4440  *xmlfile << " </text> </svg>" << std::endl;
4441  xmlfile->close();
4442  delete xmlfile;
4443  }
4444  saveAsSingleLayer = false;
4445 }
4446 
4448  if (legInfos_.empty()) {
4449  legInfos_.reserve(8);
4450 
4451  legInfos_.push_back(new TPolyLine(0));
4452  legInfos_.back()->SetFillColor(kGreen);
4453  legInfos_.push_back(new TPolyLine(0));
4454  legInfos_.back()->SetFillColor(kBlue - 9);
4455  legInfos_.push_back(new TPolyLine(0));
4456  legInfos_.back()->SetFillColor(kRed + 2);
4457  legInfos_.push_back(new TPolyLine(0));
4458  legInfos_.back()->SetFillColor(kPink - 9);
4459  legInfos_.push_back(new TPolyLine(0));
4460  legInfos_.back()->SetFillColor(kOrange + 2);
4461  legInfos_.push_back(new TPolyLine(0));
4462  legInfos_.back()->SetFillColor(kYellow);
4463  legInfos_.push_back(new TPolyLine(0));
4464  legInfos_.back()->SetFillColor(kRed + 1);
4465  legInfos_.push_back(new TPolyLine(0));
4466  legInfos_.back()->SetFillColor(kViolet - 5);
4467  legKeys_ = {"Good Modules",
4468  "Excluded FED",
4469  "FED errors",
4470  "# Clusters",
4471  "# Digis",
4472  "PCL bad",
4473  "# Clusters & Digis",
4474  "DCS Error"};
4475  }
4476 
4477  TLegend *myL = new TLegend(0.56, 0.87, 0.95, 0.99);
4478  myL->SetNColumns(2);
4479  myL->SetBorderSize(0);
4480  myL->SetFillColor(38);
4481  for (unsigned int i = 0; i < legInfos_.size(); i++) {
4482  myL->AddEntry((TObject *)legInfos_[i], legKeys_[i].c_str(), "f");
4483  }
4484  // myL->Draw();
4485  return myL;
4486 }
std::vector< TPolyLine * > legInfos_
Definition: TrackerMap.h:677
TmModule * mod
Definition: TmApvPair.h:16
void reset()
Definition: TrackerMap.cc:462
bool tkMapLog
Definition: TrackerMap.h:197
void fill_hv_channel2(int rack, int crate, int board, float qty)
Definition: TrackerMap.cc:3332
std::string text
Definition: TmApvPair.h:12
int getPsuBranch()
Definition: TmPsu.h:17
#define NUMFEDCRATE_INCOLUMN
Definition: TrackerMap.h:59
void build()
Definition: TrackerMap.cc:3468
def isnan(num)
float minvalue
Definition: TrackerMap.h:667
TrackerMap(std::string s=" ", int xsize1=340, int ysize1=200)
Definition: TrackerMap.cc:443
ModApvPair apvModuleMap
Definition: TrackerMap.h:177
double ydpixelc(double y)
Definition: TrackerMap.h:302
std::ifstream * findfile(std::string filename)
Definition: TrackerMap.cc:4291
int nfeccrates
Definition: TrackerMap.h:655
int redHV2
Definition: TmPsu.h:38
void fillc_all_blank()
Definition: TrackerMap.cc:3397
#define NUMPSURACK_INCOLUMN
Definition: TrackerMap.h:46
double ydpixelfec(double y)
Definition: TrackerMap.h:320
int getmoduleCount(int subdet, int partdet, int layer, int ring)
Definition: TrackerMap.h:536
float value
Definition: TmModule.h:11
MapCcu ccuMap
Definition: TrackerMap.h:182
int green
Definition: TmApvPair.h:10
int mpos
Definition: TmApvPair.h:17
std::string cmodid_HV2
Definition: TmPsu.h:50
int nmodHV3
Definition: TmPsu.h:48
void fillc_hv_channel2(int rack, int crate, int board, int red, int green, int blue)
Definition: TrackerMap.cc:3305
SmoduleMap smoduleMap
Definition: TrackerMap.h:171
std::ifstream * inputfile
Definition: TrackerMap.h:664
std::ofstream * savefile
Definition: TrackerMap.h:662
bool psetAvailable
Definition: TrackerMap.h:201
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
#define YFEDOFFSET
Definition: TrackerMap.h:66
int count
Definition: TmPsu.h:43
int idex
Definition: TmPsu.h:11
~TrackerMap()
default destructor
Definition: TrackerMap.cc:525
std::string cmodid
Definition: TmCcu.h:15
static const uint32_t invalid32_
Definition: Constants.h:15
bool saveGeoTrackerMap
Definition: TrackerMap.h:192
int countHV2
Definition: TmPsu.h:44
ret
prodAgent to be discontinued
int module(int fedId, int fedCh)
Definition: TrackerMap.cc:3355
bool enableFecProcessing
Definition: TrackerMap.h:194
#define XPSURSIZE
Definition: TrackerMap.h:48
int layer
Definition: TmCcu.h:16
void defwindow(int num_lay)
Definition: TrackerMap.h:388
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define NUMFEDCH_INCOLUMN
Definition: TrackerMap.h:53
void save_as_HVtrackermap(bool print_total=true, float minval=0., float maxval=0., std::string s="psu_svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:2123
int getCcuRing()
Definition: TmCcu.h:27
double xdpixelc(double x)
Definition: TrackerMap.h:294
void defpsuwindow(int num_rack)
Definition: TrackerMap.h:375
bool addPixelFlag
Definition: TrackerMap.h:674
int number_modules
Definition: TrackerMap.h:668
bool saveWebInterface
Definition: TrackerMap.h:191
std::string infilename
Definition: TrackerMap.h:199
int getlayerCount(int subdet, int partdet)
Definition: TrackerMap.h:243
int npsuracks
Definition: TrackerMap.h:656
void fill_current_val_fed_channel(int fedId, int fedCh, float current_val)
Definition: TrackerMap.cc:3241
float value
Definition: TmPsu.h:40
#define YFEDCSIZE
Definition: TrackerMap.h:64
int getPsuBoard()
Definition: TmPsu.h:31
int red
Definition: TmPsu.h:37
int greenHV3
Definition: TmPsu.h:39
double npart
Definition: HydjetWrapper.h:48
bool enableFedProcessing
Definition: TrackerMap.h:193
int layer
Definition: TmModule.h:27
ImoduleMap imoduleMap
Definition: TrackerMap.h:173
int count
Definition: TmCcu.h:11
int firstRing[43]
Definition: TrackerMap.h:647
float gminvalue
Definition: TrackerMap.h:666
int nmod
Definition: TmCcu.h:14
#define NUMFEDCRATE_INROW
Definition: TrackerMap.h:60
void fillc_fec_channel(int crate, int slot, int ring, int addr, int red, int green, int blue)
Definition: TrackerMap.cc:3253
std::string jsPath
Definition: TrackerMap.h:200
bool enableHVProcessing
Definition: TrackerMap.h:196
double xdpixelfec(double x)
Definition: TrackerMap.h:312
bool posrel
Definition: TrackerMap.h:659
int getFedId()
Definition: TmApvPair.h:22
T getUntrackedParameter(std::string const &, T const &) const
int getPsuDcs()
Definition: TmPsu.h:13
int getCcuSlot()
Definition: TmCcu.h:22
int red
Definition: TmApvPair.h:10
double phival(double x, double y)
Definition: TrackerMap.h:203
txtfile
Delete all three files at once to make sure the user never sees stale data (e.g.
void fill_all_blank()
Definition: TrackerMap.cc:3404
void fillc_lv_channel(int rack, int crate, int board, int red, int green, int blue)
Definition: TrackerMap.cc:3279
std::vector< std::string > legKeys_
Definition: TrackerMap.h:678
unsigned int idex
Definition: TmModule.h:28
void save_as_psutrackermap(bool print_total=true, float minval=0., float maxval=0., std::string s="psu_svgmap.svg", int width=100+(360+100) *5+300, int height=50+(150+50) *6+300)
Definition: TrackerMap.cc:2446
int getringCount(int subdet, int partdet, int layer)
Definition: TrackerMap.h:498
int np
Definition: AMPTWrapper.h:43
double xdpixelpsu(double x)
Definition: TrackerMap.h:330
int nmod
Definition: TmPsu.h:46
void drawHV3(int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue)
Definition: TrackerMap.cc:1730
std::string PsuId
Definition: TmModule.h:17
T sqrt(T t)
Definition: SSEVec.h:23
void save_as_fedtrackermap(bool print_total=true, float minval=0., float maxval=0., std::string s="fed_svgmap.svg", int width=100+(90+100) *31+300, int height=150+(2940+150) *1+300)
Definition: TrackerMap.cc:2754
#define NUMFED_INCOLUMN
Definition: TrackerMap.h:55
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:843
bool saveAsSingleLayer
Definition: TrackerMap.h:673
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int blueHV3
Definition: TmPsu.h:39
void deffecwindow(int num_crate)
Definition: TrackerMap.h:361
bool temporary_file
Definition: TrackerMap.h:669
bool onlyPixelFlag
Definition: TrackerMap.h:675
std::ofstream * svgfile
Definition: TrackerMap.h:661
void load(std::string s="tmap.svg")
Definition: TrackerMap.cc:3061
int greenHV2
Definition: TmPsu.h:38
key
prepare the HTCondor submission files and eventually submit them
#define XFEDCSIZE
Definition: TrackerMap.h:63
static const int npoints
Definition: value.py:1
int getCcuCrate()
Definition: TmCcu.h:18
int green
Definition: TmCcu.h:8
const std::vector< SiStripFecCrate > & crates() const
int getPsuRack()
Definition: TmPsu.h:22
int nmodHV2
Definition: TmPsu.h:47
double ydpixel(double y)
Definition: TrackerMap.h:277
void drawModule(TmModule *mod, int key, int layer, bool total, std::ofstream *file)
Definition: TrackerMap.cc:561
int green
Definition: TmPsu.h:37
int blue
Definition: TmApvPair.h:10
void drawApvPair(int crate, int numfed_incrate, bool total, TmApvPair *apvPair, std::ofstream *file, bool useApvPairValue)
Definition: TrackerMap.cc:1241
void init()
Definition: TrackerMap.cc:472
void fillc_fed_channel(int fedId, int fedCh, int red, int green, int blue)
Definition: TrackerMap.cc:3215
xmlfile
Make an XML representation of the misalignment.
int getcolor(float value, int palette)
Definition: TrackerMap.cc:3511
int count
Definition: TmModule.h:12
std::string psId
Definition: TmPsu.h:12
void fillc(int idmod, int RGBcode)
Definition: TrackerMap.h:134
#define M_PI
void printlayers(bool print_total=true, float minval=0., float maxval=0., std::string s="layer")
Definition: TrackerMap.cc:4309
int psuIdex
Definition: TmModule.h:18
SvgFed slotMap
Definition: TrackerMap.h:180
int mpos
Definition: TmCcu.h:17
void drawHV2(int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue)
Definition: TrackerMap.cc:1626
int redHV3
Definition: TmPsu.h:39
void drawCcu(int crate, int numfed_incrate, bool total, TmCcu *ccu, std::ofstream *file, bool useCcuValue)
Definition: TrackerMap.cc:1406
short int HVchannel
Definition: TmModule.h:19
int getKey()
Definition: TmModule.h:22
int green
Definition: TmModule.h:10
int CcuId
Definition: TmModule.h:16
int count
Definition: TmApvPair.h:13
SvgFed fedMap
Definition: TrackerMap.h:179
PsuModule psuModuleMap
Definition: TrackerMap.h:188
float value
Definition: TmCcu.h:9
#define YPSUOFFSET
Definition: TrackerMap.h:51
std::string cmodid_HV3
Definition: TmPsu.h:51
void fill_hv_channel3(int rack, int crate, int board, float qty)
Definition: TrackerMap.cc:3343
#define NUMPSUCRATE_INCOLUMN
Definition: TrackerMap.h:45
float valueHV2
Definition: TmPsu.h:42
bool printflag
Definition: TrackerMap.h:190
static const uint16_t invalid_
Definition: Constants.h:16
int crate
Definition: TmApvPair.h:15
int firstcrate
Definition: TrackerMap.h:654
TLegend * buildLegend()
Definition: TrackerMap.cc:4447
FecModule fecModuleMap
Definition: TrackerMap.h:184
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void setRange(float min, float max)
Definition: TrackerMap.cc:806
void drawPalette(std::ofstream *file, int xoffset=3660, int yoffset=1540)
Definition: TrackerMap.cc:3166
bool notInUse()
Definition: TmModule.h:23
#define YPSURSIZE
Definition: TrackerMap.h:49
list command
Definition: mps_check.py:25
int red
Definition: TmModule.h:10
int blue
Definition: TmModule.h:10
std::string title
Definition: TrackerMap.h:198
double xdpixel(double x)
Definition: TrackerMap.h:269
int idex
Definition: TmCcu.h:12
void printonline()
Definition: TrackerMap.cc:3558
int nlayer(int det, int part, int lay)
Definition: TrackerMap.h:595
Definition: colors.py:1
std::string textHV3
Definition: TmPsu.h:54
int red
Definition: TmCcu.h:8
#define NUMFED_INROW
Definition: TrackerMap.h:56
SvgApvPair apvMap
Definition: TrackerMap.h:175
void print(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap")
Definition: TrackerMap.cc:3095
col
Definition: cuy.py:1009
std::string text
Definition: TmPsu.h:52
int countHV3
Definition: TmPsu.h:45
void fill_fec_channel(int crate, int slot, int ring, int addr, float qty)
Definition: TrackerMap.cc:3267
float gmaxvalue
Definition: TrackerMap.h:666
int idex
Definition: TmApvPair.h:14
void fill_current_val(int idmod, float current_val)
Definition: TrackerMap.cc:3411
float maxvalue
Definition: TrackerMap.h:667
std::string cmodid_LV
Definition: TmPsu.h:49
float valueHV3
Definition: TmPsu.h:41
step
Definition: StallMonitor.cc:83
void setText(int idmod, std::string s)
Definition: TrackerMap.cc:3451
int blue
Definition: TmCcu.h:8
#define XFEDOFFSET
Definition: TrackerMap.h:65
bool enableLVProcessing
Definition: TrackerMap.h:195
#define NUMPSURACK_INROW
Definition: TrackerMap.h:47
bool firstcall
Definition: TrackerMap.h:660
std::string textHV2
Definition: TmPsu.h:53
int blue
Definition: TmPsu.h:37
MapPsu psuMap
Definition: TrackerMap.h:186
static bool isRingStereo(int key)
Definition: TrackerMap.h:583
Definition: TmCcu.h:4
int blueHV2
Definition: TmPsu.h:38
void defcwindow(int num_crate)
Definition: TrackerMap.h:349
std::ifstream * jsfile
Definition: TrackerMap.h:663
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::string text
Definition: TmCcu.h:10
Definition: TmPsu.h:6
FedsConstIterRange fedIds() const
#define XPSUOFFSET
Definition: TrackerMap.h:50
void fill_lv_channel(int rack, int crate, int board, float qty)
Definition: TrackerMap.cc:3293
std::vector< TColor * > vc
Definition: TrackerMap.h:168
#define NUMPSUCH_INROW
Definition: TrackerMap.h:44
float value
Definition: TmApvPair.h:11
void printall(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap", int width=6000, int height=3200)
Definition: TrackerMap.cc:3901
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void drawPsu(int rack, int numcrate_inrack, bool print_total, TmPsu *psu, std::ofstream *svgfile, bool usePsuValue)
Definition: TrackerMap.cc:1512
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3441
double ydpixelpsu(double y)
Definition: TrackerMap.h:338
ConnsConstIterRange fedConnections(uint16_t fed_id) const
void save_as_fectrackermap(bool print_total=true, float minval=0., float maxval=0., std::string s="fec_svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:1833
std::string name
Definition: TmModule.h:14
void fill_fed_channel(int fedId, int fedCh, float qty)
Definition: TrackerMap.cc:3363
int getFedCh()
Definition: TmApvPair.h:18
#define NUMFEDCH_INROW
Definition: TrackerMap.h:54
void fillc_hv_channel3(int rack, int crate, int board, int red, int green, int blue)
Definition: TrackerMap.cc:3318
int ntotRing[43]
Definition: TrackerMap.h:646
int getPsuCrate()
Definition: TmPsu.h:26
std::pair< float, float > getAutomaticRange()
Definition: TrackerMap.cc:815
std::string jsfilename
Definition: TrackerMap.h:199