CMS 3D CMS Logo

TrackerMap Class Reference

#include <CommonTools/TrackerMap/interface/TrackerMap.h>

Inheritance diagram for TrackerMap:

SiPixelTrackerMap

List of all members.

Public Types

typedef std::map< const int,
TmModule * > 
ImoduleMap
typedef std::multimap< const
int, TmApvPair * > 
ModApvPair
typedef std::map< const int,
TmModule * > 
SmoduleMap
typedef std::map< const int,
TmApvPair * > 
SvgApvPair
typedef std::map< const int, intSvgFed

Public Member Functions

void build ()
void defcwindow (int num_crate)
void defwindow (int num_lay)
void drawApvPair (int crate, int numfed_incrate, bool total, TmApvPair *apvPair, std::ofstream *file, bool useApvPairValue)
void drawModule (TmModule *mod, int key, int layer, bool total, std::ofstream *file)
void drawPalette (std::ofstream *file)
void fill (int idmod, float qty)
void fill (int layer, int ring, int nmod, float x)
void fill_current_val (int idmod, float current_val)
void fill_current_val_fed_channel (int fedId, int fedCh, float current_val)
void fill_fed_channel (int modId, float qty)
void fill_fed_channel (int fedId, int fedCh, float qty)
void fillc (int layer, int ring, int nmod, int red, int green, int blue)
void fillc (int idmod, int red, int green, int blue)
void fillc (int idmod, int RGBcode)
void fillc_fed_channel (int fedId, int fedCh, int red, int green, int blue)
int find_layer (int ix, int iy)
std::ifstream * findfile (std::string filename)
int getcolor (float value, int palette)
int getlayerCount (int subdet, int partdet)
int getmoduleCount (int subdet, int partdet, int layer, int ring)
int getNumMod ()
int getringCount (int subdet, int partdet, int layer)
int getxsize ()
int getysize ()
void init ()
string layername (int layer)
int module (int fedId, int fedCh)
int nlayer (int det, int part, int lay)
double phival (double x, double y)
void print (bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap")
void printall (bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap")
void printlayers (bool print_total=true, float minval=0., float maxval=0., std::string s="layer")
void printonline ()
void save (bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
void save_as_fedtrackermap (bool print_total=true, float minval=0., float maxval=0., std::string s="fed_svgmap.svg", int width=1500, int height=800)
void setPalette (int numpalette)
void setText (int layer, int ring, int nmod, string s)
void setText (int idmod, std::string s)
void showPalette (bool printflag1)
 TrackerMap (const edm::ParameterSet &iConfig, const edm::ESHandle< SiStripFedCabling > tkFed)
 TrackerMap (const edm::ParameterSet &iConfig)
 TrackerMap (std::string s=" ", int xsize1=340, int ysize1=200)
double xdpixel (double x)
double xdpixelc (double x)
double ydpixel (double y)
double ydpixelc (double y)
 ~TrackerMap ()
 default destructor

Static Public Member Functions

static bool isRingStereo (int key)
static int layerno (int subdet, int leftright, int layer)

Public Attributes

SvgApvPair apvMap
ModApvPair apvModuleMap
bool enableFedProcessing
SvgFed fedMap
int firstRing [43]
ImoduleMap imoduleMap
std::string infilename
std::string jsfilename
std::string jsPath
int ndet
int npart
int ntotRing [43]
int palette
bool printflag
bool psetAvailable
SmoduleMap smoduleMap
string title

Protected Attributes

bool firstcall
int ix
int iy
std::ifstream * jsfile
float maxvalue
float minvalue
int ncrate
int ncrates
int nlay
int number_modules
bool posrel
std::ofstream * savefile
std::ofstream * svgfile
bool temporary_file
double xmax
double xmin
int xsize
double ymax
double ymin
int ysize

Private Attributes

float oldz
bool saveAsSingleLayer


Detailed Description

Definition at line 20 of file TrackerMap.h.


Member Typedef Documentation

typedef std::map<const int , TmModule *> TrackerMap::ImoduleMap

Definition at line 61 of file TrackerMap.h.

typedef std::multimap<const int , TmApvPair*> TrackerMap::ModApvPair

Definition at line 65 of file TrackerMap.h.

typedef std::map<const int , TmModule *> TrackerMap::SmoduleMap

Definition at line 58 of file TrackerMap.h.

typedef std::map<const int , TmApvPair*> TrackerMap::SvgApvPair

Definition at line 63 of file TrackerMap.h.

typedef std::map<const int , int> TrackerMap::SvgFed

Definition at line 67 of file TrackerMap.h.


Constructor & Destructor Documentation

TrackerMap::TrackerMap ( std::string  s = " ",
int  xsize1 = 340,
int  ysize1 = 200 
)

TrackerMap::TrackerMap ( const edm::ParameterSet iConfig  ) 

Definition at line 120 of file TrackerMap.cc.

References GenMuonPlsPt100GeV_cfg::cout, enableFedProcessing, lat::endl(), edm::ParameterSet::exists(), edm::ParameterSet::getUntrackedParameter(), infilename, init(), jsfilename, ncrates, psetAvailable, saveAsSingleLayer, title, xsize, and ysize.

00120                                                         {
00121  psetAvailable=true;
00122   xsize=340;ysize=200;
00123   title=" ";
00124   jsfilename="CommonTools/TrackerMap/data/trackermap.txt";
00125   infilename="CommonTools/TrackerMap/data/tracker.dat";
00126   enableFedProcessing=false;ncrates=0;
00127   saveAsSingleLayer=false;
00128   if(tkmapPset.exists("trackermaptxtPath")){
00129   jsfilename=tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath","")+"trackermap.txt";
00130   cout << jsfilename << endl;
00131   infilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"tracker.dat";
00132   cout << infilename << endl;
00133   } else cout << "no parameters found" << endl;
00134  init();
00135 }

TrackerMap::TrackerMap ( const edm::ParameterSet iConfig,
const edm::ESHandle< SiStripFedCabling tkFed 
)

Definition at line 25 of file TrackerMap.cc.

References apvMap, apvModuleMap, TmModule::capvids, GenMuonPlsPt100GeV_cfg::cout, TmApvPair::crate, enableFedProcessing, lat::endl(), edm::ParameterSet::exists(), fedMap, TmApvPair::getFedCh(), TmApvPair::getFedId(), edm::ParameterSet::getUntrackedParameter(), TmModule::idex, TmApvPair::idex, imoduleMap, infilename, init(), sistrip::invalid32_, sistrip::invalid_, jsfilename, jsPath, getDQMSummary::key, mod(), TmApvPair::mod, TmApvPair::mpos, TmModule::name, ncrates, psetAvailable, s, saveAsSingleLayer, TmApvPair::text, title, xsize, and ysize.

00025                                                                                                    {
00026 
00027  psetAvailable=true;
00028   xsize=340;ysize=200;
00029   title=" ";
00030   jsPath="";
00031   jsfilename="CommonTools/TrackerMap/data/trackermap.txt";
00032   infilename="CommonTools/TrackerMap/data/tracker.dat";
00033   saveAsSingleLayer=false;
00034   if(tkmapPset.exists("trackermaptxtPath")){
00035   jsPath=tkmapPset.getUntrackedParameter<std::string>("trackermaptxtPath",""
00036 );
00037   jsfilename=jsPath+"trackermap.txt";
00038   cout << jsfilename << endl;
00039   infilename=tkmapPset.getUntrackedParameter<std::string>("trackerdatPath","")+"tracker.dat";
00040   cout << infilename << endl;
00041   ncrates=0;
00042   enableFedProcessing=tkmapPset.getUntrackedParameter<bool>("loadFedCabling",false);
00043   } else cout << "no parameters found" << endl;
00044 
00045  init();
00046 // Now load fed cabling information
00047  if(enableFedProcessing){
00048  const vector<unsigned short> feds = tkFed->feds();
00049   cout<<"SiStripFedCabling has "<< feds.size()<<" active FEDS"<<endl;
00050     int num_board=0;
00051     int num_crate;
00052   for(vector<unsigned short>::const_iterator ifed = feds.begin();ifed<feds.end();ifed++){
00053     const std::vector<FedChannelConnection> theconn = tkFed->connections( *ifed );
00054     int num_conn=0;
00055     for(std::vector<FedChannelConnection>::const_iterator iconn = theconn.begin();iconn<theconn.end();iconn++){
00056 
00057       if( iconn->fedId()== sistrip::invalid_    ||  
00058           iconn->detId() == sistrip::invalid_   ||  
00059           iconn->detId() == sistrip::invalid32_ ||  
00060           iconn->apvPairNumber() == sistrip::invalid_  ||
00061           iconn->nApvPairs() == sistrip::invalid_ ) {
00062         continue;
00063       }
00064         
00065       TmModule *imod = imoduleMap[iconn->detId()];
00066       int key = iconn->fedId()*1000+iconn->fedCh();
00067       TmApvPair* apvpair = apvMap[key];
00068       if(apvpair!=0)cout << "Fed "<< iconn->fedId() << " channel " << iconn->fedCh() << " seem to be already loaded!"<<endl;
00069       else
00070         {
00071           num_conn++;
00072           if(num_conn==1){
00073             if(fedMap[iconn->fedId()]==0){num_crate=num_board/18+1;fedMap[iconn->fedId()]=num_crate;num_board++;}
00074           }
00075           apvpair = new TmApvPair(key,num_crate);
00076           apvpair->mod=imod;
00077           apvpair->mpos=iconn->apvPairNumber();
00078           apvMap[key] = apvpair;        
00079           apvModuleMap.insert(make_pair(iconn->detId(),apvpair));
00080           stringstream s;
00081           iconn->print(s);  
00082           apvpair->text=s.str();
00083         }
00084     }
00085   }
00086   ncrates=num_crate;
00087   cout << num_crate << " crates used "<< endl;
00088 //Now add APv information to module name
00089     std::map<int , TmModule *>::iterator i_mod;
00090     for( i_mod=imoduleMap.begin();i_mod !=imoduleMap.end(); i_mod++){
00091       TmModule *  mod= i_mod->second;
00092       if(mod!=0) {
00093        ostringstream outs,outs1;
00094        outs << " connected to ";
00095        outs1 << "(";
00096 
00097       int idmod=mod->idex;
00098        int nchan=0;
00099        multimap<const int, TmApvPair*>::iterator pos;
00100        for (pos = apvModuleMap.lower_bound(idmod);
00101          pos != apvModuleMap.upper_bound(idmod); ++pos) {
00102        TmApvPair* apvpair = pos->second;
00103        if(apvpair!=0){
00104        outs << apvpair->mpos << " " <<apvpair->getFedId() << "/"<<apvpair->getFedCh()<<" ";
00105        outs1 << apvpair->idex+apvpair->crate*1000000<<",";
00106       nchan++;
00107     }
00108 
00109   }
00110        outs<< "("<<nchan<<")";
00111       mod->name=mod->name + outs.str(); 
00112       string s = outs1.str(); s.erase(s.end()-1,s.end());
00113       mod->capvids=s+")";
00114   }
00115   }
00116 }
00117 }

TrackerMap::~TrackerMap (  ) 

default destructor

Definition at line 196 of file TrackerMap.cc.

00196                         {
00197 }


Member Function Documentation

void TrackerMap::build (  ) 

Definition at line 1013 of file TrackerMap.cc.

References TmModule::count, GenMuonPlsPt100GeV_cfg::cout, dummys, TmModule::idex, imoduleMap, in, TreeToEdges::infile, infilename, TmModule::length, name, TmModule::name, number_modules, TmModule::posx, TmModule::posy, TmModule::posz, TmModule::setUsed(), smoduleMap, TmModule::thickness, TmModule::value, TmModule::width, width, and TmModule::widthAtHalfLength.

Referenced by init().

01013                       {
01014   //  ifstream* infile;
01015 
01016   int nmods, pix_sil, fow_bar, ring, nmod, layer;
01017   unsigned int idex;
01018   float posx, posy, posz, length, width, thickness, widthAtHalfLength;
01019   int iModule=0,old_layer=0, ntotMod =0;
01020   string name,dummys;
01021   ifstream infile(edm::FileInPath(infilename).fullPath().c_str(),ios::in);
01022   while(!infile.eof()) {
01023     infile >> nmods >> pix_sil >> fow_bar >> layer >> ring >> nmod >> posx >> posy
01024            >> posz>> length >> width >> thickness
01025            >> widthAtHalfLength >> idex ;
01026     getline(infile,dummys); //necessary to reach end of record
01027     getline(infile,name); 
01028     if(old_layer!=layer){old_layer=layer;iModule=0;}
01029     iModule++;
01030     ntotMod++;
01031     int key=layer*100000+ring*1000+nmod;
01032     TmModule * mod = smoduleMap[key];
01033     
01034     imoduleMap[idex]=mod;
01035 
01036     if(mod==0) cout << "error in module "<<key <<endl;
01037     else
01038       {
01039           mod->posx = posx;
01040           mod->posy = posy;
01041           mod->setUsed();
01042           mod->value=0;
01043           mod->count=0;
01044           mod->posz = posz;
01045           mod->length = length;
01046           mod->width = width;
01047           mod->thickness = thickness;
01048           mod->widthAtHalfLength = widthAtHalfLength;
01049           mod->idex = idex;
01050           mod->name = name;
01051       }
01052   }
01053   infile.close();
01054   number_modules = ntotMod-1;
01055 }

void TrackerMap::defcwindow ( int  num_crate  )  [inline]

Definition at line 169 of file TrackerMap.h.

References ix, iy, ncrate, xmax, xmin, xsize, ymax, ymin, and ysize.

Referenced by save_as_fedtrackermap().

00169                                  {
00170     ncrate = num_crate;
00171     int xoffset=xsize/3;
00172     int yoffset=ysize;
00173     xmin=-1.;xmax=63.;  ymin = -1.; ymax=37.;
00174     if((ncrate%3)==2)ix = xoffset+xsize*4/3;
00175     if((ncrate%3)==1)ix = xoffset+2*xsize*4/3;
00176     if((ncrate%3)==0)ix = xoffset;
00177     iy = yoffset+((ncrate-1)/3)*ysize*2;
00178   } 

void TrackerMap::defwindow ( int  num_lay  )  [inline]

Definition at line 179 of file TrackerMap.h.

References int, ix, iy, nlay, posrel, xmax, xmin, xsize, ymax, ymin, and ysize.

Referenced by VisTrackerMap::paintEvent(), save(), and VisTrackerMap::VisTrackerMap().

00179                            {
00180   nlay = num_lay;
00181   if(posrel){ // separated modules
00182     xmin=-2.;ymin=-2.;xmax=2.;ymax=2.;
00183     if(nlay >12 && nlay < 19){
00184       xmin=-.40;xmax=.40;ymin=-.40;ymax=.40;
00185     }
00186     if(nlay>30){
00187       xmin=-0.1;xmax=3.;ymin=-0.1;ymax=8.5;
00188       if(nlay<34){xmin=-0.3;xmax=1.0;}
00189       if(nlay>33&&nlay<38){xmax=2.0;}
00190       if(nlay>37){ymax=8.;}//inner
00191     }
00192   }else{ //overlayed modules
00193     xmin=-1.3;ymin=-1.3;xmax=1.3;ymax=1.3;
00194     if(nlay >12 && nlay < 19){
00195       xmin=-.20;xmax=.20;ymin=-.20;ymax=.20;
00196     }
00197     if(nlay>30){
00198       xmin=-1.5;xmax=1.5;ymin=-1.;ymax=28.;
00199       if(nlay<34){xmin=-0.5;xmax=0.5;}
00200       if(nlay>33&&nlay<38){xmin=-1.;xmax=1.;}
00201     }
00202     
00203   }
00204   if(nlay<16){
00205       ix=0;iy=(15-nlay)*ysize;}
00206   if(nlay>15&&nlay<31){
00207     ix=3*xsize;iy=(nlay-16)*ysize;}
00208   if(nlay>30){
00209     if(nlay==31){ix=(int)(1.5*xsize);iy=0;}
00210     if(nlay>31 && nlay%2==0){int il=(nlay-30)/2;ix=xsize;iy=il*2*ysize;}
00211     if(nlay>31 && nlay%2!=0){int il=(nlay-30)/2;ix=2*xsize;iy=il*2*ysize;}
00212   }
00213  }

void TrackerMap::drawApvPair ( int  crate,
int  numfed_incrate,
bool  total,
TmApvPair apvPair,
std::ofstream *  file,
bool  useApvPairValue 
)

Referenced by save_as_fedtrackermap().

void TrackerMap::drawModule ( TmModule mod,
int  key,
int  layer,
bool  total,
std::ofstream *  file 
)

Referenced by save().

void TrackerMap::drawPalette ( std::ofstream *  file  ) 

Referenced by save(), and save_as_fedtrackermap().

void TrackerMap::fill ( int  idmod,
float  qty 
)

Definition at line 970 of file TrackerMap.cc.

References TmModule::count, GenMuonPlsPt100GeV_cfg::cout, imoduleMap, and TmModule::value.

00970                                           {
00971 
00972   TmModule * mod = imoduleMap[idmod];
00973   if(mod!=0){
00974     mod->value=mod->value+qty;
00975     mod->count++;
00976     return;
00977   }
00978   cout << "**************************error in fill method **************";
00979 }

void TrackerMap::fill ( int  layer,
int  ring,
int  nmod,
float  x 
)

Definition at line 981 of file TrackerMap.cc.

References TmModule::count, GenMuonPlsPt100GeV_cfg::cout, smoduleMap, and TmModule::value.

Referenced by SiStripCablingTrackerMap::analyze(), TmTestWidget::TmTestWidget(), and cms::ClusterAnalysis::trackStudy().

00981                                                               {
00982 
00983   int key = layer*100000+ring*1000+nmod;
00984   TmModule * mod = smoduleMap[key];
00985   if(mod!=0){
00986      mod->value=mod->value+qty;
00987      mod->count++;
00988   }
00989   else cout << "**************************error in SvgModuleMap **************";
00990 } 

void TrackerMap::fill_current_val ( int  idmod,
float  current_val 
)

Definition at line 963 of file TrackerMap.cc.

References GenMuonPlsPt100GeV_cfg::cout, imoduleMap, and TmModule::value.

00963                                                               {
00964 
00965   TmModule * mod = imoduleMap[idmod];
00966   if(mod!=0)  mod->value=current_val;
00967   else cout << "**error in fill_current_val method ***";
00968 }

void TrackerMap::fill_current_val_fed_channel ( int  fedId,
int  fedCh,
float  current_val 
)

Definition at line 911 of file TrackerMap.cc.

References apvMap, GenMuonPlsPt100GeV_cfg::cout, and TmApvPair::value.

00912 {
00913   int key = fedId*1000+fedCh;
00914   TmApvPair* apvpair = apvMap[key];
00915   
00916   if(apvpair!=0)  apvpair->value=current_val;
00917   else 
00918     cout << "*** error in FedTrackerMap fill_current_val method ***";
00919 }

void TrackerMap::fill_fed_channel ( int  modId,
float  qty 
)

Definition at line 896 of file TrackerMap.cc.

References apvModuleMap, TmApvPair::count, GenMuonPlsPt100GeV_cfg::cout, and TmApvPair::value.

00897 {
00898   multimap<const int, TmApvPair*>::iterator pos;
00899   for (pos = apvModuleMap.lower_bound(idmod);
00900          pos != apvModuleMap.upper_bound(idmod); ++pos) {
00901   TmApvPair* apvpair = pos->second;
00902   if(apvpair!=0){
00903     apvpair->value=apvpair->value+qty;
00904     apvpair->count++;
00905   }
00906   }
00907     return;
00908   cout << "*** error in FedTrackerMap fill by module method ***";
00909   }

void TrackerMap::fill_fed_channel ( int  fedId,
int  fedCh,
float  qty 
)

Definition at line 931 of file TrackerMap.cc.

References apvMap, TmApvPair::count, GenMuonPlsPt100GeV_cfg::cout, and TmApvPair::value.

00932 {
00933   int key = fedId*1000+fedCh;
00934   TmApvPair* apvpair = apvMap[key];
00935   if(apvpair!=0){
00936     apvpair->value=apvpair->value+qty;
00937     apvpair->count++;
00938     return;
00939   }
00940   cout << "*** error inFedTrackerMap fill method ***";
00941 }

void TrackerMap::fillc ( int  layer,
int  ring,
int  nmod,
int  red,
int  green,
int  blue 
)

Definition at line 951 of file TrackerMap.cc.

References TmModule::blue, GenMuonPlsPt100GeV_cfg::cout, TmModule::green, TmModule::red, and smoduleMap.

00951                                                                                    {
00952   
00953   int key = layer*10000+ring*1000+nmod;
00954   TmModule * mod = smoduleMap[key];
00955 
00956   if(mod!=0){
00957      mod->red=red; mod->green=green; mod->blue=blue;
00958     return;
00959   }
00960   cout << "**************************error in fill method **************";
00961 }

void TrackerMap::fillc ( int  idmod,
int  red,
int  green,
int  blue 
)

Definition at line 942 of file TrackerMap.cc.

References TmModule::blue, GenMuonPlsPt100GeV_cfg::cout, TmModule::green, imoduleMap, and TmModule::red.

00942                                                                {
00943 
00944   TmModule * mod = imoduleMap[idmod];
00945   if(mod!=0){
00946      mod->red=red; mod->green=green; mod->blue=blue;
00947     return;
00948   }
00949   cout << "**************************error in fill method **************";
00950 }

void TrackerMap::fillc ( int  idmod,
int  RGBcode 
) [inline]

Definition at line 41 of file TrackerMap.h.

Referenced by SiStripQualityStatistics::analyze(), and SiStripQualityStatistics::SetBadComponents().

00041 {fillc(idmod,(RGBcode>>16) & 0xFF , (RGBcode>>8) & 0xFF, RGBcode & 0xFF);}

void TrackerMap::fillc_fed_channel ( int  fedId,
int  fedCh,
int  red,
int  green,
int  blue 
)

Definition at line 884 of file TrackerMap.cc.

References apvMap, TmApvPair::blue, GenMuonPlsPt100GeV_cfg::cout, TmApvPair::green, and TmApvPair::red.

00885 {
00886   int key = fedId*1000+fedCh;
00887   TmApvPair* apvpair = apvMap[key];
00888   
00889   if(apvpair!=0){
00890     apvpair->red=red; apvpair->green=green; apvpair->blue=blue;
00891     return;
00892   }
00893   cout << "*** error in FedTrackerMap fillc method ***";
00894 }

int TrackerMap::find_layer ( int  ix,
int  iy 
) [inline]

Definition at line 92 of file TrackerMap.h.

References xsize, and ysize.

Referenced by VisTrackerMap::mousePressEvent().

00093     {
00094       int add;
00095       int layer=0;
00096       if(iy <= xsize){//endcap+z
00097         add = 15;
00098         layer = ix/ysize;
00099         layer = layer+add+1;
00100       }
00101       if(iy > xsize && iy< 3*xsize){//barrel
00102         add=30;
00103         if(ix < 2*ysize){
00104           layer=1;
00105         }else {
00106           layer = ix/(2*ysize);
00107           if(iy < 2*xsize)layer=layer*2+1; else layer=layer*2;
00108         }
00109         layer = layer+add;
00110       }
00111       if(iy >= 3*xsize){        //endcap-z
00112         layer = ix/ysize;
00113         layer = 15-layer;
00114       }
00115       return layer;  
00116     }

std::ifstream* TrackerMap::findfile ( std::string  filename  ) 

Referenced by printonline().

int TrackerMap::getcolor ( float  value,
int  palette 
)

Definition at line 1056 of file TrackerMap.cc.

References int, maxvalue, minvalue, and x.

01056                                                {
01057    int red,green,blue;
01058    if(palette==1){//palette1 1 - raibow
01059    float delta=(maxvalue-minvalue);
01060    float x =(value-minvalue);
01061    red = (int) ( x<(delta/2) ? 0 : ( x > ((3./4.)*delta) ?  255 : 255/(delta/4) * (x-(2./4.)*delta)  ) );
01062    green= (int) ( x<delta/4 ? (x*255/(delta/4)) : ( x > ((3./4.)*delta) ?  255-255/(delta/4) *(x-(3./4.)*delta) : 255 ) );
01063    blue = (int) ( x<delta/4 ? 255 : ( x > ((1./2.)*delta) ?  0 : 255-255/(delta/4) * (x-(1./4.)*delta) ) );
01064      }
01065      if (palette==2){//palette 2 yellow-green
01066      green = (int)((value-minvalue)/(maxvalue-minvalue)*256.);
01067          if (green > 255) green=255;
01068          red = 255; blue=0;green=255-green;  
01069         } 
01070    return(blue|(green<<8)|(red<<16));
01071 }

int TrackerMap::getlayerCount ( int  subdet,
int  partdet 
) [inline]

Definition at line 118 of file TrackerMap.h.

Referenced by init().

00118                                             {
00119     int ncomponent=0;
00120     if(subdet == 1){ //1=pixel
00121       if(partdet == 1 || partdet == 3){ //1-3=encap
00122         ncomponent = 3;
00123       }
00124       else { ncomponent = 3; } //barrel
00125     }
00126     if(subdet== 2){ //2=inner silicon
00127       if(partdet == 1 || partdet == 3){ //1-3=encap
00128         ncomponent = 3;
00129       }
00130       else { ncomponent = 4; } //barrel
00131     }
00132     if(subdet== 3){ //3=outer silicon
00133       if(partdet == 1 || partdet == 3){ //1-3=encap
00134         ncomponent = 9;
00135       }
00136       else { ncomponent = 6; } //barrel
00137     }
00138     return(ncomponent);
00139   }   

int TrackerMap::getmoduleCount ( int  subdet,
int  partdet,
int  layer,
int  ring 
) [inline]

Definition at line 248 of file TrackerMap.h.

Referenced by init().

00248                                                                   {
00249     int ncomponent=0;
00250     int spicchif[] ={24,24,40,56,40,56,80};
00251     int spicchib[] ={20,32,44,30,38,46,56,42,48,54,60,66,74};
00252     int numero_layer = 0;
00253     
00254     if(partdet == 2){ //barrel
00255       numero_layer = layer-1;
00256       if(subdet== 2){ //inner
00257         numero_layer = numero_layer+3;
00258       }
00259       if(subdet == 3){ //outer
00260         numero_layer = numero_layer+7;
00261       }
00262       ncomponent = spicchib[numero_layer];
00263     }
00264     if(partdet!= 2){ //endcap
00265       if(subdet== 1)ncomponent=24;//pixel
00266       else
00267         ncomponent = spicchif[ring-1];
00268     }
00269     return(ncomponent);
00270   }

int TrackerMap::getNumMod (  )  [inline]

Definition at line 58 of file TrackerMap.h.

Referenced by VisTrackerMap::VisTrackerMap().

00058 {return number_modules;};

int TrackerMap::getringCount ( int  subdet,
int  partdet,
int  layer 
) [inline]

Definition at line 215 of file TrackerMap.h.

Referenced by init().

00215                                                       {
00216     int ncomponent=0;
00217     if(subdet== 1){ //1=pixel
00218       if(partdet== 1 || partdet== 3){ //end-cap
00219         ncomponent = 7;
00220       }
00221       else{ncomponent = 8;} //barrel
00222     }   
00223     if(subdet== 2){ //inner-silicon
00224       if(partdet== 1 || partdet== 3){ //end-cap
00225         ncomponent = 3;
00226       }
00227       else{ncomponent = 12;} //barrel
00228     }
00229     if(subdet== 3){ //outer-silicon
00230       if(partdet== 1){ //end-cap-z
00231         if (layer== 1) ncomponent = 4;
00232         if (layer== 2 || layer== 3) ncomponent = 5;
00233         if (layer== 4 || layer== 5 || layer== 6) ncomponent = 6;
00234         if (layer== 7 || layer== 8 || layer== 9) ncomponent = 7;
00235       }
00236       if(partdet== 3){ //endcap+z
00237         if (layer== 9) ncomponent = 4;
00238         if (layer== 8 || layer== 7) ncomponent = 5;
00239         if (layer== 6 || layer== 5 || layer== 4) ncomponent = 6;
00240         if (layer== 3 || layer== 2 || layer== 1) ncomponent = 7;
00241       }
00242       if(partdet== 2){ //barrel
00243         ncomponent = 12;
00244       }
00245     }
00246     return(ncomponent);
00247   }

int TrackerMap::getxsize (  )  [inline]

Definition at line 54 of file TrackerMap.h.

References xsize.

00054 {return xsize;};

int TrackerMap::getysize (  )  [inline]

Definition at line 55 of file TrackerMap.h.

References ysize.

00055 {return ysize;};

void TrackerMap::init ( void   ) 

Definition at line 148 of file TrackerMap.cc.

References build(), firstcall, firstRing, getlayerCount(), getmoduleCount(), getringCount(), isRingStereo(), ix, iy, getDQMSummary::key, maxvalue, minvalue, ndet, nlayer(), npart, ntotRing, palette, posrel, printflag, smoduleMap, and temporary_file.

Referenced by TrackerMap().

00148                       {
00149   
00150   int ntotmod=0;
00151   ix=0;iy=0; //used to compute the place of each layer in the tracker map
00152   firstcall = true;
00153   minvalue=0.; maxvalue=minvalue;
00154   posrel=true;
00155   palette = 1;
00156   printflag=false;
00157   temporary_file=false;
00158 
00159   ndet = 3; // number of detectors: pixel, inner silicon, outer silicon
00160   npart = 3; // number of detector parts: endcap -z, barrel, endcap +z
00161 
00162   //allocate module map
00163   for (int subdet=1; subdet < ndet+1; subdet++){//loop on subdetectors
00164     for (int detpart=1; detpart < npart+1; detpart++){//loop on subdetectors parts
00165       int nlayers = getlayerCount(subdet,detpart); // compute number of layers
00166       for(int layer=1; layer < nlayers+1; layer++){//loop on layers
00167         int nrings = getringCount(subdet,detpart,layer);// compute number of rings
00168         //fill arrays used to do the loop on the rings  
00169         int layer_g = nlayer(subdet,detpart,layer);
00170         ntotRing[layer_g-1]=nrings;
00171         firstRing[layer_g-1]=1;
00172         if(subdet==3 && detpart!=2)  firstRing[layer_g-1]= 8-nrings; //special numbering for TEC 
00173         for (int ring=firstRing[layer_g-1]; ring < ntotRing[layer_g-1]+firstRing[layer_g-1];ring++){//loop on rings
00174           int nmodules = getmoduleCount(subdet,detpart,layer,ring);// compute number of modules
00175           int key;
00176           TmModule *smodule; 
00177           for(int module=1; module < nmodules+1; module++){//loop on modules
00178             smodule = new TmModule(module,ring,layer_g);
00179             key=layer_g*100000+ring*1000+module;//key identifying module
00180             smoduleMap[key]=smodule;
00181             ntotmod++;
00182           }
00183           if(isRingStereo(key))for(int module=1; module < nmodules+1; module++){//loop on stereo modules
00184             smodule = new TmModule(module+100,ring,layer_g);
00185             int key=layer_g*100000+ring*1000+module+100;
00186             smoduleMap[key]=smodule;
00187             ntotmod++;
00188           }
00189         }
00190       }
00191     }
00192   }
00193  build();
00194 }

static bool TrackerMap::isRingStereo ( int  key  )  [inline, static]

Definition at line 283 of file TrackerMap.h.

Referenced by SiPixelTrackerMap::drawModule(), init(), and VisTrackerMap::visDrawModule().

00283                                    {
00284     int layer=key/100000;
00285     int ring = key - layer*100000;
00286     ring = ring/1000;
00287     if(layer==34 || layer==35 || layer==38 || layer==39) return true;
00288     if(layer<13 || (layer>18&&layer<31))
00289       if(ring==1 || ring==2 || ring==5)return true;
00290     return false;
00291   }

string TrackerMap::layername ( int  layer  )  [inline]

Definition at line 305 of file TrackerMap.h.

References s.

00305                              {
00306     string s= " ";
00307     ostringstream ons;
00308     
00309     if(layer < 10) ons << "TEC -z Layer " << layer;
00310     if(layer < 13 && layer > 9) ons << "TID -z Layer " << layer-9;
00311     if(layer < 16 && layer > 12) ons << "FPIX -z Layer " << layer-12;
00312     if(layer < 19 && layer > 15) ons << "FPIX +z Layer " << layer-15;
00313     if(layer < 22 && layer > 18) ons << "TID +z Layer " << layer-18;
00314     if(layer < 31 && layer > 21) ons << "TEC +z Layer " << layer-21;
00315     if(layer < 34 && layer > 30) ons << "TPB Layer " << layer-30;
00316     if(layer < 38 && layer > 33) ons << "TIB Layer " << layer-33;
00317     if(layer > 37) ons << "TOB Layer " << layer-37;
00318     s = ons.str(); 
00319     return s;  
00320   }

static int TrackerMap::layerno ( int  subdet,
int  leftright,
int  layer 
) [inline, static]

Definition at line 271 of file TrackerMap.h.

00271                                                         {
00272     if(subdet==6&&leftright==1)return(10-layer);
00273     if(subdet==6&&leftright==2)return(layer+21);
00274     if(subdet==4&&leftright==1)return(4-layer+9);
00275     if(subdet==4&&leftright==2)return(layer+18);
00276     if(subdet==2&&leftright==1)return(4-layer+12);
00277     if(subdet==2&&leftright==2)return(layer+15);
00278     if(subdet==1)return(layer+30);
00279     if(subdet==3)return(layer+33);
00280     if(subdet==5)return(layer+37);
00281   }

int TrackerMap::module ( int  fedId,
int  fedCh 
)

Definition at line 921 of file TrackerMap.cc.

References apvMap, GenMuonPlsPt100GeV_cfg::cout, TmModule::idex, and TmApvPair::mod.

00922 {
00923   int key = fedId*1000+fedCh;
00924   TmApvPair* apvpair = apvMap[key];
00925   if(apvpair!=0){
00926     return(apvpair->mod->idex);
00927   }
00928   return(0);
00929   cout << "*** error in FedTrackerMap module method ***";
00930 }

int TrackerMap::nlayer ( int  det,
int  part,
int  lay 
) [inline]

Definition at line 292 of file TrackerMap.h.

Referenced by init().

00292                                       {
00293     if(det==3 && part==1) return lay;
00294     if(det==2 && part==1) return lay+9;
00295     if(det==1 && part==1) return lay+12;
00296     if(det==1 && part==3) return lay+15;
00297     if(det==2 && part==3) return lay+18;
00298     if(det==3 && part==3) return lay+21;
00299     if(det==1 && part==2) return lay+30;
00300     if(det==2 && part==2) return lay+33;
00301     if(det==3 && part==2) return lay+37;
00302     return -1; 
00303   }

double TrackerMap::phival ( double  x,
double  y 
) [inline]

Definition at line 78 of file TrackerMap.h.

References phi.

Referenced by SiPixelTrackerMap::drawModule(), and VisTrackerMap::visDrawModule().

00078                                    {
00079     double phi;
00080     double phi1=atan(y/x);
00081     phi = phi1;
00082     if(y<0. && x>0) phi = phi1+2.*M_PI;
00083     if(x<0.)phi=phi1+M_PI;
00084     if(fabs(y)<0.000001 && x>0)phi=0;
00085     if(fabs(y)<0.000001&&x<0)phi=M_PI;
00086     if(fabs(x)<0.000001&&y>0)phi=M_PI/2.;
00087     if(fabs(x)<0.000001&&y<0)phi=3.*M_PI/2.;
00088       
00089     return phi;
00090   }

void TrackerMap::print ( bool  print_total = true,
float  minval = 0.,
float  maxval = 0.,
std::string  s = "svgmap" 
)

Referenced by SiStripQualityStatistics::analyze(), SiStripCablingTrackerMap::endJob(), and cms::ClusterAnalysis::endJob().

void TrackerMap::printall ( bool  print_total = true,
float  minval = 0.,
float  maxval = 0.,
std::string  s = "svgmap" 
)

void TrackerMap::printlayers ( bool  print_total = true,
float  minval = 0.,
float  maxval = 0.,
std::string  s = "layer" 
)

Referenced by printonline().

void TrackerMap::printonline (  ) 

Definition at line 1072 of file TrackerMap.cc.

References apvMap, apvModuleMap, enableFedProcessing, fedMap, findfile(), TmApvPair::getFedCh(), TmApvPair::getFedId(), TmModule::idex, TmApvPair::idex, TmApvPair::mod, TmModule::name, ncrates, TmModule::notInUse(), ntotRing, out, printlayers(), save(), save_as_fedtrackermap(), smoduleMap, temporary_file, and TmApvPair::text.

Referenced by SiStripTrackerMapCreator::create().

01072                             {
01073 //Copy interface
01074   std::ofstream * ofilename;
01075   std::ifstream * ifilename;
01076   std::ostringstream ofname;
01077   std::string ifname;
01078   string line;
01079   bool print_total = true;
01080   float minval = 0.;
01081   float maxval = 0.;
01082   string outputfilename="dqmtmap";
01083   ifilename=findfile("viewerHeader.xhtml");
01084   ofname << outputfilename << "viewer.xhtml";
01085   ofilename = new ofstream(ofname.str().c_str(),ios::out);
01086   while (getline( *ifilename, line )) { *ofilename << line << endl; }
01087 *ofilename <<"    var tmapname=\"" <<outputfilename << "\""<<endl;
01088 *ofilename <<"    var ncrates=" <<ncrates << ";"<<endl;
01089   ifilename=findfile("viewerTrailer.xhtml");
01090   while (getline( *ifilename, line )) { *ofilename << line << endl; }
01091   ofname.str("");
01092   ifilename=findfile("viewer.css");
01093   ofname <<  "viewer.css";
01094   ofilename = new ofstream(ofname.str().c_str(),ios::out);
01095   while (getline( *ifilename, line )) { *ofilename << line << endl; }
01096   ofname.str("");
01097   ifilename=findfile("viewer.js");
01098   ofname << "viewer.js";
01099   ofilename = new ofstream(ofname.str().c_str(),ios::out);
01100   while (getline( *ifilename, line )) { *ofilename << line << endl; }
01101   ofname.str("");
01102   ifilename=findfile("crate.js");
01103   ofname <<  "crate.js";
01104   ofilename = new ofstream(ofname.str().c_str(),ios::out);
01105   while (getline( *ifilename, line )) { *ofilename << line << endl; }
01106   ofname.str("");
01107   ifilename=findfile("layer.js");
01108   ofname <<  "layer.js";
01109   ofilename = new ofstream(ofname.str().c_str(),ios::out);
01110   while (getline( *ifilename, line )) { *ofilename << line << endl; }
01111   
01112     ostringstream outs,outs1,outs2;
01113     outs << outputfilename<<".png";
01114 save(true,0.,0.,outs.str(),3000,1600);
01115 temporary_file=false;
01116 printlayers(true,0.,0.,outputfilename);
01117 
01118 //Now print a text file for each layer 
01119   ofstream * txtfile;
01120 for (int layer=1; layer < 44; layer++){
01121     ostringstream outs;
01122     outs << outputfilename <<"layer"<<layer<< ".html";
01123     txtfile = new ofstream(outs.str().c_str(),ios::out);
01124     *txtfile << "<html><head></head> <body>" << endl;
01125     for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
01126       for (int module=1;module<200;module++) {
01127         int key=layer*100000+ring*1000+module;
01128         TmModule * mod = smoduleMap[key];
01129         if(mod !=0 && !mod->notInUse()){
01130             int idmod=mod->idex;
01131             int nchan=0;
01132             *txtfile  << "<a name="<<idmod<<"><pre>"<<endl;
01133              multimap<const int, TmApvPair*>::iterator pos;
01134              for (pos = apvModuleMap.lower_bound(idmod);
01135                 pos != apvModuleMap.upper_bound(idmod); ++pos) {
01136                TmApvPair* apvpair = pos->second;
01137                if(apvpair!=0){
01138                    nchan++;
01139                    *txtfile  <<  apvpair->text << endl;
01140                     }
01141 
01142                     }
01143                    *txtfile  << "</pre><h3>"<< mod->name<<"</h3>"<<endl;
01144                   }
01145                 }
01146                 }
01147     *txtfile << "</body></html>" << endl;
01148     txtfile->close();
01149                 }
01150 if(enableFedProcessing){
01151     outs1 << outputfilename<<"fed.png";
01152 save_as_fedtrackermap(true,0.,0.,outs1.str(),6000,3200);
01153     outs2 << outputfilename<<".xml";
01154 save_as_fedtrackermap(true,0.,0.,outs2.str(),3000,1600);
01155 //And a text file for each crate 
01156   std::map<int , int>::iterator i_fed;
01157   ofstream * txtfile;
01158   for (int crate=1; crate < (ncrates+1); crate++){
01159     ostringstream outs;
01160     outs << outputfilename <<"crate"<<crate<< ".html";
01161     txtfile = new ofstream(outs.str().c_str(),ios::out);
01162     *txtfile << "<html><head></head> <body>" << endl;
01163     for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
01164       if(i_fed->second == crate){
01165         int fedId = i_fed->first;
01166         for (int nconn=0;nconn<96;nconn++){
01167           int key = fedId*1000+nconn; 
01168           TmApvPair *  apvPair= apvMap[key];
01169           if(apvPair !=0){
01170             int idmod=apvPair->idex;
01171             *txtfile  << "<a name="<<idmod<<"><pre>"<<endl;
01172             *txtfile  <<  apvPair->text << endl;
01173             ostringstream outs;
01174             outs << "fedchannel "  <<apvPair->getFedId() << "/"<<apvPair->getFedCh()<<" connects to module  " << apvPair->mod->idex ;
01175             *txtfile  << "</pre><h3>"<< outs.str()<<"</h3>"<<endl;
01176              }
01177           }
01178       }
01179       }
01180     *txtfile << "</body></html>" << endl;
01181     txtfile->close();
01182                 }
01183   }
01184 }

void TrackerMap::save ( bool  print_total = true,
float  minval = 0.,
float  maxval = 0.,
std::string  s = "svgmap.svg",
int  width = 1500,
int  height = 800 
)

Definition at line 335 of file TrackerMap.cc.

References c, parsecf::pyparsing::col(), dbtoconf::command, TmModule::count, GenMuonPlsPt100GeV_cfg::cout, defwindow(), drawModule(), drawPalette(), lat::endl(), EgammaValidation_cff::filename, firstRing, i, in, maxvalue, minvalue, TmModule::notInUse(), ntotRing, out, printflag, savefile, smoduleMap, temporary_file, title, value, TmModule::value, x, and y.

Referenced by SiStripQualityStatistics::analyze(), SiStripCablingTrackerMap::endJob(), cms::ClusterAnalysis::endJob(), and printonline().

00335                                                                                                   {
00336   std::string filetype=s,outputfilename=s;
00337   vector<TPolyLine*> vp;
00338   filetype.erase(0,filetype.find(".")+1);
00339   outputfilename.erase(outputfilename.begin()+outputfilename.find("."),outputfilename.end());
00340   temporary_file=true;
00341   if(filetype=="svg")temporary_file=false;
00342 
00343   ostringstream outs;
00344   minvalue=minval; maxvalue=maxval;
00345   outs << outputfilename << ".coor";
00346   savefile = new ofstream(outs.str().c_str(),ios::out);
00347  if(!print_total){
00348   for (int layer=1; layer < 44; layer++){
00349     for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00350       for (int module=1;module<200;module++) {
00351         int key=layer*100000+ring*1000+module;
00352         TmModule * mod = smoduleMap[key];
00353         if(mod !=0 && !mod->notInUse()){
00354           mod->value = mod->value / mod->count;
00355         }
00356       }
00357     }
00358   }
00359   }
00360   if(minvalue>=maxvalue){
00361   minvalue=9999999.;
00362   maxvalue=-9999999.;
00363   for (int layer=1; layer < 44; layer++){
00364     for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00365       for (int module=1;module<200;module++) {
00366         int key=layer*100000+ring*1000+module;
00367         TmModule * mod = smoduleMap[key];
00368         if(mod !=0 && !mod->notInUse()){
00369           if (minvalue > mod->value)minvalue=mod->value;
00370           if (maxvalue < mod->value)maxvalue=mod->value;
00371         }
00372       }
00373     }
00374   }
00375 }
00376   if(!temporary_file){
00377   *savefile << "<?xml version=\"1.0\"  standalone=\"no\" ?>"<<endl;
00378   *savefile << "<svg  xmlns=\"https://www.w3.org/2000/svg\""<<endl;
00379   *savefile << "xmlns:svg=\"https://www.w3.org/2000/svg\" "<<endl;
00380   *savefile << "xmlns:xlink=\"https://www.w3.org/1999/xlink\">"<<endl;
00381   *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<endl;
00382   *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<endl;
00383   *savefile << "<svg:g id=\"tracker\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<endl;
00384    }
00385   for (int layer=1; layer < 44; layer++){
00386     nlay=layer;
00387     defwindow(nlay);
00388     for (int ring=firstRing[layer-1]; ring < ntotRing[layer-1]+firstRing[layer-1];ring++){
00389       for (int module=1;module<200;module++) {
00390         int key=layer*100000+ring*1000+module;
00391         TmModule * mod = smoduleMap[key];
00392         if(mod !=0 && !mod->notInUse()){
00393           drawModule(mod,key,layer,print_total,savefile);
00394         }
00395       }
00396     }
00397   }
00398   if(!temporary_file){
00399     *savefile << "</svg:g>"<<endl;
00400     *savefile << " <svg:text id=\"Title\" class=\"normalText\"  x=\"300\" y=\"0\">"<<title<<"</svg:text>"<<endl;
00401   }
00402   if(printflag)drawPalette(savefile);
00403   if(!temporary_file){
00404     *savefile << "</svg:svg>"<<endl;
00405     *savefile << "</svg>"<<endl;
00406   }
00407   savefile->close(); 
00408 
00409   const char * command1;
00410   string tempfilename = outputfilename + ".coor";
00411   if(filetype=="svg"){
00412     string command = "mv "+tempfilename +" " +outputfilename + ".svg";
00413     command1=command.c_str();
00414     cout << "Executing " << command1 << endl;
00415     system(command1);
00416   }
00417   if (temporary_file){ // create root trackermap image
00418     int red,green,blue,npoints,colindex,ncolor;
00419     double x[4],y[4];
00420     ifstream tempfile(tempfilename.c_str(),ios::in);
00421     TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
00422     gPad->SetFillColor(38);
00423     
00424     gPad->Range(0,0,3000,1600);
00425     
00426     //First  build palette
00427     ncolor=0;
00428     typedef std::map<int,int> ColorList;
00429     ColorList colorList;
00430     ColorList::iterator pos;
00431     TColor *col;
00432     while(!tempfile.eof()) {
00433       tempfile  >> red >> green  >> blue >> npoints; 
00434       colindex=red+green*1000+blue*1000000;
00435       pos=colorList.find(colindex); 
00436       if(pos == colorList.end()){ colorList[colindex]=ncolor+100; col =gROOT->GetColor(ncolor+100);
00437 if(col) col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.)); else TColor *c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));ncolor++;}
00438       for (int i=0;i<npoints;i++){
00439         tempfile >> x[i] >> y[i];  
00440       }
00441     }
00442     if(ncolor>0 && ncolor<10000){
00443       Int_t colors[10000];
00444       for(int i=0;i<ncolor;i++){colors[i]=i+100;}
00445       gStyle->SetPalette(ncolor,colors);
00446     }
00447     tempfile.clear();
00448     tempfile.seekg(0,ios::beg);
00449     cout << "created palette with " << ncolor << " colors" << endl;
00450     while(!tempfile.eof()) {//create polylines
00451       tempfile  >> red >> green  >> blue >> npoints; 
00452       for (int i=0;i<npoints;i++){
00453         tempfile >> x[i] >> y[i];  
00454       }
00455       colindex=red+green*1000+blue*1000000;
00456       pos=colorList.find(colindex); 
00457       if(pos != colorList.end()){
00458         TPolyLine*  pline = new TPolyLine(npoints,y,x);
00459         vp.push_back(pline);
00460         pline->SetFillColor(colorList[colindex]);
00461         pline->SetLineWidth(0);
00462         pline->Draw("f");
00463       }
00464     }
00465     MyC->Update();
00466     if(filetype=="png"){
00467       std::cout << "printing " << std::endl;
00468       string filename = outputfilename + ".png";
00469       MyC->Print(filename.c_str());
00470     }
00471     if(filetype=="jpg"){
00472       string filename = outputfilename + ".jpg";
00473       MyC->Print(filename.c_str());
00474     }
00475     if(filetype=="pdf"){
00476       string filename = outputfilename + ".pdf";
00477       MyC->Print(filename.c_str());
00478     }
00479     string command = "rm "+tempfilename ;
00480     command1=command.c_str();
00481     cout << "Executing " << command1 << endl;
00482     system(command1);
00483     MyC->Clear();
00484     delete MyC;
00485     for(vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
00486          delete (*pos1);}
00487 
00488   }
00489   
00490   
00491 }

