CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTSegmentAnalysisTask Class Reference

#include <DTSegmentAnalysisTask.h>

Inheritance diagram for DTSegmentAnalysisTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup)
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
 Summary.
void beginRun (const edm::Run &, const edm::EventSetup &)
 BeginRun.
 DTSegmentAnalysisTask (const edm::ParameterSet &pset)
 Constructor.
void endJob ()
 Endjob.
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
virtual ~DTSegmentAnalysisTask ()
 Destructor.

Private Member Functions

void bookHistos (DTChamberId chamberId)
void fillHistos (DTChamberId chamberId, int nHits, float chi2)

Private Attributes

bool checkNoisyChannels
bool detailedAnalysis
edm::ESHandle< DTGeometrydtGeom
std::map< DTChamberId,
std::vector< MonitorElement * > > 
histosPerCh
std::map< int, std::map< int,
DTTimeEvolutionHisto * > > 
histoTimeEvol
bool hltDQMMode
DTTimeEvolutionHistohNevtPerLS
int nEventsInLS
int nLSTimeBin
int nTimeBins
edm::ParameterSet parameters
bool slideTimeBins
std::map< int, MonitorElement * > summaryHistos
DQMStoretheDbe
std::string theRecHits4DLabel
std::string topHistoFolder

Detailed Description

DQM Analysis of 4D DT segments, it produces plots about:

Date:
2010/01/05 10:14:40
Revision:
1.11
Author:
G. Cerminara - INFN Torino

Definition at line 36 of file DTSegmentAnalysisTask.h.


Constructor & Destructor Documentation

DTSegmentAnalysisTask::DTSegmentAnalysisTask ( const edm::ParameterSet pset)

Constructor.

Definition at line 43 of file DTSegmentAnalysisTask.cc.

References checkNoisyChannels, detailedAnalysis, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hltDQMMode, nLSTimeBin, nTimeBins, cmsCodeRules::cppFunctionSkipper::operator, slideTimeBins, theDbe, theRecHits4DLabel, and topHistoFolder.

                                                                        : nEventsInLS(0), hNevtPerLS(0) {

  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "[DTSegmentAnalysisTask] Constructor called!";

  // switch for detailed analysis
  detailedAnalysis = pset.getUntrackedParameter<bool>("detailedAnalysis","false");
  // the name of the 4D rec hits collection
  theRecHits4DLabel = pset.getParameter<string>("recHits4DLabel");
  // Get the map of noisy channels
  checkNoisyChannels = pset.getUntrackedParameter<bool>("checkNoisyChannels","false");
  // # of bins in the time histos
  nTimeBins = pset.getUntrackedParameter<int>("nTimeBins",100);
  // # of LS per bin in the time histos
  nLSTimeBin = pset.getUntrackedParameter<int>("nLSTimeBin",2);
  // switch on/off sliding bins in time histos
  slideTimeBins = pset.getUntrackedParameter<bool>("slideTimeBins",true);

  // Get the DQM needed services
  theDbe = edm::Service<DQMStore>().operator->();
  
  // top folder for the histograms in DQMStore
  topHistoFolder = pset.getUntrackedParameter<string>("topHistoFolder","DT/02-Segments");
  // hlt DQM mode
  hltDQMMode = pset.getUntrackedParameter<bool>("hltDQMMode",false);

 }
DTSegmentAnalysisTask::~DTSegmentAnalysisTask ( ) [virtual]

Destructor.

Definition at line 71 of file DTSegmentAnalysisTask.cc.

                                             {
    edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "[DTSegmentAnalysisTask] Destructor called!";
}

Member Function Documentation

