00001 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
00002 #include "CommonTools/TrackerMap/interface/TmModule.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "FWCore/ParameterSet/interface/FileInPath.h"
00005 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00006 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
00007 #include "CommonTools/TrackerMap/interface/TmApvPair.h"
00008 #include "CommonTools/TrackerMap/interface/TmCcu.h"
00009 #include "CommonTools/TrackerMap/interface/TmPsu.h"
00010 #include <fstream>
00011 #include <vector>
00012 #include <iostream>
00013 #include <sstream>
00014 #include "TCanvas.h"
00015 #include "TPolyLine.h"
00016 #include "TStyle.h"
00017 #include "TColor.h"
00018 #include "TROOT.h"
00019 #include "TGaxis.h"
00020 #include "TLatex.h"
00021 #include "TArrow.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030 TrackerMap::TrackerMap(const edm::ParameterSet & tkmapPset,const edm::ESHandle<SiStripFedCabling> tkFed) {
00031
00032 psetAvailable=true;
00033 xsize=340;ysize=200;
00034 title=" ";
00035 jsPath="";
00036 jsfilename="CommonTools/TrackerMap/data/trackermap.txt";
00037 infilename="CommonTools/TrackerMap/data/tracker.dat";
00038 saveAsSingleLayer=false;
00039 if(tkmapPset.exists("trackermaptxtPath")){
00040 jsPath=tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath",""
00041 );
00042 jsfilename=jsPath+"trackermap.txt";
00043 std::cout << jsfilename << std::endl;
00044 infilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"tracker.dat";
00045 std::cout << infilename << std::endl;
00046 ncrates=0;
00047 enableFedProcessing=tkmapPset.getUntrackedParameter<bool>("loadFedCabling",false);
00048 nfeccrates=0;
00049 enableFecProcessing=tkmapPset.getUntrackedParameter<bool>("loadFecCabling",false);
00050
00051 npsuracks=0;
00052 enableLVProcessing=tkmapPset.getUntrackedParameter<bool>("loadLVCabling",false);
00053
00054 enableHVProcessing=tkmapPset.getUntrackedParameter<bool>("loadHVCabling",false);
00055
00056 } else std::cout << "no parameters found" << std::endl;
00057
00058 init();
00059
00060 if(enableFedProcessing){
00061 const std::vector<unsigned short> feds = tkFed->feds();
00062 std::cout<<"SiStripFedCabling has "<< feds.size()<<" active FEDS"<<std::endl;
00063 int num_board=0;
00064 int num_crate=0;
00065 for(std::vector<unsigned short>::const_iterator ifed = feds.begin();ifed<feds.end();ifed++){
00066 const std::vector<FedChannelConnection> theconn = tkFed->connections( *ifed );
00067 int num_conn=0;
00068 for(std::vector<FedChannelConnection>::const_iterator iconn = theconn.begin();iconn<theconn.end();iconn++){
00069
00070 if( iconn->fedId()== sistrip::invalid_ ||
00071 iconn->detId() == sistrip::invalid_ ||
00072 iconn->detId() == sistrip::invalid32_ ||
00073 iconn->apvPairNumber() == sistrip::invalid_ ||
00074 iconn->nApvPairs() == sistrip::invalid_ ) {
00075 continue;
00076 }
00077
00078 TmModule *imod = imoduleMap[iconn->detId()];
00079 int key = iconn->fedId()*1000+iconn->fedCh();
00080 TmApvPair* apvpair = apvMap[key];
00081 if(apvpair!=0)std::cout << "Fed "<< iconn->fedId() << " channel " << iconn->fedCh() << " seem to be already loaded!"<<std::endl;
00082 else
00083 {
00084 num_conn++;
00085 if(num_conn==1){
00086 if(fedMap[iconn->fedId()]==0){num_crate=num_board/18+1;fedMap[iconn->fedId()]=num_crate;num_board++;}
00087 }
00088 apvpair = new TmApvPair(key,num_crate);
00089 apvpair->mod=imod;
00090 apvpair->mpos=iconn->apvPairNumber();
00091 apvMap[key] = apvpair;
00092 apvModuleMap.insert(std::make_pair(iconn->detId(),apvpair));
00093 std::stringstream s;
00094 iconn->print(s);
00095 apvpair->text=s.str();
00096 }
00097 }
00098 }
00099 ncrates=num_crate;
00100 std::cout << num_crate << " crates used "<< std::endl;
00101
00102 std::map<int , TmModule *>::iterator i_mod;
00103 for( i_mod=imoduleMap.begin();i_mod !=imoduleMap.end(); i_mod++){
00104 TmModule * mod= i_mod->second;
00105 if(mod!=0) {
00106 std::ostringstream outs,outs1;
00107 outs << " connected to ";
00108 outs1 << "(";
00109
00110 int idmod=mod->idex;
00111 int nchan=0;
00112 std::multimap<const int, TmApvPair*>::iterator pos;
00113 for (pos = apvModuleMap.lower_bound(idmod);
00114 pos != apvModuleMap.upper_bound(idmod); ++pos) {
00115 TmApvPair* apvpair = pos->second;
00116 if(apvpair!=0){
00117 outs << apvpair->mpos << " " <<apvpair->getFedId() << "/"<<apvpair->getFedCh()<<" ";
00118 outs1 << apvpair->idex+apvpair->crate*1000000<<",";
00119 nchan++;
00120 }
00121
00122 }
00123 outs<< "("<<nchan<<")";
00124 mod->name=mod->name + outs.str();
00125 std::string s = outs1.str(); s.erase(s.end()-1,s.end());
00126 mod->capvids=s+")";
00127 }
00128 }
00129 }
00130
00131 if(enableFecProcessing){
00132 int nfec=0; int nccu; int nmod;
00133 int crate,slot,ring,addr,pos;
00134 SiStripFecCabling* fecCabling_;
00135 fecCabling_ = new SiStripFecCabling( *tkFed );
00136 std::string Ccufilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"cculist.txt";
00137 ifstream Ccufile(edm::FileInPath(Ccufilename).fullPath().c_str(),std::ios::in);
00138 std::string dummys;
00139 while(!Ccufile.eof()) {
00140 Ccufile >> crate >> slot >> ring >> addr >> pos;
00141 getline(Ccufile,dummys);
00142 int key =crate*10000000+slot*100000+ring*1000+addr;
00143 TmCcu * ccu = ccuMap[key];
00144 if(ccu==0){
00145 ccu = new TmCcu(crate,slot,ring,addr);
00146 ccu->mpos=pos,
00147 ccuMap[key]=ccu;
00148 }
00149 }
00150
00151 for ( std::vector<SiStripFecCrate>::const_iterator icrate = fecCabling_->crates().begin(); icrate != fecCabling_->crates().end(); icrate++ ) {
00152 for ( std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
00153 for ( std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
00154 nccu=0;nfec++;
00155 for ( std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
00156 nccu++; nmod=0;
00157 int key = icrate->fecCrate()*10000000+ifec->fecSlot()*100000+iring->fecRing()*1000+iccu->ccuAddr();
00158 int layer=0;
00159 TmCcu * ccu = ccuMap[key];
00160 for ( std::vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end(); imod++ ) {
00161 nmod++;
00162 TmModule *imod1 = imoduleMap[imod->detId()];
00163 layer=imod1->layer;
00164 fecModuleMap.insert(std::make_pair(ccu,imod1));
00165 if(imod1!=0)imod1->CcuId=key;
00166 }
00167 if(ccu==0)std::cout <<key<< " This ccu seems to have not been stored! " << std::endl; else{ ccu->nmod=nmod;ccu->layer=layer;}
00168
00169
00170 }
00171 }
00172 }
00173 }
00174
00175 std::map<int , TmCcu *>::iterator i_ccu;
00176 std::multimap<TmCcu*, TmModule*>::iterator it;
00177 std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
00178 nccu=0;
00179 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
00180 TmCcu * ccu= i_ccu->second;
00181 nccu++;
00182 if(ccu!=0){
00183 std::ostringstream outs;
00184 std::ostringstream outs1;
00185 outs << "CCU "<<ccu->idex <<" connected to fec,ring " << ccu->getCcuSlot() <<","<<ccu->getCcuRing()<< " in crate " <<ccu->getCcuCrate()<<" at position "<< ccu->mpos << " with " << ccu->nmod << " modules: ";
00186 outs1<<"(";
00187 ret = fecModuleMap.equal_range(ccu);
00188 for (it = ret.first; it != ret.second; ++it)
00189 {
00190 outs << (*it).second->idex << " ";
00191 outs1 << (*it).second->getKey() <<",";
00192 }
00193 outs1 << ")";
00194 ccu->text=outs.str();
00195 ccu->cmodid=outs1.str();
00196
00197 }
00198
00199 }
00200 nfeccrates=4;
00201 std::cout << nccu << " ccu stored in " <<nfeccrates<< " crates"<< std::endl;
00202
00203 delete fecCabling_ ;
00204
00205 }
00206
00207
00208 if(enableLVProcessing || enableHVProcessing){
00209 int npsu=0; int nmod,nmodHV2,nmodHV3;
00210 int modId1,modId2, dcuId;
00211 int dcs,branch,crate,board;
00212 int rack=0;
00213 std::string channelstr1;
00214 short int channel;
00215 std::string psinfo;
00216
00217
00218
00219
00220
00221 std::string LVfilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"psdcumap.dat";
00222 std::string HVfilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"hvmap.dat";
00223
00224 ifstream LVfile(edm::FileInPath(LVfilename).fullPath().c_str(),std::ios::in);
00225
00226 std::cout<<LVfilename<<" "<<HVfilename<<std::endl;
00227
00228
00229 if(enableHVProcessing){
00230
00231 ifstream HVfile(edm::FileInPath(HVfilename).fullPath().c_str(),std::ios::in);
00232 while(!HVfile.eof()) {
00233 HVfile >> modId2 >> channelstr1;
00234 std::string channelstr2 = channelstr1.substr(9,1);
00235 channel= atoi(channelstr2.c_str());
00236 TmModule *imod = imoduleMap[modId2];
00237
00238 imod->HVchannel=channel;
00239
00240 }
00241
00242 }
00243
00244
00245 while(!LVfile.eof()) {
00246 LVfile >> modId1 >> dcuId >> psinfo;
00247
00248 int length=psinfo.length();
00249 std::string dcsinfo = psinfo.substr(39,1);
00250 std::string branchinfo = psinfo.substr(57,2);
00251 std::string crateinfo= psinfo.substr(69,1);
00252 std::string boardinfo = psinfo.substr(80,2);
00253 std::string psIdinfo = psinfo.substr(83,length-83);
00254
00255 dcs= atoi(dcsinfo.c_str());
00256 branch= atoi(branchinfo.c_str());
00257 crate= atoi(crateinfo.c_str())+1;
00258 board= atoi(boardinfo.c_str())+1;
00259
00260 if(dcs==1)rack=(branch+1)/2;
00261 if(dcs==2)rack=(branch+1)/2 + 7;
00262 if(dcs==3)rack=(branch+1)/2 + 15;
00263 if(dcs==4)rack=(branch+1)/2 + 22;
00264
00265 int key = rack*1000+crate*100+board;
00266
00267 TmPsu *psu = psuMap[key];
00268 TmModule *imod = imoduleMap[modId1];
00269 if(psu==0){
00270 psu = new TmPsu(dcs,branch,rack,crate,board);
00271 psuMap[key]=psu;
00272 psu->psId=psIdinfo;
00273 }
00274
00275 psuModuleMap.insert(std::make_pair(psu,imod));
00276 if(imod!=0)imod->PsuId=psIdinfo;imod->psuIdex=psu->idex;
00277
00278 }
00279
00280
00281
00282 std::map<int , TmPsu *>::iterator ipsu;
00283 std::multimap<TmPsu*, TmModule*>::iterator it;
00284 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
00285 npsu=0;
00286
00287 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
00288 TmPsu * psu= ipsu->second;
00289 npsu++;
00290
00291 if(psu!=0){
00292
00293 std::ostringstream outs;
00294 std::ostringstream outs1;
00295
00296 std::ostringstream outs3;
00297 std::ostringstream outs4;
00298
00299 std::ostringstream outs5;
00300 std::ostringstream outs6;
00301
00302 outs <<"PSU "<<psu->psId<<" connected to Mainframe "<<psu->getPsuDcs()<<" BranchController "<<psu->getPsuBranch()<<" (Rack "<<psu->getPsuRack()<<"), crate "<<psu->getPsuCrate()<<" in position "<< psu->getPsuBoard()<< " with modules: ";
00303 outs1<<"(";
00304
00305 if(enableHVProcessing){
00306 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: ";
00307 outs4<<"(";
00308
00309 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: ";
00310 outs6<<"(";}
00311
00312
00313 ret = psuModuleMap.equal_range(psu);
00314 nmod=0;
00315 nmodHV2=0;
00316 nmodHV3=0;
00317 for (it = ret.first; it != ret.second; ++it)
00318 {
00319 nmod++;
00320 outs << (*it).second->idex << ", ";
00321 outs1 << (*it).second->getKey() <<",";
00322
00323 if(enableHVProcessing){
00324 if((*it).second->HVchannel==2){
00325 nmodHV2++;
00326 outs3 << (*it).second->idex << ", ";
00327 outs4 << (*it).second->getKey() <<",";}
00328 else if((*it).second->HVchannel==3){
00329 nmodHV3++;
00330 outs5 << (*it).second->idex << ", ";
00331 outs6 << (*it).second->getKey() <<",";}
00332
00333 }
00334 }
00335
00336 outs1 << ")";
00337 psu->nmod=nmod;
00338 outs << "(" << psu->nmod << ")";
00339 psu->text=outs.str();
00340 psu->cmodid_LV=outs1.str();
00341 if(enableHVProcessing){
00342 outs4 << ")";
00343 outs6 << ")";
00344 psu->nmodHV2=nmodHV2;
00345 psu->nmodHV3=nmodHV3;
00346 outs3 << "(" << psu->nmodHV2 << ")";
00347 outs5 << "(" << psu->nmodHV3 << ")";
00348 psu->textHV2=outs3.str();
00349 psu->textHV3=outs5.str();
00350 psu->cmodid_HV2=outs4.str();
00351 psu->cmodid_HV3=outs6.str();
00352 }
00353 }
00354 }
00355
00356
00357 npsuracks=29;
00358 std::cout << npsu << " psu stored in " <<npsuracks<<" racks"<<std::endl;
00359 }
00360 }
00361
00362 TrackerMap::TrackerMap(const edm::ParameterSet & tkmapPset) {
00363 psetAvailable=true;
00364 xsize=340;ysize=200;
00365 title=" ";
00366 jsfilename="CommonTools/TrackerMap/data/trackermap.txt";
00367 infilename="CommonTools/TrackerMap/data/tracker.dat";
00368 enableFedProcessing=true;ncrates=0;
00369 saveAsSingleLayer=false;
00370 if(tkmapPset.exists("trackermaptxtPath")){
00371 jsfilename=tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath","")+"trackermap.txt";
00372 std::cout << jsfilename << std::endl;
00373 infilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"tracker.dat";
00374 std::cout << infilename << std::endl;
00375 } else std::cout << "no parameters found" << std::endl;
00376 init();
00377 }
00378
00379 TrackerMap::TrackerMap(std::string s,int xsize1,int ysize1) {
00380 psetAvailable=false;
00381 xsize=xsize1;ysize=ysize1;
00382 title=s;
00383 jsfilename="CommonTools/TrackerMap/data/trackermap.txt";
00384 infilename="CommonTools/TrackerMap/data/tracker.dat";
00385 enableFedProcessing=false;
00386 saveAsSingleLayer=false;
00387 init();
00388 }
00389
00390 void TrackerMap::reset() {
00391 std::map<int , TmModule *>::iterator i_mod;
00392 for( i_mod=imoduleMap.begin();i_mod !=imoduleMap.end(); i_mod++){
00393 TmModule * mod= i_mod->second;
00394 mod->count=0;mod->value=0;mod->red=-1;
00395 }
00396 }
00397
00398 void TrackerMap::init() {
00399
00400 int ntotmod=0;
00401 ix=0;iy=0;
00402 firstcall = true;
00403 minvalue=0.; maxvalue=minvalue;
00404 posrel=true;
00405 palette = 1;
00406 printflag=true;
00407 addPixelFlag=false;
00408 temporary_file=false;
00409 gminvalue=0.; gmaxvalue=0.;
00410
00411 ndet = 3;
00412 npart = 3;
00413
00414
00415 for (int subdet=1; subdet < ndet+1; subdet++){
00416 for (int detpart=1; detpart < npart+1; detpart++){
00417 int nlayers = getlayerCount(subdet,detpart);
00418 for(int layer=1; layer < nlayers+1; layer++){
00419 int nrings = getringCount(subdet,detpart,layer);
00420
00421 int layer_g = nlayer(subdet,detpart,layer);
00422 ntotRing[layer_g-1]=nrings;
00423 firstRing[layer_g-1]=1;
00424 if(subdet==3 && detpart!=2) firstRing[layer_g-1]= 8-nrings;
00425 for (int ring=firstRing[layer_g-1]; ring < ntotRing[layer_g-1]+firstRing[layer_g-1];ring++){
00426 int nmodules = getmoduleCount(subdet,detpart,layer,ring);
00427 int key=0;
00428 TmModule *smodule;
00429 for(int module=1; module < nmodules+1; module++){
00430 smodule = new TmModule(module,ring,layer_g);
00431 key=layer_g*100000+ring*1000+module;
00432 smoduleMap[key]=smodule;
00433 ntotmod++;
00434 }
00435 if(isRingStereo(key))for(int module=1; module < nmodules+1; module++){
00436 smodule = new TmModule(module+100,ring,layer_g);
00437 int key=layer_g*100000+ring*1000+module+100;
00438 smoduleMap[key]=smodule;
00439 ntotmod++;
00440 }
00441 }
00442 }
00443 }
00444 }
00445 build();
00446 }
00447
00448 TrackerMap::~TrackerMap() {
00449
00450 for (int layer=1; layer < 44; layer++){
00451 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00452 for (int module=1;module<200;module++) {
00453 int key=layer*100000+ring*1000+module;
00454 TmModule * mod = smoduleMap[key];
00455 if(mod !=0 ) delete mod;
00456 }
00457 }
00458 }
00459
00460
00461
00462
00463
00464
00465 std::map<int , TmApvPair *>::iterator i_apv;
00466 for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
00467 TmApvPair * apvPair= i_apv->second;
00468 delete apvPair;
00469 }
00470
00471
00472 std::map<int , TmCcu *>::iterator i_ccu;
00473 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
00474 TmCcu * ccu= i_ccu->second;
00475 delete ccu;
00476 }
00477
00478 std::map<int , TmPsu *>::iterator ipsu;
00479 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
00480 TmPsu * psu= ipsu->second;
00481 delete psu;
00482 }
00483
00484 gROOT->Reset();
00485
00486
00487
00488
00489 }
00490
00491
00492
00493
00494
00495 void TrackerMap::drawModule(TmModule * mod, int key,int nlay, bool print_total, std::ofstream * svgfile){
00496
00497 double phi,r,dx,dy, dy1;
00498 double xp[4],yp[4],xp1,yp1;
00499 double vhbot,vhtop,vhapo;
00500 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};
00501 double xt1,yt1,xs1=0.,ys1=0.,xt2,yt2,xs2,ys2,pv1,pv2;
00502 int green = 0;
00503 int red = 0;
00504 int blue = 0;
00505 double xd[4],yd[4];
00506 int np = 4;
00507
00508 int numod=0;
00509 phi = phival(mod->posx,mod->posy);
00510 r = sqrt(mod->posx*mod->posx+mod->posy*mod->posy);
00511 vhbot = mod->width;
00512 vhtop=mod->width;
00513 vhapo=mod->length;
00514 if(nlay < 31){
00515 vhbot = mod->widthAtHalfLength/2.-(mod->width/2.-mod->widthAtHalfLength/2.);
00516 vhtop=mod->width/2.;
00517 vhapo=mod->length/2.;
00518 if(nlay >12 && nlay <19){
00519 if(posrel)r = r+r;
00520 xp[0]=r-vhtop;yp[0]=-vhapo;
00521 xp[1]=r+vhtop;yp[1]=-vhapo;
00522 xp[2]=r+vhtop;yp[2]=vhapo;
00523 xp[3]=r-vhtop;yp[3]=vhapo;
00524 }else{
00525 if(posrel)r = r + r/3.;
00526 xp[0]=r-vhapo;yp[0]=-vhbot;
00527 xp[1]=r+vhapo;yp[1]=-vhtop;
00528 xp[2]=r+vhapo;yp[2]=vhtop;
00529 xp[3]=r-vhapo;yp[3]=vhbot;
00530 }
00531 for(int j=0;j<4;j++){
00532 xp1 = xp[j]*cos(phi)-yp[j]*sin(phi);
00533 yp1 = xp[j]*sin(phi)+yp[j]*cos(phi);
00534 xp[j] = xp1;yp[j]=yp1;
00535 }
00536 } else {
00537 numod=mod->idModule;if(numod>100)numod=numod-100;
00538 int vane = mod->ring;
00539 if(posrel){
00540 dx = vhapo;
00541 phi=M_PI;
00542 xt1=rmedio[nlay-31]; yt1=-vhtop/2.;
00543 xs1 = xt1*cos(phi)-yt1*sin(phi);
00544 ys1 = xt1*sin(phi)+yt1*cos(phi);
00545 xt2=rmedio[nlay-31]; yt2=vhtop/2.;
00546 xs2 = xt2*cos(phi)-yt2*sin(phi);
00547 ys2 = xt2*sin(phi)+yt2*cos(phi);
00548 dy=phival(xs2,ys2)-phival(xs1,ys1);
00549 dy1 = dy;
00550 if(nlay==31)dy1=0.39;
00551 if(nlay==32)dy1=0.23;
00552 if(nlay==33)dy1=0.16;
00553 xp[0]=vane*(dx+dx/8.);yp[0]=numod*(dy1);
00554 xp[1]=vane*(dx+dx/8.)+dx;yp[1]=numod*(dy1);
00555 xp[2]=vane*(dx+dx/8.)+dx;yp[2]=numod*(dy1)+dy;
00556 xp[3]=vane*(dx+dx/8.);yp[3]=numod*(dy1)+dy;
00557 }else{
00558 xt1=r; yt1=-vhtop/2.;
00559 xs1 = xt1*cos(phi)-yt1*sin(phi);
00560 ys1 = xt1*sin(phi)+yt1*cos(phi);
00561 xt2=r; yt2=vhtop/2.;
00562 xs2 = xt2*cos(phi)-yt2*sin(phi);
00563 ys2 = xt2*sin(phi)+yt2*cos(phi);
00564 pv1=phival(xs1,ys1);
00565 pv2=phival(xs2,ys2);
00566 if(fabs(pv1-pv2)>M_PI && numod==1)pv1=pv1-2.*M_PI;
00567 if(fabs(pv1-pv2)>M_PI && numod!=1)pv2=pv2+2.*M_PI;
00568 xp[0]=mod->posz-vhapo/2.;yp[0]=4.2*pv1;
00569 xp[1]=mod->posz+vhapo/2.;yp[1]=4.2*pv1;
00570 xp[2]=mod->posz+vhapo/2. ;yp[2]=4.2*pv2;
00571 xp[3]=mod->posz-vhapo/2.;yp[3]=4.2*pv2;
00572 }
00573 }
00574 if(isRingStereo(key))
00575 {
00576 np = 3;
00577 if(mod->idModule>100 ){for(int j=0;j<3;j++){
00578 xd[j]=xdpixel(xp[j]);yd[j]=ydpixel(yp[j]);
00579 }
00580 }else {
00581 xd[0]=xdpixel(xp[2]);yd[0]=ydpixel(yp[2]);
00582 xd[1]=xdpixel(xp[3]);yd[1]=ydpixel(yp[3]);
00583 xd[2]=xdpixel(xp[0]);yd[2]=ydpixel(yp[0]);
00584 }
00585 } else {
00586 for(int j=0;j<4;j++){
00587 xd[j]=xdpixel(xp[j]);yd[j]=ydpixel(yp[j]);
00588 }
00589 }
00590 char buffer [20];
00591 sprintf(buffer,"%X",mod->idex);
00592
00593 if(mod->red < 0){
00594 int color = getcolor(mod->value,palette);
00595 red=(color>>16)&0xFF;
00596 green=(color>>8)&0xFF;
00597 blue=(color)&0xFF;
00598
00599 if(!print_total)mod->value=mod->value*mod->count;
00600
00601 if(mod->count > 0)
00602 if(temporary_file) *svgfile << red << " " << green << " " << blue << " "; else
00603 *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=\"";
00604 else
00605 if(temporary_file) *svgfile << 255 << " " << 255 << " " << 255 << " "; else
00606 *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=\"";
00607 if(temporary_file) *svgfile << np << " ";
00608 for(int k=0;k<np;k++){
00609 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ; else
00610 *svgfile << xd[k] << "," << yd[k] << " " ;
00611 }
00612 if(temporary_file)*svgfile << std::endl; else *svgfile <<"\" />" <<std::endl;
00613 } else {
00614 if(mod->red>255)mod->red=255;
00615 if(mod->green>255)mod->green=255;
00616 if(mod->blue>255)mod->blue=255;
00617 if(temporary_file) *svgfile << mod->red << " " << mod->green << " " << mod->blue << " "; else
00618 *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=\"";
00619 if(temporary_file) *svgfile << np << " ";
00620 for(int k=0;k<np;k++){
00621 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ; else
00622 *svgfile << xd[k] << "," << yd[k] << " " ;
00623 }
00624 if(temporary_file)*svgfile << std::endl; else *svgfile <<"\" />" <<std::endl;
00625 }
00626
00627 }
00628
00629
00630
00631
00632 void TrackerMap::save(bool print_total,float minval, float maxval,std::string s,int width, int height){
00633
00634 std::string filetype=s,outputfilename=s;
00635 std::vector<TPolyLine*> vp;
00636 TGaxis *axis = 0 ;
00637 size_t found=filetype.find_last_of(".");
00638 filetype=filetype.substr(found+1);
00639 found=outputfilename.find_last_of(".");
00640 outputfilename=outputfilename.substr(0,found);
00641
00642 temporary_file=true;
00643 if(filetype=="svg")temporary_file=false;
00644 std::ostringstream outs;
00645 minvalue=minval; maxvalue=maxval;
00646 outs << outputfilename << ".coor";
00647 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
00648 if(!print_total){
00649 for (int layer=1; layer < 44; layer++){
00650 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00651 for (int module=1;module<200;module++) {
00652 int key=layer*100000+ring*1000+module;
00653 TmModule * mod = smoduleMap[key];
00654 if(mod !=0 && !mod->notInUse()){
00655 mod->value = mod->value / mod->count;
00656 }
00657 }
00658 }
00659 }
00660 }
00661
00662 if(minvalue>=maxvalue){
00663 minvalue=9999999.;
00664 maxvalue=-9999999.;
00665 for (int layer=1; layer < 44; layer++){
00666 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00667 for (int module=1;module<200;module++) {
00668 int key=layer*100000+ring*1000+module;
00669 TmModule * mod = smoduleMap[key];
00670 if(mod !=0 && !mod->notInUse()){
00671 if (minvalue > mod->value)minvalue=mod->value;
00672 if (maxvalue < mod->value)maxvalue=mod->value;
00673 }
00674 }
00675 }
00676 }
00677 }
00678 if (maxvalue == minvalue) printflag = false;
00679 if(!temporary_file){
00680 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
00681 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
00682 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
00683 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
00684 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3100 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
00685 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3100\" height=\"1600\" /> "<<std::endl;
00686 *savefile << "<svg:g id=\"tracker\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
00687 }
00688 for (int layer=1; layer < 44; layer++){
00689 nlay=layer;
00690 defwindow(nlay);
00691 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00692 for (int module=1;module<200;module++) {
00693 int key=layer*100000+ring*1000+module;
00694 TmModule * mod = smoduleMap[key];
00695 if(mod !=0 && !mod->notInUse()){
00696 drawModule(mod,key,layer,print_total,savefile);
00697 }
00698 }
00699 }
00700 }
00701
00702 if(!temporary_file){
00703 *savefile << "</svg:g>"<<std::endl;
00704 *savefile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">"<<title<<"</svg:text>"<<std::endl;
00705 }
00706
00707 if(printflag)drawPalette(savefile);
00708 if(!temporary_file){
00709 *savefile << "</svg:svg>"<<std::endl;
00710 *savefile << "</svg>"<<std::endl;
00711 }
00712 savefile->close(); delete savefile;
00713
00714 const char * command1;
00715 std::string tempfilename = outputfilename + ".coor";
00716 if(filetype=="svg"){
00717 std::string command = "mv "+tempfilename +" " +outputfilename + ".svg";
00718 command1=command.c_str();
00719 std::cout << "Executing " << command1 << std::endl;
00720 system(command1);
00721 }
00722
00723 if (temporary_file){
00724 int red,green,blue,npoints,colindex,ncolor;
00725 double x[4],y[4];
00726 ifstream tempfile(tempfilename.c_str(),std::ios::in);
00727 TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
00728 gPad->SetFillColor(38);
00729
00730 if(addPixelFlag)gPad->Range(0,0,3800,1600);else gPad->Range(800,0,3800,1600);
00731
00732
00733 ncolor=0;
00734 typedef std::map<int,int> ColorList;
00735 ColorList colorList;
00736 ColorList::iterator pos;
00737 TColor *col, *c;
00738 std::cout<<"tempfilename "<<tempfilename<<std::endl;
00739 while(!tempfile.eof()) {
00740 tempfile >> red >> green >> blue >> npoints;
00741 colindex=red+green*1000+blue*1000000;
00742 pos=colorList.find(colindex);
00743 if(pos == colorList.end()){ colorList[colindex]=ncolor+100; col =gROOT->GetColor(ncolor+100);
00744 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++;}
00745 for (int i=0;i<npoints;i++){
00746 tempfile >> x[i] >> y[i];
00747 }
00748 }
00749
00750 if(ncolor>0 && ncolor<10000){
00751 Int_t colors[10000];
00752 for(int i=0;i<ncolor;i++){colors[i]=i+100;}
00753 gStyle->SetPalette(ncolor,colors);
00754 }
00755
00756 tempfile.clear();
00757 tempfile.seekg(0,std::ios::beg);
00758 std::cout << "created palette with " << ncolor << " colors" << std::endl;
00759
00760 while(!tempfile.eof()) {
00761 tempfile >> red >> green >> blue >> npoints;
00762 for (int i=0;i<npoints;i++){
00763 tempfile >> x[i] >> y[i];
00764 }
00765 colindex=red+green*1000+blue*1000000;
00766 pos=colorList.find(colindex);
00767 if(pos != colorList.end()){
00768 TPolyLine* pline = new TPolyLine(npoints,y,x);
00769 vp.push_back(pline);
00770 pline->SetFillColor(colorList[colindex]);
00771 pline->SetLineWidth(0);
00772 pline->Draw("f");
00773 }
00774 }
00775 if (printflag) {
00776 axis = new TGaxis(3660,36,3660,1530,minvalue,maxvalue,510,"+L");
00777 axis->SetLabelSize(0.02);
00778 axis->Draw();
00779 }
00780 TLatex l;
00781 l.SetTextSize(0.03);
00782 l.DrawLatex(950,1330,"TID");
00783 l.DrawLatex(2300,1330,"TEC");
00784 l.DrawLatex(300,1330,"FPIX");
00785 l.DrawLatex(20,560,"BPIX L1");
00786 l.DrawLatex(500,385,"BPIX L2");
00787 l.DrawLatex(500,945,"BPIX L3");
00788 l.SetTextSize(0.04);
00789 l.DrawLatex(850,1500,title.c_str());
00790 l.DrawLatex(1730,40,"-z");
00791 l.DrawLatex(1730,1360,"+z");
00792 l.DrawLatex(1085,330,"TIB L1");
00793 l.DrawLatex(1085,1000,"TIB L2");
00794 l.DrawLatex(1585,330,"TIB L3");
00795 l.DrawLatex(1585,1000,"TIB L4");
00796 l.DrawLatex(2085,330,"TOB L1");
00797 l.DrawLatex(2085,1000,"TOB L2");
00798 l.DrawLatex(2585,330,"TOB L3");
00799 l.DrawLatex(2585,1000,"TOB L4");
00800 l.DrawLatex(3085,330,"TOB L5");
00801 l.DrawLatex(3085,1000,"TOB L6");
00802 TArrow arx(3448,1190,3448,1350,0.01,"|>");
00803 l.DrawLatex(3460,1350,"x");
00804 TArrow ary(3448,1190,3312,1190,0.01,"|>");
00805 l.DrawLatex(3312,1210,"y");
00806 TArrow arz(3485,373,3485,676,0.01,"|>");
00807 l.DrawLatex(3510,667,"z");
00808 TArrow arphi(3485,511,3037,511,0.01,"|>");
00809 l.DrawLatex(3023,520,"#Phi");
00810 arx.SetLineWidth(3);
00811 ary.SetLineWidth(3);
00812 arz.SetLineWidth(3);
00813 arphi.SetLineWidth(3);
00814 arx.Draw();
00815 ary.Draw();
00816 arz.Draw();
00817 arphi.Draw();
00818 MyC->Update();
00819 if(filetype=="png"){
00820
00821 std::string filename = outputfilename + ".png";
00822 std::cout << "printing " <<filename<< std::endl;
00823 MyC->Print(filename.c_str());
00824 }
00825 if(filetype=="jpg"){
00826 std::string filename = outputfilename + ".jpg";
00827 MyC->Print(filename.c_str());
00828 }
00829 if(filetype=="pdf"){
00830 std::string filename = outputfilename + ".pdf";
00831 MyC->Print(filename.c_str());
00832 }
00833 std::string command = "rm "+tempfilename ;
00834 command1=command.c_str();
00835 std::cout << "Executing " << command1 << std::endl;
00836 system(command1);
00837 MyC->Clear();
00838 delete MyC;
00839 if (printflag)delete axis;
00840 for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
00841 delete (*pos1);}
00842
00843 }
00844
00845
00846 }
00847 void TrackerMap::drawApvPair(int crate, int numfed_incrate, bool print_total, TmApvPair* apvPair,std::ofstream * svgfile,bool useApvPairValue)
00848 {
00849 double xp[4],yp[4];
00850 int color;
00851 int green = 0;
00852 int red = 0;
00853 int blue = 0;
00854 double xd[4],yd[4];
00855 int np = 4;
00856 double boxinitx=0., boxinity=0.;
00857 double dx=.9,dy=.9;
00858 int numfedch_incolumn = 12;
00859 int numfedch_inrow = 8;
00860 int numfed_incolumn = 5;
00861 int numfed_inrow = 4;
00862 boxinitx=boxinitx+(numfed_incolumn-(numfed_incrate-1)/numfed_inrow)*14.;
00863 boxinity=boxinity+(numfed_inrow-(numfed_incrate-1)%numfed_inrow)*9.;
00864 boxinity=boxinity+numfedch_inrow-(apvPair->getFedCh()/numfedch_incolumn);
00865 boxinitx = boxinitx+numfedch_incolumn-(int)(apvPair->getFedCh()%numfedch_incolumn);
00866
00867 xp[0]=boxinitx;yp[0]=boxinity;
00868 xp[1]=boxinitx+dx;yp[1]=boxinity;
00869 xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
00870 xp[3]=boxinitx;yp[3]=boxinity + dy;
00871 for(int j=0;j<4;j++){
00872 xd[j]=xdpixelc(xp[j]);yd[j]=ydpixelc(yp[j]);
00873
00874 }
00875
00876 char buffer [20];
00877 sprintf(buffer,"%X",apvPair->mod->idex);
00878 std::string s = apvPair->mod->name;
00879 s.erase(s.begin()+s.find("connected"),s.end());
00880
00881 if(useApvPairValue){
00882 if(apvPair->red < 0){
00883 if(apvPair->count > 0) {
00884 color = getcolor(apvPair->value,palette);
00885 red=(color>>16)&0xFF;
00886 green=(color>>8)&0xFF;
00887 blue=(color)&0xFF;
00888 if(!print_total)apvPair->value=apvPair->value*apvPair->count;
00889 if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
00890 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=\"";
00891 } else {
00892 if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
00893 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=\"";
00894 }
00895 } else {
00896 if(apvPair->red>255)apvPair->red=255;
00897 if(apvPair->green>255)apvPair->green=255;
00898 if(apvPair->blue>255)apvPair->blue=255;
00899 if(temporary_file)*svgfile << apvPair->red << " " << apvPair->green << " " << apvPair->blue << " ";
00900 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=\"";
00901 }
00902 }else{
00903 if(apvPair->mod->red < 0){
00904 if(apvPair->mod->count > 0) {
00905 color = getcolor(apvPair->mod->value,palette);
00906 red=(color>>16)&0xFF;
00907 green=(color>>8)&0xFF;
00908 blue=(color)&0xFF;
00909 if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
00910 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=\"";
00911 } else {
00912 if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
00913 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=\"";
00914 }
00915 } else {
00916 if(apvPair->mod->red>255)apvPair->mod->red=255;
00917 if(apvPair->mod->green>255)apvPair->mod->green=255;
00918 if(apvPair->mod->blue>255)apvPair->mod->blue=255;
00919 if(temporary_file)*svgfile << apvPair->mod->red << " " << apvPair->mod->green << " " << apvPair->mod->blue << " ";
00920 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=\"";
00921 }
00922 }
00923 if(temporary_file)*svgfile << np << " ";
00924 for(int k=0;k<np;k++){
00925 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
00926 else *svgfile << xd[k] << "," << yd[k] << " " ;
00927 }
00928 if(temporary_file)*svgfile << std::endl;
00929 else *svgfile <<"\" />" <<std::endl;
00930 }
00931 void TrackerMap::drawCcu(int crate, int numfec_incrate, bool print_total, TmCcu* ccu,std::ofstream * svgfile,bool useCcuValue)
00932 {
00933 double xp[4],yp[4];
00934 int color;
00935 int green = 0;
00936 int red = 0;
00937 int blue = 0;
00938 double xd[4],yd[4];
00939 int np = 4;
00940 double boxinitx=0., boxinity=0.;
00941 double dx=.9,dy=.9;
00942 int numccu_incolumn = 8;
00943 int numccu_inrow = 15;
00944 int numfed_incolumn = 5;
00945 int numfed_inrow = 4;
00946 boxinitx=boxinitx+(numfed_incolumn-(numfec_incrate-1)/numfed_inrow)*14.;
00947 boxinity=boxinity+(numfed_inrow-(numfec_incrate-1)%numfed_inrow)*16.;
00948 boxinity=boxinity+numccu_inrow-ccu->mpos;
00949 boxinitx = boxinitx+numccu_incolumn-(int)(ccu->getCcuRing()%numccu_incolumn);
00950
00951 xp[0]=boxinitx;yp[0]=boxinity;
00952 xp[1]=boxinitx+dx;yp[1]=boxinity;
00953 xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
00954 xp[3]=boxinitx;yp[3]=boxinity + dy;
00955 for(int j=0;j<4;j++){
00956 xd[j]=xdpixelfec(xp[j]);yd[j]=ydpixelfec(yp[j]);
00957
00958 }
00959
00960 char buffer [20];
00961 sprintf(buffer,"%X",ccu->idex);
00962
00963
00964 std::string s = ccu->text;
00965 s.erase(s.begin()+s.find("connected"),s.end());
00966
00967 if(ccu->red < 0){
00968 if(ccu->count > 0) {
00969 color = getcolor(ccu->value,palette);
00970 red=(color>>16)&0xFF;
00971 green=(color>>8)&0xFF;
00972 blue=(color)&0xFF;
00973 if(!print_total)ccu->value=ccu->value*ccu->count;
00974 if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
00975 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=\"";
00976 } else {
00977 if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
00978 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=\"";
00979 }
00980 } else {
00981 if(ccu->red>255)ccu->red=255;
00982 if(ccu->green>255)ccu->green=255;
00983 if(ccu->blue>255)ccu->blue=255;
00984 if(temporary_file)*svgfile << ccu->red << " " << ccu->green << " " << ccu->blue << " ";
00985 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=\"";
00986 }
00987 if(temporary_file)*svgfile << np << " ";
00988 for(int k=0;k<np;k++){
00989 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
00990 else *svgfile << xd[k] << "," << yd[k] << " " ;
00991 }
00992 if(temporary_file)*svgfile << std::endl;
00993 else *svgfile <<"\" />" <<std::endl;
00994
00995 }
00996 void TrackerMap::drawPsu(int rack,int numcrate_inrack , bool print_total, TmPsu* psu,std::ofstream * svgfile,bool usePsuValue)
00997 {
00998 double xp[4],yp[4];
00999 int color;
01000 int green = 0;
01001 int red = 0;
01002 int blue = 0;
01003 double xd[4],yd[4];
01004 int np = 4;
01005 double boxinitx=35, boxinity=12;
01006 double dx=3,dy=1.3;
01007
01008 boxinitx= boxinitx+(5 - numcrate_inrack)*5;
01009 boxinity= boxinity+(18 - psu->getPsuBoard())*1.75;
01010
01011 xp[0]=boxinitx;yp[0]=boxinity;
01012 xp[1]=boxinitx+dx;yp[1]=boxinity;
01013 xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
01014 xp[3]=boxinitx;yp[3]=boxinity + dy;
01015
01016
01017 for(int j=0;j<4;j++){
01018 xd[j]=xdpixelpsu(xp[j]);yd[j]=ydpixelpsu(yp[j]);
01019
01020 }
01021
01022 char buffer [20];
01023 sprintf(buffer,"%X",psu->idex);
01024 std::string s = psu->text;
01025 s.erase(s.begin()+s.find("connected"),s.end());
01026
01027 if(psu->red < 0){
01028 if(psu->value > 0){
01029 color = getcolor(psu->value,palette);
01030 red=(color>>16)&0xFF;
01031 green=(color>>8)&0xFF;
01032 blue=(color)&0xFF;
01033 if(!print_total)psu->value=psu->value*psu->count;
01034 if(temporary_file)*svgfile << red << " " << green << " " << blue << " ";
01035 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=\"";
01036 }
01037 else{
01038
01039 if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
01040 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=\"";
01041 }
01042 }
01043
01044 else {
01045 if(psu->red>255)psu->red=255;
01046 if(psu->green>255)psu->green=255;
01047 if(psu->blue>255)psu->blue=255;
01048 if(temporary_file)*svgfile << psu->red << " " << psu->green << " " << psu->blue << " ";
01049 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=\"";
01050 }
01051
01052 if(temporary_file)*svgfile << np << " ";
01053 for(int k=0;k<np;k++){
01054 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
01055 else *svgfile << xd[k] << "," << yd[k] << " " ;
01056 }
01057 if(temporary_file)*svgfile << std::endl;
01058 else *svgfile <<"\" />" <<std::endl;
01059
01060 }
01061
01062 void TrackerMap::drawHV2(int rack,int numcrate_inrack , bool print_total, TmPsu* psu,std::ofstream * svgfile,bool usePsuValue)
01063 {
01064 double xp[4],yp[4];
01065 int color;
01066 int greenHV2 = 0;
01067 int redHV2 = 0;
01068 int blueHV2 = 0;
01069 double xd[4],yd[4];
01070 int np = 4;
01071 double boxinitx=35, boxinity=12;
01072 double dx=1.1,dy=1.3;
01073
01074 boxinitx= boxinitx+(5 - numcrate_inrack)*5;
01075 boxinity= boxinity+(18 - psu->getPsuBoard())*1.75;
01076
01077 xp[0]=boxinitx;yp[0]=boxinity;
01078 xp[1]=boxinitx+dx;yp[1]=boxinity;
01079 xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
01080 xp[3]=boxinitx;yp[3]=boxinity + dy;
01081
01082
01083 for(int j=0;j<4;j++){
01084 xd[j]=xdpixelpsu(xp[j]);yd[j]=ydpixelpsu(yp[j]);
01085
01086 }
01087
01088 char buffer [20];
01089 sprintf(buffer,"%X",psu->idex);
01090 std::string s = psu->textHV2;
01091 s.erase(s.begin()+s.find("connected"),s.end());
01092
01093 if(psu->redHV2 < 0){
01094
01095 if(psu->valueHV2 > 0){
01096 color = getcolor(psu->valueHV2,palette);
01097 redHV2=(color>>16)&0xFF;
01098 greenHV2=(color>>8)&0xFF;
01099 blueHV2=(color)&0xFF;
01100 if(!print_total)psu->valueHV2=psu->valueHV2*psu->countHV2;
01101 if(temporary_file)*svgfile << redHV2 << " " << greenHV2 << " " << blueHV2 << " ";
01102 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=\"";
01103 }
01104 else{
01105 if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
01106 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=\"";
01107 }
01108 }
01109
01110 else {
01111 if(psu->redHV2>255)psu->redHV2=255;
01112 if(psu->greenHV2>255)psu->greenHV2=255;
01113 if(psu->blueHV2>255)psu->blueHV2=255;
01114 if(temporary_file)*svgfile << psu->redHV2 << " " << psu->greenHV2 << " " << psu->blueHV2 << " ";
01115 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=\"";
01116 }
01117
01118 if(temporary_file)*svgfile << np << " ";
01119 for(int k=0;k<np;k++){
01120 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
01121 else *svgfile << xd[k] << "," << yd[k] << " " ;
01122 }
01123 if(temporary_file)*svgfile << std::endl;
01124 else *svgfile <<"\" />" <<std::endl;
01125
01126 }
01127
01128
01129 void TrackerMap::drawHV3(int rack,int numcrate_inrack , bool print_total, TmPsu* psu,std::ofstream * svgfile,bool usePsuValue)
01130 {
01131 double xp[4],yp[4];
01132 int color;
01133 int greenHV3 = 0;
01134 int redHV3 = 0;
01135 int blueHV3 = 0;
01136 double xd[4],yd[4];
01137 int np = 4;
01138 double boxinitx=36.5, boxinity=12;
01139 double dx=1.1,dy=1.3;
01140
01141 boxinitx= boxinitx+(5 - numcrate_inrack)*5;
01142 boxinity= boxinity+(18 - psu->getPsuBoard())*1.75;
01143
01144 xp[0]=boxinitx;yp[0]=boxinity;
01145 xp[1]=boxinitx+dx;yp[1]=boxinity;
01146 xp[2]=boxinitx+dx;yp[2]=boxinity + dy;
01147 xp[3]=boxinitx;yp[3]=boxinity + dy;
01148
01149
01150 for(int j=0;j<4;j++){
01151 xd[j]=xdpixelpsu(xp[j]);yd[j]=ydpixelpsu(yp[j]);
01152
01153 }
01154
01155 char buffer [20];
01156 sprintf(buffer,"%X",psu->idex);
01157 std::string s = psu->textHV3;
01158 s.erase(s.begin()+s.find("connected"),s.end());
01159
01160 if(psu->redHV3 < 0){
01161 if(psu->valueHV3 > 0){
01162 color = getcolor(psu->valueHV3,palette);
01163 redHV3=(color>>16)&0xFF;
01164 greenHV3=(color>>8)&0xFF;
01165 blueHV3=(color)&0xFF;
01166 if(!print_total)psu->valueHV3=psu->valueHV3*psu->countHV3;
01167 if(temporary_file)*svgfile << redHV3 << " " << greenHV3 << " " << blueHV3 << " ";
01168 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=\"";
01169 }
01170 else{
01171 if(temporary_file)*svgfile << 255 << " " << 255 << " " << 255 << " ";
01172 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=\"";
01173 }
01174 }
01175
01176 else {
01177 if(psu->redHV3>255)psu->redHV3=255;
01178 if(psu->greenHV3>255)psu->greenHV3=255;
01179 if(psu->blueHV3>255)psu->blueHV3=255;
01180 if(temporary_file)*svgfile << psu->redHV3 << " " << psu->greenHV3 << " " << psu->blueHV3 << " ";
01181 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=\"";
01182 }
01183
01184 if(temporary_file)*svgfile << np << " ";
01185 for(int k=0;k<np;k++){
01186 if(temporary_file)*svgfile << xd[k] << " " << yd[k] << " " ;
01187 else *svgfile << xd[k] << "," << yd[k] << " " ;
01188 }
01189 if(temporary_file)*svgfile << std::endl;
01190 else *svgfile <<"\" />" <<std::endl;
01191
01192 }
01193
01194 void TrackerMap::save_as_fectrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
01195 if(enableFecProcessing){
01196 std::string filetype=s,outputfilename=s;
01197 std::vector<TPolyLine*> vp;
01198 size_t found=filetype.find_last_of(".");
01199 filetype=filetype.substr(found+1);
01200 found=outputfilename.find_last_of(".");
01201 outputfilename=outputfilename.substr(0,found);
01202 temporary_file=true;
01203 if(filetype=="xml"||filetype=="svg")temporary_file=false;
01204 std::ostringstream outs;
01205 minvalue=minval; maxvalue=maxval;
01206 outs << outputfilename << ".coor";
01207 if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01208 std::map<int , TmCcu *>::iterator i_ccu;
01209 std::multimap<TmCcu*, TmModule*>::iterator it;
01210 std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
01211
01212 bool useCcuValue=false;
01213
01214
01215 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01216 TmCcu * ccu= i_ccu->second;
01217 if(ccu!=0) {
01218 if(ccu->count > 0 || ccu->red!=-1) { useCcuValue=true; break;}
01219 }
01220 }
01221
01222
01223 if(!useCcuValue)
01224 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01225 TmCcu * ccu= i_ccu->second;
01226 if(ccu!=0) {
01227 ret = fecModuleMap.equal_range(ccu);
01228 for (it = ret.first; it != ret.second; ++it)
01229 {
01230 if( (*it).second->count>0){ccu->value=ccu->value+(*it).second->value;ccu->count++;}
01231 }
01232 if(ccu->count>0)ccu->value=ccu->value/ccu->count;
01233 if(ccu->nmod==0) { ccu->red=0;ccu->green=0;ccu->blue=0;}
01234 }
01235 }
01236
01237
01238 if(title==" Tracker Map from QTestAlarm"){
01239 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01240 TmCcu * ccu= i_ccu->second;
01241 if(ccu!=0) {
01242 ret = fecModuleMap.equal_range(ccu);
01243 ccu->red=0;ccu->green=255;ccu->blue=0;
01244 for (it = ret.first; it != ret.second; ++it) {
01245 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 ) ){
01246 ccu->red=255;ccu->green=0;ccu->blue=0;
01247 }
01248 }
01249 }
01250 }
01251 }
01252
01253
01254
01255 if(!print_total){
01256 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01257 TmCcu * ccu= i_ccu->second;
01258 if(ccu!=0) {
01259 if(useCcuValue) ccu->value = ccu->value / ccu->count;
01260
01261 }
01262 }
01263 }
01264
01265 if(minvalue>=maxvalue){
01266
01267 minvalue=9999999.;
01268 maxvalue=-9999999.;
01269 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01270 TmCcu * ccu= i_ccu->second;
01271 if(ccu!=0) {
01272 if (minvalue > ccu->value)minvalue=ccu->value;
01273 if (maxvalue < ccu->value)maxvalue=ccu->value;
01274 }
01275 }
01276 }
01277
01278
01279
01280 if(filetype=="svg"){
01281 saveAsSingleLayer=false;
01282 std::ostringstream outs;
01283 outs << outputfilename<<".svg";
01284 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01285 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
01286 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
01287 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
01288 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
01289 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
01290 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
01291 *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
01292 }
01293 for (int crate=1; crate < (nfeccrates+1); crate++){
01294 if(filetype=="xml"){
01295 saveAsSingleLayer=true;
01296 std::ostringstream outs;
01297 outs << outputfilename<<"feccrate" <<crate<< ".xml";
01298 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01299 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
01300 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
01301 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
01302 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
01303 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"feccrate.js\" />"<<std::endl;
01304 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<std::endl;
01305 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
01306 *savefile << "<g id=\"crate\" transform=\" translate(280,580) rotate(270) scale(.7,.8)\" > "<<std::endl;
01307 }
01308 ncrate=crate;
01309 deffecwindow(ncrate);
01310
01311 for ( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01312 TmCcu * ccu= i_ccu->second;
01313 if(ccu!=0){
01314 if(ccu->getCcuCrate() == crate){
01315
01316 drawCcu(crate,ccu->getCcuSlot()-2,print_total,ccu,savefile,useCcuValue);
01317 }
01318 }
01319 }
01320
01321 if(!temporary_file){
01322 if(filetype=="xml"){
01323 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
01324 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
01325 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
01326 *savefile << " </text> </svg>" << std::endl;
01327 savefile->close();
01328 saveAsSingleLayer=false;
01329 }
01330 }
01331 }
01332 if(filetype=="svg"){
01333 *savefile << "</g> </svg> </svg> " << std::endl;
01334 savefile->close();
01335 }
01336 if(!print_total && !useCcuValue){
01337
01338 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
01339 TmCcu * ccu= i_ccu->second;
01340 if(ccu!=0) {
01341 ccu->value = ccu->value * ccu->count;
01342 }
01343 }
01344 }
01345 if(temporary_file){
01346
01347 savefile->close();
01348
01349 const char * command1;
01350 std::string tempfilename = outputfilename + ".coor";
01351 int red,green,blue,npoints,colindex,ncolor;
01352 double x[4],y[4];
01353 ifstream tempfile(tempfilename.c_str(),std::ios::in);
01354 TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
01355 gPad->SetFillColor(38);
01356
01357 gPad->Range(0,0,3700,1600);
01358
01359
01360 ncolor=0;
01361 typedef std::map<int,int> ColorList;
01362 ColorList colorList;
01363 ColorList::iterator pos;
01364 TColor *col,*c;
01365 while(!tempfile.eof()) {
01366 tempfile >> red >> green >> blue >> npoints;
01367 colindex=red+green*1000+blue*1000000;
01368 pos=colorList.find(colindex);
01369 if(pos == colorList.end()){
01370 colorList[colindex]=ncolor+100;
01371 col =gROOT->GetColor(ncolor+100);
01372 if(col)
01373 col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
01374 else
01375 c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
01376 vc.push_back(c);
01377 ncolor++;
01378 }
01379 for (int i=0;i<npoints;i++){
01380 tempfile >> x[i] >> y[i];
01381 }
01382 }
01383 if(ncolor>0 && ncolor<10000){
01384 Int_t colors[10000];
01385 for(int i=0;i<ncolor;i++){colors[i]=i+100;}
01386 gStyle->SetPalette(ncolor,colors);
01387 }
01388 tempfile.clear();
01389 tempfile.seekg(0,std::ios::beg);
01390 std::cout << "created palette with " << ncolor << " colors" << std::endl;
01391 while(!tempfile.eof()) {
01392 tempfile >> red >> green >> blue >> npoints;
01393 for (int i=0;i<npoints;i++){
01394 tempfile >> x[i] >> y[i];
01395 }
01396 colindex=red+green*1000+blue*1000000;
01397 pos=colorList.find(colindex);
01398 if(pos != colorList.end()){
01399 TPolyLine* pline = new TPolyLine(npoints,y,x);
01400 vp.push_back(pline);
01401 pline->SetFillColor(colorList[colindex]);
01402 pline->SetLineWidth(0);
01403 pline->Draw("f");
01404 }
01405 }
01406 MyC->Update();
01407 std::cout << "Filetype " << filetype << std::endl;
01408 if(filetype=="png"){
01409 std::string filename = outputfilename + ".png";
01410 MyC->Print(filename.c_str());
01411 }
01412 if(filetype=="jpg"){
01413 std::string filename = outputfilename + ".jpg";
01414 MyC->Print(filename.c_str());
01415 }
01416 if(filetype=="pdf"){
01417 std::string filename = outputfilename + ".pdf";
01418 MyC->Print(filename.c_str());
01419 }
01420 std::string command = "rm "+tempfilename ;
01421 command1=command.c_str();
01422 std::cout << "Executing " << command1 << std::endl;
01423 system(command1);
01424 MyC->Clear();
01425 delete MyC;
01426 for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
01427 delete (*pos1);}
01428
01429
01430
01431
01432 }
01433 }
01434 }
01435 void TrackerMap::save_as_HVtrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
01436
01437 if(enableHVProcessing){
01438 std::string filetype=s,outputfilename=s;
01439 std::vector<TPolyLine*> vp;
01440
01441 size_t found=filetype.find_last_of(".");
01442 filetype=filetype.substr(found+1);
01443 found=outputfilename.find_last_of(".");
01444 outputfilename=outputfilename.substr(0,found);
01445
01446 temporary_file=true;
01447
01448
01449 if(filetype=="xml"||filetype=="svg")temporary_file=false;
01450
01451 std::ostringstream outs;
01452 minvalue=minval; maxvalue=maxval;
01453 outs << outputfilename << ".coor";
01454 if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01455
01456 std::map<int , TmPsu *>::iterator ipsu;
01457 std::multimap<TmPsu*, TmModule*>::iterator it;
01458 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
01459
01460
01461 bool usePsuValue=false;
01462
01463 for( ipsu=psuMap.begin();ipsu!=psuMap.end(); ipsu++){
01464 TmPsu* psu= ipsu->second;
01465 if(psu!=0) {
01466 if(psu->countHV2 > 0 || psu->redHV2!=-1 || psu->countHV3 > 0 || psu->redHV3!=-1) { usePsuValue=true; break;}
01467 }
01468 }
01469
01470 if(!usePsuValue){
01471
01472 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01473 TmPsu * psu= ipsu->second;
01474 if(psu!=0) {
01475 ret = psuModuleMap.equal_range(psu);
01476 for(it = ret.first; it != ret.second; ++it){
01477 if((*it).second->HVchannel==2){ psu->valueHV2=psu->valueHV2+(*it).second->value;}
01478 if((*it).second->HVchannel==3){ psu->valueHV3=psu->valueHV3+(*it).second->value;}
01479 }
01480 if(psu->nmodHV2!=0){psu->valueHV2=psu->valueHV2/psu->nmodHV2;}
01481 if(psu->nmodHV3!=0){psu->valueHV3=psu->valueHV3/psu->nmodHV3;}
01482 psu->countHV2=1;
01483 psu->countHV3=1;
01484
01485 }
01486
01487 }
01488 }
01489
01490 if(title==" Tracker Map from QTestAlarm"){
01491 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01492 TmPsu * psu= ipsu->second;
01493 if(psu!=0) {
01494 ret = psuModuleMap.equal_range(psu);
01495 psu->redHV2=0;psu->greenHV2=255;psu->blueHV2=0;
01496 psu->redHV3=0;psu->greenHV3=255;psu->blueHV3=0;
01497 for (it = ret.first; it != ret.second; ++it) {
01498 if((*it).second->HVchannel==2){
01499 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 ) ){
01500 psu->redHV2=255;psu->greenHV2=0;psu->blueHV2=0;
01501 }
01502 }
01503 if((*it).second->HVchannel==3){
01504 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 ) ){
01505 psu->redHV3=255;psu->greenHV3=0;psu->blueHV3=0;
01506 }
01507 }
01508 }
01509 }
01510 }
01511 }
01512
01513 if(!print_total){
01514 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01515 TmPsu * psu= ipsu->second;
01516 if(psu!=0) {
01517 if(usePsuValue){
01518 psu->valueHV2 = psu->valueHV2 / psu->countHV2;
01519 psu->valueHV3 = psu->valueHV3 / psu->countHV3;
01520 }
01521 }
01522 }
01523 }
01524
01525 if(minvalue>=maxvalue){
01526
01527 minvalue=9999999.;
01528 maxvalue=-9999999.;
01529
01530 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01531 TmPsu * psu= ipsu->second;
01532 if(psu!=0) {
01533 if (minvalue > psu->valueHV2 || minvalue > psu->valueHV3)minvalue=std::min(psu->valueHV2,psu->valueHV3);
01534 if (maxvalue < psu->valueHV2 || maxvalue < psu->valueHV3)maxvalue=std::max(psu->valueHV2,psu->valueHV3);
01535
01536
01537 }
01538 }
01539 }
01540
01541 if(filetype=="svg"){
01542 saveAsSingleLayer=false;
01543 std::ostringstream outs;
01544 outs << outputfilename<<".svg";
01545 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01546 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
01547 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
01548 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
01549 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
01550 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
01551 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
01552 *savefile << "<svg:g id=\"HVtrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
01553 }
01554
01555 for (int irack=1; irack < (npsuracks+1); irack++){
01556 if(filetype=="xml"){
01557 saveAsSingleLayer=true;
01558 std::ostringstream outs;
01559 outs << outputfilename<<"HVrack" <<irack<< ".xml";
01560 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01561 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
01562 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
01563 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
01564 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
01565 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rackhv.js\" />"<<std::endl;
01566 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerRackhv.init()\">"<<std::endl;
01567 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
01568 *savefile << "<g id=\"rackhv\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > "<<std::endl;
01569 }
01570
01571 nrack=irack;
01572 defpsuwindow(nrack);
01573 for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01574 TmPsu * psu= ipsu->second;
01575 if(psu->getPsuRack() == irack){
01576 drawHV2(irack,psu->getPsuCrate(),print_total,psu,savefile,usePsuValue);
01577 drawHV3(irack,psu->getPsuCrate(),print_total,psu,savefile,usePsuValue);
01578 }
01579 }
01580
01581
01582 if(!temporary_file){
01583 if(filetype=="xml"){
01584 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
01585 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
01586 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
01587 *savefile << " </text> </svg>" << std::endl;
01588 savefile->close();
01589 saveAsSingleLayer=false;
01590 }
01591 }
01592 }
01593 if(filetype=="svg"){
01594 *savefile << "</g> </svg> </svg> " << std::endl;
01595 savefile->close();
01596 }
01597
01598
01599 if(!print_total && !usePsuValue){
01600 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01601 TmPsu *psu = ipsu->second;
01602 if(psu!=0) {
01603 psu->valueHV2 = psu->valueHV2 * psu->countHV2;
01604 psu->valueHV3 = psu->valueHV3 * psu->countHV3;
01605 }
01606 }
01607 }
01608
01609
01610 if(temporary_file){
01611
01612 savefile->close();
01613
01614 const char * command1;
01615 std::string tempfilename = outputfilename + ".coor";
01616 int red,green,blue,npoints,colindex,ncolor;
01617 double x[4],y[4];
01618 ifstream tempfile(tempfilename.c_str(),std::ios::in);
01619 TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
01620 gPad->SetFillColor(38);
01621
01622 gPad->Range(0,0,3700,1600);
01623
01624
01625 ncolor=0;
01626 typedef std::map<int,int> ColorList;
01627 ColorList colorList;
01628 ColorList::iterator pos;
01629 TColor *col,*c;
01630 while(!tempfile.eof()) {
01631 tempfile >> red >> green >> blue >> npoints;
01632 colindex=red+green*1000+blue*1000000;
01633 pos=colorList.find(colindex);
01634 if(pos == colorList.end()){
01635 colorList[colindex]=ncolor+100;
01636 col =gROOT->GetColor(ncolor+100);
01637 if(col)
01638 col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
01639 else
01640 c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
01641 vc.push_back(c);
01642 ncolor++;
01643 }
01644 for (int i=0;i<npoints;i++){
01645 tempfile >> x[i] >> y[i];
01646 }
01647 }
01648 if(ncolor>0 && ncolor<10000){
01649 Int_t colors[10000];
01650 for(int i=0;i<ncolor;i++){colors[i]=i+100;}
01651 gStyle->SetPalette(ncolor,colors);
01652 }
01653 tempfile.clear();
01654 tempfile.seekg(0,std::ios::beg);
01655 std::cout << "created palette with " << ncolor << " colors" << std::endl;
01656 while(!tempfile.eof()) {
01657 tempfile >> red >> green >> blue >> npoints;
01658 for (int i=0;i<npoints;i++){
01659 tempfile >> x[i] >> y[i];
01660 }
01661 colindex=red+green*1000+blue*1000000;
01662 pos=colorList.find(colindex);
01663 if(pos != colorList.end()){
01664 TPolyLine* pline = new TPolyLine(npoints,y,x);
01665 vp.push_back(pline);
01666 pline->SetFillColor(colorList[colindex]);
01667 pline->SetLineWidth(0);
01668 pline->Draw("f");
01669 }
01670 }
01671 MyC->Update();
01672 std::cout << "Filetype " << filetype << std::endl;
01673 if(filetype=="png"){
01674 std::string filename = outputfilename + ".png";
01675 MyC->Print(filename.c_str());
01676 }
01677 if(filetype=="jpg"){
01678 std::string filename = outputfilename + ".jpg";
01679 MyC->Print(filename.c_str());
01680 }
01681 if(filetype=="pdf"){
01682 std::string filename = outputfilename + ".pdf";
01683 MyC->Print(filename.c_str());
01684 }
01685 std::string command = "rm "+tempfilename ;
01686 command1=command.c_str();
01687 std::cout << "Executing " << command1 << std::endl;
01688 system(command1);
01689 MyC->Clear();
01690 delete MyC;
01691 for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
01692 delete (*pos1);}
01693
01694
01695 }
01696 }
01697 }
01698
01699
01700 void TrackerMap::save_as_psutrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
01701
01702 if(enableLVProcessing){
01703
01704 std::string filetype=s,outputfilename=s;
01705 std::vector<TPolyLine*> vp;
01706
01707 size_t found=filetype.find_last_of(".");
01708 filetype=filetype.substr(found+1);
01709 found=outputfilename.find_last_of(".");
01710 outputfilename=outputfilename.substr(0,found);
01711
01712 temporary_file=true;
01713
01714
01715
01716 if(filetype=="xml"||filetype=="svg")temporary_file=false;
01717
01718 std::ostringstream outs;
01719 minvalue=minval; maxvalue=maxval;
01720 outs << outputfilename << ".coor";
01721 if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01722
01723 std::map<int , TmPsu *>::iterator ipsu;
01724 std::multimap<TmPsu*, TmModule*>::iterator it;
01725 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
01726
01727
01728 bool usePsuValue=false;
01729
01730 for( ipsu=psuMap.begin();ipsu!=psuMap.end(); ipsu++){
01731 TmPsu* psu= ipsu->second;
01732 if(psu!=0) {
01733 if(psu->count > 0 || psu->red!=-1) { usePsuValue=true; break;}
01734 }
01735 }
01736
01737 if(!usePsuValue){
01738 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01739 TmPsu * psu= ipsu->second;
01740 if(psu!=0) {
01741 ret = psuModuleMap.equal_range(psu);
01742 for(it = ret.first; it != ret.second; ++it){
01743 psu->value=psu->value+(*it).second->value;
01744
01745 }
01746 psu->value=psu->value/psu->nmod;
01747 psu->count=1;
01748
01749 }
01750 }
01751 }
01752
01753 if(title==" Tracker Map from QTestAlarm"){
01754 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01755 TmPsu * psu= ipsu->second;
01756 if(psu!=0) {
01757 ret = psuModuleMap.equal_range(psu);
01758 psu->red=0;psu->green=255;psu->blue=0;
01759 for (it = ret.first; it != ret.second; ++it) {
01760 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 ) ){
01761 psu->red=255;psu->green=0;psu->blue=0;
01762 }
01763 }
01764 }
01765 }
01766 }
01767
01768
01769
01770 if(!print_total){
01771 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01772 TmPsu * psu= ipsu->second;
01773 if(psu!=0) {
01774 if(usePsuValue) psu->value = psu->value / psu->count;
01775
01776 }
01777 }
01778 }
01779
01780 if(minvalue>=maxvalue){
01781
01782 minvalue=9999999.;
01783 maxvalue=-9999999.;
01784 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01785 TmPsu * psu= ipsu->second;
01786 if(psu!=0) {
01787 if (minvalue > psu->value)minvalue=psu->value;
01788 if (maxvalue < psu->value)maxvalue=psu->value;
01789 }
01790 }
01791 }
01792
01793 if(filetype=="svg"){
01794 saveAsSingleLayer=false;
01795 std::ostringstream outs;
01796 outs << outputfilename<<".svg";
01797 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01798 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
01799 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
01800 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
01801 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
01802 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
01803 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
01804 *savefile << "<svg:g id=\"psutrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
01805 }
01806
01807 for (int irack=1; irack < (npsuracks+1); irack++){
01808 if(filetype=="xml"){
01809 saveAsSingleLayer=true;
01810 outs << outputfilename<<"psurack" <<irack<< ".xml";
01811 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01812 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
01813 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
01814 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
01815 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
01816 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"rack.js\" />"<<std::endl;
01817 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<std::endl;
01818 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
01819 *savefile << "<g id=\"rack\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > "<<std::endl;
01820 }
01821
01822
01823 nrack=irack;
01824 defpsuwindow(nrack);
01825 for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01826 TmPsu * psu= ipsu->second;
01827 if(psu->getPsuRack() == irack){
01828
01829 drawPsu(irack,psu->getPsuCrate(),print_total,psu,savefile,usePsuValue);
01830 }
01831 }
01832
01833
01834 if(!temporary_file){
01835 if(filetype=="xml"){
01836 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
01837 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
01838 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
01839 *savefile << " </text> </svg>" << std::endl;
01840 savefile->close();
01841 saveAsSingleLayer=false;
01842 }
01843 }
01844 }
01845 if(filetype=="svg"){
01846 *savefile << "</g> </svg> </svg> " << std::endl;
01847 savefile->close();
01848 }
01849
01850
01851 if(!print_total && !usePsuValue){
01852 for( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
01853 TmPsu *psu = ipsu->second;
01854 if(psu!=0) {
01855 psu->value = psu->value * psu->count;
01856 }
01857 }
01858 }
01859
01860
01861 if(temporary_file){
01862
01863 savefile->close();
01864
01865 const char * command1;
01866 std::string tempfilename = outputfilename + ".coor";
01867 int red,green,blue,npoints,colindex,ncolor;
01868 double x[4],y[4];
01869 ifstream tempfile(tempfilename.c_str(),std::ios::in);
01870 TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
01871 gPad->SetFillColor(38);
01872
01873 gPad->Range(0,0,3700,1600);
01874
01875
01876 ncolor=0;
01877 typedef std::map<int,int> ColorList;
01878 ColorList colorList;
01879 ColorList::iterator pos;
01880 TColor *col,*c;
01881 while(!tempfile.eof()) {
01882 tempfile >> red >> green >> blue >> npoints;
01883 colindex=red+green*1000+blue*1000000;
01884 pos=colorList.find(colindex);
01885 if(pos == colorList.end()){
01886 colorList[colindex]=ncolor+100;
01887 col =gROOT->GetColor(ncolor+100);
01888 if(col)
01889 col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
01890 else
01891 c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
01892 vc.push_back(c);
01893 ncolor++;
01894 }
01895 for (int i=0;i<npoints;i++){
01896 tempfile >> x[i] >> y[i];
01897 }
01898 }
01899 if(ncolor>0 && ncolor<10000){
01900 Int_t colors[10000];
01901 for(int i=0;i<ncolor;i++){colors[i]=i+100;}
01902 gStyle->SetPalette(ncolor,colors);
01903 }
01904 tempfile.clear();
01905 tempfile.seekg(0,std::ios::beg);
01906 std::cout << "created palette with " << ncolor << " colors" << std::endl;
01907 while(!tempfile.eof()) {
01908 tempfile >> red >> green >> blue >> npoints;
01909 for (int i=0;i<npoints;i++){
01910 tempfile >> x[i] >> y[i];
01911 }
01912 colindex=red+green*1000+blue*1000000;
01913 pos=colorList.find(colindex);
01914 if(pos != colorList.end()){
01915 TPolyLine* pline = new TPolyLine(npoints,y,x);
01916 vp.push_back(pline);
01917 pline->SetFillColor(colorList[colindex]);
01918 pline->SetLineWidth(0);
01919 pline->Draw("f");
01920 }
01921 }
01922 MyC->Update();
01923 std::cout << "Filetype " << filetype << std::endl;
01924 if(filetype=="png"){
01925 std::string filename = outputfilename + ".png";
01926 MyC->Print(filename.c_str());
01927 }
01928 if(filetype=="jpg"){
01929 std::string filename = outputfilename + ".jpg";
01930 MyC->Print(filename.c_str());
01931 }
01932 if(filetype=="pdf"){
01933 std::string filename = outputfilename + ".pdf";
01934 MyC->Print(filename.c_str());
01935 }
01936 std::string command = "rm "+tempfilename ;
01937 command1=command.c_str();
01938 std::cout << "Executing " << command1 << std::endl;
01939 system(command1);
01940 MyC->Clear();
01941 delete MyC;
01942 for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
01943 delete (*pos1);}
01944
01945 }
01946 }
01947 }
01948
01949 void TrackerMap::save_as_fedtrackermap(bool print_total,float minval, float maxval,std::string s,int width, int height){
01950 if(enableFedProcessing){
01951 std::string filetype=s,outputfilename=s;
01952 std::vector<TPolyLine*> vp;
01953
01954 size_t found=filetype.find_last_of(".");
01955 filetype=filetype.substr(found+1);
01956 found=outputfilename.find_last_of(".");
01957 outputfilename=outputfilename.substr(0,found);
01958
01959 temporary_file=true;
01960 if(filetype=="xml"||filetype=="svg")temporary_file=false;
01961 std::ostringstream outs;
01962 minvalue=minval; maxvalue=maxval;
01963 outs << outputfilename << ".coor";
01964 if(temporary_file)savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
01965 std::map<int , TmApvPair *>::iterator i_apv;
01966 std::map<int , int>::iterator i_fed;
01967
01968 bool useApvPairValue=false;
01969 for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
01970 TmApvPair * apvPair= i_apv->second;
01971 if(apvPair!=0) {
01972 TmModule * apv_mod = apvPair->mod;
01973 if(apv_mod !=0 && !apv_mod->notInUse()){
01974 if(apvPair->count > 0 || apvPair->red!=-1) { useApvPairValue=true; break;}
01975 }
01976 }
01977 }
01978 if(!print_total){
01979 for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
01980 TmApvPair * apvPair= i_apv->second;
01981 if(apvPair!=0) {
01982 TmModule * apv_mod = apvPair->mod;
01983 if(apv_mod !=0 && !apv_mod->notInUse()){
01984 if(useApvPairValue) apvPair->value = apvPair->value / apvPair->count;
01985 else if(apvPair->mpos==0)apv_mod->value = apv_mod->value / apv_mod->count;
01986 }
01987 }
01988 }
01989 }
01990 if(minvalue>=maxvalue){
01991
01992 minvalue=9999999.;
01993 maxvalue=-9999999.;
01994 for(i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
01995 TmApvPair * apvPair= i_apv->second;
01996 if(apvPair!=0) {
01997 TmModule * apv_mod = apvPair->mod;
01998 if( apv_mod !=0 && !apv_mod->notInUse()){
01999 if(useApvPairValue){
02000 if (minvalue > apvPair->value)minvalue=apvPair->value;
02001 if (maxvalue < apvPair->value)maxvalue=apvPair->value;
02002 } else {
02003 if (minvalue > apv_mod->value)minvalue=apv_mod->value;
02004 if (maxvalue < apv_mod->value)maxvalue=apv_mod->value;
02005 }
02006 }
02007 }
02008 }
02009 }
02010 if(filetype=="svg"){
02011 saveAsSingleLayer=false;
02012 std::ostringstream outs;
02013 outs << outputfilename<<".svg";
02014 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
02015 *savefile << "<?xml version=\"1.0\" standalone=\"no\" ?>"<<std::endl;
02016 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
02017 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\" "<<std::endl;
02018 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\">"<<std::endl;
02019 *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<std::endl;
02020 *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<std::endl;
02021 *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<std::endl;
02022 }
02023 for (int crate=1; crate < (ncrates+1); crate++){
02024 if(filetype=="xml"){
02025 saveAsSingleLayer=true;
02026 std::ostringstream outs;
02027 outs << outputfilename<<"crate" <<crate<< ".xml";
02028 savefile = new std::ofstream(outs.str().c_str(),std::ios::out);
02029 *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
02030 *savefile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
02031 *savefile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
02032 *savefile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
02033 *savefile << "<script type=\"text/ecmascript\" xlink:href=\"crate.js\" />"<<std::endl;
02034 *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<std::endl;
02035 *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
02036 *savefile << "<g id=\"crate\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\" > "<<std::endl;
02037 }
02038 ncrate=crate;
02039 defcwindow(ncrate);
02040 int numfed_incrate=0;
02041 for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
02042 if(i_fed->second == crate){
02043 int fedId = i_fed->first;
02044 numfed_incrate++;
02045 for (int nconn=0;nconn<96;nconn++){
02046 int key = fedId*1000+nconn;
02047 TmApvPair * apvPair= apvMap[key];
02048 if(apvPair !=0){
02049 TmModule * apv_mod = apvPair->mod;
02050 if(apv_mod !=0 && !apv_mod->notInUse()){
02051 drawApvPair(crate,numfed_incrate,print_total,apvPair,savefile,useApvPairValue);
02052 }
02053 }
02054 }
02055 }
02056 }
02057 if(!temporary_file){
02058 if(filetype=="xml"){
02059 *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << std::endl;
02060 *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
02061 *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
02062 *savefile << " </text> </svg>" << std::endl;
02063 savefile->close();delete savefile;
02064 saveAsSingleLayer=false;
02065 }
02066 }
02067 }
02068 if(filetype=="svg"){
02069 *savefile << "</g> </svg> </svg> " << std::endl;
02070 savefile->close();delete savefile;
02071 }
02072 if(!print_total && !useApvPairValue){
02073
02074 for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
02075 TmApvPair * apvPair= i_apv->second;
02076 if(apvPair!=0) {
02077 TmModule * apv_mod = apvPair->mod;
02078 if(apv_mod !=0 && apvPair->mpos==0 && !apv_mod->notInUse()){
02079 apv_mod->value = apv_mod->value * apv_mod->count;
02080 }
02081 }
02082 }
02083 }
02084
02085 if(temporary_file){
02086
02087 savefile->close(); delete savefile;
02088
02089 const char * command1;
02090 std::string tempfilename = outputfilename + ".coor";
02091 int red,green,blue,npoints,colindex,ncolor;
02092 double x[4],y[4];
02093 ifstream tempfile(tempfilename.c_str(),std::ios::in);
02094 TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
02095 gPad->SetFillColor(38);
02096
02097 gPad->Range(0,0,3750,1600);
02098
02099
02100 ncolor=0;
02101 typedef std::map<int,int> ColorList;
02102 ColorList colorList;
02103 ColorList::iterator pos;
02104 TColor *col,*c;
02105 while(!tempfile.eof()) {
02106 tempfile >> red >> green >> blue >> npoints;
02107 colindex=red+green*1000+blue*1000000;
02108 pos=colorList.find(colindex);
02109 if(pos == colorList.end()){
02110 colorList[colindex]=ncolor+100;
02111 col =gROOT->GetColor(ncolor+100);
02112 if(col)
02113 col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
02114 else
02115 c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
02116 vc.push_back(c);
02117 ncolor++;
02118 }
02119 for (int i=0;i<npoints;i++){
02120 tempfile >> x[i] >> y[i];
02121 }
02122 }
02123 if(ncolor>0 && ncolor<10000){
02124 Int_t colors[10000];
02125 for(int i=0;i<ncolor;i++){colors[i]=i+100;}
02126 gStyle->SetPalette(ncolor,colors);
02127 }
02128 tempfile.clear();
02129 tempfile.seekg(0,std::ios::beg);
02130 std::cout << "created palette with " << ncolor << " colors" << std::endl;
02131 while(!tempfile.eof()) {
02132 tempfile >> red >> green >> blue >> npoints;
02133 for (int i=0;i<npoints;i++){
02134 tempfile >> x[i] >> y[i];
02135 }
02136 colindex=red+green*1000+blue*1000000;
02137 pos=colorList.find(colindex);
02138 if(pos != colorList.end()){
02139 TPolyLine* pline = new TPolyLine(npoints,y,x);
02140 vp.push_back(pline);
02141 pline->SetFillColor(colorList[colindex]);
02142 pline->SetLineWidth(0);
02143 pline->Draw("f");
02144 }
02145 }
02146 MyC->Update();
02147 std::cout << "Filetype " << filetype << std::endl;
02148 if(filetype=="png"){
02149 std::string filename = outputfilename + ".png";
02150 MyC->Print(filename.c_str());
02151 }
02152 if(filetype=="jpg"){
02153 std::string filename = outputfilename + ".jpg";
02154 MyC->Print(filename.c_str());
02155 }
02156 if(filetype=="pdf"){
02157 std::string filename = outputfilename + ".pdf";
02158 MyC->Print(filename.c_str());
02159 }
02160 std::string command = "rm "+tempfilename ;
02161 command1=command.c_str();
02162 std::cout << "Executing " << command1 << std::endl;
02163 system(command1);
02164 MyC->Clear();
02165 delete MyC;
02166 for(std::vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
02167 delete (*pos1);}
02168
02169
02170 }
02171 }
02172 }
02173
02174 void TrackerMap::load(std::string inputfilename){
02175 inputfile = new ifstream(inputfilename.c_str(),std::ios::in);
02176 std::string line,value;
02177 int ipos,ipos1,ipos2,id=0,val=0;
02178 int nline=0;
02179 while (getline( *inputfile, line ))
02180 {
02181 ipos1 = line.find("value=\"");
02182 if(ipos1 > 0) {
02183 value = line.substr(ipos1+7,10);
02184 ipos = value.find("\"");
02185 value = value.substr(0,ipos);
02186 val=atoi(value.c_str());
02187 }
02188 ipos2 = line.find("detid=\"");
02189 if(ipos2 > 0) {
02190 value = line.substr(ipos2+7,10);
02191 ipos = value.find("\"");
02192 value = value.substr(0,ipos);
02193 id = atoi(value.c_str());
02194 }
02195 if(ipos1>0 && ipos2>0 && val>0)this->fill(id,val);
02196 if(ipos1>0 && ipos2>0)nline++;
02197
02198
02199 }
02200 std::cout << nline << " modules found in this svg file " << std::endl;
02201 inputfile->close();delete inputfile;
02202 }
02203
02204
02205
02206
02207
02208
02209 void TrackerMap::print(bool print_total, float minval, float maxval, std::string outputfilename){
02210 temporary_file=false;
02211 std::ostringstream outs;
02212 minvalue=minval; maxvalue=maxval;
02213 outs << outputfilename << ".xml";
02214 svgfile = new std::ofstream(outs.str().c_str(),std::ios::out);
02215 jsfile = new ifstream(edm::FileInPath(jsfilename).fullPath().c_str(),std::ios::in);
02216
02217
02218 std::string line;
02219 while (getline( *jsfile, line ))
02220 {
02221 *svgfile << line << std::endl;
02222 }
02223 jsfile->close();delete jsfile;
02224
02225 if(!print_total){
02226 for (int layer=1; layer < 44; layer++){
02227 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
02228 for (int module=1;module<200;module++) {
02229 int key=layer*100000+ring*1000+module;
02230 TmModule * mod = smoduleMap[key];
02231 if(mod !=0 && !mod->notInUse()){
02232 mod->value = mod->value / mod->count;
02233 }
02234 }
02235 }
02236 }
02237 }
02238 if(minvalue>=maxvalue){
02239 minvalue=9999999.;
02240 maxvalue=-9999999.;
02241 for (int layer=1; layer < 44; layer++){
02242 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
02243 for (int module=1;module<200;module++) {
02244 int key=layer*100000+ring*1000+module;
02245 TmModule * mod = smoduleMap[key];
02246 if(mod !=0 && !mod->notInUse()){
02247 if (minvalue > mod->value)minvalue=mod->value;
02248 if (maxvalue < mod->value)maxvalue=mod->value;
02249 }
02250 }
02251 }
02252 }
02253 }
02254 for (int layer=1; layer < 44; layer++){
02255 nlay=layer;
02256 defwindow(nlay);
02257 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
02258 for (int module=1;module<200;module++) {
02259 int key=layer*100000+ring*1000+module;
02260 TmModule * mod = smoduleMap[key];
02261 if(mod !=0 && !mod->notInUse()){
02262 drawModule(mod,key,layer,print_total,svgfile);
02263 }
02264 }
02265 }
02266 }
02267 *svgfile << "</svg:g></svg:svg>"<<std::endl;
02268 *svgfile << " <svg:text id=\"Title\" class=\"normalText\" x=\"300\" y=\"0\">"<<title<<"</svg:text>"<<std::endl;
02269 if(printflag)drawPalette(svgfile);
02270 *svgfile << "</svg:svg>"<<std::endl;
02271 *svgfile << "</body></html>"<<std::endl;
02272 svgfile->close();delete svgfile;
02273
02274 }
02275
02276 void TrackerMap::drawPalette(std::ofstream * svgfile){
02277 int color,red, green, blue;
02278 float val=minvalue;
02279 int paletteLength = 250;
02280 float dval = (maxvalue-minvalue)/(float)paletteLength;
02281 for(int i=0;i<paletteLength;i++){
02282 color = getcolor(val,palette);
02283 red=(color>>16)&0xFF;
02284 green=(color>>8)&0xFF;
02285 blue=(color)&0xFF;
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296 if(!temporary_file)*svgfile <<"<svg:rect x=\"3610\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"6\" fill=\"rgb("<<red<<","<<green<<","<<blue<<")\" />\n";
02297 else *svgfile << red << " " << green << " " << blue << " 4 " << (6*i)+40 << " 3610. " <<
02298 (6*i)+40 << " 3660. " <<
02299 (6*(i-1))+40 << " 3660. " <<
02300 (6*(i-1))+40 <<" 3610. " << std::endl;
02301
02302 if(i%50 == 0){
02303 if(!temporary_file)*svgfile <<"<svg:rect x=\"3610\" y=\""<<(1550-6*i)<<"\" width=\"50\" height=\"1\" fill=\"black\" />\n";
02304 if(i%50==0&&!temporary_file)*svgfile << " <svg:text class=\"normalText\" x=\"3660\" y=\""<<(1560-6*i)<<"\">" <<val<<"</svg:text>"<<std::endl;
02305 }
02306 val = val + dval;
02307 }
02308 }
02309 void TrackerMap::fillc_fed_channel(int fedId,int fedCh, int red, int green, int blue )
02310 {
02311 int key = fedId*1000+fedCh;
02312 TmApvPair* apvpair = apvMap[key];
02313
02314 if(apvpair!=0){
02315 apvpair->red=red; apvpair->green=green; apvpair->blue=blue;
02316 return;
02317 }
02318 std::cout << "*** error in FedTrackerMap fillc method ***";
02319 }
02320
02321 void TrackerMap::fill_fed_channel(int idmod, float qty )
02322 {
02323 std::multimap<const int, TmApvPair*>::iterator pos;
02324 for (pos = apvModuleMap.lower_bound(idmod);
02325 pos != apvModuleMap.upper_bound(idmod); ++pos) {
02326 TmApvPair* apvpair = pos->second;
02327 if(apvpair!=0){
02328 apvpair->value=apvpair->value+qty;
02329 apvpair->count++;
02330 }
02331 }
02332 return;
02333 std::cout << "*** error in FedTrackerMap fill by module method ***";
02334 }
02335
02336 void TrackerMap::fill_current_val_fed_channel(int fedId, int fedCh, float current_val )
02337 {
02338 int key = fedId*1000+fedCh;
02339 TmApvPair* apvpair = apvMap[key];
02340
02341 if(apvpair!=0) {apvpair->value=current_val; apvpair->count=1; apvpair->red=-1;}
02342 else
02343 std::cout << "*** error in FedTrackerMap fill_current_val method ***";
02344 }
02345
02346
02347 void TrackerMap::fillc_fec_channel(int crate,int slot, int ring, int addr, int red, int green, int blue )
02348 {
02349 int key =crate*10000000+slot*100000+ring*1000+addr;
02350
02351 TmCcu *ccu = ccuMap[key];
02352
02353 if(ccu!=0){
02354 ccu->red=red; ccu->green=green; ccu->blue=blue;
02355 return;
02356 }
02357 std::cout << "*** error in FecTrackerMap fillc method ***";
02358 }
02359
02360 void TrackerMap::fill_fec_channel(int crate,int slot, int ring, int addr, float qty )
02361 {
02362 int key =crate*10000000+slot*100000+ring*1000+addr;
02363 TmCcu *ccu = ccuMap[key];
02364 if(ccu!=0){
02365 ccu->count++; ccu->value=ccu->value+qty;
02366 return;
02367
02368 }
02369
02370 std::cout << "*** error in FecTrackerMap fill by module method ***";
02371 }
02372
02373
02374
02375 void TrackerMap::fillc_lv_channel(int rack,int crate, int board, int red, int green, int blue )
02376 {
02377
02378 int key = rack*1000+crate*100+board;
02379
02380 TmPsu *psu = psuMap[key];
02381
02382 if(psu!=0){
02383 psu->red=red; psu->green=green; psu->blue=blue;
02384 return;
02385 }
02386 std::cout << "*** error in LVTrackerMap fillc method ***";
02387 }
02388
02389 void TrackerMap::fill_lv_channel(int rack,int crate, int board, float qty )
02390 {
02391 int key = rack*1000+crate*100+board;
02392 TmPsu *psu = psuMap[key];
02393 if(psu!=0){
02394 psu->count++; psu->value=psu->value+qty;
02395 return;
02396
02397 }
02398
02399 std::cout << "*** error in LVTrackerMap fill by module method ***";
02400 }
02401
02402 void TrackerMap::fillc_hv_channel2(int rack,int crate, int board, int red, int green, int blue )
02403 {
02404
02405 int key = rack*1000+crate*100+board;
02406
02407 TmPsu *psu = psuMap[key];
02408
02409 if(psu!=0){
02410 psu->redHV2=red; psu->greenHV2=green; psu->blueHV2=blue;
02411 return;
02412 }
02413 std::cout << "*** error in HVTrackerMap (channel 2) fillc method ***";
02414 }
02415 void TrackerMap::fillc_hv_channel3(int rack,int crate, int board, int red, int green, int blue )
02416 {
02417
02418 int key = rack*1000+crate*100+board;
02419
02420 TmPsu *psu = psuMap[key];
02421
02422 if(psu!=0){
02423 psu->redHV3=red; psu->greenHV3=green; psu->blueHV3=blue;
02424 return;
02425 }
02426 std::cout << "*** error in HVTrackerMap (channel 3) fillc method ***";
02427 }
02428
02429
02430 void TrackerMap::fill_hv_channel2(int rack,int crate, int board, float qty )
02431 {
02432 int key = rack*1000+crate*100+board;
02433 TmPsu *psu = psuMap[key];
02434 if(psu!=0){
02435 psu->countHV2++; psu->valueHV2=psu->valueHV2+qty;
02436 return;
02437
02438 }
02439
02440 std::cout << "*** error in HVTrackerMap fill by module method ***";
02441 }
02442 void TrackerMap::fill_hv_channel3(int rack,int crate, int board, float qty )
02443 {
02444 int key = rack*1000+crate*100+board;
02445 TmPsu *psu = psuMap[key];
02446 if(psu!=0){
02447 psu->countHV3++; psu->valueHV3=psu->valueHV3+qty;
02448 return;
02449
02450 }
02451
02452 std::cout << "*** error in HVTrackerMap fill by module method ***";
02453 }
02454
02455
02456
02457
02458
02459 int TrackerMap::module(int fedId, int fedCh)
02460 {
02461 int key = fedId*1000+fedCh;
02462 TmApvPair* apvpair = apvMap[key];
02463 if(apvpair!=0){
02464 return(apvpair->mod->idex);
02465 }
02466 return(0);
02467 std::cout << "*** error in FedTrackerMap module method ***";
02468 }
02469 void TrackerMap::fill_fed_channel(int fedId, int fedCh, float qty )
02470 {
02471 int key = fedId*1000+fedCh;
02472 TmApvPair* apvpair = apvMap[key];
02473 if(apvpair!=0){
02474 apvpair->value=apvpair->value+qty;
02475 apvpair->count++;
02476 return;
02477 }
02478 std::cout << "*** error inFedTrackerMap fill method ***";
02479 }
02480
02481
02482 void TrackerMap::fillc(int idmod, int red, int green, int blue ){
02483
02484 TmModule * mod = imoduleMap[idmod];
02485 if(mod!=0){
02486 mod->red=red; mod->green=green; mod->blue=blue;
02487 return;
02488 }
02489 std::cout << "**************************error in fill method **************module "<<idmod<<std::endl;
02490 }
02491 void TrackerMap::fillc(int layer, int ring, int nmod, int red, int green, int blue ){
02492
02493 int key = layer*10000+ring*1000+nmod;
02494 TmModule * mod = smoduleMap[key];
02495
02496 if(mod!=0){
02497 mod->red=red; mod->green=green; mod->blue=blue;
02498 return;
02499 }
02500 std::cout << "**************************error in fill method **************"<< std::endl;
02501 }
02502
02503 void TrackerMap::fillc_all_blank(){
02504
02505 std::map<const int , TmModule *>::iterator imod;
02506 for( imod=imoduleMap.begin();imod !=imoduleMap.end(); imod++){
02507 fillc(imod->first,255,255,255);
02508 }
02509 }
02510
02511 void TrackerMap::fill_all_blank(){
02512
02513 std::map<const int , TmModule *>::iterator imod;
02514 for( imod=imoduleMap.begin();imod !=imoduleMap.end(); imod++){
02515 fill_current_val(imod->first,0);
02516 }
02517 }
02518
02519
02520
02521 void TrackerMap::fill_current_val(int idmod, float current_val ){
02522
02523 TmModule * mod = imoduleMap[idmod];
02524 if(mod!=0) {mod->value=current_val; mod->count=1; mod->red=-1;}
02525 else std::cout << "**error in fill_current_val method ***module "<<idmod<<std::endl;
02526 }
02527
02528 void TrackerMap::fill(int idmod, float qty ){
02529
02530 TmModule * mod = imoduleMap[idmod];
02531 if(mod!=0){
02532 mod->value=mod->value+qty;
02533 mod->count++;
02534 return;
02535 }else{
02536 TmModule * mod1 = imoduleMap[idmod+1];
02537 TmModule * mod2 = imoduleMap[idmod+2];
02538 if(mod1!=0 && mod2!=0){
02539 mod1->value=mod1->value+qty;
02540 mod1->count++;
02541 mod2->value=mod2->value+qty;
02542 mod2->count++;
02543 return;
02544 }}
02545 std::cout << "**************************error in fill method **************module "<<idmod<<std::endl;
02546 }
02547
02548 void TrackerMap::fill(int layer, int ring, int nmod, float qty){
02549
02550 int key = layer*100000+ring*1000+nmod;
02551 TmModule * mod = smoduleMap[key];
02552 if(mod!=0){
02553 mod->value=mod->value+qty;
02554 mod->count++;
02555 }
02556 else std::cout << "**************************error in SvgModuleMap **************";
02557 }
02558
02559 void TrackerMap::setText(int idmod, std::string s){
02560
02561 TmModule * mod = imoduleMap[idmod];
02562 if(mod!=0){
02563 mod->text=s;
02564 }
02565 else std::cout << "**************************error in IdModuleMap **************";
02566 }
02567
02568
02569 void TrackerMap::setText(int layer, int ring, int nmod, std::string s){
02570
02571 int key = layer*100000+ring*1000+nmod;
02572 TmModule * mod = smoduleMap[key];
02573 if(mod!=0){
02574 mod->text=s;
02575 }
02576 else std::cout << "**************************error in SvgModuleMap **************";
02577 }
02578
02579 void TrackerMap::build(){
02580
02581
02582 int nmods, pix_sil, fow_bar, ring, nmod, layer;
02583 unsigned int idex;
02584 float posx, posy, posz, length, width, thickness, widthAtHalfLength;
02585 int iModule=0,old_layer=0, ntotMod =0;
02586 std::string name,dummys;
02587 ifstream infile(edm::FileInPath(infilename).fullPath().c_str(),std::ios::in);
02588 while(!infile.eof()) {
02589 infile >> nmods >> pix_sil >> fow_bar >> layer >> ring >> nmod >> posx >> posy
02590 >> posz>> length >> width >> thickness
02591 >> widthAtHalfLength >> idex ;
02592 getline(infile,dummys);
02593 getline(infile,name);
02594 if(old_layer!=layer){old_layer=layer;iModule=0;}
02595 iModule++;
02596 ntotMod++;
02597 int key=layer*100000+ring*1000+nmod;
02598 TmModule * mod = smoduleMap[key];
02599
02600 imoduleMap[idex]=mod;
02601
02602 if(mod==0) std::cout << "error in module "<<key <<std::endl;
02603 else
02604 {
02605 mod->posx = posx;
02606 mod->posy = posy;
02607 mod->setUsed();
02608 mod->value=0;
02609 mod->count=0;
02610 mod->posz = posz;
02611 mod->length = length;
02612 mod->width = width;
02613 mod->thickness = thickness;
02614 mod->widthAtHalfLength = widthAtHalfLength;
02615 mod->idex = idex;
02616 mod->name = name;
02617 }
02618 }
02619 infile.close();
02620 number_modules = ntotMod-1;
02621 }
02622 int TrackerMap::getcolor(float value,int palette){
02623 int red,green,blue;
02624 red=0;green=0;blue=0;
02625 if(palette==1){
02626 float delta=(maxvalue-minvalue);
02627 float x =(value-minvalue);
02628 if(value<minvalue){red=0;green=0;blue=255;}
02629 if(value>maxvalue){red=255;green=0;blue=0;}
02630 if(value>=minvalue&&value<=maxvalue){
02631 red = (int) ( x<(delta/2) ? 0 : ( x > ((3./4.)*delta) ? 255 : 255/(delta/4) * (x-(2./4.)*delta) ) );
02632 green= (int) ( x<delta/4 ? (x*255/(delta/4)) : ( x > ((3./4.)*delta) ? 255-255/(delta/4) *(x-(3./4.)*delta) : 255 ) );
02633 blue = (int) ( x<delta/4 ? 255 : ( x > ((1./2.)*delta) ? 0 : 255-255/(delta/4) * (x-(1./4.)*delta) ) );
02634 }
02635 }
02636 if (palette==2){
02637 green = (int)((value-minvalue)/(maxvalue-minvalue)*256.);
02638 if (green > 255) green=255;
02639 red = 255; blue=0;green=255-green;
02640 }
02641 return(blue|(green<<8)|(red<<16));
02642 }
02643 void TrackerMap::printonline(){
02644
02645 std::ofstream * ofilename;
02646 std::ifstream * ifilename;
02647 std::ostringstream ofname;
02648 std::string ifname;
02649 std::string command;
02650 std::string line;
02651 std::string outputfilename="dqmtmap";
02652 ifilename=findfile("viewerHeader.xhtml");
02653 ofname << outputfilename << "viewer.html";
02654 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02655 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02656 *ofilename <<" var tmapname=\"" <<outputfilename << "\""<<std::endl;
02657 *ofilename <<" var tmaptitle=\"" <<title << "\""<<std::endl;
02658 *ofilename <<" var ncrates=" <<ncrates << ";"<<std::endl;
02659 *ofilename <<" var nfeccrates=" <<nfeccrates << ";"<<std::endl;
02660 *ofilename <<" var npsuracks=" <<npsuracks << ";"<<std::endl;
02661
02662 ifilename->close();delete ifilename;
02663
02664 ifilename=findfile("viewerTrailer.xhtml");
02665 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02666 ofilename->close();delete ofilename;
02667 command = "sed -i \"s/XtmapnameX/"+outputfilename+"/g\" "+ ofname.str();
02668 std::cout << "Executing " << command << std::endl;
02669 system(command.c_str());
02670 command = "sed -i \"s/XtmaptitleX/"+title+"/g\" "+ ofname.str();
02671 std::cout << "Executing " << command << std::endl;
02672 system(command.c_str());
02673 ofname.str("");
02674 ifilename->close();delete ifilename;
02675
02676 ifilename=findfile("jqviewer.js");
02677 ofname << "jqviewer.js";
02678 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02679 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02680 ofname.str("");
02681 ofilename->close();delete ofilename;
02682 ifilename->close();delete ifilename;
02683
02684 ifilename=findfile("crate.js");
02685 ofname << "crate.js";
02686 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02687 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02688 ofname.str("");
02689 ofilename->close();delete ofilename;
02690 ifilename->close();delete ifilename;
02691
02692 ifilename=findfile("feccrate.js");
02693 ofname << "feccrate.js";
02694 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02695 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02696 ofname.str("");
02697 ofilename->close();delete ofilename;
02698 ifilename->close();delete ifilename;
02699
02700 ifilename=findfile("layer.js");
02701 ofname << "layer.js";
02702 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02703 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02704 ofname.str("");
02705 ofilename->close();delete ofilename;
02706 ifilename->close();delete ifilename;
02707
02708 ifilename=findfile("rack.js");
02709 ofname << "rack.js";
02710 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02711 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02712 ofname.str("");
02713 ofilename->close();delete ofilename;
02714 ifilename->close();delete ifilename;
02715 ofname.str("");
02716
02717 ifilename=findfile("rackhv.js");
02718 ofname << "rackhv.js";
02719 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02720 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02721 ofname.str("");
02722 ofilename->close();delete ofilename;
02723 ifilename->close();delete ifilename;
02724
02725
02726
02727
02728 std::ostringstream outs,outs1,outs2;
02729 outs << outputfilename<<".png";
02730 save(true,gminvalue,gmaxvalue,outs.str(),3000,1600);
02731 temporary_file=false;
02732 printlayers(true,gminvalue,gmaxvalue,outputfilename);
02733
02734
02735 std::ofstream * txtfile;
02736 for (int layer=1; layer < 44; layer++){
02737 std::ostringstream outs;
02738 outs << outputfilename <<"layer"<<layer<< ".html";
02739 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
02740 *txtfile << "<html><head></head> <body>" << std::endl;
02741 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
02742 for (int module=1;module<200;module++) {
02743 int key=layer*100000+ring*1000+module;
02744 TmModule * mod = smoduleMap[key];
02745 if(mod !=0 && !mod->notInUse()){
02746 int idmod=mod->idex;
02747 int nchan=0;
02748 *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
02749 std::multimap<const int, TmApvPair*>::iterator pos;
02750 for (pos = apvModuleMap.lower_bound(idmod);
02751 pos != apvModuleMap.upper_bound(idmod); ++pos) {
02752 TmApvPair* apvpair = pos->second;
02753 if(apvpair!=0){
02754 nchan++;
02755 *txtfile << apvpair->text << std::endl;
02756 }
02757
02758 }
02759 *txtfile << "</pre><h3>"<< mod->name<<"</h3>"<<std::endl;
02760 }
02761 }
02762 }
02763 *txtfile << "</body></html>" << std::endl;
02764 txtfile->close();delete txtfile;
02765 }
02766 if(enableFedProcessing){
02767 outs1 << outputfilename<<"fed.png";
02768 save_as_fedtrackermap(true,gminvalue,gmaxvalue,outs1.str(),6000,3200);
02769 outs2 << outputfilename<<".xml";
02770 save_as_fedtrackermap(true,gminvalue,gmaxvalue,outs2.str(),3000,1600);
02771
02772 std::map<int , int>::iterator i_fed;
02773 std::ofstream * txtfile;
02774 for (int crate=1; crate < (ncrates+1); crate++){
02775 std::ostringstream outs;
02776 outs << outputfilename <<"crate"<<crate<< ".html";
02777 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
02778 *txtfile << "<html><head></head> <body>" << std::endl;
02779 for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
02780 if(i_fed->second == crate){
02781 int fedId = i_fed->first;
02782 for (int nconn=0;nconn<96;nconn++){
02783 int key = fedId*1000+nconn;
02784 TmApvPair * apvPair= apvMap[key];
02785 if(apvPair !=0){
02786 int idmod=apvPair->idex;
02787 *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
02788 *txtfile << apvPair->text << std::endl;
02789 std::ostringstream outs;
02790 outs << "fedchannel " <<apvPair->getFedId() << "/"<<apvPair->getFedCh()<<" connects to module " << apvPair->mod->idex ;
02791 *txtfile << "</pre><h3>"<< outs.str()<<"</h3>"<<std::endl;
02792 }
02793 }
02794 }
02795 }
02796 *txtfile << "</body></html>" << std::endl;
02797 txtfile->close();delete txtfile;
02798 }
02799 }
02800 if(enableFecProcessing){
02801 std::ostringstream outs1,outs2;
02802 outs1 << outputfilename<<"fec.png";
02803 save_as_fectrackermap(true,gminvalue,gmaxvalue,outs1.str(),6000,3200);
02804 outs2 << outputfilename<<".xml";
02805 save_as_fectrackermap(true,gminvalue,gmaxvalue,outs2.str(),3000,1600);
02806
02807 std::ofstream * txtfile;
02808 std::map<int , TmCcu *>::iterator i_ccu;
02809 std::multimap<TmCcu*, TmModule*>::iterator it;
02810 std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
02811 for (int crate=1; crate < (nfeccrates+1); crate++){
02812 std::ostringstream outs;
02813 outs << outputfilename <<"feccrate"<<crate<< ".html";
02814 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
02815 *txtfile << "<html><head></head> <body>" << std::endl;
02816 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
02817 TmCcu * ccu= i_ccu->second;
02818 if(ccu!=0&&ccu->getCcuCrate() == crate){
02819 int idmod=ccu->idex;
02820 *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
02821 *txtfile << ccu->text << std::endl;
02822 std::ostringstream outs;
02823 if(ccu->nmod==0)outs << "ccu is in position" << ccu->mpos<<"in ring but doesn't seem to have any module connected"; else
02824 {
02825 outs << "ccu is in position " << ccu->mpos<<" in ring and connects " <<ccu->nmod<< " modules" << std::endl;
02826 ret = fecModuleMap.equal_range(ccu);
02827 for (it = ret.first; it != ret.second; ++it)
02828 {
02829 outs << (*it).second->idex<<" " << (*it).second->name <<" value= "<< (*it).second->value<<"\n\n";
02830 }
02831
02832 *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
02833 }
02834 }
02835 }
02836 *txtfile << "</body></html>" << std::endl;
02837 txtfile->close();delete txtfile;
02838 }
02839 }
02840 if(enableLVProcessing){
02841 std::ostringstream outs3,outs4;
02842 outs3 << outputfilename<<"psu.png";
02843 save_as_psutrackermap(true,gminvalue,gmaxvalue,outs3.str(),6000,3200);
02844
02845 outs4 << outputfilename<<".xml";
02846 save_as_psutrackermap(true,gminvalue,gmaxvalue,outs4.str(),3000,1600);
02847
02848
02849 std::ofstream * txtfile;
02850 std::map<int , TmPsu *>::iterator ipsu;
02851 std::multimap<TmPsu*, TmModule*>::iterator it;
02852 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
02853 for (int rack=1; rack < (npsuracks+1); rack++){
02854 std::ostringstream outs;
02855
02856 outs << outputfilename <<"psurack"<<rack<< ".html";
02857 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
02858 *txtfile << "<html><head></head> <body>" << std::endl;
02859 for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
02860 TmPsu * psu= ipsu->second;
02861 if(psu!=0 && psu->getPsuRack() == rack){
02862 *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
02863 *txtfile << psu->text << std::endl;
02864 std::ostringstream outs;
02865 if(psu->nmod==0)outs << "Ps is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
02866 {
02867 outs<< "PS is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmod<<" modules. "<<std::endl;
02868
02869 ret = psuModuleMap.equal_range(psu);
02870 for (it = ret.first; it != ret.second; ++it)
02871 {
02872 outs <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;
02873
02874 }
02875 *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
02876 }
02877 }
02878 }
02879 *txtfile << "</body></html>" << std::endl;
02880 txtfile->close();delete txtfile;
02881 }
02882 }
02883
02884
02885 if(enableHVProcessing){
02886 std::ostringstream outs5,outs6;
02887 outs5 << outputfilename<<"hv.png";
02888 save_as_HVtrackermap(true,gminvalue,gmaxvalue,outs5.str(),6000,3200);
02889
02890 outs6 << outputfilename<<".xml";
02891 save_as_HVtrackermap(true,gminvalue,gmaxvalue,outs6.str(),3000,1600);
02892
02893
02894 std::ofstream * txtfile;
02895 std::map<int , TmPsu *>::iterator ipsu;
02896 std::multimap<TmPsu*, TmModule*>::iterator it;
02897 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
02898 for (int rack=1; rack < (npsuracks+1); rack++){
02899 std::ostringstream outs;
02900
02901 outs << outputfilename <<"HVrack"<<rack<< ".html";
02902 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
02903 *txtfile << "<html><head></head> <body>" << std::endl;
02904 for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
02905 TmPsu * psu= ipsu->second;
02906 if(psu!=0 && psu->getPsuRack() == rack){
02907 *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
02908 *txtfile << psu->textHV2 << std::endl;
02909 std::ostringstream outsHV2;
02910 if(psu->nmodHV2==0)outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
02911 {
02912 outsHV2<< "HV Channel002 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV2<<" modules. "<<" <br>"<<std::endl;
02913
02914 ret = psuModuleMap.equal_range(psu);
02915 for (it = ret.first; it != ret.second; ++it)
02916 {
02917 if((*it).second->HVchannel==2){outsHV2 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
02918 }
02919 *txtfile << "</pre><h4>"<< outsHV2.str()<<"</h4>"<<std::endl;
02920 }
02921
02922 *txtfile << psu->textHV3 << std::endl;
02923 std::ostringstream outsHV3;
02924 if(psu->nmodHV3==0)outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
02925 {
02926 outsHV3<< "HV Channel003 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV3<<" modules. "<<" <br>"<<std::endl;
02927
02928 ret = psuModuleMap.equal_range(psu);
02929 for (it = ret.first; it != ret.second; ++it)
02930 {
02931 if((*it).second->HVchannel==3){outsHV3 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
02932 }
02933 *txtfile << "</pre><h4>"<< outsHV3.str()<<"</h4>"<<std::endl;
02934 }
02935
02936 }
02937 }
02938 *txtfile << "</body></html>" << std::endl;
02939 txtfile->close();delete txtfile;
02940 }
02941 }
02942
02943 }
02944 void TrackerMap::printall(bool print_total, float minval, float maxval, std::string outputfilename){
02945
02946 std::ofstream * ofilename;
02947 std::ifstream * ifilename;
02948 std::ostringstream ofname;
02949 std::string ifname;
02950 std::string line;
02951 std::string command;
02952
02953 ifilename=findfile("viewerHeader.xhtml");
02954 ofname << outputfilename << "viewer.html";
02955 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02956 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02957 *ofilename <<" var tmapname=\"" <<outputfilename << "\""<<std::endl;
02958 *ofilename <<" var tmaptitle=\"" <<title << "\""<<std::endl;
02959 *ofilename <<" var ncrates=" <<ncrates << ";"<<std::endl;
02960 *ofilename <<" var nfeccrates=" <<nfeccrates << ";"<<std::endl;
02961 *ofilename <<" var npsuracks=" <<npsuracks << ";"<<std::endl;
02962 ifilename->close();delete ifilename;
02963 ifilename=findfile("viewerTrailer.xhtml");
02964 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02965 ofilename->close();delete ofilename;
02966 ifilename->close();delete ifilename;
02967 command = "sed -i \"s/XtmapnameX/"+outputfilename+"/g\" "+ ofname.str();
02968 std::cout << "Executing " << command << std::endl;
02969 system(command.c_str());
02970 command = "sed -i \"s/XtmaptitleX/"+title+"/g\" "+ ofname.str();
02971 std::cout << "Executing " << command << std::endl;
02972 system(command.c_str());
02973 ofname.str("");
02974
02975 ifilename=findfile("jqviewer.js");
02976 ofname << "jqviewer.js";
02977 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02978 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02979 ofilename->close();delete ofilename;
02980 ifilename->close();delete ifilename;
02981
02982 ofname.str("");
02983 ifilename=findfile("crate.js");
02984 ofname << "crate.js";
02985 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02986 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02987 ofilename->close();delete ofilename;
02988 ifilename->close();delete ifilename;
02989
02990 ofname.str("");
02991 ifilename=findfile("feccrate.js");
02992 ofname << "feccrate.js";
02993 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
02994 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
02995 ofilename->close();delete ofilename;
02996 ifilename->close();delete ifilename;
02997
02998 ofname.str("");
02999 ifilename=findfile("rack.js");
03000 ofname << "rack.js";
03001 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
03002 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
03003 ofilename->close();delete ofilename;
03004 ifilename->close();delete ifilename;
03005
03006 ofname.str("");
03007 ifilename=findfile("rackhv.js");
03008 ofname << "rackhv.js";
03009 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
03010 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
03011 ofilename->close();delete ofilename;
03012 ifilename->close();delete ifilename;
03013
03014 ofname.str("");
03015 ifilename=findfile("layer.js");
03016 ofname << "layer.js";
03017 ofilename = new std::ofstream(ofname.str().c_str(),std::ios::out);
03018 while (getline( *ifilename, line )) { *ofilename << line << std::endl; }
03019 ofilename->close();delete ofilename;
03020 ifilename->close();delete ifilename;
03021
03022 command = "scp -r ../../DQM/TrackerCommon/test/jquery/ .";
03023 std::cout << "Executing " << command << std::endl;
03024 system(command.c_str());
03025 command = "scp -r ../../CommonTools/TrackerMap/data/images/ .";
03026 std::cout << "Executing " << command << std::endl;
03027 system(command.c_str());
03028
03029
03030 std::ostringstream outs;
03031 outs << outputfilename<<".png";
03032 save(true,minval,maxval,outs.str(),3000,1600);
03033 temporary_file=false;
03034 printlayers(true,minval,maxval,outputfilename);
03035
03036
03037 std::ofstream * txtfile;
03038 for (int layer=1; layer < 44; layer++){
03039 std::ostringstream outs;
03040 outs << outputfilename <<"layer"<<layer<< ".html";
03041 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
03042 *txtfile << "<html><head></head> <body>" << std::endl;
03043 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
03044 for (int module=1;module<200;module++) {
03045 int key=layer*100000+ring*1000+module;
03046 TmModule * mod = smoduleMap[key];
03047 if(mod !=0 && !mod->notInUse()){
03048 int idmod=mod->idex;
03049 int nchan=0;
03050 *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
03051 std::multimap<const int, TmApvPair*>::iterator pos;
03052 for (pos = apvModuleMap.lower_bound(idmod);
03053 pos != apvModuleMap.upper_bound(idmod); ++pos) {
03054 TmApvPair* apvpair = pos->second;
03055 if(apvpair!=0){
03056 nchan++;
03057 *txtfile << apvpair->text << std::endl;
03058 }
03059
03060 }
03061 *txtfile << "</pre><h3>"<< mod->name<<"</h3>"<<std::endl;
03062 }
03063 }
03064 }
03065 *txtfile << "</body></html>" << std::endl;
03066 txtfile->close();delete txtfile;
03067 }
03068 if(enableFedProcessing){
03069 std::ostringstream outs1,outs2;
03070 outs1 << outputfilename<<"fed.png";
03071 save_as_fedtrackermap(true,0.,0.,outs1.str(),6000,3200);
03072 outs2 << outputfilename<<".xml";
03073 save_as_fedtrackermap(true,0.,0.,outs2.str(),3000,1600);
03074
03075 std::map<int , int>::iterator i_fed;
03076 std::ofstream * txtfile;
03077 for (int crate=1; crate < (ncrates+1); crate++){
03078 std::ostringstream outs;
03079 outs << outputfilename <<"crate"<<crate<< ".html";
03080 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
03081 *txtfile << "<html><head></head> <body>" << std::endl;
03082 for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
03083 if(i_fed->second == crate){
03084 int fedId = i_fed->first;
03085 for (int nconn=0;nconn<96;nconn++){
03086 int key = fedId*1000+nconn;
03087 TmApvPair * apvPair= apvMap[key];
03088 if(apvPair !=0){
03089 int idmod=apvPair->idex;
03090 *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
03091 *txtfile << apvPair->text << std::endl;
03092 std::ostringstream outs;
03093 outs << "fedchannel " <<apvPair->getFedId() << "/"<<apvPair->getFedCh()<<" connects to module " << apvPair->mod->idex ;
03094 *txtfile << "</pre><h3>"<< outs.str()<<"</h3>"<<std::endl;
03095 }
03096 }
03097 }
03098 }
03099 *txtfile << "</body></html>" << std::endl;
03100 txtfile->close();delete txtfile;
03101 }
03102 }
03103 if(enableFecProcessing){
03104 std::ostringstream outs1,outs2;
03105 outs1 << outputfilename<<"fec.png";
03106 save_as_fectrackermap(true,0.,0.,outs1.str(),6000,3200);
03107 outs2 << outputfilename<<".xml";
03108 save_as_fectrackermap(true,0.,0.,outs2.str(),3000,1600);
03109
03110 std::ofstream * txtfile;
03111 std::map<int , TmCcu *>::iterator i_ccu;
03112 std::multimap<TmCcu*, TmModule*>::iterator it;
03113 std::pair<std::multimap<TmCcu*, TmModule*>::iterator,std::multimap<TmCcu*, TmModule*>::iterator> ret;
03114 for (int crate=1; crate < (nfeccrates+1); crate++){
03115 std::ostringstream outs;
03116 outs << outputfilename <<"feccrate"<<crate<< ".html";
03117 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
03118 *txtfile << "<html><head></head> <body>" << std::endl;
03119 for( i_ccu=ccuMap.begin();i_ccu !=ccuMap.end(); i_ccu++){
03120 TmCcu * ccu= i_ccu->second;
03121 if(ccu!=0&&ccu->getCcuCrate() == crate){
03122 int idmod=ccu->idex;
03123 *txtfile << "<a name="<<idmod<<"><pre>"<<std::endl;
03124 *txtfile << ccu->text << std::endl;
03125 std::ostringstream outs;
03126 if(ccu->nmod==0)outs << "ccu is in position" << ccu->mpos<<"in ring but doesn't seem to have any module connected"; else
03127 {
03128 outs << "ccu is in position " << ccu->mpos<<" in ring and connects " <<ccu->nmod<< " modules" << std::endl;
03129 ret = fecModuleMap.equal_range(ccu);
03130 for (it = ret.first; it != ret.second; ++it)
03131 {
03132 outs << (*it).second->idex<<" " << (*it).second->name <<" value= "<< (*it).second->value<<"\n\n";
03133 }
03134
03135 *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
03136 }
03137 }
03138 }
03139 *txtfile << "</body></html>" << std::endl;
03140 txtfile->close();
03141 }
03142 }
03143 if(enableLVProcessing){
03144 std::ostringstream outs3,outs4;
03145 outs3 << outputfilename<<"psu.png";
03146 save_as_psutrackermap(true,0.,0.,outs3.str(),6000,3200);
03147
03148 outs4 << outputfilename<<".xml";
03149 save_as_psutrackermap(true,0.,0.,outs4.str(),3000,1600);
03150
03151
03152 std::ofstream * txtfile;
03153 std::map<int , TmPsu *>::iterator ipsu;
03154 std::multimap<TmPsu*, TmModule*>::iterator it;
03155 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
03156 for (int rack=1; rack < (npsuracks+1); rack++){
03157 std::ostringstream outs;
03158
03159 outs << outputfilename <<"psurack"<<rack<< ".html";
03160 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
03161 *txtfile << "<html><head></head> <body>" << std::endl;
03162 for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
03163 TmPsu * psu= ipsu->second;
03164 if(psu!=0 && psu->getPsuRack() == rack){
03165 *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
03166 *txtfile << psu->text << std::endl;
03167 std::ostringstream outs;
03168 if(psu->nmod==0)outs << "Ps is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
03169 {
03170 outs<< "PS is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmod<<" modules. "<<std::endl;
03171
03172 ret = psuModuleMap.equal_range(psu);
03173 for (it = ret.first; it != ret.second; ++it)
03174 {
03175 outs <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;
03176
03177 }
03178 *txtfile << "</pre><h4>"<< outs.str()<<"</h4>"<<std::endl;
03179 }
03180 }
03181 }
03182 *txtfile << "</body></html>" << std::endl;
03183 txtfile->close();
03184 }
03185 }
03186
03187
03188 if(enableHVProcessing){
03189 std::ostringstream outs5,outs6;
03190 outs5 << outputfilename<<"hv.png";
03191 save_as_HVtrackermap(true,0.,0.,outs5.str(),6000,3200);
03192
03193 outs6 << outputfilename<<".xml";
03194 save_as_HVtrackermap(true,0.,0.,outs6.str(),3000,1600);
03195
03196
03197 std::ofstream * txtfile;
03198 std::map<int , TmPsu *>::iterator ipsu;
03199 std::multimap<TmPsu*, TmModule*>::iterator it;
03200 std::pair<std::multimap<TmPsu*, TmModule*>::iterator,std::multimap<TmPsu*, TmModule*>::iterator> ret;
03201 for (int rack=1; rack < (npsuracks+1); rack++){
03202 std::ostringstream outs;
03203
03204 outs << outputfilename <<"HVrack"<<rack<< ".html";
03205 txtfile = new std::ofstream(outs.str().c_str(),std::ios::out);
03206 *txtfile << "<html><head></head> <body>" << std::endl;
03207 for ( ipsu=psuMap.begin();ipsu !=psuMap.end(); ipsu++){
03208 TmPsu * psu= ipsu->second;
03209 if(psu!=0 && psu->getPsuRack() == rack){
03210 *txtfile << "<a name="<<psu->idex<<"><pre>"<<std::endl;
03211 *txtfile << psu->textHV2 << std::endl;
03212 std::ostringstream outsHV2;
03213 if(psu->nmodHV2==0)outsHV2 << "HV Channel002 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
03214 {
03215 outsHV2<< "HV Channel002 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV2<<" modules. "<<" <br>"<<std::endl;
03216
03217 ret = psuModuleMap.equal_range(psu);
03218 for (it = ret.first; it != ret.second; ++it)
03219 {
03220 if((*it).second->HVchannel==2){outsHV2 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
03221 }
03222 *txtfile << "</pre><h4>"<< outsHV2.str()<<"</h4>"<<std::endl;
03223 }
03224
03225 *txtfile << psu->textHV3 << std::endl;
03226 std::ostringstream outsHV3;
03227 if(psu->nmodHV3==0)outsHV3 << "HV Channel003 is in position" << psu->getPsuBoard()<<"in crate but doesn't seem to have any module connected"; else
03228 {
03229 outsHV3<< "HV Channel003 is in position " <<psu->getPsuBoard()<< " in crate and connects to "<<psu->nmodHV3<<" modules. "<<" <br>"<<std::endl;
03230
03231 ret = psuModuleMap.equal_range(psu);
03232 for (it = ret.first; it != ret.second; ++it)
03233 {
03234 if((*it).second->HVchannel==3){outsHV3 <<(*it).second->idex << " "<< (*it).second->name<<" value= "<<(*it).second->value<<" <br>"<<std::endl;}
03235 }
03236 *txtfile << "</pre><h4>"<< outsHV3.str()<<"</h4>"<<std::endl;
03237 }
03238
03239 }
03240 }
03241 *txtfile << "</body></html>" << std::endl;
03242 txtfile->close();
03243 }
03244 }
03245
03246
03247 }
03248
03249
03250 std::ifstream * TrackerMap::findfile(std::string filename) {
03251 std::ifstream * ifilename;
03252 std::string ifname;
03253 if(jsPath!=""){
03254 ifname=jsPath+filename;
03255 ifilename = new ifstream(edm::FileInPath(ifname).fullPath().c_str(),std::ios::in);
03256 if(!ifilename){
03257 ifname="CommonTools/TrackerMap/data/"+filename;
03258 ifilename = new ifstream(edm::FileInPath(ifname).fullPath().c_str(),std::ios::in);
03259 }
03260 }else {
03261 ifname="CommonTools/TrackerMap/data/"+filename;
03262 ifilename = new ifstream(edm::FileInPath(ifname).fullPath().c_str(),std::ios::in);
03263 }
03264 if(!ifilename)std::cout << "File " << filename << " missing" << std::endl;
03265 return ifilename;
03266 }
03267 void TrackerMap::printlayers(bool print_total, float minval, float maxval, std::string outputfilename){
03268 std::ofstream * xmlfile;
03269 saveAsSingleLayer=true;
03270 if(!print_total){
03271 for (int layer=1; layer < 44; layer++){
03272 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
03273 for (int module=1;module<200;module++) {
03274 int key=layer*100000+ring*1000+module;
03275 TmModule * mod = smoduleMap[key];
03276 if(mod !=0 && !mod->notInUse()){
03277 mod->value = mod->value / mod->count;
03278 }
03279 }
03280 }
03281 }
03282 }
03283 if(minvalue>=maxvalue){
03284 minvalue=9999999.;
03285 maxvalue=-9999999.;
03286 for (int layer=1; layer < 44; layer++){
03287 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
03288 for (int module=1;module<200;module++) {
03289 int key=layer*100000+ring*1000+module;
03290 TmModule * mod = smoduleMap[key];
03291 if(mod !=0 && !mod->notInUse()){
03292 if (minvalue > mod->value)minvalue=mod->value;
03293 if (maxvalue < mod->value)maxvalue=mod->value;
03294 }
03295 }
03296 }
03297 }
03298 }
03299 for (int layer=1; layer < 44; layer++){
03300 std::ostringstream outs;
03301 outs << outputfilename <<"layer"<<layer<< ".xml";
03302 xmlfile = new std::ofstream(outs.str().c_str(),std::ios::out);
03303 *xmlfile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<std::endl;
03304 *xmlfile << "<svg xmlns=\"http://www.w3.org/2000/svg\""<<std::endl;
03305 *xmlfile << "xmlns:svg=\"http://www.w3.org/2000/svg\""<<std::endl;
03306 *xmlfile << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" >"<<std::endl;
03307 *xmlfile << "<script type=\"text/ecmascript\" xlink:href=\"layer.js\" />"<<std::endl;
03308 *xmlfile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 500 500\" width=\"700\" height=\"700\" onload=\"TrackerLayer.init()\">"<<std::endl;
03309 if(layer<31)*xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,1.)\" > "<<std::endl;
03310 else *xmlfile << "<g id=\"layer\" transform=\" translate(0,400) rotate(270) scale(1.,0.8)\" > "<<std::endl;
03311 *xmlfile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<std::endl;
03312 *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;
03313 *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;
03314 *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;
03315 *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;
03316 *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;
03317
03318 nlay=layer;
03319 defwindow(nlay);
03320 for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
03321 for (int module=1;module<200;module++) {
03322 int key=layer*100000+ring*1000+module;
03323 TmModule * mod = smoduleMap[key];
03324 if(mod !=0 && !mod->notInUse()){
03325 drawModule(mod,key,layer,print_total,xmlfile);
03326 }
03327 }
03328 }
03329 *xmlfile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\">" << std::endl;
03330 *xmlfile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << std::endl;
03331 *xmlfile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << std::endl;
03332 *xmlfile << "<tspan id=\"line3\" x=\"40\" y=\"90\"> </tspan> " << std::endl;
03333 *xmlfile << "<tspan id=\"line4\" x=\"40\" y=\"120\"> </tspan> " << std::endl;
03334 if(layer > 33){
03335 *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;
03336 *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;
03337 *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;
03338 *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;
03339 *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;
03340 }
03341 else{
03342 *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;
03343 *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;
03344 *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;
03345 *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;
03346 *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;
03347 }
03348 *xmlfile << " </text> </svg>" << std::endl;
03349 xmlfile->close();delete xmlfile;
03350 }
03351 saveAsSingleLayer=false;
03352 }