CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingAnalyzer.cc
Go to the documentation of this file.
2 
3 
5 
6 
13 
15 
19 
23 
28 
32 
33 #include <iostream>
34 #include <iomanip>
35 #include <stdio.h>
36 #include <string>
37 #include <sstream>
38 #include <math.h>
39 
40 #define BUF_SIZE 256
41 
42 //
43 // -- Constructor
44 //
46  verbose_(ps.getUntrackedParameter<bool>("verbose",false))
47 {
48 
49  // Get TkMap ParameterSet
50  // tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
51 
52  std::string localPath = std::string("DQM/TrackingMonitorClient/test/loader.html");
53  std::ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
54  char buf[BUF_SIZE];
55 
56  if (!fin) {
57  std::cerr << "Input File: loader.html"<< " could not be opened!" << std::endl;
58  return;
59  }
60 
61  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
62  html_out_ << buf ;
63  }
64  fin.close();
65 
66 
67 
68  edm::LogInfo("TrackingAnalyser") << " TrackingAnalyser::Creating TrackingAnalyser ";
69  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency",1);
70  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
71  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
72 
73  edm::InputTag rawDataTag = ps.getUntrackedParameter<edm::InputTag>("RawDataTag");
74  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag);
75 
76  // get back-end interface
78 
79 
80  // instantiate web interface
82  trackerFEDsFound_ = false;
83  endLumiAnalysisOn_ = false;
84 }
85 //
86 // -- Destructor
87 //
89 
90  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser::Deleting TrackingAnalyser ";
91 
92 }
93 //
94 // -- Begin Job
95 //
97 
98  nLumiSecs_ = 0;
99  nEvents_ = 0;
100 }
101 //
102 // -- Begin Run
103 //
105  edm::LogInfo ("TrackingAnalyser") <<"TrackingAnalyser:: Begining of Run";
106 
107  // Check latest Fed cabling and create TrackerMapCreator
108  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
109  if (m_cacheID_ != cacheID) {
110  m_cacheID_ = cacheID;
111  edm::LogInfo("TrackingAnalyser") <<"TrackingAnalyser::beginRun: "
112  << " Change in Cabling, recrated TrackerMap";
113  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
114  eSetup.get<SiStripDetCablingRcd>().get(detCabling_);
115  }
117 }
118 //
119 // -- Begin Luminosity Block
120 //
122  edm::LogInfo("TrackingAnalyser") <<"TrackingAnalyser:: Begin of LS transition";
123 }
124 //
125 // -- Analyze
126 //
128  nEvents_++;
129  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
130  checkTrackerFEDs(e);
131  if (!trackerFEDsFound_) {
134  } else {
137  }
138  }
139 }
140 //
141 // -- End Luminosity Block
142 //
144  edm::LogInfo ("TrackingAnalyser") <<"TrackingAnalyser:: End of LS transition, performing the DQM client operation";
145  if (verbose_) std::cout << "[TrackingAnalyser::endLuminosityBlock]" << std::endl;
146  nLumiSecs_++;
147 
148  if (!trackerFEDsFound_) {
150  return;
151  }
152  endLumiAnalysisOn_ = true;
153 
154  if (verbose_) std::cout << "====================================================== " << std::endl;
155  if (verbose_) std::cout << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << std::endl;
156  if (verbose_) std::cout << "====================================================== " << std::endl;
157  // Fill Global Status
158  if (globalStatusFilling_ > 0) {
160  }
161  endLumiAnalysisOn_ = false;
162 }
163 
164 //
165 // -- End Run
166 //
168  edm::LogInfo ("TrackingAnalyser") <<"TrackingAnalyser:: End of Run";
169 }
170 //
171 // -- End Job
172 //
174  edm::LogInfo("TrackingAnalyser") <<"TrackingAnalyser:: endjob called!";
175 }
176 //
177 // Check Tracker FEDs
178 //
180  edm::Handle<FEDRawDataCollection> rawDataHandle;
181  e.getByToken( rawDataToken_, rawDataHandle );
182  if ( !rawDataHandle.isValid() ) return;
183 
184  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
185  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
186  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
187  const int siPixelFedIdMin = FEDNumbering::MINSiPixelFEDID;
188  const int siPixelFedIdMax = FEDNumbering::MAXSiPixelFEDID;
189 
190  unsigned int nFed = 0;
191  for (int i=siStripFedIdMin; i <= siStripFedIdMax; i++) {
192  if (rawDataCollection.FEDData(i).size() &&
193  rawDataCollection.FEDData(i).data() )
194  nFed++;
195  }
196  for (int i=siPixelFedIdMin; i <= siPixelFedIdMax; i++) {
197  if (rawDataCollection.FEDData(i).size() &&
198  rawDataCollection.FEDData(i).data() )
199  nFed++;
200  }
201 
202  trackerFEDsFound_ = (nFed > 0);
203 
204 }
205 
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
BeginRun.
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
EndRun.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::ESHandle< SiStripDetCabling > detCabling_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void checkTrackerFEDs(edm::Event const &e)
void createShiftReport(DQMStore *dqm_store)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
LuminosityBlockNumber_t luminosityBlock() const
virtual ~TrackingAnalyser()
Destructor.
TrackingAnalyser(const edm::ParameterSet &ps)
Constructor.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
Begin Luminosity Block.
unsigned long long m_cacheID_
void endJob()
Endjob.
bool isValid() const
Definition: HandleBase.h:76
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
End Luminosity Block.
DQMStore * dqmStore_
void createGlobalStatus(DQMStore *dqm_store)
void analyze(edm::Event const &e, edm::EventSetup const &eSetup)
Analyze.
const T & get() const
Definition: EventSetup.h:55
void fillGlobalStatus(DQMStore *dqm_store)
edm::ESHandle< SiStripFedCabling > fedCabling_
std::ostringstream html_out_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void beginJob()
BeginJob.
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
TrackingActionExecutor * actionExecutor_
#define BUF_SIZE
Definition: Run.h:41