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 // $Id: RotationForOnline.cc,v 1.7 2010/03/25 21:55:36 case Exp $
5 //
6 //
7 
8 
9 // system include files
10 #include <memory>
11 
12 // user include files
18 
23 
24 
25 #include <iostream>
26 #include <istream>
27 #include <fstream>
28 #include <string>
29 
30 
31 
32 //
33 // class decleration
34 //
35 
37  public:
38  explicit RotationForOnline(const edm::ParameterSet&);
40  virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
41  virtual void analyze(const edm::Event&, const edm::EventSetup&);
42  virtual void endJob() ;
43 
44 
45  private:
46 
47  // ----------member data ---------------------------
48 };
49 
50 //
51 // constants, enums and typedefs
52 //
53 
54 //
55 // static data member definitions
56 //
57 
58 //
59 // constructors and destructor
60 //
62 {
63  //now do what ever initialization is needed
64 
65 }
66 
67 
69 {
70 
71  // do anything here that needs to be done at desctruction time
72  // (e.g. close files, deallocate resources etc.)
73 
74 }
75 
76 
77 //
78 // member functions
79 //
80 
81 // ------------ method called to for each event ------------
82 void
84 {
85  std::cout << "analyze does nothing" << std::endl;
86 }
87 
88 
89 // ------------ method called once each job just before starting event loop ------------
90 void
92 {
93  // set tolerance for "near zero"
94  double tolerance= 1.0e-3;
95  std::string rotationFileName("ROTATIONS.dat");
96  std::ofstream rotationOS(rotationFileName.c_str());
97  std::cout << "RotationForOnline Analyzer..." << std::endl;
98 
99 
101 
102  iSetup.get<IdealGeometryRecord>().get( "", pDD );
103  DDRotationMatrix ident;
104 
105  DDRotation::iterator<DDRotation> rit(DDRotation::begin()), red(DDRotation::end());
106  for (; rit != red; ++rit) {
107  if (! rit->isDefined().second) continue;
108  // if ( rit->matrix()->isIdentity() ) continue;
109  if ( *(rit->matrix()) == ident ) continue;
110  const DDRotation& rota = *rit;
111  bool reflection = false;
112 
113  DD3Vector x, y, z;
114  rit->matrix()->GetComponents(x, y, z);
115  if ( (1.0 + (x.Cross(y)).Dot(z)) <= tolerance ) {
116  reflection = true;
117  }
118 
119  rotationOS<< *(rota.isDefined().first); //rota name
120  double thetaX, phiX, thetaY, phiY, thetaZ, phiZ;
121 
122  thetaX = std::acos(x.z());
123  phiX = ( x.y() == 0 && x.x() == 0.0) ? 0.0 : std::atan2(x.y(), x.x());
124 
125  thetaY = std::acos(y.z());
126  phiY = ( y.y() == 0 && y.x() == 0.0) ? 0.0 : std::atan2(y.y(), y.x());
127 
128  thetaZ = std::acos(z.z());
129  phiZ = ( z.y() == 0 && z.x() == 0.0) ? 0.0 : std::atan2(z.y(), z.x());
130 
131  rotationOS<< "," << thetaX
132  << "," << phiX
133  << "," << thetaY
134  << "," << phiY
135  << "," << thetaZ
136  << "," << phiZ
137  << "," << (int)reflection
138  <<std::endl;
139  }
140 
141  rotationOS.close();
142 
143 }
144 
145 // ------------ method called once each job just after ending the event loop ------------
146 void
148 }
149 
150 //define this as a plug-in
def_type isDefined() const
Definition: DDBase.h:115
#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 beginRun(const edm::Run &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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.
virtual void endJob()
Definition: Run.h:36