Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-14 22:35:48

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include "FWCore/ServiceRegistry/interface/Service.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/PluginManager/interface/ModuleDef.h"
0012 
0013 #include "CondFormats/Common/interface/FileBlob.h"
0014 #include "CondFormats/GeometryObjects/interface/PGeometricDet.h"
0015 #include "CondFormats/GeometryObjects/interface/PCaloGeometry.h"
0016 #include "CondFormats/GeometryObjects/interface/RecoIdealGeometry.h"
0017 #include "CondFormats/GeometryObjects/interface/CSCRecoDigiParameters.h"
0018 #include "DataFormats/Math/interface/Rounding.h"
0019 
0020 #include "Geometry/Records/interface/GeometryFileRcd.h"
0021 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0022 #include "Geometry/Records/interface/DTRecoGeometryRcd.h"
0023 #include "Geometry/Records/interface/RPCRecoGeometryRcd.h"
0024 #include "Geometry/Records/interface/CSCRecoGeometryRcd.h"
0025 #include "Geometry/Records/interface/CSCRecoDigiParametersRcd.h"
0026 #include "Geometry/Records/interface/PEcalBarrelRcd.h"
0027 #include "Geometry/Records/interface/PEcalEndcapRcd.h"
0028 #include "Geometry/Records/interface/PEcalPreshowerRcd.h"
0029 #include "Geometry/Records/interface/PHcalRcd.h"
0030 #include "Geometry/Records/interface/PHGCalRcd.h"
0031 #include "Geometry/Records/interface/PCaloTowerRcd.h"
0032 #include "Geometry/Records/interface/PCastorRcd.h"
0033 #include "Geometry/Records/interface/PZdcRcd.h"
0034 
0035 #include <iostream>
0036 #include <string>
0037 #include <vector>
0038 
0039 namespace {
0040 
0041   class FmtOstream {
0042   public:
0043     FmtOstream() = default;
0044 
0045     friend FmtOstream &operator<<(FmtOstream &output, const double val) {
0046       std::cout << " " << cms_rounding::roundIfNear0(val);
0047       return (output);
0048     }
0049 
0050     friend FmtOstream &operator<<(FmtOstream &output, const int val) {
0051       std::cout << " " << val;
0052       return (output);
0053     }
0054 
0055     friend FmtOstream &operator<<(FmtOstream &output, const unsigned int val) {
0056       std::cout << " " << val;
0057       return (output);
0058     }
0059 
0060     friend FmtOstream &operator<<(FmtOstream &output, const bool val) {
0061       std::cout << " " << (val ? "true" : "false");
0062       return (output);
0063     }
0064 
0065     friend FmtOstream &operator<<(FmtOstream &output, const std::string &strVal) {
0066       std::cout << " " << strVal;
0067       return (output);
0068     }
0069 
0070     friend FmtOstream &operator<<(FmtOstream &output, const char *cstr) {
0071       std::cout << " " << cstr;
0072       return (output);
0073     }
0074   };
0075 
0076   class GeometryTester : public edm::one::EDAnalyzer<> {
0077   public:
0078     GeometryTester(edm::ParameterSet const &);
0079     void beginJob() override {}
0080     void analyze(edm::Event const &, edm::EventSetup const &) override;
0081     void endJob() override {}
0082 
0083   private:
0084     bool m_xmltest, m_tktest, m_ecaltest;
0085     bool m_hcaltest, m_hgcaltest, m_calotowertest;
0086     bool m_castortest, m_zdctest, m_csctest;
0087     bool m_dttest, m_rpctest, m_round;
0088     std::string m_geomLabel;
0089     edm::ESGetToken<FileBlob, GeometryFileRcd> m_xmlGeoToken;
0090     edm::ESGetToken<PGeometricDet, IdealGeometryRecord> m_tkGeoToken;
0091     edm::ESGetToken<PCaloGeometry, PEcalBarrelRcd> m_ebGeoToken;
0092     edm::ESGetToken<PCaloGeometry, PEcalEndcapRcd> m_eeGeoToken;
0093     edm::ESGetToken<PCaloGeometry, PEcalPreshowerRcd> m_epGeoToken;
0094     edm::ESGetToken<PCaloGeometry, PHcalRcd> m_hGeoToken;
0095     edm::ESGetToken<PCaloGeometry, PHGCalRcd> m_hgcGeoToken;
0096     edm::ESGetToken<PCaloGeometry, PCaloTowerRcd> m_ctGeoToken;
0097     edm::ESGetToken<PCaloGeometry, PCastorRcd> m_castGeoToken;
0098     edm::ESGetToken<PCaloGeometry, PZdcRcd> m_zdcGeoToken;
0099     edm::ESGetToken<CSCRecoDigiParameters, CSCRecoDigiParametersRcd> m_cscDigiGeoToken;
0100     edm::ESGetToken<RecoIdealGeometry, CSCRecoGeometryRcd> m_cscGeoToken;
0101     edm::ESGetToken<RecoIdealGeometry, DTRecoGeometryRcd> m_dtGeoToken;
0102     edm::ESGetToken<RecoIdealGeometry, RPCRecoGeometryRcd> m_rpcGeoToken;
0103   };
0104 }  // namespace
0105 
0106 GeometryTester::GeometryTester(const edm::ParameterSet &iConfig)
0107     : m_xmltest(iConfig.getUntrackedParameter<bool>("XMLTest", true)),
0108       m_tktest(iConfig.getUntrackedParameter<bool>("TrackerTest", true)),
0109       m_ecaltest(iConfig.getUntrackedParameter<bool>("EcalTest", true)),
0110       m_hcaltest(iConfig.getUntrackedParameter<bool>("HcalTest", true)),
0111       m_hgcaltest(iConfig.getUntrackedParameter<bool>("HGCalTest", true)),
0112       m_calotowertest(iConfig.getUntrackedParameter<bool>("CaloTowerTest", true)),
0113       m_castortest(iConfig.getUntrackedParameter<bool>("CastorTest", true)),
0114       m_zdctest(iConfig.getUntrackedParameter<bool>("ZDCTest", true)),
0115       m_csctest(iConfig.getUntrackedParameter<bool>("CSCTest", true)),
0116       m_dttest(iConfig.getUntrackedParameter<bool>("DTTest", true)),
0117       m_rpctest(iConfig.getUntrackedParameter<bool>("RPCTest", true)),
0118       m_round(iConfig.getUntrackedParameter<bool>("roundValues", false)),
0119       m_geomLabel(iConfig.getUntrackedParameter<std::string>("geomLabel", "Extended")),
0120       m_xmlGeoToken(esConsumes(edm::ESInputTag("", m_geomLabel))),
0121       m_tkGeoToken(esConsumes()),
0122       m_ebGeoToken(esConsumes()),
0123       m_eeGeoToken(esConsumes()),
0124       m_epGeoToken(esConsumes()),
0125       m_hGeoToken(esConsumes()),
0126       m_hgcGeoToken(esConsumes()),
0127       m_ctGeoToken(esConsumes()),
0128       m_castGeoToken(esConsumes()),
0129       m_zdcGeoToken(esConsumes()),
0130       m_cscDigiGeoToken(esConsumes()),
0131       m_cscGeoToken(esConsumes()),
0132       m_dtGeoToken(esConsumes()),
0133       m_rpcGeoToken(esConsumes()) {}
0134 
0135 void GeometryTester::analyze(const edm::Event &, const edm::EventSetup &iSetup) {
0136   if (m_xmltest) {
0137     auto const &xmlGeo = iSetup.getData(m_xmlGeoToken);
0138 
0139     std::cout << "XML FILE\n";
0140     std::unique_ptr<std::vector<unsigned char> > tb = xmlGeo.getUncompressedBlob();
0141     std::cout << "SIZE FILE = " << tb->size() << "\n";
0142     for (auto it : *tb) {
0143       std::cout << it;
0144     }
0145     std::cout << "\n";
0146   }
0147 
0148   FmtOstream outStream;
0149   if (m_tktest) {
0150     auto const &tkGeo = iSetup.getData(m_tkGeoToken);
0151     std::cout << "TRACKER\n";
0152 
0153     for (auto it : tkGeo.pgeomdets_) {
0154       std::cout << "trk ";
0155       outStream << it._params0 << it._params1 << it._params2 << it._params3 << it._params4 << it._params5 << it._params6
0156                 << it._params7 << it._params8 << it._params9 << it._params10 << it._x << it._y << it._z << it._phi
0157                 << it._rho << it._a11 << it._a12 << it._a13 << it._a21 << it._a22 << it._a23 << it._a31 << it._a32
0158                 << it._a33 << it._shape << it._name << it._ns;
0159       outStream << it._radLength << it._xi << it._pixROCRows << it._pixROCCols << it._pixROCx << it._pixROCy
0160                 << it._stereo << it._siliconAPVNum << it._geographicalID << it._nt0 << it._nt1 << it._nt2 << it._nt3
0161                 << it._nt4 << it._nt5 << it._nt6 << it._nt7 << it._nt8 << it._nt9 << it._nt10 << "\n";
0162     }
0163   }
0164 
0165   if (m_ecaltest) {
0166     auto const &ebGeo = iSetup.getData(m_ebGeoToken);
0167     std::cout << "ECAL BARREL\n";
0168     auto tseb = ebGeo.getTranslation();
0169     auto dimeb = ebGeo.getDimension();
0170     auto indeb = ebGeo.getIndexes();
0171     std::cout << "Translations " << tseb.size() << "\n";
0172     std::cout << "Dimensions " << dimeb.size() << "\n";
0173     std::cout << "Indices " << indeb.size() << "\n";
0174     std::cout << "ecalb ";
0175     for (auto it : tseb)
0176       outStream << it;
0177     std::cout << "\n";
0178     std::cout << "ecalb ";
0179     for (auto it : dimeb)
0180       outStream << it;
0181     std::cout << "\n";
0182     std::cout << "ecalb ";
0183     for (auto it : indeb)
0184       outStream << it;
0185     std::cout << "\n";
0186 
0187     auto const &eeGeo = iSetup.getData(m_eeGeoToken);
0188     std::cout << "ECAL ENDCAP\n";
0189     auto tsee = eeGeo.getTranslation();
0190     auto dimee = eeGeo.getDimension();
0191     auto indee = eeGeo.getIndexes();
0192     std::cout << "Translations " << tsee.size() << "\n";
0193     std::cout << "Dimensions " << dimee.size() << "\n";
0194     std::cout << "Indices " << indee.size() << "\n";
0195     std::cout << "ecale " << std::endl;
0196     int cnt = 1;
0197     for (auto it : tsee) {
0198       if (cnt % 6 == 1) {
0199         outStream << "ecale xyz ";
0200         if (m_round)
0201           std::cout << std::defaultfloat << std::setprecision(6);
0202       } else if (cnt % 3 == 1) {
0203         outStream << "ecale phi/theta/psi ";
0204         if (m_round) {
0205           std::cout << std::setprecision(4);
0206           // Angles show fluctuations beyond four digits
0207           if (std::abs(it) < 1.e-4) {
0208             it = 0.0;
0209             // Show tiny phi values as 0 to avoid fluctuations
0210           }
0211         }
0212       }
0213       outStream << it;
0214       if ((cnt++) % 3 == 0)
0215         std::cout << "\n";
0216     }
0217     std::cout << "\n";
0218     if (m_round)
0219       std::cout << std::setprecision(6);
0220     std::cout << "ecale ";
0221     for (auto it : dimee)
0222       outStream << it;
0223     std::cout << "\n";
0224     std::cout << "ecale ";
0225     for (auto it : indee)
0226       outStream << it;
0227     std::cout << "\n";
0228 
0229     auto const &epGeo = iSetup.getData(m_epGeoToken);
0230     std::cout << "ECAL PRESHOWER\n";
0231     auto tsep = epGeo.getTranslation();
0232     auto dimep = epGeo.getDimension();
0233     auto indep = epGeo.getIndexes();
0234     std::cout << "Translations " << tsep.size() << "\n";
0235     std::cout << "Dimensions " << dimep.size() << "\n";
0236     std::cout << "Indices " << indep.size() << "\n";
0237     std::cout << "ecalpre ";
0238     for (auto it : tsep)
0239       outStream << it;
0240     std::cout << "\n";
0241     std::cout << "ecalpre ";
0242     for (auto it : dimep)
0243       outStream << it;
0244     std::cout << "\n";
0245     std::cout << "ecalpre ";
0246     for (auto it : indep)
0247       outStream << it;
0248     std::cout << "\n";
0249   }
0250 
0251   if (m_hcaltest) {
0252     auto const &hGeo = iSetup.getData(m_hGeoToken);
0253     std::cout << "HCAL\n";
0254     auto tsh = hGeo.getTranslation();
0255     auto dimh = hGeo.getDimension();
0256     auto indh = hGeo.getIndexes();
0257     auto dindh = hGeo.getDenseIndices();
0258     std::cout << "Translations " << tsh.size() << "\n";
0259     std::cout << "Dimensions " << dimh.size() << "\n";
0260     std::cout << "Indices " << indh.size() << "\n";
0261     std::cout << "Dense Indices " << dindh.size() << "\n";
0262     std::cout << "hcal";
0263     for (auto it : tsh)
0264       outStream << it;
0265     std::cout << "\n";
0266     std::cout << "hcal";
0267     for (auto it : dimh)
0268       outStream << it;
0269     std::cout << "\n";
0270     std::cout << "hcal";
0271     for (auto it : indh)
0272       outStream << it;
0273     std::cout << "hcal";
0274     for (auto it : dindh)
0275       outStream << it;
0276     std::cout << "\n";
0277   }
0278 
0279   if (m_hgcaltest) {
0280     auto const &hgcGeo = iSetup.getData(m_hgcGeoToken);
0281     std::cout << "HGCAL\n";
0282     auto tsh = hgcGeo.getTranslation();
0283     auto dimh = hgcGeo.getDimension();
0284     auto indh = hgcGeo.getIndexes();
0285     auto dindh = hgcGeo.getDenseIndices();
0286     std::cout << "Translations " << tsh.size() << "\n";
0287     std::cout << "Dimensions " << dimh.size() << "\n";
0288     std::cout << "Indices " << indh.size() << "\n";
0289     std::cout << "Dense Indices " << dindh.size() << "\n";
0290     std::cout << "hgcal ";
0291     for (auto it : tsh)
0292       outStream << it;
0293     std::cout << "\n";
0294     std::cout << "hgcal ";
0295     for (auto it : dimh)
0296       outStream << it;
0297     std::cout << "\n";
0298     std::cout << "hgcal ";
0299     for (auto it : indh)
0300       outStream << it;
0301     std::cout << "\n";
0302     std::cout << "hgcal ";
0303     for (auto it : dindh)
0304       outStream << it;
0305     std::cout << "\n";
0306   }
0307 
0308   if (m_calotowertest) {
0309     auto const &ctGeo = iSetup.getData(m_ctGeoToken);
0310     std::cout << "CALO TOWER:\n";
0311     auto tsct = ctGeo.getTranslation();
0312     auto dimct = ctGeo.getDimension();
0313     auto indct = ctGeo.getIndexes();
0314     std::cout << "Translations " << tsct.size() << "\n";
0315     std::cout << "Dimensions " << dimct.size() << "\n";
0316     std::cout << "Indices " << indct.size() << "\n";
0317     std::cout << "calotow ";
0318     for (auto it : tsct)
0319       outStream << it;
0320     std::cout << "\n";
0321     std::cout << "calotow ";
0322     for (auto it : dimct)
0323       outStream << it;
0324     std::cout << "\n";
0325     std::cout << "calotow ";
0326     for (auto it : indct)
0327       outStream << it;
0328     std::cout << "\n";
0329   }
0330 
0331   if (m_castortest) {
0332     auto const &castGeo = iSetup.getData(m_castGeoToken);
0333     std::cout << "CASTOR\n";
0334     std::cout << "castor ";
0335     for (auto it : castGeo.getTranslation())
0336       outStream << it;
0337     std::cout << "\n";
0338     std::cout << "castor ";
0339     for (auto it : castGeo.getDimension())
0340       outStream << it;
0341     std::cout << "\n";
0342     std::cout << "castor ";
0343     for (auto it : castGeo.getIndexes())
0344       outStream << it;
0345     std::cout << "\n";
0346   }
0347 
0348   if (m_zdctest) {
0349     auto const &zdcGeo = iSetup.getData(m_zdcGeoToken);
0350     std::cout << "ZDC\n";
0351     std::cout << "zdc ";
0352     for (auto it : zdcGeo.getTranslation())
0353       outStream << it;
0354     std::cout << "\n";
0355     std::cout << "zdc ";
0356     for (auto it : zdcGeo.getDimension())
0357       outStream << it;
0358     std::cout << "\n";
0359     std::cout << "zdc ";
0360     for (auto it : zdcGeo.getIndexes())
0361       outStream << it;
0362     std::cout << "\n";
0363   }
0364 
0365   if (m_csctest) {
0366     auto const &cscGeo = iSetup.getData(m_cscGeoToken);
0367 
0368     auto const &cscDigiGeo = iSetup.getData(m_cscDigiGeoToken);
0369     std::cout << "CSC\n";
0370 
0371     std::vector<int> obj1(cscDigiGeo.pUserParOffset);
0372     std::cout << "csc ";
0373     for (auto it : obj1)
0374       outStream << it;
0375     std::cout << "\n";
0376 
0377     std::vector<int> obj2(cscDigiGeo.pUserParSize);
0378     std::cout << "csc ";
0379     for (auto it : obj2)
0380       outStream << it;
0381     std::cout << "\n";
0382 
0383     std::vector<int> obj3(cscDigiGeo.pChamberType);
0384     std::cout << "csc ";
0385     for (auto it : obj3)
0386       outStream << it;
0387     std::cout << "\n";
0388 
0389     std::vector<float> obj4(cscDigiGeo.pfupars);
0390     std::cout << "csc ";
0391     for (auto it : obj4)
0392       outStream << it;
0393     std::cout << "\n";
0394 
0395     std::vector<DetId> myIdcsc(cscGeo.detIds());
0396     std::cout << "csc ";
0397     for (auto it : myIdcsc)
0398       outStream << it;
0399     std::cout << "\n";
0400 
0401     uint32_t cscsize = myIdcsc.size();
0402     for (uint32_t i = 0; i < cscsize; i++) {
0403       std::vector<double> trcsc(cscGeo.tranStart(i), cscGeo.tranEnd(i));
0404       std::cout << "csc ";
0405       for (auto it : trcsc)
0406         outStream << it;
0407       std::cout << "\n";
0408 
0409       std::vector<double> rotcsc(cscGeo.rotStart(i), cscGeo.rotEnd(i));
0410       std::cout << "csc ";
0411       for (auto it : rotcsc)
0412         outStream << it;
0413       std::cout << "\n";
0414 
0415       std::vector<double> shapecsc(cscGeo.shapeStart(i), cscGeo.shapeEnd(i));
0416       std::cout << "csc ";
0417       for (auto it : shapecsc)
0418         outStream << it;
0419       std::cout << "\n";
0420     }
0421   }
0422 
0423   if (m_dttest) {
0424     auto const &dtGeo = iSetup.getData(m_dtGeoToken);
0425     std::cout << "DT\n";
0426     std::vector<DetId> myIddt(dtGeo.detIds());
0427     std::cout << "dt ";
0428     for (auto it : myIddt)
0429       std::cout << " " << it;  // DetId
0430     std::cout << "\n";
0431 
0432     uint32_t dtsize = myIddt.size();
0433     std::cout << "dt ";
0434     for (uint32_t i = 0; i < dtsize; i++) {
0435       std::vector<double> trdt(dtGeo.tranStart(i), dtGeo.tranEnd(i));
0436       for (auto it : trdt)
0437         outStream << it;
0438       std::cout << "\n";
0439 
0440       std::vector<double> rotdt(dtGeo.rotStart(i), dtGeo.rotEnd(i));
0441       std::cout << "dt ";
0442       for (auto it : rotdt)
0443         outStream << it;
0444       std::cout << "\n";
0445 
0446       std::vector<double> shapedt(dtGeo.shapeStart(i), dtGeo.shapeEnd(i));
0447       std::cout << "dt ";
0448       for (auto it : shapedt)
0449         outStream << it;
0450       std::cout << "\n";
0451     }
0452   }
0453 
0454   if (m_rpctest) {
0455     auto const &rpcGeo = iSetup.getData(m_rpcGeoToken);
0456     std::cout << "RPC\n";
0457 
0458     std::vector<DetId> myIdrpc(rpcGeo.detIds());
0459     std::cout << "rpc ";
0460     for (auto it : myIdrpc)
0461       std::cout << " " << it;  // DetId
0462     std::cout << "\n";
0463     uint32_t rpcsize = myIdrpc.size();
0464     for (uint32_t i = 0; i < rpcsize; i++) {
0465       std::vector<double> trrpc(rpcGeo.tranStart(i), rpcGeo.tranEnd(i));
0466       std::cout << "rpc ";
0467       for (auto it : trrpc)
0468         outStream << it;
0469       std::cout << "\n";
0470 
0471       std::vector<double> rotrpc(rpcGeo.rotStart(i), rpcGeo.rotEnd(i));
0472       std::cout << "rpc ";
0473       for (auto it : rotrpc)
0474         outStream << it;
0475       std::cout << "\n";
0476 
0477       std::vector<double> shaperpc(rpcGeo.shapeStart(i), rpcGeo.shapeEnd(i));
0478       std::cout << "rpc ";
0479       for (auto it : shaperpc)
0480         outStream << it;
0481       std::cout << "\n";
0482 
0483       std::vector<std::string> strrpc(rpcGeo.strStart(i), rpcGeo.strEnd(i));
0484       std::cout << "rpc ";
0485       for (auto it : strrpc)
0486         outStream << it;
0487       std::cout << "\n";
0488     }
0489   }
0490 }
0491 
0492 DEFINE_FWK_MODULE(GeometryTester);