CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  vhbot = mod->width;
555  vhtop=mod->width;
556  vhapo=mod->length;
557  if(mlay < 31){ //endcap
558  vhbot = mod->widthAtHalfLength/2.-(mod->width/2.-mod->widthAtHalfLength/2.);
559  vhtop=mod->width/2.;
560  vhapo=mod->length/2.;
561  if(mlay >12 && mlay <19){
562  if(posrel)r = r+r;
563  xp[0]=r-vhtop;yp[0]=-vhapo;
564  xp[1]=r+vhtop;yp[1]=-vhapo;
565  xp[2]=r+vhtop;yp[2]=vhapo;
566  xp[3]=r-vhtop;yp[3]=vhapo;
567  }else{
568  if(posrel)r = r + r/3.;
569  xp[0]=r-vhapo;yp[0]=-vhbot;
570  xp[1]=r+vhapo;yp[1]=-vhtop;
571  xp[2]=r+vhapo;yp[2]=vhtop;
572  xp[3]=r-vhapo;yp[3]=vhbot;
573  }
574  for(int j=0;j<4;j++){
575  xp1 = xp[j]*cos(phi)-yp[j]*sin(phi);
576  yp1 = xp[j]*sin(phi)+yp[j]*cos(phi);
577  xp[j] = xp1;yp[j]=yp1;
578  }
579  } else { //barrel
580  numod=mod->idModule;if(numod>100)numod=numod-100;
581  int vane = mod->ring;
582  if(posrel){
583  dx = vhapo;
584  phi=M_PI;
585  xt1=rmedio[mlay-31]; yt1=-vhtop/2.;
586  xs1 = xt1*cos(phi)-yt1*sin(phi);
587  ys1 = xt1*sin(phi)+yt1*cos(phi);
588  xt2=rmedio[mlay-31]; yt2=vhtop/2.;
589  xs2 = xt2*cos(phi)-yt2*sin(phi);
590  ys2 = xt2*sin(phi)+yt2*cos(phi);
591  dy=phival(xs2,ys2)-phival(xs1,ys1);
592  dy1 = dy;
593  if(mlay==31)dy1=0.39;
594  if(mlay==32)dy1=0.23;
595  if(mlay==33)dy1=0.16;
596  xp[0]=vane*(dx+dx/8.);yp[0]=numod*(dy1);
597  xp[1]=vane*(dx+dx/8.)+dx;yp[1]=numod*(dy1);
598  xp[2]=vane*(dx+dx/8.)+dx;yp[2]=numod*(dy1)+dy;
599  xp[3]=vane*(dx+dx/8.);yp[3]=numod*(dy1)+dy;
600  }else{
601  xt1=r; yt1=-vhtop/2.;
602  xs1 = xt1*cos(phi)-yt1*sin(phi);
603  ys1 = xt1*sin(phi)+yt1*cos(phi);
604  xt2=r; yt2=vhtop/2.;
605  xs2 = xt2*cos(phi)-yt2*sin(phi);
606  ys2 = xt2*sin(phi)+yt2*cos(phi);
607  pv1=phival(xs1,ys1);
608  pv2=phival(xs2,ys2);
609  if(fabs(pv1-pv2)>M_PI && numod==1)pv1=pv1-2.*M_PI;
610  if(fabs(pv1-pv2)>M_PI && numod!=1)pv2=pv2+2.*M_PI;
611  xp[0]=mod->posz-vhapo/2.;yp[0]=4.2*pv1;
612  xp[1]=mod->posz+vhapo/2.;yp[1]=4.2*pv1;
613  xp[2]=mod->posz+vhapo/2. ;yp[2]=4.2*pv2;
614  xp[3]=mod->posz-vhapo/2.;yp[3]=4.2*pv2;
615  }
616  }
617  if(isRingStereo(key))
618  {
619  np = 3;
620  if(mod->idModule>100 ){for(int j=0;j<3;j++){
621  xd[j]=xdpixel(xp[j]);yd[j]=ydpixel(yp[j]);
622  }
623  }else {
624  xd[0]=xdpixel(xp[2]);yd[0]=ydpixel(yp[2]);
625  xd[1]=xdpixel(xp[3]);yd[1]=ydpixel(yp[3]);
626  xd[2]=xdpixel(xp[0]);yd[2]=ydpixel(yp[0]);
627  }
628  } else {
629  for(int j=0;j<4;j++){
630  xd[j]=xdpixel(xp[j]);yd[j]=ydpixel(yp[j]);
631  }
632  }
633  char buffer [20];
634  sprintf(buffer,"%X",mod->idex);
635 
636  if(mod->red < 0){ //use count to compute color
637  int color = getcolor(mod->value,palette);
638  red=(color>>16)&0xFF;
639  green=(color>>8)&0xFF;
640  blue=(color)&0xFF;
641 
642 if(!print_total)mod->value=mod->value*mod->count;//restore mod->value
643 
644  if(mod->count > 0)
645  if(temporary_file) *svgfile << red << " " << green << " " << blue << " "; else
646  *svgfile <<"<svg:polygon detid=\""<<mod->idex<<"\" count=\""<<mod->count <<"\" value=\""<<mod->value<<"\" id=\""<<key<<"\" capvids=\""<<mod->capvids<<"\" lv=\""<<mod->psuIdex<<"\" hv=\""<<mod->psuIdex*10 + mod->HVchannel<<"\" fec=\""<<mod->CcuId<<"\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""<<mod->text<<"\" POS=\""<<mod->name<<" \" fill=\"rgb("<<red<<","<<green<<","<<blue<<")\" points=\"";
647  else
648  if(temporary_file) *svgfile << 255 << " " << 255 << " " << 255 << " "; else
649  *svgfile <<"<svg:polygon detid=\""<<mod->idex<<"\" count=\""<<mod->count <<"\" value=\""<<mod->value<<"\" id=\""<<key<<"\" capvids=\""<<mod->capvids<<"\" lv=\""<<mod->psuIdex<<"\" hv=\""<<mod->psuIdex*10 + mod->HVchannel<<"\" fec=\""<<mod->CcuId<<"\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""<<mod->text<<"\" POS=\""<<mod->name<<" \" fill=\"white\" points=\"";
650  if(temporary_file) *svgfile << np << " ";
651  for(int k=0;k<np;k++){
652  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ; else
653  *svgfile << xd[k] << "," << yd[k] << " " ;
654  }
655  if(temporary_file)*svgfile << std::endl; else *svgfile <<"\" />" <<std::endl;
656  } else {//color defined with fillc
657  if(mod->red>255)mod->red=255;
658  if(mod->green>255)mod->green=255;
659  if(mod->blue>255)mod->blue=255;
660  if(temporary_file) *svgfile << mod->red << " " << mod->green << " " << mod->blue << " "; else
661  *svgfile <<"<svg:polygon detid=\""<<mod->idex<<"\" count=\""<<mod->count <<"\" value=\""<<mod->value<<"\" id=\""<<key<<"\" capvids=\""<<mod->capvids<<"\" lv=\""<<mod->psuIdex<<"\" hv=\""<<mod->psuIdex*10 + mod->HVchannel<<"\" fec=\""<<mod->CcuId<<"\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\""<<mod->text<<"\" POS=\""<<mod->name<<" \" fill=\"rgb("<<mod->red<<","<<mod->green<<","<<mod->blue<<")\" points=\"";
662  if(temporary_file) *svgfile << np << " ";
663  for(int k=0;k<np;k++){
664  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ; else
665  *svgfile << xd[k] << "," << yd[k] << " " ;
666  }
667  if(temporary_file)*svgfile << std::endl; else *svgfile <<"\" />" <<std::endl;
668  }
669 
670 }
672 if(tkMapLog) {gminvalue=pow(10.,min);gmaxvalue=pow(10.,max);}
673 }
674 
675 std::pair<float,float> TrackerMap::getAutomaticRange(){
676  float minval,maxval;
677  minval=9999999.;
678  maxval=-9999999.;
679  for (int layer=1; layer < 44; layer++){
680  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
681  for (int module=1;module<200;module++) {
682  int key=layer*100000+ring*1000+module;
683  TmModule * mod = smoduleMap[key];
684  if(mod !=0 && !mod->notInUse() && mod->count>0){
685  if (minval > mod->value)minval=mod->value;
686  if (maxval < mod->value)maxval=mod->value;
687  }
688  }
689  }
690  }
691 if(tkMapLog) {minval=log(minval)/log(10);maxval=log(maxval)/log(10);}
692  return std::make_pair(minval,maxval);
693 
694 }
695 
696 //export tracker map
697 //print_total = true represent in color the total stored in the module
698 //print_total = false represent in color the average
699 void TrackerMap::save(bool print_total,float minval, float maxval,std::string s,int width, int height){
700 
701  printflag=true;
702  bool rangefound = true;
703  if(saveGeoTrackerMap){
704  std::string filetype=s,outputfilename=s;
705  std::vector<TPolyLine*> vp;
706  TGaxis *axis = 0 ;
707  size_t found=filetype.find_last_of(".");
708  filetype=filetype.substr(found+1);
709  found=outputfilename.find_last_of(".");
710  outputfilename=outputfilename.substr(0,found);
711  //outputfilename.erase(outputfilename.begin()+outputfilename.find("."),outputfilename.end());
712  temporary_file=true;
713  if(filetype=="svg")temporary_file=false;
714  std::ostringstream outs;
715  minvalue=minval; maxvalue=maxval;
716  outs << outputfilename << ".coor";
717  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
718  if(!print_total){
719  for (int layer=1; layer < 44; layer++){
720  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
721  for (int module=1;module<200;module++) {
722  int key=layer*100000+ring*1000+module;
723  TmModule * mod = smoduleMap[key];
724  if(mod !=0 && !mod->notInUse()){
725  mod->value = mod->value / mod->count;
726  }
727  }
728  }
729  }
730  }
731 
732  if(minvalue>=maxvalue){
733  minvalue=9999999.;
734  maxvalue=-9999999.;
735  rangefound=false;
736  for (int layer=1; layer < 44; layer++){
737  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
738  for (int module=1;module<200;module++) {
739  int key=layer*100000+ring*1000+module;
740  TmModule * mod = smoduleMap[key];
741  if(mod !=0 && !mod->notInUse() && mod->count>0){
742  rangefound=true;
743  if (minvalue > mod->value)minvalue=mod->value;
744  if (maxvalue < mod->value)maxvalue=mod->value;
745  }
746  }
747  }
748  }
749  }
750  if ((title.find("QTestAlarm")!=std::string::npos) || (maxvalue == minvalue)||!rangefound) printflag = false;
751  if(!temporary_file){
752  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
753  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
754  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
755  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
756  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3100 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
757  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3100\" height=\"1600\" /> "<<std::endl;
758  *savefile << "<svg:g id=\"tracker\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
759  }
760  for (int layer=1; layer < 44; layer++){
761  // nlay=layer;
762  defwindow(layer);
763  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
764  for (int module=1;module<200;module++) {
765  int key=layer*100000+ring*1000+module;
766  TmModule * mod = smoduleMap[key];
767  if(mod !=0 && !mod->notInUse()){
768  drawModule(mod,key,layer,print_total,savefile);
769  }
770  }
771  }
772  }
773 
774  if(!temporary_file){
775  *savefile << "</svg:g>"<<std::endl;
776  *savefile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">"<<title<<"</svg:text>"<<std::endl;
777  }
778 
779  if(printflag) {
781  else {drawPalette(savefile);}
782  }
783  if(!temporary_file){
784  *savefile << "</svg:svg>"<<std::endl;
785  *savefile << "</svg>"<<std::endl;
786  }
787  savefile->close(); delete savefile;
788 
789  const char * command1;
790  std::string tempfilename = outputfilename + ".coor";
791  if(filetype=="svg"){
792  std::string command = "mv "+tempfilename +" " +outputfilename + ".svg";
793  command1=command.c_str();
794  std::cout << "Executing " << command1 << std::endl;
795  system(command1);
796  }
797 
798 
799  if (temporary_file){ // create root trackermap image
800  int red,green,blue,npoints,colindex,ncolor;
801  double x[4],y[4];
802  std::ifstream tempfile(tempfilename.c_str(),std::ios::in);
803  TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
804  gPad->SetFillColor(38);
805 
806  if(addPixelFlag) {gPad->Range(0,0,3800,1600);}
807  else if(onlyPixelFlag) {gPad->Range(-100,0,800,1600);}
808  else {gPad->Range(800,0,3800,1600);}
809 
810  //First build palette
811  ncolor=0;
812  typedef std::map<int,int> ColorList;
813  ColorList colorList;
814  ColorList::iterator pos;
815  TColor *col, *c;
816  std::cout<<"tempfilename "<<tempfilename<<std::endl;
817  while(!tempfile.eof()) {
818  tempfile >> red >> green >> blue >> npoints;
819  colindex=red+green*1000+blue*1000000;
820  pos=colorList.find(colindex);
821  if(pos == colorList.end()){ colorList[colindex]=ncolor+100; col =gROOT->GetColor(ncolor+100);
822  if(col) col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.)); else c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));vc.push_back(c); ncolor++;}
823  for (int i=0;i<npoints;i++){
824  tempfile >> x[i] >> y[i];
825  }
826  }
827 
828  if(ncolor>0 && ncolor<10000){
829  Int_t colors[10000];
830  for(int i=0;i<ncolor;i++){colors[i]=i+100;}
831  gStyle->SetPalette(ncolor,colors);
832  }
833 
834  tempfile.clear();
835  tempfile.seekg(0,std::ios::beg);
836  std::cout << "created palette with " << ncolor << " colors" << std::endl;
837 
838  while(!tempfile.eof()) {//create polylines
839  tempfile >> red >> green >> blue >> npoints;
840  for (int i=0;i<npoints;i++){
841  tempfile >> x[i] >> y[i];
842  }
843  colindex=red+green*1000+blue*1000000;
844  pos=colorList.find(colindex);
845  if(pos != colorList.end()){
846  TPolyLine* pline = new TPolyLine(npoints,y,x);
847  vp.push_back(pline);
848  pline->SetFillColor(colorList[colindex]);
849  pline->SetLineWidth(0);
850  pline->Draw("f");
851  }
852  }
853  if (printflag) {
854  float lminvalue=minvalue; float lmaxvalue=maxvalue;
855  if(tkMapLog) {lminvalue=log(minvalue)/log(10);lmaxvalue=log(maxvalue)/log(10);}
856  if(onlyPixelFlag) {axis = new TGaxis(-30,36,-30,1530,lminvalue,lmaxvalue,510,"+L");}
857  else {axis = new TGaxis(3660,36,3660,1530,lminvalue,lmaxvalue,510,"+L");}
858  axis->SetLabelSize(0.02);
859  axis->Draw();
860  }
861  TLatex l;
862  l.SetTextSize(0.03);
863  l.DrawLatex(950,1330,"TID");
864  l.DrawLatex(2300,1330,"TEC");
865  l.DrawLatex(300,1330,"FPIX");
866  l.DrawLatex(20,560,"BPIX L1");
867  l.DrawLatex(500,385,"BPIX L2");
868  l.DrawLatex(500,945,"BPIX L3");
869  l.SetTextSize(0.04);
870  std::string fulltitle = title;
871  if(tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos)) fulltitle += ": Log10 scale";
872  if(onlyPixelFlag) {l.DrawLatex(30,1500,fulltitle.c_str());}
873  else {l.DrawLatex(850,1500,fulltitle.c_str());}
874  if(onlyPixelFlag) {l.DrawLatex(380,40,"-z");}
875  else {l.DrawLatex(1730,40,"-z");}
876  if(onlyPixelFlag) {l.DrawLatex(380,1330,"+z");}
877  else {l.DrawLatex(1730,1360,"+z");}
878  l.DrawLatex(1085,330,"TIB L1");
879  l.DrawLatex(1085,1000,"TIB L2");
880  l.DrawLatex(1585,330,"TIB L3");
881  l.DrawLatex(1585,1000,"TIB L4");
882  l.DrawLatex(2085,330,"TOB L1");
883  l.DrawLatex(2085,1000,"TOB L2");
884  l.DrawLatex(2585,330,"TOB L3");
885  l.DrawLatex(2585,1000,"TOB L4");
886  l.DrawLatex(3085,330,"TOB L5");
887  l.DrawLatex(3085,1000,"TOB L6");
888  TArrow arx(3448,1190,3448,1350,0.01,"|>");
889  l.DrawLatex(3460,1350,"x");
890  TArrow ary(3448,1190,3312,1190,0.01,"|>");
891  l.DrawLatex(3312,1210,"y");
892  TArrow arz(3485,373,3485,676,0.01,"|>");
893  l.DrawLatex(3510,667,"z");
894  TArrow arphi(3485,511,3037,511,0.01,"|>");
895  l.DrawLatex(3023,520,"#Phi");
896  arx.SetLineWidth(3);
897  ary.SetLineWidth(3);
898  arz.SetLineWidth(3);
899  arphi.SetLineWidth(3);
900  if(onlyPixelFlag) {
901  arx.SetX1(570);arx.SetX2(570);arx.SetY1(1190);arx.SetY2(1350);
902  l.DrawLatex(570+12,1190+160,"x");
903  ary.SetX1(570);ary.SetX2(570-160);ary.SetY1(1190);ary.SetY2(1190);
904  l.DrawLatex(570-160,1190+30,"y");
905  arz.SetX1(380);arz.SetX2(380);arz.SetY1(683-100);arz.SetY2(683+100);
906  l.DrawLatex(380+15,683+100-9,"z");
907  arphi.SetX1(380);arphi.SetX2(380-390);arphi.SetY1(683);arphi.SetY2(683);
908  l.DrawLatex(380-390-14,683+9,"#Phi");
909  }
910  arx.Draw();
911  ary.Draw();
912  arz.Draw();
913  arphi.Draw();
914  MyC->Update();
915  if(filetype=="png"){
916 
917  std::string filename = outputfilename + ".png";
918  std::cout << "printing " <<filename<< std::endl;
919  MyC->Print(filename.c_str());
920  }
921  if(filetype=="jpg"){
922  std::string filename = outputfilename + ".jpg";
923  MyC->Print(filename.c_str());
924  }
925  if(filetype=="pdf"){
926  std::string filename = outputfilename + ".pdf";
927  MyC->Print(filename.c_str());
928  }
929  std::string command = "rm "+tempfilename ;
930  command1=command.c_str();
931  std::cout << "Executing " << command1 << std::endl;
932  system(command1);
933  MyC->Clear();
934  delete MyC;
935  if (printflag)delete axis;
936  for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
937  delete (*pos1);}
938 
939  }
940  }
941  return;
942 }
943 void TrackerMap::drawApvPair(int crate, int numfed_incrate, bool print_total, TmApvPair* apvPair,std::ofstream * svgfile,bool useApvPairValue)
944 {
945  double xp[4],yp[4];
946  int color;
947  int green = 0;
948  int red = 0;
949  int blue = 0;
950  double xd[4],yd[4];
951  int np = 4;
952  double boxinitx=0., boxinity=0.;
953  double dx=.9,dy=.9;
954  /*
955  int numfedch_incolumn = 12;
956  int numfedch_inrow = 8;
957  int numfed_incolumn = 6;
958  int numfed_inrow = 4;
959  */
960  boxinitx=boxinitx+(NUMFED_INCOLUMN-1-(numfed_incrate-1)/NUMFED_INROW)*(NUMFEDCH_INCOLUMN+2);
961  boxinity=boxinity+(NUMFED_INROW-1-(numfed_incrate-1)%NUMFED_INROW)*(NUMFEDCH_INROW+1);
962  boxinity=boxinity+NUMFEDCH_INROW-(apvPair->getFedCh()/NUMFEDCH_INCOLUMN);
963  boxinitx = boxinitx+NUMFEDCH_INCOLUMN-(int)(apvPair->getFedCh()%NUMFEDCH_INCOLUMN);
964  // std::cout << crate << " " << numfed_incrate << " " << apvPair->getFedCh()<<" "<<boxinitx<< " " << boxinity << std::endl; ;
965  xp[0]=boxinitx;yp[0]=boxinity;
966  xp[1]=boxinitx+dx;yp[1]=boxinity;
967  xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
968  xp[3]=boxinitx;yp[3]=boxinity + dy;
969  for(int j=0;j<4;j++){
970  xd[j]=xdpixelc(xp[j]);yd[j]=ydpixelc(yp[j]);
971  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
972  }
973 
974  char buffer [20];
975  sprintf(buffer,"%X",apvPair->mod->idex);
976  std::string s = apvPair->mod->name;
977  s.erase(s.begin()+s.find("connected"),s.end());
978 
979  if(useApvPairValue){
980  if(apvPair->red < 0){ //use count to compute color
981  if(apvPair->count > 0) {
982  color = getcolor(apvPair->value,palette);
983  red=(color>>16)&0xFF;
984  green=(color>>8)&0xFF;
985  blue=(color)&0xFF;
986  if(!print_total)apvPair->value=apvPair->value*apvPair->count;//restore mod->value
987  if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
988  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=\"";
989  } else {
990  if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
991  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=\"";
992  }
993  } else {//color defined with fillc
994  if(apvPair->red>255)apvPair->red=255;
995  if(apvPair->green>255)apvPair->green=255;
996  if(apvPair->blue>255)apvPair->blue=255;
997  if(temporary_file)*svgfile << apvPair->red << " " << apvPair->green << " " << apvPair->blue << " ";
998  else *svgfile <<"<svg:polygon detid=\""<<apvPair->idex<<"\" count=\""<<apvPair->count <<"\" value=\""<<apvPair->value<<"\" id=\""<<apvPair->idex+crate*1000000<<"\" cmodid=\""<<apvPair->mod->getKey()<<"\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\"""\" POS=\"Fed/Ch "<<apvPair->getFedId()<<"/"<<apvPair->getFedCh()<<" connected to "<<s<<" Id "<<buffer<<" \" fill=\"rgb("<<apvPair->red<<","<<apvPair->green<<","<<apvPair->blue<<")\" points=\"";
999  }
1000  }else{
1001  if(apvPair->mod->red < 0){ //use count to compute color
1002  if(apvPair->mod->count > 0) {
1003  color = getcolor(apvPair->mod->value,palette);
1004  red=(color>>16)&0xFF;
1005  green=(color>>8)&0xFF;
1006  blue=(color)&0xFF;
1007  if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
1008  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=\"";
1009  } else {
1010  if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
1011  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=\"";
1012  }
1013  } else {//color defined with fillc
1014  if(apvPair->mod->red>255)apvPair->mod->red=255;
1015  if(apvPair->mod->green>255)apvPair->mod->green=255;
1016  if(apvPair->mod->blue>255)apvPair->mod->blue=255;
1017  if(temporary_file)*svgfile << apvPair->mod->red << " " << apvPair->mod->green << " " << apvPair->mod->blue << " ";
1018  else *svgfile <<"<svg:polygon detid=\""<<apvPair->idex<<"\" count=\""<<apvPair->count <<"\" value=\""<<apvPair->value<<"\" id=\""<<apvPair->idex+crate*1000000<<"\" cmodid=\""<<apvPair->mod->getKey()<<"\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\"""\" POS=\"Fed/Ch "<<apvPair->getFedId()<<"/"<<apvPair->getFedCh()<<" connected to "<<s<<" Id "<<buffer<<" \" fill=\"rgb("<<apvPair->mod->red<<","<<apvPair->mod->green<<","<<apvPair->mod->blue<<")\" points=\"";
1019  }
1020  }
1021  if(temporary_file)*svgfile << np << " ";
1022  for(int k=0;k<np;k++){
1023  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
1024  else *svgfile << xd[k] << "," << yd[k] << " " ;
1025  }
1026  if(temporary_file)*svgfile << std::endl;
1027  else *svgfile <<"\" />" <<std::endl;
1028 }
1029 void TrackerMap::drawCcu(int crate, int numfec_incrate, bool print_total, TmCcu* ccu,std::ofstream * svgfile,bool useCcuValue)
1030 {
1031  double xp[4],yp[4];
1032  int color;
1033  int green = 0;
1034  int red = 0;
1035  int blue = 0;
1036  double xd[4],yd[4];
1037  int np = 4;
1038  double boxinitx=0., boxinity=0.;
1039  double dx=.9,dy=.9;
1040  int numccu_incolumn = 8;
1041  int numccu_inrow = 15;
1042  int numfec_incolumn = 5;
1043  int numfec_inrow = 4;
1044  boxinitx=boxinitx+(numfec_incolumn-(numfec_incrate-1)/numfec_inrow)*14.;
1045  boxinity=boxinity+(numfec_inrow-(numfec_incrate-1)%numfec_inrow)*16.;
1046  boxinity=boxinity+numccu_inrow-ccu->mpos;
1047  boxinitx = boxinitx+numccu_incolumn-(int)(ccu->getCcuRing()%numccu_incolumn);
1048  //std::cout << crate << " " << numfec_incrate << " " << ccu->getCcuRing()<<" "<<ccu->mpos<<" "<<boxinitx<< " " << boxinity << std::endl; ;
1049  xp[0]=boxinitx;yp[0]=boxinity;
1050  xp[1]=boxinitx+dx;yp[1]=boxinity;
1051  xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
1052  xp[3]=boxinitx;yp[3]=boxinity + dy;
1053  for(int j=0;j<4;j++){
1054  xd[j]=xdpixelfec(xp[j]);yd[j]=ydpixelfec(yp[j]);
1055  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1056  }
1057 
1058  char buffer [20];
1059  sprintf(buffer,"%X",ccu->idex);
1060  //sprintf(buffer,"%X",ccu->mod->idex);
1061  //std::string s = ccu->mod->name;
1062  std::string s = ccu->text;
1063  s.erase(s.begin()+s.find("connected"),s.end());
1064 
1065  if(ccu->red < 0){ //use count to compute color
1066  if(ccu->count > 0) {
1067  color = getcolor(ccu->value,palette);
1068  red=(color>>16)&0xFF;
1069  green=(color>>8)&0xFF;
1070  blue=(color)&0xFF;
1071  if(!print_total)ccu->value=ccu->value*ccu->count;//restore mod->value
1072  if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
1073  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=\"";
1074  } else {
1075  if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
1076  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=\"";
1077  }
1078  } else {//color defined with fillc
1079  if(ccu->red>255)ccu->red=255;
1080  if(ccu->green>255)ccu->green=255;
1081  if(ccu->blue>255)ccu->blue=255;
1082  if(temporary_file)*svgfile << ccu->red << " " << ccu->green << " " << ccu->blue << " ";
1083  else *svgfile <<"<svg:polygon detid=\""<<ccu->idex<<"\" count=\""<<ccu->count <<"\" value=\""<<ccu->value<<"\" id=\""<<ccu->idex+crate*1000000<<"\" cmodid=\""<<ccu->cmodid<<"\" layer=\""<<ccu->layer<<"\" onclick=\"showData(evt);\" onmouseover=\"showData(evt);\" onmouseout=\"showData(evt);\" MESSAGE=\"""\" POS=\"Slot/Ring "<<ccu->getCcuSlot()<<"/"<<ccu->getCcuRing()<<" connected to "<<s<<" Id "<<buffer<<" \" fill=\"rgb("<<ccu->red<<","<<ccu->green<<","<<ccu->blue<<")\" points=\"";
1084  }
1085 if(temporary_file)*svgfile << np << " ";
1086 for(int k=0;k<np;k++){
1087  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
1088  else *svgfile << xd[k] << "," << yd[k] << " " ;
1089 }
1090 if(temporary_file)*svgfile << std::endl;
1091 else *svgfile <<"\" />" <<std::endl;
1092 
1093 }
1094 void TrackerMap::drawPsu(int rack,int numcrate_inrack , bool print_total, TmPsu* psu,std::ofstream * svgfile,bool usePsuValue)
1095 {
1096  double xp[4],yp[4];
1097  int color;
1098  int green = 0;
1099  int red = 0;
1100  int blue = 0;
1101  double xd[4],yd[4];
1102  int np = 4;
1103  double boxinitx=0., boxinity=0.;
1104  double dx=.9,dy=.9;
1105 
1106  boxinitx=boxinitx+(NUMPSUCRATE_INCOLUMN-psu->getPsuCrate())*1.5;
1107  boxinity=boxinity+(NUMPSUCH_INROW-psu->getPsuBoard());
1108 
1109  xp[0]=boxinitx;yp[0]=boxinity;
1110  xp[1]=boxinitx+dx;yp[1]=boxinity;
1111  xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
1112  xp[3]=boxinitx;yp[3]=boxinity + dy;
1113 
1114 
1115  for(int j=0;j<4;j++){
1116  xd[j]=xdpixelpsu(xp[j]);yd[j]=ydpixelpsu(yp[j]);
1117  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1118  }
1119 
1120  // lines needed to prepare the clickable maps: understand why I get twice the full list of channels (HV1 and HV0?)
1121  /*
1122  double scalex=2695./2700.;
1123  double scaley=1520./1550.;
1124  std::cout << "<area shape=\"rect\" coords=\" "
1125  << int(scalex*yd[2]) << "," << int(1520-scaley*xd[2])
1126  << "," << int(scalex*yd[0]) << "," << int(1520-scaley*xd[0])
1127  << "\" title=\" " << psu->psId << "\" /> " << std::endl;
1128  */
1129  //
1130 
1131  char buffer [20];
1132  sprintf(buffer,"%X",psu->idex);
1133  std::string s = psu->text;
1134  s.erase(s.begin()+s.find("connected"),s.end());
1135 
1136  if(psu->red < 0){ //use count to compute color
1137  if(psu->count > 0){
1138  color = getcolor(psu->value,palette);
1139  red=(color>>16)&0xFF;
1140  green=(color>>8)&0xFF;
1141  blue=(color)&0xFF;
1142  if(!print_total)psu->value=psu->value*psu->count;//restore mod->value
1143  if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
1144  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=\"";
1145  }
1146  else{
1147 
1148  if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
1149  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=\"";
1150  }
1151  }
1152 
1153  else {//color defined with fillc
1154  if(psu->red>255)psu->red=255;
1155  if(psu->green>255)psu->green=255;
1156  if(psu->blue>255)psu->blue=255;
1157  if(temporary_file)*svgfile << psu->red << " " << psu->green << " " << psu->blue << " ";
1158  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=\"";
1159  }
1160 
1161 if(temporary_file)*svgfile << np << " ";
1162 for(int k=0;k<np;k++){
1163  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
1164  else *svgfile << xd[k] << "," << yd[k] << " " ;
1165 }
1166 if(temporary_file)*svgfile << std::endl;
1167 else *svgfile <<"\" />" <<std::endl;
1168 
1169 }
1170 
1171 void TrackerMap::drawHV2(int rack,int numcrate_inrack , bool print_total, TmPsu* psu,std::ofstream * svgfile,bool usePsuValue)
1172 {
1173  double xp[4],yp[4];
1174  int color;
1175  int greenHV2 = 0;
1176  int redHV2 = 0;
1177  int blueHV2 = 0;
1178  double xd[4],yd[4];
1179  int np = 4;
1180  double boxinitx=35, boxinity=12;
1181  double dx=1.1,dy=1.3;
1182 
1183  boxinitx= boxinitx+(5 - psu->getPsuCrate())*5;
1184  boxinity= boxinity+(18 - psu->getPsuBoard())*1.75;
1185 
1186  xp[0]=boxinitx;yp[0]=boxinity;
1187  xp[1]=boxinitx+dx;yp[1]=boxinity;
1188  xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
1189  xp[3]=boxinitx;yp[3]=boxinity + dy;
1190 
1191 
1192  for(int j=0;j<4;j++){
1193  xd[j]=xdpixelpsu(xp[j]);yd[j]=ydpixelpsu(yp[j]);
1194  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1195  }
1196 
1197  char buffer [20];
1198  sprintf(buffer,"%X",psu->idex);
1199  std::string s = psu->textHV2;
1200  s.erase(s.begin()+s.find("connected"),s.end());
1201 
1202  if(psu->redHV2 < 0){ //use count to compute color
1203 
1204  if(psu->valueHV2 > 0){
1205  color = getcolor(psu->valueHV2,palette);
1206  redHV2=(color>>16)&0xFF;
1207  greenHV2=(color>>8)&0xFF;
1208  blueHV2=(color)&0xFF;
1209  if(!print_total)psu->valueHV2=psu->valueHV2*psu->countHV2;//restore mod->value
1210  if(temporary_file)*svgfile << redHV2 << " " << greenHV2 << " " << blueHV2 << " ";
1211  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=\"";
1212  }
1213  else{
1214  if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
1215  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=\"";
1216  }
1217  }
1218 
1219  else {//color defined with fillc
1220  if(psu->redHV2>255)psu->redHV2=255;
1221  if(psu->greenHV2>255)psu->greenHV2=255;
1222  if(psu->blueHV2>255)psu->blueHV2=255;
1223  if(temporary_file)*svgfile << psu->redHV2 << " " << psu->greenHV2 << " " << psu->blueHV2 << " ";
1224  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=\"";
1225  }
1226 
1227 if(temporary_file)*svgfile << np << " ";
1228 for(int k=0;k<np;k++){
1229  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
1230  else *svgfile << xd[k] << "," << yd[k] << " " ;
1231 }
1232 if(temporary_file)*svgfile << std::endl;
1233 else *svgfile <<"\" />" <<std::endl;
1234 
1235 }
1236 
1237 
1238 void TrackerMap::drawHV3(int rack,int numcrate_inrack , bool print_total, TmPsu* psu,std::ofstream * svgfile,bool usePsuValue)
1239 {
1240  double xp[4],yp[4];
1241  int color;
1242  int greenHV3 = 0;
1243  int redHV3 = 0;
1244  int blueHV3 = 0;
1245  double xd[4],yd[4];
1246  int np = 4;
1247  double boxinitx=36.5, boxinity=12;
1248  double dx=1.1,dy=1.3;
1249 
1250  boxinitx= boxinitx+(5 - psu->getPsuCrate())*5;
1251  boxinity= boxinity+(18 - psu->getPsuBoard())*1.75;
1252 
1253  xp[0]=boxinitx;yp[0]=boxinity;
1254  xp[1]=boxinitx+dx;yp[1]=boxinity;
1255  xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
1256  xp[3]=boxinitx;yp[3]=boxinity + dy;
1257 
1258 
1259  for(int j=0;j<4;j++){
1260  xd[j]=xdpixelpsu(xp[j]);yd[j]=ydpixelpsu(yp[j]);
1261  //std::cout << boxinity << " "<< ymax << " "<< yp[j] << std::endl;
1262  }
1263 
1264  char buffer [20];
1265  sprintf(buffer,"%X",psu->idex);
1266  std::string s = psu->textHV3;
1267  s.erase(s.begin()+s.find("connected"),s.end());
1268 
1269  if(psu->redHV3 < 0){ //use count to compute color
1270  if(psu->valueHV3 > 0){
1271  color = getcolor(psu->valueHV3,palette);
1272  redHV3=(color>>16)&0xFF;
1273  greenHV3=(color>>8)&0xFF;
1274  blueHV3=(color)&0xFF;
1275  if(!print_total)psu->valueHV3=psu->valueHV3*psu->countHV3;//restore mod->value
1276  if(temporary_file)*svgfile << redHV3 << " " << greenHV3 << " " << blueHV3 << " ";
1277  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=\"";
1278  }
1279  else{
1280  if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
1281  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=\"";
1282  }
1283  }
1284 
1285  else {//color defined with fillc
1286  if(psu->redHV3>255)psu->redHV3=255;
1287  if(psu->greenHV3>255)psu->greenHV3=255;
1288  if(psu->blueHV3>255)psu->blueHV3=255;
1289  if(temporary_file)*svgfile << psu->redHV3 << " " << psu->greenHV3 << " " << psu->blueHV3 << " ";
1290  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=\"";
1291  }
1292 
1293 if(temporary_file)*svgfile << np << " ";
1294 for(int k=0;k<np;k++){
1295  if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
1296  else *svgfile << xd[k] << "," << yd[k] << " " ;
1297 }
1298 if(temporary_file)*svgfile << std::endl;
1299 else *svgfile <<"\" />" <<std::endl;
1300 
1301 }
1302 
1303 void TrackerMap::save_as_fectrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
1304 
1305  if(enableFecProcessing){
1306  std::string filetype=s,outputfilename=s;
1307  std::vector<TPolyLine*> vp;
1308  TGaxis *axis = 0 ;
1309  size_t found=filetype.find_last_of(".");
1310  filetype=filetype.substr(found+1);
1311  found=outputfilename.find_last_of(".");
1312  outputfilename=outputfilename.substr(0,found);
1313  temporary_file=true;
1314  if(filetype=="xml"||filetype=="svg")temporary_file=false;
1315  std::ostringstream outs;
1316  minvalue=minval; maxvalue=maxval;
1317  outs << outputfilename << ".coor";
1318  if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
1319  std::map<int , TmCcu *>::iterator i_ccu;
1320  std::multimap<TmCcu*, TmModule*>::iterator it;
1321  std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
1322  //Decide if we must use Module or Ccu value
1323  bool useCcuValue=false;
1324 
1325 
1326  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1327  TmCcu * ccu= i_ccu->second;
1328  if(ccu!=0) {
1329  if(ccu->count > 0 || ccu->red!=-1) { useCcuValue=true; break;}
1330  }
1331  }
1332 
1333 
1334  if(!useCcuValue)//store mean of connected modules value{
1335  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1336  TmCcu * ccu= i_ccu->second;
1337  if(ccu!=0) {
1338  ret = fecModuleMap.equal_range(ccu);
1339  for (it = ret.first; it != ret.second; ++it)
1340  {
1341  if( (*it).second->count>0){ccu->value=ccu->value+(*it).second->value;ccu->count++;}
1342  }
1343  if(ccu->count>0)ccu->value=ccu->value/ccu->count;
1344  if(ccu->nmod==0) { ccu->red=0;ccu->green=0;ccu->blue=0;}
1345  }
1346  }
1347 
1348 
1349  if(title.find("QTestAlarm")!=std::string::npos){
1350  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1351  TmCcu * ccu= i_ccu->second;
1352  if(ccu!=0) {
1353  ret = fecModuleMap.equal_range(ccu);
1354  ccu->red=0;ccu->green=255;ccu->blue=0;
1355  for (it = ret.first; it != ret.second; ++it) {
1356  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 ) ){
1357  ccu->red=255;ccu->green=0;ccu->blue=0;
1358  }
1359  }
1360  }
1361  }
1362  }
1363 
1364 
1365 
1366  if(!print_total){
1367  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1368  TmCcu * ccu= i_ccu->second;
1369  if(ccu!=0) {
1370  if(useCcuValue) ccu->value = ccu->value / ccu->count;
1371 
1372  }
1373  }
1374  }
1375 
1376  if(minvalue>=maxvalue){
1377 
1378  minvalue=9999999.;
1379  maxvalue=-9999999.;
1380  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1381  TmCcu * ccu= i_ccu->second;
1382  if(ccu!=0 && ccu->count>0) {
1383  if (minvalue > ccu->value)minvalue=ccu->value;
1384  if (maxvalue < ccu->value)maxvalue=ccu->value;
1385  }
1386  }
1387  }
1388 
1389 
1390 
1391  if(filetype=="svg"){
1392  saveAsSingleLayer=false;
1393  std::ostringstream outs;
1394  outs << outputfilename<<".svg";
1395  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
1396  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
1397  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
1398  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
1399  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
1400  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
1401  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
1402  *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
1403  }
1404  for (int crate=1; crate < (nfeccrates+1); crate++){
1405  if(filetype=="xml"){
1406  saveAsSingleLayer=true;
1407  std::ostringstream outs;
1408  outs << outputfilename<<"feccrate" <<crate<< ".xml";
1409  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
1410  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
1411  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
1412  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
1413  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
1414  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"feccrate.js\" />"<<std::endl;
1415  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<std::endl;
1416  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
1417  *savefile << "<g id=\"crate\" transform=\" translate(280,580) rotate(270) scale(.7,.8)\" > "<<std::endl;
1418  }
1419  // ncrate=crate;
1420  deffecwindow(crate);
1421 
1422  for ( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1423  TmCcu * ccu= i_ccu->second;
1424  if(ccu!=0){
1425  if(ccu->getCcuCrate() == crate){
1426 
1427  drawCcu(crate,ccu->getCcuSlot()-2,print_total,ccu,savefile,useCcuValue);
1428  }
1429  }
1430  }
1431 
1432  if(!temporary_file){
1433  if(filetype=="xml"){
1434  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
1435  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
1436  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
1437  *savefile << " </text> </svg>" << std::endl;
1438  savefile->close();
1439  saveAsSingleLayer=false;
1440  }
1441  }
1442  }
1443  if(filetype=="svg"){
1444  *savefile << "</g> </svg> </svg> " << std::endl;
1445  savefile->close();
1446  }
1447  if(!print_total && !useCcuValue){
1448 //Restore ccu value
1449  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
1450  TmCcu * ccu= i_ccu->second;
1451  if(ccu!=0) {
1452  ccu->value = ccu->value * ccu->count;
1453  }
1454 }
1455 }
1456  if(temporary_file){
1458  savefile->close();
1459 
1460  const char * command1;
1461  std::string tempfilename = outputfilename + ".coor";
1462  int red,green,blue,npoints,colindex,ncolor;
1463  double x[4],y[4];
1464  std::ifstream tempfile(tempfilename.c_str(),std::ios::in);
1465  TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
1466  gPad->SetFillColor(38);
1467 
1468  if(saveWebInterface)gPad->Range(0,0,3700,1600); else gPad->Range(0,0,3800,1600);
1469 
1470  //First build palette
1471  ncolor=0;
1472  typedef std::map<int,int> ColorList;
1473  ColorList colorList;
1474  ColorList::iterator pos;
1475  TColor *col,*c;
1476  while(!tempfile.eof()) {
1477  tempfile >> red >> green >> blue >> npoints;
1478  colindex=red+green*1000+blue*1000000;
1479  pos=colorList.find(colindex);
1480  if(pos == colorList.end()){
1481  colorList[colindex]=ncolor+100;
1482  col =gROOT->GetColor(ncolor+100);
1483  if(col)
1484  col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
1485  else
1486  c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
1487  vc.push_back(c);
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){
1565  std::string filetype=s,outputfilename=s;
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  ncolor++;
1770  }
1771  for (int i=0;i<npoints;i++){
1772  tempfile >> x[i] >> y[i];
1773  }
1774  }
1775  if(ncolor>0 && ncolor<10000){
1776  Int_t colors[10000];
1777  for(int i=0;i<ncolor;i++){colors[i]=i+100;}
1778  gStyle->SetPalette(ncolor,colors);
1779  }
1780  tempfile.clear();
1781  tempfile.seekg(0,std::ios::beg);
1782  std::cout << "created palette with " << ncolor << " colors" << std::endl;
1783  while(!tempfile.eof()) {//create polylines
1784  tempfile >> red >> green >> blue >> npoints;
1785  for (int i=0;i<npoints;i++){
1786  tempfile >> x[i] >> y[i];
1787  }
1788  colindex=red+green*1000+blue*1000000;
1789  pos=colorList.find(colindex);
1790  if(pos != colorList.end()){
1791  TPolyLine* pline = new TPolyLine(npoints,y,x);
1792  vp.push_back(pline);
1793  pline->SetFillColor(colorList[colindex]);
1794  pline->SetLineWidth(0);
1795  pline->Draw("f");
1796  }
1797  }
1798  if (printflag&&!saveWebInterface) {
1799  float lminvalue=minvalue; float lmaxvalue=maxvalue;
1800  if(tkMapLog) {lminvalue=log(minvalue)/log(10);lmaxvalue=log(maxvalue)/log(10);}
1801  axis = new TGaxis(3660,36,3660,1530,lminvalue,lmaxvalue,510,"+L");
1802  axis->SetLabelSize(0.02);
1803  axis->Draw();
1804  }
1805 
1806 
1807  if(!saveWebInterface){
1808  TLatex l;
1809  l.SetTextSize(0.05);
1810  std::string fulltitle = title;
1811  if(tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos)) fulltitle += ": Log10 scale";
1812  l.DrawLatex(50,1530,fulltitle.c_str());
1813  }
1814  MyC->Update();
1815  std::cout << "Filetype " << filetype << std::endl;
1816  if(filetype=="png"){
1817  std::string filename = outputfilename + ".png";
1818  MyC->Print(filename.c_str());
1819  }
1820  if(filetype=="jpg"){
1821  std::string filename = outputfilename + ".jpg";
1822  MyC->Print(filename.c_str());
1823  }
1824  if(filetype=="pdf"){
1825  std::string filename = outputfilename + ".pdf";
1826  MyC->Print(filename.c_str());
1827  }
1828  std::string command = "rm "+tempfilename ;
1829  command1=command.c_str();
1830  std::cout << "Executing " << command1 << std::endl;
1831  system(command1);
1832  MyC->Clear();
1833  delete MyC;
1834  if (printflag&&!saveWebInterface)delete axis;
1835  for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
1836  delete (*pos1);}
1837 
1838 
1839  }//if(temporary_file)
1840 }//if(enabledHVProcessing)
1841 }
1842 
1843 
1844 void TrackerMap::save_as_psutrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
1845 
1846  if(enableLVProcessing){
1847 
1848  printflag=true;
1849  bool rangefound=true;
1850  std::string filetype=s,outputfilename=s;
1851  std::vector<TPolyLine*> vp;
1852  TGaxis *axis = 0 ;
1853 
1854  size_t found=filetype.find_last_of(".");
1855  filetype=filetype.substr(found+1);
1856  found=outputfilename.find_last_of(".");
1857  outputfilename=outputfilename.substr(0,found);
1858 
1859  temporary_file=true;
1860 
1861 
1862 
1863  if(filetype=="xml"||filetype=="svg")temporary_file=false;
1864 
1865  std::ostringstream outs;
1866  minvalue=minval; maxvalue=maxval;
1867  outs << outputfilename << ".coor";
1868  if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
1869 
1870  std::map<int , TmPsu *>::iterator ipsu;
1871  std::multimap<TmPsu*, TmModule*>::iterator it;
1872  std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
1873 
1874  //Decide if we must use Module or Power Psupply value
1875  bool usePsuValue=false;
1876 
1877  for( ipsu=psuMap.begin();ipsu!=psuMap.end(); ipsu++){
1878  TmPsu* psu= ipsu->second;
1879  if(psu!=0) {
1880  if(psu->count > 0 || psu->red!=-1) { usePsuValue=true; break;}
1881  }
1882  }
1883 
1884  if(!usePsuValue){//store mean of connected modules value{
1885  for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
1886  TmPsu * psu= ipsu->second;
1887  if(psu!=0) {
1888  ret = psuModuleMap.equal_range(psu);
1889  int nconn=0;
1890  for(it = ret.first; it != ret.second; ++it){
1891  if((*it).second->count>0){nconn++;psu->value=psu->value+(*it).second->value;}
1892 
1893  }
1894  if(nconn>0){ psu->value=psu->value/psu->nmod; psu->count=1;}
1895 
1896  }
1897  }
1898  }
1899 
1900  if(title.find("QTestAlarm")!=std::string::npos){
1901  for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
1902  TmPsu * psu= ipsu->second;
1903  if(psu!=0) {
1904  ret = psuModuleMap.equal_range(psu);
1905  // psu->red=255;psu->green=255;psu->blue=255;
1906  psu->red=-1;
1907  int nconn=0;
1908  for (it = ret.first; it != ret.second; ++it) {
1909  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 ) ){
1910  nconn++;psu->value++;
1911  }
1912  }
1913  if(nconn>0){ psu->value=psu->value/psu->nmod; psu->count=1;}
1914  }
1915  }
1916  }
1917 
1918 
1919 
1920  if(!print_total){
1921  for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
1922  TmPsu * psu= ipsu->second;
1923  if(psu!=0) {
1924  if(usePsuValue) psu->value = psu->value / psu->count;
1925 
1926  }
1927  }
1928  }
1929 
1930  if(minvalue>=maxvalue){
1931 
1932  minvalue=9999999.;
1933  maxvalue=-9999999.;
1934  rangefound=false;
1935  for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
1936  TmPsu * psu= ipsu->second;
1937  if(psu!=0 && psu->count>0) {
1938  rangefound = true;
1939  if (minvalue > psu->value)minvalue=psu->value;
1940  if (maxvalue < psu->value)maxvalue=psu->value;
1941  }
1942  }
1943  }
1944  if ((maxvalue == minvalue)||!rangefound) printflag = false;
1945 
1946 
1947  if(filetype=="svg"){
1948  saveAsSingleLayer=false;
1949  std::ostringstream outs;
1950  outs << outputfilename<<".svg";
1951  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
1952  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
1953  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
1954  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
1955  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
1956  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
1957  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
1958  *savefile << "<svg:g id=\"psutrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
1959  }
1960 
1961  for (int irack=1; irack < (npsuracks+1); irack++){
1962  if(filetype=="xml"){
1963  saveAsSingleLayer=true;
1964  std::ostringstream outs;
1965  outs << outputfilename<<"psurack" <<irack<< ".xml";
1966  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
1967  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
1968  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
1969  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
1970  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
1971  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rack.js\" />"<<std::endl;
1972  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<std::endl;
1973  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
1974  *savefile << "<g id=\"rack\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > "<<std::endl;
1975  }
1976 
1977 
1978  // nrack=irack;
1979  defpsuwindow(irack);
1980  for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
1981  TmPsu * psu= ipsu->second;
1982  if(psu->getPsuRack() == irack){
1983 
1984  drawPsu(irack,psu->getPsuCrate(),print_total,psu,savefile,usePsuValue);
1985  }
1986  }
1987 
1988 
1989  if(!temporary_file){
1990  if(filetype=="xml"){
1991  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
1992  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
1993  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
1994  *savefile << " </text> </svg>" << std::endl;
1995  savefile->close();
1996  saveAsSingleLayer=false;
1997  }
1998  }
1999  }
2000  if(filetype=="svg"){
2001  *savefile << "</g> </svg> </svg> " << std::endl;
2002  savefile->close();
2003  }
2004 
2005  //Restore psu value
2006  if(!print_total && !usePsuValue){
2007  for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
2008  TmPsu *psu = ipsu->second;
2009  if(psu!=0) {
2010  psu->value = psu->value * psu->count;
2011  }
2012  }
2013  }
2014 
2015  int rangex=YPSUOFFSET+(YPSURSIZE+YPSUOFFSET)*NUMPSURACK_INROW+300;
2017 
2018 
2019  if(temporary_file){
2020  if(printflag&&!saveWebInterface)drawPalette(savefile,rangex-140,rangey-100);
2021  savefile->close();
2022 
2023  const char * command1;
2024  std::string tempfilename = outputfilename + ".coor";
2025  int red,green,blue,npoints,colindex,ncolor;
2026  double x[4],y[4];
2027  std::ifstream tempfile(tempfilename.c_str(),std::ios::in);
2028  TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
2029  gPad->SetFillColor(38);
2030 
2031  // if(saveWebInterface)gPad->Range(0,0,3700,1600); else gPad->Range(0,0,3800,1600);
2032  std::cout << " range x " << rangex << std::endl;
2033  std::cout << " range y " << rangey << std::endl;
2034  gPad->Range(0,0,rangex,rangey);
2035 
2036  //First build palette
2037  ncolor=0;
2038  typedef std::map<int,int> ColorList;
2039  ColorList colorList;
2040  ColorList::iterator pos;
2041  TColor *col,*c;
2042  while(!tempfile.eof()) {
2043  tempfile >> red >> green >> blue >> npoints;
2044  colindex=red+green*1000+blue*1000000;
2045  pos=colorList.find(colindex);
2046  if(pos == colorList.end()){
2047  colorList[colindex]=ncolor+100;
2048  col =gROOT->GetColor(ncolor+100);
2049  if(col)
2050  col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
2051  else
2052  c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
2053  vc.push_back(c);
2054  ncolor++;
2055  }
2056  for (int i=0;i<npoints;i++){
2057  tempfile >> x[i] >> y[i];
2058  }
2059  }
2060  if(ncolor>0 && ncolor<10000){
2061  Int_t colors[10000];
2062  for(int i=0;i<ncolor;i++){colors[i]=i+100;}
2063  gStyle->SetPalette(ncolor,colors);
2064  }
2065  tempfile.clear();
2066  tempfile.seekg(0,std::ios::beg);
2067  std::cout << "created palette with " << ncolor << " colors" << std::endl;
2068  while(!tempfile.eof()) {//create polylines
2069  tempfile >> red >> green >> blue >> npoints;
2070  for (int i=0;i<npoints;i++){
2071  tempfile >> x[i] >> y[i];
2072  }
2073  colindex=red+green*1000+blue*1000000;
2074  pos=colorList.find(colindex);
2075  if(pos != colorList.end()){
2076  TPolyLine* pline = new TPolyLine(npoints,y,x);
2077  vp.push_back(pline);
2078  pline->SetFillColor(colorList[colindex]);
2079  pline->SetLineWidth(0);
2080  pline->Draw("f");
2081  }
2082  }
2083  if (printflag&&!saveWebInterface) {
2084  float lminvalue=minvalue; float lmaxvalue=maxvalue;
2085  if(tkMapLog) {lminvalue=log(minvalue)/log(10);lmaxvalue=log(maxvalue)/log(10);}
2086  axis = new TGaxis(rangex-140,34,rangex-140,rangey-106,lminvalue,lmaxvalue,510,"+L");
2087  axis->SetLabelSize(0.02);
2088  axis->Draw();
2089  }
2090 
2091  if(!saveWebInterface){
2092  TLatex l;
2093  l.SetTextSize(0.05);
2094  std::string fulltitle = title;
2095  if(tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos)) fulltitle += ": Log10 scale";
2096  l.DrawLatex(50,rangey-200,fulltitle.c_str());
2097  }
2098  MyC->Update();
2099  std::cout << "Filetype " << filetype << std::endl;
2100  if(filetype=="png"){
2101  std::string filename = outputfilename + ".png";
2102  MyC->Print(filename.c_str());
2103  }
2104  if(filetype=="jpg"){
2105  std::string filename = outputfilename + ".jpg";
2106  MyC->Print(filename.c_str());
2107  }
2108  if(filetype=="pdf"){
2109  std::string filename = outputfilename + ".pdf";
2110  MyC->Print(filename.c_str());
2111  }
2112  std::string command = "rm "+tempfilename ;
2113  command1=command.c_str();
2114  std::cout << "Executing " << command1 << std::endl;
2115  system(command1);
2116  MyC->Clear();
2117  delete MyC;
2118  if (printflag&&!saveWebInterface)delete axis;
2119  for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
2120  delete (*pos1);}
2121 
2122 }//if(temporary_file)
2123 }//if(enabledFedProcessing)
2124 }
2125 
2126 void TrackerMap::save_as_fedtrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
2127  if(enableFedProcessing){
2128  printflag=true;
2129  bool rangefound = true;
2130  std::string filetype=s,outputfilename=s;
2131  std::vector<TPolyLine*> vp;
2132  TGaxis *axis = 0 ;
2133 
2134  size_t found=filetype.find_last_of(".");
2135  filetype=filetype.substr(found+1);
2136  found=outputfilename.find_last_of(".");
2137  outputfilename=outputfilename.substr(0,found);
2138 
2139  temporary_file=true;
2140  if(filetype=="xml"||filetype=="svg")temporary_file=false;
2141  std::ostringstream outs;
2142  minvalue=minval; maxvalue=maxval;
2143  outs << outputfilename << ".coor";
2144  if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
2145  std::map<int , TmApvPair *>::iterator i_apv;
2146  std::map<int , int>::iterator i_fed;
2147  //Decide if we must use Module or ApvPair value
2148  bool useApvPairValue=false;
2149  for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
2150  TmApvPair * apvPair= i_apv->second;
2151  if(apvPair!=0) {
2152  TmModule * apv_mod = apvPair->mod;
2153  if(apv_mod !=0 && !apv_mod->notInUse()){
2154  if(apvPair->count > 0 || apvPair->red!=-1) { useApvPairValue=true; break;}
2155  }
2156  }
2157  }
2158  if(!print_total){
2159  for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
2160  TmApvPair * apvPair= i_apv->second;
2161  if(apvPair!=0) {
2162  TmModule * apv_mod = apvPair->mod;
2163  if(apv_mod !=0 && !apv_mod->notInUse() ){
2164  if(useApvPairValue) apvPair->value = apvPair->value / apvPair->count;
2165  else if(apvPair->mpos==0 && apv_mod->count>0)apv_mod->value = apv_mod->value / apv_mod->count;
2166  }
2167  }
2168  }
2169  }
2170  if(minvalue>=maxvalue){
2171 
2172  minvalue=9999999.;
2173  maxvalue=-9999999.;
2174  rangefound=false;
2175  for(i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
2176  TmApvPair * apvPair= i_apv->second;
2177  if(apvPair!=0 ) {
2178  TmModule * apv_mod = apvPair->mod;
2179  if( apv_mod !=0 && !apv_mod->notInUse() ){
2180  if(useApvPairValue){
2181  rangefound=true;
2182  if (minvalue > apvPair->value)minvalue=apvPair->value;
2183  if (maxvalue < apvPair->value)maxvalue=apvPair->value;
2184  } else {
2185  if(apv_mod->count>0){
2186  rangefound=true;
2187  if (minvalue > apv_mod->value)minvalue=apv_mod->value;
2188  if (maxvalue < apv_mod->value)maxvalue=apv_mod->value;}
2189  }
2190  }
2191  }
2192  }
2193  }
2194  if ((title.find("QTestAlarm")!=std::string::npos) || (maxvalue == minvalue)||!rangefound) printflag = false;
2195 
2196  if(filetype=="svg"){
2197  saveAsSingleLayer=false;
2198  std::ostringstream outs;
2199  outs << outputfilename<<".svg";
2200  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
2201  *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
2202  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
2203  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
2204  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
2205  *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
2206  *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
2207  *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
2208  }
2209  for (int crate=firstcrate; crate < (ncrates+1); crate++){
2210  if(filetype=="xml"){
2211  saveAsSingleLayer=true;
2212  std::ostringstream outs;
2213  outs << outputfilename<<"crate" <<crate<< ".xml";
2214  savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
2215  *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
2216  *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
2217  *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
2218  *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
2219  *savefile << "<script type=\"text/ecmascript\" xlink:href=\"crate.js\" />"<<std::endl;
2220  *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<std::endl;
2221  *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
2222  *savefile << "<g id=\"crate\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > "<<std::endl;
2223  }
2224  // ncrate=crate;
2225  defcwindow(crate);
2226  int numfed_incrate=0;
2227  for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
2228  if(i_fed->second == crate){
2229  int fedId = i_fed->first;
2230  // numfed_incrate++;
2231  numfed_incrate = slotMap[fedId];
2232  // the following piece of code is used to prepare the HTML clickable map
2233  /*
2234  double scalex=6285./6290.;
2235  double scaley=3510./3540.;
2236  double boxinitix=(NUMFED_INCOLUMN-1-(numfed_incrate-1)/NUMFED_INROW)*(NUMFEDCH_INCOLUMN+2)+NUMFEDCH_INCOLUMN+0.9;
2237  double boxinitiy=(NUMFED_INROW-1-(numfed_incrate-1)%NUMFED_INROW)*(NUMFEDCH_INROW+1)+NUMFEDCH_INROW+0.9;
2238  double boxendix=boxinitix-(NUMFEDCH_INCOLUMN-1)-0.9;
2239  double boxendiy=boxinitiy-(NUMFEDCH_INROW-1)-0.9;
2240 
2241  std::cout << "<area shape=\"rect\" coords=\" "
2242  << int(scalex*ydpixelc(boxinitiy)) << "," << int(3510-scaley*xdpixelc(boxinitix))
2243  << "," << int(scalex*ydpixelc(boxendiy)) << "," << int(3510-scaley*xdpixelc(boxendix))
2244  << "\" href=\"\" title=\"crate " << crate << " slot " << numfed_incrate << " FED " << fedId << "\" /> " << std::endl;
2245  */
2246  //
2247  for (int nconn=0;nconn<96;nconn++){
2248  int key = fedId*1000+nconn;
2249  TmApvPair * apvPair= apvMap[key];
2250  if(apvPair !=0){
2251  TmModule * apv_mod = apvPair->mod;
2252  if(apv_mod !=0 && !apv_mod->notInUse()){
2253  drawApvPair(crate,numfed_incrate,print_total,apvPair,savefile,useApvPairValue);
2254  }
2255  }
2256  }
2257  }
2258  }
2259  if(!temporary_file){
2260  if(filetype=="xml"){
2261  *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
2262  *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
2263  *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
2264  *savefile << " </text> </svg>" << std::endl;
2265  savefile->close();delete savefile;
2266  saveAsSingleLayer=false;
2267  }
2268  }
2269  }
2270  if(filetype=="svg"){
2271  *savefile << "</g> </svg> </svg> " << std::endl;
2272  savefile->close();delete savefile;
2273  }
2274  if(!print_total && !useApvPairValue){
2275 //Restore module value
2276  for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
2277  TmApvPair * apvPair= i_apv->second;
2278  if(apvPair!=0) {
2279  TmModule * apv_mod = apvPair->mod;
2280  if(apv_mod !=0 && apvPair->mpos==0 && !apv_mod->notInUse()){
2281  apv_mod->value = apv_mod->value * apv_mod->count;
2282  }
2283  }
2284  }
2285 }
2286 
2287  int rangex = YFEDOFFSET+(YFEDCSIZE+YFEDOFFSET)*NUMFEDCRATE_INROW+300;
2289 
2290  if(temporary_file){
2291  if(printflag&&!saveWebInterface)drawPalette(savefile,rangex-140,rangey-100);
2292  savefile->close(); delete savefile;
2293 
2294  const char * command1;
2295  std::string tempfilename = outputfilename + ".coor";
2296  int red,green,blue,npoints,colindex,ncolor;
2297  double x[4],y[4];
2298  std::ifstream tempfile(tempfilename.c_str(),std::ios::in);
2299  TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
2300  gPad->SetFillColor(38);
2301 
2302  // if(saveWebInterface)gPad->Range(0,0,3750,1600); else gPad->Range(0,0,3800,1600);
2303  std::cout << " range x " << rangex << std::endl;
2304  std::cout << " range y " << rangey << std::endl;
2305  gPad->Range(0,0,rangex,rangey);
2306 
2307  //First build palette
2308  ncolor=0;
2309  typedef std::map<int,int> ColorList;
2310  ColorList colorList;
2311  ColorList::iterator pos;
2312  TColor *col,*c;
2313  while(!tempfile.eof()) {
2314  tempfile >> red >> green >> blue >> npoints;
2315  colindex=red+green*1000+blue*1000000;
2316  pos=colorList.find(colindex);
2317  if(pos == colorList.end()){
2318  colorList[colindex]=ncolor+100;
2319  col =gROOT->GetColor(ncolor+100);
2320  if(col)
2321  col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
2322  else
2323  c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
2324  vc.push_back(c);
2325  ncolor++;
2326  }
2327  for (int i=0;i<npoints;i++){
2328  tempfile >> x[i] >> y[i];
2329  }
2330  }
2331  if(ncolor>0 && ncolor<10000){
2332  Int_t colors[10000];
2333  for(int i=0;i<ncolor;i++){colors[i]=i+100;}
2334  gStyle->SetPalette(ncolor,colors);
2335  }
2336  tempfile.clear();
2337  tempfile.seekg(0,std::ios::beg);
2338  std::cout << "created palette with " << ncolor << " colors" << std::endl;
2339  while(!tempfile.eof()) {//create polylines
2340  tempfile >> red >> green >> blue >> npoints;
2341  for (int i=0;i<npoints;i++){
2342  tempfile >> x[i] >> y[i];
2343  }
2344  colindex=red+green*1000+blue*1000000;
2345  pos=colorList.find(colindex);
2346  if(pos != colorList.end()){
2347  TPolyLine* pline = new TPolyLine(npoints,y,x);
2348  vp.push_back(pline);
2349  pline->SetFillColor(colorList[colindex]);
2350  pline->SetLineWidth(0);
2351  pline->Draw("f");
2352  }
2353  }
2354  if (printflag&&!saveWebInterface) {
2355  float lminvalue=minvalue; float lmaxvalue=maxvalue;
2356  if(tkMapLog) {lminvalue=log(minvalue)/log(10);lmaxvalue=log(maxvalue)/log(10);}
2357  axis = new TGaxis(rangex-140,34,rangex-140,rangey-106,lminvalue,lmaxvalue,510,"+L");
2358  axis->SetLabelSize(0.02);
2359  axis->Draw();
2360  }
2361 
2362  if(!saveWebInterface){
2363  TLatex l;
2364  l.SetTextSize(0.05);
2365  std::string fulltitle = title;
2366  if(tkMapLog && (fulltitle.find("Log10 scale") == std::string::npos)) fulltitle += ": Log10 scale";
2367  l.DrawLatex(50,rangey-200,fulltitle.c_str());
2368  }
2369  MyC->Update();
2370  std::cout << "Filetype " << filetype << std::endl;
2371  if(filetype=="png"){
2372  std::string filename = outputfilename + ".png";
2373  MyC->Print(filename.c_str());
2374  }
2375  if(filetype=="jpg"){
2376  std::string filename = outputfilename + ".jpg";
2377  MyC->Print(filename.c_str());
2378  }
2379  if(filetype=="pdf"){
2380  std::string filename = outputfilename + ".pdf";
2381  MyC->Print(filename.c_str());
2382  }
2383  std::string command = "rm "+tempfilename ;
2384  command1=command.c_str();
2385  std::cout << "Executing " << command1 << std::endl;
2386  system(command1);
2387  MyC->Clear();
2388  delete MyC;
2389  if (printflag&&!saveWebInterface)delete axis;
2390  for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
2391  delete (*pos1);}
2392 
2393 
2394 }//if(temporary_file)
2395 }//if(enabledFedProcessing)
2396 }
2397 
2398 void TrackerMap::load(std::string inputfilename){
2399  inputfile = new std::ifstream(inputfilename.c_str(),std::ios::in);
2401  int ipos,ipos1,ipos2,id=0,val=0;
2402  int nline=0;
2403  while (getline( *inputfile, line ))
2404  {
2405  ipos1 = line.find("value=\"");
2406  if(ipos1 > 0) {
2407  value = line.substr(ipos1+7,10);
2408  ipos = value.find("\"");
2409  value = value.substr(0,ipos);
2410  val=atoi(value.c_str());
2411  }
2412  ipos2 = line.find("detid=\"");
2413  if(ipos2 > 0) {
2414  value = line.substr(ipos2+7,10);
2415  ipos = value.find("\"");
2416  value = value.substr(0,ipos);
2417  id = atoi(value.c_str());
2418  }
2419  if(ipos1>0 && ipos2>0 && val>0)this->fill(id,val);
2420  if(ipos1>0 && ipos2>0)nline++;
2421  //if(ipos1>0 && ipos2>0)std::cout << nline << " " << id << " " << val << std::endl;
2422 
2423  }
2424  std::cout << nline << " modules found in this svg file " << std::endl;
2425  inputfile->close();delete inputfile;
2426  }
2427 
2428 
2429 
2430 //print in svg format tracker map
2431 //print_total = true represent in color the total stored in the module
2432 //print_total = false represent in color the average
2433 void TrackerMap::print(bool print_total, float minval, float maxval, std::string outputfilename){
2434  temporary_file=false;
2435  std::ostringstream outs;
2436  minvalue=minval; maxvalue=maxval;
2437  outs << outputfilename << ".xml";
2438  svgfile = new std::ofstream(outs.str().c_str(),std::ios::out);
2439  jsfile = new std::ifstream(edm::FileInPath(jsfilename).fullPath().c_str(),std::ios::in);
2440 
2441  //copy javascript interface from trackermap.txt file
2442  std::string line;
2443  while (getline( *jsfile, line ))
2444  {
2445  *svgfile << line << std::endl;
2446  }
2447  jsfile->close();delete jsfile;
2448  //
2449  if(!print_total){
2450  for (int layer=1; layer < 44; layer++){
2451  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
2452  for (int module=1;module<200;module++) {
2453  int key=layer*100000+ring*1000+module;
2454  TmModule * mod = smoduleMap[key];
2455  if(mod !=0 && !mod->notInUse()){
2456  mod->value = mod->value / mod->count;
2457  }
2458  }
2459  }
2460  }
2461  }
2462  if(minvalue>=maxvalue){
2463  minvalue=9999999.;
2464  maxvalue=-9999999.;
2465  for (int layer=1; layer < 44; layer++){
2466  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
2467  for (int module=1;module<200;module++) {
2468  int key=layer*100000+ring*1000+module;
2469  TmModule * mod = smoduleMap[key];
2470  if(mod !=0 && !mod->notInUse()){
2471  if (minvalue > mod->value)minvalue=mod->value;
2472  if (maxvalue < mod->value)maxvalue=mod->value;
2473  }
2474  }
2475  }
2476  }
2477 }
2478  for (int layer=1; layer < 44; layer++){
2479  // nlay=layer;
2480  defwindow(layer);
2481  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
2482  for (int module=1;module<200;module++) {
2483  int key=layer*100000+ring*1000+module;
2484  TmModule * mod = smoduleMap[key];
2485  if(mod !=0 && !mod->notInUse()){
2486  drawModule(mod,key,layer,print_total,svgfile);
2487  }
2488  }
2489  }
2490  }
2491  *svgfile << "</svg:g></svg:svg>"<<std::endl;
2492  *svgfile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">"<<title<<"</svg:text>"<<std::endl;
2494  *svgfile << "</svg:svg>"<<std::endl;
2495  *svgfile << "</body></html>"<<std::endl;
2496  svgfile->close();delete svgfile;
2497 
2498 }
2499 
2500 void TrackerMap::drawPalette(std::ofstream * svgfile,int xoffset, int yoffset){
2501  std::cout << "preparing the palette" << std::endl;
2502  int color,red, green, blue;
2503  float val=minvalue;
2504  int paletteLength = 250;
2505  int width=50*(yoffset-40)/1500;
2506  float dval = (maxvalue-minvalue)/(float)paletteLength;
2507  bool rtkMapLog = tkMapLog; if (tkMapLog)tkMapLog=false;
2508  float step = float(yoffset-40)/float(paletteLength);
2509  for(int i=1;i<paletteLength+1;i++){
2510  color = getcolor(val,palette);
2511  red=(color>>16)&0xFF;
2512  green=(color>>8)&0xFF;
2513  blue=(color)&0xFF;
2514  // if(!temporary_file)*svgfile <<"<svg:rect x=\"3010\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"6\" fill=\"rgb("<<red<<","<<green<<","<<blue<<")\" />\n";
2515  // else *svgfile << red << " " << green << " " << blue << " 4 " << (6*i)+40 << " 3010. " <<//
2516  // (6*i)+40 << " 3060. " <<//
2517  // (6*(i-1))+40 << " 3060. " <<//
2518  // (6*(i-1))+40 <<" 3010. " << std::endl; //
2519 
2520  // if(i%50 == 0){
2521  // if(!temporary_file)*svgfile <<"<svg:rect x=\"3010\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"1\" fill=\"black\" />\n";
2522  // if(i%50==0&&!temporary_file)*svgfile << " <svg:text class=\"normalText\" x=\"3060\" y=\""<<(1560-6*i)<<"\">" <<val<<"</svg:text>"<<std::endl;
2523 
2524  if(!temporary_file)*svgfile <<"<svg:rect x=\"3610\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"6\" fill=\"rgb("<<red<<","<<green<<","<<blue<<")\" />\n";
2525  else *svgfile << red << " " << green << " " << blue << " 4 " << int(step*i)+34 << " " << xoffset-width << ". " <<//
2526  int(step*i)+34 << " " << xoffset << ". " <<//
2527  int(step*(i-1))+34 << " " << xoffset << ". " <<//
2528  int(step*(i-1))+34 << " " << xoffset-width << ". " << std::endl; //
2529 
2530  if(i%50 == 0){
2531  if(!temporary_file)*svgfile <<"<svg:rect x=\"3610\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"1\" fill=\"black\" />\n";
2532  if(i%50==0&&!temporary_file)*svgfile << " <svg:text class=\"normalText\" x=\"3660\" y=\""<<(1560-6*i)<<"\">" <<val<<"</svg:text>"<<std::endl;
2533  }
2534  val = val + dval;
2535  }
2536  tkMapLog=rtkMapLog;
2537 }
2538 void TrackerMap::fillc_fed_channel(int fedId,int fedCh, int red, int green, int blue )
2539 {
2540  int key = fedId*1000+fedCh;
2541  TmApvPair* apvpair = apvMap[key];
2542 
2543  if(apvpair!=0){
2544  apvpair->red=red; apvpair->green=green; apvpair->blue=blue;
2545  return;
2546  }
2547  std::cout << "*** error in FedTrackerMap fillc method ***";
2548 }
2549 
2551 {
2552  std::multimap<const int, TmApvPair*>::iterator pos;
2553  for (pos = apvModuleMap.lower_bound(idmod);
2554  pos != apvModuleMap.upper_bound(idmod); ++pos) {
2555  TmApvPair* apvpair = pos->second;
2556  if(apvpair!=0){
2557  apvpair->value=apvpair->value+qty;
2558  apvpair->count++;
2559  }
2560  }
2561  return;
2562  std::cout << "*** error in FedTrackerMap fill by module method ***";
2563  }
2564 
2565 void TrackerMap::fill_current_val_fed_channel(int fedId, int fedCh, float current_val )
2566 {
2567  int key = fedId*1000+fedCh;
2568  TmApvPair* apvpair = apvMap[key];
2569 
2570  if(apvpair!=0) {apvpair->value=current_val; apvpair->count=1; apvpair->red=-1;}
2571  else
2572  std::cout << "*** error in FedTrackerMap fill_current_val method ***";
2573 }
2574 
2575 
2576 void TrackerMap::fillc_fec_channel(int crate,int slot, int ring, int addr, int red, int green, int blue )
2577  {
2578  int key =crate*10000000+slot*100000+ring*1000+addr;
2579 
2580  TmCcu *ccu = ccuMap[key];
2581 
2582  if(ccu!=0){
2583  ccu->red=red; ccu->green=green; ccu->blue=blue;
2584  return;
2585  }
2586  std::cout << "*** error in FecTrackerMap fillc method ***";
2587 }
2588 
2589 void TrackerMap::fill_fec_channel(int crate,int slot, int ring, int addr, float qty )
2590 {
2591  int key =crate*10000000+slot*100000+ring*1000+addr;
2592  TmCcu *ccu = ccuMap[key];
2593  if(ccu!=0){
2594  ccu->count++; ccu->value=ccu->value+qty;
2595  return;
2596 
2597  }
2598 
2599  std::cout << "*** error in FecTrackerMap fill by module method ***";
2600  }
2601 
2602 
2603 
2604 void TrackerMap::fillc_lv_channel(int rack,int crate, int board, int red, int green, int blue )
2605 {
2606 
2607  int key = rack*1000+crate*100+board;
2608 
2609  TmPsu *psu = psuMap[key];
2610 
2611  if(psu!=0){
2612  psu->red=red; psu->green=green; psu->blue=blue;
2613  return;
2614  }
2615  std::cout << "*** error in LVTrackerMap fillc method ***";
2616 }
2617 
2618 void TrackerMap::fill_lv_channel(int rack,int crate, int board, float qty )
2619 {
2620  int key = rack*1000+crate*100+board;
2621  TmPsu *psu = psuMap[key];
2622  if(psu!=0){
2623  psu->count++; psu->value=psu->value+qty;
2624  return;
2625 
2626  }
2627 
2628  std::cout << "*** error in LVTrackerMap fill by module method ***";
2629  }
2630 
2631 void TrackerMap::fillc_hv_channel2(int rack,int crate, int board, int red, int green, int blue )
2632 {
2633 
2634  int key = rack*1000+crate*100+board;
2635 
2636  TmPsu *psu = psuMap[key];
2637 
2638  if(psu!=0){
2639  psu->redHV2=red; psu->greenHV2=green; psu->blueHV2=blue;
2640  return;
2641  }
2642  std::cout << "*** error in HVTrackerMap (channel 2) fillc method ***";
2643 }
2644 void TrackerMap::fillc_hv_channel3(int rack,int crate, int board, int red, int green, int blue )
2645 {
2646 
2647  int key = rack*1000+crate*100+board;
2648 
2649  TmPsu *psu = psuMap[key];
2650 
2651  if(psu!=0){
2652  psu->redHV3=red; psu->greenHV3=green; psu->blueHV3=blue;
2653  return;
2654  }
2655  std::cout << "*** error in HVTrackerMap (channel 3) fillc method ***";
2656 }
2657 
2658 
2659 void TrackerMap::fill_hv_channel2(int rack,int crate, int board, float qty )
2660 {
2661  int key = rack*1000+crate*100+board;
2662  TmPsu *psu = psuMap[key];
2663  if(psu!=0){
2664  psu->countHV2++; psu->valueHV2=psu->valueHV2+qty;
2665  return;
2666 
2667  }
2668 
2669  std::cout << "*** error in HVTrackerMap fill by module method ***";
2670  }
2671 void TrackerMap::fill_hv_channel3(int rack,int crate, int board, float qty )
2672 {
2673  int key = rack*1000+crate*100+board;
2674  TmPsu *psu = psuMap[key];
2675  if(psu!=0){
2676  psu->countHV3++; psu->valueHV3=psu->valueHV3+qty;
2677  return;
2678 
2679  }
2680 
2681  std::cout << "*** error in HVTrackerMap fill by module method ***";
2682  }
2683 
2684 
2685 
2686 
2687 
2688 int TrackerMap::module(int fedId, int fedCh)
2689 {
2690  int key = fedId*1000+fedCh;
2691  TmApvPair* apvpair = apvMap[key];
2692  if(apvpair!=0){
2693  return(apvpair->mod->idex);
2694  }
2695  return(0);
2696  std::cout << "*** error in FedTrackerMap module method ***";
2697 }
2698 void TrackerMap::fill_fed_channel(int fedId, int fedCh, float qty )
2699 {
2700  int key = fedId*1000+fedCh;
2701  TmApvPair* apvpair = apvMap[key];
2702  if(apvpair!=0){
2703  apvpair->value=apvpair->value+qty;
2704  apvpair->count++;
2705  return;
2706  }
2707  std::cout << "*** error inFedTrackerMap fill method ***";
2708 }
2709 
2710 
2711 void TrackerMap::fillc(int idmod, int red, int green, int blue ){
2712 
2714  if(mod!=0){
2715  mod->red=red; mod->green=green; mod->blue=blue;
2716  return;
2717  }
2718  std::cout << "**************************error in fill method **************module "<<idmod<<std::endl;
2719 }
2720 void TrackerMap::fillc(int layer, int ring, int nmod, int red, int green, int blue ){
2721 
2722  int key = layer*10000+ring*1000+nmod;
2723  TmModule * mod = smoduleMap[key];
2724 
2725  if(mod!=0){
2726  mod->red=red; mod->green=green; mod->blue=blue;
2727  return;
2728  }
2729  std::cout << "**************************error in fill method **************"<< std::endl;
2730 }
2731 
2733 
2734  std::map<const int , TmModule *>::iterator imod;
2735  for( imod=imoduleMap.begin();imod !=imoduleMap.end(); imod++){
2736  fillc(imod->first,255,255,255);
2737  }
2738 }
2739 
2741 
2742  std::map<const int , TmModule *>::iterator imod;
2743  for( imod=imoduleMap.begin();imod !=imoduleMap.end(); imod++){
2744  fill_current_val(imod->first,0);
2745  }
2746 }
2747 
2748 
2749 
2750 void TrackerMap::fill_current_val(int idmod, float current_val ){
2751 
2753  if(mod!=0) {mod->value=current_val; mod->count=1; mod->red=-1;}
2754  else std::cout << "**error in fill_current_val method ***module "<<idmod<<std::endl;
2755 }
2756 
2757 void TrackerMap::fill(int idmod, float qty ){
2758 
2760  if(mod!=0){
2761  mod->value=mod->value+qty;
2762  mod->count++;
2763  return;
2764  }else{
2765  TmModule * mod1 = imoduleMap[idmod+1];
2766  TmModule * mod2 = imoduleMap[idmod+2];
2767  if(mod1!=0 && mod2!=0){
2768  mod1->value=mod1->value+qty;
2769  mod1->count++;
2770  mod2->value=mod2->value+qty;
2771  mod2->count++;
2772  return;
2773  }}
2774  std::cout << "**************************error in fill method **************module "<<idmod<<std::endl;
2775 }
2776 
2777 void TrackerMap::fill(int layer, int ring, int nmod, float qty){
2778 
2779  int key = layer*100000+ring*1000+nmod;
2780  TmModule * mod = smoduleMap[key];
2781  if(mod!=0){
2782  mod->value=mod->value+qty;
2783  mod->count++;
2784  }
2785  else std::cout << "**************************error in SvgModuleMap **************";
2786 }
2787 
2789 
2791  if(mod!=0){
2792  mod->text=s;
2793  }
2794  else std::cout << "**************************error in IdModuleMap **************";
2795 }
2796 
2797 
2798 void TrackerMap::setText(int layer, int ring, int nmod, std::string s){
2799 
2800  int key = layer*100000+ring*1000+nmod;
2801  TmModule * mod = smoduleMap[key];
2802  if(mod!=0){
2803  mod->text=s;
2804  }
2805  else std::cout << "**************************error in SvgModuleMap **************";
2806 }
2807 
2809  // std::ifstream* infile;
2810 
2811  int nmods, pix_sil, fow_bar, ring, nmod, layer;
2812  unsigned int idex;
2813  float posx, posy, posz, length, width, thickness, widthAtHalfLength;
2814  int iModule=0,old_layer=0, ntotMod =0;
2815  std::string name,dummys;
2816  std::ifstream infile(edm::FileInPath(infilename).fullPath().c_str(),std::ios::in);
2817  while(!infile.eof()) {
2818  infile >> nmods >> pix_sil >> fow_bar >> layer >> ring >> nmod >> posx >> posy
2819  >> posz>> length >> width >> thickness
2820  >> widthAtHalfLength >> idex ;
2821  getline(infile,dummys); //necessary to reach end of record
2822  getline(infile,name);
2823  if(old_layer!=layer){old_layer=layer;iModule=0;}
2824  iModule++;
2825  ntotMod++;
2826  int key=layer*100000+ring*1000+nmod;
2827  TmModule * mod = smoduleMap[key];
2828 
2829  imoduleMap[idex]=mod;
2830 
2831  if(mod==0) std::cout << "error in module "<<key <<std::endl;
2832  else
2833  {
2834  mod->posx = posx;
2835  mod->posy = posy;
2836  mod->setUsed();
2837  mod->value=0;
2838  mod->count=0;
2839  mod->posz = posz;
2840  mod->length = length;
2841  mod->width = width;
2842  mod->thickness = thickness;
2843  mod->widthAtHalfLength = widthAtHalfLength;
2844  mod->idex = idex;
2845  mod->name = name;
2846  }
2847  }
2848  infile.close();
2849  number_modules = ntotMod-1;
2850 }
2851 int TrackerMap::getcolor(float value,int palette){
2852  int red,green,blue;
2853  float lminvalue, lmaxvalue;
2854  lminvalue=minvalue; lmaxvalue=maxvalue;
2855  if(tkMapLog) {lminvalue=log(minvalue)/log(10);lmaxvalue=log(maxvalue)/log(10); value=log(value)/log(10);}
2856 
2857 
2858  red=0;green=0;blue=0;
2859  if(palette==1){//palette1 1 - raibow
2860  float delta=(lmaxvalue-lminvalue);
2861  float x =(value-lminvalue);
2862  if(value<lminvalue){red=0;green=0;blue=255;}
2863  if(value>lmaxvalue){red=255;green=0;blue=0;}
2864  if(value>=lminvalue&&value<=lmaxvalue){
2865  red = (int) ( x<(delta/2) ? 0 : ( x > ((3./4.)*delta) ? 255 : 255/(delta/4) * (x-(2./4.)*delta) ) );
2866  green= (int) ( x<delta/4 ? (x*255/(delta/4)) : ( x > ((3./4.)*delta) ? 255-255/(delta/4) *(x-(3./4.)*delta) : 255 ) );
2867  blue = (int) ( x<delta/4 ? 255 : ( x > ((1./2.)*delta) ? 0 : 255-255/(delta/4) * (x-(1./4.)*delta) ) );
2868  }
2869  }
2870  if (palette==2){//palette 2 yellow-green
2871  green = (int)((value-lminvalue)/(lmaxvalue-lminvalue)*256.);
2872  if (green > 255) green=255;
2873  red = 255; blue=0;green=255-green;
2874  }
2875  // std::cout<<red<<" "<<green<<" "<<blue<<" "<<value <<" "<<lminvalue<<" "<< lmaxvalue<<std::endl;
2876  return(blue|(green<<8)|(red<<16));
2877 }
2879 //Copy interface
2880  std::ofstream * ofilename;
2881  std::ifstream * ifilename;
2882  std::ostringstream ofname;
2883  std::string ifname;
2885  std::string line;
2886  std::string outputfilename="dqmtmap";
2887  ifilename=findfile("viewerHeader.xhtml");
2888  ofname << outputfilename << "viewer.html";
2889  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2890  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2891 *ofilename <<" var tmapname=\"" <<outputfilename << "\""<<std::endl;
2892 *ofilename <<" var tmaptitle=\"" <<title << "\""<<std::endl;
2893 *ofilename <<" var ncrates=" <<ncrates << ";"<<std::endl;
2894 *ofilename <<" var nfeccrates=" <<nfeccrates << ";"<<std::endl;
2895  *ofilename <<" var npsuracks=" <<npsuracks << ";"<<std::endl;
2896 
2897  ifilename->close();delete ifilename;
2898 
2899  ifilename=findfile("viewerTrailer.xhtml");
2900  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2901  ofilename->close();delete ofilename;
2902  command = "sed -i \"s/XtmapnameX/"+outputfilename+"/g\" "+ ofname.str();
2903  std::cout << "Executing " << command << std::endl;
2904  system(command.c_str());
2905  command = "sed -i \"s/XtmaptitleX/"+title+"/g\" "+ ofname.str();
2906  std::cout << "Executing " << command << std::endl;
2907  system(command.c_str());
2908  ofname.str("");
2909  ifilename->close();delete ifilename;
2910 
2911  ifilename=findfile("jqviewer.js");
2912  ofname << "jqviewer.js";
2913  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2914  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2915  ofname.str("");
2916  ofilename->close();delete ofilename;
2917  ifilename->close();delete ifilename;
2918 
2919  ifilename=findfile("crate.js");
2920  ofname << "crate.js";
2921  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2922  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2923  ofname.str("");
2924  ofilename->close();delete ofilename;
2925  ifilename->close();delete ifilename;
2926 
2927  ifilename=findfile("feccrate.js");
2928  ofname << "feccrate.js";
2929  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2930  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2931  ofname.str("");
2932  ofilename->close();delete ofilename;
2933  ifilename->close();delete ifilename;
2934 
2935  ifilename=findfile("layer.js");
2936  ofname << "layer.js";
2937  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2938  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2939  ofname.str("");
2940  ofilename->close();delete ofilename;
2941  ifilename->close();delete ifilename;
2942 
2943  ifilename=findfile("rack.js");
2944  ofname << "rack.js";
2945  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2946  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2947  ofname.str("");
2948  ofilename->close();delete ofilename;
2949  ifilename->close();delete ifilename;
2950  ofname.str("");
2951 
2952  ifilename=findfile("rackhv.js");
2953  ofname << "rackhv.js";
2954  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
2955  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
2956  ofname.str("");
2957  ofilename->close();delete ofilename;
2958  ifilename->close();delete ifilename;
2959 
2960 
2961 
2962 
2963  std::ostringstream outs,outs1,outs2;
2964  outs << outputfilename<<".png";
2965 save(true,gminvalue,gmaxvalue,outs.str(),3000,1600);
2966 temporary_file=false;
2967 printlayers(true,gminvalue,gmaxvalue,outputfilename);
2968 
2969 //Now print a text file for each layer
2970  std::ofstream * txtfile;
2971 for (int layer=1; layer < 44; layer++){
2972  std::ostringstream outs;
2973  outs << outputfilename <<"layer"<<layer<< ".html";
2974  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
2975  *txtfile << "<html><head></head> <body>" << std::endl;
2976  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
2977  for (int module=1;module<200;module++) {
2978  int key=layer*100000+ring*1000+module;
2979  TmModule * mod = smoduleMap[key];
2980  if(mod !=0 && !mod->notInUse()){
2981  int idmod=mod->idex;
2982  int nchan=0;
2983  *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
2984  std::multimap<const int, TmApvPair*>::iterator pos;
2985  for (pos = apvModuleMap.lower_bound(idmod);
2986  pos != apvModuleMap.upper_bound(idmod); ++pos) {
2987  TmApvPair* apvpair = pos->second;
2988  if(apvpair!=0){
2989  nchan++;
2990  *txtfile << apvpair->text << std::endl;
2991  }
2992 
2993  }
2994  *txtfile << "</pre><h3>"<< mod->name<<"</h3>"<<std::endl;
2995  }
2996  }
2997  }
2998  *txtfile << "</body></html>" << std::endl;
2999  txtfile->close();delete txtfile;
3000  }
3002  outs1 << outputfilename<<"fed.png";
3003 save_as_fedtrackermap(true,gminvalue,gmaxvalue,outs1.str(),6000,3200);
3004  outs2 << outputfilename<<".xml";
3005 save_as_fedtrackermap(true,gminvalue,gmaxvalue,outs2.str(),3000,1600);
3006 //And a text file for each crate
3007  std::map<int , int>::iterator i_fed;
3008  std::ofstream * txtfile;
3009  for (int crate=firstcrate; crate < (ncrates+1); crate++){
3010  std::ostringstream outs;
3011  outs << outputfilename <<"crate"<<crate<< ".html";
3012  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3013  *txtfile << "<html><head></head> <body>" << std::endl;
3014  for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
3015  if(i_fed->second == crate){
3016  int fedId = i_fed->first;
3017  for (int nconn=0;nconn<96;nconn++){
3018  int key = fedId*1000+nconn;
3019  TmApvPair * apvPair= apvMap[key];
3020  if(apvPair !=0){
3021  int idmod=apvPair->idex;
3022  *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
3023  *txtfile << apvPair->text << std::endl;
3024  std::ostringstream outs;
3025  outs << "fedchannel " <<apvPair->getFedId() << "/"<<apvPair->getFedCh()<<" connects to module " << apvPair->mod->idex ;
3026  *txtfile << "</pre><h3>"<< outs.str()<<"</h3>"<<std::endl;
3027  }
3028  }
3029  }
3030  }
3031  *txtfile << "</body></html>" << std::endl;
3032  txtfile->close();delete txtfile;
3033  }
3034  }
3036  std::ostringstream outs1,outs2;
3037  outs1 << outputfilename<<"fec.png";
3038 save_as_fectrackermap(true,gminvalue,gmaxvalue,outs1.str(),6000,3200);
3039  outs2 << outputfilename<<".xml";
3040 save_as_fectrackermap(true,gminvalue,gmaxvalue,outs2.str(),3000,1600);
3041 //And a text file for each crate
3042  std::ofstream * txtfile;
3043  std::map<int , TmCcu *>::iterator i_ccu;
3044  std::multimap<TmCcu*, TmModule*>::iterator it;
3045  std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
3046  for (int crate=1; crate < (nfeccrates+1); crate++){
3047  std::ostringstream outs;
3048  outs << outputfilename <<"feccrate"<<crate<< ".html";
3049  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3050  *txtfile << "<html><head></head> <body>" << std::endl;
3051  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
3052  TmCcu * ccu= i_ccu->second;
3053  if(ccu!=0&&ccu->getCcuCrate() == crate){
3054  int idmod=ccu->idex;
3055  *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
3056  *txtfile << ccu->text << std::endl;
3057  std::ostringstream outs;
3058  if(ccu->nmod==0)outs << "ccu is in position" << ccu->mpos<<"in ring but doesn't seem to have any module connected"; else
3059  {
3060  outs << "ccu is in position " << ccu->mpos<<" in ring and connects " <<ccu->nmod<< " modules" << std::endl;
3061  ret = fecModuleMap.equal_range(ccu);
3062  for (it = ret.first; it != ret.second; ++it)
3063  {
3064  outs << (*it).second->idex<<" " << (*it).second->name <<" value= "<< (*it).second->value<<"\n\n";
3065  }
3066 
3067  *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
3068  }//ifccu->nmod==0
3069  }//if ccu!=0
3070  }//for i_ccu
3071  *txtfile << "</body></html>" << std::endl;
3072  txtfile->close();delete txtfile;
3073  }//for int crate
3074  }
3075 if(enableLVProcessing){
3076  std::ostringstream outs3,outs4;
3077  outs3 << outputfilename<<"psu.png";
3078 save_as_psutrackermap(true,gminvalue,gmaxvalue,outs3.str(),6000,3200);
3079 
3080  outs4 << outputfilename<<".xml";
3081 save_as_psutrackermap(true,gminvalue,gmaxvalue,outs4.str(),3000,1600);
3082 //And a text file for each rack
3083 
3084  std::ofstream * txtfile;
3085  std::map<int , TmPsu *>::iterator ipsu;
3086  std::multimap<TmPsu*, TmModule*>::iterator it;
3087  std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
3088  for (int rack=1; rack < (npsuracks+1); rack++){
3089  std::ostringstream outs;
3090 
3091  outs << outputfilename <<"psurack"<<rack<< ".html";
3092  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3093  *txtfile << "<html><head></head> <body>" << std::endl;
3094  for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
3095  TmPsu * psu= ipsu->second;
3096  if(psu!=0 && psu->getPsuRack() == rack){
3097  *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
3098  *txtfile << psu->text << std::endl;
3099  std::ostringstream outs;
3100  if(psu->nmod==0)outs << "Ps is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
3101  {
3102  outs<< "PS is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmod<<" modules. "<<std::endl;
3103 
3104  ret = psuModuleMap.equal_range(psu);
3105  for (it = ret.first; it != ret.second; ++it)
3106  {
3107  outs <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;
3108 
3109  }
3110  *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
3111  }
3112  }
3113  }
3114  *txtfile << "</body></html>" << std::endl;
3115  txtfile->close();delete txtfile;
3116  }
3117  }
3118 
3119 
3120 if(enableHVProcessing){
3121  std::ostringstream outs5,outs6;
3122  outs5 << outputfilename<<"hv.png";
3123 save_as_HVtrackermap(true,gminvalue,gmaxvalue,outs5.str(),6000,3200);
3124 
3125  outs6 << outputfilename<<".xml";
3126 save_as_HVtrackermap(true,gminvalue,gmaxvalue,outs6.str(),3000,1600);
3127 //And a text file for each rack
3128 
3129  std::ofstream * txtfile;
3130  std::map<int , TmPsu *>::iterator ipsu;
3131  std::multimap<TmPsu*, TmModule*>::iterator it;
3132  std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
3133  for (int rack=1; rack < (npsuracks+1); rack++){
3134  std::ostringstream outs;
3135 
3136  outs << outputfilename <<"HVrack"<<rack<< ".html";
3137  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3138  *txtfile << "<html><head></head> <body>" << std::endl;
3139  for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
3140  TmPsu * psu= ipsu->second;
3141  if(psu!=0 && psu->getPsuRack() == rack){
3142  *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
3143  *txtfile << psu->textHV2 << std::endl;
3144  std::ostringstream outsHV2;
3145  if(psu->nmodHV2==0)outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
3146  {
3147  outsHV2<< "HV Channel002 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV2<<" modules. "<<" <br>"<<std::endl;
3148 
3149  ret = psuModuleMap.equal_range(psu);
3150  for (it = ret.first; it != ret.second; ++it)
3151  {
3152  if((*it).second->HVchannel==2){outsHV2 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
3153  }
3154  *txtfile << "</pre><h4>"<< outsHV2.str()<<"</h4>"<<std::endl;
3155  }
3156 
3157  *txtfile << psu->textHV3 << std::endl;
3158  std::ostringstream outsHV3;
3159  if(psu->nmodHV3==0)outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
3160  {
3161  outsHV3<< "HV Channel003 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV3<<" modules. "<<" <br>"<<std::endl;
3162 
3163  ret = psuModuleMap.equal_range(psu);
3164  for (it = ret.first; it != ret.second; ++it)
3165  {
3166  if((*it).second->HVchannel==3){outsHV3 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
3167  }
3168  *txtfile << "</pre><h4>"<< outsHV3.str()<<"</h4>"<<std::endl;
3169  }
3170 
3171  }
3172  }
3173  *txtfile << "</body></html>" << std::endl;
3174  txtfile->close();delete txtfile;
3175  }
3176  }
3177 
3178 }
3179 void TrackerMap::printall(bool print_total, float minval1, float maxval1, std::string s,int width, int height){
3180 //Copy interface
3181  float minval,maxval; minval=minval1; maxval=maxval1;
3182  if(tkMapLog && (minval<maxval)) {minval=pow(10.,minval1);maxval=pow(10.,maxval1);}
3183  std::string filetype=s,outputfilename=s;
3184  if(saveWebInterface){width=6000;height=3200;}
3185  else{
3186  size_t found=filetype.find_last_of(".");
3187  filetype=filetype.substr(found+1);
3188  found=outputfilename.find_last_of(".");
3189  outputfilename=outputfilename.substr(0,found);
3190  }
3191  std::ofstream * ofilename;
3192  std::ifstream * ifilename;
3193  std::ostringstream ofname;
3194  std::string ifname;
3195  std::string line;
3197  if(saveWebInterface){
3198  ifilename=findfile("viewerHeader.xhtml");
3199  ofname << outputfilename << "viewer.html";
3200  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3201  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3202 *ofilename <<" var tmapname=\"" <<outputfilename << "\""<<std::endl;
3203 *ofilename <<" var tmaptitle=\"" <<title << "\""<<std::endl;
3204 *ofilename <<" var ncrates=" <<ncrates << ";"<<std::endl;
3205 *ofilename <<" var nfeccrates=" <<nfeccrates << ";"<<std::endl;
3206 *ofilename <<" var npsuracks=" <<npsuracks << ";"<<std::endl;
3207  ifilename->close();delete ifilename;
3208  ifilename=findfile("viewerTrailer.xhtml");
3209  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3210  ofilename->close();delete ofilename;
3211  ifilename->close();delete ifilename;
3212  command = "sed -i \"s/XtmapnameX/"+outputfilename+"/g\" "+ ofname.str();
3213  std::cout << "Executing " << command << std::endl;
3214  system(command.c_str());
3215  command = "sed -i \"s/XtmaptitleX/"+title+"/g\" "+ ofname.str();
3216  std::cout << "Executing " << command << std::endl;
3217  system(command.c_str());
3218  ofname.str("");
3219 
3220 ifilename=findfile("jqviewer.js");
3221  ofname << "jqviewer.js";
3222  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3223  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3224  ofilename->close();delete ofilename;
3225  ifilename->close();delete ifilename;
3226 
3227  ofname.str("");
3228  ifilename=findfile("crate.js");
3229  ofname << "crate.js";
3230  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3231  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3232  ofilename->close();delete ofilename;
3233  ifilename->close();delete ifilename;
3234 
3235  ofname.str("");
3236  ifilename=findfile("feccrate.js");
3237  ofname << "feccrate.js";
3238  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3239  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3240  ofilename->close();delete ofilename;
3241  ifilename->close();delete ifilename;
3242 
3243  ofname.str("");
3244  ifilename=findfile("rack.js");
3245  ofname << "rack.js";
3246  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3247  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3248  ofilename->close();delete ofilename;
3249  ifilename->close();delete ifilename;
3250 
3251  ofname.str("");
3252  ifilename=findfile("rackhv.js");
3253  ofname << "rackhv.js";
3254  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3255  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3256  ofilename->close();delete ofilename;
3257  ifilename->close();delete ifilename;
3258 
3259  ofname.str("");
3260  ifilename=findfile("layer.js");
3261  ofname << "layer.js";
3262  ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
3263  while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
3264  ofilename->close();delete ofilename;
3265  ifilename->close();delete ifilename;
3266 
3267  command = "scp -r ../../DQM/TrackerCommon/test/jquery/ .";
3268  std::cout << "Executing " << command << std::endl;
3269  system(command.c_str());
3270  command = "scp -r ../../CommonTools/TrackerMap/data/images/ .";
3271  std::cout << "Executing " << command << std::endl;
3272  system(command.c_str());
3273 }
3274 
3275  std::ostringstream outs;
3276  outs << outputfilename<<".png";
3277  if(saveWebInterface)save(true,minval,maxval,outs.str(),3000,1600);
3278  else {if(saveGeoTrackerMap)save(true,minval,maxval,s,width,height);}
3279  if(saveWebInterface){
3280  std::ostringstream outs;
3281  outs << outputfilename<<".png";
3282 temporary_file=false;
3283 printlayers(true,minval,maxval,outputfilename);
3284 
3285 //Now print a text file for each layer
3286  std::ofstream * txtfile;
3287 for (int layer=1; layer < 44; layer++){
3288  std::ostringstream outs;
3289  outs << outputfilename <<"layer"<<layer<< ".html";
3290  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3291  *txtfile << "<html><head></head> <body>" << std::endl;
3292  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
3293  for (int module=1;module<200;module++) {
3294  int key=layer*100000+ring*1000+module;
3295  TmModule * mod = smoduleMap[key];
3296  if(mod !=0 && !mod->notInUse()){
3297  int idmod=mod->idex;
3298  int nchan=0;
3299  *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
3300  std::multimap<const int, TmApvPair*>::iterator pos;
3301  for (pos = apvModuleMap.lower_bound(idmod);
3302  pos != apvModuleMap.upper_bound(idmod); ++pos) {
3303  TmApvPair* apvpair = pos->second;
3304  if(apvpair!=0){
3305  nchan++;
3306  *txtfile << apvpair->text << std::endl;
3307  }
3308 
3309  }
3310  *txtfile << "</pre><h3>"<< mod->name<<"</h3>"<<std::endl;
3311  }
3312  }
3313  }
3314  *txtfile << "</body></html>" << std::endl;
3315  txtfile->close();delete txtfile;
3316 }
3317  }
3319  std::ostringstream outs1,outs2;
3320  if(saveWebInterface)outs1 << outputfilename<<"fed.png";
3321  else outs1 << outputfilename<<"fed."<<filetype;
3322 save_as_fedtrackermap(true,0.,0.,outs1.str(),width,height);
3323  if(saveWebInterface){
3324  outs2 << outputfilename<<".xml";
3325 save_as_fedtrackermap(true,0.,0.,outs2.str(),3000,1600);
3326 //And a text file for each crate
3327  std::map<int , int>::iterator i_fed;
3328  std::ofstream * txtfile;
3329  for (int crate=firstcrate; crate < (ncrates+1); crate++){
3330  std::ostringstream outs;
3331  outs << outputfilename <<"crate"<<crate<< ".html";
3332  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3333  *txtfile << "<html><head></head> <body>" << std::endl;
3334  for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
3335  if(i_fed->second == crate){
3336  int fedId = i_fed->first;
3337  for (int nconn=0;nconn<96;nconn++){
3338  int key = fedId*1000+nconn;
3339  TmApvPair * apvPair= apvMap[key];
3340  if(apvPair !=0){
3341  int idmod=apvPair->idex;
3342  *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
3343  *txtfile << apvPair->text << std::endl;
3344  std::ostringstream outs;
3345  outs << "fedchannel " <<apvPair->getFedId() << "/"<<apvPair->getFedCh()<<" connects to module " << apvPair->mod->idex ;
3346  *txtfile << "</pre><h3>"<< outs.str()<<"</h3>"<<std::endl;
3347  }
3348  }
3349  }
3350  }
3351  *txtfile << "</body></html>" << std::endl;
3352  txtfile->close();delete txtfile;
3353  }
3354  }
3355  }
3357  std::ostringstream outs1,outs2;
3358  if(saveWebInterface)outs1 << outputfilename<<"fec.png";
3359  else outs1 << outputfilename<<"fec."<<filetype;
3360 save_as_fectrackermap(true,0.,0.,outs1.str(),width,height);
3361  if(saveWebInterface){
3362  outs2 << outputfilename<<".xml";
3363 save_as_fectrackermap(true,0.,0.,outs2.str(),3000,1600);
3364 //And a text file for each crate
3365  std::ofstream * txtfile;
3366  std::map<int , TmCcu *>::iterator i_ccu;
3367  std::multimap<TmCcu*, TmModule*>::iterator it;
3368  std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
3369  for (int crate=1; crate < (nfeccrates+1); crate++){
3370  std::ostringstream outs;
3371  outs << outputfilename <<"feccrate"<<crate<< ".html";
3372  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3373  *txtfile << "<html><head></head> <body>" << std::endl;
3374  for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
3375  TmCcu * ccu= i_ccu->second;
3376  if(ccu!=0&&ccu->getCcuCrate() == crate){
3377  int idmod=ccu->idex;
3378  *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
3379  *txtfile << ccu->text << std::endl;
3380  std::ostringstream outs;
3381  if(ccu->nmod==0)outs << "ccu is in position" << ccu->mpos<<"in ring but doesn't seem to have any module connected"; else
3382  {
3383  outs << "ccu is in position " << ccu->mpos<<" in ring and connects " <<ccu->nmod<< " modules" << std::endl;
3384  ret = fecModuleMap.equal_range(ccu);
3385  for (it = ret.first; it != ret.second; ++it)
3386  {
3387  outs << (*it).second->idex<<" " << (*it).second->name <<" value= "<< (*it).second->value<<"\n\n";
3388  }
3389 
3390  *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
3391  }//ifccu->nmod==0
3392  }//if ccu!=0
3393  }//for i_ccu
3394  *txtfile << "</body></html>" << std::endl;
3395  txtfile->close();
3396  }//for int crate
3397  }
3398  }
3399 if(enableLVProcessing){
3400  std::ostringstream outs3,outs4;
3401  if(saveWebInterface)outs3 << outputfilename<<"psu.png";
3402  else outs3 << outputfilename<<"psu."<<filetype;
3403 save_as_psutrackermap(true,0.,0.,outs3.str(),width,height);
3404  if(saveWebInterface){
3405  outs4 << outputfilename<<".xml";
3406 save_as_psutrackermap(true,0.,0.,outs4.str(),3000,1600);
3407 //And a text file for each rack
3408 
3409  std::ofstream * txtfile;
3410  std::map<int , TmPsu *>::iterator ipsu;
3411  std::multimap<TmPsu*, TmModule*>::iterator it;
3412  std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
3413  for (int rack=1; rack < (npsuracks+1); rack++){
3414  std::ostringstream outs;
3415 
3416  outs << outputfilename <<"psurack"<<rack<< ".html";
3417  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3418  *txtfile << "<html><head></head> <body>" << std::endl;
3419  for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
3420  TmPsu * psu= ipsu->second;
3421  if(psu!=0 && psu->getPsuRack() == rack){
3422  *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
3423  *txtfile << psu->text << std::endl;
3424  std::ostringstream outs;
3425  if(psu->nmod==0)outs << "Ps is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
3426  {
3427  outs<< "PS is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmod<<" modules. "<<std::endl;
3428 
3429  ret = psuModuleMap.equal_range(psu);
3430  for (it = ret.first; it != ret.second; ++it)
3431  {
3432  outs <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;
3433 
3434  }
3435  *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
3436  }
3437  }
3438  }
3439  *txtfile << "</body></html>" << std::endl;
3440  txtfile->close();
3441  }
3442  }
3443  }
3444 
3445 
3446 if(enableHVProcessing){
3447  std::ostringstream outs5,outs6;
3448  if(saveWebInterface)outs5 << outputfilename<<"hv.png";
3449  else outs5 << outputfilename<<"hv."<<filetype;
3450 save_as_HVtrackermap(true,0.,0.,outs5.str(),width,height);
3451  if(saveWebInterface){
3452  outs6 << outputfilename<<".xml";
3453 save_as_HVtrackermap(true,0.,0.,outs6.str(),3000,1600);
3454 //And a text file for each rack
3455 
3456  std::ofstream * txtfile;
3457  std::map<int , TmPsu *>::iterator ipsu;
3458  std::multimap<TmPsu*, TmModule*>::iterator it;
3459  std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
3460  for (int rack=1; rack < (npsuracks+1); rack++){
3461  std::ostringstream outs;
3462 
3463  outs << outputfilename <<"HVrack"<<rack<< ".html";
3464  txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3465  *txtfile << "<html><head></head> <body>" << std::endl;
3466  for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
3467  TmPsu * psu= ipsu->second;
3468  if(psu!=0 && psu->getPsuRack() == rack){
3469  *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
3470  *txtfile << psu->textHV2 << std::endl;
3471  std::ostringstream outsHV2;
3472  if(psu->nmodHV2==0)outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
3473  {
3474  outsHV2<< "HV Channel002 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV2<<" modules. "<<" <br>"<<std::endl;
3475 
3476  ret = psuModuleMap.equal_range(psu);
3477  for (it = ret.first; it != ret.second; ++it)
3478  {
3479  if((*it).second->HVchannel==2){outsHV2 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
3480  }
3481  *txtfile << "</pre><h4>"<< outsHV2.str()<<"</h4>"<<std::endl;
3482  }
3483 
3484  *txtfile << psu->textHV3 << std::endl;
3485  std::ostringstream outsHV3;
3486  if(psu->nmodHV3==0)outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
3487  {
3488  outsHV3<< "HV Channel003 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV3<<" modules. "<<" <br>"<<std::endl;
3489 
3490  ret = psuModuleMap.equal_range(psu);
3491  for (it = ret.first; it != ret.second; ++it)
3492  {
3493  if((*it).second->HVchannel==3){outsHV3 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
3494  }
3495  *txtfile << "</pre><h4>"<< outsHV3.str()<<"</h4>"<<std::endl;
3496  }
3497 
3498  }
3499  }
3500  *txtfile << "</body></html>" << std::endl;
3501  txtfile->close();
3502  }
3503  }
3504  }
3505 
3506 
3507 }
3508 
3509 
3511  std::ifstream * ifilename;
3512  std::string ifname;
3513  if(jsPath!=""){
3514  ifname=jsPath+filename;
3515  ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(),std::ios::in);
3516  if(!ifilename){
3517  ifname="CommonTools/TrackerMap/data/"+filename;
3518  ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(),std::ios::in);
3519  }
3520  }else {
3521  ifname="CommonTools/TrackerMap/data/"+filename;
3522  ifilename = new std::ifstream(edm::FileInPath(ifname).fullPath().c_str(),std::ios::in);
3523  }
3524  if(!ifilename)std::cout << "File " << filename << " missing" << std::endl;
3525  return ifilename;
3526  }
3527 void TrackerMap::printlayers(bool print_total, float minval, float maxval, std::string outputfilename){
3528  std::ofstream * xmlfile;
3529 saveAsSingleLayer=true;
3530 if(!print_total){
3531  for (int layer=1; layer < 44; layer++){
3532  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
3533  for (int module=1;module<200;module++) {
3534  int key=layer*100000+ring*1000+module;
3535  TmModule * mod = smoduleMap[key];
3536  if(mod !=0 && !mod->notInUse()){
3537  mod->value = mod->value / mod->count;
3538  }
3539  }
3540  }
3541  }
3542  }
3543  if(minvalue>=maxvalue){
3544  minvalue=9999999.;
3545  maxvalue=-9999999.;
3546  for (int layer=1; layer < 44; layer++){
3547  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
3548  for (int module=1;module<200;module++) {
3549  int key=layer*100000+ring*1000+module;
3550  TmModule * mod = smoduleMap[key];
3551  if(mod !=0 && !mod->notInUse()){
3552  if (minvalue > mod->value)minvalue=mod->value;
3553  if (maxvalue < mod->value)maxvalue=mod->value;
3554  }
3555  }
3556  }
3557  }
3558  }
3559 for (int layer=1; layer < 44; layer++){
3560  std::ostringstream outs;
3561  outs << outputfilename <<"layer"<<layer<< ".xml";
3562  xmlfile = new std::ofstream(outs.str().c_str(),std::ios::out);
3563  *xmlfile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
3564  *xmlfile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
3565  *xmlfile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
3566  *xmlfile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
3567  *xmlfile << "<script type=\"text/ecmascript\" xlink:href=\"layer.js\" />"<<std::endl;
3568  *xmlfile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerLayer.init()\">"<<std::endl;
3569  if(layer<31)*xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,1.)\" > "<<std::endl;
3570  else *xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,0.8)\" > "<<std::endl;
3571  *xmlfile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
3572  *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;
3573  *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;
3574  *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;
3575  *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;
3576  *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;
3577 
3578  // nlay=layer;
3579  defwindow(layer);
3580  for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
3581  for (int module=1;module<200;module++) {
3582  int key=layer*100000+ring*1000+module;
3583  TmModule * mod = smoduleMap[key];
3584  if(mod !=0 && !mod->notInUse()){
3585  drawModule(mod,key,layer,print_total,xmlfile);
3586  }
3587  }
3588  }
3589  *xmlfile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\">" << std::endl;
3590  *xmlfile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
3591  *xmlfile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
3592  *xmlfile << "<tspan id=\"line3\" x=\"40\" y=\"90\"> </tspan> " << std::endl;
3593  *xmlfile << "<tspan id=\"line4\" x=\"40\" y=\"120\"> </tspan> " << std::endl;
3594  if(layer > 33){
3595  *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;
3596  *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;
3597  *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;
3598  *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;
3599  *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;
3600  }
3601  else{
3602  *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;
3603  *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;
3604  *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;
3605  *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;
3606  *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;
3607  }
3608  *xmlfile << " </text> </svg>" << std::endl;
3609  xmlfile->close();delete xmlfile;
3610  }
3611 saveAsSingleLayer=false;
3612 }
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:2659
std::string text
Definition: TmApvPair.h:12
T getUntrackedParameter(std::string const &, T const &) const
int getPsuBranch()
Definition: TmPsu.h:14
int i
Definition: DBlmapReader.cc:9
#define NUMFEDCRATE_INCOLUMN
Definition: TrackerMap.h:56
void build()
Definition: TrackerMap.cc:2808
tuple ret
prodAgent to be discontinued
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:3510
int nfeccrates
Definition: TrackerMap.h:488
int redHV2
Definition: TmPsu.h:21
void fillc_all_blank()
Definition: TrackerMap.cc:2732
#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:2631
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:1844
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:2688
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:2565
const std::vector< SiStripFecCrate > & crates() const
float value
Definition: TmPsu.h:23
tuple txtfile
Delete all three files at once to make sure the user never sees stale data (e.g.
#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:2576
tuple xmlfile
Make an XML representation of the misalignment.
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
void fill_all_blank()
Definition: TrackerMap.cc:2740
void fillc_lv_channel(int rack, int crate, int board, int red, int green, int blue)
Definition: TrackerMap.cc:2604
unsigned int idex
Definition: TmModule.h:29
vector< Color_t > colors
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:1238
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:699
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
int j
Definition: DBlmapReader.cc:9
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:2398
int greenHV2
Definition: TmPsu.h:21
#define XFEDCSIZE
Definition: TrackerMap.h:60
static const int npoints
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void drawApvPair(int crate, int numfed_incrate, bool total, TmApvPair *apvPair, std::ofstream *file, bool useApvPairValue)
Definition: TrackerMap.cc:943
void init()
Definition: TrackerMap.cc:439
void fillc_fed_channel(int fedId, int fedCh, int red, int green, int blue)
Definition: TrackerMap.cc:2538
#define M_PI
int getcolor(float value, int palette)
Definition: TrackerMap.cc:2851
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
void printlayers(bool print_total=true, float minval=0., float maxval=0., std::string s="layer")
Definition: TrackerMap.cc:3527
int psuIdex
Definition: TmModule.h:19
SvgFed slotMap
Definition: TrackerMap.h:150
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:1171
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:1029
short int HVchannel
Definition: TmModule.h:20
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:2126
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:2671
#define NUMPSUCRATE_INCOLUMN
Definition: TrackerMap.h:42
float thickness
Definition: TmModule.h:10
float valueHV2
Definition: TmPsu.h:25
tuple branchinfo
Definition: dataDML.py:2355
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:671
void drawPalette(std::ofstream *file, int xoffset=3660, int yoffset=1540)
Definition: TrackerMap.cc:2500
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:2878
int nlayer(int det, int part, int lay)
Definition: TrackerMap.h:450
std::string textHV3
Definition: TmPsu.h:37
int red
Definition: TmCcu.h:9
#define NUMFED_INROW
Definition: TrackerMap.h:53
tuple filetype
Definition: symbols.py:48
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:2433
tuple filename
Definition: lut2db_cfg.py:20
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:2589
float gmaxvalue
Definition: TrackerMap.h:499
int idex
Definition: TmApvPair.h:14
void fill_current_val(int idmod, float current_val)
Definition: TrackerMap.cc:2750
float maxvalue
Definition: TrackerMap.h:500
tuple cout
Definition: gather_cfg.py:145
std::string cmodid_LV
Definition: TmPsu.h:32
float valueHV3
Definition: TmPsu.h:24
void setText(int idmod, std::string s)
Definition: TrackerMap.cc:2788
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 col
Definition: cuy.py:1008
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:2618
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:3179
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:1094
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:2777
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:1303
std::string name
Definition: TmModule.h:15
void fill_fed_channel(int fedId, int fedCh, float qty)
Definition: TrackerMap.cc:2698
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:2644
int ntotRing[43]
Definition: TrackerMap.h:479
int getPsuCrate()
Definition: TmPsu.h:16
std::pair< float, float > getAutomaticRange()
Definition: TrackerMap.cc:675
std::string jsfilename
Definition: TrackerMap.h:171