Skip to content

Commit

Permalink
Merged from-CMSSW_10_3_0_pre5 from repository Mourtz with cms-merge-t…
Browse files Browse the repository at this point in the history
…opic
  • Loading branch information
Mourtz committed Nov 1, 2018
2 parents c395e0c + 6ec21d8 commit fe5711c
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@ __init__.py
.#*
#*#
*~
*.root
3 changes: 3 additions & 0 deletions Fireworks/Core/interface/FW3DViewBase.h
Expand Up @@ -83,6 +83,9 @@ class FW3DViewBase : public FWEveView
FWBoolParameter m_showPixelEndcap;
FWBoolParameter m_showTrackerBarrel;
FWBoolParameter m_showTrackerEndcap;
FWBoolParameter m_showHGCalEE;
FWBoolParameter m_showHGCalHSi;
FWBoolParameter m_showHGCalHSc;

TEveBoxSet* m_ecalBarrel;
FWBoolParameter m_showEcalBarrel;
Expand Down
6 changes: 6 additions & 0 deletions Fireworks/Core/interface/FW3DViewGeometry.h
Expand Up @@ -47,6 +47,9 @@ class FW3DViewGeometry : public FWViewGeometryList
void showPixelEndcap( bool );
void showTrackerBarrel( bool );
void showTrackerEndcap( bool );
void showHGCalEE( bool );
void showHGCalHSi( bool );
void showHGCalHSc( bool );
private:
FW3DViewGeometry(const FW3DViewGeometry&) = delete; // stop default

Expand All @@ -62,6 +65,9 @@ class FW3DViewGeometry : public FWViewGeometryList
TEveElementList* m_pixelEndcapElements;
TEveElementList* m_trackerBarrelElements;
TEveElementList* m_trackerEndcapElements;
TEveElementList* m_HGCalEEElements;
TEveElementList* m_HGCalHSiElements;
TEveElementList* m_HGCalHScElements;
};

#endif
3 changes: 3 additions & 0 deletions Fireworks/Core/interface/FWColorManager.h
Expand Up @@ -37,6 +37,9 @@ enum FWGeomColorIndex
kFWTrackerEndcapColorIndex,
kFWMuonBarrelLineColorIndex,
kFWMuonEndcapLineColorIndex,
HGCalEEColorIndex,
HGCalHSiColorIndex,
HGCalHScColorIndex,
kFWGeomColorSize
};

Expand Down
5 changes: 4 additions & 1 deletion Fireworks/Core/interface/FWGeometry.h
Expand Up @@ -20,6 +20,7 @@ class TObjArray;

#include "TEveVSDStructs.h"
#include "TGeoMatrix.h"
#include "TGeoXtru.h"

#include "Fireworks/Core/interface/FWRecoGeom.h"

Expand All @@ -30,7 +31,7 @@ class FWGeometry
static const int kDetOffset = 28;
static const int kSubdetOffset = 25;

enum Detector { Tracker = 1, Muon = 2, Ecal = 3, Hcal = 4, Calo = 5 };
enum Detector { Tracker = 1, Muon = 2, Ecal = 3, Hcal = 4, Calo = 5, HGCalEE=8, HGCalHSi=9, HGCalHSc=10, HGCalTrigger=11 };
enum SubDetector { PixelBarrel = 1, PixelEndcap = 2, TIB = 3, TID = 4, TOB = 5, TEC = 6, CSC = 7, DT = 8, RPCBarrel = 9, RPCEndcap = 10, GEM = 11, ME0 = 12};

