CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

BeamSpotProblemMonitor Class Reference

#include <BeamSpotProblemMonitor.h>

Inheritance diagram for BeamSpotProblemMonitor:
edm::EDAnalyzer

List of all members.

Public Member Functions

 BeamSpotProblemMonitor (const edm::ParameterSet &)
 ~BeamSpotProblemMonitor ()

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
void beginJob ()
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
void beginRun (const edm::Run &r, const edm::EventSetup &c)
void endJob (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void endRun (const edm::Run &r, const edm::EventSetup &c)

Private Member Functions

void FillPlots (const edm::LuminosityBlock &lumiSeg, int &, int &, int &)

Private Attributes

bool ALARM_ON_
int alarmOFFThreshold_
int alarmONThreshold_
MonitorElementBeamSpotError
int BeamSpotFromDB_
double BeamSpotStatus_
DQMStoredbe_
bool dcsTk [6]
bool debug_
bool doTest_
int fitNLumi_
std::map< TString,
MonitorElement * > 
hs
int intervalInSec_
int lastlumi_
std::string monitorName_
int nCosmicTrk_
int nextlumi_
int nFitElements_
int Ntracks_
bool onlineMode_
edm::ParameterSet parameters_
bool processed_
edm::InputTag scalertag_
edm::InputTag trkSrc_

Detailed Description

*

Date:
2012/05/22 19:44:16
Revision:
1.1
Author:
Sushil S. Chauhan/UC Davis

Definition at line 30 of file BeamSpotProblemMonitor.h.


Constructor & Destructor Documentation

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

Definition at line 80 of file BeamSpotProblemMonitor.cc.

                                                {
}

Member Function Documentation

void BeamSpotProblemMonitor::analyze ( const edm::Event e,
const edm::EventSetup c 
) [protected, virtual]

Implements edm::EDAnalyzer.

Definition at line 180 of file BeamSpotProblemMonitor.cc.

References ALARM_ON_, BeamSpotStatus_, DcsStatus::BPIX, dbe_, dcsTk, doTest_, DcsStatus::FPIX, edm::Event::getByLabel(), i, edm::EventBase::luminosityBlock(), monitorName_, nCosmicTrk_, nextlumi_, Ntracks_, onlineMode_, processed_, edm::Handle< T >::product(), scalertag_, DQMStore::setCurrentFolder(), DcsStatus::TECm, DcsStatus::TECp, DcsStatus::TIBTID, DcsStatus::TOB, testEve_cfg::tracks, trkSrc_, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotOnline::y(), and BeamSpotOnline::z().

                                                     {
  const int nthlumi = iEvent.luminosityBlock();


  if (onlineMode_ && (nthlumi < nextlumi_)) {
    edm::LogInfo("BeamSpotProblemMonitor") << "analyze::  Spilt event from previous lumi section!" << std::endl;
    return;
  }
  if (onlineMode_ && (nthlumi > nextlumi_)) {
    edm::LogInfo("BeamSpotProblemMonitor") << "analyze::  Spilt event from next lumi section!!!" << std::endl;
    return;
  }

    BeamSpotStatus_ = 0.;


    // Checking TK status
    Handle<DcsStatusCollection> dcsStatus;
    iEvent.getByLabel("scalersRawToDigi", dcsStatus);
    for (int i=0;i<6;i++) dcsTk[i]=true;
    for (DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin(); 
         dcsStatusItr != dcsStatus->end(); ++dcsStatusItr) {
      if (!dcsStatusItr->ready(DcsStatus::BPIX))   dcsTk[0]=false;
      if (!dcsStatusItr->ready(DcsStatus::FPIX))   dcsTk[1]=false;
      if (!dcsStatusItr->ready(DcsStatus::TIBTID)) dcsTk[2]=false;
      if (!dcsStatusItr->ready(DcsStatus::TOB))    dcsTk[3]=false;
      if (!dcsStatusItr->ready(DcsStatus::TECp))   dcsTk[4]=false;
      if (!dcsStatusItr->ready(DcsStatus::TECm))   dcsTk[5]=false;
    }  

     bool AllTkOn = true;
        for (int i=0; i<5; i++) 
            {
              if (!dcsTk[i]) {
                              AllTkOn = false;
                       
                             }
            }


     //If tracker is ON and collision is going on then must be few track ther
     edm::Handle<reco::TrackCollection> TrackCollection;
     iEvent.getByLabel(trkSrc_, TrackCollection);
     const reco::TrackCollection *tracks = TrackCollection.product();
     for ( reco::TrackCollection::const_iterator track = tracks->begin();track != tracks->end();++track ) 
      {
         if(track->pt() > 1.0)Ntracks_++;
          if(Ntracks_> 200) break;
      }



  // get scalar collection and BeamSpot
  Handle<BeamSpotOnlineCollection> handleScaler;
  iEvent.getByLabel( scalertag_, handleScaler);
     
   // beam spot scalar object
   BeamSpotOnline spotOnline;
     
   bool fallBackToDB=false;
        ALARM_ON_  = false;

 
   if (handleScaler->size()!=0)
     {
      spotOnline = * ( handleScaler->begin() );

    // check if we have a valid beam spot fit result from online DQM thrugh scalars
    if ( spotOnline.x() == 0. &&
         spotOnline.y() == 0. &&
         spotOnline.z() == 0. &&
         spotOnline.width_x() == 0. &&
         spotOnline.width_y() == 0. ) 
      { 
         fallBackToDB=true;
        } 
     }


   //For testing set it false for every LSs
   if(doTest_)fallBackToDB= true;
 
    //based on last event of this lumi only as it overwrite it
    if(AllTkOn && fallBackToDB){BeamSpotStatus_ = -1.;}    //i.e,from DB
    if(AllTkOn && (!fallBackToDB)){BeamSpotStatus_ = 1.;}  //i.e,from online DQM


    //when collision at least few tracks should be there otherwise it give false ALARM  
    if(AllTkOn && Ntracks_ < nCosmicTrk_)BeamSpotStatus_ = 0.;
      

    dbe_->setCurrentFolder(monitorName_+"FitFromScalars/");


  processed_ = true;

}
void BeamSpotProblemMonitor::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 85 of file BeamSpotProblemMonitor.cc.

References BeamSpotError, DQMStore::book1D(), dbe_, hs, i, monitorName_, AlCaHLTBitMon_ParallelJobs::options, MonitorElement::setAxisTitle(), and DQMStore::setCurrentFolder().

                                      {


  // create and cd into new folder
  dbe_->setCurrentFolder(monitorName_+"FitFromScalars");

  /* S.Dutta : Commenting out these variables are not used and giving error with "-Werror=unused-variable" option
  int nbins = alarmOFFThreshold_; 
  double hiRange = (alarmOFFThreshold_+0.5);*/

  const int nvar_ = 1;
  string coord[nvar_] = {"BeamSpotStatus"};
  /* S.Dutta : Commenting out these variables are not used and giving error with "-Werror=unused-variable" option
  string label[nvar_] = {"BeamSpotStatus "};*/

  for (int i = 0; i < 1; i++) {
    dbe_->setCurrentFolder(monitorName_+"FitFromScalars");
    for (int ic=0; ic<nvar_; ++ic) {
      TString histName(coord[ic]);
      TString histTitle(coord[ic]);
      string ytitle("Problem (-1)  /  OK (1)");
      string xtitle("");
      string options("E1");
      bool createHisto = true;
     switch(i){

     case 0: 
        histName += "_lumi";
        xtitle = "Lumisection";

      if (createHisto) {
        hs[histName] = dbe_->book1D(histName,histTitle,40,0.5,40.5);
        hs[histName]->setAxisTitle(xtitle,1);
        hs[histName]->setAxisTitle(ytitle,2);

        histName += "_all";
        histTitle += " all";
        hs[histName] = dbe_->book1D(histName,histTitle,40,0.5,40.5);
        hs[histName]->getTH1()->SetBit(TH1::kCanRebin);
        hs[histName]->setAxisTitle(xtitle,1);
        hs[histName]->setAxisTitle(ytitle,2);

        }//create histo
      }
    }
  }

  BeamSpotError = dbe_->book1D("BeamSpotError","ERROR: Beamspot missing from scalars",20,0.5,20.5);
  BeamSpotError->setAxisTitle("# of consecutive LSs with problem",1);
  BeamSpotError->setAxisTitle("Problem with scalar BeamSpot",2);


  dbe_->setCurrentFolder(monitorName_+"FitFromScalars");



}
void BeamSpotProblemMonitor::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 154 of file BeamSpotProblemMonitor.cc.

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

                                                                  {
  int nthlumi = lumiSeg.luminosityBlock();


  if (onlineMode_) {
    if (nthlumi > nextlumi_) {
        FillPlots(lumiSeg,lastlumi_,nextlumi_,nthlumi);
        nextlumi_ = nthlumi;
      edm::LogInfo("BeamSpotProblemMonitor") << "beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
    }
  }
  else{
    if (processed_) FillPlots(lumiSeg,lastlumi_,nextlumi_,nthlumi);
    nextlumi_ = nthlumi;
    edm::LogInfo("BeamSpotProblemMonitor") << " beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
  }

  if (processed_) processed_ = false;
  edm::LogInfo("BeamSpotProblemMonitor") << " beginLuminosityBlock::  Begin of Lumi: " << nthlumi << endl;
}
void BeamSpotProblemMonitor::beginRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 144 of file BeamSpotProblemMonitor.cc.

References debug_.

                                                                                {


  if (debug_) {
    edm::LogInfo("BeamSpotProblemMonitor") << "TimeOffset = ";
  }

}
void BeamSpotProblemMonitor::endJob ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
) [protected]