void TrackerMap::save_as_fedtrackermap ( bool  print_total = true,
float  minval = 0.,
float  maxval = 0.,
std::string  s = "fed_svgmap.svg",
int  width = 1500,
int  height = 800 
)

Definition at line 577 of file TrackerMap.cc.

References apvMap, c, parsecf::pyparsing::col(), dbtoconf::command, TmModule::count, TmApvPair::count, GenMuonPlsPt100GeV_cfg::cout, defcwindow(), drawApvPair(), drawPalette(), enableFedProcessing, lat::endl(), fedMap, EgammaValidation_cff::filename, i, in, maxvalue, minvalue, TmApvPair::mod, TmApvPair::mpos, ncrate, ncrates, TmModule::notInUse(), out, printflag, TmApvPair::red, saveAsSingleLayer, savefile, temporary_file, value, TmApvPair::value, TmModule::value, x, and y.

Referenced by printonline().

00577                                                                                                                    {
00578  if(enableFedProcessing){
00579   std::string filetype=s,outputfilename=s;
00580   vector<TPolyLine*> vp;
00581   filetype.erase(0,filetype.find(".")+1);
00582   outputfilename.erase(outputfilename.begin()+outputfilename.find("."),outputfilename.end());
00583   temporary_file=true;
00584   if(filetype=="xml"||filetype=="svg")temporary_file=false;
00585   ostringstream outs;
00586   minvalue=minval; maxvalue=maxval;
00587   outs << outputfilename << ".coor";
00588   if(temporary_file)savefile = new ofstream(outs.str().c_str(),ios::out);
00589   std::map<int , TmApvPair *>::iterator i_apv;
00590   std::map<int , int>::iterator i_fed;
00591   //Decide if we must use Module or ApvPair value
00592   bool useApvPairValue=false;
00593   for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
00594     TmApvPair *  apvPair= i_apv->second;
00595     if(apvPair!=0) {
00596       TmModule * apv_mod = apvPair->mod;
00597       if(apv_mod !=0 && !apv_mod->notInUse()){
00598         if(apvPair->count > 0 || apvPair->red!=-1) { useApvPairValue=true; break;}
00599       }
00600     }
00601   }
00602   if(!print_total){
00603     for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
00604       TmApvPair *  apvPair= i_apv->second;
00605       if(apvPair!=0) {
00606         TmModule * apv_mod = apvPair->mod;
00607         if(apv_mod !=0 && !apv_mod->notInUse()){
00608           if(useApvPairValue) apvPair->value = apvPair->value / apvPair->count;
00609           else if(apvPair->mpos==0)apv_mod->value = apv_mod->value / apv_mod->count;
00610         }
00611       }
00612     }
00613   }
00614   if(minvalue>=maxvalue){
00615     
00616     minvalue=9999999.;
00617     maxvalue=-9999999.;
00618     for(i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
00619         TmApvPair *  apvPair= i_apv->second;
00620         if(apvPair!=0) {
00621           TmModule * apv_mod = apvPair->mod;
00622           if( apv_mod !=0 && !apv_mod->notInUse()){
00623             if(useApvPairValue){
00624               if (minvalue > apvPair->value)minvalue=apvPair->value;
00625               if (maxvalue < apvPair->value)maxvalue=apvPair->value;
00626             } else {
00627               if (minvalue > apv_mod->value)minvalue=apv_mod->value;
00628               if (maxvalue < apv_mod->value)maxvalue=apv_mod->value;
00629             }
00630           }
00631         }
00632     }
00633   }
00634      if(filetype=="svg"){
00635       saveAsSingleLayer=false;
00636       ostringstream outs;
00637     outs << outputfilename<<".svg";
00638     savefile = new ofstream(outs.str().c_str(),ios::out);
00639   *savefile << "<?xml version=\"1.0\"  standalone=\"no\" ?>"<<endl;
00640   *savefile << "<svg  xmlns=\"https://www.w3.org/2000/svg\""<<endl;
00641   *savefile << "xmlns:svg=\"https://www.w3.org/2000/svg\" "<<endl;
00642   *savefile << "xmlns:xlink=\"https://www.w3.org/1999/xlink\">"<<endl;
00643   *savefile << "<svg:svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0 3000 1600"<<"\" width=\""<<width<<"\" height=\""<<height<<"\">"<<endl;
00644   *savefile << "<svg:rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"3000\" height=\"1600\" /> "<<endl;
00645   *savefile << "<svg:g id=\"fedtrackermap\" transform=\"translate(10,1500) rotate(270)\" style=\"fill:none;stroke:black;stroke-width:0;\"> "<<endl;
00646      }
00647   for (int crate=1; crate < (ncrates+1); crate++){
00648     if(filetype=="xml"){
00649       saveAsSingleLayer=true;
00650       ostringstream outs;
00651     outs << outputfilename<<"crate" <<crate<< ".xml";
00652     savefile = new ofstream(outs.str().c_str(),ios::out);
00653     *savefile << "<?xml version=\"1.0\" standalone=\"no\"?>"<<endl;
00654     *savefile << "<svg xmlns=\"https://www.w3.org/2000/svg\""<<endl;
00655     *savefile << "xmlns:svg=\"https://www.w3.org/2000/svg\""<<endl;
00656     *savefile << "xmlns:xlink=\"https://www.w3.org/1999/xlink\" >"<<endl;
00657     *savefile << "<script type=\"text/ecmascript\" xlink:href=\"crate.js\" />"<<endl;
00658     *savefile << "<svg id=\"mainMap\" x=\"0\" y=\"0\" viewBox=\"0 0  500 500\" width=\"700\" height=\"700\" onload=\"TrackerCrate.init()\">"<<endl;
00659     *savefile << "<rect fill=\"lightblue\" stroke=\"none\" x=\"0\" y=\"0\" width=\"700\" height=\"700\" />"<<endl;
00660     *savefile << "<g id=\"crate\" transform=\" translate(150,500) rotate(270) scale(1.,1.)\"  > "<<endl;
00661          }
00662     ncrate=crate;
00663     defcwindow(ncrate);
00664     int numfed_incrate=0;
00665     for (i_fed=fedMap.begin();i_fed != fedMap.end(); i_fed++){
00666       if(i_fed->second == crate){
00667         int fedId = i_fed->first;
00668         numfed_incrate++;
00669         for (int nconn=0;nconn<96;nconn++){
00670           int key = fedId*1000+nconn; 
00671           TmApvPair *  apvPair= apvMap[key];
00672           if(apvPair !=0){
00673             TmModule * apv_mod = apvPair->mod;
00674             if(apv_mod !=0 && !apv_mod->notInUse()){
00675               drawApvPair(crate,numfed_incrate,print_total,apvPair,savefile,useApvPairValue);
00676             }
00677           } 
00678         }
00679       }
00680     }
00681    if(!temporary_file){
00682     if(filetype=="xml"){
00683     *savefile << "</g> </svg> <text id=\"currentElementText\" x=\"40\" y=\"30\"> " << endl;
00684     *savefile << "<tspan id=\"line1\" x=\"40\" y=\"30\"> </tspan> " << endl;
00685     *savefile << "<tspan id=\"line2\" x=\"40\" y=\"60\"> </tspan> " << endl;
00686     *savefile << " </text> </svg>" << endl;
00687     savefile->close();
00688      saveAsSingleLayer=false;
00689       }
00690       }
00691     }
00692     if(filetype=="svg"){
00693     *savefile << "</g> </svg> </svg> " << endl;
00694     savefile->close();
00695       }
00696   if(!print_total && !useApvPairValue){
00697 //Restore module value
00698     for( i_apv=apvMap.begin();i_apv !=apvMap.end(); i_apv++){
00699       TmApvPair *  apvPair= i_apv->second;
00700       if(apvPair!=0) {
00701         TmModule * apv_mod = apvPair->mod;
00702         if(apv_mod !=0 && apvPair->mpos==0 && !apv_mod->notInUse()){
00703           apv_mod->value = apv_mod->value * apv_mod->count;
00704         }
00705       }
00706     }
00707 }
00708   
00709   if(temporary_file){
00710     if(printflag)drawPalette(savefile);
00711   savefile->close(); 
00712 
00713   const char * command1;
00714   string tempfilename = outputfilename + ".coor";
00715     int red,green,blue,npoints,colindex,ncolor;
00716     double x[4],y[4];
00717     ifstream tempfile(tempfilename.c_str(),ios::in);
00718     TCanvas *MyC = new TCanvas("MyC", "TrackerMap",width,height);
00719     gPad->SetFillColor(38);
00720     
00721     gPad->Range(0,0,3000,1600);
00722     
00723     //First  build palette
00724     ncolor=0;
00725     typedef std::map<int,int> ColorList;
00726     ColorList colorList;
00727     ColorList::iterator pos;
00728     TColor *col;
00729     while(!tempfile.eof()) {
00730       tempfile  >> red >> green  >> blue >> npoints; 
00731       colindex=red+green*1000+blue*1000000;
00732       pos=colorList.find(colindex); 
00733       if(pos == colorList.end()){ 
00734         colorList[colindex]=ncolor+100; 
00735         col =gROOT->GetColor(ncolor+100);
00736         if(col) 
00737           col->SetRGB((Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.)); 
00738         else 
00739           TColor *c = new TColor(ncolor+100,(Double_t)(red/255.),(Double_t)(green/255.),(Double_t)(blue/255.));
00740         ncolor++;
00741       }
00742       for (int i=0;i<npoints;i++){
00743         tempfile >> x[i] >> y[i];  
00744       }
00745     }
00746     if(ncolor>0 && ncolor<10000){
00747       Int_t colors[10000];
00748       for(int i=0;i<ncolor;i++){colors[i]=i+100;}
00749       gStyle->SetPalette(ncolor,colors);
00750     }
00751     tempfile.clear();
00752     tempfile.seekg(0,ios::beg);
00753     cout << "created palette with " << ncolor << " colors" << endl;
00754     while(!tempfile.eof()) {//create polylines
00755       tempfile  >> red >> green  >> blue >> npoints; 
00756       for (int i=0;i<npoints;i++){
00757         tempfile >> x[i] >> y[i];  
00758       }
00759       colindex=red+green*1000+blue*1000000;
00760       pos=colorList.find(colindex); 
00761       if(pos != colorList.end()){
00762         TPolyLine*  pline = new TPolyLine(npoints,y,x);
00763         vp.push_back(pline);
00764         pline->SetFillColor(colorList[colindex]);
00765         pline->SetLineWidth(0);
00766         pline->Draw("f");
00767       }
00768     }
00769     MyC->Update();
00770     std::cout << "Filetype " << filetype << std::endl;
00771     if(filetype=="png"){
00772       string filename = outputfilename + ".png";
00773       MyC->Print(filename.c_str());
00774     }
00775     if(filetype=="jpg"){
00776       string filename = outputfilename + ".jpg";
00777       MyC->Print(filename.c_str());
00778     }
00779     if(filetype=="pdf"){
00780       string filename = outputfilename + ".pdf";
00781       MyC->Print(filename.c_str());
00782     }
00783     string command = "rm "+tempfilename ;
00784     command1=command.c_str();
00785     cout << "Executing " << command1 << endl;
00786     system(command1);
00787     MyC->Clear();
00788     delete MyC;
00789     for(vector<TPolyLine*>::iterator pos1=vp.begin();pos1!=vp.end();pos1++){
00790          delete (*pos1);}
00791   
00792   
00793 }//if(temporary_file)
00794 }//if(enabledFedProcessing)
00795 }