struct Range {
Expand Down Expand Up @@ -71,12 +72,14 @@ class FWGeometry

// extract globally positioned shape for stand alone use
TEveGeoShape* getEveShape( unsigned int id ) const;
TEveGeoShape* getHGCalEveShape( unsigned int id ) const;

// get shape description parameters
const float* getShapePars( unsigned int id ) const;

// get all known detector ids with id matching mask
std::vector<unsigned int> getMatchedIds( Detector det, SubDetector subdet ) const;
std::vector<unsigned int> getMatchedIds( Detector det ) const;

// get reco geometry
const float* getCorners( unsigned int id ) const;
Expand Down
9 changes: 9 additions & 0 deletions Fireworks/Core/src/FW3DViewBase.cc
Expand Up @@ -112,6 +112,9 @@ FW3DViewBase::FW3DViewBase(TEveWindowSlot* iParent, FWViewType::EType typeId, un
m_showPixelEndcap(this, "Show Pixel Endcap", false),
m_showTrackerBarrel(this, "Show Tracker Barrel", false ),
m_showTrackerEndcap(this, "Show Tracker Endcap", false),
m_showHGCalEE(this, "Show HGCalEE", false),
m_showHGCalHSi(this, "Show HGCalHSi", false),
m_showHGCalHSc(this, "Show HGCalHSc", false),
m_ecalBarrel(nullptr),
m_showEcalBarrel(this, "Show Ecal Barrel", false),
m_rnrStyle(this, "Render Style", 0l, 0l, 2l),
Expand Down Expand Up @@ -182,6 +185,9 @@ void FW3DViewBase::setContext(const fireworks::Context& context)
m_showPixelEndcap.changed_.connect(boost::bind(&FW3DViewGeometry::showPixelEndcap,m_geometry,_1));
m_showTrackerBarrel.changed_.connect(boost::bind(&FW3DViewGeometry::showTrackerBarrel,m_geometry,_1));
m_showTrackerEndcap.changed_.connect(boost::bind(&FW3DViewGeometry::showTrackerEndcap,m_geometry,_1));
m_showHGCalEE.changed_.connect(boost::bind(&FW3DViewGeometry::showHGCalEE,m_geometry,_1));
m_showHGCalHSi.changed_.connect(boost::bind(&FW3DViewGeometry::showHGCalHSi,m_geometry,_1));
m_showHGCalHSc.changed_.connect(boost::bind(&FW3DViewGeometry::showHGCalHSc,m_geometry,_1));
m_showMuonEndcap.changed_.connect(boost::bind(&FW3DViewGeometry::showMuonEndcap,m_geometry,_1));
m_showEcalBarrel.changed_.connect(boost::bind(&FW3DViewBase::showEcalBarrel, this,_1));

Expand Down Expand Up @@ -455,6 +461,9 @@ FW3DViewBase::populateController(ViewerParameterGUI& gui) const
addParam(&m_showMuonEndcap).
addParam(&m_showTrackerBarrel).
addParam(&m_showTrackerEndcap).
addParam(&m_showHGCalEE).
addParam(&m_showHGCalHSi).
addParam(&m_showHGCalHSc).
addParam(&m_showPixelBarrel).
addParam(&m_showPixelEndcap).
addParam(&m_showEcalBarrel).
Expand Down
88 changes: 87 additions & 1 deletion Fireworks/Core/src/FW3DViewGeometry.cc
Expand Up @@ -48,7 +48,8 @@ FW3DViewGeometry::FW3DViewGeometry(const fireworks::Context& context):
m_pixelBarrelElements(nullptr),
m_pixelEndcapElements(nullptr),
m_trackerBarrelElements(nullptr),
m_trackerEndcapElements(nullptr)
m_trackerEndcapElements(nullptr),
m_HGCalEEElements(nullptr), m_HGCalHSiElements(nullptr), m_HGCalHScElements(nullptr)
{

SetElementName("3D Geometry");
Expand Down Expand Up @@ -415,4 +416,89 @@ FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
}
}

//______________________________________________________________________________
void
FW3DViewGeometry::showHGCalEE(bool showHGCalEE){
if( showHGCalEE && !m_HGCalEEElements ){
m_HGCalEEElements = new TEveElementList("HGCalEE");
std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::HGCalEE );
for( std::vector<unsigned int>::const_iterator id = ids.begin();
id != ids.end(); ++id )
{
TEveGeoShape* shape = m_geom->getHGCalEveShape( *id );
shape->SetTitle(Form("HGCalEE %d",*id));
{
const unsigned int layer = (*id>>20)&0x1F;
float color[3];
color[0] = color[1] = color[2] = 0.2f + 0.8f*(1.0f-layer/28.0f);
color[1] = 0.5f*(layer&2U) + 0.5f*color[1];
const unsigned int type = (*id>>26)&0x3;
color[0] *= (type == 0) ? 1.0f : 1.0f;
color[1] *= (type == 0) ? 1.0f : 0.4f;
color[2] *= (type == 0) ? 0.0f : 0.0f;
shape->SetMainColorRGB( color[0], color[1], color[2] );
shape->SetPickable(false);
m_colorComp[HGCalEEColorIndex]->AddElement(shape);
}
m_HGCalEEElements->AddElement( shape );
}
AddElement( m_HGCalEEElements );
}
if (m_HGCalEEElements ){
m_HGCalEEElements->SetRnrState( showHGCalEE );
gEve->Redraw3D();
}
}