Definition at line 366 of file BeamSpotProblemMonitor.cc.

References BeamSpotError, endLuminosityBlock(), onlineMode_, and MonitorElement::Reset().

                                                  {
  if (!onlineMode_) endLuminosityBlock(lumiSeg, iSetup);
     //Reset it end of job
     BeamSpotError->Reset();
}
void BeamSpotProblemMonitor::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 348 of file BeamSpotProblemMonitor.cc.

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

Referenced by endJob().

                                                               {
  int nthlumi = lumiSeg.id().luminosityBlock();
  edm::LogInfo("BeamSpotProblemMonitor") << "endLuminosityBlock:: Lumi of the last event before endLuminosityBlock: " << nthlumi << endl;

  if (onlineMode_ && nthlumi < nextlumi_) return;

}
void BeamSpotProblemMonitor::endRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 358 of file BeamSpotProblemMonitor.cc.

References BeamSpotError, debug_, and MonitorElement::Reset().

                                                                          {

if(debug_)edm::LogInfo("BeamSpotProblemMonitor") << "endRun:: Clearing all the Maps "<<endl;
     //Reset it end of job
     BeamSpotError->Reset();
}
void BeamSpotProblemMonitor::FillPlots ( const edm::LuminosityBlock lumiSeg,
int &  lastlumi,
int &  nextlumi,
int &  nthlumi 
) [private]