void TrackerMap::setPalette ( int  numpalette  )  [inline]

Definition at line 51 of file TrackerMap.h.

References palette.

00051 {palette=numpalette;} 

void TrackerMap::setText ( int  layer,
int  ring,
int  nmod,
string  s 
)

Definition at line 1002 of file TrackerMap.cc.

References GenMuonPlsPt100GeV_cfg::cout, smoduleMap, and TmModule::text.

01002                                                                {
01003 
01004   int key = layer*100000+ring*1000+nmod;
01005   TmModule * mod = smoduleMap[key];
01006   if(mod!=0){
01007      mod->text=s;
01008   }
01009   else cout << "**************************error in SvgModuleMap **************";
01010 } 

void TrackerMap::setText ( int  idmod,
std::string  s 
)

Referenced by TmTestWidget::TmTestWidget().

void TrackerMap::showPalette ( bool  printflag1  )  [inline]

Definition at line 53 of file TrackerMap.h.

References printflag.

00053 {printflag=printflag1;}; 

double TrackerMap::xdpixel ( double  x  )  [inline]

Definition at line 140 of file TrackerMap.h.

References ix, res, saveAsSingleLayer, xmax, xmin, and xsize.

Referenced by SiPixelTrackerMap::drawModule(), and VisTrackerMap::visDrawModule().

