CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Member Functions

WriteESAlignments Class Reference

#include <WriteESAlignments.h>

List of all members.

Public Types

typedef AlignmentsAliPtr
typedef std::vector
< AlignTransform
AliVec
typedef std::vector< double > DVec
typedef AlignTransform::Rotation Rot
typedef AlignTransform::Translation Trl

Public Member Functions

 WriteESAlignments (const edm::EventSetup &eventSetup, const DVec &alphaVec, const DVec &betaVec, const DVec &gammaVec, const DVec &xtranslVec, const DVec &ytranslVec, const DVec &ztranslVec)
 ~WriteESAlignments ()

Static Public Attributes

static const unsigned int k_nA = EcalPreshowerGeometry::numberOfAlignments()

Private Member Functions

void convert (const edm::EventSetup &eS, const DVec &a, const DVec &b, const DVec &g, const DVec &x, const DVec &y, const DVec &z, AliVec &va)
void write (AliPtr aliPtr)

Detailed Description

Definition at line 14 of file WriteESAlignments.h.


Member Typedef Documentation

Definition at line 18 of file WriteESAlignments.h.

Definition at line 19 of file WriteESAlignments.h.

typedef std::vector<double> WriteESAlignments::DVec

Definition at line 24 of file WriteESAlignments.h.

Definition at line 22 of file WriteESAlignments.h.

Definition at line 21 of file WriteESAlignments.h.


Constructor & Destructor Documentation

WEA::WriteESAlignments ( const edm::EventSetup eventSetup,
const DVec alphaVec,
const DVec betaVec,
const DVec gammaVec,
const DVec xtranslVec,
const DVec ytranslVec,
const DVec ztranslVec 
)

Definition at line 18 of file WriteESAlignments.cc.

References convert(), k_nA, and write().

{
   assert( alphaVec.size()   == k_nA ) ;
   assert( betaVec.size()    == k_nA ) ;
   assert( gammaVec.size()   == k_nA ) ;
   assert( xtranslVec.size() == k_nA ) ;
   assert( ytranslVec.size() == k_nA ) ;
   assert( ztranslVec.size() == k_nA ) ;

   AliPtr  aliPtr ( new Alignments  ) ;// writeOne will take ownership!
   AliVec& vali   ( aliPtr->m_align ) ;

   convert( eventSetup , 
            alphaVec   ,
            betaVec    , 
            gammaVec   ,
            xtranslVec , 
            ytranslVec , 
            ztranslVec ,
            vali         ) ;

   write( aliPtr ) ;
}
WEA::~WriteESAlignments ( )

Definition at line 16 of file WriteESAlignments.cc.

{}

Member Function Documentation

void WEA::convert ( const edm::EventSetup eS,
const DVec a,
const DVec b,
const DVec g,
const DVec x,
const DVec y,
const DVec z,
WEA::AliVec va 
) [private]

Definition at line 64 of file WriteESAlignments.cc.

References alpha, beta, gather_cfg::cout, EcalPreshowerGeometry::detIdFromLocalAlignmentIndex(), DetId::Ecal, EcalPreshower, relativeConstraints::geom, edm::EventSetup::get(), i, errorMatrix2Lands_multiChannel::id, k_nA, idealTransformation::rotation, and z.

Referenced by WriteESAlignments().

{
   edm::ESHandle<CaloGeometry>       pG   ;
   eS.get<CaloGeometryRecord>().get( pG ) ;

   const CaloSubdetectorGeometry* geom ( 
      pG->getSubdetectorGeometry( DetId::Ecal, EcalPreshower ) ) ;

   edm::ESHandle<Alignments>  pA ;
   eS.get<ESAlignmentRcd>().get( pA ) ;
   const AliVec& vaPrev ( pA->m_align ) ;

   va.reserve( k_nA ) ;
   for( unsigned int i ( 0 ) ; i != k_nA ; ++i )
   {
      // ordering of i is: left, right, left, right,...
      // starting at ES- rear, then ES- front, 
      // then ES+ front, then ES+ rear

      const ESDetId id ( EcalPreshowerGeometry::detIdFromLocalAlignmentIndex( i ) ) ;

      const double zPlanePrev ( geom->getGeometry( id )->getPosition().z() ) ;
      const double zAlignPrev ( vaPrev[i].translation().z() ) ;
      const Trl    q_I ( 0, 0, zPlanePrev - zAlignPrev ) ;
      const Trl&   s_p ( vaPrev[i].translation() ) ;
      const Trl    t_n ( x[i], y[i], z[i] ) ;
      const Rot    G_p ( vaPrev[i].rotation() ) ;
      const double gamma ( g[i] ) ;
      const double alpha ( a[i] ) ;
      const double beta  ( b[i] ) ;

      const Rot L_n ( // New rotation in local frame!
         Rot( Rot( Rot().rotateZ( -gamma ) ).rotateX( -alpha ) ).rotateY( -beta ) ) ;

      const Rot InvL_n ( L_n.inverse() ) ;

      const Rot G_n ( InvL_n * G_p ) ;

      const Trl s_n ( t_n + s_p + q_I - InvL_n*q_I ) ;

      std::cout<<"For i = "<<i<<", q_I="<<q_I<<std::endl ;
      std::cout<<"For i = "<<i<<", s_p="<<s_p<<std::endl ;
      std::cout<<"For i = "<<i<<", alpha = "<<1000.*alpha<<" mr"<<std::endl;
      std::cout<<"For i = "<<i<<", beta  = "<<1000.*beta <<" mr"<<std::endl;
      std::cout<<"For i = "<<i<<", gamma = "<<1000.*gamma<<" mr"<<std::endl;
      std::cout<<" For i = "<<i<<", L_n = "<< L_n
               <<"   Euler angles="<<InvL_n.eulerAngles()<<"\n"<<std::endl;
      std::cout<<"For i = "<<i<<", t_n="<<t_n<<std::endl ;
      std::cout<<"For i = "<<i<<", G_p="<<G_p
               <<"   Euler angles="<<G_p.eulerAngles()<<"\n"<<std::endl ;
      std::cout<<" For i = "<<i<<", InvL_n = "<< InvL_n
               <<"   Euler angles="<<InvL_n.eulerAngles()<<"\n"<<std::endl;
      std::cout<<" For i ="<<i<<", G_n = "<< G_n
               <<"    Euler angles="<<G_n.eulerAngles()<<"\n"<<std::endl;
      std::cout<<" For i ="<<i<<", s_n = "<< s_n<<std::endl;
      std::cout<<"++++++++++++++++++++++++++\n\n"<<std::endl;

      va.push_back( AlignTransform( s_n, G_n, id ) ) ;
   }
}
void WEA::write ( WEA::AliPtr  aliPtr) [private]

Definition at line 49 of file WriteESAlignments.cc.

References gather_cfg::cout, and edm::Service< T >::isAvailable().

Referenced by WriteESAlignments().

{
   std::cout << "Uploading ES alignments to the database" << std::endl ;

   edm::Service<cond::service::PoolDBOutputService> poolDbService ;

   if (!poolDbService.isAvailable()) throw cms::Exception("NotAvailable") 
      << "PoolDBOutputService not available";

   poolDbService->writeOne<Alignments>(&(*aliPtr), 
                                       poolDbService->currentTime(),
                                       "ESAlignmentRcd" ) ;
}

Member Data Documentation

const unsigned int WEA::k_nA = EcalPreshowerGeometry::numberOfAlignments() [static]

Definition at line 26 of file WriteESAlignments.h.

Referenced by convert(), and WriteESAlignments().