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