Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:35

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestCaloAlignmentEP
0004 // Class:      TestCaloAlignmentEP
0005 //
0006 /**\class TestCaloAlignmentEP TestCaloAlignmentEP.h Alignment/TestCaloAlignmentEP/interface/TestCaloAlignmentEP.h
0007 
0008 Description: Producer of fake alignment data for calo geometries
0009 
0010 Implementation: 
0011 The alignment objects are filled with fixed alignments.
0012 */
0013 //
0014 // Original Author:  Brian Heltsley
0015 //
0016 //
0017 
0018 // System
0019 #include <memory>
0020 
0021 // Framework
0022 #include "FWCore/Framework/interface/ModuleFactory.h"
0023 #include "FWCore/Framework/interface/ESProducer.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 // Alignment
0027 #include "CondFormats/Alignment/interface/Alignments.h"
0028 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
0029 #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
0030 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
0031 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
0032 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
0033 #include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
0034 #include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
0035 #include "DataFormats/EcalDetId/interface/ESDetId.h"
0036 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0037 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
0038 #include "CondFormats/AlignmentRecord/interface/EBAlignmentRcd.h"
0039 #include "CondFormats/AlignmentRecord/interface/EBAlignmentErrorExtendedRcd.h"
0040 #include "CondFormats/AlignmentRecord/interface/EEAlignmentRcd.h"
0041 #include "CondFormats/AlignmentRecord/interface/EEAlignmentErrorExtendedRcd.h"
0042 #include "CondFormats/AlignmentRecord/interface/ESAlignmentRcd.h"
0043 #include "CondFormats/AlignmentRecord/interface/ESAlignmentErrorExtendedRcd.h"
0044 #include "CondFormats/AlignmentRecord/interface/HBAlignmentRcd.h"
0045 #include "CondFormats/AlignmentRecord/interface/HBAlignmentErrorExtendedRcd.h"
0046 #include "CondFormats/AlignmentRecord/interface/HEAlignmentRcd.h"
0047 #include "CondFormats/AlignmentRecord/interface/HEAlignmentErrorExtendedRcd.h"
0048 #include "CondFormats/AlignmentRecord/interface/HOAlignmentRcd.h"
0049 #include "CondFormats/AlignmentRecord/interface/HOAlignmentErrorExtendedRcd.h"
0050 #include "CondFormats/AlignmentRecord/interface/HFAlignmentRcd.h"
0051 #include "CondFormats/AlignmentRecord/interface/HFAlignmentErrorExtendedRcd.h"
0052 #include "CondFormats/AlignmentRecord/interface/ZDCAlignmentRcd.h"
0053 #include "CondFormats/AlignmentRecord/interface/ZDCAlignmentErrorExtendedRcd.h"
0054 #include "CondFormats/AlignmentRecord/interface/CastorAlignmentRcd.h"
0055 #include "CondFormats/AlignmentRecord/interface/CastorAlignmentErrorExtendedRcd.h"
0056 
0057 class TestCaloAlignmentEP : public edm::ESProducer {
0058 public:
0059   using ReturnAli = std::unique_ptr<Alignments>;
0060   using ReturnAliErr = std::unique_ptr<AlignmentErrors>;
0061 
0062   typedef AlignTransform::Translation Trl;
0063   typedef AlignTransform::Rotation Rot;
0064 
0065   TestCaloAlignmentEP(const edm::ParameterSet&) {
0066     setWhatProduced(this, &TestCaloAlignmentEP::produceEBAli);
0067     setWhatProduced(this, &TestCaloAlignmentEP::produceEBAliErr);
0068     setWhatProduced(this, &TestCaloAlignmentEP::produceEEAli);
0069     setWhatProduced(this, &TestCaloAlignmentEP::produceEEAliErr);
0070     setWhatProduced(this, &TestCaloAlignmentEP::produceESAli);
0071     setWhatProduced(this, &TestCaloAlignmentEP::produceESAliErr);
0072     setWhatProduced(this, &TestCaloAlignmentEP::produceHBAli);
0073     setWhatProduced(this, &TestCaloAlignmentEP::produceHBAliErr);
0074     setWhatProduced(this, &TestCaloAlignmentEP::produceHEAli);
0075     setWhatProduced(this, &TestCaloAlignmentEP::produceHEAliErr);
0076     setWhatProduced(this, &TestCaloAlignmentEP::produceHOAli);
0077     setWhatProduced(this, &TestCaloAlignmentEP::produceHOAliErr);
0078     setWhatProduced(this, &TestCaloAlignmentEP::produceHFAli);
0079     setWhatProduced(this, &TestCaloAlignmentEP::produceHFAliErr);
0080     setWhatProduced(this, &TestCaloAlignmentEP::produceZdcAli);
0081     setWhatProduced(this, &TestCaloAlignmentEP::produceZdcAliErr);
0082     setWhatProduced(this, &TestCaloAlignmentEP::produceCastorAli);
0083     setWhatProduced(this, &TestCaloAlignmentEP::produceCastorAliErr);
0084   }
0085 
0086   ~TestCaloAlignmentEP() override {}
0087 
0088   //-------------------------------------------------------------------
0089 
0090   ReturnAli produceEBAli(const EBAlignmentRcd& /*iRecord*/) {
0091     ReturnAli ali = std::make_unique<Alignments>();
0092     std::vector<AlignTransform>& vtr(ali->m_align);
0093     const unsigned int nA(EcalBarrelGeometry::numberOfAlignments());
0094     vtr.reserve(nA);
0095     for (unsigned int i(0); i != nA; ++i) {
0096       const EBDetId id(EcalBarrelGeometry::detIdFromLocalAlignmentIndex(i));
0097       vtr.emplace_back(AlignTransform((1 == id.ism() ? Trl(0, 0, 0) :  //-0.3 ) :
0098                                            Trl(0, 0, 0)),
0099                                       Rot(),
0100                                       id));
0101     }
0102     return ali;
0103   }
0104 
0105   ReturnAliErr produceEBAliErr(const EBAlignmentErrorExtendedRcd& /*iRecord*/) {
0106     return std::make_unique<AlignmentErrors>();
0107   }
0108   //-------------------------------------------------------------------
0109 
0110   ReturnAli produceEEAli(const EEAlignmentRcd& /*iRecord*/) {
0111     ReturnAli ali = std::make_unique<Alignments>();
0112     std::vector<AlignTransform>& vtr(ali->m_align);
0113     const unsigned int nA(EcalEndcapGeometry::numberOfAlignments());
0114     vtr.reserve(nA);
0115     for (unsigned int i(0); i != nA; ++i) {
0116       const EEDetId id(EcalEndcapGeometry::detIdFromLocalAlignmentIndex(i));
0117       vtr.emplace_back(AlignTransform((2 > i ? Trl(-0.02, -0.81, -0.94) : Trl(+0.52, -0.81, +0.81)), Rot(), id));
0118     }
0119     return ali;
0120   }
0121 
0122   ReturnAliErr produceEEAliErr(const EEAlignmentErrorExtendedRcd& /*iRecord*/) {
0123     return std::make_unique<AlignmentErrors>();
0124   }
0125   //-------------------------------------------------------------------
0126 
0127   ReturnAli produceESAli(const ESAlignmentRcd& /*iRecord*/) {
0128     ReturnAli ali = std::make_unique<Alignments>();
0129     std::vector<AlignTransform>& vtr(ali->m_align);
0130     const unsigned int nA(EcalPreshowerGeometry::numberOfAlignments());
0131     vtr.reserve(nA);
0132     for (unsigned int i(0); i != nA; ++i) {
0133       const ESDetId id(EcalPreshowerGeometry::detIdFromLocalAlignmentIndex(i));
0134       vtr.emplace_back(AlignTransform((4 > i ? Trl(-0.02, -0.81, -0.94) : Trl(+0.52, -0.81, +0.81)), Rot(), id));
0135     }
0136     return ali;
0137   }
0138 
0139   ReturnAliErr produceESAliErr(const ESAlignmentErrorExtendedRcd& /*iRecord*/) {
0140     return std::make_unique<AlignmentErrors>();
0141   }
0142   //-------------------------------------------------------------------
0143 
0144   ReturnAli produceHBAli(const HBAlignmentRcd& /*iRecord*/) {
0145     ReturnAli ali = std::make_unique<Alignments>();
0146     std::vector<AlignTransform>& vtr(ali->m_align);
0147     const unsigned int nA(HcalGeometry::numberOfBarrelAlignments());
0148     vtr.reserve(nA);
0149     for (unsigned int i(0); i != nA; ++i) {
0150       const HcalDetId id(HcalGeometry::detIdFromBarrelAlignmentIndex(i));
0151       vtr.emplace_back(AlignTransform(Trl(0, 0, 0), Rot(), id));
0152     }
0153     return ali;
0154   }
0155 
0156   ReturnAliErr produceHBAliErr(const HBAlignmentErrorExtendedRcd& /*iRecord*/) {
0157     return std::make_unique<AlignmentErrors>();
0158   }
0159   //-------------------------------------------------------------------
0160 
0161   ReturnAli produceHEAli(const HEAlignmentRcd& /*iRecord*/) {
0162     ReturnAli ali = std::make_unique<Alignments>();
0163     std::vector<AlignTransform>& vtr(ali->m_align);
0164     const unsigned int nA(HcalGeometry::numberOfEndcapAlignments());
0165     vtr.reserve(nA);
0166     for (unsigned int i(0); i != nA; ++i) {
0167       const HcalDetId id(HcalGeometry::detIdFromEndcapAlignmentIndex(i));
0168       vtr.emplace_back(AlignTransform(Trl(0, 0, 0), Rot(), id));
0169     }
0170     return ali;
0171   }
0172 
0173   ReturnAliErr produceHEAliErr(const HEAlignmentErrorExtendedRcd& /*iRecord*/) {
0174     return std::make_unique<AlignmentErrors>();
0175   }
0176   //-------------------------------------------------------------------
0177 
0178   ReturnAli produceHOAli(const HOAlignmentRcd& /*iRecord*/) {
0179     ReturnAli ali = std::make_unique<Alignments>();
0180     std::vector<AlignTransform>& vtr(ali->m_align);
0181     const unsigned int nA(HcalGeometry::numberOfOuterAlignments());
0182     vtr.reserve(nA);
0183     for (unsigned int i(0); i != nA; ++i) {
0184       const HcalDetId id(HcalGeometry::detIdFromOuterAlignmentIndex(i));
0185       vtr.emplace_back(AlignTransform(Trl(0, 0, 0), Rot(), id));
0186     }
0187     return ali;
0188   }
0189 
0190   ReturnAliErr produceHOAliErr(const HOAlignmentErrorExtendedRcd& /*iRecord*/) {
0191     return std::make_unique<AlignmentErrors>();
0192   }
0193   //-------------------------------------------------------------------
0194 
0195   ReturnAli produceHFAli(const HFAlignmentRcd& /*iRecord*/) {
0196     ReturnAli ali = std::make_unique<Alignments>();
0197     std::vector<AlignTransform>& vtr(ali->m_align);
0198     const unsigned int nA(HcalGeometry::numberOfForwardAlignments());
0199     vtr.reserve(nA);
0200     for (unsigned int i(0); i != nA; ++i) {
0201       const HcalDetId id(HcalGeometry::detIdFromForwardAlignmentIndex(i));
0202       vtr.emplace_back(AlignTransform(Trl(0, 0, 0), Rot(), id));
0203     }
0204     return ali;
0205   }
0206 
0207   ReturnAliErr produceHFAliErr(const HFAlignmentErrorExtendedRcd& /*iRecord*/) {
0208     return std::make_unique<AlignmentErrors>();
0209   }
0210   //-------------------------------------------------------------------
0211 
0212   ReturnAli produceZdcAli(const ZDCAlignmentRcd& /*iRecord*/) {
0213     ReturnAli ali = std::make_unique<Alignments>();
0214     std::vector<AlignTransform>& vtr(ali->m_align);
0215     const unsigned int nA(ZdcGeometry::numberOfAlignments());
0216     vtr.reserve(nA);
0217     for (unsigned int i(0); i != nA; ++i) {
0218       const HcalZDCDetId id(HcalZDCDetId::EM, false, 1);
0219       vtr.emplace_back(AlignTransform(Trl(0, 0, 0), Rot(), id));
0220     }
0221     return ali;
0222   }
0223 
0224   ReturnAliErr produceZdcAliErr(const ZDCAlignmentErrorExtendedRcd& /*iRecord*/) {
0225     return std::make_unique<AlignmentErrors>();
0226   }
0227   //-------------------------------------------------------------------
0228 
0229   ReturnAli produceCastorAli(const CastorAlignmentRcd& /*iRecord*/) {
0230     ReturnAli ali = std::make_unique<Alignments>();
0231     std::vector<AlignTransform>& vtr(ali->m_align);
0232     const unsigned int nA(CastorGeometry::numberOfAlignments());
0233     vtr.reserve(nA);
0234     for (unsigned int i(0); i != nA; ++i) {
0235       const HcalCastorDetId id(HcalCastorDetId::EM, false, 1, 1);
0236       vtr.emplace_back(AlignTransform(Trl(0, 0, 0), Rot(), id));
0237     }
0238     return ali;
0239   }
0240 
0241   ReturnAliErr produceCastorAliErr(const CastorAlignmentErrorExtendedRcd& /*iRecord*/) {
0242     return std::make_unique<AlignmentErrors>();
0243   }
0244 };
0245 
0246 //define this as a plug-in
0247 DEFINE_FWK_EVENTSETUP_MODULE(TestCaloAlignmentEP);