CMS 3D CMS Logo

OMTFReconstruction.cc
Go to the documentation of this file.
2 
5 
8 
16 
18 
20  : m_OMTFConfig(nullptr), m_OMTF(nullptr), aTopElement(nullptr), m_OMTFConfigMaker(nullptr), m_Writer(nullptr) {}
24  : m_Config(theConfig),
26  m_OMTF(nullptr),
29  m_Writer(nullptr) {
30  dumpResultToXML = m_Config.getParameter<bool>("dumpResultToXML");
31  dumpDetailedResultToXML = m_Config.getParameter<bool>("dumpDetailedResultToXML");
32  //m_Config.getParameter<std::string>("XMLDumpFileName");
33  bxMin = m_Config.exists("bxMin") ? m_Config.getParameter<int>("bxMin") : 0;
34  bxMax = m_Config.exists("bxMax") ? m_Config.getParameter<int>("bxMax") : 0;
35 }
39  delete m_OMTFConfig;
40  delete m_OMTF;
41 
42  if (m_Writer)
43  delete m_Writer;
44 }
45 
50  m_OMTF = new OMTFProcessor();
51 }
55  if (dumpResultToXML) {
56  std::string fName = m_Config.getParameter<std::string>("XMLDumpFileName");
58  }
59 }
63  const L1TMuonOverlapParamsRcd& omtfRcd = iSetup.get<L1TMuonOverlapParamsRcd>();
64 
65  edm::ESHandle<L1TMuonOverlapParams> omtfParamsHandle;
66  omtfRcd.get(omtfParamsHandle);
67 
68  const L1TMuonOverlapParams* omtfParams = omtfParamsHandle.product();
69 
70  if (!omtfParams) {
71  edm::LogError("L1TMuonOverlapTrackProducer") << "Could not retrieve parameters from Event Setup" << std::endl;
72  }
73 
74  m_OMTFConfig->configure(omtfParams);
75  m_OMTF->configure(m_OMTFConfig, omtfParams);
76  //m_GhostBuster.setNphiBins(m_OMTFConfig->nPhiBins());
77 
78  if (m_OMTFConfig->fwVersion() >= 5) {
79  // if(m_Config.exists("ghostBusterType") ) {
80  // if(m_Config.getParameter<std::string>("ghostBusterType") == "GhostBusterPreferRefDt")
82  } else {
83  m_GhostBuster.reset(new GhostBuster());
84  }
85 
88 
90 
91  if (dumpResultToXML) {
93  std::string fName = "OMTF";
95  }
96 }
99 std::unique_ptr<l1t::RegionalMuonCandBxCollection> OMTFReconstruction::reconstruct(const edm::Event& iEvent,
100  const edm::EventSetup& evSetup) {
101  loadAndFilterDigis(iEvent);
102 
103  if (dumpResultToXML)
105 
106  std::unique_ptr<l1t::RegionalMuonCandBxCollection> candidates(new l1t::RegionalMuonCandBxCollection);
107  candidates->setBXRange(bxMin, bxMax);
108 
110  for (int bx = bxMin; bx <= bxMax; bx++) {
111  for (unsigned int iProcessor = 0; iProcessor < m_OMTFConfig->nProcessors(); ++iProcessor)
112  getProcessorCandidates(iProcessor, l1t::tftype::omtf_pos, bx, *candidates);
113 
114  for (unsigned int iProcessor = 0; iProcessor < m_OMTFConfig->nProcessors(); ++iProcessor)
115  getProcessorCandidates(iProcessor, l1t::tftype::omtf_neg, bx, *candidates);
116 
117  edm::LogInfo("OMTFReconstruction") << "OMTF: Number of candidates in BX=" << bx << ": " << candidates->size(bx)
118  << std::endl;
119  ;
120  }
121 
122  return candidates;
123 }
124 
128  // Filter digis by dropping digis from selected (by cfg.py) subsystems
129  if (!m_Config.getParameter<bool>("dropDTPrimitives")) {
132  }
133  if (!m_Config.getParameter<bool>("dropRPCPrimitives"))
135  if (!m_Config.getParameter<bool>("dropCSCPrimitives"))
137 }
138 
141 void OMTFReconstruction::getProcessorCandidates(unsigned int iProcessor,
142  l1t::tftype mtfType,
143  int bx,
144  l1t::RegionalMuonCandBxCollection& omtfCandidates) {
147  dtPhDigis.product(), dtThDigis.product(), cscDigis.product(), rpcDigis.product(), iProcessor, mtfType, bx);
148  int flag = m_InputMaker.getFlag();
149 
150  const std::vector<OMTFProcessor::resultsMap>& results = m_OMTF->processInput(iProcessor, input);
151 
152  std::vector<AlgoMuon> algoCandidates;
153 
154  m_Sorter.sortRefHitResults(results, algoCandidates);
155 
156  // perform GB
157  std::vector<AlgoMuon> gbCandidates = m_GhostBuster->select(algoCandidates);
158 
159  // fill RegionalMuonCand colleciton
160  std::vector<l1t::RegionalMuonCand> candMuons = m_Sorter.candidates(iProcessor, mtfType, gbCandidates);
161 
162  //fill outgoing collection
163  for (auto& candMuon : candMuons) {
164  candMuon.setHwQual(candMuon.hwQual() | flag); //FIXME temporary debug fix
165  omtfCandidates.push_back(bx, candMuon);
166  }
167 
168  //dump to XML
169  if (bx == 0)
170  writeResultToXML(iProcessor, mtfType, input, results, candMuons);
171 }
174 void OMTFReconstruction::writeResultToXML(unsigned int iProcessor,
175  l1t::tftype mtfType,
176  const OMTFinput& input,
177  const std::vector<OMTFProcessor::resultsMap>& results,
178  const std::vector<l1t::RegionalMuonCand>& candMuons) {
179  int endcap = (mtfType == l1t::omtf_neg) ? -1 : ((mtfType == l1t::omtf_pos) ? +1 : 0);
180  OmtfName board(iProcessor, endcap);
181 
182  //Write data to XML file
183  if (dumpResultToXML) {
184  xercesc::DOMElement* aProcElement = m_Writer->writeEventData(aTopElement, board, input);
185  for (unsigned int iRefHit = 0; iRefHit < m_OMTFConfig->nTestRefHits(); ++iRefHit) {
187  AlgoMuon algoMuon = m_Sorter.sortRefHitResults(results[iRefHit], 0); //charge=0 means ignore charge
188  if (algoMuon.getPt()) {
189  m_Writer->writeAlgoMuon(aProcElement, iRefHit, algoMuon);
191  for (auto& itKey : results[iRefHit])
192  m_Writer->writeResultsData(aProcElement, iRefHit, itKey.first, itKey.second);
193  }
194  }
195  }
196  for (auto& candMuon : candMuons)
197  m_Writer->writeCandMuon(aProcElement, candMuon);
198  }
199 }
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:40
void getProcessorCandidates(unsigned int iProcessor, l1t::tftype mtfType, int bx, l1t::RegionalMuonCandBxCollection &myCandidates)
bool configure(const OMTFConfiguration *omtfParams, const L1TMuonOverlapParams *omtfPatterns)
Fill GP map with patterns from CondFormats object.
OMTFConfiguration * m_OMTFConfig
OMTF objects.
OMTFConfigMaker * m_OMTFConfigMaker
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.
void initialiseXMLDocument(const std::string &docName)
void initialize(const edm::EventSetup &es, const OMTFConfiguration *)
#define nullptr
bool exists(std::string const &parameterName) const
checks if a parameter exists
xercesc::DOMElement * aTopElement
unsigned int nPhiBins() const
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
unsigned int nProcessors() const
std::unique_ptr< IGhostBuster > m_GhostBuster
void initialize(const OMTFConfiguration *cfg)
Definition: OMTFSorter.h:19
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
static std::string const input
Definition: EdmProvDump.cc:48
void loadAndFilterDigis(const edm::Event &)
void beginRun(edm::Run const &run, edm::EventSetup const &iSetup)
int iEvent
Definition: GenABIO.cc:224
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 writeResultToXML(unsigned int iProcessor, l1t::tftype mtfType, const OMTFinput &myInput, const std::vector< OMTFProcessor::resultsMap > &myResults, const std::vector< l1t::RegionalMuonCand > &candMuons)
int getFlag() const
void writeCandMuon(xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
edm::Handle< RPCDigiCollection > rpcDigis
XMLConfigWriter * m_Writer
void setFlag(int aFlag)
void configure(const L1TMuonOverlapParams *omtfParams)
T const * product() const
Definition: Handle.h:69
edm::Handle< L1MuDTChambThContainer > dtThDigis
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:131
OMTFinputMaker m_InputMaker
edm::Handle< L1MuDTChambPhContainer > dtPhDigis
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:73
const std::vector< OMTFProcessor::resultsMap > & processInput(unsigned int iProcessor, const OMTFinput &aInput)
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)
std::vector< l1t::RegionalMuonCand > candidates(unsigned int iProcessor, l1t::tftype mtfType, const std::vector< AlgoMuon > &algoCands)
Definition: OMTFSorter.cc:157
void setNphiBins(unsigned int phiBins)
Definition: OMTFSorter.h:20
edm::ParameterSet m_Config
unsigned int nTestRefHits() const
edm::Handle< CSCCorrelatedLCTDigiCollection > cscDigis
Definition: Run.h:45
void push_back(int bx, T object)