Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <string>
0002 #include <map>
0003 #include <vector>
0004 
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "CondFormats/Alignment/interface/Alignments.h"
0010 #include "CondFormats/Alignment/interface/AlignTransform.h"
0011 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
0012 #include "DataFormats/DetId/interface/DetId.h"
0013 
0014 class GlobalPositionRcdRead : public edm::one::EDAnalyzer<> {
0015 public:
0016   explicit GlobalPositionRcdRead(const edm::ParameterSet& iConfig) : GPRToken_(esConsumes()), nEventCalls_(0) {}
0017   ~GlobalPositionRcdRead() {}
0018   void analyze(const edm::Event&, const edm::EventSetup&) override;
0019 
0020 private:
0021   const edm::ESGetToken<Alignments, GlobalPositionRcd> GPRToken_;
0022   unsigned int nEventCalls_;
0023 };
0024 
0025 void GlobalPositionRcdRead::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0026   if (nEventCalls_ > 0) {
0027     edm::LogPrint("GlobalPositionRcdRead")
0028         << "Reading from DB to be done only once, "
0029         << "set 'untracked PSet maxEvents = {untracked int32 input = 1}'." << std::endl;
0030 
0031     return;
0032   }
0033 
0034   edm::LogPrint("GlobalPositionRcdRead") << "Reading from database in GlobalPositionRcdRead::analyze..." << std::endl;
0035 
0036   const Alignments* globalPositionRcd = &iSetup.getData(GPRToken_);
0037 
0038   edm::LogPrint("GlobalPositionRcdRead") << "Expecting entries in " << DetId(DetId::Tracker).rawId() << " "
0039                                          << DetId(DetId::Muon).rawId() << " " << DetId(DetId::Ecal).rawId() << " "
0040                                          << DetId(DetId::Hcal).rawId() << " " << DetId(DetId::Calo).rawId()
0041                                          << std::endl;
0042   for (std::vector<AlignTransform>::const_iterator i = globalPositionRcd->m_align.begin();
0043        i != globalPositionRcd->m_align.end();
0044        ++i) {
0045     edm::LogPrint("GlobalPositionRcdRead") << "entry " << i->rawId() << " translation " << i->translation()
0046                                            << " angles " << i->rotation().eulerAngles() << std::endl;
0047     edm::LogPrint("GlobalPositionRcdRead") << i->rotation() << std::endl;
0048   }
0049 
0050   edm::LogPrint("GlobalPositionRcdRead") << "done!" << std::endl;
0051   nEventCalls_++;
0052 }
0053 
0054 //define this as a plug-in
0055 DEFINE_FWK_MODULE(GlobalPositionRcdRead);