CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
BeamSpotProblemMonitor Class Reference

#include <BeamSpotProblemMonitor.h>

Inheritance diagram for BeamSpotProblemMonitor:
one::DQMEDAnalyzer< one::DQMLuminosityBlockElements > one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

 BeamSpotProblemMonitor (const edm::ParameterSet &)
 
- Public Member Functions inherited from one::DQMEDAnalyzer< one::DQMLuminosityBlockElements >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
 
void bookHistograms (DQMStore::IBooker &i, const edm::Run &r, const edm::EventSetup &c) override
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 

Private Member Functions

void fillPlots (int &, int &, int)
 

Private Attributes

const int alarmOFFThreshold_
 
bool alarmOn_
 
const int alarmONThreshold_
 
MonitorElementbeamSpotError_ = 0
 
int beamSpotFromDB_
 
double beamSpotStatus_
 
MonitorElementbeamSpotStatusLumi_ = 0
 
MonitorElementbeamSpotStatusLumiAll_ = 0
 
const edm::EDGetTokenT< DcsStatusCollectiondcsStatus_
 
const bool debug_
 
const bool doTest_
 
const int fitNLumi_
 
int lastlumi_
 
std::string monitorName_
 
const int nCosmicTrk_
 
int nextlumi_
 
int nTracks_
 
const bool onlineMode_
 
bool processed_
 
const edm::EDGetTokenT< BeamSpotOnlineCollectionscalertag_
 
const edm::EDGetTokenT< reco::TrackCollectiontrkSrc_
 

Detailed Description

Definition at line 27 of file BeamSpotProblemMonitor.h.

Constructor & Destructor Documentation

BeamSpotProblemMonitor::BeamSpotProblemMonitor ( const edm::ParameterSet ps)
explicit

Definition at line 35 of file BeamSpotProblemMonitor.cc.

References alarmOFFThreshold_, alarmOn_, alarmONThreshold_, beamSpotFromDB_, beamSpotStatus_, debug_, doTest_, fitNLumi_, edm::ParameterSet::getUntrackedParameter(), lastlumi_, monitorName_, nCosmicTrk_, nextlumi_, nTracks_, onlineMode_, processed_, scalertag_, and trkSrc_.

