1 |
konec |
1.1 |
#include "L1RpcTreeMaker.h"
|
2 |
|
|
#include <vector>
|
3 |
|
|
|
4 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
5 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
6 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
7 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
8 |
|
|
|
9 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
10 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
11 |
|
|
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
12 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
13 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/BestMuonFinder.h"
|
17 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/DetHitCompatibleCollector.h"
|
18 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjMaker.h"
|
19 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/TrackToL1ObjMatcher.h"
|
20 |
|
|
#include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
|
21 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
|
22 |
konec |
1.4 |
#include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
|
23 |
konec |
1.1 |
|
24 |
|
|
#include "TFile.h"
|
25 |
|
|
#include "TTree.h"
|
26 |
|
|
|
27 |
|
|
template <class T> T sqr( T t) {return t*t;}
|
28 |
|
|
|
29 |
|
|
L1RpcTreeMaker::L1RpcTreeMaker(const edm::ParameterSet& cfg)
|
30 |
konec |
1.4 |
: theConfig(cfg), theTree(0), event(0), muon(0), track(0),
|
31 |
|
|
bitsL1(0), bitsHLT(0),
|
32 |
|
|
counts(0),
|
33 |
konec |
1.10 |
l1ObjColl(0),
|
34 |
konec |
1.1 |
theCounter(0),
|
35 |
|
|
theBestMuonFinder(cfg.getParameter<edm::ParameterSet>("bestMuonFinder")),
|
36 |
|
|
theDetHitCollector(cfg.getParameter<edm::ParameterSet>("detHitCollector")),
|
37 |
konec |
1.5 |
theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber")),
|
38 |
konec |
1.10 |
theL1ObjMaker(cfg.getParameter<edm::ParameterSet>("l1ObjMaker")),
|
39 |
konec |
1.5 |
theMenuInspector(edm::ParameterSet())
|
40 |
konec |
1.1 |
{ }
|
41 |
|
|
|
42 |
konec |
1.5 |
void L1RpcTreeMaker::beginRun(const edm::Run &ru, const edm::EventSetup &es)
|
43 |
konec |
1.1 |
{
|
44 |
konec |
1.5 |
std::cout <<" L1RpcTreeMaker::beginRun CALLED" << std::endl;
|
45 |
|
|
theMenuInspector.checkRun(ru,es);
|
46 |
konec |
1.1 |
}
|
47 |
|
|
|
48 |
|
|
void L1RpcTreeMaker::beginJob()
|
49 |
|
|
{
|
50 |
|
|
theFile = new TFile(theConfig.getParameter<std::string>("treeFileName").c_str(),"RECREATE");
|
51 |
|
|
theTree = new TTree("tL1Rpc","L1RpcEfficciency");
|
52 |
|
|
|
53 |
|
|
theTree->Branch("event","EventObj",&event,32000,99);
|
54 |
|
|
theTree->Branch("muon","MuonObj",&muon,32000,99);
|
55 |
|
|
theTree->Branch("track", "TrackObj",&track,32000,99);
|
56 |
|
|
|
57 |
konec |
1.4 |
theTree->Branch("bitsL1" ,"TriggerMenuResultObj",&bitsL1 ,32000,99);
|
58 |
|
|
theTree->Branch("bitsHLT","TriggerMenuResultObj",&bitsHLT,32000,99);
|
59 |
|
|
|
60 |
konec |
1.1 |
theTree->Branch("counts",&counts);
|
61 |
|
|
theTree->Branch("detsCrossedByMuon",&detsCrossedByMuon);
|
62 |
|
|
theTree->Branch("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside);
|
63 |
|
|
theTree->Branch("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon);
|
64 |
|
|
theTree->Branch("detsSIMU",&detsSIMU);
|
65 |
|
|
|
66 |
konec |
1.10 |
theTree->Branch("l1ObjColl","L1ObjColl",&l1ObjColl,32000,99);
|
67 |
konec |
1.1 |
|
68 |
|
|
theHelper.SetOwner();
|
69 |
|
|
theBestMuonFinder.initHistos(theHelper);
|
70 |
|
|
theDetHitCollector.initHistos(theHelper);
|
71 |
|
|
theSynchroGrabber.initHistos(theHelper);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
void L1RpcTreeMaker::endJob()
|
75 |
|
|
{
|
76 |
|
|
theFile->Write();
|
77 |
|
|
delete theFile;
|
78 |
|
|
|
79 |
|
|
std::string helperFile = theConfig.getParameter<std::string>("histoFileName");
|
80 |
|
|
TFile f(helperFile.c_str(),"RECREATE");
|
81 |
|
|
theHelper.Write();
|
82 |
|
|
f.Close();
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
L1RpcTreeMaker::~L1RpcTreeMaker()
|
86 |
|
|
{
|
87 |
|
|
std::cout <<"L1RpcTreeMaker: Event counter is: "<<theCounter<<std::endl;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
void L1RpcTreeMaker::analyze(const edm::Event &ev, const edm::EventSetup &es)
|
91 |
|
|
{
|
92 |
|
|
//
|
93 |
|
|
// check reference muon
|
94 |
|
|
//
|
95 |
|
|
const reco::Muon * theMuon = theBestMuonFinder.result(ev,es);
|
96 |
|
|
if (!theMuon || !theBestMuonFinder.isUnique(ev,es) ) return;
|
97 |
|
|
theCounter++;
|
98 |
|
|
|
99 |
|
|
//
|
100 |
|
|
// fill event information
|
101 |
|
|
//
|
102 |
|
|
event = new EventObj;
|
103 |
|
|
event->bx = ev.bunchCrossing();
|
104 |
|
|
event->orbit = ev.orbitNumber();
|
105 |
|
|
event->time = ev.time().value();
|
106 |
|
|
event->id = ev.id().event();
|
107 |
|
|
event->run = ev.run();
|
108 |
|
|
event->lumi = ev.luminosityBlock();
|
109 |
|
|
|
110 |
|
|
//
|
111 |
|
|
// create other objects structure
|
112 |
|
|
//
|
113 |
|
|
muon = new MuonObj();
|
114 |
|
|
track = new TrackObj();
|
115 |
konec |
1.4 |
|
116 |
|
|
bitsL1 = new TriggerMenuResultObj();
|
117 |
|
|
bitsHLT = new TriggerMenuResultObj();
|
118 |
|
|
|
119 |
konec |
1.1 |
counts = std::vector<SynchroCountsObj>();
|
120 |
|
|
detsCrossedByMuon = std::vector<uint32_t>();
|
121 |
|
|
detsCrossedByMuonDeepInside = std::vector<uint32_t>();
|
122 |
konec |
1.6 |
detsHitsCompatibleWithMuon = std::vector<DetCluDigiObj>();
|
123 |
konec |
1.1 |
detsSIMU = std::vector<uint32_t>();
|
124 |
konec |
1.6 |
|
125 |
konec |
1.10 |
l1ObjColl = new L1ObjColl;
|
126 |
konec |
1.1 |
|
127 |
|
|
//
|
128 |
|
|
// fill muon info
|
129 |
|
|
//
|
130 |
|
|
muon->setKine(theMuon->track()->pt(), theMuon->track()->eta(), theMuon->track()->phi(), theMuon->track()->charge());
|
131 |
|
|
muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid());
|
132 |
|
|
muon->nMatchedStations = theMuon->numberOfMatchedStations();
|
133 |
|
|
if (theMuon->isGlobalMuon()) {
|
134 |
|
|
const reco::HitPattern& hp = (theMuon->combinedMuon())->hitPattern();
|
135 |
|
|
muon->nRPCHits = hp.numberOfValidMuonRPCHits();
|
136 |
|
|
muon->nDTHits = hp.numberOfValidMuonDTHits();
|
137 |
|
|
muon->nCSCHits = hp.numberOfValidMuonCSCHits();
|
138 |
|
|
} else muon->nRPCHits = muon->nDTHits = muon->nCSCHits = 0;
|
139 |
|
|
muon->nTrackerHits = theMuon->isTrackerMuon() ? (theMuon->innerTrack())->hitPattern().numberOfValidTrackerHits() : 0;
|
140 |
|
|
|
141 |
konec |
1.5 |
//
|
142 |
|
|
// fill algoBits info
|
143 |
|
|
//
|
144 |
|
|
static edm::RunNumber_t lastRun = 0;
|
145 |
|
|
if (ev.run() != lastRun) {
|
146 |
|
|
lastRun = ev.run();
|
147 |
|
|
bitsL1->names = theMenuInspector.namesAlgoL1();
|
148 |
|
|
bitsHLT->names = theMenuInspector.namesAlgoHLT();
|
149 |
|
|
}
|
150 |
|
|
bitsL1->firedAlgos = theMenuInspector.firedAlgosL1(ev,es);
|
151 |
|
|
bitsHLT->firedAlgos = theMenuInspector.firedAlgosHLT(ev,es);
|
152 |
|
|
|
153 |
konec |
1.1 |
|
154 |
|
|
//
|
155 |
|
|
// hits and detectors compatible with muon track
|
156 |
|
|
//
|
157 |
|
|
if ( muon->pt() > 10.) {
|
158 |
konec |
1.6 |
detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es);
|
159 |
konec |
1.1 |
detsCrossedByMuon = theDetHitCollector.compatibleDets( theMuon, ev, es, false);
|
160 |
|
|
detsCrossedByMuonDeepInside = theDetHitCollector.compatibleDets( theMuon, ev, es, true);
|
161 |
|
|
if (theConfig.getParameter<bool>("checkDestSIMU")) detsSIMU = theDetHitCollector.compatibleSIMU( theMuon, ev, es);
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
//
|
166 |
|
|
// fill LinkSynchroAnalysis data
|
167 |
|
|
//
|
168 |
|
|
theSynchroGrabber.setMuon(theMuon);
|
169 |
|
|
RPCRawSynchro::ProdItem rawCounts = theSynchroGrabber.counts(ev,es);
|
170 |
|
|
counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts);
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
//
|
174 |
konec |
1.10 |
// fill L1 info
|
175 |
|
|
//
|
176 |
|
|
std::vector<L1Obj> l1Obj = theL1ObjMaker(ev);
|
177 |
|
|
l1ObjColl->set( l1Obj);
|
178 |
|
|
std::vector<bool> matching(l1Obj.size(), false);
|
179 |
|
|
std::vector<double> deltaR(l1Obj.size(), 0.);
|
180 |
konec |
1.11 |
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet"));
|
181 |
konec |
1.10 |
for(unsigned int i=0; i< l1Obj.size(); ++i) {
|
182 |
|
|
if (matcher(l1Obj[i].eta, l1Obj[i].phi, theMuon, ev,es)) matching[i]=true;
|
183 |
|
|
TrackToL1ObjMatcher::LastResult result = matcher.lastResult();
|
184 |
|
|
deltaR[i] = sqrt( sqr(result.deltaEta) + sqr(result.deltaPhi) );
|
185 |
|
|
}
|
186 |
|
|
l1ObjColl->set( matching );
|
187 |
|
|
l1ObjColl->set( deltaR );
|
188 |
|
|
|
189 |
|
|
|
190 |
konec |
1.1 |
//
|
191 |
|
|
// fill ntuple + cleanup
|
192 |
|
|
//
|
193 |
|
|
//std::cout <<" THIS event written!" << std::endl;
|
194 |
|
|
theTree->Fill();
|
195 |
|
|
delete event; event = 0;
|
196 |
|
|
delete muon; muon = 0;
|
197 |
|
|
delete track; track = 0;
|
198 |
konec |
1.4 |
delete bitsL1; bitsL1= 0;
|
199 |
|
|
delete bitsHLT; bitsHLT= 0;
|
200 |
konec |
1.10 |
delete l1ObjColl; l1ObjColl = 0;
|
201 |
konec |
1.1 |
}
|
202 |
|
|
|