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