1 |
konec |
1.1 |
#include "LinkSynchroAnalysis.h"
|
2 |
|
|
|
3 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
4 |
|
|
#include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
|
5 |
|
|
#include "CondFormats/RPCObjects/interface/LinkBoardSpec.h"
|
6 |
|
|
|
7 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
8 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
9 |
|
|
#include "FWCore/Framework/interface/ESTransientHandle.h"
|
10 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
11 |
|
|
#include "FWCore/Framework/interface/ESWatcher.h"
|
12 |
|
|
#include "CondFormats/RPCObjects/interface/RPCEMap.h"
|
13 |
|
|
#include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
|
14 |
|
|
|
15 |
konec |
1.4 |
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroSelectorTrack.h"
|
16 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroSelectorMuon.h"
|
17 |
konec |
1.5 |
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroSelectorL1Muon.h"
|
18 |
konec |
1.1 |
|
19 |
|
|
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
|
20 |
|
|
#include "TFile.h"
|
21 |
|
|
#include "TH1F.h"
|
22 |
|
|
#include <map>
|
23 |
|
|
|
24 |
konec |
1.2 |
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
|
25 |
|
|
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
|
26 |
|
|
|
27 |
|
|
struct LessGP { bool operator () (const GlobalPoint & p1, const GlobalPoint & p2) const { return p1.perp() < p2.perp(); } };
|
28 |
|
|
|
29 |
konec |
1.1 |
LinkSynchroAnalysis::LinkSynchroAnalysis(const edm::ParameterSet& cfg)
|
30 |
|
|
: RPCMonitorLinkSynchro(cfg.getParameter<edm::ParameterSet>("linkMonitorPSet")), theAnaConfig(cfg),theCabling(0), theEventCounter(0) { }
|
31 |
|
|
|
32 |
konec |
1.4 |
LinkSynchroAnalysis::~LinkSynchroAnalysis()
|
33 |
|
|
{
|
34 |
|
|
delete theCabling;
|
35 |
|
|
for (std::vector<SynchroSelector* >::iterator ix=theSynchroFilters.begin(); ix != theSynchroFilters.end(); ++ix) delete (*ix);
|
36 |
|
|
theSynchroFilters.clear();
|
37 |
|
|
}
|
38 |
|
|
|
39 |
konec |
1.1 |
|
40 |
|
|
void LinkSynchroAnalysis::beginJob()
|
41 |
|
|
{
|
42 |
|
|
RPCMonitorLinkSynchro::beginJob();
|
43 |
|
|
theHistos.SetOwner();
|
44 |
|
|
theHistos.Add(new TH1F("hBX","hBX",3564,0.,3564));
|
45 |
konec |
1.4 |
|
46 |
|
|
if (theAnaConfig.exists("synchroSelectorMuon")) theSynchroFilters.push_back( new SynchroSelectorMuon(theAnaConfig.getParameter<edm::ParameterSet>("synchroSelectorMuon"), theHistos) );
|
47 |
|
|
if (theAnaConfig.exists("synchroSelectorTrack")) theSynchroFilters.push_back( new SynchroSelectorTrack(theAnaConfig.getParameter<edm::ParameterSet>("synchroSelectorTrack"), theHistos) );
|
48 |
konec |
1.5 |
if (theAnaConfig.exists("synchroSelectorL1Muon")) theSynchroFilters.push_back( new SynchroSelectorL1Muon(theAnaConfig.getParameter<edm::ParameterSet>("synchroSelectorL1Muon"), theHistos) );
|
49 |
konec |
1.4 |
std::cout << "SIZE OF SELECTORS IS: " << theSynchroFilters.size()<<std::endl;
|
50 |
|
|
|
51 |
konec |
1.1 |
}
|
52 |
|
|
|
53 |
|
|
void LinkSynchroAnalysis::endJob()
|
54 |
|
|
{
|
55 |
|
|
RPCMonitorLinkSynchro::endJob();
|
56 |
|
|
bool writeHistos = theAnaConfig.getUntrackedParameter<bool>("writeHistograms", false);
|
57 |
|
|
if (writeHistos) {
|
58 |
|
|
std::string histoFile = theAnaConfig.getUntrackedParameter<std::string>("histoFileName");
|
59 |
|
|
TFile f(histoFile.c_str(),"RECREATE");
|
60 |
|
|
theHistos.Write();
|
61 |
|
|
histos().Write();
|
62 |
|
|
edm::LogInfo(" END JOB, histos saved!");
|
63 |
|
|
edm::LogInfo("") <<"LINK SYNCHRO ANALYSIS number of events SELECTED: "<<theEventCounter;
|
64 |
|
|
f.Close();
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
const RPCRawSynchro::ProdItem& LinkSynchroAnalysis::select(const RPCRawSynchro::ProdItem & vItem, const edm::Event &ev, const edm::EventSetup &es)
|
69 |
|
|
{
|
70 |
|
|
static RPCRawSynchro::ProdItem selected;
|
71 |
|
|
selected.clear();
|
72 |
|
|
|
73 |
|
|
bool wasTakeIt = false;
|
74 |
|
|
|
75 |
|
|
if (theMapWatcher.check(es)) {
|
76 |
|
|
delete theCabling;
|
77 |
|
|
edm::ESTransientHandle<RPCEMap> readoutMapping;
|
78 |
|
|
es.get<RPCEMapRcd>().get(readoutMapping);
|
79 |
|
|
theCabling = readoutMapping->convert();
|
80 |
|
|
LogTrace("") << "LinkSynchroAnalysis - record has CHANGED!!, read map, VERSION: " << theCabling->version();
|
81 |
|
|
}
|
82 |
|
|
|
83 |
konec |
1.5 |
for (std::vector<SynchroSelector* >::iterator ix=theSynchroFilters.begin(); ix != theSynchroFilters.end(); ++ix) (*ix)->update(ev,es);
|
84 |
|
|
|
85 |
konec |
1.1 |
for(RPCRawSynchro::ProdItem::const_iterator it = vItem.begin(); it != vItem.end(); ++it) {
|
86 |
|
|
const LinkBoardElectronicIndex & path = it->first;
|
87 |
|
|
const std::vector<FebConnectorSpec> & febs = theCabling->location(path)->febs();
|
88 |
|
|
std::map<uint32_t,bool> dets;
|
89 |
|
|
for (std::vector<FebConnectorSpec>::const_iterator iif = febs.begin(); iif != febs.end(); ++iif) dets[iif->rawId()] = true;
|
90 |
|
|
|
91 |
|
|
bool takeIt = false;
|
92 |
|
|
for ( std::map<uint32_t,bool>::const_iterator im = dets.begin(); im != dets.end(); ++im) {
|
93 |
|
|
RPCDetId rpcDet(im->first);
|
94 |
konec |
1.4 |
for (std::vector<SynchroSelector* >::iterator ix=theSynchroFilters.begin(); ix != theSynchroFilters.end(); ++ix) if((*ix)->takeIt(rpcDet,ev,es) ) takeIt = true;
|
95 |
konec |
1.1 |
}
|
96 |
|
|
if (takeIt) selected.push_back(*it);
|
97 |
|
|
if (takeIt) wasTakeIt = true;
|
98 |
|
|
}
|
99 |
konec |
1.3 |
|
100 |
konec |
1.1 |
if (wasTakeIt) static_cast<TH1*>(theHistos.FindObject("hBX"))->Fill( ev.bunchCrossing());
|
101 |
|
|
if (wasTakeIt) theEventCounter++;
|
102 |
|
|
return selected;
|
103 |
|
|
}
|
104 |
|
|
|