00001 // -*- C++ -*- 00002 // 00003 // Package: HcalAlignmentEP 00004 // Class: HcalAlignmentEP 00005 // 00006 // 00007 // Original Author: Brian Heltsley 00008 // 00009 // 00010 00011 00012 // System 00013 #include <memory> 00014 00015 // Framework 00016 #include "FWCore/Framework/interface/ModuleFactory.h" 00017 #include "FWCore/Framework/interface/ESProducer.h" 00018 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00019 00020 00021 00022 // Alignment 00023 #include "CondFormats/Alignment/interface/Alignments.h" 00024 #include "CondFormats/Alignment/interface/AlignmentErrors.h" 00025 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h" 00026 #include "CondFormats/AlignmentRecord/interface/HcalAlignmentRcd.h" 00027 #include "CondFormats/AlignmentRecord/interface/HcalAlignmentErrorRcd.h" 00028 #include "FWCore/Framework/interface/ESHandle.h" 00029 00030 class HcalAlignmentEP : public edm::ESProducer 00031 { 00032 public: 00033 00034 typedef boost::shared_ptr<Alignments> ReturnAli ; 00035 typedef boost::shared_ptr<AlignmentErrors> ReturnAliErr ; 00036 00037 typedef AlignTransform::Translation Trl ; 00038 typedef AlignTransform::Rotation Rot ; 00039 00040 HcalAlignmentEP(const edm::ParameterSet&) 00041 { 00042 setWhatProduced( this, &HcalAlignmentEP::produceHcalAli ) ; 00043 } 00044 00045 ~HcalAlignmentEP() {} 00046 00047 //------------------------------------------------------------------- 00048 00049 ReturnAli produceHcalAli( const HcalAlignmentRcd& iRecord ) 00050 { 00051 ReturnAli ali ( new Alignments ) ; 00052 std::vector<AlignTransform>& vtr ( ali->m_align ) ; 00053 const unsigned int nA ( HcalGeometry::numberOfAlignments() ) ; 00054 vtr.resize( nA ) ; 00055 00056 edm::ESHandle<Alignments> hb ; 00057 edm::ESHandle<Alignments> he ; 00058 edm::ESHandle<Alignments> hf ; 00059 edm::ESHandle<Alignments> ho ; 00060 iRecord.getRecord<HBAlignmentRcd>().get( hb ) ; 00061 iRecord.getRecord<HEAlignmentRcd>().get( he ) ; 00062 iRecord.getRecord<HFAlignmentRcd>().get( hf ) ; 00063 iRecord.getRecord<HOAlignmentRcd>().get( ho ) ; 00064 00065 assert( hb.isValid() && // require valid alignments and expected size 00066 ( hb->m_align.size() == HcalGeometry::numberOfBarrelAlignments() ) ) ; 00067 assert( he.isValid() && // require valid alignments and expected size 00068 ( he->m_align.size() == HcalGeometry::numberOfEndcapAlignments() ) ) ; 00069 assert( ho.isValid() && // require valid alignments and expected size 00070 ( ho->m_align.size() == HcalGeometry::numberOfForwardAlignments() ) ) ; 00071 assert( ho.isValid() && // require valid alignments and expected size 00072 ( ho->m_align.size() == HcalGeometry::numberOfOuterAlignments() ) ) ; 00073 const std::vector<AlignTransform>& hbt = hb->m_align ; 00074 const std::vector<AlignTransform>& het = he->m_align ; 00075 const std::vector<AlignTransform>& hft = hf->m_align ; 00076 const std::vector<AlignTransform>& hot = ho->m_align ; 00077 00078 copy( hbt.begin(), hbt.end(), vtr.begin() ) ; 00079 copy( het.begin(), het.end(), vtr.begin()+hbt.size() ) ; 00080 copy( hft.begin(), hft.end(), vtr.begin()+hbt.size()+het.size() ) ; 00081 copy( hot.begin(), hot.end(), vtr.begin()+hbt.size()+het.size()+hft.size() ) ; 00082 00083 return ali ; 00084 } 00085 }; 00086 00087 00088 //define this as a plug-in 00089 DEFINE_FWK_EVENTSETUP_MODULE(HcalAlignmentEP);