00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h"
00015 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017
00018 #include "Alignment/MuonAlignment/interface/AlignableMuon.h"
00019 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00020 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00021 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00022
00023 #include "TTree.h"
00024
00025 #include <fstream>
00026
00027
00028
00029
00030
00031
00032
00033 class AlignmentMonitorMuonPositions: public AlignmentMonitorBase {
00034 public:
00035 AlignmentMonitorMuonPositions(const edm::ParameterSet& cfg);
00036 ~AlignmentMonitorMuonPositions() {};
00037
00038 void book();
00039 void event(const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& iTrajTracks);
00040 void afterAlignment(const edm::EventSetup &iSetup);
00041
00042 private:
00043 void fill();
00044
00045 TTree *m_wheels, *m_dtchambers, *m_rings, *m_cscchambers;
00046 Int_t m_wheel_id;
00047 Float_t m_wheel_x, m_wheel_y, m_wheel_z, m_wheel_phix, m_wheel_phiy, m_wheel_phiz;
00048 Int_t m_dtchamber_id, m_dtchamber_rawid, m_dtchamber_wheel;
00049 Float_t m_dtchamber_x, m_dtchamber_y, m_dtchamber_z, m_dtchamber_phix, m_dtchamber_phiy, m_dtchamber_phiz;
00050 Int_t m_ring_id;
00051 Float_t m_ring_x, m_ring_y, m_ring_z, m_ring_phix, m_ring_phiy, m_ring_phiz;
00052 Int_t m_cscchamber_id, m_cscchamber_rawid, m_cscchamber_ring;
00053 Float_t m_cscchamber_x, m_cscchamber_y, m_cscchamber_z, m_cscchamber_phix, m_cscchamber_phiy, m_cscchamber_phiz;
00054 };
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 AlignmentMonitorMuonPositions::AlignmentMonitorMuonPositions(const edm::ParameterSet& cfg)
00086 : AlignmentMonitorBase(cfg, "AlignmentMonitorMuonPositions")
00087 {
00088 }
00089
00090
00091
00092
00093
00095
00097
00098 void AlignmentMonitorMuonPositions::book() {
00099 if (iteration() == 1) {
00100 m_wheels = directory("/start/")->make<TTree>("wheels", "wheel positions after iteration");
00101 m_wheels->Branch("id", &m_wheel_id, "id/I");
00102 m_wheels->Branch("x", &m_wheel_x, "x/F");
00103 m_wheels->Branch("y", &m_wheel_y, "y/F");
00104 m_wheels->Branch("z", &m_wheel_z, "z/F");
00105 m_wheels->Branch("phix", &m_wheel_phix, "phix/F");
00106 m_wheels->Branch("phiy", &m_wheel_phiy, "phiy/F");
00107 m_wheels->Branch("phiz", &m_wheel_phiz, "phiz/F");
00108
00109 m_dtchambers = directory("/start/")->make<TTree>("dtchambers", "dtchamber positions after iteration");
00110 m_dtchambers->Branch("id", &m_dtchamber_id, "id/I");
00111 m_dtchambers->Branch("rawid", &m_dtchamber_rawid, "rawid/I");
00112 m_dtchambers->Branch("wheel", &m_dtchamber_wheel, "wheel/I");
00113 m_dtchambers->Branch("x", &m_dtchamber_x, "x/F");
00114 m_dtchambers->Branch("y", &m_dtchamber_y, "y/F");
00115 m_dtchambers->Branch("z", &m_dtchamber_z, "z/F");
00116 m_dtchambers->Branch("phix", &m_dtchamber_phix, "phix/F");
00117 m_dtchambers->Branch("phiy", &m_dtchamber_phiy, "phiy/F");
00118 m_dtchambers->Branch("phiz", &m_dtchamber_phiz, "phiz/F");
00119
00120 m_rings = directory("/start/")->make<TTree>("rings", "ring positions after iteration");
00121 m_rings->Branch("id", &m_ring_id, "id/I");
00122 m_rings->Branch("x", &m_ring_x, "x/F");
00123 m_rings->Branch("y", &m_ring_y, "y/F");
00124 m_rings->Branch("z", &m_ring_z, "z/F");
00125 m_rings->Branch("phix", &m_ring_phix, "phix/F");
00126 m_rings->Branch("phiy", &m_ring_phiy, "phiy/F");
00127 m_rings->Branch("phiz", &m_ring_phiz, "phiz/F");
00128
00129 m_cscchambers = directory("/start/")->make<TTree>("cscchambers", "cscchamber positions after iteration");
00130 m_cscchambers->Branch("id", &m_cscchamber_id, "id/I");
00131 m_cscchambers->Branch("rawid", &m_cscchamber_rawid, "rawid/I");
00132 m_cscchambers->Branch("ring", &m_cscchamber_ring, "ring/I");
00133 m_cscchambers->Branch("x", &m_cscchamber_x, "x/F");
00134 m_cscchambers->Branch("y", &m_cscchamber_y, "y/F");
00135 m_cscchambers->Branch("z", &m_cscchamber_z, "z/F");
00136 m_cscchambers->Branch("phix", &m_cscchamber_phix, "phix/F");
00137 m_cscchambers->Branch("phiy", &m_cscchamber_phiy, "phiy/F");
00138 m_cscchambers->Branch("phiz", &m_cscchamber_phiz, "phiz/F");
00139
00140 fill();
00141 }
00142
00143 m_wheels = directory("/iterN/")->make<TTree>("wheels", "wheel positions after iteration");
00144 m_wheels->Branch("id", &m_wheel_id, "id/I");
00145 m_wheels->Branch("x", &m_wheel_x, "x/F");
00146 m_wheels->Branch("y", &m_wheel_y, "y/F");
00147 m_wheels->Branch("z", &m_wheel_z, "z/F");
00148 m_wheels->Branch("phix", &m_wheel_phix, "phix/F");
00149 m_wheels->Branch("phiy", &m_wheel_phiy, "phiy/F");
00150 m_wheels->Branch("phiz", &m_wheel_phiz, "phiz/F");
00151
00152 m_dtchambers = directory("/iterN/")->make<TTree>("dtchambers", "dtchamber positions after iteration");
00153 m_dtchambers->Branch("id", &m_dtchamber_id, "id/I");
00154 m_dtchambers->Branch("rawid", &m_dtchamber_rawid, "rawid/I");
00155 m_dtchambers->Branch("wheel", &m_dtchamber_wheel, "wheel/I");
00156 m_dtchambers->Branch("x", &m_dtchamber_x, "x/F");
00157 m_dtchambers->Branch("y", &m_dtchamber_y, "y/F");
00158 m_dtchambers->Branch("z", &m_dtchamber_z, "z/F");
00159 m_dtchambers->Branch("phix", &m_dtchamber_phix, "phix/F");
00160 m_dtchambers->Branch("phiy", &m_dtchamber_phiy, "phiy/F");
00161 m_dtchambers->Branch("phiz", &m_dtchamber_phiz, "phiz/F");
00162
00163 m_rings = directory("/iterN/")->make<TTree>("rings", "ring positions after iteration");
00164 m_rings->Branch("id", &m_ring_id, "id/I");
00165 m_rings->Branch("x", &m_ring_x, "x/F");
00166 m_rings->Branch("y", &m_ring_y, "y/F");
00167 m_rings->Branch("z", &m_ring_z, "z/F");
00168 m_rings->Branch("phix", &m_ring_phix, "phix/F");
00169 m_rings->Branch("phiy", &m_ring_phiy, "phiy/F");
00170 m_rings->Branch("phiz", &m_ring_phiz, "phiz/F");
00171
00172 m_cscchambers = directory("/iterN/")->make<TTree>("cscchambers", "cscchamber positions after iteration");
00173 m_cscchambers->Branch("id", &m_cscchamber_id, "id/I");
00174 m_cscchambers->Branch("rawid", &m_cscchamber_rawid, "rawid/I");
00175 m_cscchambers->Branch("ring", &m_cscchamber_ring, "ring/I");
00176 m_cscchambers->Branch("x", &m_cscchamber_x, "x/F");
00177 m_cscchambers->Branch("y", &m_cscchamber_y, "y/F");
00178 m_cscchambers->Branch("z", &m_cscchamber_z, "z/F");
00179 m_cscchambers->Branch("phix", &m_cscchamber_phix, "phix/F");
00180 m_cscchambers->Branch("phiy", &m_cscchamber_phiy, "phiy/F");
00181 m_cscchambers->Branch("phiz", &m_cscchamber_phiz, "phiz/F");
00182 }
00183
00185
00187
00188 void AlignmentMonitorMuonPositions::event(const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& tracks) { }
00189
00191
00193
00194 void AlignmentMonitorMuonPositions::afterAlignment(const edm::EventSetup &iSetup) {
00195 fill();
00196 }
00197
00198 void AlignmentMonitorMuonPositions::fill() {
00199 const std::vector<Alignable*> wheels = pMuon()->DTWheels();
00200 const std::vector<Alignable*> dtchambers = pMuon()->DTChambers();
00201 const std::vector<Alignable*> rings = pMuon()->CSCRings();
00202 const std::vector<Alignable*> cscchambers = pMuon()->CSCChambers();
00203
00204 for (std::vector<Alignable*>::const_iterator iter = wheels.begin(); iter != wheels.end(); ++iter) {
00205 LocalVector displacement = (*iter)->surface().toLocal((*iter)->displacement());
00206 align::RotationType rotation = (*iter)->surface().toLocal((*iter)->rotation());
00207 double mxx = rotation.xx();
00208 double myx = rotation.yx();
00209 double mzx = rotation.zx();
00210 double mzy = rotation.zy();
00211 double mzz = rotation.zz();
00212 double denom = sqrt(1. - mzx*mzx);
00213
00214 std::vector<Alignable*> components = (*iter)->components();
00215 while (components[0]->geomDetId().rawId() == 0) {
00216 components = components[0]->components();
00217 }
00218
00219 DTChamberId dtChamberId(components[0]->geomDetId().rawId());
00220 m_wheel_id = dtChamberId.wheel();
00221 m_wheel_x = displacement.x();
00222 m_wheel_y = displacement.y();
00223 m_wheel_z = displacement.z();
00224 m_wheel_phix = atan2(-mzy/denom, mzz/denom);
00225 m_wheel_phiy = atan2(mzx, denom);
00226 m_wheel_phiz = atan2(-myx/denom, mxx/denom);
00227 m_wheels->Fill();
00228 }
00229
00230 for (std::vector<Alignable*>::const_iterator iter = dtchambers.begin(); iter != dtchambers.end(); ++iter) {
00231 LocalVector displacement = (*iter)->surface().toLocal((*iter)->displacement());
00232 align::RotationType rotation = (*iter)->surface().toLocal((*iter)->rotation());
00233 double mxx = rotation.xx();
00234 double myx = rotation.yx();
00235 double mzx = rotation.zx();
00236 double mzy = rotation.zy();
00237 double mzz = rotation.zz();
00238 double denom = sqrt(1. - mzx*mzx);
00239
00240 DTChamberId dtChamberId((*iter)->geomDetId().rawId());
00241 m_dtchamber_id = dtChamberId.station() * 100 + dtChamberId.sector();
00242 m_dtchamber_rawid = (*iter)->geomDetId().rawId();
00243 m_dtchamber_wheel = dtChamberId.wheel();
00244 m_dtchamber_x = displacement.x();
00245 m_dtchamber_y = displacement.y();
00246 m_dtchamber_z = displacement.z();
00247 m_dtchamber_phix = atan2(-mzy/denom, mzz/denom);
00248 m_dtchamber_phiy = atan2(mzx, denom);
00249 m_dtchamber_phiz = atan2(-myx/denom, mxx/denom);
00250 m_dtchambers->Fill();
00251 }
00252
00253 for (std::vector<Alignable*>::const_iterator iter = rings.begin(); iter != rings.end(); ++iter) {
00254 LocalVector displacement = (*iter)->surface().toLocal((*iter)->displacement());
00255 align::RotationType rotation = (*iter)->surface().toLocal((*iter)->rotation());
00256 double mxx = rotation.xx();
00257 double myx = rotation.yx();
00258 double mzx = rotation.zx();
00259 double mzy = rotation.zy();
00260 double mzz = rotation.zz();
00261 double denom = sqrt(1. - mzx*mzx);
00262
00263 std::vector<Alignable*> components = (*iter)->components();
00264 while (components[0]->geomDetId().rawId() == 0) {
00265 components = components[0]->components();
00266 }
00267
00268 CSCDetId cscDetId(components[0]->geomDetId().rawId());
00269 m_ring_id = (cscDetId.endcap() == 1 ? 1 : -1) * (abs(cscDetId.station()) * 10 + cscDetId.ring());
00270 m_ring_x = displacement.x();
00271 m_ring_y = displacement.y();
00272 m_ring_z = displacement.z();
00273 m_ring_phix = atan2(-mzy/denom, mzz/denom);
00274 m_ring_phiy = atan2(mzx, denom);
00275 m_ring_phiz = atan2(-myx/denom, mxx/denom);
00276 m_rings->Fill();
00277 }
00278
00279 for (std::vector<Alignable*>::const_iterator iter = cscchambers.begin(); iter != cscchambers.end(); ++iter) {
00280 LocalVector displacement = (*iter)->surface().toLocal((*iter)->displacement());
00281 align::RotationType rotation = (*iter)->surface().toLocal((*iter)->rotation());
00282 double mxx = rotation.xx();
00283 double myx = rotation.yx();
00284 double mzx = rotation.zx();
00285 double mzy = rotation.zy();
00286 double mzz = rotation.zz();
00287 double denom = sqrt(1. - mzx*mzx);
00288
00289 CSCDetId cscDetId((*iter)->geomDetId().rawId());
00290 m_cscchamber_id = cscDetId.chamber();
00291 m_cscchamber_rawid = cscDetId.rawId();
00292 m_cscchamber_ring = (cscDetId.endcap() == 1 ? 1 : -1) * (abs(cscDetId.station()) * 10 + cscDetId.ring());
00293 m_cscchamber_x = displacement.x();
00294 m_cscchamber_y = displacement.y();
00295 m_cscchamber_z = displacement.z();
00296 m_cscchamber_phix = atan2(-mzy/denom, mzz/denom);
00297 m_cscchamber_phiy = atan2(mzx, denom);
00298 m_cscchamber_phiz = atan2(-myx/denom, mxx/denom);
00299 m_cscchambers->Fill();
00300 }
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 DEFINE_EDM_PLUGIN(AlignmentMonitorPluginFactory, AlignmentMonitorMuonPositions, "AlignmentMonitorMuonPositions");