Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMSSW_6_1_X_SLHC Improvement of rec-hit visualization #153

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Fireworks/Calo/interface/FWECALDetailViewBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class FWECALDetailViewBuilder {
// draw the ecal information with the preset colors
// (if any colors have been preset)
TEveCaloLego* build();

TEveCaloData* buildCaloData(bool xyEE);

// set colors of some predefined detids
void setColor(Color_t color, const std::vector<DetId> &detIds);
Expand All @@ -65,7 +67,7 @@ class FWECALDetailViewBuilder {

// fill data
void fillData(const EcalRecHitCollection *hits,
TEveCaloDataVec *data);
TEveCaloDataVec *data, bool xyEE);
const edm::EventBase *m_event; // the event
const FWGeometry *m_geom; // the geometry
float m_eta; // eta position view centred on
Expand Down
174 changes: 174 additions & 0 deletions Fireworks/Calo/plugins/FWCaloRecHitDigitSetProxyBuilder.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#include "Fireworks/Calo/plugins/FWCaloRecHitDigitSetProxyBuilder.h"
#include "TEveBoxSet.h"
#include "FWCaloRecHitDigitSetProxyBuilder.h"
#include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"
#include "Fireworks/Core/interface/FWEventItem.h"
#include "Fireworks/Core/interface/FWGeometry.h"
#include "Fireworks/Core/interface/BuilderUtils.h"
#include "Fireworks/Core/interface/FWViewEnergyScale.h"
#include "DataFormats/CaloRecHit/interface/CaloRecHit.h"

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

FWCaloRecHitDigitSetProxyBuilder::FWCaloRecHitDigitSetProxyBuilder()
: m_invertBox(false), m_ignoreGeoShapeSize(false)
{}

//______________________________________________________________________________

void FWCaloRecHitDigitSetProxyBuilder::setItem(const FWEventItem* iItem)
{
FWProxyBuilderBase::setItem(iItem);
// if (iItem) iItem->getConfig()->assertParam( "IgnoreShapeSize", false);
}
//______________________________________________________________________________

void FWCaloRecHitDigitSetProxyBuilder::viewContextBoxScale( const float* corners, float scale, bool plotEt, std::vector<float>& scaledCorners, const CaloRecHit*)
{
if ( m_ignoreGeoShapeSize)
{
// Same functionality as fireworks::energyTower3DCorners()

for( int i = 0; i < 24; ++i )
scaledCorners[i] = corners[i];

// Coordinates of a front face scaled
if( m_invertBox )
{
// We know, that an ES rechit geometry in -Z needs correction.
// The back face is actually its front face.
for( unsigned int i = 0; i < 12; i += 3 )
{
m_vector.Set( corners[i] - corners[i + 12], corners[i + 1] - corners[i + 13], corners[i + 2] - corners[i + 14] );
m_vector.Normalize();
m_vector *= scale;

scaledCorners[i] = corners[i] + m_vector.fX;
scaledCorners[i + 1] = corners[i + 1] + m_vector.fY;
scaledCorners[i + 2] = corners[i + 2] + m_vector.fZ;
}
}
else
{
for( unsigned int i = 0; i < 12; i += 3 )
{
m_vector.Set( corners[i + 12] - corners[i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2] );
m_vector.Normalize();
m_vector *= scale;

scaledCorners[i] = corners[i + 12];
scaledCorners[i + 1] = corners[i + 13];
scaledCorners[i + 2] = corners[i + 14];

scaledCorners[i + 12] = corners[i + 12] + m_vector.fX;
scaledCorners[i + 13] = corners[i + 13] + m_vector.fY;
scaledCorners[i + 14] = corners[i + 14] + m_vector.fZ;
}
}
}
else {

// Same functionality as fireworks::energyScaledBox3DCorners().

m_vector.Set(0.f, 0.f, 0.f);
for( unsigned int i = 0; i < 24; i += 3 )
{
m_vector[0] += corners[i];
m_vector[1] += corners[i + 1];
m_vector[2] += corners[i + 2];
}
m_vector *= 1.f/8.f;

if (plotEt)
{
scale *= m_vector.Perp()/m_vector.Mag();
}

// Coordinates for a scaled version of the original box
for( unsigned int i = 0; i < 24; i += 3 )
{
scaledCorners[i] = m_vector[0] + ( corners[i] - m_vector[0] ) * scale;
scaledCorners[i + 1] = m_vector[1] + ( corners[i + 1] - m_vector[1] ) * scale;
scaledCorners[i + 2] = m_vector[2] + ( corners[i + 2] - m_vector[2] ) * scale;
}

if( m_invertBox )
fireworks::invertBox( scaledCorners );
}
}
//_____________________________________________________________________________

float FWCaloRecHitDigitSetProxyBuilder::scaleFactor(const FWViewContext* vc)
{
// printf("scale face %f \n", vc->getEnergyScale()->getScaleFactor3D());
return vc->getEnergyScale()->getScaleFactor3D()/50;
}

//______________________________________________________________________________

void
FWCaloRecHitDigitSetProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc)
{
size_t size = item()->size();
if (!size) return;


std::vector<float> scaledCorners(24);
float scale = scaleFactor(vc);

assert(parent->NumChildren() == 1);
TEveBoxSet* boxSet = static_cast<TEveBoxSet*>(*parent->BeginChildren());

for (int index = 0; index < static_cast<int>(size); ++index)
{
const CaloRecHit* hit = (const CaloRecHit*)item()->modelData(index);
const float* corners = item()->getGeom()->getCorners(hit->detid());
if (corners == 0) continue;

FWDigitSetProxyBuilder::BFreeBox_t* b = (FWDigitSetProxyBuilder::BFreeBox_t*)boxSet->GetPlex()->Atom(index);

viewContextBoxScale(corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
memcpy(b->fVertices, &scaledCorners[0], sizeof(b->fVertices));
}
boxSet->ElementChanged();
}
//______________________________________________________________________________

void
FWCaloRecHitDigitSetProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
{
size_t size = iItem->size();
if (!size) return;

// m_ignoreGeoShapeSize = item()->getConfig()->value<bool>("IgnoreShapeSize");

std::vector<float> scaledCorners(24);

float scale = scaleFactor(vc);

TEveBoxSet* boxSet = addBoxSetToProduct(product);
boxSet->SetAntiFlick(kTRUE);
for (int index = 0; index < static_cast<int>(size); ++index)
{
const CaloRecHit* hit = (const CaloRecHit*)item()->modelData(index);

const float* corners = context().getGeom()->getCorners(hit->detid());
if (corners)
{
m_vector.Set(0.f, 0.f, 0.f);
for( unsigned int i = 0; i < 24; i += 3 )
{
m_vector[0] += corners[i];
m_vector[1] += corners[i + 1];
m_vector[2] += corners[i + 2];
}
m_vector.Normalize();
context().voteMaxEtAndEnergy( m_vector.Perp() *hit->energy(), hit->energy());
viewContextBoxScale( corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
}

addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index).displayProperties());
}
}


