1 |
konec |
1.1 |
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroSelectorL1Muon.h"
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
5 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
6 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
7 |
|
|
#include "FWCore/Utilities/interface/InputTag.h"
|
8 |
|
|
|
9 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
|
10 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
|
11 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
|
12 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
|
13 |
|
|
|
14 |
|
|
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
|
15 |
|
|
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
|
16 |
|
|
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
|
17 |
|
|
|
18 |
|
|
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
|
19 |
|
|
#include "DataFormats/Math/interface/deltaPhi.h"
|
20 |
|
|
|
21 |
|
|
#include "TObjArray.h"
|
22 |
|
|
#include "TH1F.h"
|
23 |
|
|
#include <cmath>
|
24 |
|
|
using namespace edm;
|
25 |
|
|
using namespace std;
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
SynchroSelectorL1Muon::SynchroSelectorL1Muon(const edm::ParameterSet& cfg, TObjArray& histos)
|
29 |
|
|
: SynchroSelector(cfg)
|
30 |
|
|
{
|
31 |
|
|
hDeltaEta = new TH1F("hDeltaEta","hDeltaEta",100.,-1.,1.); histos.Add(hDeltaEta);
|
32 |
|
|
hDeltaPhi = new TH1F("hDeltaPhi","hDeltaPhi",100.,-1.,1.); histos.Add(hDeltaPhi);
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
void SynchroSelectorL1Muon::update(const edm::Event&ev, const edm::EventSetup& es)
|
36 |
|
|
{
|
37 |
|
|
theL1Muons.clear();
|
38 |
|
|
edm::Handle<L1MuGMTReadoutCollection> pCollection;
|
39 |
|
|
ev.getByLabel(theConfig.getParameter<edm::InputTag>("l1MuReadout"),pCollection);
|
40 |
|
|
|
41 |
|
|
L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
|
42 |
|
|
if (!gmtrc) return;
|
43 |
|
|
|
44 |
|
|
vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
|
45 |
|
|
|
46 |
|
|
vector<string> systems = theConfig.getParameter<vector<string> >("systems");
|
47 |
|
|
|
48 |
|
|
for (vector<string>::const_iterator ic = systems.begin(); ic != systems.end(); ++ic) {
|
49 |
|
|
for( vector<L1MuGMTReadoutRecord>::const_iterator it = gmt_records.begin() ; it != gmt_records.end() ; it++ ) {
|
50 |
|
|
vector<L1MuRegionalCand> cands;
|
51 |
|
|
if ( (*ic) == "rpcb" ) cands = it->getBrlRPCCands();
|
52 |
|
|
else if ( (*ic) == "rpcf" ) cands = it->getFwdRPCCands();
|
53 |
|
|
else if ( (*ic) == "csc" ) cands = it->getCSCCands();
|
54 |
|
|
else if ( (*ic) == "dt" ) cands = it->getDTBXCands();
|
55 |
|
|
for (vector<L1MuRegionalCand>::const_iterator il=cands.begin(); il < cands.end(); ++il) {
|
56 |
|
|
if (!il->empty() && ( (il->bx() == 0) || !theConfig.getParameter<bool>("checkBX0") ) )theL1Muons.push_back(*il);
|
57 |
|
|
}
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
bool SynchroSelectorL1Muon::takeIt(const RPCDetId & det, const edm::Event&ev, const edm::EventSetup& es)
|
64 |
|
|
{
|
65 |
|
|
bool result = false;
|
66 |
|
|
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
|
67 |
|
|
es.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
GlobalPoint detPos = globalGeometry->idToDet(det)->position();
|
71 |
|
|
float detEta = detPos.eta();
|
72 |
|
|
float detPhi = detPos.phi();
|
73 |
|
|
for(vector<L1MuRegionalCand>::const_iterator it =theL1Muons.begin(); it != theL1Muons.end(); ++it) {
|
74 |
|
|
if (it->empty()) continue;
|
75 |
|
|
float l1Eta = it->etaValue();
|
76 |
|
|
float l1Phi = it->phiValue();
|
77 |
|
|
bool matchedDeltaPhi = fabs(deltaPhi(l1Phi,detPhi)) < theConfig.getParameter<double>("maxDeltaPhi");
|
78 |
|
|
bool matchedDeltaEta = fabs(l1Eta-detEta) < theConfig.getParameter<double>("maxDeltaEta");
|
79 |
|
|
if (matchedDeltaPhi) hDeltaEta->Fill(l1Eta-detEta);
|
80 |
|
|
if (matchedDeltaEta) hDeltaPhi->Fill(deltaPhi(l1Phi,detPhi));
|
81 |
|
|
if ( !matchedDeltaPhi ) continue;
|
82 |
|
|
if ( !matchedDeltaEta ) continue;
|
83 |
|
|
|
84 |
|
|
// std::cout <<" compatible det, (eta,phi,r,z)= ("<<detEta<<", "<<detPhi<<", "<<detPos.perp()<<", "<<detPos.z()
|
85 |
|
|
// <<") L1 (eta,phi): ("<< l1Eta<<", "<<l1Phi<<")"<<std::endl;
|
86 |
|
|
|
87 |
|
|
result = true;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
return result;
|
91 |
|
|
}
|
92 |
|
|
|