00140                            {
00141     double res;
00142     if(saveAsSingleLayer)res= ((x-xmin)/(xmax-xmin)*xsize);
00143     else res= ((x-xmin)/(xmax-xmin)*xsize)+ix;
00144     return res;
00145   }

double TrackerMap::xdpixelc ( double  x  )  [inline]

Definition at line 155 of file TrackerMap.h.

References ix, res, saveAsSingleLayer, xmax, xmin, and xsize.

00155                             {
00156     double res;
00157     if(saveAsSingleLayer)res= ((x-xmin)/(xmax-xmin)*xsize);
00158     else res= ((x-xmin)/(xmax-xmin)*xsize)+ix;
00159     return res;
00160   }

double TrackerMap::ydpixel ( double  y  )  [inline]

Definition at line 146 of file TrackerMap.h.

References iy, nlay, res, saveAsSingleLayer, ymax, ymin, and ysize.

Referenced by SiPixelTrackerMap::drawModule(), and VisTrackerMap::visDrawModule().

00146                            {
00147     double res;
00148     double y1;
00149     y1 = (y-ymin)/(ymax-ymin);
00150     if(nlay>30)   res= 2*ysize - (y1*2*ysize);
00151     else res= ysize - (y1*ysize);
00152     if(!saveAsSingleLayer) res=res+iy;
00153     return res;
00154   }

