CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/Geometry/CaloEventSetup/plugins/TestCaloAlignmentEP.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    TestCaloAlignmentEP
00004 // Class:      TestCaloAlignmentEP
00005 // 
00013 //
00014 // Original Author:  Brian Heltsley
00015 //
00016 //
00017 
00018 
00019 // System
00020 #include <memory>
00021 
00022 // Framework
00023 #include "FWCore/Framework/interface/ModuleFactory.h"
00024 #include "FWCore/Framework/interface/ESProducer.h"
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 
00027 
00028 
00029 // Alignment
00030 #include "CondFormats/Alignment/interface/Alignments.h"
00031 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00032 #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
00033 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
00034 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
00035 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
00036 #include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
00037 #include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
00038 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00039 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00040 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
00041 #include "CondFormats/AlignmentRecord/interface/EBAlignmentRcd.h"
00042 #include "CondFormats/AlignmentRecord/interface/EBAlignmentErrorRcd.h"
00043 #include "CondFormats/AlignmentRecord/interface/EEAlignmentRcd.h"
00044 #include "CondFormats/AlignmentRecord/interface/EEAlignmentErrorRcd.h"
00045 #include "CondFormats/AlignmentRecord/interface/ESAlignmentRcd.h"
00046 #include "CondFormats/AlignmentRecord/interface/ESAlignmentErrorRcd.h"
00047 #include "CondFormats/AlignmentRecord/interface/HBAlignmentRcd.h"
00048 #include "CondFormats/AlignmentRecord/interface/HBAlignmentErrorRcd.h"
00049 #include "CondFormats/AlignmentRecord/interface/HEAlignmentRcd.h"
00050 #include "CondFormats/AlignmentRecord/interface/HEAlignmentErrorRcd.h"
00051 #include "CondFormats/AlignmentRecord/interface/HOAlignmentRcd.h"
00052 #include "CondFormats/AlignmentRecord/interface/HOAlignmentErrorRcd.h"
00053 #include "CondFormats/AlignmentRecord/interface/HFAlignmentRcd.h"
00054 #include "CondFormats/AlignmentRecord/interface/HFAlignmentErrorRcd.h"
00055 #include "CondFormats/AlignmentRecord/interface/ZDCAlignmentRcd.h"
00056 #include "CondFormats/AlignmentRecord/interface/ZDCAlignmentErrorRcd.h"
00057 #include "CondFormats/AlignmentRecord/interface/CastorAlignmentRcd.h"
00058 #include "CondFormats/AlignmentRecord/interface/CastorAlignmentErrorRcd.h"
00059 
00060 class TestCaloAlignmentEP : public edm::ESProducer 
00061 {
00062    public:
00063 
00064       typedef boost::shared_ptr<Alignments>      ReturnAli    ;
00065       typedef boost::shared_ptr<AlignmentErrors> ReturnAliErr ;
00066 
00067       typedef AlignTransform::Translation Trl ;
00068       typedef AlignTransform::Rotation    Rot ;
00069 
00070       TestCaloAlignmentEP(const edm::ParameterSet&)
00071       {
00072          setWhatProduced( this, &TestCaloAlignmentEP::produceEBAli    ) ;
00073          setWhatProduced( this, &TestCaloAlignmentEP::produceEBAliErr ) ;
00074          setWhatProduced( this, &TestCaloAlignmentEP::produceEEAli    ) ;
00075          setWhatProduced( this, &TestCaloAlignmentEP::produceEEAliErr ) ;
00076          setWhatProduced( this, &TestCaloAlignmentEP::produceESAli    ) ;
00077          setWhatProduced( this, &TestCaloAlignmentEP::produceESAliErr ) ;
00078          setWhatProduced( this, &TestCaloAlignmentEP::produceHBAli    ) ;
00079          setWhatProduced( this, &TestCaloAlignmentEP::produceHBAliErr ) ;
00080          setWhatProduced( this, &TestCaloAlignmentEP::produceHEAli    ) ;
00081          setWhatProduced( this, &TestCaloAlignmentEP::produceHEAliErr ) ;
00082          setWhatProduced( this, &TestCaloAlignmentEP::produceHOAli    ) ;
00083          setWhatProduced( this, &TestCaloAlignmentEP::produceHOAliErr ) ;
00084          setWhatProduced( this, &TestCaloAlignmentEP::produceHFAli    ) ;
00085          setWhatProduced( this, &TestCaloAlignmentEP::produceHFAliErr ) ;
00086          setWhatProduced( this, &TestCaloAlignmentEP::produceZdcAli    ) ;
00087          setWhatProduced( this, &TestCaloAlignmentEP::produceZdcAliErr ) ;
00088          setWhatProduced( this, &TestCaloAlignmentEP::produceCastorAli    ) ;
00089          setWhatProduced( this, &TestCaloAlignmentEP::produceCastorAliErr ) ;
00090       }
00091 
00092       ~TestCaloAlignmentEP() {}
00093 
00094 //-------------------------------------------------------------------
00095  
00096       ReturnAli    produceEBAli( const EBAlignmentRcd& /*iRecord*/ ) 
00097       {
00098          ReturnAli ali ( new Alignments ) ;
00099          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00100          const unsigned int nA ( EcalBarrelGeometry::numberOfAlignments() ) ; 
00101          vtr.reserve( nA ) ;
00102          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00103          {
00104             const EBDetId id ( EcalBarrelGeometry::detIdFromLocalAlignmentIndex( i ) ) ;
00105             vtr.push_back( AlignTransform( ( 1==id.ism() ? Trl( 0, 0, 0 ) : //-0.3 ) :
00106                                              Trl(0,0,0 ) ) , 
00107                                            Rot(),
00108                                            id              ) ) ;
00109          }
00110          return ali ;
00111       }
00112 
00113       ReturnAliErr produceEBAliErr( const EBAlignmentErrorRcd& /*iRecord*/ ) 
00114       { 
00115          ReturnAliErr aliErr ( new AlignmentErrors ); 
00116          return aliErr ;
00117       }
00118 //-------------------------------------------------------------------
00119 
00120       ReturnAli    produceEEAli( const EEAlignmentRcd& /*iRecord*/ ) 
00121       {
00122          ReturnAli ali ( new Alignments ) ;
00123          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00124          const unsigned int nA ( EcalEndcapGeometry::numberOfAlignments() ) ; 
00125          vtr.reserve( nA ) ;
00126          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00127          {
00128             const EEDetId id (  EcalEndcapGeometry::detIdFromLocalAlignmentIndex( i ) ) ;
00129             vtr.push_back( AlignTransform(  ( 2 > i ? Trl( -0.02, -0.81, -0.94 ) :
00130                                               Trl( +0.52, -0.81, +0.81 ) ) ,
00131                                            Rot(),
00132                                            id              ) ) ;
00133          }
00134          return ali ;
00135       }
00136 
00137       ReturnAliErr produceEEAliErr( const EEAlignmentErrorRcd& /*iRecord*/ ) 
00138       { 
00139          ReturnAliErr aliErr ( new AlignmentErrors ); 
00140          return aliErr ;
00141       }
00142 //-------------------------------------------------------------------
00143 
00144       ReturnAli    produceESAli( const ESAlignmentRcd& /*iRecord*/ ) 
00145       {
00146          ReturnAli ali ( new Alignments ) ;
00147          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00148          const unsigned int nA ( EcalPreshowerGeometry::numberOfAlignments() ) ; 
00149          vtr.reserve( nA ) ;
00150          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00151          {
00152             const ESDetId id ( EcalPreshowerGeometry::detIdFromLocalAlignmentIndex( i ) ) ;
00153             vtr.push_back( AlignTransform( ( 4 > i ? Trl( -0.02, -0.81, -0.94 ) :
00154                                              Trl( +0.52, -0.81, +0.81 ) ) ,  
00155                                            Rot(),
00156                                            id           ) ) ;
00157          }
00158          return ali ;
00159       }
00160 
00161       ReturnAliErr produceESAliErr( const ESAlignmentErrorRcd& /*iRecord*/ ) 
00162       { 
00163          ReturnAliErr aliErr ( new AlignmentErrors ); 
00164          return aliErr ;
00165       }
00166 //-------------------------------------------------------------------
00167 
00168       ReturnAli    produceHBAli( const HBAlignmentRcd& /*iRecord*/ ) 
00169       {
00170          ReturnAli ali ( new Alignments ) ;
00171          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00172          const unsigned int nA ( HcalGeometry::numberOfBarrelAlignments() ) ; 
00173          vtr.reserve( nA ) ;
00174          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00175          {
00176             const HcalDetId id ( HcalBarrel, 1, 1, 1 ) ;
00177             vtr.push_back( AlignTransform( Trl( 0, 0, 0 ), 
00178                                            Rot(),
00179                                            id           ) ) ;
00180          }
00181          return ali ;
00182       }
00183 
00184       ReturnAliErr produceHBAliErr( const HBAlignmentErrorRcd& /*iRecord*/ ) 
00185       { 
00186          ReturnAliErr aliErr ( new AlignmentErrors ); 
00187          return aliErr ;
00188       }
00189 //-------------------------------------------------------------------
00190 
00191       ReturnAli    produceHEAli( const HEAlignmentRcd& /*iRecord*/ ) 
00192       {
00193          ReturnAli ali ( new Alignments ) ;
00194          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00195          const unsigned int nA ( HcalGeometry::numberOfEndcapAlignments() ) ; 
00196          vtr.reserve( nA ) ;
00197          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00198          {
00199             const HcalDetId id ( HcalEndcap, 21, 1, 1 ) ;
00200             vtr.push_back( AlignTransform( Trl( 0, 0, 0 ), 
00201                                            Rot(),
00202                                            id           ) ) ;
00203          }
00204          return ali ;
00205       }
00206 
00207       ReturnAliErr produceHEAliErr( const HEAlignmentErrorRcd& /*iRecord*/ ) 
00208       { 
00209          ReturnAliErr aliErr ( new AlignmentErrors ); 
00210          return aliErr ;
00211       }
00212 //-------------------------------------------------------------------
00213 
00214       ReturnAli    produceHOAli( const HOAlignmentRcd& /*iRecord*/ ) 
00215       {
00216          ReturnAli ali ( new Alignments ) ;
00217          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00218          const unsigned int nA ( HcalGeometry::numberOfOuterAlignments() ) ; 
00219          vtr.reserve( nA ) ;
00220          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00221          {
00222             const HcalDetId id ( HcalOuter, 1, 1, 4 ) ;
00223             vtr.push_back( AlignTransform( Trl( 0, 0, 0 ), 
00224                                            Rot(),
00225                                            id           ) ) ;
00226          }
00227          return ali ;
00228       }
00229 
00230       ReturnAliErr produceHOAliErr( const HOAlignmentErrorRcd& /*iRecord*/ ) 
00231       { 
00232          ReturnAliErr aliErr ( new AlignmentErrors ); 
00233          return aliErr ;
00234       }
00235 //-------------------------------------------------------------------
00236 
00237       ReturnAli    produceHFAli( const HFAlignmentRcd& /*iRecord*/ ) 
00238       {
00239          ReturnAli ali ( new Alignments ) ;
00240          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00241          const unsigned int nA ( HcalGeometry::numberOfForwardAlignments() ) ; 
00242          vtr.reserve( nA ) ;
00243          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00244          {
00245             const HcalDetId id ( HcalForward, 29, 1, 1 ) ;
00246             vtr.push_back( AlignTransform( Trl( 0, 0, 0 ), 
00247                                            Rot(),
00248                                            id           ) ) ;
00249          }
00250          return ali ;
00251       }
00252 
00253       ReturnAliErr produceHFAliErr( const HFAlignmentErrorRcd& /*iRecord*/ ) 
00254       { 
00255          ReturnAliErr aliErr ( new AlignmentErrors ); 
00256          return aliErr ;
00257       }
00258 //-------------------------------------------------------------------
00259 
00260       ReturnAli    produceZdcAli( const ZDCAlignmentRcd& /*iRecord*/ ) 
00261       {
00262          ReturnAli ali ( new Alignments ) ;
00263          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00264          const unsigned int nA ( ZdcGeometry::numberOfAlignments() ) ; 
00265          vtr.reserve( nA ) ;
00266          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00267          {
00268             const HcalZDCDetId id ( HcalZDCDetId::EM, false, 1 ) ;
00269             vtr.push_back( AlignTransform( Trl( 0, 0, 0 ), 
00270                                            Rot(),
00271                                            id           ) ) ;
00272          }
00273          return ali ;
00274       }
00275 
00276       ReturnAliErr produceZdcAliErr( const ZDCAlignmentErrorRcd& /*iRecord*/ ) 
00277       { 
00278          ReturnAliErr aliErr ( new AlignmentErrors ); 
00279          return aliErr ;
00280       }
00281 //-------------------------------------------------------------------
00282 
00283       ReturnAli    produceCastorAli( const CastorAlignmentRcd& /*iRecord*/ ) 
00284       {
00285          ReturnAli ali ( new Alignments ) ;
00286          std::vector<AlignTransform>& vtr ( ali->m_align ) ;
00287          const unsigned int nA ( CastorGeometry::numberOfAlignments() ) ; 
00288          vtr.reserve( nA ) ;
00289          for( unsigned int i ( 0 ) ; i != nA ; ++i )
00290          {
00291             const HcalCastorDetId id ( HcalCastorDetId::EM, false, 1, 1 ) ;
00292             vtr.push_back( AlignTransform( Trl( 0, 0, 0 ), 
00293                                            Rot(),
00294                                            id           ) ) ;
00295          }
00296          return ali ;
00297       }
00298 
00299       ReturnAliErr produceCastorAliErr( const CastorAlignmentErrorRcd& /*iRecord*/ ) 
00300       { 
00301          ReturnAliErr aliErr ( new AlignmentErrors ); 
00302          return aliErr ;
00303       }
00304 };
00305 
00306 
00307 //define this as a plug-in
00308 DEFINE_FWK_EVENTSETUP_MODULE(TestCaloAlignmentEP);