Skip to content

Commit

Permalink
Merge pull request #4915 from alja/recogeo4b
Browse files Browse the repository at this point in the history
7x improvements in Fireworks reco geometry tag info
  • Loading branch information
davidlange6 committed Aug 26, 2014
2 parents 9aac5b9 + 196e709 commit 0b3bd08
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 132 deletions.
14 changes: 6 additions & 8 deletions Fireworks/Core/interface/FWGeometry.h
Expand Up @@ -11,6 +11,7 @@ class TEveGeoShape;
class TGeoVolume;
class TGeoShape;
class TFile;
class TObjArray;

#include "TEveVSDStructs.h"
#include "TGeoMatrix.h"
Expand Down Expand Up @@ -40,15 +41,12 @@ class FWGeometry

class VersionInfo {
public:
VersionInfo() :m_haveRE4(false), m_haveGEM(false) {}
TNamed* productionTag;
TNamed* cmsswVersion;
TObjArray* extraDetectors;

bool haveRE4() const { return m_haveRE4; }
bool haveGEM() const { return m_haveGEM; }

void ProcessProductionTag(const char*);
private:
bool m_haveRE4;
bool m_haveGEM;
VersionInfo() : productionTag(0), cmsswVersion(0), extraDetectors(0) {}
bool haveExtraDet(const char*)const;
};

FWGeometry( void );
Expand Down
36 changes: 13 additions & 23 deletions Fireworks/Core/src/FWGeometry.cc
Expand Up @@ -4,6 +4,7 @@
#include "TPRegexp.h"
#include "TSystem.h"
#include "TGeoArb8.h"
#include "TObjArray.h"

#include "Fireworks/Core/interface/FWGeometry.h"
#include "Fireworks/Core/interface/fwLog.h"
Expand Down Expand Up @@ -120,18 +121,17 @@ FWGeometry::loadMap( const char* fileName )
}


TNamed* tag = static_cast<TNamed*>(file->Get( "TAG" ));
if (tag) {
m_versionInfo.ProcessProductionTag(tag->GetTitle());
}


TNamed* version = static_cast<TNamed*>(file->Get( "CMSSW_VERSION" ));
m_versionInfo.productionTag = static_cast<TNamed*>(file->Get( "tag" ));
m_versionInfo.cmsswVersion = static_cast<TNamed*>(file->Get( "CMSSW_VERSION" ));
m_versionInfo.extraDetectors = static_cast<TObjArray*>(file->Get( "ExtraDetectors" ));

TString path = file->GetPath();
if (path.EndsWith(":/")) path.Resize(path.Length() -2);

if (version)
fwLog( fwlog::kInfo ) << Form("Load %s %s from %s\n ", tree->GetName(), version->GetTitle(), file->GetPath());
if (m_versionInfo.productionTag)
fwLog( fwlog::kInfo ) << Form("Load %s %s from %s\n ", tree->GetName(), m_versionInfo.productionTag->GetName(), path.Data());
else
fwLog( fwlog::kInfo ) << Form("Load %s from %s\n ", tree->GetName(), file->GetPath());
fwLog( fwlog::kInfo ) << Form("Load %s from %s\n ", tree->GetName(), path.Data());

file->Close();
}
Expand Down Expand Up @@ -373,18 +373,8 @@ FWGeometry::localToGlobal( const GeomDetInfo& info, const float* local, float* g

//______________________________________________________________________________

void FWGeometry::VersionInfo::ProcessProductionTag(const char* tag)
bool FWGeometry::VersionInfo::haveExtraDet(const char* det) const
{
if (!strncmp(tag,"2015",4))
{
m_haveRE4 = true;
}
else if (!strncmp(tag,"2019",4))
{
m_haveRE4 = true;
m_haveGEM = true;
}


fwLog( fwlog::kDebug ) << Form("FWGeometry::VersionInfo parse tag [%s] GEM=%d RE4=%d \n", tag, m_haveGEM, m_haveRE4);

return (extraDetectors && extraDetectors->FindObject(det)) ? true : false;
}
2 changes: 1 addition & 1 deletion Fireworks/Core/src/FWRPZView.cc
Expand Up @@ -413,7 +413,7 @@ FWRPZView::populateController(ViewerParameterGUI& gui) const
det.addParam(&m_showTrackerBarrel);
det.addParam(&m_showPixelEndcap);
det.addParam(&m_showRpcEndcap);
bool showGEM = m_context->getGeom()->versionInfo().haveGEM();
bool showGEM = m_context->getGeom()->versionInfo().haveExtraDet("GEM");
if (showGEM) det.addParam(&m_showGEM);
}

