CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTMapGenerator Class Reference

#include <DTMapGenerator.h>

Inheritance diagram for DTMapGenerator:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
void beginJob () override
 
 DTMapGenerator (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob () override
 
 ~DTMapGenerator () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool checkWireExist (const std::set< DTWireId > &wireMap, int wheel, int station, int sector, int sl, int layer, int wire)
 

Private Attributes

std::string inputMapName
 
std::string outputMapName
 
int rosType
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Class which creates a textual map of the hardware channels in the software detIds

Author
G. Cerminara S. Bolognesi - INFN Torino

Definition at line 17 of file DTMapGenerator.h.

Constructor & Destructor Documentation

DTMapGenerator::DTMapGenerator ( const edm::ParameterSet pset)

Constructor.

Definition at line 18 of file DTMapGenerator.cc.

References gather_cfg::cout, and edm::ParameterSet::getUntrackedParameter().

18  {
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 }
std::string outputMapName
T getUntrackedParameter(std::string const &, T const &) const
std::string inputMapName
DTMapGenerator::~DTMapGenerator ( )
override

Destructor.

Definition at line 31 of file DTMapGenerator.cc.

31 {}

Member Function Documentation

void DTMapGenerator::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
inlineoverride
void DTMapGenerator::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 27 of file DTMapGenerator.h.

27 {}
bool DTMapGenerator::checkWireExist ( const std::set< DTWireId > &  wireMap,
int  wheel,
int  station,
int  sector,
int  sl,
int  layer,
int  wire 
)
private

Definition at line 167 of file DTMapGenerator.cc.

References gather_cfg::cout.

Referenced by analyze().

168  {
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 }
void DTMapGenerator::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file DTMapGenerator.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::fileName, mps_splice::line, relativeConstraints::station, and makeMuonMisalignmentScenario::wheel.

Referenced by analyze(), and o2olib.O2ORunMgr::executeJob().

33  {
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 }
std::string outputMapName
bool checkWireExist(const std::set< DTWireId > &wireMap, int wheel, int station, int sector, int sl, int layer, int wire)
std::string inputMapName

Member Data Documentation

std::string DTMapGenerator::inputMapName
private

Definition at line 43 of file DTMapGenerator.h.

std::string DTMapGenerator::outputMapName
private

Definition at line 41 of file DTMapGenerator.h.

int DTMapGenerator::rosType
private

Definition at line 45 of file DTMapGenerator.h.