void DTSegmentAnalysisTask::analyze ( const edm::Event event,
const edm::EventSetup setup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 126 of file DTSegmentAnalysisTask.cc.

References checkNoisyChannels, edm::EventID::event(), fillHistos(), edm::EventSetup::get(), edm::EventBase::id(), edm::HandleBase::isValid(), nEventsInLS, findQualityFiles::size, DTRecSegment2D::specificRecHits(), crabStatusFromReport::statusMap, and theRecHits4DLabel.

                                                                                     {
  nEventsInLS++;
  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "[DTSegmentAnalysisTask] Analyze #Run: " << event.id().run()
                               << " #Event: " << event.id().event();
  if(!(event.id().event()%1000))
    edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "[DTSegmentAnalysisTask] Analyze #Run: " << event.id().run()
                                 << " #Event: " << event.id().event();
  
  ESHandle<DTStatusFlag> statusMap;
  if(checkNoisyChannels) {
    setup.get<DTStatusFlagRcd>().get(statusMap);
  } 


  // -- 4D segment analysis  -----------------------------------------------------
  
  // Get the 4D segment collection from the event
  edm::Handle<DTRecSegment4DCollection> all4DSegments;
  event.getByLabel(theRecHits4DLabel, all4DSegments);

  if(!all4DSegments.isValid()) return;
  
  // Loop over all chambers containing a segment
  DTRecSegment4DCollection::id_iterator chamberId;
  for (chamberId = all4DSegments->id_begin();
       chamberId != all4DSegments->id_end();
       ++chamberId){
    // Get the range for the corresponding ChamerId
    DTRecSegment4DCollection::range  range = all4DSegments->get(*chamberId);

    edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "   Chamber: " << *chamberId << " has " << distance(range.first, range.second)
                                 << " 4D segments";

    // Loop over the rechits of this ChamerId
    for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
         segment4D!=range.second;
           ++segment4D){

      //FOR NOISY CHANNELS////////////////////////////////
     bool segmNoisy = false;
     if(checkNoisyChannels) {
       
       if((*segment4D).hasPhi()){
         const DTChamberRecSegment2D* phiSeg = (*segment4D).phiSegment();
         vector<DTRecHit1D> phiHits = phiSeg->specificRecHits();
         map<DTSuperLayerId,vector<DTRecHit1D> > hitsBySLMap; 
         for(vector<DTRecHit1D>::const_iterator hit = phiHits.begin();
             hit != phiHits.end(); ++hit) {
           DTWireId wireId = (*hit).wireId();
           
           // Check for noisy channels to skip them
           bool isNoisy = false;
           bool isFEMasked = false;
           bool isTDCMasked = false;
           bool isTrigMask = false;
           bool isDead = false;
           bool isNohv = false;
           statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
           if(isNoisy) {
             edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "Wire: " << wireId << " is noisy, skipping!";
             segmNoisy = true;
           }      
         }
       }
       
       if((*segment4D).hasZed()) {
         const DTSLRecSegment2D* zSeg = (*segment4D).zSegment();  // zSeg lives in the SL RF
         // Check for noisy channels to skip them
         vector<DTRecHit1D> zHits = zSeg->specificRecHits();
         for(vector<DTRecHit1D>::const_iterator hit = zHits.begin();
             hit != zHits.end(); ++hit) {
           DTWireId wireId = (*hit).wireId();
           bool isNoisy = false;
           bool isFEMasked = false;
           bool isTDCMasked = false;
           bool isTrigMask = false;
           bool isDead = false;
           bool isNohv = false;
           statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
           if(isNoisy) {
             edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "Wire: " << wireId << " is noisy, skipping!";
             segmNoisy = true;
           }     
         }
       } 

     } // end of switch on noisy channels
     if (segmNoisy) {
       edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask")<<"skipping the segment: it contains noisy cells";
       continue;
     }
     //END FOR NOISY CHANNELS////////////////////////////////
      
     int nHits=0;
     LocalPoint segment4DLocalPos = (*segment4D).localPosition();
     LocalVector segment4DLocalDirection = (*segment4D).localDirection();
     if((*segment4D).hasPhi())
       nHits = (((*segment4D).phiSegment())->specificRecHits()).size();
     if((*segment4D).hasZed()) 
       nHits = nHits + ((((*segment4D).zSegment())->specificRecHits()).size());
      
     fillHistos(*chamberId,
                nHits,
                (*segment4D).chi2()/(*segment4D).degreesOfFreedom());
    }
  }

  // -----------------------------------------------------------------------------
}
void DTSegmentAnalysisTask::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  eSetup 
) [virtual]

Summary.

Reimplemented from edm::EDAnalyzer.

Definition at line 332 of file DTSegmentAnalysisTask.cc.

References nEventsInLS.

                                                                                                         {
  nEventsInLS = 0;
}
void DTSegmentAnalysisTask::beginRun ( const edm::Run run,
const edm::EventSetup context 
) [virtual]

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 76 of file DTSegmentAnalysisTask.cc.

