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

Move MTD geometry test from expanded to filtered view #25217

Merged
merged 2 commits into from Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 20 additions & 16 deletions Geometry/MTDCommonData/test/TestMTDNumbering.cc
Expand Up @@ -17,9 +17,9 @@
#include "Geometry/Records/interface/IdealGeometryRecord.h"

#include "DetectorDescription/Core/interface/DDValue.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedNode.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos - is it needed?

#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"

#include "Geometry/MTDCommonData/interface/MTDBaseNumber.h"
Expand Down Expand Up @@ -110,9 +110,13 @@ TestMTDNumbering::analyze( const edm::Event& iEvent, const edm::EventSetup& iSet
void TestMTDNumbering::checkMTD ( const DDCompactView& cpv, std::string fname, int nVols , std::string ddtop_ ) {

fname = "dump" + fname;
DDExpandedView epv(cpv);
edm::LogInfo("TestMTDNumbering") << "Top Most LogicalPart = " << epv.logicalPart();
typedef DDExpandedView::nav_type nav_type;

DDPassAllFilter filter;
DDFilteredView fv(cpv, filter);

edm::LogInfo("TestMTDNumbering") << "Top Most LogicalPart = " << fv.logicalPart();

typedef DDFilteredView::nav_type nav_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using nav_type = DDFilteredView::nav_type;

typedef std::map<nav_type,int> id_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using id_type = std::map<nav_type,int>;

id_type idMap;
int id=0;
Expand All @@ -124,21 +128,21 @@ void TestMTDNumbering::checkMTD ( const DDCompactView& cpv, std::string fname, i
size_t limit = 0;

do {
nav_type pos = epv.navPos();
nav_type pos = fv.navPos();
idMap[pos]=id;
size_t num = epv.geoHistory().size();

size_t num = fv.geoHistory().size();

if ( num <= limit ) { write = false; }
if ( epv.geoHistory()[num-1].logicalPart().name() == "btl:BarrelTimingLayer" ) {
if ( fv.geoHistory()[num-1].logicalPart().name() == "btl:BarrelTimingLayer" ) {
isBarrel = true;
limit = num;
write = true;
#ifdef EDM_ML_DEBUG
edm::LogInfo("TestMTDNumbering") << "isBarrel = " << isBarrel;
#endif
}
else if ( epv.geoHistory()[num-1].logicalPart().name() == "etl:EndcapTimingLayer" ) {
else if ( fv.geoHistory()[num-1].logicalPart().name() == "etl:EndcapTimingLayer" ) {
isBarrel = false;
limit = num;
write = true;
Expand All @@ -149,15 +153,15 @@ void TestMTDNumbering::checkMTD ( const DDCompactView& cpv, std::string fname, i

// Actions for MTD volumes: searchg for sensitive detectors

if ( write && epv.geoHistory()[limit-1].logicalPart().name() == ddtop_ ) {
if ( write && fv.geoHistory()[limit-1].logicalPart().name() == ddtop_ ) {

dump << " - " << epv.geoHistory();
dump << " - " << fv.geoHistory();
dump << "\n";

bool isSens = false;

if ( epv.geoHistory()[num-1].logicalPart().specifics().size() > 0 ) {
for ( auto elem : *(epv.geoHistory()[num-1].logicalPart().specifics()[0]) ) {
if ( fv.geoHistory()[num-1].logicalPart().specifics().size() > 0 ) {
for ( auto elem : *(fv.geoHistory()[num-1].logicalPart().specifics()[0]) ) {
if ( elem.second.name() == "SensitiveDetector" ) { isSens = true; break; }
}
}
Expand All @@ -167,7 +171,7 @@ void TestMTDNumbering::checkMTD ( const DDCompactView& cpv, std::string fname, i

if ( isSens ) {

theBaseNumber( epv.geoHistory() );
theBaseNumber( fv.geoHistory() );

if ( isBarrel ) {
BTLDetId::CrysLayout lay = static_cast< BTLDetId::CrysLayout >(theLayout_);
Expand Down Expand Up @@ -195,7 +199,7 @@ void TestMTDNumbering::checkMTD ( const DDCompactView& cpv, std::string fname, i
}
++id;
if ( nVols != 0 && id > nVols ) notReachedDepth = false;
} while (epv.next() && notReachedDepth);
} while (fv.next() && notReachedDepth);
dump << std::flush;
dump.close();
}
Expand Down
39 changes: 21 additions & 18 deletions Geometry/MTDCommonData/test/TestMTDPosition.cc
Expand Up @@ -18,9 +18,9 @@
#include "Geometry/Records/interface/IdealGeometryRecord.h"

#include "DetectorDescription/Core/interface/DDValue.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedNode.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it needed?

#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDSolidShapes.h"
Expand Down Expand Up @@ -100,8 +100,11 @@ TestMTDPosition::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetu
void TestMTDPosition::checkMTD ( const DDCompactView& cpv, std::string fname, int nVols , std::string ddtop_ ) {

fname = "dump" + fname;
DDExpandedView epv(cpv);
edm::LogInfo("TestMTDPosition") << "Top Most LogicalPart = " << epv.logicalPart();

DDPassAllFilter filter;
DDFilteredView fv(cpv, filter);

edm::LogInfo("TestMTDPosition") << "Top Most LogicalPart = " << fv.logicalPart();
typedef DDExpandedView::nav_type nav_type;
typedef std::map<nav_type,int> id_type;
id_type idMap;
Expand All @@ -113,29 +116,29 @@ void TestMTDPosition::checkMTD ( const DDCompactView& cpv, std::string fname, in
size_t limit = 0;

do {
nav_type pos = epv.navPos();
nav_type pos = fv.navPos();
idMap[pos]=id;

size_t num = epv.geoHistory().size();
size_t num = fv.geoHistory().size();

if ( num <= limit ) { write = false; }
if ( epv.geoHistory()[num-1].logicalPart().name() == "btl:BarrelTimingLayer" ||
epv.geoHistory()[num-1].logicalPart().name() == "etl:EndcapTimingLayer" ) {
if ( fv.geoHistory()[num-1].logicalPart().name() == "btl:BarrelTimingLayer" ||
fv.geoHistory()[num-1].logicalPart().name() == "etl:EndcapTimingLayer" ) {
limit = num;
write = true;
}

// Actions for MTD volumes: searchg for sensitive detectors

if ( write && epv.geoHistory()[limit-1].logicalPart().name() == ddtop_ ) {
if ( write && fv.geoHistory()[limit-1].logicalPart().name() == ddtop_ ) {

dump << " - " << epv.geoHistory();
dump << " - " << fv.geoHistory();
dump << "\n";

bool isSens = false;

if ( epv.geoHistory()[num-1].logicalPart().specifics().size() > 0 ) {
for ( auto elem : *(epv.geoHistory()[num-1].logicalPart().specifics()[0]) ) {
if ( fv.geoHistory()[num-1].logicalPart().specifics().size() > 0 ) {
for ( auto elem : *(fv.geoHistory()[num-1].logicalPart().specifics()[0]) ) {
if ( elem.second.name() == "SensitiveDetector" ) { isSens = true; break; }
}
}
Expand All @@ -145,16 +148,16 @@ void TestMTDPosition::checkMTD ( const DDCompactView& cpv, std::string fname, in

if ( isSens ) {

DDBox mySens = epv.geoHistory()[num-1].logicalPart().solid();
DDBox mySens = fv.geoHistory()[num-1].logicalPart().solid();
dump << "Solid shape name: " << DDSolidShapesName::name(mySens.shape()) << "\n";
if ( static_cast<int>(mySens.shape()) != 1 ) { throw cms::Exception("TestMTDPosition") << "MTD sensitive element not a DDBox"; break; }
dump << "Box dimensions: " << mySens.halfX() << " " << mySens.halfY() << " " << mySens.halfZ() << "\n";

char buf[256];
DD3Vector x, y, z;
epv.rotation().GetComponents(x,y,z);
fv.rotation().GetComponents(x,y,z);
size_t s = snprintf(buf, 256, ",%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f",
epv.translation().x(), epv.translation().y(), epv.translation().z(),
fv.translation().x(), fv.translation().y(), fv.translation().z(),
x.X(), y.X(), z.X(),
x.Y(), y.Y(), z.Y(),
x.Z(), y.Z(), z.Z());
Expand All @@ -165,8 +168,8 @@ void TestMTDPosition::checkMTD ( const DDCompactView& cpv, std::string fname, in
DD3Vector zeroLocal(0.,0.,0.);
DD3Vector cn1Local(mySens.halfX(),mySens.halfY(),mySens.halfZ());
double distLocal = cn1Local.R();
DD3Vector zeroGlobal = (epv.rotation())(zeroLocal) + epv.translation();
DD3Vector cn1Global = (epv.rotation())(cn1Local) + epv.translation();;
DD3Vector zeroGlobal = (fv.rotation())(zeroLocal) + fv.translation();
DD3Vector cn1Global = (fv.rotation())(cn1Local) + fv.translation();;
double distGlobal = std::sqrt(std::pow(zeroGlobal.X()-cn1Global.X(),2)
+std::pow(zeroGlobal.Y()-cn1Global.Y(),2)
+std::pow(zeroGlobal.Z()-cn1Global.Z(),2));
Expand Down Expand Up @@ -195,7 +198,7 @@ void TestMTDPosition::checkMTD ( const DDCompactView& cpv, std::string fname, in
}
++id;
if ( nVols != 0 && id > nVols ) notReachedDepth = false;
} while (epv.next() && notReachedDepth);
} while (fv.next() && notReachedDepth);
dump << std::flush;
dump.close();
}
Expand Down