35  :
36  dcsStatus_{consumes<DcsStatusCollection>(
37  ps.getUntrackedParameter<InputTag>("DCSStatus"))},
38  scalertag_{consumes<BeamSpotOnlineCollection>(
39  ps.getUntrackedParameter<InputTag>("scalarBSCollection"))},
40  trkSrc_{consumes<reco::TrackCollection>(
41  ps.getUntrackedParameter<InputTag>("pixelTracks"))},
42  nTracks_{0},
43  nCosmicTrk_{ps.getUntrackedParameter<int>("nCosmicTrk")},
44  fitNLumi_{1},
45  debug_{ps.getUntrackedParameter<bool>("Debug")},
46  onlineMode_{ps.getUntrackedParameter<bool>("OnlineMode")},
47  doTest_{ps.getUntrackedParameter<bool>("doTest")},
48  alarmONThreshold_{ps.getUntrackedParameter<int>("AlarmONThreshold")},
49  alarmOFFThreshold_{ps.getUntrackedParameter<int>("AlarmOFFThreshold")},
50  lastlumi_{0},
51  nextlumi_{0},
52  processed_{false},
53  alarmOn_{false},
54  beamSpotStatus_{0},
55  beamSpotFromDB_{0}{
56 
57  monitorName_ = ps.getUntrackedParameter<string>("monitorName");
58 
59  if (not monitorName_.empty() ) monitorName_ +="/" ;
60 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalertag_
const edm::EDGetTokenT< DcsStatusCollection > dcsStatus_
const edm::EDGetTokenT< reco::TrackCollection > trkSrc_

Member Function Documentation

void BeamSpotProblemMonitor::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotected

Definition at line 140 of file BeamSpotProblemMonitor.cc.

References alarmOn_, beamSpotStatus_, DcsStatus::BPIX, dcsStatus_, doTest_, MillePedeFileConverter_cfg::e, DcsStatus::FPIX, edm::Event::getByToken(), edm::EventBase::luminosityBlock(), nCosmicTrk_, nextlumi_, nTracks_, onlineMode_, processed_, scalertag_, mps_update::status, DcsStatus::TECm, DcsStatus::TECp, DcsStatus::TIBTID, DcsStatus::TOB, HiIsolationCommonParameters_cff::track, findElectronsInSiStrips_cfi::trackCollection, trkSrc_, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotOnline::y(), and BeamSpotOnline::z().

141  {
142  const int nthlumi = iEvent.luminosityBlock();
143 
144  if (onlineMode_ && (nthlumi < nextlumi_)) {
145  edm::LogInfo("BeamSpotProblemMonitor") << "analyze:: Spilt event from previous lumi section!" << std::endl;
146  return;
147  }
148  if (onlineMode_ && (nthlumi > nextlumi_)) {
149  edm::LogInfo("BeamSpotProblemMonitor") << "analyze:: Spilt event from next lumi section!!!" << std::endl;
150  return;
151  }
152 
153  beamSpotStatus_ = 0.;
154 
155 
156  // Checking TK status
158  iEvent.getByToken(dcsStatus_, dcsStatus);
159  std::array<bool,6> dcsTk;
160  for (auto &e: dcsTk) { e=true; }
161  for (auto const& status: *dcsStatus ) {
162  if (!status.ready(DcsStatus::BPIX)) dcsTk[0]=false;
163  if (!status.ready(DcsStatus::FPIX)) dcsTk[1]=false;
164  if (!status.ready(DcsStatus::TIBTID)) dcsTk[2]=false;
165  if (!status.ready(DcsStatus::TOB)) dcsTk[3]=false;
166  if (!status.ready(DcsStatus::TECp)) dcsTk[4]=false;
167  if (!status.ready(DcsStatus::TECm)) dcsTk[5]=false;
168  }
169 
170  bool allTkOn = true;
171  for (auto status: dcsTk) {
172  if (!status) {
173  allTkOn = false;
174  break;
175  }
176  }
177 
178 
179  //If tracker is ON and collision is going on then must be few track ther
181  iEvent.getByToken(trkSrc_, trackCollection);
182  for ( auto const& track : *trackCollection) {
183  if(track.pt() > 1.0)nTracks_++;
184  if(nTracks_> 200) break;
185  }
186 
187 
188 
189  // get scalar collection and BeamSpot
191  iEvent.getByToken( scalertag_, handleScaler);
192 
193  // beam spot scalar object
194  BeamSpotOnline spotOnline;
195 
196  bool fallBackToDB=false;
197  alarmOn_ = false;
198 
199 
200  if (!handleScaler->empty()) {
201  spotOnline = * ( handleScaler->begin() );
202 
203  // check if we have a valid beam spot fit result from online DQM thrugh scalars
204  if ( spotOnline.x() == 0. &&
205  spotOnline.y() == 0. &&
206  spotOnline.z() == 0. &&
207  spotOnline.width_x() == 0. &&
208  spotOnline.width_y() == 0. ) {
209  fallBackToDB=true;
210  }
211  }
212 
213 
214  //For testing set it false for every LSs
215  if(doTest_)fallBackToDB= true;
216 
217  //based on last event of this lumi only as it overwrite it
218  if(allTkOn && fallBackToDB){beamSpotStatus_ = -1.;} //i.e,from DB
219  if(allTkOn && (!fallBackToDB)){beamSpotStatus_ = 1.;} //i.e,from online DQM
220 
221  //when collision at least few tracks should be there otherwise it give false ALARM
222  if(allTkOn && nTracks_ < nCosmicTrk_)beamSpotStatus_ = 0.;
223 
224  processed_ = true;
225 }
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalertag_
float y() const
float x() const
float z() const
float width_y() const
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< DcsStatusCollection > dcsStatus_
const edm::EDGetTokenT< reco::TrackCollection > trkSrc_
float width_x() const
struct DcsStatusRaw_v4 dcsStatus
Definition: ScalersRaw.h:227
void BeamSpotProblemMonitor::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
overrideprotected

Definition at line 114 of file BeamSpotProblemMonitor.cc.

References fillPlots(), lastlumi_, edm::LuminosityBlockBase::luminosityBlock(), nextlumi_, onlineMode_, and processed_.

115  {
116  const int nthlumi = lumiSeg.luminosityBlock();
117 
118 
119  if (onlineMode_) {
120  if (nthlumi > nextlumi_) {
121  fillPlots(lastlumi_,nextlumi_,nthlumi);
122  nextlumi_ = nthlumi;
123  edm::LogInfo("BeamSpotProblemMonitor") << "beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
124  }
125  }
126  else{
127  if (processed_) fillPlots(lastlumi_,nextlumi_,nthlumi);
128  nextlumi_ = nthlumi;
129  edm::LogInfo("BeamSpotProblemMonitor") << " beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
130  }
131 
132  if (processed_) processed_ = false;
133  edm::LogInfo("BeamSpotProblemMonitor") << " beginLuminosityBlock:: Begin of Lumi: " << nthlumi << endl;
134 }
void fillPlots(int &, int &, int)
LuminosityBlockNumber_t luminosityBlock() const
void BeamSpotProblemMonitor::bookHistograms ( DQMStore::IBooker i,
const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

Definition at line 81 of file BeamSpotProblemMonitor.cc.

References beamSpotError_, beamSpotStatusLumi_, beamSpotStatusLumiAll_, DQMStore::IBooker::book1D(), MonitorElement::getTH1(), monitorName_, MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), hgcalPlots::xtitle, and trackingPlots::ytitle.

81  {
82 
83 
84  // create and cd into new folder
85  iB.setCurrentFolder(monitorName_+"FitFromScalars");
86 
87  const string coord{"BeamSpotStatus"};
88 
89  string histName(coord + "_lumi");
90  string histTitle(coord);
91  const string ytitle("Problem (-1) / OK (1)");
92  const string xtitle("Lumisection");
93 
94  beamSpotStatusLumi_ = iB.book1D(histName,histTitle,40,0.5,40.5);
97 
98  histName += "_all";
99  histTitle += " all";
100  beamSpotStatusLumiAll_ = iB.book1D(histName,histTitle,40,0.5,40.5);
101  beamSpotStatusLumiAll_->getTH1()->SetCanExtend(TH1::kAllAxes);
104 
105  //NOTE: This in principal should be a Lumi only histogram since it gets reset at every
106  // beginLuminosityBlock call. However, it is also filled at that time and the DQMStore
107  // clears all lumi histograms at postGlobalBeginLuminosityBlock!
108  beamSpotError_ = iB.book1D("BeamSpotError","ERROR: Beamspot missing from scalars",20,0.5,20.5);
109  beamSpotError_->setAxisTitle("# of consecutive LSs with problem",1);
110  beamSpotError_->setAxisTitle("Problem with scalar BeamSpot",2);
111 }
MonitorElement * beamSpotStatusLumi_
TH1 * getTH1() const
MonitorElement * beamSpotStatusLumiAll_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void BeamSpotProblemMonitor::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overrideprotected

Definition at line 291 of file BeamSpotProblemMonitor.cc.

References edm::LuminosityBlockBase::id(), and edm::LuminosityBlockID::luminosityBlock().

292  {
293  const int nthlumi = lumiSeg.id().luminosityBlock();
294  edm::LogInfo("BeamSpotProblemMonitor") << "endLuminosityBlock:: Lumi of the last event before endLuminosityBlock: " << nthlumi << endl;
295 }
LuminosityBlockID id() const
LuminosityBlockNumber_t luminosityBlock() const
void BeamSpotProblemMonitor::endRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

Definition at line 298 of file BeamSpotProblemMonitor.cc.

References beamSpotError_, debug_, DEFINE_FWK_MODULE, and MonitorElement::Reset().

298  {
299 
300  if(debug_)edm::LogInfo("BeamSpotProblemMonitor") << "endRun:: Clearing all the Maps "<<endl;
301  //Reset it end of job
303 }
void Reset()
reset ME (ie. contents, errors, etc)
void BeamSpotProblemMonitor::fillDescriptions ( edm::ConfigurationDescriptions oDesc)
static

Definition at line 63 of file BeamSpotProblemMonitor.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addUntracked().

63  {
65  desc.addUntracked<string>("monitorName", "BeamSpotProblemMonitor");
66  desc.addUntracked<InputTag>("DCSStatus", edm::InputTag("scalersRawToDigi"));
67  desc.addUntracked<InputTag>("scalarBSCollection", edm::InputTag("scalersRawToDigi") );
68  desc.addUntracked<InputTag>("pixelTracks", edm::InputTag("pixelTracks") );
69  desc.addUntracked<int>("nCosmicTrk",10);
70  desc.addUntracked<bool>("Debug", false);
71  desc.addUntracked<bool>("OnlineMode", true);
72  desc.addUntracked<bool>("doTest", false);
73  desc.addUntracked<int>("AlarmONThreshold",10);
74  desc.addUntracked<int>("AlarmOFFThreshold",40);
75 
76  oDesc.add("dqmBeamSpotProblemMonitor",desc);
77 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void BeamSpotProblemMonitor::fillPlots ( int &  lastlumi,
int &  nextlumi,
int  nthlumi 
)
private

Definition at line 228 of file BeamSpotProblemMonitor.cc.

References alarmOFFThreshold_, alarmOn_, alarmONThreshold_, beamSpotError_, beamSpotFromDB_, beamSpotStatus_, beamSpotStatusLumi_, beamSpotStatusLumiAll_, MonitorElement::Fill(), fitNLumi_, MonitorElement::getQReport(), MonitorElement::getTH1(), nTracks_, onlineMode_, MonitorElement::Reset(), MonitorElement::setBinContent(), and MonitorElement::ShiftFillLast().

Referenced by beginLuminosityBlock().

228  {
229 
230  if (onlineMode_ && (nthlumi <= nextlumi)) return;
231 
232  int currentlumi = nextlumi;
233  lastlumi = currentlumi;
234 
235  //Chcek status and if lumi are in succession when fall to DB
236  if(beamSpotStatus_== -1. && (lastlumi+1) == nthlumi) {
237  beamSpotFromDB_++;
238  } else {
239  beamSpotFromDB_=0; //if not in succesion or status is ok then set zero
240  }
241 
243  alarmOn_ =true; //set the audio alarm true after N successive LSs
244  }
245 
247  alarmOn_ =false; //set the audio alarm true after 10 successive LSs
248  beamSpotFromDB_=0; //reset it for new incident
249  }
250 
251 
252 
253  if (onlineMode_) { // filling LS gap For status plot
254 
255  const int countLS_bs = beamSpotStatusLumi_->getTH1()->GetEntries();
256  int LSgap_bs = currentlumi/fitNLumi_ - countLS_bs;
257  if (currentlumi%fitNLumi_ == 0)LSgap_bs--;
258 
259 
260  // filling previous fits if LS gap ever exists
261  for (int ig = 0; ig < LSgap_bs; ig++) {
262  beamSpotStatusLumi_->ShiftFillLast( 0., 0., fitNLumi_ );//x0 , x0err, fitNLumi_; see DQMCore....
263  }
264 
265  beamSpotStatusLumi_->ShiftFillLast( beamSpotStatus_, 0. , fitNLumi_ ); //beamSpotStatus_ =>0. (no collision, no tracks); =>1 (OK from scaler), =>-1 (No scalar results)
267 
268 
269  } else {
271  }//onlineMode_
272 
273  //Reset it here for next lumi
276 
277 
278  //Get quality report
279  const QReport * beamSpotQReport = beamSpotError_->getQReport("BeamSpotOnlineTest");
280 
281  if(beamSpotQReport){
282  /* S.Dutta : Commenting out these variables are not used and giving error with "-Werror=unused-variable" option
283  float qtresult = BeamSpotQReport->getQTresult();
284  int qtstatus = BeamSpotQReport->getStatus() ; // get QT status value (see table below) */
285  }
286 
287  nTracks_= 0;
288 }
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * beamSpotStatusLumi_
TH1 * getTH1() const
MonitorElement * beamSpotStatusLumiAll_
void Fill(long long x)
void ShiftFillLast(double y, double ye=0., int32_t xscale=1)
void Reset()
reset ME (ie. contents, errors, etc)