References bookHistos(), chambers, dtGeom, edm::EventSetup::get(), histoTimeEvol, hltDQMMode, hNevtPerLS, nLSTimeBin, nTimeBins, DQMStore::setCurrentFolder(), slideTimeBins, theDbe, and topHistoFolder.

                                                                                { 

   // Get the DT Geometry
  context.get<MuonGeometryRecord>().get(dtGeom);

  // loop over all the DT chambers & book the histos
  vector<DTChamber*> chambers = dtGeom->chambers();
  vector<DTChamber*>::const_iterator ch_it = chambers.begin();
  vector<DTChamber*>::const_iterator ch_end = chambers.end();
  for (; ch_it != ch_end; ++ch_it) {
    bookHistos((*ch_it)->id());
  }

  // book sector time-evolution histos
  int modeTimeHisto = 0;
  if(!slideTimeBins) modeTimeHisto = 1;
  for(int wheel = -2; wheel != 3; ++wheel) { // loop over wheels
    for(int sector = 1; sector <= 12; ++sector) { // loop over sectors
      stringstream wheelstr; wheelstr << wheel; 
      stringstream sectorstr; sectorstr << sector;
      string sectorHistoName = "NSegmPerEvent_W" + wheelstr.str()
        + "_Sec" + sectorstr.str();
      string sectorHistoTitle = "# segm. W" + wheelstr.str() + " Sect." + sectorstr.str();

      theDbe->setCurrentFolder(topHistoFolder + "/Wheel" + wheelstr.str() +
                               "/Sector" + sectorstr.str());
      histoTimeEvol[wheel][sector] = new DTTimeEvolutionHisto(&(*theDbe),sectorHistoName,sectorHistoTitle,
                                                              nTimeBins,nLSTimeBin,slideTimeBins,modeTimeHisto);
    }
  }

  if(hltDQMMode) theDbe->setCurrentFolder(topHistoFolder);
  else theDbe->setCurrentFolder("DT/EventInfo/");

  hNevtPerLS = new DTTimeEvolutionHisto(&(*theDbe),"NevtPerLS","# evt.",nTimeBins,nLSTimeBin,slideTimeBins,2);

}
void DTSegmentAnalysisTask::bookHistos ( DTChamberId  chamberId) [private]

Definition at line 238 of file DTSegmentAnalysisTask.cc.

References DQMStore::book1D(), DQMStore::book2D(), detailedAnalysis, mergeVDriftHistosByStation::histos, histosPerCh, DTChamberId::sector(), DQMStore::setCurrentFolder(), relativeConstraints::station, DTChamberId::station(), summaryHistos, theDbe, topHistoFolder, and DTChamberId::wheel().

Referenced by beginRun().

                                                            {

  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") << "   Booking histos for chamber: " << chamberId;


  // Compose the chamber name
  stringstream wheel; wheel << chamberId.wheel();       
  stringstream station; station << chamberId.station(); 
  stringstream sector; sector << chamberId.sector();
  
  string chamberHistoName =
    "_W" + wheel.str() +
    "_St" + station.str() +
    "_Sec" + sector.str();
  

  for(int wh=-2; wh<=2; wh++){
    stringstream wheel; wheel << wh;
    theDbe->setCurrentFolder(topHistoFolder + "/Wheel" + wheel.str());
    string histoName =  "numberOfSegments_W" + wheel.str();
    summaryHistos[wh] = theDbe->book2D(histoName.c_str(),histoName.c_str(),12,1,13,4,1,5);
    summaryHistos[wh]->setAxisTitle("Sector",1);
    summaryHistos[wh]->setBinLabel(1,"1",1);
    summaryHistos[wh]->setBinLabel(2,"2",1);
    summaryHistos[wh]->setBinLabel(3,"3",1);
    summaryHistos[wh]->setBinLabel(4,"4",1);
    summaryHistos[wh]->setBinLabel(5,"5",1);
    summaryHistos[wh]->setBinLabel(6,"6",1);
    summaryHistos[wh]->setBinLabel(7,"7",1);
    summaryHistos[wh]->setBinLabel(8,"8",1);
    summaryHistos[wh]->setBinLabel(9,"9",1);
    summaryHistos[wh]->setBinLabel(10,"10",1);
    summaryHistos[wh]->setBinLabel(11,"11",1);
    summaryHistos[wh]->setBinLabel(12,"12",1);
    summaryHistos[wh]->setBinLabel(1,"MB1",2);
    summaryHistos[wh]->setBinLabel(2,"MB2",2);
    summaryHistos[wh]->setBinLabel(3,"MB3",2);
    summaryHistos[wh]->setBinLabel(4,"MB4",2);  
  }


  theDbe->setCurrentFolder(topHistoFolder + "/Wheel" + wheel.str() +
                           "/Sector" + sector.str() +
                           "/Station" + station.str());

  // Create the monitor elements
  vector<MonitorElement *> histos;
  histos.push_back(theDbe->book1D("h4DSegmNHits"+chamberHistoName,
                                  "# of hits per segment",
                                  16, 0.5, 16.5));
  if(detailedAnalysis){
    histos.push_back(theDbe->book1D("h4DChi2"+chamberHistoName,
                                    "4D Segment reduced Chi2",
                                    20, 0, 20));
  }
  histosPerCh[chamberId] = histos;
}
void DTSegmentAnalysisTask::endJob ( void  ) [virtual]

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 115 of file DTSegmentAnalysisTask.cc.