Expand Down
34 changes: 16 additions & 18 deletions Fireworks/Core/src/FWRPZViewGeometry.cc
Expand Up @@ -496,7 +496,7 @@ FWRPZViewGeometry::showRpcEndcap( bool show )


std::vector<RPCDetId> ids;
int mxSt = m_geom->versionInfo().haveRE4() ? 4:3;
int mxSt = m_geom->versionInfo().haveExtraDet("RE4") ? 4:3;
for (int region = -1; region <=1; ++ region )
{
if (region == 0 ) continue;
Expand Down Expand Up @@ -556,23 +556,21 @@ FWRPZViewGeometry::showGEM( bool show )

std::vector<GEMDetId> ids;
int rArr [] = { -1, 1}; // front back region
int cArr [] = { 10, 30}; // top bottom chamber

for (int st = 1; st <= 2; ++st )
for (int ri = 0; ri < 2; ++ri )
for (int ci= 0; ci < 2; ++ci) {
int maxRoll = st == 1 ? 8 : 12;
for (int roll = 1; roll <=maxRoll; ++roll)
for (int layer = 1; layer <=2; ++layer)
{
GEMDetId id(rArr[ri], 1, st, layer, cArr[ci]/st, roll);
TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
addToCompound(shape, kFWMuonEndcapLineColorIndex);
m_GEMElements->AddElement( shape );
// gEve->AddToListTree(shape, true);
//gEve->AddElement(shape);
}
}
int cArr [] = { 9, 10, 29, 30}; // top bottom chamber

for (int ri = 0; ri < 2; ++ri )
for (int ci= 0; ci < 4; ++ci) {
int minRoll = 2;
//if (ci == 1 || ci == 3) minRoll = 2;
for (int roll = minRoll; roll <=10; ++roll)
for (int layer = 1; layer <=2; ++layer)
{
GEMDetId id(rArr[ri], 1, 1, layer, cArr[ci], roll);
TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
addToCompound(shape, kFWMuonEndcapLineColorIndex);
m_GEMElements->AddElement( shape );
}
}



Expand Down
3 changes: 2 additions & 1 deletion Fireworks/Geometry/interface/FWRecoGeometry.h
Expand Up @@ -2,7 +2,7 @@
# define GEOMETRY_FWRECO_GEOMETRY_H

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

#include "TObjArray.h"
class FWRecoGeometry
{
public:
Expand All @@ -13,6 +13,7 @@ class FWRecoGeometry
{}

FWRecoGeom::InfoMap idToName;
TObjArray extraDet;
};

#endif // GEOMETRY_FWRECO_GEOMETRY_H
19 changes: 10 additions & 9 deletions Fireworks/Geometry/plugins/DumpFWRecoGeometry.cc
Expand Up @@ -23,12 +23,14 @@ class DumpFWRecoGeometry : public edm::EDAnalyzer
virtual void endJob( void ) override;

int m_level;
std::string m_info;
std::string m_tag;
std::string m_outputFileName;
};

DumpFWRecoGeometry::DumpFWRecoGeometry( const edm::ParameterSet& config )
: m_level( config.getUntrackedParameter<int>( "level", 1 )),
m_info( config.getUntrackedParameter<std::string>( "tagInfo", "2015" ))
m_tag( config.getUntrackedParameter<std::string>( "tagInfo", "unknown" )),
m_outputFileName( config.getUntrackedParameter<std::string>( "outputFileName", "cmsRecoGeo.root" ))
{}