void
FW3DViewGeometry::showHGCalHSi(bool showHGCalHSi){
if( showHGCalHSi && !m_HGCalHSiElements ){
m_HGCalHSiElements = new TEveElementList("HGCalHSi");
std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::HGCalHSi );
for( std::vector<unsigned int>::const_iterator id = ids.begin();
id != ids.end(); ++id )
{
TEveGeoShape* shape = m_geom->getHGCalEveShape( *id );
shape->SetTitle(Form("HGCalHSi %d",*id));
{
const unsigned int layer = (*id>>20)&0x1F;
float color[3];
color[0] = color[1] = color[2] = 0.3f + 0.7f*(1.0f-layer/28.0f);
color[1] = 0.5f*(layer&2U) + 0.5f*color[1];
const unsigned int type = (*id>>26)&0x3;
color[0] *= (type == 0) ? 1.0f : 1.0f;
color[1] *= (type == 0) ? 1.0f : 0.4f;
color[2] *= (type == 0) ? 0.0f : 0.0f;
shape->SetMainColorRGB( color[0], color[1], color[2] );
shape->SetPickable(false);
m_colorComp[HGCalEEColorIndex]->AddElement(shape);
}
m_HGCalHSiElements->AddElement( shape );
}
AddElement( m_HGCalHSiElements );
}
if (m_HGCalHSiElements ){
m_HGCalHSiElements->SetRnrState( showHGCalHSi );
gEve->Redraw3D();
}
}

void FW3DViewGeometry::showHGCalHSc(bool showHGCalHSc){
if( showHGCalHSc && ! m_HGCalHScElements )
{
m_HGCalHScElements = new TEveElementList( "HGCalHSc" );
std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::HGCalHSc );
for( std::vector<unsigned int>::const_iterator id = ids.begin();
id != ids.end(); ++id )
{
TEveGeoShape* shape = m_geom->getEveShape( *id );
addToCompound(shape, HGCalHScColorIndex);
m_HGCalHScElements->AddElement( shape );
}
}
if( m_HGCalHScElements )
{
m_HGCalHScElements->SetRnrState( showHGCalHSc );
gEve->Redraw3D();
}
}
4 changes: 4 additions & 0 deletions Fireworks/Core/src/FWColorManager.cc
Expand Up @@ -108,6 +108,10 @@ void FWColorManager::setDefaultGeomColors()
m_geomColor[kFWMuonBarrelLineColorIndex] = 1025;
m_geomColor[kFWMuonEndcapLineColorIndex] = 1022;

m_geomColor[HGCalEEColorIndex] = 1000;
m_geomColor[HGCalHSiColorIndex] = 1000;
m_geomColor[HGCalHScColorIndex] = 1000;

switch (m_paletteId) {
case (kArctic):
// m_geomColor[kFWMuonBarrelLineColorIndex] = 1027;
Expand Down
100 changes: 100 additions & 0 deletions Fireworks/Core/src/FWGeometry.cc
Expand Up @@ -225,6 +225,27 @@ FWGeometry::getMatchedIds( Detector det, SubDetector subdet ) const
return ids;
}

std::vector<unsigned int>
FWGeometry::getMatchedIds( Detector det ) const
{
std::vector<unsigned int> ids;
for( IdToInfoItr it = m_idToInfo.begin(), itEnd = m_idToInfo.end();
it != itEnd; ++it )
{
if( (( it->id >> kDetOffset ) & 0xF) != det ) continue;
// select only the 1st layer
// if(((it->id>>20)&0x1F) != 1) continue;
bool flag(false);
for(std::vector<unsigned int>::iterator id_it = ids.begin(); id_it != ids.end(); ++id_it) {
flag = (~0x3FF & it->id) == (~0x3FF & *id_it);
if(flag) break;
}
if(flag) continue;
ids.push_back( it->id );
}
return ids;
}

