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