void
Expand All @@ -38,10 +40,7 @@ DumpFWRecoGeometry::analyze( const edm::Event& event, const edm::EventSetup& eve

ESTransientHandle<FWRecoGeometry> geoh;
eventSetup.get<FWRecoGeometryRecord>().get( geoh );

std::stringstream s;
s << "cmsRecoGeom" << m_level << ".root";
TFile file( s.str().c_str(), "RECREATE" );
TFile file( m_outputFileName.c_str(), "RECREATE" );

TTree *tree = new TTree("idToGeo", "raw detector id association with geometry");

Expand Down Expand Up @@ -79,10 +78,12 @@ DumpFWRecoGeometry::analyze( const edm::Event& event, const edm::EventSetup& eve
}
file.WriteTObject( tree );

TNamed* version = new TNamed("CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" ));
file.WriteTObject(version);

file.WriteTObject(new TNamed("TAG", m_info.c_str()));
file.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" )));
file.WriteTObject(new TNamed("tag", m_tag.c_str()));
file.WriteTObject(&geoh.product()->extraDet, "ExtraDetectors");



file.Close();
}
Expand Down
14 changes: 9 additions & 5 deletions Fireworks/Geometry/plugins/DumpFWTGeoRecoGeometry.cc
Expand Up @@ -10,6 +10,7 @@
#include "TFile.h"
#include "TTree.h"
#include "TError.h"
#include "TSystem.h"

class DumpFWTGeoRecoGeometry : public edm::EDAnalyzer
{
Expand All @@ -22,11 +23,14 @@ class DumpFWTGeoRecoGeometry : public edm::EDAnalyzer
virtual void beginJob( void ) override;
virtual void endJob( void ) override;

int m_level;
std::string m_tag;
std::string m_outputFileName;
};

DumpFWTGeoRecoGeometry::DumpFWTGeoRecoGeometry( const edm::ParameterSet& config )
: m_level( config.getUntrackedParameter<int>( "level", 1 ))
:m_tag( config.getUntrackedParameter<std::string>( "tagInfo", "unknown" )),
m_outputFileName( config.getUntrackedParameter<std::string>( "outputFileName", "cmsTGeoReco.root" ))

{}

void
Expand All @@ -38,10 +42,10 @@ DumpFWTGeoRecoGeometry::analyze( const edm::Event& event, const edm::EventSetup&
eventSetup.get<FWTGeoRecoGeometryRecord>().get( geoh );
TGeoManager *geom = geoh.product()->manager();//const_cast<TGeoManager*>( geoh.product()->manager());

TFile file( "cmsTRecoGeom.root", "RECREATE" );


TFile file( m_outputFileName.c_str(), "RECREATE" );
file.WriteTObject( &*geom );
file.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" )));
file.WriteTObject(new TNamed("tag", m_tag.c_str()));
file.Close();
}

Expand Down
17 changes: 12 additions & 5 deletions Fireworks/Geometry/plugins/DumpSimGeometry.cc
Expand Up @@ -40,6 +40,7 @@

#include "TFile.h"
#include "TError.h"
#include "TSystem.h"

//
// class declaration
Expand All @@ -52,19 +53,22 @@ class DumpSimGeometry : public edm::EDAnalyzer
~DumpSimGeometry();

private:
// virtual void beginJob();
// virtual void endJob();

virtual void analyze(const edm::Event&, const edm::EventSetup&) override;

std::string m_tag;
std::string m_outputFileName;
};


//
// constructors and destructor
//
DumpSimGeometry::DumpSimGeometry(const edm::ParameterSet&)
DumpSimGeometry::DumpSimGeometry(const edm::ParameterSet& ps)
{
// now do what ever initialization is needed
m_tag = ps.getUntrackedParameter<std::string>("tag", "unknown");
m_outputFileName = ps.getUntrackedParameter<std::string>("outputFileName", "cmsSimGeom.root");

}


Expand All @@ -91,8 +95,11 @@ DumpSimGeometry::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
std::cout << "In the DumpSimGeometry::analyze method...obtained main geometry, level="
<< level << std::endl;

TFile f(TString::Format("cmsSimGeom-%d.root", level), "RECREATE");
// TFile f(TString::Format("cmsSimGeom-%d.root", level), "RECREATE");
TFile f(m_outputFileName.c_str(), "RECREATE");
f.WriteTObject(geom);
f.WriteTObject(new TNamed("CMSSW_VERSION", gSystem->Getenv( "CMSSW_VERSION" )));
f.WriteTObject(new TNamed("tag", m_tag.c_str()));
f.Close();
}

Expand Down

0 comments on commit 0b3bd08

Please sign in to comment.