TGeoShape*
FWGeometry::getShape( unsigned int id ) const
{
Expand Down Expand Up @@ -293,6 +314,85 @@ FWGeometry::getEveShape( unsigned int id ) const
}
}

TEveGeoShape*
FWGeometry::getHGCalEveShape( unsigned int id ) const
{
#if 0
const unsigned int type = (id>>26)&0x3;
// select the middle cell of each waifer
id &= ~0x3FF;
id |= (type == 0) ? 0x16B : 0xE7;
#else
float sideToSideWaferSize = 16.7441;
float dx = sideToSideWaferSize/2;
float sidey = dx/sqrt(3);
float dy = 2*sidey;

int waferUint = (id >> 10) & 0xF;
int waferVint = (id >> 15) & 0xF;
float waferU = ((id>>14) & 0x1) ? -sideToSideWaferSize*waferUint : sideToSideWaferSize*waferUint;
float waferV = ((id>>19) & 0x1) ? -sideToSideWaferSize*waferVint : sideToSideWaferSize*waferVint;

float waferX = (-2*waferU+waferV)/2;
float waferY = waferV*sqrt(3)/2;
#endif
IdToInfoItr it = FWGeometry::find( id );
if( it == m_idToInfo.end())
{
fwLog( fwlog::kWarning ) << "no reco geometry found for id " << id << std::endl;
return nullptr;
}
else
{
GeomDetInfo info = *it;

TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
TEveGeoShape* shape = new TEveGeoShape(TString::Format("RecoGeom Id=%u", id));
#if 0
TGeoShape* geoShape = new TGeoBBox( info.shape[1], info.shape[2], info.shape[3] );
#else
float dz = fabs(info.points[14] - info.points[2])*0.5;
// std::cout << "new point:\n";
// for(int i = 0; i < 24;)
// std::cout << info.points[i++] << ", " << info.points[i++] << ", " << info.points[i++] << "\n";
info.translation[2] = (info.points[14] + info.points[2])/2.0f;
info.translation[0] = waferX*((0 < info.translation[2]) - (info.translation[2] < 0));
info.translation[1] = waferY;
// scale up each cell
// size[0] *= (type == 0) ? 12.0f : 8.0f;
// size[1] *= (type == 0) ? 12.0f : 8.0f;
// roll = pitch = yaw = 0.0
info.matrix[0] = 1.0;
info.matrix[4] = 1.0;
info.matrix[8] = 1.0;
TGeoXtru* geoShape = new TGeoXtru(2);
Double_t x[6] = {
-dx, -dx, 0.0, dx, dx, 0.0
};
Double_t y[6] = {
-sidey,
sidey,
dy,
sidey,
-sidey,
-dy
};
geoShape->DefinePolygon(6,x,y);
geoShape->DefineSection(0, -dz);
geoShape->DefineSection(1, dz);
#endif
shape->SetShape( geoShape );
double array[16] = { info.matrix[0], info.matrix[3], info.matrix[6], 0.,
info.matrix[1], info.matrix[4], info.matrix[7], 0.,
info.matrix[2], info.matrix[5], info.matrix[8], 0.,
info.translation[0], info.translation[1], info.translation[2], 1.
};
// Set transformation matrix from a column-major array
shape->SetTransMatrix( array );
return shape;
}
}

const float*
FWGeometry::getCorners( unsigned int id ) const
{
Expand Down
1 change: 1 addition & 0 deletions Fireworks/SimData/plugins/BuildFile.xml
Expand Up @@ -8,5 +8,6 @@
<use name="SimDataFormats/CaloAnalysis"/>
<lib name="Eve"/>
<lib name="EG"/>
<lib name="Geom"/>
<flags EDM_PLUGIN="1"/>
</library>

0 comments on commit fe5711c

Please sign in to comment.