double TrackerMap::ydpixelc ( double  y  )  [inline]

Definition at line 161 of file TrackerMap.h.

References iy, res, saveAsSingleLayer, ymax, ymin, and ysize.

00161                             {
00162     double res;
00163     double y1;
00164     y1 = (y-ymin)/(ymax-ymin);
00165      if(saveAsSingleLayer)res= 2*ysize - (y1*2*ysize);
00166      else res= 2*ysize - (y1*2*ysize)+iy;
00167     return res;
00168   }


Member Data Documentation

SvgApvPair TrackerMap::apvMap

Definition at line 64 of file TrackerMap.h.

Referenced by fill_current_val_fed_channel(), fill_fed_channel(), fillc_fed_channel(), module(), printonline(), save_as_fedtrackermap(), and TrackerMap().

ModApvPair TrackerMap::apvModuleMap

Definition at line 66 of file TrackerMap.h.

Referenced by fill_fed_channel(), printonline(), and TrackerMap().

bool TrackerMap::enableFedProcessing

Definition at line 71 of file TrackerMap.h.

Referenced by printonline(), save_as_fedtrackermap(), and TrackerMap().

SvgFed TrackerMap::fedMap

Definition at line 68 of file TrackerMap.h.

Referenced by printonline(), save_as_fedtrackermap(), and TrackerMap().

