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::one::EDAnalyzer<> edm::one::EDAnalyzerBase 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=default
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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::DTMapGenerator ( const edm::ParameterSet pset)

Constructor.

Definition at line 18 of file DTMapGenerator.cc.

References gather_cfg::cout, and muonDTDigis_cfi::pset.

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
std::string inputMapName

◆ ~DTMapGenerator()

DTMapGenerator::~DTMapGenerator ( )
overridedefault

Destructor.

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 29 of file DTMapGenerator.h.

29 {}

◆ beginJob()

void DTMapGenerator::beginJob ( )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 27 of file DTMapGenerator.h.

27 {}

◆ checkWireExist()

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

Definition at line 164 of file DTMapGenerator.cc.

References gather_cfg::cout, relativeConstraints::station, and makeMuonMisalignmentScenario::wheel.

165  {
166  DTWireId wireId(wheel, station, sector, sl, layer, wire);
167  if (wireMap.find(wireId) == wireMap.end()) {
168  cout << "Skipping channel: Wh: " << wheel << ", st: " << station << ", sec: " << sector << ", sl: " << sl
169  << ", lay: " << layer << ", wire: " << wire << endl;
170  return false;
171  }
172 
173  return true;
174 }
constexpr std::array< uint8_t, layerIndexSize > layer

◆ endJob()

void DTMapGenerator::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 31 of file DTMapGenerator.cc.

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

Referenced by o2olib.O2ORunMgr::executeJob().

31  {
32  cout << "DTMapGenerator: Output Map: " << outputMapName << " ROS Type: " << rosType << endl;
33 
34  // Read the existing wires
35  ifstream existingChannels("/afs/cern.ch/cms/Physics/muon/CMSSW/DT/channelsMaps/existing_channels.txt");
36 
37  set<DTWireId> wireMap; //FIXME:MAYBE YOU NEED THE > and == operators to use set?
38 
39  // Read the map between DDU - ROS and Chambers
40  string lineMap;
41  while (getline(existingChannels, lineMap)) {
42  if (lineMap.empty() || lineMap[0] == '#')
43  continue; // Skip comments and empty lines
44  stringstream linestr;
45  linestr << lineMap;
46  int wheelEx, stationEx, sectorEx, slEx, layerEx, wireEx;
47  linestr >> wheelEx >> sectorEx >> stationEx >> slEx >> layerEx >> wireEx;
48  DTWireId wireIdEx(wheelEx, stationEx, sectorEx, slEx, layerEx, wireEx);
49  wireMap.insert(wireIdEx);
50  }
51  cout << "Map size: " << wireMap.size() << endl;
52 
53  // The map between DDU - ROS and Chambers
54  ifstream skeletonMap(inputMapName.c_str());
55 
56  // The output map in the CMSSW format
57  ofstream outputMap(outputMapName.c_str());
58 
59  // Read the map between DDU - ROS and Chambers
60  string line;
61  while (getline(skeletonMap, line)) {
62  if (line.empty() || line[0] == '#')
63  continue; // Skip comments and empty lines
64  stringstream linestr;
65  linestr << line;
66  int ddu, ros, wheel, station, sector;
67  linestr >> ddu >> ros >> wheel >> station >> sector;
68  cout << "DDU: " << ddu << endl
69  << "ROS: " << ros << endl
70  << "Connected to chamber in Wh: " << wheel << " St: " << station << " Sec: " << sector << endl;
71 
72  int previousROB = -1;
73  int robCounter = -1;
74  // The chamber map in ORCA commissioning format
75  string fileName;
76  stringstream nameTmp;
77  nameTmp << "/afs/cern.ch/cms/Physics/muon/CMSSW/DT/channelsMaps/templates/MB" << station << "_" << sector << ".map";
78  nameTmp >> fileName;
79  ifstream chamberMap(fileName.c_str());
80 
81  string lineChamberMap;
82  while (getline(chamberMap, lineChamberMap)) {
83  if (lineChamberMap.empty() || lineChamberMap[0] == '#')
84  continue; // Skip comments and empty lines
85  stringstream chamberMapStr;
86  chamberMapStr << lineChamberMap;
87 
88  int rob, tdc, tdcChannel, sl, layer, wire;
89  int unusedRos, unusedChamberCode;
90  int outRob = -1;
91  chamberMapStr >> unusedRos >> rob >> tdc >> tdcChannel >> unusedChamberCode >> sl >> layer >> wire;
92 
93  // Check if the channel really exists
94  if (!checkWireExist(wireMap, wheel, station, sector, sl, layer, wire))
95  continue;
96 
97  if (rob > previousROB) {
98  previousROB = rob;
99  robCounter++;
100  } else if (rob < previousROB) {
101  cout << "Error: ROB number is not uniformly increasing!" << endl;
102  abort();
103  }
104  // Set the ROB id within the ros
105  if (rosType == 25) {
106  if (station == 1) { //MB1
107  outRob = robCounter;
108  } else if (station == 2) { //MB2
109  outRob = robCounter + 6;
110  } else if (station == 3) { //MB3
111  if (robCounter < 3)
112  outRob = robCounter + 12;
113  else if (robCounter == 3)
114  outRob = 24;
115  else if (robCounter > 3)
116  outRob = robCounter + 11;
117  } else if (station == 4) { //MB4
118  if (sector == 14) {
119  if (robCounter == 3) {
120  continue;
121  }
122  outRob = robCounter + 18;
123  } else if (sector == 10) {
124  if (robCounter == 3) {
125  continue;
126  } else if (robCounter == 0) {
127  outRob = 21;
128  } else {
129  outRob = robCounter + 21;
130  }
131  } else if (sector == 4) {
132  if (robCounter == 3 || robCounter == 4) {
133  continue;
134  }
135  outRob = robCounter + 18;
136  } else if (sector == 13) {
137  if (robCounter == 3 || robCounter == 4) {
138  continue;
139  } else if (robCounter == 0) {
140  outRob = 21;
141  } else {
142  outRob = robCounter + 21;
143  }
144  } else if (sector == 11 || sector == 9) {
145  outRob = robCounter + 18;
146  if (robCounter == 3) {
147  continue;
148  }
149  }
150  //else if(sector==12 || sector == 8 || sector == 7 || sector == 6 || sector == 5 || sector == 3 || sector == 2 ||sector == 1 ){
151  else {
152  outRob = robCounter + 18;
153  }
154  }
155  } else {
156  outRob = rob;
157  }
158  outputMap << ddu << " " << ros << " " << outRob << " " << tdc << " " << tdcChannel << " " << wheel << " "
159  << station << " " << sector << " " << sl << " " << layer << " " << wire << endl;
160  }
161  }
162 }
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
constexpr std::array< uint8_t, layerIndexSize > layer

Member Data Documentation

◆ inputMapName

std::string DTMapGenerator::inputMapName
private

Definition at line 43 of file DTMapGenerator.h.

◆ outputMapName

std::string DTMapGenerator::outputMapName
private

Definition at line 41 of file DTMapGenerator.h.

◆ rosType

int DTMapGenerator::rosType
private

Definition at line 45 of file DTMapGenerator.h.