CMS 3D CMS Logo

VisTrackerMap Class Reference

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

List of all members.

Signals

void moduleSelected (int)

Public Member Functions

void computeColor (TmModule *mod, bool print_total, QPainter *p)
TrackerMapgetTrackerMap ()
void mousePressEvent (QMouseEvent *e)
void paintEvent (QPaintEvent *)
void setPaintOptions (bool vtk_print_total=true, float vtk_minval=0., float vtk_maxval=0.)
void visDrawModule (TmModule *mod, int key, int nlay, QPointArray a)
 VisTrackerMap (QWidget *parent=0, const char *name=0, QLabel *labelinfo=0)
 ~VisTrackerMap ()

Public Attributes

QLabel * ql
TrackerMaptk

Private Attributes

bool horizontal_view
float maxval
float minval
bool posrel
bool print_total
QPointArray * reg_mod
double xmax
double xmin
double ymax
double ymin


Detailed Description

Definition at line 15 of file VisTrackerMap.h.


Constructor & Destructor Documentation

VisTrackerMap::VisTrackerMap ( QWidget *  parent = 0,
const char *  name = 0,
QLabel *  labelinfo = 0 
)

Definition at line 6 of file VisTrackerMap.cc.

References count, TrackerMap::defwindow(), TrackerMap::firstRing, TmModule::getKey(), TrackerMap::getNumMod(), horizontal_view, getDQMSummary::key, TmModule::layer, mod(), TmModule::notInUse(), posrel, ql, reg_mod, TmModule::setQPointArray(), TrackerMap::smoduleMap, tk, visDrawModule(), xmax, xmin, ymax, and ymin.

00007   : QWidget( parent, name )
00008 {
00009   setMinimumSize( 3000, 1360 );
00010   setMaximumSize( 3000, 1360 );
00011   
00012   setPalette( QPalette( QColor( 250, 250, 250) ) );
00013   xmin = -3.0; xmax = 3.0; ymin = -0.1; ymax =1.0;
00014   ql = labelinfo;
00015 
00016   horizontal_view = true;
00017   posrel= true;
00018   tk =new TrackerMap(name,340,200);
00019   int number_mod = tk->getNumMod();
00020   reg_mod = new QPointArray[number_mod];
00021   int count=0;
00022   
00023   for (int layer=1; layer < 44; layer++){
00024     int n_lay=layer;
00025     tk->defwindow(n_lay);
00026     for (int ring=tk->firstRing[layer-1]; ring < tk->ntotRing[layer-1]+tk->firstRing[layer-1];ring++){
00027       for (int module=1;module<200;module++) {
00028         int key=layer*100000+ring*1000+module;
00029         TmModule * mod = tk->smoduleMap[key];
00030         if(mod !=0 && !mod->notInUse()){
00031           reg_mod[count] =  QPointArray(4);
00032           mod->setQPointArray(count);
00033           visDrawModule(mod,mod->getKey(),mod->layer,reg_mod[count]);
00034           count++;
00035         }
00036       }
00037     }
00038   }
00039 }

VisTrackerMap::~VisTrackerMap (  ) 

Definition at line 41 of file VisTrackerMap.cc.

00042 {
00043 
00044 }


Member Function Documentation

void VisTrackerMap::computeColor ( TmModule mod,
bool  print_total,
QPainter *  p 
)

Definition at line 132 of file VisTrackerMap.cc.

References TmModule::blue, TmModule::count, cmsRelvalreport::green(), TmModule::green, int, maxval, minval, TmModule::red, and TmModule::value.

Referenced by paintEvent().

00133 {
00134   int green = 0;
00135   
00136   if(mod->red < 0){ //use count to compute color
00137     green = (int)((mod->value-minval)/(maxval-minval)*256.);
00138     
00139     if (green > 255) green=255;
00140     if(!print_total)mod->value=mod->value*mod->count;//restore mod->value
00141 
00142     if(mod->count > 0){
00143       p->setBrush(QColor(255,255-green,0));
00144       p->setPen(QColor(255,255-green,0));
00145     }
00146     else{
00147       p->setBrush(QColor(white));
00148     }
00149 
00150   } else {//color defined with fillc
00151     if(mod->red>255)mod->red=255;
00152     if(mod->green>255)mod->green=255;
00153     if(mod->blue>255)mod->blue=255;
00154     
00155     p->setBrush(QColor(mod->red, mod->green,mod->blue ));
00156   }
00157 }

TrackerMap* VisTrackerMap::getTrackerMap (  )  [inline]

Definition at line 28 of file VisTrackerMap.h.