bool TrackerMap::firstcall [protected]

Definition at line 331 of file TrackerMap.h.

Referenced by init().

int TrackerMap::firstRing[43]

Definition at line 322 of file TrackerMap.h.

Referenced by init(), VisTrackerMap::mousePressEvent(), VisTrackerMap::paintEvent(), save(), and VisTrackerMap::VisTrackerMap().

ImoduleMap TrackerMap::imoduleMap

Definition at line 62 of file TrackerMap.h.

Referenced by build(), fill(), fill_current_val(), fillc(), TmTestWidget::TmTestWidget(), and TrackerMap().

std::string TrackerMap::infilename

Definition at line 75 of file TrackerMap.h.

Referenced by build(), and TrackerMap().

int TrackerMap::ix [protected]

Definition at line 329 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), init(), xdpixel(), and xdpixelc().

int TrackerMap::iy [protected]

Definition at line 329 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), init(), ydpixel(), and ydpixelc().

std::ifstream* TrackerMap::jsfile [protected]

Definition at line 334 of file TrackerMap.h.

std::string TrackerMap::jsfilename

Definition at line 75 of file TrackerMap.h.

Referenced by TrackerMap().

std::string TrackerMap::jsPath

Definition at line 76 of file TrackerMap.h.

Referenced by TrackerMap().

