CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RotationForOnline.cc
Go to the documentation of this file.
1 //
2 // Original Author: Jie Chen
3 // Created: Mon Apr 9 11:36:53 CDT 2007
4 //
5 //
6 
7 
8 // system include files
9 #include <memory>
10 
11 // user include files
17 
22 
23 
24 #include <iostream>
25 #include <istream>
26 #include <fstream>
27 #include <string>
28 
29 
30 
31 //
32 // class decleration
33 //
34 
36  public:
37  explicit RotationForOnline(const edm::ParameterSet&);
39  virtual void beginRun(const edm::Run&, const edm::EventSetup&) override ;
40  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
41  virtual void endJob() override ;
42 
43 
44  private:
45 
46  // ----------member data ---------------------------
47 };
48 
49 //
50 // constants, enums and typedefs
51 //
52 
53 //
54 // static data member definitions
55 //
56 
57 //
58 // constructors and destructor
59 //
61 {
62  //now do what ever initialization is needed
63 
64 }
65 
66 
68 {
69 
70  // do anything here that needs to be done at desctruction time
71  // (e.g. close files, deallocate resources etc.)
72 
73 }
74 
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to for each event ------------
81 void
83 {
84  std::cout << "analyze does nothing" << std::endl;
85 }
86 
87 
88 // ------------ method called once each job just before starting event loop ------------
89 void
91 {
92  // set tolerance for "near zero"
93  double tolerance= 1.0e-3;
94  std::string rotationFileName("ROTATIONS.dat");
95  std::ofstream rotationOS(rotationFileName.c_str());
96  std::cout << "RotationForOnline Analyzer..." << std::endl;
97 
98 
100 
101  iSetup.get<IdealGeometryRecord>().get( "", pDD );
102  DDRotationMatrix ident;
103 
104  DDRotation::iterator<DDRotation> rit(DDRotation::begin()), red(DDRotation::end());
105  for (; rit != red; ++rit) {
106  if (! rit->isDefined().second) continue;
107  // if ( rit->matrix()->isIdentity() ) continue;
108  if ( *(rit->matrix()) == ident ) continue;
109  const DDRotation& rota = *rit;
110  bool reflection = false;
111 
112  DD3Vector x, y, z;
113  rit->matrix()->GetComponents(x, y, z);
114  if ( (1.0 + (x.Cross(y)).Dot(z)) <= tolerance ) {
115  reflection = true;
116  }
117 
118  rotationOS<< *(rota.isDefined().first); //rota name
119  double thetaX, phiX, thetaY, phiY, thetaZ, phiZ;
120 
121  thetaX = std::acos(x.z());
122  phiX = ( x.y() == 0 && x.x() == 0.0) ? 0.0 : std::atan2(x.y(), x.x());
123 
124  thetaY = std::acos(y.z());
125  phiY = ( y.y() == 0 && y.x() == 0.0) ? 0.0 : std::atan2(y.y(), y.x());
126 
127  thetaZ = std::acos(z.z());
128  phiZ = ( z.y() == 0 && z.x() == 0.0) ? 0.0 : std::atan2(z.y(), z.x());
129 
130  rotationOS<< "," << thetaX
131  << "," << phiX
132  << "," << thetaY
133  << "," << phiY
134  << "," << thetaZ
135  << "," << phiZ
136  << "," << (int)reflection
137  <<std::endl;
138  }
139 
140  rotationOS.close();
141 
142 }
143 
144 // ------------ method called once each job just after ending the event loop ------------
145 void
147 }
148 
149 //define this as a plug-in
def_type isDefined() const
Definition: DDBase.h:115
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
float float float z
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
int iEvent
Definition: GenABIO.cc:243
RotationForOnline(const edm::ParameterSet &)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
const T & get() const
Definition: EventSetup.h:55
virtual void endJob() override
static DDI::Store< DDName, DDRotationMatrix * >::iterator begin()
Definition: DDBase.h:70
tuple cout
Definition: gather_cfg.py:121
static DDI::Store< DDName, DDRotationMatrix * >::iterator end()
Definition: DDBase.h:69
Definition: DDAxes.h:10
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: Run.h:41