00001
00002
00003 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00004 #include "VisFramework/VisConfigService/interface/VisConfigurationService.h"
00005 #include "FWCore/Framework/interface/Selector.h"
00006 #include "VisReco/VisCustomTracker/interface/VisCuTrackerCluster.h"
00007 #include "VisReco/VisRecoGeometry/interface/VisTrackingGeometry.h"
00008 #include "VisReco/VisCustomTracker/interface/VisCuTkModuleMap.h"
00009 #include "VisReco/VisCustomTracker/interface/VisCuTkMap2D.h"
00010 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00011 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00012 #include "DataFormats/Common/interface/DetSetVector.h"
00013 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "FWCore/Framework/interface/Selector.h"
00017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00018 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00019 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00020 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00021 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00022 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00023 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00024 #include "Iguana/Studio/interface/IgQtLock.h"
00025 #include "Iguana/Inventor/interface/IgSoCircularHist.h"
00026 #include "Iguana/Inventor/interface/IgSoTower.h"
00027 #include "Iguana/Inventor/interface/IgSoArrow.h"
00028 #include "Iguana/Framework/interface/IgRepSet.h"
00029 #include "Iguana/Models/interface/IgTextRep.h"
00030 #include "Iguana/GLModels/interface/Ig3DRep.h"
00031 #include "Iguana/GLModels/interface/IgLegoRep.h"
00032 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00033 #include "Iguana/GLModels/interface/IgRZRep.h"
00034 #include <Inventor/nodes/SoSeparator.h>
00035 #include <Inventor/nodes/SoTransform.h>
00036 #include <Inventor/nodes/SoCube.h>
00037 #include <Inventor/nodes/SoDrawStyle.h>
00038 #include <Inventor/nodes/SoMaterial.h>
00039 #include <Inventor/nodes/SoPointSet.h>
00040 #include "Inventor/nodes/SoIndexedLineSet.h"
00041 #include <Inventor/nodes/SoVertexProperty.h>
00042 #include <qstring.h>
00043 #include <iostream>
00044 #include <iomanip>
00045 #include <qpointarray.h>
00046 #include <qpainter.h>
00047 #include <qimage.h>
00048
00049 using namespace edm;
00050
00051 VisCuTrackerCluster::VisCuTrackerCluster ()
00052 {
00053 horizontal_view = true;
00054 firsteventloaded=false;
00055 const edm::ParameterSet *pset=VisConfigurationService::pSet();
00056 if(!pset)
00057 {
00058 edm::ParameterSet p;
00059 VisConfigurationService *visService = new VisConfigurationService(p);
00060 pset = visService->pSet();
00061 delete visService;
00062 }
00063 clusterPointSize = pset->getUntrackedParameter<double> ("clusterPointSize", 4.0);
00064 stripclusterProducerName = pset->getUntrackedParameter<std::string>("stripclusterProducer", "siStripClusters");
00065 stripclusterLabelName = pset->getUntrackedParameter<std::string>("stripclusterLabel","");
00066 cout <<"stripclusterProducer="<< stripclusterProducerName << " stripclusterLabel=" << stripclusterLabelName << endl;
00067 pixelclusterProducerName = pset->getUntrackedParameter<std::string>("pixelclusterProducer", "siPixelClusters");
00068 pixelclusterLabelName = pset->getUntrackedParameter<std::string>("pixelclusterLabel","");
00069 cout <<"pixelclusterProducer="<< pixelclusterProducerName << " pixelclusterLabel=" << pixelclusterLabelName << endl;
00070 siStripClusterRepresentation = pset->getUntrackedParameter<std::string>("siStripClusterRepresentation", "point");
00071 }
00072
00073 void
00074 VisCuTrackerCluster::setEvent (const edm::Event &event,
00075 const edm::EventSetup &eventSetup)
00076 {
00077 eventSetup.get<TrackerDigiGeometryRecord> ().get (m_pDD);
00078
00079 cdigi.clear();
00080 cpdigi.clear();
00081 firsteventloaded=true;
00082 bool nocluster=true;
00083 int cd_pointer=0;
00084
00085 if(stripclusterProducerName!="ignore"){
00086 std::vector< edm::Handle<edmNew::DetSetVector<SiStripCluster> > > s_cluster_collections;
00087 Selector sel(ProductInstanceNameSelector(stripclusterLabelName) &&
00088 ModuleLabelSelector(stripclusterProducerName));
00089 event.getMany (sel, s_cluster_collections);
00090 if (! s_cluster_collections.empty ())nocluster=false;
00091 if(nocluster) cout << "no stripclusters type "<<stripclusterProducerName<<"/"<<stripclusterLabelName<< " in event" << endl;
00092 if(!nocluster){
00093 std::vector< edm::Handle<edmNew::DetSetVector<SiStripCluster> > >::iterator i;
00094 i = s_cluster_collections.begin ();
00095 const edmNew::DetSetVector<SiStripCluster> &cinput = *(*i);
00096 if (cinput.size())
00097 {
00098 edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=cinput.begin();
00099 for (; DSViter!=cinput.end();DSViter++){
00100 const uint32_t detID = DSViter->detId();
00101 DetId detIdObject(detID);
00102 const GeomDetUnit * geoUnit = m_pDD->idToDetUnit( detIdObject );
00103 VisCuTkModule * mod = VisCuTkModuleMap::moduleMap[geoUnit];
00104 if(mod){
00105 mod->cluster_start=cd_pointer;
00106 mod->cluster_size=DSViter->size();
00107 } else cout << "module not found " << endl;
00108 edmNew::DetSet<SiStripCluster>::const_iterator clustIt = DSViter->begin(), clustEnd = DSViter->end();
00109 for ( ; clustIt != clustEnd; clustIt++)
00110 {
00111 cdigi.push_back(*clustIt);
00112
00113 }
00114 cd_pointer=cd_pointer+DSViter->size();
00115 }
00116 }
00117 }
00118 }
00119
00120 cd_pointer=0;
00121 nocluster=true;
00122 if(pixelclusterProducerName!="ignore"){
00123 std::vector< edm::Handle<edmNew::DetSetVector<SiPixelCluster> > > p_cluster_collections;
00124 Selector sel(ProductInstanceNameSelector(pixelclusterLabelName) &&
00125 ModuleLabelSelector(pixelclusterProducerName));
00126 event.getMany (sel, p_cluster_collections);
00127 if (! p_cluster_collections.empty ())nocluster=false;
00128 if(nocluster) cout << "no pixelcluster type "<<pixelclusterProducerName<<"/"<<pixelclusterLabelName<< " in event" << endl;
00129 if(!nocluster){
00130 std::vector< edm::Handle<edmNew::DetSetVector<SiPixelCluster> > >::iterator i;
00131 i = p_cluster_collections.begin ();
00132 const edmNew::DetSetVector<SiPixelCluster> &cpinput = *(*i);
00133 if (cpinput.size())
00134 {
00135 edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=cpinput.begin();
00136 for (; DSViter!=cpinput.end();DSViter++){
00137 const uint32_t detID = DSViter->detId();
00138 DetId detIdObject(detID);
00139 const GeomDetUnit * geoUnit = m_pDD->idToDetUnit( detIdObject );
00140 VisCuTkModule * mod = VisCuTkModuleMap::moduleMap[geoUnit];
00141 if(mod){
00142 mod->cluster_start=cd_pointer;
00143 mod->cluster_size=DSViter->size();
00144 } else cout << "module not found " << endl;
00145 edmNew::DetSet<SiPixelCluster>::const_iterator clustIt = DSViter->begin(), clustEnd = DSViter->end();
00146 for ( ; clustIt != clustEnd; clustIt++)
00147 {
00148 cpdigi.push_back(*clustIt);
00149 }
00150 cd_pointer=cd_pointer+DSViter->size();
00151 }
00152 }
00153 }
00154 }
00155 }
00156
00157 SoSeparator * VisCuTrackerCluster::update (VisTrackingGeometry::DetectorRep type)
00158 {
00159 SoSeparator *sep = new SoSeparator;
00160 if (! cdigi.empty ())
00161 {
00162 SoMaterial *mat = new SoMaterial;
00163 mat->diffuseColor.setValue (0.0, 0.0, 1.0);
00164 mat->emissiveColor.setValue(0.0, 0.0, 1.0);
00165
00166 SoDrawStyle *drawStyle = new SoDrawStyle;
00167 drawStyle->pointSize = clusterPointSize;
00168
00169 sep->addChild (mat);
00170 sep->addChild (drawStyle);
00171
00172 try
00173 {
00174 SoVertexProperty *vertices = new SoVertexProperty;
00175 SoVertexProperty *vtx = 0;
00176 SoIndexedLineSet *strips=0 ;
00177 int nVrtx = 0;
00178 int n = 0;
00179 int coord=0;
00180 SoMFInt32 coords;
00181 if(siStripClusterRepresentation=="strip"){
00182 vtx = new SoVertexProperty;
00183 strips = new SoIndexedLineSet;
00184 }
00185
00186 std::map<const GeomDetUnit * , VisCuTkModule *>::iterator imod;
00187 for (imod=VisCuTkModuleMap::moduleMap.begin();imod != VisCuTkModuleMap::moduleMap.end(); imod++){
00188 VisCuTkModule* mod = imod->second;
00189 unsigned int detType = mod->detUnit->geographicalId().subdetId();
00190 if(mod->isVisible()){
00191 if(detType < 3)
00192 {
00193 const PixelGeomDetUnit* theDet = dynamic_cast<const PixelGeomDetUnit*>(mod->detUnit);
00194 const RectangularPixelTopology *theTopol = dynamic_cast<const RectangularPixelTopology *>( &(theDet->specificTopology ()));
00195 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00196 SiPixelCluster d = cpdigi[idigi];
00197 int row = d.minPixelRow();
00198 int col = d.minPixelCol();
00199 GlobalPoint pos = mod->detUnit->surface().toGlobal(theTopol->localPosition(MeasurementPoint(row,col)));
00200 float x = pos.x () / 100.0;
00201 float y;
00202 if(type==RZDet){
00203 x=0.0;
00204 y = sqrt(pos.x ()*pos.x()+pos.y()*pos.y()) / 100.0; if(pos.y()< 0. )y = - y;} else y = pos.y () / 100.0;
00205 float z = pos.z () / 100.0;
00206
00207 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00208 }
00209 } else {
00210 const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>(mod->detUnit);
00211 const StripTopology * theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00212 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00213 SiStripCluster d = cdigi[idigi];
00214 short strip = d.firstStrip();
00215 GlobalPoint pos = mod->detUnit->surface().toGlobal(theStripTopol->localPosition(strip));
00216 float x = pos.x () / 100.0;
00217 float y;
00218 if(type==RZDet){
00219 x=0.0;
00220 y = sqrt(pos.x ()*pos.x()+pos.y()*pos.y()) / 100.0; if(pos.y()< 0. )y = - y;} else y = pos.y () / 100.0;
00221
00222 float z = pos.z () / 100.0;
00223 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00224 if(siStripClusterRepresentation=="strip"){
00225
00226 MeasurementPoint mp1((float)strip,(float)-0.5);LocalPoint lp1=theStripTopol->localPosition(mp1);
00227 MeasurementPoint mp2((float)strip,(float)+0.5);LocalPoint lp2=theStripTopol->localPosition(mp2);
00228 GlobalPoint pos1 = mod->detUnit->surface().toGlobal(lp1);
00229 GlobalPoint pos2 = mod->detUnit->surface().toGlobal(lp2);
00230 vtx->vertex.set1Value(n,SbVec3f(pos1.x()/100.0,pos1.y()/100.0,pos1.z()/100.0));
00231 coords.set1Value (coord, n);
00232 coord++;n++;
00233 vtx->vertex.set1Value(n,SbVec3f(pos2.x()/100.0,pos2.y()/100.0,pos2.z()/100.0));
00234 coords.set1Value (coord, n);
00235 coord++;n++;
00236 coords.set1Value (coord, SO_END_LINE_INDEX);
00237 coord++;
00238 }
00239
00240 }
00241 }
00242 }
00243 }
00244 vertices->vertex.setNum (nVrtx);
00245 SoPointSet *points = new SoPointSet;
00246 points->vertexProperty.setValue (vertices);
00247 points->numPoints.setValue (nVrtx);
00248 sep->addChild (points);
00249
00250 if(siStripClusterRepresentation=="strip"){
00251 strips->vertexProperty = vtx;
00252 strips->coordIndex = coords;
00253 sep->addChild (strips);
00254 }
00255
00256
00257 }
00258 catch (...)
00259 {
00260 std::cout << "No Clusters." << std::endl;
00261 }
00262 }
00263 return sep;
00264 }
00265
00266 void VisCuTrackerCluster::drawcluster(VisCuTkModule * mod,int nlay,QPainter *p)
00267 {
00268 int x,y;
00269 int xc1=0,xc2=0,yc1=0,yc2=0;
00270 double phi,r,dx,dy,dy1;
00271 double xp[4],yp[4],xp1,yp1;
00272 double vhbot,vhtop,vhapo;
00273 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};
00274 double xt1,yt1,xs1=0.,ys1=0.,xt2,yt2,xs2,ys2,pv1,pv2;
00275 unsigned int numberOfDigis = 0;
00276 unsigned int detType = mod->detUnit->geographicalId().subdetId();
00277 const RectangularPixelTopology * theTopol = 0;
00278 const StripTopology * theStripTopol = 0;
00279 const PixelGeomDetUnit* theDet;
00280 const StripGeomDetUnit* theStripDet;
00281
00282 if(detType<3) {
00283 theDet = dynamic_cast<const PixelGeomDetUnit*>(mod->detUnit);
00284 theTopol = dynamic_cast<const RectangularPixelTopology *>( &(theDet->specificTopology ()));
00285 } else {
00286 theStripDet = dynamic_cast<const StripGeomDetUnit*>(mod->detUnit);
00287 theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00288 }
00289
00290 if(firsteventloaded){
00291 QPointArray a = QPointArray(4);
00292 phi = VisCuTkMap2D::phival(mod->posx,mod->posy);
00293 r = sqrt(mod->posx*mod->posx+mod->posy*mod->posy);
00294 vhbot = mod->width;
00295 vhtop=mod->width;
00296 vhapo=mod->length;
00297 if(nlay < 31){
00298 vhbot = mod->widthAtHalfLength/2.-(mod->width/2.-mod->widthAtHalfLength/2.);
00299 vhtop=mod->width/2.;
00300 vhapo=mod->length/2.;
00301 if(nlay >12 && nlay <19){
00302 if(map->separated)r = r+r;
00303 xp[0]=r-vhtop;yp[0]=-vhapo;
00304 xp[1]=r+vhtop;yp[1]=-vhapo;
00305 xp[2]=r+vhtop;yp[2]=vhapo;
00306 xp[3]=r-vhtop;yp[3]=vhapo;
00307 }else{
00308 if(map->separated)r = r + r/3.;
00309 xp[0]=r-vhapo;yp[0]=-vhbot;
00310 xp[1]=r+vhapo;yp[1]=-vhtop;
00311 xp[2]=r+vhapo;yp[2]=vhtop;
00312 xp[3]=r-vhapo;yp[3]=vhbot;
00313 }
00314 for(int j=0;j<4;j++){
00315 xp1 = xp[j]*cos(phi)-yp[j]*sin(phi);
00316 yp1 = xp[j]*sin(phi)+yp[j]*cos(phi);
00317 xp[j] = xp1;yp[j]=yp1;
00318 }
00319 if(detType<3) {
00320 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00321 if(!map->separated){
00322 int row = cpdigi[idigi].minPixelRow();
00323 int col =cpdigi[idigi].minPixelCol();
00324 GlobalPoint pos = mod->detUnit->surface().toGlobal(theTopol->localPosition(MeasurementPoint(row,col)));
00325 float x = pos.x () / 100.0;
00326 float y = pos.y () / 100.0;
00327 int xc = map->xpixel(x);
00328 int yc = map->ypixel(y);
00329 if(!map->acc){
00330 p->setPen(QColor(0,0,255));
00331 p->setBrush(QColor(0,0,255));
00332 if(!horizontal_view)p->drawRect(xc,yc,3,3);else p->drawRect(yc,map->x_win-xc,3,3);
00333 } else {
00334 if(!horizontal_view){
00335 if(xc > (map->ximg -1)) xc = (map->ximg -1);
00336 if(yc > (map->yimg -1)) yc =(map->yimg-1);
00337 } else {
00338 if(yc > (map->ximg -1)) yc = (map->ximg -1);
00339 if(xc > (map->yimg -1)) xc =(map->yimg-1);
00340 }
00341 QRgb pixel;
00342 if(!horizontal_view){
00343 pixel = map->image->pixel(xc,yc);
00344 }else pixel = map->image->pixel(yc,map->x_win-xc);
00345 int green = qGreen(pixel);
00346 if(green > 1) green = green -20;
00347 if(green < 0) green = 0;
00348 if(!horizontal_view)map->image->setPixel(xc,yc,green); else map->image->setPixel(yc,map->x_win-xc,green);
00349 }
00350 }
00351 numberOfDigis++;
00352 }
00353 } else {
00354 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00355 if(!map->separated){
00356 short strip =cdigi[idigi].firstStrip();
00357 GlobalPoint pos = mod->detUnit->surface().toGlobal(theStripTopol->localPosition(strip));
00358 if(siStripClusterRepresentation=="strip"){
00359 MeasurementPoint mp1((float)strip,(float)-0.5);LocalPoint lp1=theStripTopol->localPosition(mp1);
00360 MeasurementPoint mp2((float)strip,(float)+0.5);LocalPoint lp2=theStripTopol->localPosition(mp2);
00361 GlobalPoint pos1 = mod->detUnit->surface().toGlobal(lp1);
00362 xc1 = map->xpixel(pos1.x()/100.); yc1 = map->ypixel(pos1.y()/100.);
00363 GlobalPoint pos2 = mod->detUnit->surface().toGlobal(lp2);
00364 xc2 = map->xpixel(pos2.x()/100.); yc2 = map->ypixel(pos2.y()/100.);
00365 }
00366 float x = pos.x () / 100.0;
00367 float y = pos.y () / 100.0;
00368 int xc = map->xpixel(x);
00369 int yc = map->ypixel(y);
00370 if(!map->acc){
00371 p->setPen(QColor(0,0,255));
00372 p->setBrush(QColor(0,0,255));
00373 if(!horizontal_view){p->drawRect(xc,yc,3,3);
00374 if(siStripClusterRepresentation=="strip")
00375 p->drawLine(xc1,yc1,xc2,yc2);
00376 }
00377 else {p->drawRect(yc,map->x_win-xc,3,3);
00378 if(siStripClusterRepresentation=="strip")
00379 p->drawLine(yc1,map->x_win-xc1,yc2,map->x_win-xc2);
00380 }
00381
00382 } else {
00383 if(!horizontal_view){
00384 if(xc > (map->ximg -1)) xc = (map->ximg -1);
00385 if(yc > (map->yimg -1)) yc =(map->yimg-1);
00386 } else {
00387 if(yc > (map->ximg -1)) yc = (map->ximg -1);
00388 if(xc > (map->yimg -1)) xc =(map->yimg-1);
00389 }
00390 QRgb pixel;
00391 if(!horizontal_view){
00392 pixel = map->image->pixel(xc,yc);
00393 }else pixel = map->image->pixel(yc,map->x_win-xc);
00394 int green = qGreen(pixel);
00395 if(green > 1) green = green -20;
00396 if(green < 0) green = 0;
00397 if(!horizontal_view)map->image->setPixel(xc,yc,green);else map->image->setPixel(yc,map->x_win-xc,green);
00398 }
00399 }
00400 numberOfDigis++;
00401 }
00402 }
00403 } else {
00404 int numod;
00405 numod=mod->getId();if(numod>100)numod=numod-100;
00406 int vane = mod->getOwner()->getId();
00407 if(map->separated){
00408 dx = vhapo;
00409 phi=M_PI;
00410 xt1=rmedio[nlay-31]; yt1=-vhtop/2.;
00411 xs1 = xt1*cos(phi)-yt1*sin(phi);
00412 ys1 = xt1*sin(phi)+yt1*cos(phi);
00413 xt2=rmedio[nlay-31]; yt2=vhtop/2.;
00414 xs2 = xt2*cos(phi)-yt2*sin(phi);
00415 ys2 = xt2*sin(phi)+yt2*cos(phi);
00416 dy=VisCuTkMap2D::phival(xs2,ys2)-VisCuTkMap2D::phival(xs1,ys1);
00417 dy1 = dy;
00418 if(nlay==31)dy1=0.39;
00419 if(nlay==32)dy1=0.23;
00420 if(nlay==33)dy1=0.16;
00421 xp[0]=vane*(dx+dx/8.);yp[0]=numod*(dy1);
00422 xp[1]=vane*(dx+dx/8.)+dx;yp[1]=numod*(dy1);
00423 xp[2]=vane*(dx+dx/8.)+dx;yp[2]=numod*(dy1)+dy;
00424 xp[3]=vane*(dx+dx/8.);yp[3]=numod*(dy1)+dy;
00425 }else{
00426 xt1=r; yt1=-vhtop/2.;
00427 xs1 = xt1*cos(phi)-yt1*sin(phi);
00428 ys1 = xt1*sin(phi)+yt1*cos(phi);
00429 xt2=r; yt2=vhtop/2.;
00430 xs2 = xt2*cos(phi)-yt2*sin(phi);
00431 ys2 = xt2*sin(phi)+yt2*cos(phi);
00432 pv1=VisCuTkMap2D::phival(xs1,ys1);
00433 pv2=VisCuTkMap2D::phival(xs2,ys2);
00434 if(fabs(pv1-pv2)>M_PI && numod==1)pv1=pv1-2.*M_PI;
00435 if(fabs(pv1-pv2)>M_PI && numod!=1)pv2=pv2+2.*M_PI;
00436 xp[0]=mod->posz-vhapo/2.;yp[0]=4.2*pv1;
00437 xp[1]=mod->posz+vhapo/2.;yp[1]=4.2*pv1;
00438 xp[2]=mod->posz+vhapo/2. ;yp[2]=4.2*pv2;
00439 xp[3]=mod->posz-vhapo/2.;yp[3]=4.2*pv2;
00440 }
00441 if(detType<3) {
00442 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00443 if(!map->separated){
00444 int row = cpdigi[idigi].minPixelRow();
00445 int col =cpdigi[idigi].minPixelCol();
00446 GlobalPoint pos = mod->detUnit->surface().toGlobal(theTopol->localPosition(MeasurementPoint(row,col)));
00447 float x = pos.x () / 100.0;
00448 float y = pos.y () / 100.0;
00449 float z = pos.z () / 100.0;
00450 int xc = map->xpixel(z);
00451 int yc = map->ypixel(4.2*VisCuTkMap2D::phival(x,y));
00452 if(!map->acc){
00453 p->setPen(QColor(0,0,255));
00454 p->setBrush(QColor(0,0,255));
00455 if(!horizontal_view)p->drawRect(xc,yc,3,3);else p->drawRect(yc,map->x_win-xc,3,3);
00456 } else {
00457 if(!horizontal_view){
00458 if(xc > (map->ximg -1)) xc = (map->ximg -1);
00459 if(yc > (map->yimg -1)) yc =(map->yimg-1);
00460 } else {
00461 if(yc > (map->ximg -1)) yc = (map->ximg -1);
00462 if(xc > (map->yimg -1)) xc =(map->yimg-1);
00463 }
00464 QRgb pixel;
00465 if(!horizontal_view){
00466 pixel = map->image->pixel(map->x_win-xc,yc);
00467 }else pixel = map->image->pixel(yc,xc);
00468 int green = qGreen(pixel);
00469 if(green > 1) green = green -20;
00470 if(green < 0) green = 0;
00471 if(!horizontal_view)map->image->setPixel(xc,yc,green);else map->image->setPixel(yc,map->x_win-xc,green);
00472 }
00473 }
00474 numberOfDigis++;
00475 }
00476 } else {
00477 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00478 if(!map->separated){
00479 short strip =cdigi[idigi].firstStrip();
00480 GlobalPoint pos = mod->detUnit->surface().toGlobal(theStripTopol->localPosition(strip));
00481 float x = pos.x () / 100.0;
00482 float y = pos.y () / 100.0;
00483 float z = pos.z () / 100.0;
00484 int xc = map->xpixel(z);
00485 int yc = map->ypixel(4.2*VisCuTkMap2D::phival(x,y));
00486 if(siStripClusterRepresentation=="strip"){
00487 MeasurementPoint mp1((float)strip,(float)-0.5);LocalPoint lp1=theStripTopol->localPosition(mp1);
00488 MeasurementPoint mp2((float)strip,(float)+0.5);LocalPoint lp2=theStripTopol->localPosition(mp2);
00489 GlobalPoint pos1 = mod->detUnit->surface().toGlobal(lp1);
00490 xc1 = map->xpixel(pos1.z()/100.); yc1 = map->ypixel(4.2*VisCuTkMap2D::phival(pos1.x()/100.,pos1.y()/100.));
00491 GlobalPoint pos2 = mod->detUnit->surface().toGlobal(lp2);
00492 xc2 = map->xpixel(pos2.z()/100.); yc2 = map->ypixel(4.2*VisCuTkMap2D::phival(pos2.x()/100.,pos2.y()/100.)); if(mod->getId() > 100 && (abs(abs(yc2-yc)-abs(yc1-yc))) > 20) {if(abs(yc1-yc)>abs(yc2-yc)) {yc1=yc; xc1=xc;yc2=yc;xc2=xc;}else{yc1=yc; xc1=xc; yc2=yc;xc2=xc;}};
00493 }
00494 if(!map->acc){
00495 p->setPen(QColor(0,0,255));
00496 p->setBrush(QColor(0,0,255));
00497 if(!horizontal_view){
00498 if(siStripClusterRepresentation=="strip")
00499 p->drawLine(xc1,yc1,xc2,yc2);
00500 p->drawRect(xc,yc,3,3);}else{
00501 if(siStripClusterRepresentation=="strip")
00502 p->drawLine(yc1,map->x_win-xc1,yc2,map->x_win-xc2);
00503 p->drawRect(yc,map->x_win-xc,3,3);}
00504 } else {
00505 if(!horizontal_view){
00506 if(xc > (map->ximg -1)) xc = (map->ximg -1);
00507 if(yc > (map->yimg -1)) yc =(map->yimg-1);
00508 } else {
00509 if(yc > (map->ximg -1)) yc = (map->ximg -1);
00510 if(xc > (map->yimg -1)) xc =(map->yimg-1);
00511 }
00512 QRgb pixel;
00513 if(!horizontal_view){
00514 pixel = map->image->pixel(xc,yc);
00515 }else pixel = map->image->pixel(yc,map->x_win-xc);
00516 int green = qGreen(pixel);
00517 if(green > 1) green = green -20;
00518 if(green < 0) green = 0;
00519 if(!horizontal_view)map->image->setPixel(xc,yc,green);else map->image->setPixel(yc,map->x_win-xc,green);
00520 }
00521 }
00522 numberOfDigis++;
00523 }
00524 }
00525 }
00526 VisCuTkSubLayer* sl = mod->getOwner();
00527
00528 if(sl->isStereo()&& map->separated)
00529 {
00530 if(mod->getId()>100 ){
00531 for(int j=0;j<3;j++){
00532 x=map->xpixel(xp[j]);y=map->ypixel(yp[j]);
00533 if(!horizontal_view)a.setPoint(j,x,y);else a.setPoint(j,y,map->x_win-x);
00534 }
00535 if(!horizontal_view)a.setPoint(3,x,y);else a.setPoint(3,y,map->x_win-x);
00536 }else {
00537 x=map->xpixel(xp[2]);y=map->ypixel(yp[2]);
00538 if(!horizontal_view)a.setPoint(0,x,y);else a.setPoint(0,y,map->x_win-x);
00539 x=map->xpixel(xp[3]);y=map->ypixel(yp[3]);
00540 if(!horizontal_view)a.setPoint(1,x,y);else a.setPoint(1,y,map->x_win-x);
00541 x=map->xpixel(xp[0]);y=map->ypixel(yp[0]);
00542 if(!horizontal_view)a.setPoint(2,x,y);else a.setPoint(2,y,map->x_win-x);
00543 if(!horizontal_view)a.setPoint(3,x,y);else a.setPoint(3,y,map->x_win-x);
00544 }
00545 } else {
00546 for(int j=0;j<4;j++){
00547 x=map->xpixel(xp[j]);y=map->ypixel(yp[j]);
00548 if(!horizontal_view)a.setPoint(j,x,y);else a.setPoint(j,y,map->x_win-x);
00549 }
00550 }
00551 if(map->acc){mod->value = mod->value + mod->cluster_size;mod->bufvalue = mod->bufvalue + mod->cluster_size;}
00552 else mod->value = mod->cluster_size;
00553 if(map->separated){
00554 p->setPen(QColor( 158, 185, 225));
00555 int green = 255-mod->value; if (green < 0)green = 0;if(green > 255)green=255;
00556 p->setBrush(QColor(255,green,0));
00557 if(mod->value==0)p->setBrush(QColor(255,255,255));
00558 p->drawPolygon(a);
00559 }
00560 p->setPen(QColor(0,0,0));
00561 p->setBrush(Qt::NoBrush);
00562 }
00563 }
00564 std::string VisCuTrackerCluster::updatetext (VisCuTkModule * mod)
00565 {
00566 const RectangularPixelTopology * theTopol = 0;
00567 const StripTopology * theStripTopol = 0;
00568 const PixelGeomDetUnit* theDet;
00569 const StripGeomDetUnit* theStripDet;
00570 std::ostringstream text;
00571
00572 if(mod->cluster_size>0){
00573 unsigned int detType = mod->detUnit->geographicalId().subdetId();
00574 if(detType<3) {
00575 theDet = dynamic_cast<const PixelGeomDetUnit*>(mod->detUnit);
00576 theTopol = dynamic_cast<const RectangularPixelTopology *>( &(theDet->specificTopology ()));
00577 text << mod->cluster_size << " pixel clusters : ---------------------------------------------------- <p>" ;
00578 } else {
00579 theStripDet = dynamic_cast<const StripGeomDetUnit*>(mod->detUnit);
00580 theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00581 text << mod->cluster_size << " strip clusters : --------------------------------------- <p>" ;
00582 }
00583 int ncluster=0;
00584 for(int idigi=mod->cluster_start;idigi!=(mod->cluster_start+mod->cluster_size);idigi++){
00585 text << " Number=" << ncluster++ ;
00586 if(detType<3) {
00587 int row = cpdigi[idigi].minPixelRow();
00588 int col =cpdigi[idigi].minPixelCol();
00589 GlobalPoint pos = mod->detUnit->surface().toGlobal(theTopol->localPosition(MeasurementPoint(row,col)));
00590 text << " Position=" << pos.x () << ", " << pos.y () << ", " << pos.z ()
00591 << " Row=" << row
00592 << " Column=" << col <<"<p>" ;
00593 } else {
00594 short strip =cdigi[idigi].firstStrip();
00595 GlobalPoint pos = mod->detUnit->surface().toGlobal(theStripTopol->localPosition(strip));
00596 text << " Position=" << pos.x () << ", " << pos.y () << ", " << pos.z ()
00597 << " ClusterSize=" << cdigi[idigi].amplitudes().size()
00598 << " Barycenter=" << std::setprecision (5) << cdigi[idigi].barycenter() << "<p>";
00599 }
00600 }
00601 text << " -----------------------------" ;
00602 }
00603 return text.str();
00604 }