float TrackerMap::maxvalue [protected]

Definition at line 335 of file TrackerMap.h.

Referenced by getcolor(), init(), save(), and save_as_fedtrackermap().

float TrackerMap::minvalue [protected]

Definition at line 335 of file TrackerMap.h.

Referenced by getcolor(), init(), save(), and save_as_fedtrackermap().

int TrackerMap::ncrate [protected]

Definition at line 326 of file TrackerMap.h.

Referenced by defcwindow(), and save_as_fedtrackermap().

int TrackerMap::ncrates [protected]

Definition at line 327 of file TrackerMap.h.

Referenced by printonline(), save_as_fedtrackermap(), and TrackerMap().

int TrackerMap::ndet

Definition at line 72 of file TrackerMap.h.

Referenced by init().

int TrackerMap::nlay [protected]

Definition at line 325 of file TrackerMap.h.

Referenced by defwindow(), and ydpixel().

int TrackerMap::npart

Definition at line 73 of file TrackerMap.h.

Referenced by init().

int TrackerMap::ntotRing[43]

Definition at line 321 of file TrackerMap.h.

Referenced by init(), printonline(), and save().

int TrackerMap::number_modules [protected]

Definition at line 336 of file TrackerMap.h.

Referenced by build().

float TrackerMap::oldz [private]

