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){}
25 
26  dumpResultToXML = m_Config.getParameter<bool>("dumpResultToXML");
27  dumpDetailedResultToXML = m_Config.getParameter<bool>("dumpDetailedResultToXML");
28  //m_Config.getParameter<std::string>("XMLDumpFileName");
29  bxMin = m_Config.exists("bxMin") ? m_Config.getParameter<int>("bxMin") : 0;
30  bxMax = m_Config.exists("bxMax") ? m_Config.getParameter<int>("bxMax") : 0;
31 }
35 
36  delete m_OMTFConfig;
37  delete m_OMTF;
38 
39  if (m_Writer) delete m_Writer;
40 }
41 
45 
47  m_OMTF = new OMTFProcessor();
48 
49 }
53 
54  if(dumpResultToXML){
55  std::string fName = m_Config.getParameter<std::string>("XMLDumpFileName");
57  }
58 }
62 
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  }
83  else {
84  m_GhostBuster.reset(new GhostBuster() );
85  }
86 
89 
91 
92  if(dumpResultToXML){
94  std::string fName = "OMTF";
96  }
97 }
100 std::unique_ptr<l1t::RegionalMuonCandBxCollection> OMTFReconstruction::reconstruct(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
101 
102  loadAndFilterDigis(iEvent);
103 
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 
112  for(unsigned int iProcessor=0; iProcessor<m_OMTFConfig->nProcessors(); ++iProcessor)
113  getProcessorCandidates(iProcessor, l1t::tftype::omtf_pos, bx, *candidates);
114 
115  for(unsigned int iProcessor=0; iProcessor<m_OMTFConfig->nProcessors(); ++iProcessor)
116  getProcessorCandidates(iProcessor, l1t::tftype::omtf_neg, bx, *candidates);
117 
118  edm::LogInfo("OMTFReconstruction") <<"OMTF: Number of candidates in BX="<<bx<<": "<<candidates->size(bx) << std::endl;;
119  }
120 
121  return candidates;
122 }
123 
127 
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")) iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcRPC"),rpcDigis);
134  if(!m_Config.getParameter<bool>("dropCSCPrimitives")) iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcCSC"),cscDigis);
135 
136 }
137 
140 void OMTFReconstruction::getProcessorCandidates(unsigned int iProcessor, l1t::tftype mtfType, int bx,
141  l1t::RegionalMuonCandBxCollection & omtfCandidates){
142 
143 
146  dtThDigis.product(),
147  cscDigis.product(),
148  rpcDigis.product(),
149  iProcessor, mtfType, bx);
150  int flag = m_InputMaker.getFlag();
151 
152  const std::vector<OMTFProcessor::resultsMap> & results = m_OMTF->processInput(iProcessor,input);
153 
154  std::vector<AlgoMuon> algoCandidates;
155 
156  m_Sorter.sortRefHitResults(results, algoCandidates);
157 
158  // perform GB
159  std::vector<AlgoMuon> gbCandidates = m_GhostBuster->select(algoCandidates);
160 
161  // fill RegionalMuonCand colleciton
162  std::vector<l1t::RegionalMuonCand> candMuons = m_Sorter.candidates(iProcessor, mtfType, gbCandidates);
163 
164  //fill outgoing collection
165  for (auto & candMuon : candMuons) {
166  candMuon.setHwQual( candMuon.hwQual() | flag); //FIXME temporary debug fix
167  omtfCandidates.push_back(bx, candMuon);
168  }
169 
170  //dump to XML
171  if(bx==0)writeResultToXML(iProcessor, mtfType, input, results, candMuons);
172 }
175 void OMTFReconstruction::writeResultToXML(unsigned int iProcessor, l1t::tftype mtfType, const OMTFinput &input,
176  const std::vector<OMTFProcessor::resultsMap> & results,
177  const std::vector<l1t::RegionalMuonCand> & candMuons ){
178 
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) m_Writer->writeCandMuon(aProcElement, candMuon);
197  }
198 }
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
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:21
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 &)
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:480
edm::Handle< RPCDigiCollection > rpcDigis
XMLConfigWriter * m_Writer
void setFlag(int aFlag)
void configure(const L1TMuonOverlapParams *omtfParams)
T const * product() const
Definition: Handle.h:74
edm::Handle< L1MuDTChambThContainer > dtThDigis
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:134
OMTFinputMaker m_InputMaker
edm::Handle< L1MuDTChambPhContainer > dtPhDigis
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:71
const std::vector< OMTFProcessor::resultsMap > & processInput(unsigned int iProcessor, const OMTFinput &aInput)
int getPt() const
Definition: AlgoMuon.h:27
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:160
void setNphiBins(unsigned int phiBins)
Definition: OMTFSorter.h:22
edm::ParameterSet m_Config
unsigned int nTestRefHits() const
edm::Handle< CSCCorrelatedLCTDigiCollection > cscDigis
Definition: Run.h:45
void push_back(int bx, T object)