CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WriteESAlignments.cc
Go to the documentation of this file.
2 
7 
9 
13 
15 
17 
19 
21  const WEA::DVec& alphaVec ,
22  const WEA::DVec& betaVec ,
23  const WEA::DVec& gammaVec ,
24  const WEA::DVec& xtranslVec ,
25  const WEA::DVec& ytranslVec ,
26  const WEA::DVec& ztranslVec )
27 {
28  assert( alphaVec.size() == k_nA ) ;
29  assert( betaVec.size() == k_nA ) ;
30  assert( gammaVec.size() == k_nA ) ;
31  assert( xtranslVec.size() == k_nA ) ;
32  assert( ytranslVec.size() == k_nA ) ;
33  assert( ztranslVec.size() == k_nA ) ;
34 
35  AliPtr aliPtr ( new Alignments ) ;// writeOne will take ownership!
36  AliVec& vali ( aliPtr->m_align ) ;
37 
38  convert( eventSetup ,
39  alphaVec ,
40  betaVec ,
41  gammaVec ,
42  xtranslVec ,
43  ytranslVec ,
44  ztranslVec ,
45  vali ) ;
46 
47  write( aliPtr ) ;
48 }
49 
50 void
52 {
53  std::cout << "Uploading ES alignments to the database" << std::endl ;
54 
56 
57  if (!poolDbService.isAvailable()) throw cms::Exception("NotAvailable")
58  << "PoolDBOutputService not available";
59 
60  poolDbService->writeOne<Alignments>(&(*aliPtr),
61  poolDbService->currentTime(),
62  "ESAlignmentRcd" ) ;
63 }
64 
65 void
67  const WEA::DVec& a ,
68  const WEA::DVec& b ,
69  const WEA::DVec& g ,
70  const WEA::DVec& x ,
71  const WEA::DVec& y ,
72  const WEA::DVec& z ,
73  WEA::AliVec& va )
74 {
76  eS.get<CaloGeometryRecord>().get( pG ) ;
77 
79  pG->getSubdetectorGeometry( DetId::Ecal, EcalPreshower ) ) ;
80 
82  eS.get<ESAlignmentRcd>().get( pA ) ;
83  const AliVec& vaPrev ( pA->m_align ) ;
84 
85  va.reserve( k_nA ) ;
86  for( unsigned int i ( 0 ) ; i != k_nA ; ++i )
87  {
88  // ordering of i is: left, right, left, right,...
89  // starting at ES- rear, then ES- front,
90  // then ES+ front, then ES+ rear
91 
93 
94  const double zPlanePrev ( geom->getGeometry( id )->getPosition().z() ) ;
95  const double zAlignPrev ( vaPrev[i].translation().z() ) ;
96  const Trl q_I ( 0, 0, zPlanePrev - zAlignPrev ) ;
97  const Trl& s_p ( vaPrev[i].translation() ) ;
98  const Trl t_n ( x[i], y[i], z[i] ) ;
99  const Rot G_p ( vaPrev[i].rotation() ) ;
100  const double gamma ( g[i] ) ;
101  const double alpha ( a[i] ) ;
102  const double beta ( b[i] ) ;
103 
104  const Rot L_n ( // New rotation in local frame!
105  Rot( Rot( Rot().rotateZ( -gamma ) ).rotateX( -alpha ) ).rotateY( -beta ) ) ;
106 
107  const Rot InvL_n ( L_n.inverse() ) ;
108 
109  const Rot G_n ( InvL_n * G_p ) ;
110 
111  const Trl s_n ( t_n + s_p + q_I - InvL_n*q_I ) ;
112 
113  std::cout<<"For i = "<<i<<", q_I="<<q_I<<std::endl ;
114  std::cout<<"For i = "<<i<<", s_p="<<s_p<<std::endl ;
115  std::cout<<"For i = "<<i<<", alpha = "<<1000.*alpha<<" mr"<<std::endl;
116  std::cout<<"For i = "<<i<<", beta = "<<1000.*beta <<" mr"<<std::endl;
117  std::cout<<"For i = "<<i<<", gamma = "<<1000.*gamma<<" mr"<<std::endl;
118  std::cout<<" For i = "<<i<<", L_n = "<< L_n
119  <<" Euler angles="<<InvL_n.eulerAngles()<<"\n"<<std::endl;
120  std::cout<<"For i = "<<i<<", t_n="<<t_n<<std::endl ;
121  std::cout<<"For i = "<<i<<", G_p="<<G_p
122  <<" Euler angles="<<G_p.eulerAngles()<<"\n"<<std::endl ;
123  std::cout<<" For i = "<<i<<", InvL_n = "<< InvL_n
124  <<" Euler angles="<<InvL_n.eulerAngles()<<"\n"<<std::endl;
125  std::cout<<" For i ="<<i<<", G_n = "<< G_n
126  <<" Euler angles="<<G_n.eulerAngles()<<"\n"<<std::endl;
127  std::cout<<" For i ="<<i<<", s_n = "<< s_n<<std::endl;
128  std::cout<<"++++++++++++++++++++++++++\n\n"<<std::endl;
129 
130  va.push_back( AlignTransform( s_n, G_n, id ) ) ;
131  }
132 }
AlignTransform::Rotation Rot
const double beta
int i
Definition: DBlmapReader.cc:9
AlignTransform::Translation Trl
float alpha
Definition: AMPTWrapper.h:95
std::vector< AlignTransform > AliVec
assert(m_qm.get())
void write(AliPtr aliPtr)
WriteESAlignments WEA
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
float float float z
WriteESAlignments(const edm::EventSetup &eventSetup, const DVec &alphaVec, const DVec &betaVec, const DVec &gammaVec, const DVec &xtranslVec, const DVec &ytranslVec, const DVec &ztranslVec)
static DetId detIdFromLocalAlignmentIndex(unsigned int iLoc)
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
static unsigned int numberOfAlignments()
const T & get() const
Definition: EventSetup.h:55
double b
Definition: hdecay.h:120
static const unsigned int k_nA
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
std::vector< double > DVec
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)