Definition at line 341 of file TrackerMap.h.

int TrackerMap::palette

Definition at line 69 of file TrackerMap.h.

Referenced by init(), and setPalette().

bool TrackerMap::posrel [protected]

Definition at line 330 of file TrackerMap.h.

Referenced by defwindow(), SiPixelTrackerMap::drawModule(), and init().

bool TrackerMap::printflag

Definition at line 70 of file TrackerMap.h.

Referenced by init(), save(), save_as_fedtrackermap(), and showPalette().

bool TrackerMap::psetAvailable

Definition at line 77 of file TrackerMap.h.

Referenced by TrackerMap().

bool TrackerMap::saveAsSingleLayer [private]

Definition at line 342 of file TrackerMap.h.

Referenced by save_as_fedtrackermap(), TrackerMap(), xdpixel(), xdpixelc(), ydpixel(), and ydpixelc().

std::ofstream* TrackerMap::savefile [protected]

Definition at line 333 of file TrackerMap.h.

Referenced by save(), and save_as_fedtrackermap().

SmoduleMap TrackerMap::smoduleMap

Definition at line 60 of file TrackerMap.h.

Referenced by build(), fill(), fillc(), init(), VisTrackerMap::mousePressEvent(), VisTrackerMap::paintEvent(), printonline(), save(), setText(), and VisTrackerMap::VisTrackerMap().

std::ofstream* TrackerMap::svgfile [protected]

Definition at line 332 of file TrackerMap.h.

Referenced by SiPixelTrackerMap::drawModule().

bool TrackerMap::temporary_file [protected]

Definition at line 337 of file TrackerMap.h.

Referenced by init(), printonline(), save(), and save_as_fedtrackermap().

string TrackerMap::title

Reimplemented in SiPixelTrackerMap.

Definition at line 74 of file TrackerMap.h.

Referenced by save(), and TrackerMap().

double TrackerMap::xmax [protected]

Definition at line 328 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), xdpixel(), and xdpixelc().

double TrackerMap::xmin [protected]

Definition at line 328 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), xdpixel(), and xdpixelc().

int TrackerMap::xsize [protected]

Definition at line 329 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), find_layer(), getxsize(), TrackerMap(), xdpixel(), and xdpixelc().

double TrackerMap::ymax [protected]

Definition at line 328 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), ydpixel(), and ydpixelc().

double TrackerMap::ymin [protected]

Definition at line 328 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), ydpixel(), and ydpixelc().

int TrackerMap::ysize [protected]

Definition at line 329 of file TrackerMap.h.

Referenced by defcwindow(), defwindow(), find_layer(), getysize(), TrackerMap(), ydpixel(), and ydpixelc().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:10 2009 for CMSSW by  doxygen 1.5.4