References tk.

00028 {return tk;}

void VisTrackerMap::moduleSelected ( int   )  [signal]

Referenced by mousePressEvent().

void VisTrackerMap::mousePressEvent ( QMouseEvent *  e  ) 

Definition at line 103 of file VisTrackerMap.cc.

References TmModule::count, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), TrackerMap::find_layer(), TrackerMap::firstRing, TmModule::getQPointArray(), TmModule::idex, getDQMSummary::key, mod(), moduleSelected(), TmModule::name, TmModule::notInUse(), ql, reg_mod, TrackerMap::smoduleMap, TmModule::text, tk, and TmModule::value.

00104 {
00105   int layer = tk->find_layer(e->pos().x(),e->pos().y());
00106   cout << "mouse position " << e->pos().x() << " " << e->pos().y()<<" layer "<< layer << endl;
00107   ostringstream outs;
00108      
00109   TmModule * mod;
00110   for (int ring=tk->firstRing[layer-1]; ring < tk->ntotRing[layer-1]+tk->firstRing[layer-1];ring++){
00111     for (int module=1;module<200;module++) {
00112       int key=layer*100000+ring*1000+module;
00113       mod = tk->smoduleMap[key];
00114       if(mod !=0 && !mod->notInUse()){
00115 
00116         QRegion q(reg_mod[mod->getQPointArray()],false);
00117 //      QPoint pt(e->pos().x(), (tk->getxsize()*4)-e->pos().y());
00118         QPoint pt(e->pos().x(), e->pos().y());
00119         if(q.contains(pt)){
00120 
00121           outs << mod->name<<" "<< mod->text<<" DetId="<<mod->idex<<" count="<<mod->count<<" value=" <<mod->value<< "mouse pos= "<< e->pos().x() <<" "<<e->pos().y();
00122           ql->setText(outs.str());
00123 
00124           emit moduleSelected(mod->idex);
00125           break;
00126         }
00127       }
00128     }
00129   }
00130 }

void VisTrackerMap::paintEvent ( QPaintEvent *   ) 

Definition at line 54 of file VisTrackerMap.cc.

References computeColor(), TmModule::count, TrackerMap::defwindow(), TrackerMap::firstRing, TmModule::getQPointArray(), getDQMSummary::key, maxval, minval, mod(), TmModule::notInUse(), p, print_total, reg_mod, TrackerMap::smoduleMap, tk, value, and TmModule::value.

00055 {
00056   QPainter *p = new QPainter( this );
00057   
00058   if(!print_total){
00059     for (int layer=1; layer < 44; layer++){
00060       for (int ring=tk->firstRing[layer-1]; ring < tk->ntotRing[layer-1]+tk->firstRing[layer-1];ring++){
00061         for (int module=1;module<200;module++) {
00062           int key=layer*100000+ring*1000+module;
00063           TmModule * mod = tk->smoduleMap[key];
00064           if(mod !=0 && !mod->notInUse()){
00065             mod->value = mod->value / mod->count;
00066           }
00067         }
00068       }
00069     }
00070   }
00071   if(minval>=maxval){
00072     minval=9999999.;
00073     maxval=-9999999.;
00074     for (int layer=1; layer < 44; layer++){
00075       for (int ring=tk->firstRing[layer-1]; ring < tk->ntotRing[layer-1]+tk->firstRing[layer-1];ring++){
00076         for (int module=1;module<200;module++) {
00077           int key=layer*100000+ring*1000+module;
00078           TmModule * mod = tk->smoduleMap[key];
00079           if(mod !=0 && !mod->notInUse()){
00080             if (minval > mod->value)minval=mod->value;
00081             if (maxval < mod->value)maxval=mod->value;
00082           }
00083         }
00084       }
00085     }
00086   }
00087   for (int layer=1; layer < 44; layer++){
00088     int n_lay=layer;
00089     tk->defwindow(n_lay);
00090     for (int ring=tk->firstRing[layer-1]; ring < tk->ntotRing[layer-1]+tk->firstRing[layer-1];ring++){
00091       for (int module=1;module<200;module++) {
00092         int key=layer*100000+ring*1000+module;
00093         TmModule * mod = tk->smoduleMap[key];
00094         if(mod !=0 && !mod->notInUse()){
00095           computeColor(mod, print_total, p);
00096           p->drawPolygon(reg_mod[mod->getQPointArray()]);
00097         }
00098       }
00099     }
00100   }
00101 }

void VisTrackerMap::setPaintOptions ( bool  vtk_print_total = true,
float  vtk_minval = 0.,
float  vtk_maxval = 0. 
)

