Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:29

0001 // -*- C++ -*-
0002 //
0003 //
0004 // Description: Module to test the Alignment software
0005 //
0006 //
0007 // Original Author:  Frederic Ronga
0008 //         Created:  March 16, 2006
0009 //
0010 
0011 // system include files
0012 #include <TRotMatrix.h>
0013 
0014 // user include files
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/Framework/interface/MakerMacros.h"
0019 
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 
0022 #include "CondFormats/Alignment/interface/Alignments.h"
0023 #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h"
0024 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
0025 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h"
0026 
0027 //
0028 //
0029 // class declaration
0030 //
0031 
0032 class TestTrackerReader : public edm::one::EDAnalyzer<> {
0033 public:
0034   explicit TestTrackerReader(const edm::ParameterSet&) : aliToken_(esConsumes()), aliErrToken_(esConsumes()), rot(0) {}
0035 
0036   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0037 
0038 private:
0039   // ----------member data ---------------------------
0040   const edm::ESGetToken<Alignments, TrackerAlignmentRcd> aliToken_;
0041   const edm::ESGetToken<AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd> aliErrToken_;
0042   float x, y, z, phi, theta, length, thick, width;
0043   TRotMatrix* rot;
0044 };
0045 
0046 void TestTrackerReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0047   edm::LogInfo("TrackerAlignment") << "Starting!";
0048 
0049   // Retrieve alignment[Error]s from DBase
0050   const Alignments* alignments = &iSetup.getData(aliToken_);
0051   const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(aliErrToken_);
0052 
0053   edm::LogVerbatim("DumpAlignments") << "\n----------------------\n";
0054   for (std::vector<AlignTransform>::const_iterator it = alignments->m_align.begin(); it != alignments->m_align.end();
0055        it++) {
0056     CLHEP::HepRotation rot((*it).rotation());
0057     align::RotationType rotation(
0058         rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz());
0059 
0060     edm::LogVerbatim("DumpAlignments") << (*it).rawId() << "  " << (*it).translation().x() << " "
0061                                        << (*it).translation().y() << " " << (*it).translation().z() << "  "
0062                                        << rotation.xx() << " " << rotation.xy() << " " << rotation.xz() << " "
0063                                        << rotation.yx() << " " << rotation.yy() << " " << rotation.yz() << " "
0064                                        << rotation.zx() << " " << rotation.zy() << " " << rotation.zz();
0065   }
0066   edm::LogVerbatim("DumpAlignments") << "\n----------------------\n";
0067   edm::LogVerbatim("DumpAlignmentErrorsExtended") << "\n----------------------\n";
0068 
0069   std::vector<AlignTransformErrorExtended> alignErrors = alignmentErrors->m_alignError;
0070   for (std::vector<AlignTransformErrorExtended>::const_iterator it = alignErrors.begin(); it != alignErrors.end();
0071        it++) {
0072     edm::LogVerbatim("DumpAlignments") << (*it).rawId() << (*it).matrix();
0073   }
0074   edm::LogVerbatim("DumpAlignmentErrorsExtended") << "\n----------------------\n";
0075 
0076   edm::LogInfo("TrackerAlignment") << "Done!";
0077 }
0078 
0079 //define this as a plug-in
0080 DEFINE_FWK_MODULE(TestTrackerReader);