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