Definition at line 47 of file VisTrackerMap.cc.

References maxval, minval, and print_total.

Referenced by VisTrackerMapBox::setPaintOptions().

00048 {
00049   print_total =vtk_print_total;
00050   minval = vtk_minval;
00051   maxval = vtk_maxval;
00052 }

void VisTrackerMap::visDrawModule ( TmModule mod,
int  key,
int  nlay,
QPointArray  a 
)

Definition at line 159 of file VisTrackerMap.cc.

References funct::cos(), horizontal_view, TmModule::idModule, int, TrackerMap::isRingStereo(), j, TmModule::length, np, phi, TrackerMap::phival(), posrel, TmModule::posx, TmModule::posy, TmModule::posz, pv1, r, TmModule::ring, funct::sin(), funct::sqrt(), tk, TmModule::width, TmModule::widthAtHalfLength, x, TrackerMap::xdpixel(), y, and TrackerMap::ydpixel().

Referenced by VisTrackerMap().

00160 {
00161   int x,y;
00162   double phi,r,dx,dy, dy1;
00163   double xp[4],yp[4],xp1,yp1;
00164   double vhbot,vhtop,vhapo;
00165   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};
00166   double xt1,yt1,xs1=0.,ys1=0.,xt2,yt2,xs2,ys2,pv1,pv2;
00167   int np = 4;
00168   int numod=0;
00169   
00170   phi = tk->phival(mod->posx,mod->posy);
00171   r = sqrt(mod->posx*mod->posx+mod->posy*mod->posy);
00172   vhbot = mod->width;
00173   vhtop=mod->width;
00174   vhapo=mod->length;
00175   if(nlay < 31){ //endcap
00176     vhbot = mod->widthAtHalfLength/2.-(mod->width/2.-mod->widthAtHalfLength/2.);
00177     vhtop=mod->width/2.;
00178     vhapo=mod->length/2.;
00179     if(nlay >12 && nlay <19){
00180       if(posrel)r = r+r;
00181       xp[0]=r-vhtop;yp[0]=-vhapo;
00182       xp[1]=r+vhtop;yp[1]=-vhapo;
00183       xp[2]=r+vhtop;yp[2]=vhapo;
00184       xp[3]=r-vhtop;yp[3]=vhapo;
00185     }else{
00186       if(posrel)r = r + r/3.;
00187       xp[0]=r-vhapo;yp[0]=-vhbot;
00188       xp[1]=r+vhapo;yp[1]=-vhtop;
00189       xp[2]=r+vhapo;yp[2]=vhtop;
00190       xp[3]=r-vhapo;yp[3]=vhbot;
00191     }
00192     for(int j=0;j<4;j++){
00193       xp1 = xp[j]*cos(phi)-yp[j]*sin(phi);
00194       yp1 = xp[j]*sin(phi)+yp[j]*cos(phi);
00195       xp[j] = xp1;yp[j]=yp1;
00196     }
00197   } else { //barrel
00198     numod=mod->idModule;if(numod>100)numod=numod-100;
00199     int vane = mod->ring;
00200     if(posrel){
00201       dx = vhapo;
00202       phi=M_PI;
00203       xt1=rmedio[nlay-31]; yt1=-vhtop/2.;
00204       xs1 = xt1*cos(phi)-yt1*sin(phi);
00205       ys1 = xt1*sin(phi)+yt1*cos(phi);
00206       xt2=rmedio[nlay-31]; yt2=vhtop/2.;
00207       xs2 = xt2*cos(phi)-yt2*sin(phi);
00208       ys2 = xt2*sin(phi)+yt2*cos(phi);
00209       dy=tk->phival(xs2,ys2)-tk->phival(xs1,ys1);
00210          dy1 = dy;
00211       if(nlay==31)dy1=0.39;
00212       if(nlay==32)dy1=0.23;
00213       if(nlay==33)dy1=0.16;
00214       xp[0]=vane*(dx+dx/8.);yp[0]=numod*(dy1);
00215       xp[1]=vane*(dx+dx/8.)+dx;yp[1]=numod*(dy1);
00216       xp[2]=vane*(dx+dx/8.)+dx;yp[2]=numod*(dy1)+dy;
00217       xp[3]=vane*(dx+dx/8.);yp[3]=numod*(dy1)+dy;
00218     }else{
00219       xt1=r; yt1=-vhtop/2.;
00220       xs1 = xt1*cos(phi)-yt1*sin(phi);
00221       ys1 = xt1*sin(phi)+yt1*cos(phi);
00222       xt2=r; yt2=vhtop/2.;
00223       xs2 = xt2*cos(phi)-yt2*sin(phi);
00224       ys2 = xt2*sin(phi)+yt2*cos(phi);
00225       pv1=tk->phival(xs1,ys1);
00226       pv2=tk->phival(xs2,ys2);
00227       if(fabs(pv1-pv2)>M_PI && numod==1)pv1=pv1-2.*M_PI;
00228       if(fabs(pv1-pv2)>M_PI && numod!=1)pv2=pv2+2.*M_PI;
00229       xp[0]=mod->posz-vhapo/2.;yp[0]=4.2*pv1;
00230       xp[1]=mod->posz+vhapo/2.;yp[1]=4.2*pv1;
00231       xp[2]=mod->posz+vhapo/2. ;yp[2]=4.2*pv2;
00232       xp[3]=mod->posz-vhapo/2.;yp[3]=4.2*pv2;
00233     }
00234   }
00235   if(tk->isRingStereo(key))
00236     {
00237       np = 3;
00238       if(mod->idModule>100 ){for(int j=0;j<3;j++){
00239         x=(int)(tk->xdpixel(xp[j]));y=(int)(tk->ydpixel(yp[j]));
00240         if(!horizontal_view)a.setPoint(j,x,y);else a.setPoint(j,y,1360-x);
00241       }
00242       if(!horizontal_view)a.setPoint(3,x,y);else a.setPoint(3,y,1360-x);
00243       }else {
00244         x=(int)(tk->xdpixel(xp[2]));y=(int)(tk->ydpixel(yp[2]));
00245         if(!horizontal_view)a.setPoint(0,x,y); else a.setPoint(0,y,1360-x);
00246         x=(int)(tk->xdpixel(xp[3]));y=(int)(tk->ydpixel(yp[3]));
00247         if(!horizontal_view)a.setPoint(1,x,y); else a.setPoint(1,y,1360-x);
00248         x=(int)(tk->xdpixel(xp[0]));y=(int)(tk->ydpixel(yp[0]));
00249         if(!horizontal_view)a.setPoint(2,x,y); else a.setPoint(2,y,1360-x);
00250         if(!horizontal_view)a.setPoint(3,x,y); else a.setPoint(3,y,1360-x);
00251       }
00252     } else {
00253       for(int j=0;j<4;j++){
00254         x=(int)(tk->xdpixel(xp[j]));y=(int)(tk->ydpixel(yp[j]));
00255         if(!horizontal_view)a.setPoint(j,x,y);else a.setPoint(j,y,1360-x);
00256       }
00257     }
00258 }


