CMS 3D CMS Logo

OMTFReconstruction.cc
Go to the documentation of this file.
2 
5 
8 
16 
18 
20  m_OMTFConfig(0), m_OMTF(0), aTopElement(0), m_OMTFConfigMaker(0), m_Writer(0){}
24  m_Config(theConfig), m_OMTFConfig(0), m_OMTF(0), aTopElement(0), m_OMTFConfigMaker(0), m_Writer(0) {
25 
26  dumpResultToXML = m_Config.getParameter<bool>("dumpResultToXML");
27  dumpDetailedResultToXML = m_Config.getParameter<bool>("dumpDetailedResultToXML");
28  m_Config.getParameter<std::string>("XMLDumpFileName");
29 }
33 
34  delete m_OMTFConfig;
35  delete m_OMTF;
36 
37  if (m_Writer) delete m_Writer;
38 }
39 
43 
45  m_OMTF = new OMTFProcessor();
46 
47 }
51 
52  if(dumpResultToXML){
53  std::string fName = m_Config.getParameter<std::string>("XMLDumpFileName");
55  }
56 }
60 
61  const L1TMuonOverlapParamsRcd& omtfRcd = iSetup.get<L1TMuonOverlapParamsRcd>();
62 
63  edm::ESHandle<L1TMuonOverlapParams> omtfParamsHandle;
64  omtfRcd.get(omtfParamsHandle);
65 
66  const L1TMuonOverlapParams* omtfParams = omtfParamsHandle.product();
67 
68  if (!omtfParams) {
69  edm::LogError("L1TMuonOverlapTrackProducer") << "Could not retrieve parameters from Event Setup" << std::endl;
70  }
71 
72  m_OMTFConfig->configure(omtfParams);
73  m_OMTF->configure(m_OMTFConfig, omtfParams);
76 
78 
79  if(dumpResultToXML){
81  std::string fName = "OMTF";
83  }
84 }
87 std::unique_ptr<l1t::RegionalMuonCandBxCollection> OMTFReconstruction::reconstruct(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
88 
89  loadAndFilterDigis(iEvent);
90 
92 
93  // NOTE: assuming all is for bx 0
94  int bx = 0;
95  std::unique_ptr<l1t::RegionalMuonCandBxCollection> candidates(new l1t::RegionalMuonCandBxCollection);
96 
98  for(unsigned int iProcessor=0; iProcessor<m_OMTFConfig->nProcessors(); ++iProcessor)
99  getProcessorCandidates(iProcessor, l1t::tftype::omtf_pos, bx, *candidates);
100 
101  for(unsigned int iProcessor=0; iProcessor<m_OMTFConfig->nProcessors(); ++iProcessor)
102  getProcessorCandidates(iProcessor, l1t::tftype::omtf_neg, bx, *candidates);
103 
104  return candidates;
105 }
106 
110 
111  // Filter digis by dropping digis from selected (by cfg.py) subsystems
112  if(!m_Config.getParameter<bool>("dropDTPrimitives")){
115  }
116  if(!m_Config.getParameter<bool>("dropRPCPrimitives")) iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcRPC"),rpcDigis);
117  if(!m_Config.getParameter<bool>("dropCSCPrimitives")) iEvent.getByLabel(m_Config.getParameter<edm::InputTag>("srcCSC"),cscDigis);
118 
119 }
120 
123 void OMTFReconstruction::getProcessorCandidates(unsigned int iProcessor, l1t::tftype mtfType, int bx,
124  l1t::RegionalMuonCandBxCollection & omtfCandidates){
125 
126 
129  dtThDigis.product(),
130  cscDigis.product(),
131  rpcDigis.product(),
132  iProcessor, mtfType);
133  int flag = m_InputMaker.getFlag();
134 
135  const std::vector<OMTFProcessor::resultsMap> & results = m_OMTF->processInput(iProcessor,input);
136 
137  std::vector<AlgoMuon> algoCandidates;
138 
139  m_Sorter.sortRefHitResults(results, algoCandidates);
140 
141  // perform GB
142  m_GhostBuster.select(algoCandidates);
143 
144  // fill RegionalMuonCand colleciton
145  std::vector<l1t::RegionalMuonCand> candMuons = m_Sorter.candidates(iProcessor, mtfType, algoCandidates);
146 
147  //fill outgoing collection
148  for (auto & candMuon : candMuons) {
149  candMuon.setHwQual( candMuon.hwQual() | flag); //FIXME temporary debug fix
150  omtfCandidates.push_back(bx, candMuon);
151  }
152 
153  //dump to XML
154  writeResultToXML(iProcessor, mtfType, input, results, candMuons);
155 }
158 void OMTFReconstruction::writeResultToXML(unsigned int iProcessor, l1t::tftype mtfType, const OMTFinput &input,
159  const std::vector<OMTFProcessor::resultsMap> & results,
160  const std::vector<l1t::RegionalMuonCand> & candMuons ){
161 
162  int endcap = (mtfType == l1t::omtf_neg) ? -1 : ( ( mtfType == l1t::omtf_pos) ? +1 : 0 );
163  OmtfName board(iProcessor, endcap);
164 
165  //Write data to XML file
166  if(dumpResultToXML){
167  xercesc::DOMElement * aProcElement = m_Writer->writeEventData(aTopElement, board, input);
168  for(unsigned int iRefHit=0;iRefHit<m_OMTFConfig->nTestRefHits();++iRefHit){
170  AlgoMuon algoMuon = m_Sorter.sortRefHitResults(results[iRefHit],0);//charge=0 means ignore charge
171  if(algoMuon.getPt()) {
172  m_Writer->writeAlgoMuon(aProcElement,iRefHit,algoMuon);
174  for(auto & itKey: results[iRefHit])
175  m_Writer->writeResultsData(aProcElement, iRefHit, itKey.first,itKey.second);
176  }
177  }
178  }
179  for (auto & candMuon : candMuons) m_Writer->writeCandMuon(aProcElement, candMuon);
180  }
181 }
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
void initialiseXMLDocument(const std::string &docName)
void initialize(const edm::EventSetup &es, const OMTFConfiguration *)
xercesc::DOMElement * aTopElement
unsigned int nPhiBins() const
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
unsigned int nProcessors() const
static std::string const input
Definition: EdmProvDump.cc:44
void loadAndFilterDigis(const edm::Event &)
void setNphiBins(unsigned int phiBins)
Definition: GhostBuster.h:20
void beginRun(edm::Run const &run, edm::EventSetup const &iSetup)
int iEvent
Definition: GenABIO.cc:230
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)
OMTFGhostBuster m_GhostBuster
void writeResultToXML(unsigned int iProcessor, l1t::tftype mtfType, const OMTFinput &myInput, const std::vector< OMTFProcessor::resultsMap > &myResults, const std::vector< l1t::RegionalMuonCand > &candMuons)
void get(HolderT &iHolder) const
int getFlag() const
void writeCandMuon(xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
edm::Handle< RPCDigiCollection > rpcDigis
XMLConfigWriter * m_Writer
void setFlag(int aFlag)
void configure(const L1TMuonOverlapParams *omtfParams)
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
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:58
const std::vector< OMTFProcessor::resultsMap > & processInput(unsigned int iProcessor, const OMTFinput &aInput)
int getPt() const
Definition: AlgoMuon.h:25
void finaliseXMLDocument(const std::string &fName)
void writeAlgoMuon(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aMuon)
OMTFinput buildInputForProcessor(const L1MuDTChambPhContainer *dtPhDigis, const L1MuDTChambThContainer *dtThDigis, const CSCCorrelatedLCTDigiCollection *cscDigis, const RPCDigiCollection *rpcDigis, unsigned int iProcessor, l1t::tftype type=l1t::tftype::omtf_pos)
Method translating trigger digis into input matrix with global phi coordinates.
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:19
edm::ParameterSet m_Config
void select(std::vector< AlgoMuon > &refHitCands, int charge=0)
Definition: GhostBuster.cc:12
unsigned int nTestRefHits() const
edm::Handle< CSCCorrelatedLCTDigiCollection > cscDigis
Definition: Run.h:42
void push_back(int bx, T object)