CMS 3D CMS Logo

DTSurveyConvert.cc
Go to the documentation of this file.
1 #include <fstream>
2 
8 
10  : muonGeoToken_(esConsumes()),
11  dtGeomToken_(esConsumes()),
12  cscGeomToken_(esConsumes()),
13  gemGeomToken_(esConsumes()) {
14  //now do what ever initialization is needed
15  nameWheel_m2 = iConfig.getUntrackedParameter<std::string>("nameWheel_m2");
16  nameWheel_m1 = iConfig.getUntrackedParameter<std::string>("nameWheel_m1");
17  nameWheel_0 = iConfig.getUntrackedParameter<std::string>("nameWheel_0");
18  nameWheel_p1 = iConfig.getUntrackedParameter<std::string>("nameWheel_p1");
19  nameWheel_p2 = iConfig.getUntrackedParameter<std::string>("nameWheel_p2");
20 
21  nameChambers_m2 = iConfig.getUntrackedParameter<std::string>("nameChambers_m2");
22  nameChambers_m1 = iConfig.getUntrackedParameter<std::string>("nameChambers_m1");
23  nameChambers_0 = iConfig.getUntrackedParameter<std::string>("nameChambers_0");
24  nameChambers_p1 = iConfig.getUntrackedParameter<std::string>("nameChambers_p1");
25  nameChambers_p2 = iConfig.getUntrackedParameter<std::string>("nameChambers_p2");
26 
27  wheel_m2 = iConfig.getUntrackedParameter<bool>("wheel_m2");
28  wheel_m1 = iConfig.getUntrackedParameter<bool>("wheel_m1");
29  wheel_0 = iConfig.getUntrackedParameter<bool>("wheel_0");
30  wheel_p1 = iConfig.getUntrackedParameter<bool>("wheel_p1");
31  wheel_p2 = iConfig.getUntrackedParameter<bool>("wheel_p2");
32 
33  outputFileName = iConfig.getUntrackedParameter<std::string>("OutputTextFile");
34  WriteToDB = iConfig.getUntrackedParameter<bool>("writeToDB");
35 }
36 
37 // ------------ method called to for each event ------------
38 void DTSurveyConvert::analyze(const edm::Event &, const edm::EventSetup &iSetup) {
39  const DTGeometry *pDD = &iSetup.getData(muonGeoToken_);
40 
41  std::ofstream outFile(outputFileName.c_str());
42 
43  if (wheel_m2 == true) {
45  wheel->ReadChambers(pDD);
46  wheel->CalculateChambers();
47  outFile << *wheel;
48  wheelList.push_back(wheel);
49  }
50  if (wheel_m1 == true) {
52  wheel->ReadChambers(pDD);
53  wheel->CalculateChambers();
54  outFile << *wheel;
55  wheelList.push_back(wheel);
56  }
57  if (wheel_0 == true) {
59  wheel->ReadChambers(pDD);
60  wheel->CalculateChambers();
61  outFile << *wheel;
62  wheelList.push_back(wheel);
63  }
64  if (wheel_p1 == true) {
66  wheel->ReadChambers(pDD);
67  wheel->CalculateChambers();
68  outFile << *wheel;
69  wheelList.push_back(wheel);
70  }
71  if (wheel_p2 == true) {
73  wheel->ReadChambers(pDD);
74  wheel->CalculateChambers();
75  outFile << *wheel;
76  wheelList.push_back(wheel);
77  }
78  outFile.close();
79 
80  if (WriteToDB == true) {
81  // Instantiate the helper class
82  const DTGeometry *dtGeometry = &iSetup.getData(dtGeomToken_);
83  const CSCGeometry *cscGeometry = &iSetup.getData(cscGeomToken_);
84  const GEMGeometry *gemGeometry = &iSetup.getData(gemGeomToken_);
85 
86  MuonAlignment align(&*dtGeometry, &*cscGeometry, &*gemGeometry);
87  std::ifstream inFile(outputFileName.c_str());
88  while (!inFile.eof()) {
89  float dx, dy, dz, sigma_dx, sigma_dy, sigma_dz;
90  float alpha, beta, gamma, sigma_alpha, sigma_beta, sigma_gamma;
91  inFile >> dx >> sigma_dx >> dy >> sigma_dy >> dz >> sigma_dz >> alpha >> sigma_alpha >> beta >> sigma_beta >>
92  gamma >> sigma_gamma;
93  if (inFile.eof())
94  break;
95  std::vector<float> displacement;
96  displacement.push_back(dx);
97  displacement.push_back(dy);
98  displacement.push_back(dz);
99  displacement.push_back(-alpha);
100  displacement.push_back(-beta);
101  displacement.push_back(-gamma);
102  }
103  inFile.close();
104  align.saveToDB();
105  }
106 }
107 
std::string nameWheel_p2
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
float alpha
Definition: AMPTWrapper.h:105
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
std::string nameChambers_0
std::string nameChambers_p2
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string nameChambers_p1
std::string nameWheel_m2
std::string nameWheel_p1
std::string outputFileName
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeoToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
std::string nameChambers_m2
std::vector< DTSurvey * > wheelList
std::string nameWheel_0
void analyze(const edm::Event &, const edm::EventSetup &) override
DTSurveyConvert(const edm::ParameterSet &)
std::string nameWheel_m1
std::string nameChambers_m1
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_