Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <memory>
00011
00012
00013 #include "FWCore/Framework/interface/EDAnalyzer.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/Framework/interface/ESTransientHandle.h"
00016 #include <FWCore/Framework/interface/ESHandle.h>
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018
00019 #include <DetectorDescription/Core/interface/DDCompactView.h>
00020 #include <DetectorDescription/Core/interface/DDValue.h>
00021 #include "DetectorDescription/Core/interface/DDName.h"
00022 #include <Geometry/Records/interface/IdealGeometryRecord.h>
00023
00024
00025 #include <iostream>
00026 #include <istream>
00027 #include <fstream>
00028 #include <string>
00029
00030
00031
00032
00033
00034
00035
00036 class RotationForOnline : public edm::EDAnalyzer {
00037 public:
00038 explicit RotationForOnline(const edm::ParameterSet&);
00039 ~RotationForOnline();
00040 virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
00041 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00042 virtual void endJob() ;
00043
00044
00045 private:
00046
00047
00048 };
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 RotationForOnline::RotationForOnline(const edm::ParameterSet& iConfig)
00062 {
00063
00064
00065 }
00066
00067
00068 RotationForOnline::~RotationForOnline()
00069 {
00070
00071
00072
00073
00074 }
00075
00076
00077
00078
00079
00080
00081
00082 void
00083 RotationForOnline::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00084 {
00085 std::cout << "analyze does nothing" << std::endl;
00086 }
00087
00088
00089
00090 void
00091 RotationForOnline::beginRun(const edm::Run&, const edm::EventSetup& iSetup)
00092 {
00093
00094 double tolerance= 1.0e-3;
00095 std::string rotationFileName("ROTATIONS.dat");
00096 std::ofstream rotationOS(rotationFileName.c_str());
00097 std::cout << "RotationForOnline Analyzer..." << std::endl;
00098
00099
00100 edm::ESTransientHandle<DDCompactView> pDD;
00101
00102 iSetup.get<IdealGeometryRecord>().get( "", pDD );
00103 DDRotationMatrix ident;
00104
00105 DDRotation::iterator<DDRotation> rit(DDRotation::begin()), red(DDRotation::end());
00106 for (; rit != red; ++rit) {
00107 if (! rit->isDefined().second) continue;
00108
00109 if ( *(rit->matrix()) == ident ) continue;
00110 const DDRotation& rota = *rit;
00111 bool reflection = false;
00112
00113 DD3Vector x, y, z;
00114 rit->matrix()->GetComponents(x, y, z);
00115 if ( (1.0 + (x.Cross(y)).Dot(z)) <= tolerance ) {
00116 reflection = true;
00117 }
00118
00119 rotationOS<< *(rota.isDefined().first);
00120 double thetaX, phiX, thetaY, phiY, thetaZ, phiZ;
00121
00122 thetaX = std::acos(x.z());
00123 phiX = ( x.y() == 0 && x.x() == 0.0) ? 0.0 : std::atan2(x.y(), x.x());
00124
00125 thetaY = std::acos(y.z());
00126 phiY = ( y.y() == 0 && y.x() == 0.0) ? 0.0 : std::atan2(y.y(), y.x());
00127
00128 thetaZ = std::acos(z.z());
00129 phiZ = ( z.y() == 0 && z.x() == 0.0) ? 0.0 : std::atan2(z.y(), z.x());
00130
00131 rotationOS<< "," << thetaX
00132 << "," << phiX
00133 << "," << thetaY
00134 << "," << phiY
00135 << "," << thetaZ
00136 << "," << phiZ
00137 << "," << (int)reflection
00138 <<std::endl;
00139 }
00140
00141 rotationOS.close();
00142
00143 }
00144
00145
00146 void
00147 RotationForOnline::endJob() {
00148 }
00149
00150
00151 DEFINE_FWK_MODULE(RotationForOnline);