ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/plugins/LinkSynchroAnalysis.cc
Revision: 1.4
Committed: Thu Jun 17 00:47:03 2010 UTC (14 years, 10 months ago) by konec
Content type: text/plain
Branch: MAIN
CVS Tags: V00-02-01, V00-02-00, V00-01-00
Changes since 1.3: +15 -56 lines
Log Message:
*** empty log message ***

File Contents

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