Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:17

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestAccessGeom
0004 // Class:      TestAccessGeom
0005 //
0006 /**\class TestAccessGeom Alignment/CommonAlignmentProducer/test/TestAccessGeom.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011  Module accessing tracking geometries for tracker, DT and CSC
0012 */
0013 //
0014 // Original Author:  Gero Flucke
0015 //         Created:  Sat Feb 16 20:56:04 CET 2008
0016 // $Id: TestAccessGeom.cc,v 1.2 2008/06/26 10:05:09 flucke Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/EventSetup.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 
0033 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0034 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0035 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0036 
0037 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0038 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0039 
0040 #include "FWCore/Framework/interface/ESHandle.h"
0041 
0042 #include <vector>
0043 #include <string>
0044 #include "TString.h"
0045 
0046 //
0047 // class declaration
0048 //
0049 
0050 class TestAccessGeom : public edm::one::EDAnalyzer<> {
0051 public:
0052   explicit TestAccessGeom(const edm::ParameterSet&);
0053   ~TestAccessGeom() = default;
0054 
0055 private:
0056   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0057 
0058   // ----------member data ---------------------------
0059   const std::vector<std::string> tkGeomLabels_;
0060   const std::vector<std::string> dtGeomLabels_;
0061   const std::vector<std::string> cscGeomLabels_;
0062 
0063   std::vector<edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord>> tkGeoTokens_;
0064   std::vector<edm::ESGetToken<DTGeometry, MuonGeometryRecord>> dtGeoTokens_;
0065   std::vector<edm::ESGetToken<CSCGeometry, MuonGeometryRecord>> cscGeoTokens_;
0066 };
0067 
0068 //
0069 // constructors and destructor
0070 //
0071 TestAccessGeom::TestAccessGeom(const edm::ParameterSet& iConfig)
0072     : tkGeomLabels_(iConfig.getParameter<std::vector<std::string>>("TrackerGeomLabels")),
0073       dtGeomLabels_(iConfig.getParameter<std::vector<std::string>>("DTGeomLabels")),
0074       cscGeomLabels_(iConfig.getParameter<std::vector<std::string>>("CSCGeomLabels")) {
0075   //now do what ever initialization is needed
0076 
0077   for (std::vector<std::string>::const_iterator iL = tkGeomLabels_.begin(), iE = tkGeomLabels_.end(); iL != iE; ++iL) {
0078     auto index = std::distance(tkGeomLabels_.begin(), iL);
0079     TString label(iL->c_str());
0080     label.ReplaceAll(" ", "");  // fix for buggy framework
0081     tkGeoTokens_[index] = esConsumes(edm::ESInputTag("", label.Data()));
0082   }
0083 
0084   for (std::vector<std::string>::const_iterator iL = dtGeomLabels_.begin(), iE = dtGeomLabels_.end(); iL != iE; ++iL) {
0085     auto index = std::distance(dtGeomLabels_.begin(), iL);
0086     TString label(iL->c_str());
0087     label.ReplaceAll(" ", "");  // fix for buggy framework
0088     dtGeoTokens_[index] = esConsumes(edm::ESInputTag("", label.Data()));
0089   }
0090 
0091   for (std::vector<std::string>::const_iterator iL = cscGeomLabels_.begin(), iE = cscGeomLabels_.end(); iL != iE;
0092        ++iL) {
0093     auto index = std::distance(cscGeomLabels_.begin(), iL);
0094     TString label(iL->c_str());
0095     label.ReplaceAll(" ", "");  // fix for buggy framework
0096     cscGeoTokens_[index] = esConsumes(edm::ESInputTag("", label.Data()));
0097   }
0098 }
0099 
0100 //
0101 // member functions
0102 //
0103 
0104 // ------------ method called to for each event  ------------
0105 void TestAccessGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0106   using std::string;
0107   using std::vector;
0108 
0109   edm::LogInfo("Test") << "@SUB=analyze"
0110                        << "Try to  access " << tkGeomLabels_.size() << " Tracker-, " << dtGeomLabels_.size()
0111                        << " DT- and " << cscGeomLabels_.size() << " CSC-geometries.";
0112 
0113   for (vector<string>::const_iterator iL = tkGeomLabels_.begin(), iE = tkGeomLabels_.end(); iL != iE; ++iL) {
0114     TString label(iL->c_str());
0115     label.ReplaceAll(" ", "");  // fix for buggy framework
0116     edm::LogInfo("Test") << "Try access to tracker geometry with label '" << label << "'.";
0117     auto idx = std::distance(tkGeomLabels_.begin(), iL);
0118     //*iL << "'.";
0119     edm::ESHandle<TrackerGeometry> tkGeomHandle = iSetup.getHandle(tkGeoTokens_[idx]);
0120     edm::LogInfo("Test") << "TrackerGeometry pointer: " << tkGeomHandle.product();
0121   }
0122 
0123   for (vector<string>::const_iterator iL = dtGeomLabels_.begin(), iE = dtGeomLabels_.end(); iL != iE; ++iL) {
0124     TString label(iL->c_str());
0125     label.ReplaceAll(" ", "");  // fix for buggy framework
0126     edm::LogInfo("Test") << "Try access to DT geometry with label '" << label << "'.";
0127     auto idx = std::distance(dtGeomLabels_.begin(), iL);
0128     //*iL << "'.";
0129     edm::ESHandle<DTGeometry> dtGeomHandle = iSetup.getHandle(dtGeoTokens_[idx]);
0130     edm::LogInfo("Test") << "DTGeometry pointer: " << dtGeomHandle.product();
0131   }
0132 
0133   for (vector<string>::const_iterator iL = cscGeomLabels_.begin(), iE = cscGeomLabels_.end(); iL != iE; ++iL) {
0134     TString label(iL->c_str());
0135     label.ReplaceAll(" ", "");  // fix for buggy framework
0136     edm::LogInfo("Test") << "Try access to CSC geometry with label '" << label << "'.";
0137     auto idx = std::distance(cscGeomLabels_.begin(), iL);
0138     //*iL << "'.";
0139     edm::ESHandle<CSCGeometry> cscGeomHandle = iSetup.getHandle(cscGeoTokens_[idx]);
0140     edm::LogInfo("Test") << "CSCGeometry pointer: " << cscGeomHandle.product();
0141   }
0142 
0143   edm::LogInfo("Test") << "@SUB=analyze"
0144                        << "Succesfully accessed " << tkGeomLabels_.size() << " Tracker-, " << dtGeomLabels_.size()
0145                        << " DT- and " << cscGeomLabels_.size() << " CSC-geometries.";
0146 }
0147 
0148 //define this as a plug-in
0149 DEFINE_FWK_MODULE(TestAccessGeom);