34 changes: 34 additions & 0 deletions Fireworks/Calo/plugins/FWCaloRecHitDigitSetProxyBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef Fireworks_Calo_FWCaloRecHitDigitSetProxyBuilder_h
#define Fireworks_Calo_FWCaloRecHitDigitSetProxyBuilder_h

#include "TEveVector.h"
#include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"

class CaloRecHit;

class FWCaloRecHitDigitSetProxyBuilder : public FWDigitSetProxyBuilder
{
public:
FWCaloRecHitDigitSetProxyBuilder();
virtual ~FWCaloRecHitDigitSetProxyBuilder( void ) {}

virtual void setItem(const FWEventItem* iItem);

virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );

virtual float scaleFactor(const FWViewContext* vc);
virtual void invertBox(bool x ) { m_invertBox = x ;}
virtual void viewContextBoxScale( const float* corners, float scale, bool plotEt, std::vector<float>& scaledCorners, const CaloRecHit*);

private:

FWCaloRecHitDigitSetProxyBuilder( const FWCaloRecHitDigitSetProxyBuilder& );
const FWCaloRecHitDigitSetProxyBuilder& operator=( const FWCaloRecHitDigitSetProxyBuilder& );

bool m_invertBox;
bool m_ignoreGeoShapeSize;
TEveVector m_vector; // internal memeber, to avoid constant recreation
};
#endif
22 changes: 11 additions & 11 deletions Fireworks/Calo/plugins/FWCastorRecHitProxyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
* Created by Ianna Osborne on 7/8/10.
*
*/

#include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"
#include "Fireworks/Core/interface/FWEventItem.h"
#include "Fireworks/Core/interface/FWGeometry.h"
#include "Fireworks/Core/interface/BuilderUtils.h"
#include "DataFormats/HcalRecHit/interface/CastorRecHit.h"
#include "Fireworks/Calo/plugins/FWCaloRecHitDigitSetProxyBuilder.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"

class FWCastorRecHitProxyBuilder : public FWDigitSetProxyBuilder
class FWCastorRecHitProxyBuilder : public FWCaloRecHitDigitSetProxyBuilder
{
public:
FWCastorRecHitProxyBuilder( void ) {}
virtual ~FWCastorRecHitProxyBuilder( void ) {}


virtual float scaleFactor(const FWViewContext* vc) { return 10 * FWCaloRecHitDigitSetProxyBuilder::scaleFactor(vc); }

REGISTER_PROXYBUILDER_METHODS();

private:
FWCastorRecHitProxyBuilder( const FWCastorRecHitProxyBuilder& );
const FWCastorRecHitProxyBuilder& operator=( const FWCastorRecHitProxyBuilder& );

virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
};

REGISTER_FWPROXYBUILDER( FWCastorRecHitProxyBuilder, CastorRecHitCollection, "Castor RecHit", FWViewType::kISpyBit );