References hNevtPerLS.

                                   {
 
  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTSegmentAnalysisTask") <<"[DTSegmentAnalysisTask] endjob called!";

  delete hNevtPerLS;
  //theDbe->save("testMonitoring.root");

}
void DTSegmentAnalysisTask::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  eSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 320 of file DTSegmentAnalysisTask.cc.

References histoTimeEvol, hNevtPerLS, edm::LuminosityBlockBase::luminosityBlock(), nEventsInLS, and DTTimeEvolutionHisto::updateTimeSlot().

                                                                                                       {

  hNevtPerLS->updateTimeSlot(lumiSeg.luminosityBlock(), nEventsInLS);
 // book sector time-evolution histos
  for(int wheel = -2; wheel != 3; ++wheel) {
    for(int sector = 1; sector <= 12; ++sector) {
      histoTimeEvol[wheel][sector]->updateTimeSlot(lumiSeg.luminosityBlock(), nEventsInLS);
    }
  }
}
void DTSegmentAnalysisTask::fillHistos ( DTChamberId  chamberId,
int  nHits,
float  chi2 
) [private]

Definition at line 298 of file DTSegmentAnalysisTask.cc.

References detailedAnalysis, mergeVDriftHistosByStation::histos, histosPerCh, histoTimeEvol, DTChamberId::sector(), DTChamberId::station(), summaryHistos, and DTChamberId::wheel().

Referenced by analyze().

                                               {
  int sector = chamberId.sector();
  if(chamberId.sector()==13) {
    sector = 4;
  } else if(chamberId.sector()==14) {
     sector = 10;
  }

  summaryHistos[chamberId.wheel()]->Fill(sector,chamberId.station());
  histoTimeEvol[chamberId.wheel()][sector]->accumulateValueTimeSlot(1);

  vector<MonitorElement *> histos =  histosPerCh[chamberId];                          
  histos[0]->Fill(nHits);
  if(detailedAnalysis){
    histos[1]->Fill(chi2);
  }

}

Member Data Documentation

Definition at line 74 of file DTSegmentAnalysisTask.h.

Referenced by analyze(), and DTSegmentAnalysisTask().

Definition at line 65 of file DTSegmentAnalysisTask.h.

Referenced by bookHistos(), DTSegmentAnalysisTask(), and fillHistos().

Definition at line 68 of file DTSegmentAnalysisTask.h.

Referenced by beginRun().

std::map<DTChamberId, std::vector<MonitorElement*> > DTSegmentAnalysisTask::histosPerCh [private]

Definition at line 86 of file DTSegmentAnalysisTask.h.

Referenced by bookHistos(), and fillHistos().

std::map<int, std::map<int, DTTimeEvolutionHisto*> > DTSegmentAnalysisTask::histoTimeEvol [private]

Definition at line 88 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), endLuminosityBlock(), and fillHistos().

Definition at line 102 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), and DTSegmentAnalysisTask().

Definition at line 91 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), endJob(), and endLuminosityBlock().

Definition at line 90 of file DTSegmentAnalysisTask.h.

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

Definition at line 96 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), and DTSegmentAnalysisTask().

Definition at line 94 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), and DTSegmentAnalysisTask().

Definition at line 76 of file DTSegmentAnalysisTask.h.

Definition at line 98 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), and DTSegmentAnalysisTask().

Definition at line 87 of file DTSegmentAnalysisTask.h.

Referenced by bookHistos(), and fillHistos().

Definition at line 62 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), bookHistos(), and DTSegmentAnalysisTask().

Definition at line 71 of file DTSegmentAnalysisTask.h.

Referenced by analyze(), and DTSegmentAnalysisTask().

Definition at line 100 of file DTSegmentAnalysisTask.h.

Referenced by beginRun(), bookHistos(), and DTSegmentAnalysisTask().