ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/plugins/L1RpcTreeMaker.cc
(Generate patch)

Comparing UserCode/L1RpcTriggerAnalysis/plugins/L1RpcTreeMaker.cc (file contents):
Revision 1.3 by konec, Mon Oct 8 07:09:24 2012 UTC vs.
Revision 1.14 by konec, Tue Apr 23 14:27:36 2013 UTC

# Line 16 | Line 16
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/L1ObjMakerRpcEmu.h"
19   #include "UserCode/L1RpcTriggerAnalysis/interface/TrackToL1ObjMatcher.h"
20   #include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
21   #include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
22 <
22 > #include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
23  
24   #include "TFile.h"
25   #include "TTree.h"
26  
27   template <class T> T sqr( T t) {return t*t;}
28  
30
29   L1RpcTreeMaker::L1RpcTreeMaker(const edm::ParameterSet& cfg)
30 <  : theConfig(cfg), theTree(0), event(0), muon(0), track(0), counts(0),
31 <    l1RpcColl(0) , l1OtherColl(0), l1RpcCollEmu(0),
30 >  : theConfig(cfg), theTree(0), event(0), muon(0), track(0),
31 >    bitsL1(0), bitsHLT(0),
32 >    counts(0),
33 >    l1ObjColl(0),
34      theCounter(0),
35      theBestMuonFinder(cfg.getParameter<edm::ParameterSet>("bestMuonFinder")),
36      theDetHitCollector(cfg.getParameter<edm::ParameterSet>("detHitCollector")),
37 <    theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber"))
37 >    theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber")),
38 >    theL1ObjMaker(cfg.getParameter<edm::ParameterSet>("l1ObjMaker")),
39 >    theMenuInspector(edm::ParameterSet())
40   { }
41  
42 < void L1RpcTreeMaker::beginRun( const edm::Run &ru, const edm::EventSetup &es)
42 > void L1RpcTreeMaker::beginRun(const edm::Run &ru, const edm::EventSetup &es)
43   {
44 +  std::cout <<" L1RpcTreeMaker::beginRun CALLED" << std::endl;
45 +  theMenuInspector.checkRun(ru,es);
46   }
47  
48   void L1RpcTreeMaker::beginJob()
# Line 50 | Line 54 | void L1RpcTreeMaker::beginJob()
54    theTree->Branch("muon","MuonObj",&muon,32000,99);
55    theTree->Branch("track", "TrackObj",&track,32000,99);
56  
57 +  theTree->Branch("bitsL1" ,"TriggerMenuResultObj",&bitsL1 ,32000,99);
58 +  theTree->Branch("bitsHLT","TriggerMenuResultObj",&bitsHLT,32000,99);
59 +
60    theTree->Branch("counts",&counts);
61    theTree->Branch("detsCrossedByMuon",&detsCrossedByMuon);
62    theTree->Branch("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside);
63    theTree->Branch("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon);
64    theTree->Branch("detsSIMU",&detsSIMU);
58  theTree->Branch("nDigisCompDets",&nDigisCompDets);
59  theTree->Branch("clSizeCompDets",&clSizeCompDets);
65  
66 <  theTree->Branch("l1RpcColl","L1ObjColl",&l1RpcColl,32000,99);
62 <  theTree->Branch("l1RpcCollEmu","L1ObjColl",&l1RpcCollEmu,32000,99);
63 <  theTree->Branch("l1OtherColl","L1ObjColl",&l1OtherColl,32000,99);
66 >  theTree->Branch("l1ObjColl","L1ObjColl",&l1ObjColl,32000,99);
67  
68    theHelper.SetOwner();
69    theBestMuonFinder.initHistos(theHelper);
# Line 86 | Line 89 | L1RpcTreeMaker::~L1RpcTreeMaker()
89  
90   void L1RpcTreeMaker::analyze(const edm::Event &ev, const edm::EventSetup &es)
91   {
89
90
92    //
93    // check reference muon
94    //
95    const reco::Muon * theMuon = theBestMuonFinder.result(ev,es);
96 <  if (!theMuon || !theBestMuonFinder.isUnique(ev,es) ) return;
96 >  if (theConfig.getParameter<bool>("onlyBestMuEvents") && (!theMuon || !theBestMuonFinder.isUnique(ev,es)) ) return;
97    theCounter++;
98  
99    //
# Line 111 | Line 112 | void L1RpcTreeMaker::analyze(const edm::
112    //
113    muon = new MuonObj();
114    track = new TrackObj();
115 < //  counts = new SynchroCountsObjVect;
115 >
116 >  bitsL1 = new TriggerMenuResultObj();
117 >  bitsHLT = new TriggerMenuResultObj();
118 >
119    counts = std::vector<SynchroCountsObj>();
120    detsCrossedByMuon = std::vector<uint32_t>();
121    detsCrossedByMuonDeepInside = std::vector<uint32_t>();
122 <  detsHitsCompatibleWithMuon = std::vector<uint32_t>();
122 >  detsHitsCompatibleWithMuon = std::vector<DetCluDigiObj>();
123    detsSIMU = std::vector<uint32_t>();
124 <  nDigisCompDets = std::vector<uint32_t>();
125 <  clSizeCompDets = std::vector<uint32_t>();
122 <  l1RpcColl = new L1ObjColl;
123 <  l1OtherColl = new L1ObjColl;
124 <  l1RpcCollEmu = new L1ObjColl;
124 >
125 >  l1ObjColl = new L1ObjColl;
126  
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;
130 >  if (theMuon) {
131 >    muon->setKine(theMuon->track()->pt(), theMuon->track()->eta(), theMuon->track()->phi(), theMuon->track()->charge());
132 >    muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid());
133 >    muon->nMatchedStations = theMuon->numberOfMatchedStations();
134 >    if (theMuon->isGlobalMuon()) {
135 >      const reco::HitPattern& hp = (theMuon->combinedMuon())->hitPattern();
136 >      muon->nRPCHits = hp.numberOfValidMuonRPCHits();
137 >      muon->nDTHits  = hp.numberOfValidMuonDTHits();
138 >      muon->nCSCHits = hp.numberOfValidMuonCSCHits();
139 >    } else  muon->nRPCHits = muon->nDTHits = muon->nCSCHits = 0;
140 >    muon->nTrackerHits = theMuon->isTrackerMuon() ? (theMuon->innerTrack())->hitPattern().numberOfValidTrackerHits() : 0;
141 >  }
142  
143 +  //
144 +  // fill algoBits info
145 +  //
146 +  static edm::RunNumber_t lastRun = 0;
147 +  if (ev.run() != lastRun) {
148 +    lastRun = ev.run();
149 +    bitsL1->names  = theMenuInspector.namesAlgoL1();
150 +    bitsHLT->names = theMenuInspector.namesAlgoHLT();
151 +  }
152 +  bitsL1->firedAlgos = theMenuInspector.firedAlgosL1(ev,es);
153 +  bitsHLT->firedAlgos = theMenuInspector.firedAlgosHLT(ev,es);
154 +  
155  
156    //
157    // hits and detectors compatible with muon track
158    //
159 <  if ( muon->pt() > 10.) {
160 <    detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es);
159 >  if (theMuon &&  muon->pt() > 10.) {
160 >    detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es);
161      detsCrossedByMuon = theDetHitCollector.compatibleDets( theMuon, ev, es, false);
162      detsCrossedByMuonDeepInside = theDetHitCollector.compatibleDets( theMuon, ev, es, true);
163      if (theConfig.getParameter<bool>("checkDestSIMU")) detsSIMU = theDetHitCollector.compatibleSIMU( theMuon, ev, es);
149    nDigisCompDets = theDetHitCollector.nDigisCompDets(detsHitsCompatibleWithMuon, ev, es);
150    clSizeCompDets = theDetHitCollector.clSizeCompDets(detsHitsCompatibleWithMuon, ev, es);
151
152    for (uint32_t i=0; i< nDigisCompDets.size(); i++) {
153      if (clSizeCompDets[i] > nDigisCompDets[i]) std::cout <<" PROBLEM, event: "<<theCounter<<" cl:"<<clSizeCompDets[i]<<" nDigis:"<<nDigisCompDets[i]<<std::endl;
154    }
164    }
165  
166    
167    //
168    // fill LinkSynchroAnalysis data
169    //
170 <  theSynchroGrabber.setMuon(theMuon);
171 <  RPCRawSynchro::ProdItem rawCounts  = theSynchroGrabber.counts(ev,es);
172 <  counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts);
173 <  
165 <
166 <  //
167 <  // fill L1 RPCemu
168 <  //
169 <  if (theConfig.exists("l1RpcEmu") ) {
170 <    TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet"));
171 <    L1ObjMakerRpcEmu l1RpcsFromEmu( theConfig.getParameter<edm::InputTag>("l1RpcEmu"), ev);
172 <    std::vector<L1Obj> l1RpcsEmu = l1RpcsFromEmu();
173 <    std::vector<bool> l1RpcsEmuMatching(l1RpcsEmu.size(), false);
174 <    for(unsigned int i=0; i< l1RpcsEmu.size(); ++i) if (matcher(l1RpcsEmu[i].eta, l1RpcsEmu[i].phi, theMuon, ev,es)) l1RpcsEmuMatching[i]=true;
175 <    l1RpcCollEmu->set(l1RpcsEmu);
176 <    l1RpcCollEmu->set(l1RpcsEmuMatching);
170 >  if (theMuon) {
171 >    theSynchroGrabber.setMuon(theMuon);
172 >    RPCRawSynchro::ProdItem rawCounts  = theSynchroGrabber.counts(ev,es);
173 >    counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts);
174    }
175 +  
176  
177    //
178 <  // fill L1 objects (Rpc,Oth)
178 >  // fill L1 info
179    //
180 <  L1ObjMaker l1( theConfig.getParameter<edm::InputTag>("l1MuReadout"), ev);
180 >  std::vector<L1Obj> l1Obj = theL1ObjMaker(ev);
181 >  l1ObjColl->set( l1Obj);
182 >  std::vector<bool> matching(l1Obj.size(), false);
183 >  std::vector<double> deltaR(l1Obj.size(), 0.);
184    TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet"));
185 <  std::vector<L1Obj> l1Rpcs = l1(L1ObjMaker::RPCB,L1ObjMaker::RPCF);
186 <  std::vector<L1Obj> l1Others = l1(L1ObjMaker::DT,L1ObjMaker::CSC);
187 <  std::vector<bool> l1RpcsMatching(l1Rpcs.size(), false);
188 <  std::vector<bool> l1OthersMatching(l1Others.size(), false);
189 <  for(unsigned int i=0; i< l1Rpcs.size(); ++i) if (matcher(l1Rpcs[i].eta, l1Rpcs[i].phi, theMuon, ev,es)) l1RpcsMatching[i]=true;
190 <  for(unsigned int i=0; i< l1Others.size(); ++i) if (matcher(l1Others[i].eta, l1Others[i].phi, theMuon, ev,es)) l1OthersMatching[i]=true;
191 <  l1RpcColl->set(l1Rpcs);
192 <  l1RpcColl->set(l1RpcsMatching);
193 <  l1OtherColl->set(l1Others);
194 <  l1OtherColl->set(l1OthersMatching);
195 <
195 < //  std::cout <<"RPCColl:"<<std::endl; l1RpcColl->print();
196 < //  std::cout <<"RPCCollEmu:"<<std::endl; l1RpcCollEmu->print();
185 >  if (theMuon){
186 >    for(unsigned int i=0; i< l1Obj.size(); ++i) {
187 >      if (matcher(l1Obj[i].eta, l1Obj[i].phi, theMuon, ev,es)) matching[i]=true;
188 >      TrackToL1ObjMatcher::LastResult result = matcher.lastResult();
189 >      deltaR[i] = sqrt( sqr(result.deltaEta) + sqr(result.deltaPhi) );
190 >    }
191 >  }
192 >  l1ObjColl->set( matching );
193 >  l1ObjColl->set( deltaR );
194 >  std::cout <<"----------"<<std::endl;
195 >  std::cout <<*l1ObjColl << std::endl;
196  
197    //
198    // fill ntuple + cleanup
# Line 203 | Line 202 | void L1RpcTreeMaker::analyze(const edm::
202    delete event; event = 0;
203    delete muon;  muon = 0;
204    delete track; track = 0;
205 <  delete l1RpcColl; l1RpcColl = 0;
206 <  delete l1OtherColl; l1OtherColl = 0;
207 <  delete l1RpcCollEmu; l1RpcCollEmu = 0;
205 >  delete bitsL1;  bitsL1= 0;
206 >  delete bitsHLT;  bitsHLT= 0;
207 >  delete l1ObjColl; l1ObjColl = 0;
208   }
209                                  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines