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