CMS 3D CMS Logo

DTMapGenerator.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author G. Cerminara, S. Bolognesi - INFN Torino
5  */
6 
8 
9 #include "DTMapGenerator.h"
10 
11 #include <iostream>
12 #include <fstream>
13 #include <sstream>
14 
15 using namespace edm;
16 using namespace std;
17 
19  // The output file with the map
20  outputMapName = pset.getUntrackedParameter<string>("outputFileName", "output.map");
21  // The input file with the base map (DDU ROS -> Wheel, Station, Sector)
22  inputMapName = pset.getUntrackedParameter<string>("inputFileName", "basemap.txt");
23  //The ros type: ROS8 for commissioning, ROS25 otherwise
24  rosType = pset.getUntrackedParameter<int>("rosType", 25);
25  if (rosType != 8 && rosType != 25) {
26  cout << "[DTMapGenerator]: wrong ros type (8 for commissioning, 25 otherwise)" << endl;
27  abort();
28  }
29 }
30 
32 
34  cout << "DTMapGenerator: Output Map: " << outputMapName << " ROS Type: " << rosType << endl;
35 
36  // Read the existing wires
37  ifstream existingChannels("/afs/cern.ch/cms/Physics/muon/CMSSW/DT/channelsMaps/existing_channels.txt");
38 
39  set<DTWireId> wireMap; //FIXME:MAYBE YOU NEED THE > and == operators to use set?
40 
41  // Read the map between DDU - ROS and Chambers
42  string lineMap;
43  while (getline(existingChannels, lineMap)) {
44  if (lineMap.empty() || lineMap[0] == '#')
45  continue; // Skip comments and empty lines
46  stringstream linestr;
47  linestr << lineMap;
48  int wheelEx, stationEx, sectorEx, slEx, layerEx, wireEx;
49  linestr >> wheelEx >> sectorEx >> stationEx >> slEx >> layerEx >> wireEx;
50  DTWireId wireIdEx(wheelEx, stationEx, sectorEx, slEx, layerEx, wireEx);
51  wireMap.insert(wireIdEx);
52  }
53  cout << "Map size: " << wireMap.size() << endl;
54 
55  // The map between DDU - ROS and Chambers
56  ifstream skeletonMap(inputMapName.c_str());
57 
58  // The output map in the CMSSW format
59  ofstream outputMap(outputMapName.c_str());
60 
61  // Read the map between DDU - ROS and Chambers
62  string line;
63  while (getline(skeletonMap, line)) {
64  if (line.empty() || line[0] == '#')
65  continue; // Skip comments and empty lines
66  stringstream linestr;
67  linestr << line;
68  int ddu, ros, wheel, station, sector;
69  linestr >> ddu >> ros >> wheel >> station >> sector;
70  cout << "DDU: " << ddu << endl
71  << "ROS: " << ros << endl
72  << "Connected to chamber in Wh: " << wheel << " St: " << station << " Sec: " << sector << endl;
73 
74  int previousROB = -1;
75  int robCounter = -1;
76  // The chamber map in ORCA commissioning format
77  string fileName;
78  stringstream nameTmp;
79  nameTmp << "/afs/cern.ch/cms/Physics/muon/CMSSW/DT/channelsMaps/templates/MB" << station << "_" << sector << ".map";
80  nameTmp >> fileName;
81  ifstream chamberMap(fileName.c_str());
82 
83  string lineChamberMap;
84  while (getline(chamberMap, lineChamberMap)) {
85  if (lineChamberMap.empty() || lineChamberMap[0] == '#')
86  continue; // Skip comments and empty lines
87  stringstream chamberMapStr;
88  chamberMapStr << lineChamberMap;
89 
90  int rob, tdc, tdcChannel, sl, layer, wire;
91  int unusedRos, unusedChamberCode;
92  int outRob = -1;
93  chamberMapStr >> unusedRos >> rob >> tdc >> tdcChannel >> unusedChamberCode >> sl >> layer >> wire;
94 
95  // Check if the channel really exists
96  if (!checkWireExist(wireMap, wheel, station, sector, sl, layer, wire))
97  continue;
98 
99  if (rob > previousROB) {
100  previousROB = rob;
101  robCounter++;
102  } else if (rob < previousROB) {
103  cout << "Error: ROB number is not uniformly increasing!" << endl;
104  abort();
105  }
106  // Set the ROB id within the ros
107  if (rosType == 25) {
108  if (station == 1) { //MB1
109  outRob = robCounter;
110  } else if (station == 2) { //MB2
111  outRob = robCounter + 6;
112  } else if (station == 3) { //MB3
113  if (robCounter < 3)
114  outRob = robCounter + 12;
115  else if (robCounter == 3)
116  outRob = 24;
117  else if (robCounter > 3)
118  outRob = robCounter + 11;
119  } else if (station == 4) { //MB4
120  if (sector == 14) {
121  if (robCounter == 3) {
122  continue;
123  }
124  outRob = robCounter + 18;
125  } else if (sector == 10) {
126  if (robCounter == 3) {
127  continue;
128  } else if (robCounter == 0) {
129  outRob = 21;
130  } else {
131  outRob = robCounter + 21;
132  }
133  }
134  if (sector == 4) {
135  if (robCounter == 3 || robCounter == 4) {
136  continue;
137  }
138  outRob = robCounter + 18;
139  } else if (sector == 13) {
140  if (robCounter == 3 || robCounter == 4) {
141  continue;
142  } else if (robCounter == 0) {
143  outRob = 21;
144  } else {
145  outRob = robCounter + 21;
146  }
147  } else if (sector == 11 || sector == 9) {
148  outRob = robCounter + 18;
149  if (robCounter == 3) {
150  continue;
151  }
152  }
153  //else if(sector==12 || sector == 8 || sector == 7 || sector == 6 || sector == 5 || sector == 3 || sector == 2 ||sector == 1 ){
154  else {
155  outRob = robCounter + 18;
156  }
157  }
158  } else {
159  outRob = rob;
160  }
161  outputMap << ddu << " " << ros << " " << outRob << " " << tdc << " " << tdcChannel << " " << wheel << " "
162  << station << " " << sector << " " << sl << " " << layer << " " << wire << endl;
163  }
164  }
165 }
166 
168  const set<DTWireId>& wireMap, int wheel, int station, int sector, int sl, int layer, int wire) {
169  DTWireId wireId(wheel, station, sector, sl, layer, wire);
170  if (wireMap.find(wireId) == wireMap.end()) {
171  cout << "Skipping channel: Wh: " << wheel << ", st: " << station << ", sec: " << sector << ", sl: " << sl
172  << ", lay: " << layer << ", wire: " << wire << endl;
173  return false;
174  }
175 
176  return true;
177 }
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
DTMapGenerator::~DTMapGenerator
~DTMapGenerator() override
Destructor.
Definition: DTMapGenerator.cc:31
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTMapGenerator::DTMapGenerator
DTMapGenerator(const edm::ParameterSet &pset)
Constructor.
Definition: DTMapGenerator.cc:18
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
DTWireId
Definition: DTWireId.h:12
DTMapGenerator.h
edm::ParameterSet
Definition: ParameterSet.h:36
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
std
Definition: JetResolutionObject.h:76
ParameterSet.h
DTMapGenerator::checkWireExist
bool checkWireExist(const std::set< DTWireId > &wireMap, int wheel, int station, int sector, int sl, int layer, int wire)
Definition: DTMapGenerator.cc:167
DTMapGenerator::endJob
void endJob() override
Definition: DTMapGenerator.cc:33
mps_splice.line
line
Definition: mps_splice.py:76
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27