Member Data Documentation

bool VisTrackerMap::horizontal_view [private]

Definition at line 39 of file VisTrackerMap.h.

Referenced by visDrawModule(), and VisTrackerMap().

float VisTrackerMap::maxval [private]

Definition at line 37 of file VisTrackerMap.h.

Referenced by computeColor(), paintEvent(), and setPaintOptions().

float VisTrackerMap::minval [private]

Definition at line 37 of file VisTrackerMap.h.

Referenced by computeColor(), paintEvent(), and setPaintOptions().

bool VisTrackerMap::posrel [private]

Definition at line 39 of file VisTrackerMap.h.

Referenced by visDrawModule(), and VisTrackerMap().

bool VisTrackerMap::print_total [private]

Definition at line 38 of file VisTrackerMap.h.

Referenced by paintEvent(), and setPaintOptions().

QLabel* VisTrackerMap::ql

Definition at line 30 of file VisTrackerMap.h.

Referenced by mousePressEvent(), and VisTrackerMap().

QPointArray* VisTrackerMap::reg_mod [private]

Definition at line 42 of file VisTrackerMap.h.

Referenced by mousePressEvent(), paintEvent(), and VisTrackerMap().

TrackerMap* VisTrackerMap::tk

Definition at line 29 of file VisTrackerMap.h.

Referenced by getTrackerMap(), mousePressEvent(), paintEvent(), visDrawModule(), and VisTrackerMap().

double VisTrackerMap::xmax [private]

Definition at line 40 of file VisTrackerMap.h.

Referenced by VisTrackerMap().

double VisTrackerMap::xmin [private]

Definition at line 40 of file VisTrackerMap.h.

Referenced by VisTrackerMap().

double VisTrackerMap::ymax [private]

Definition at line 40 of file VisTrackerMap.h.

Referenced by VisTrackerMap().

double VisTrackerMap::ymin [private]

Definition at line 40 of file VisTrackerMap.h.

Referenced by VisTrackerMap().


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