Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:30

0001 #include <cppunit/extensions/HelperMacros.h>
0002 
0003 #include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
0004 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0005 #include "FWCore/ParameterSet/interface/FileInPath.h"
0006 #include "DD4hep/Detector.h"
0007 
0008 #include <string>
0009 #include <memory>
0010 
0011 #include "cppunit/TestAssert.h"
0012 #include "cppunit/TestFixture.h"
0013 
0014 using namespace cms;
0015 using namespace std;
0016 
0017 class testDDFilteredViewFirstChild : public CppUnit::TestFixture {
0018   CPPUNIT_TEST_SUITE(testDDFilteredViewFirstChild);
0019   CPPUNIT_TEST(checkFilteredViewFirstChild);
0020   CPPUNIT_TEST_SUITE_END();
0021 
0022 public:
0023   void setUp() override;
0024   void tearDown() override {}
0025   void checkFilteredViewFirstChild();
0026 
0027 private:
0028   string fileName_;
0029   vector<double> refdattl_;
0030   vector<string> refsattl_;
0031   vector<double> refdLongFL_;
0032   vector<string> refsLongFL_;
0033 };
0034 
0035 CPPUNIT_TEST_SUITE_REGISTRATION(testDDFilteredViewFirstChild);
0036 
0037 void testDDFilteredViewFirstChild::setUp() {
0038   fileName_ = edm::FileInPath("Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml").fullPath();
0039   refdattl_ = {0.000809653, 0.000713002, 0.000654918, 0.000602767, 0.000566295, 0.000541647, 0.000516174, 0.000502512,
0040                0.000504225, 0.000506212, 0.000506275, 0.000487621, 0.000473034, 0.000454002, 0.000442383, 0.000441043,
0041                0.000443609, 0.000433124, 0.000440188, 0.000435257, 0.000439224, 0.000431385, 0.00041707,  0.000415677,
0042                0.000408389, 0.000400293, 0.000400989, 0.000395417, 0.00038936,  0.000383942};
0043   refsattl_ = {"0.8096535E-03/cm", "0.7130018E-03/cm", "0.6549183E-03/cm", "0.6027666E-03/cm", "0.5662951E-03/cm",
0044                "0.5416475E-03/cm", "0.5161745E-03/cm", "0.5025120E-03/cm", "0.5042249E-03/cm", "0.5062117E-03/cm",
0045                "0.5062750E-03/cm", "0.4876212E-03/cm", "0.4730343E-03/cm", "0.4540021E-03/cm", "0.4423832E-03/cm",
0046                "0.4410428E-03/cm", "0.4436095E-03/cm", "0.4331241E-03/cm", "0.4401879E-03/cm", "0.4352570E-03/cm",
0047                "0.4392237E-03/cm", "0.4313847E-03/cm", "0.4170704E-03/cm", "0.4156771E-03/cm", "0.4083890E-03/cm",
0048                "0.4002930E-03/cm", "0.4009888E-03/cm", "0.3954170E-03/cm", "0.3893599E-03/cm", "0.3839422E-03/cm"};
0049   refdLongFL_ = {
0050       227.993, 237.122, 241.701, 256.48, 266.754, 275.988, 276.982, 284.989, 286.307, 290.478, 290.5, 292, 295.5};
0051   refsLongFL_ = {"227.9925651*cm",
0052                  "237.1215213*cm",
0053                  "241.7005445*cm",
0054                  "256.47981*cm",
0055                  "266.7540042*cm",
0056                  "275.987715*cm",
0057                  "276.9823529*cm",
0058                  "284.9889299*cm",
0059                  "286.3065327*cm",
0060                  "290.4779412*cm",
0061                  "290.5*cm",
0062                  "292.0*cm",
0063                  "295.5*cm"};
0064 }
0065 
0066 void testDDFilteredViewFirstChild::checkFilteredViewFirstChild() {
0067   unique_ptr<DDDetector> det = make_unique<DDDetector>("DUMMY", fileName_);
0068   DDFilteredView fview(det.get(), det->description()->worldVolume());
0069   const cms::DDSpecParRegistry& mypar = det->specpars();
0070   std::string attribute{"CMSCutsRegion"};
0071   cms::DDSpecParRefs ref;
0072   mypar.filter(ref, attribute, "MuonChamber");
0073   fview.mergedSpecifics(ref);
0074 
0075   fview.firstChild();
0076   std::cout << fview.name() << " is a " << cms::dd::name(cms::DDSolidShapeMap, fview.shape()) << "\n";
0077   std::cout << "Full path to it is " << fview.path() << "\n";
0078   auto copyNos = fview.copyNos();
0079   if (dd4hep::isA<dd4hep::Box>(fview.solid()))
0080     cout << "It's a Box\n";
0081 
0082   std::cout << fview.name() << " is a " << cms::dd::name(cms::DDSolidShapeMap, fview.shape()) << "\n";
0083   do {
0084     std::cout << fview.path() << "\n";
0085   } while (fview.nextChild());
0086   std::cout << "Current node is:\n" << fview.path() << "\n";
0087 }