Member Data Documentation

const int BeamSpotProblemMonitor::alarmOFFThreshold_
private

Definition at line 64 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and fillPlots().

bool BeamSpotProblemMonitor::alarmOn_
private

Definition at line 71 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), and fillPlots().

const int BeamSpotProblemMonitor::alarmONThreshold_
private

Definition at line 63 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and fillPlots().

MonitorElement* BeamSpotProblemMonitor::beamSpotError_ = 0
private

Definition at line 78 of file BeamSpotProblemMonitor.h.

Referenced by bookHistograms(), endRun(), and fillPlots().

int BeamSpotProblemMonitor::beamSpotFromDB_
private

Definition at line 73 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and fillPlots().

double BeamSpotProblemMonitor::beamSpotStatus_
private

Definition at line 72 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), and fillPlots().

MonitorElement* BeamSpotProblemMonitor::beamSpotStatusLumi_ = 0
private

Definition at line 76 of file BeamSpotProblemMonitor.h.

Referenced by bookHistograms(), and fillPlots().

MonitorElement* BeamSpotProblemMonitor::beamSpotStatusLumiAll_ = 0
private

Definition at line 77 of file BeamSpotProblemMonitor.h.

Referenced by bookHistograms(), and fillPlots().

const edm::EDGetTokenT<DcsStatusCollection> BeamSpotProblemMonitor::dcsStatus_
private

