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