CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
70  m_OMTFConfig->configure(omtfParams);
71  m_OMTF->configure(m_OMTFConfig, omtfParams);
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&) {
97  loadAndFilterDigis(iEvent);
98 
99  if (dumpResultToXML)
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)
108  getProcessorCandidates(iProcessor, l1t::tftype::omtf_pos, bx, *candidates);
109 
110  for (unsigned int iProcessor = 0; iProcessor < m_OMTFConfig->nProcessors(); ++iProcessor)
111  getProcessorCandidates(iProcessor, l1t::tftype::omtf_neg, bx, *candidates);
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")) {
128  }
129  if (!m_Config.getParameter<bool>("dropRPCPrimitives"))
131  if (!m_Config.getParameter<bool>("dropCSCPrimitives"))
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_
EventNumber_t event() const
Definition: EventID.h:40
void getProcessorCandidates(unsigned int iProcessor, l1t::tftype mtfType, int bx, l1t::RegionalMuonCandBxCollection &myCandidates)
OMTFConfiguration * m_OMTFConfig
OMTF objects.
unsigned int fwVersion() const
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.
tuple omtfParams
OMTF ESProducer.
void initialiseXMLDocument(const std::string &docName)
dictionary results
xercesc::DOMElement * aTopElement
bool exists(std::string const &parameterName) const
checks if a parameter exists
unsigned int nPhiBins() const
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
unsigned int nProcessors() const
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 &)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void setNphiBins(unsigned int phiBins)
Definition: OMTFSorter.h:20
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< l1t::RegionalMuonCandBxCollection > reconstruct(const edm::Event &, const edm::EventSetup &)
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
int getFlag() const
void writeCandMuon(xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
edm::Handle< RPCDigiCollection > rpcDigis
XMLConfigWriter * m_Writer
void setFlag(int aFlag)
OMTFReconstruction(const edm::ParameterSet &, edm::ConsumesCollector &&)
void configure(const L1TMuonOverlapParams *omtfParams)
Log< level::Info, false > LogInfo
T const * product() const
Definition: Handle.h:70
std::vector< l1t::RegionalMuonCand > candidates(unsigned int iProcessor, l1t::tftype mtfType, const std::vector< AlgoMuon > &algoCands)
Definition: OMTFSorter.cc:157
edm::Handle< L1MuDTChambThContainer > dtThDigis
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
OMTFinputMaker m_InputMaker
edm::Handle< L1MuDTChambPhContainer > dtPhDigis
bool configure(const OMTFConfiguration *omtfParams, const L1TMuonOverlapParams *omtfPatterns)
Fill GP map with patterns from CondFormats object.
edm::EventID id() const
Definition: EventBase.h:59
int getPt() const
Definition: AlgoMuon.h:41
void finaliseXMLDocument(const std::string &fName)
void writeAlgoMuon(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aMuon)
xercesc::DOMElement * writeEventHeader(unsigned int eventId, unsigned int mixedEventId=0)
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:131
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ParameterSet m_Config
unsigned int nTestRefHits() const
edm::Handle< CSCCorrelatedLCTDigiCollection > cscDigis
Definition: Run.h:45
void push_back(int bx, T object)
void initialize(const OMTFConfiguration *cfg)
Definition: OMTFSorter.h:19