CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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) {
44  DTSurvey *wheel = new DTSurvey(nameWheel_m2, nameChambers_m2, -2);
45  wheel->ReadChambers(pDD);
46  wheel->CalculateChambers();
47  outFile << *wheel;
48  wheelList.push_back(wheel);
49  }
50  if (wheel_m1 == true) {
51  DTSurvey *wheel = new DTSurvey(nameWheel_m1, nameChambers_m1, -1);
52  wheel->ReadChambers(pDD);
53  wheel->CalculateChambers();
54  outFile << *wheel;
55  wheelList.push_back(wheel);
56  }
57  if (wheel_0 == true) {
58  DTSurvey *wheel = new DTSurvey(nameWheel_0, nameChambers_0, 0);
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 
T getUntrackedParameter(std::string const &, T const &) const
std::string nameWheel_p2
float alpha
Definition: AMPTWrapper.h:105
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
std::string nameChambers_0
void ReadChambers(edm::ESHandle< DTGeometry >)
Definition: DTSurvey.cc:34
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
void CalculateChambers()
Definition: DTSurvey.cc:22
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeoToken_
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
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::string nameChambers_m1
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_