// AMT:: scale box round center. Scaleing and e/et added now. Previously used fireworks::energyTower3DCorners();

/*
void FWCastorRecHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
{
const CastorRecHitCollection* collection = 0;
Expand All @@ -50,5 +51,4 @@ void FWCastorRecHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList
addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
}
}

REGISTER_FWPROXYBUILDER( FWCastorRecHitProxyBuilder, CastorRecHitCollection, "Castor RecHit", FWViewType::kISpyBit );
*/
83 changes: 14 additions & 69 deletions Fireworks/Calo/plugins/FWEcalRecHitProxyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,94 +5,40 @@
* Created by Ianna Osborne on 5/28/10.
*
*/
#include "TEveBoxSet.h"
#include "TEveChunkManager.h"
#include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"
#include "Fireworks/Core/interface/FWEventItem.h"
#include "Fireworks/Core/interface/FWGeometry.h"
#include "Fireworks/Core/interface/FWViewEnergyScale.h"
#include "Fireworks/Core/interface/BuilderUtils.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "Fireworks/Calo/plugins/FWCaloRecHitDigitSetProxyBuilder.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"

class FWEcalRecHitProxyBuilder : public FWDigitSetProxyBuilder
class FWEcalRecHitProxyBuilder : public FWCaloRecHitDigitSetProxyBuilder
{
public:
FWEcalRecHitProxyBuilder():FWDigitSetProxyBuilder(), m_plotEt(true) {}
FWEcalRecHitProxyBuilder() {}
virtual ~FWEcalRecHitProxyBuilder() {}

virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
virtual void viewContextBoxScale( const float* corners, float scale, bool plotEt, std::vector<float>& scaledCorners, const CaloRecHit*);

REGISTER_PROXYBUILDER_METHODS();

private:
FWEcalRecHitProxyBuilder( const FWEcalRecHitProxyBuilder& );
const FWEcalRecHitProxyBuilder& operator=( const FWEcalRecHitProxyBuilder& );

virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );

bool m_plotEt;
};

//______________________________________________________________________________


void
FWEcalRecHitProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc)
{

if (m_plotEt != vc->getEnergyScale()->getPlotEt() )
{
m_plotEt = !m_plotEt;

const EcalRecHitCollection* collection = 0;
item()->get( collection );
if (! collection)
return;

int index = 0;
std::vector<float> scaledCorners(24);
for (std::vector<EcalRecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it, ++index)
{
const float* corners = item()->getGeom()->getCorners((*it).detid());
if (corners == 0)
continue;

Float_t scale = 10.0;
bool reflect = false;
if (EcalSubdetector( (*it).detid().subdetId() ) == EcalPreshower)
{
scale = 1000.0; // FIXME: The scale should be taken form somewhere else
reflect = corners[2] < 0;
}
void FWEcalRecHitProxyBuilder::viewContextBoxScale( const float* corners, float scale, bool plotEt, std::vector<float>& scaledCorners, const CaloRecHit* hit)
{
invertBox((EcalSubdetector( hit->detid().subdetId() ) == EcalPreshower) && (corners[2] < 0));
FWCaloRecHitDigitSetProxyBuilder::viewContextBoxScale(corners, scale, plotEt, scaledCorners, hit );
}

FWDigitSetProxyBuilder::BFreeBox_t* b = (FWDigitSetProxyBuilder::BFreeBox_t*)getBoxSet()->GetPlex()->Atom(index);
/*
printf("--------------------scale product \n");
for (int i = 0; i < 8 ; ++i)
printf("[%f %f %f ]\n",b->fVertices[i][0], b->fVertices[i][1],b->fVertices[i][2] );
*/

if (m_plotEt)
fireworks::etTower3DCorners(corners, (*it).energy() * scale, scaledCorners, reflect);
else
fireworks::energyTower3DCorners(corners, (*it).energy() * scale, scaledCorners, reflect);
REGISTER_FWPROXYBUILDER( FWEcalRecHitProxyBuilder, EcalRecHitCollection, "Ecal RecHit", FWViewType::kISpyBit );

memcpy(b->fVertices, &scaledCorners[0], sizeof(b->fVertices));
// AMT: Scale box round cener. Prviousy used fireworks::energyTower3DCorners().
// Why differnt scale factor in EcalPreShower ???

/*
printf("after \n");
for (int i = 0; i < 8 ; ++i)
printf("[%f %f %f ]\n",b->fVertices[i][0], b->fVertices[i][1],b->fVertices[i][2] );
*/
}
getBoxSet()->ElementChanged();
}
}

//______________________________________________________________________________

/*
void FWEcalRecHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
{
m_plotEt = vc->getEnergyScale()->getPlotEt();
Expand Down Expand Up @@ -127,5 +73,4 @@ void FWEcalRecHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList*
addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
}
}

REGISTER_FWPROXYBUILDER( FWEcalRecHitProxyBuilder, EcalRecHitCollection, "Ecal RecHit", FWViewType::kISpyBit );
*/
Loading