Definition at line 53 of file BeamSpotProblemMonitor.h.

Referenced by analyze().

const bool BeamSpotProblemMonitor::debug_
private

Definition at line 60 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and endRun().

const bool BeamSpotProblemMonitor::doTest_
private

Definition at line 62 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().

const int BeamSpotProblemMonitor::fitNLumi_
private

Definition at line 59 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and fillPlots().

int BeamSpotProblemMonitor::lastlumi_
private

Definition at line 66 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and beginLuminosityBlock().

std::string BeamSpotProblemMonitor::monitorName_
private

Definition at line 52 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and bookHistograms().

const int BeamSpotProblemMonitor::nCosmicTrk_
private

Definition at line 58 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().

int BeamSpotProblemMonitor::nextlumi_
private

Definition at line 67 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), and beginLuminosityBlock().

int BeamSpotProblemMonitor::nTracks_
private

Definition at line 57 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), and fillPlots().

const bool BeamSpotProblemMonitor::onlineMode_
private
bool BeamSpotProblemMonitor::processed_
private

Definition at line 68 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), and beginLuminosityBlock().

const edm::EDGetTokenT<BeamSpotOnlineCollection> BeamSpotProblemMonitor::scalertag_
private

Definition at line 54 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().

const edm::EDGetTokenT<reco::TrackCollection> BeamSpotProblemMonitor::trkSrc_
private

Definition at line 55 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().