Definition at line 280 of file BeamSpotProblemMonitor.cc.

References ALARM_ON_, alarmOFFThreshold_, alarmONThreshold_, BeamSpotError, BeamSpotFromDB_, BeamSpotStatus_, dbe_, MonitorElement::Fill(), fitNLumi_, DQMStore::get(), QReport::getMessage(), MonitorElement::getQReport(), hs, monitorName_, Ntracks_, onlineMode_, MonitorElement::Reset(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by beginLuminosityBlock().

                                                                                                             {

  if (onlineMode_ && (nthlumi <= nextlumi)) return;

  int currentlumi = nextlumi;
      lastlumi = currentlumi;

    //Chcek status and if lumi are in succession when fall to DB
   if(BeamSpotStatus_== -1.  && (lastlumi+1) == nthlumi)
                             {BeamSpotFromDB_++;
                                 }
                                 else{
                                        BeamSpotFromDB_=0;} //if not in succesion or status is ok then set zero


   if(BeamSpotFromDB_ >= alarmONThreshold_ ){ ALARM_ON_ =true; //set the audio alarm true after N successive LSs
                                           }

   if(BeamSpotFromDB_ > alarmOFFThreshold_ ){ ALARM_ON_ =false; //set the audio alarm true after 10 successive LSs
                                               BeamSpotFromDB_=0; //reset it for new incident
                                             }



 if (onlineMode_) 
 { // filling LS gap For status plot
    const int countLS_bs = hs["BeamSpotStatus_lumi"]->getTH1()->GetEntries();
    int LSgap_bs = currentlumi/fitNLumi_ - countLS_bs;
    if (currentlumi%fitNLumi_ == 0)LSgap_bs--;


    // filling previous fits if LS gap ever exists
    for (int ig = 0; ig < LSgap_bs; ig++) {
      hs["BeamSpotStatus_lumi"]->ShiftFillLast( 0., 0., fitNLumi_ );//x0 , x0err, fitNLumi_;  see DQMCore....
     }

     hs["BeamSpotStatus_lumi"]->ShiftFillLast( BeamSpotStatus_, 0. , fitNLumi_ ); //BeamSpotStatus_ =>0. (no collision, no tracks); =>1 (OK from scaler), =>-1 (No scalar results) 
     hs["BeamSpotStatus_lumi_all"]->setBinContent( currentlumi, BeamSpotStatus_);


 }//onlineMode_
 else { 
      hs["BeamSpotStatus_lumi"]->ShiftFillLast( 0., 0., fitNLumi_ );
     }

      //Reset it here for next lumi
      BeamSpotError->Reset();
      if(ALARM_ON_)BeamSpotError->Fill(BeamSpotFromDB_);


    //Get quality report
     MonitorElement* myQReport = dbe_->get(monitorName_+"FitFromScalars/BeamSpotError");

     const QReport * BeamSpotQReport = myQReport->getQReport("BeamSpotOnlineTest");  

    if(BeamSpotQReport){  
                          /* S.Dutta : Commenting out these variables are not used and giving error with "-Werror=unused-variable" option
                           float qtresult = BeamSpotQReport->getQTresult();
                           int qtstatus   = BeamSpotQReport->getStatus() ; // get QT status value (see table below) */
                           std::string qtmessage = BeamSpotQReport->getMessage() ; // get the whole QT result message
                      }


   Ntracks_= 0;

}

Member Data Documentation

Definition at line 83 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and FillPlots().

Definition at line 73 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and FillPlots().

Definition at line 72 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and FillPlots().

Definition at line 90 of file BeamSpotProblemMonitor.h.

Referenced by beginJob(), endJob(), endRun(), and FillPlots().

Definition at line 85 of file BeamSpotProblemMonitor.h.

Referenced by FillPlots().

Definition at line 84 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and FillPlots().

Definition at line 75 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), beginJob(), and FillPlots().

bool BeamSpotProblemMonitor::dcsTk[6] [private]

Definition at line 86 of file BeamSpotProblemMonitor.h.

Referenced by analyze().

Definition at line 69 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), beginRun(), and endRun().

Definition at line 71 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().

Definition at line 67 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and FillPlots().

std::map<TString, MonitorElement*> BeamSpotProblemMonitor::hs [private]

Definition at line 89 of file BeamSpotProblemMonitor.h.

Referenced by beginJob(), and FillPlots().

Definition at line 68 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor().

Definition at line 77 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor(), and beginLuminosityBlock().

std::string BeamSpotProblemMonitor::monitorName_ [private]

Definition at line 61 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), BeamSpotProblemMonitor(), beginJob(), and FillPlots().

Definition at line 66 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().

Definition at line 79 of file BeamSpotProblemMonitor.h.

Definition at line 65 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and FillPlots().

Definition at line 60 of file BeamSpotProblemMonitor.h.

Referenced by BeamSpotProblemMonitor().

Definition at line 80 of file BeamSpotProblemMonitor.h.

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

Definition at line 62 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().

Definition at line 63 of file BeamSpotProblemMonitor.h.

Referenced by analyze(), and BeamSpotProblemMonitor().