CMS 3D CMS Logo

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