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.
1 
3 
4 
6 
7 
14 
16 
20 
24 
29 
33 
34 #include <iostream>
35 #include <iomanip>
36 #include <stdio.h>
37 #include <string>
38 #include <sstream>
39 #include <math.h>
40 
41 #define BUF_SIZE 256
42 
43 //
44 // -- Constructor
45 //
47 
48  // Get TkMap ParameterSet
49  tkMapPSet_ = ps.getParameter<edm::ParameterSet>("TkmapParameters");
50 
51  std::string localPath = std::string("DQM/TrackingMonitorClient/test/loader.html");
52  std::ifstream fin(edm::FileInPath(localPath).fullPath().c_str(), std::ios::in);
53  char buf[BUF_SIZE];
54 
55  if (!fin) {
56  std::cerr << "Input File: loader.html"<< " could not be opened!" << std::endl;
57  return;
58  }
59 
60  while (fin.getline(buf, BUF_SIZE, '\n')) { // pops off the newline character
61  html_out_ << buf ;
62  }
63  fin.close();
64 
65 
66 
67  edm::LogInfo("TrackingAnalyser") << " TrackingAnalyser::Creating TrackingAnalyser ";
68  staticUpdateFrequency_ = ps.getUntrackedParameter<int>("StaticUpdateFrequency",1);
69  globalStatusFilling_ = ps.getUntrackedParameter<int>("GlobalStatusFilling", 1);
70  shiftReportFrequency_ = ps.getUntrackedParameter<int>("ShiftReportFrequency", 1);
71 
72  edm::InputTag rawDataTag = ps.getUntrackedParameter<edm::InputTag>("RawDataTag");
73  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag);
74 
75  // get back-end interface
77 
78 
79  // instantiate web interface
81  trackerFEDsFound_ = false;
82  endLumiAnalysisOn_ = false;
83 }
84 //
85 // -- Destructor
86 //
88 
89  edm::LogInfo("TrackingAnalyser") << "TrackingAnalyser::Deleting TrackingAnalyser ";
90 
91 }
92 //
93 // -- Begin Job
94 //
96 
97  nLumiSecs_ = 0;
98  nEvents_ = 0;
99 }
100 //
101 // -- Begin Run
102 //
104  std::cout << "[TrackingAnalyser::beginRun] .. starting" << std::endl;
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  std::cout << "[TrackingAnalyser::analyze] .. starting" << std::endl;
129  nEvents_++;
130  if (nEvents_ == 1 && globalStatusFilling_ > 0) {
131  checkTrackerFEDs(e);
132  if (!trackerFEDsFound_) {
135  } else {
138  }
139  }
140 
141 }
142 //
143 // -- End Luminosity Block
144 //
146  edm::LogInfo ("TrackingAnalyser") <<"TrackingAnalyser:: End of LS transition, performing the DQM client operation";
147 
148  nLumiSecs_++;
149 
150  if (!trackerFEDsFound_) {
152  return;
153  }
154  endLumiAnalysisOn_ = true;
155 
156  std::cout << "====================================================== " << std::endl;
157  std::cout << " ===> Iteration # " << nLumiSecs_ << " " << lumiSeg.luminosityBlock() << std::endl;
158  std::cout << "====================================================== " << std::endl;
159  // Fill Global Status
160  if (globalStatusFilling_ > 0) {
162  }
163  endLumiAnalysisOn_ = false;
164 }
165 
166 //
167 // -- End Run
168 //
170  edm::LogInfo ("TrackingAnalyser") <<"TrackingAnalyser:: End of Run";
171 }
172 //
173 // -- End Job
174 //
176  edm::LogInfo("TrackingAnalyser") <<"TrackingAnalyser:: endjob called!";
177 }
178 //
179 // Check Tracker FEDs
180 //
182  edm::Handle<FEDRawDataCollection> rawDataHandle;
183  e.getByToken( rawDataToken_, rawDataHandle );
184  if ( !rawDataHandle.isValid() ) return;
185 
186  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
187  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
188  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
189  const int siPixelFedIdMin = FEDNumbering::MINSiPixelFEDID;
190  const int siPixelFedIdMax = FEDNumbering::MAXSiPixelFEDID;
191 
192  unsigned int nFed = 0;
193  for (int i=siStripFedIdMin; i <= siStripFedIdMax; i++) {
194  if (rawDataCollection.FEDData(i).size() &&
195  rawDataCollection.FEDData(i).data() )
196  nFed++;
197  }
198  for (int i=siPixelFedIdMin; i <= siPixelFedIdMax; i++) {
199  if (rawDataCollection.FEDData(i).size() &&
200  rawDataCollection.FEDData(i).data() )
201  nFed++;
202  }
203 
204  trackerFEDsFound_ = (nFed > 0);
205 
206 }
207 
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
BeginRun.
T getParameter(std::string const &) const
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 fillStatusAtLumi(DQMStore *dqm_store)
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
TrackingActionExecutor * actionExecutor_
edm::ParameterSet tkMapPSet_
#define BUF_SIZE
Definition: Run.h:41