CMS 3D CMS Logo

OMTFReconstruction.cc
Go to the documentation of this file.
1 #include <memory>
2 
8 
16 
18 
22  : m_Config(theConfig),
23  l1TMuonOverlapParamsToken_(
25  m_OMTFConfig(nullptr),
26  m_InputMaker(iC, false),
27  m_OMTF(nullptr),
28  aTopElement(nullptr),
29  m_OMTFConfigMaker(nullptr),
30  m_Writer(nullptr) {
31  dumpResultToXML = m_Config.getParameter<bool>("dumpResultToXML");
32  dumpDetailedResultToXML = m_Config.getParameter<bool>("dumpDetailedResultToXML");
33  //m_Config.getParameter<std::string>("XMLDumpFileName");
34  bxMin = m_Config.exists("bxMin") ? m_Config.getParameter<int>("bxMin") : 0;
35  bxMax = m_Config.exists("bxMax") ? m_Config.getParameter<int>("bxMax") : 0;
36 }
40  delete m_OMTFConfig;
41  delete m_OMTF;
42 
43  if (m_Writer)
44  delete m_Writer;
45 }
46 
51  m_OMTF = new OMTFProcessor();
52 }
56  if (dumpResultToXML) {
57  std::string fName = m_Config.getParameter<std::string>("XMLDumpFileName");
59  }
60 }
65 
66  if (!omtfParams) {
67  edm::LogError("L1TMuonOverlapTrackProducer") << "Could not retrieve parameters from Event Setup" << std::endl;
68  }
69 
72  //m_GhostBuster.setNphiBins(m_OMTFConfig->nPhiBins());
73 
74  if (m_OMTFConfig->fwVersion() >= 5) {
75  // if(m_Config.exists("ghostBusterType") ) {
76  // if(m_Config.getParameter<std::string>("ghostBusterType") == "GhostBusterPreferRefDt")
77  m_GhostBuster = std::make_unique<GhostBusterPreferRefDt>(m_OMTFConfig);
78  } else {
79  m_GhostBuster = std::make_unique<GhostBuster>();
80  }
81 
84 
86 
87  if (dumpResultToXML) {
89  std::string fName = "OMTF";
91  }
92 }
95 std::unique_ptr<l1t::RegionalMuonCandBxCollection> OMTFReconstruction::reconstruct(const edm::Event& iEvent,
96  const edm::EventSetup&) {
98 
99  if (dumpResultToXML)
100  aTopElement = m_Writer->writeEventHeader(iEvent.id().event());
101 
102  std::unique_ptr<l1t::RegionalMuonCandBxCollection> candidates(new l1t::RegionalMuonCandBxCollection);
103  candidates->setBXRange(bxMin, bxMax);
104 
106  for (int bx = bxMin; bx <= bxMax; bx++) {
107  for (unsigned int iProcessor = 0; iProcessor < m_OMTFConfig->nProcessors(); ++iProcessor)
109 
110  for (unsigned int iProcessor = 0; iProcessor < m_OMTFConfig->nProcessors(); ++iProcessor)
112 
113  edm::LogInfo("OMTFReconstruction") << "OMTF: Number of candidates in BX=" << bx << ": " << candidates->size(bx)
114  << std::endl;
115  ;
116  }
117 
118  return candidates;
119 }
120 
124  // Filter digis by dropping digis from selected (by cfg.py) subsystems
125  if (!m_Config.getParameter<bool>("dropDTPrimitives")) {
126  iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcDTPh"), dtPhDigis);
127  iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcDTTh"), dtThDigis);
128  }
129  if (!m_Config.getParameter<bool>("dropRPCPrimitives"))
130  iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcRPC"), rpcDigis);
131  if (!m_Config.getParameter<bool>("dropCSCPrimitives"))
132  iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcCSC"), cscDigis);
133 }
134 
137 void OMTFReconstruction::getProcessorCandidates(unsigned int iProcessor,
138  l1t::tftype mtfType,
139  int bx,
140  l1t::RegionalMuonCandBxCollection& omtfCandidates) {
143  dtPhDigis.product(), dtThDigis.product(), cscDigis.product(), rpcDigis.product(), iProcessor, mtfType, bx);
144  int flag = m_InputMaker.getFlag();
145 
146  const std::vector<OMTFProcessor::resultsMap>& results = m_OMTF->processInput(iProcessor, input);
147 
148  std::vector<AlgoMuon> algoCandidates;
149 
150  m_Sorter.sortRefHitResults(results, algoCandidates);
151 
152  // perform GB
153  std::vector<AlgoMuon> gbCandidates = m_GhostBuster->select(algoCandidates);
154 
155  // fill RegionalMuonCand colleciton
156  std::vector<l1t::RegionalMuonCand> candMuons = m_Sorter.candidates(iProcessor, mtfType, gbCandidates);
157 
158  //fill outgoing collection
159  for (auto& candMuon : candMuons) {
160  candMuon.setHwQual(candMuon.hwQual() | flag); //FIXME temporary debug fix
161  omtfCandidates.push_back(bx, candMuon);
162  }
163 
164  //dump to XML
165  if (bx == 0)
166  writeResultToXML(iProcessor, mtfType, input, results, candMuons);
167 }
170 void OMTFReconstruction::writeResultToXML(unsigned int iProcessor,
171  l1t::tftype mtfType,
172  const OMTFinput& input,
173  const std::vector<OMTFProcessor::resultsMap>& results,
174  const std::vector<l1t::RegionalMuonCand>& candMuons) {
175  int endcap = (mtfType == l1t::omtf_neg) ? -1 : ((mtfType == l1t::omtf_pos) ? +1 : 0);
176  OmtfName board(iProcessor, endcap);
177 
178  //Write data to XML file
179  if (dumpResultToXML) {
180  xercesc::DOMElement* aProcElement = m_Writer->writeEventData(aTopElement, board, input);
181  for (unsigned int iRefHit = 0; iRefHit < m_OMTFConfig->nTestRefHits(); ++iRefHit) {
183  AlgoMuon algoMuon = m_Sorter.sortRefHitResults(results[iRefHit], 0); //charge=0 means ignore charge
184  if (algoMuon.getPt()) {
185  m_Writer->writeAlgoMuon(aProcElement, iRefHit, algoMuon);
187  for (auto& itKey : results[iRefHit])
188  m_Writer->writeResultsData(aProcElement, iRefHit, itKey.first, itKey.second);
189  }
190  }
191  }
192  for (auto& candMuon : candMuons)
193  m_Writer->writeCandMuon(aProcElement, candMuon);
194  }
195 }
edm::ESGetToken< L1TMuonOverlapParams, L1TMuonOverlapParamsRcd > l1TMuonOverlapParamsToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void getProcessorCandidates(unsigned int iProcessor, l1t::tftype mtfType, int bx, l1t::RegionalMuonCandBxCollection &myCandidates)
OMTFConfiguration * m_OMTFConfig
OMTF objects.
OMTFinput buildInputForProcessor(const L1MuDTChambPhContainer *dtPhDigis, const L1MuDTChambThContainer *dtThDigis, const CSCCorrelatedLCTDigiCollection *cscDigis, const RPCDigiCollection *rpcDigis, unsigned int iProcessor, l1t::tftype type=l1t::tftype::omtf_pos, int bx=0)
Method translating trigger digis into input matrix with global phi coordinates.
void initialiseXMLDocument(const std::string &docName)
bool exists(std::string const &parameterName) const
checks if a parameter exists
T const * product() const
Definition: Handle.h:70
xercesc::DOMElement * aTopElement
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
void initialize(const edm::EventSetup &, const OMTFConfiguration *)
Log< level::Error, false > LogError
std::unique_ptr< IGhostBuster > m_GhostBuster
static std::string const input
Definition: EdmProvDump.cc:47
void loadAndFilterDigis(const edm::Event &)
int getFlag() const
void setNphiBins(unsigned int phiBins)
Definition: OMTFSorter.h:20
int iEvent
Definition: GenABIO.cc:224
unsigned int fwVersion() const
unsigned int nPhiBins() const
std::unique_ptr< l1t::RegionalMuonCandBxCollection > reconstruct(const edm::Event &, const edm::EventSetup &)
omtfParams
OMTF ESProducer.
OMTFProcessor * m_OMTF
void writeResultsData(xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const OMTFResult &aResult)
void beginRun(edm::Run const &, edm::EventSetup const &)
void writeResultToXML(unsigned int iProcessor, l1t::tftype mtfType, const OMTFinput &myInput, const std::vector< OMTFProcessor::resultsMap > &myResults, const std::vector< l1t::RegionalMuonCand > &candMuons)
const std::vector< OMTFProcessor::resultsMap > & processInput(unsigned int iProcessor, const OMTFinput &aInput)
Transition
Definition: Transition.h:12
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void writeCandMuon(xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
edm::Handle< RPCDigiCollection > rpcDigis
XMLConfigWriter * m_Writer
void setFlag(int aFlag)
OMTFReconstruction(const edm::ParameterSet &, edm::ConsumesCollector &&)
void configure(const L1TMuonOverlapParams *omtfParams)
unsigned int nTestRefHits() const
Log< level::Info, false > LogInfo
std::vector< l1t::RegionalMuonCand > candidates(unsigned int iProcessor, l1t::tftype mtfType, const std::vector< AlgoMuon > &algoCands)
Definition: OMTFSorter.cc:157
edm::Handle< L1MuDTChambThContainer > dtThDigis
OMTFinputMaker m_InputMaker
edm::Handle< L1MuDTChambPhContainer > dtPhDigis
bool configure(const OMTFConfiguration *omtfParams, const L1TMuonOverlapParams *omtfPatterns)
Fill GP map with patterns from CondFormats object.
HLT enums.
void finaliseXMLDocument(const std::string &fName)
void writeAlgoMuon(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aMuon)
int getPt() const
Definition: AlgoMuon.h:41
xercesc::DOMElement * writeEventHeader(unsigned int eventId, unsigned int mixedEventId=0)
unsigned int nProcessors() const
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:131
edm::ParameterSet m_Config
edm::Handle< CSCCorrelatedLCTDigiCollection > cscDigis
Definition: Run.h:45
void push_back(int bx, T object)
void initialize(const OMTFConfiguration *cfg)
Definition: OMTFSorter.h:19