CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

DTDigiForNoiseTask Class Reference

#include <DTDigiForNoiseTask.h>

Inheritance diagram for DTDigiForNoiseTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

 DTDigiForNoiseTask (const edm::ParameterSet &ps)
 Constructor.
virtual ~DTDigiForNoiseTask ()
 Destructor.

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze.
void beginJob ()
 BeginJob.
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 To reset the MEs.
void beginRun (const edm::Run &, const edm::EventSetup &)
 BeginRun.
void bookHistos (const DTLayerId &dtSL)
 Book the ME.
void endJob ()
 Endjob.

Private Attributes

DQMStoredbe
bool debug
std::map< DTLayerId,
MonitorElement * > 
digiHistos
edm::ESHandle< DTGeometrymuonGeom
int nevents
edm::ParameterSet parameters

Detailed Description

Definition at line 39 of file DTDigiForNoiseTask.h.


Constructor & Destructor Documentation

DTDigiForNoiseTask::DTDigiForNoiseTask ( const edm::ParameterSet ps)

Constructor.

Definition at line 38 of file DTDigiForNoiseTask.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getUntrackedParameter(), cmsCodeRules::cppFunctionSkipper::operator, and Parameters::parameters.

                                                               {
  
  debug = ps.getUntrackedParameter<bool>("debug", false);
  if(debug)
    cout<<"[DTDigiForNoiseTask]: Constructor"<<endl;

  parameters = ps;
  
  dbe = edm::Service<DQMStore>().operator->();

}
DTDigiForNoiseTask::~DTDigiForNoiseTask ( ) [virtual]

Destructor.

Definition at line 51 of file DTDigiForNoiseTask.cc.

References gather_cfg::cout, debug, and nevents.

                                       {

  if(debug)
    cout << "DTDigiForNoiseTask: analyzed " << nevents << " events" << endl;

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 145 of file DTDigiForNoiseTask.cc.

References bookHistos(), debug, DTTopology::firstChannel(), edm::Event::getByLabel(), DTTopology::lastChannel(), and nevents.

                                                                         {
  
  nevents++;
  //  cout << "events:  " << nevents << endl;
  if (nevents%1000 == 0 && debug) {}
  
  edm::Handle<DTDigiCollection> dtdigis;
  e.getByLabel("dtunpacker", dtdigis);

  std::map< int,int > DigiPerWirePerEvent;
  
  // Loop over all the chambers
  vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
  vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
  // Loop over the SLs
  for (; ch_it != ch_end; ++ch_it) {
    //    DTChamberId ch = (*ch_it)->id();
    vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin(); 
    vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
    // Loop over the SLs
    for(; sl_it != sl_end; ++sl_it) {
      vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin(); 
      vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
      // Loop over the Ls
      for(; l_it != l_end; ++l_it) {
        DTLayerId layerId = (*l_it)->id();

        DTDigiCollection::Range layerDigi= dtdigis->get(layerId);
        if(layerDigi.first != layerDigi.second){

          const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
          const int firstWire = dtTopo.firstChannel();
          const int lastWire = dtTopo.lastChannel();
          
          if (digiHistos.find(layerId) == digiHistos.end())
            bookHistos(layerId);
          
          if (digiHistos.find(layerId) != digiHistos.end()){
            for (int wire=firstWire; wire<=lastWire; wire++) {
              DigiPerWirePerEvent[wire]= 0;
            }

            for (DTDigiCollection::const_iterator digi = layerDigi.first;
                 digi!=layerDigi.second;
                 ++digi){
              DigiPerWirePerEvent[(*digi).wire()]+=1;
            }

            for (int wire=firstWire; wire<=lastWire; wire++) {
              digiHistos.find(layerId)->second->Fill(wire,DigiPerWirePerEvent[wire]);
            }
          }
        }

      } //Loop Ls
    } //Loop SLs
  } //Loop over chambers
   
}
void DTDigiForNoiseTask::beginJob ( void  ) [protected, virtual]

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file DTDigiForNoiseTask.cc.

References gather_cfg::cout, debug, and nevents.

                                 {

  if(debug)
    cout<<"[DTDigiForNoiseTask]: BeginJob"<<endl;

  nevents = 0;

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

To reset the MEs.

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file DTDigiForNoiseTask.cc.

References gather_cfg::cout, debug, timingPdfMaker::histo, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), and Parameters::parameters.

                                                                                                       {
  
  if(debug)
    cout<<"[DTDigiForNoiseTask]: Begin of LS transition"<<endl;
  
  if(lumiSeg.id().luminosityBlock()%parameters.getUntrackedParameter<int>("ResetCycle", 3) == 0) {
    for(map< DTLayerId, MonitorElement* > ::const_iterator histo = digiHistos.begin();
        histo != digiHistos.end();
        histo++) {
      (*histo).second->Reset();
    }
  }
  
}
void DTDigiForNoiseTask::beginRun ( const edm::Run run,
const edm::EventSetup context 
) [protected, virtual]

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 78 of file DTDigiForNoiseTask.cc.

References gather_cfg::cout, debug, and edm::EventSetup::get().

                                                                                 {

  if(debug)
    cout<<"[DTDigiForNoiseTask]: BeginRun"<<endl;

  // Get the geometry
  context.get<MuonGeometryRecord>().get(muonGeom);

}
void DTDigiForNoiseTask::bookHistos ( const DTLayerId dtSL) [protected]

Book the ME.

Definition at line 104 of file DTDigiForNoiseTask.cc.

References DTSuperLayerId::chamberId(), gather_cfg::cout, debug, DTTopology::firstChannel(), DTTopology::lastChannel(), DTLayerId::layer(), DTChamberId::sector(), relativeConstraints::station, DTChamberId::station(), DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), and DTChamberId::wheel().

                                                        {
  
  if (debug) cout<<"[DTDigiForNoiseTask]: booking"<<endl;

  const  DTSuperLayerId dtSLId = lId.superlayerId();
  const  DTChamberId dtChId = dtSLId.chamberId(); 
  stringstream layer; layer << lId.layer();
  stringstream superLayer; superLayer << dtSLId.superlayer();
  stringstream wheel; wheel << dtChId.wheel();  
  stringstream station; station << dtChId.station();    
  stringstream sector; sector << dtChId.sector();

  dbe->setCurrentFolder("DT/DTDigiForNoiseTask/Wheel" + wheel.str() +
                        "/Station" + station.str() +
                        "/Sector" + sector.str() + "/DigiPerEvent");

  if (debug){
    cout<<"[DTDigiForNoiseTask]: folder "<< "DT/DTDigiTask/Wheel" + wheel.str() +
      "/Station" + station.str() +
      "/Sector" + sector.str() + "/DigiPerEvent"<<endl;
  }
  
  string histoName =
    "DigiPerEvent_W" + wheel.str() 
    + "_St" + station.str() 
    + "_Sec" + sector.str()
    + "_SL" + superLayer.str()  
    + "_L" + layer.str();
  
  if (debug) cout<<"[DTDigiTask]: histoName "<<histoName<<endl;

  const DTTopology& dtTopo = muonGeom->layer(lId)->specificTopology();
  const int firstWire = dtTopo.firstChannel();
  const int lastWire = dtTopo.lastChannel();
  int nWires = lastWire-firstWire+1;
  
  digiHistos[lId] = dbe->book2D(histoName,histoName,nWires,firstWire,lastWire,10,-0.5,9.5);

}
void DTDigiForNoiseTask::endJob ( void  ) [protected, virtual]

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 59 of file DTDigiForNoiseTask.cc.

References gather_cfg::cout, and debug.

                               {

  if(debug)
    cout<<"[DTDigiForNoiseTask] endjob called!"<<endl;

  dbe->rmdir("DT/DTDigiForNoiseTask");

}

Member Data Documentation

Definition at line 74 of file DTDigiForNoiseTask.h.

bool DTDigiForNoiseTask::debug [private]

Definition at line 71 of file DTDigiForNoiseTask.h.

Definition at line 80 of file DTDigiForNoiseTask.h.

Definition at line 78 of file DTDigiForNoiseTask.h.

Definition at line 72 of file DTDigiForNoiseTask.h.

Definition at line 76 of file DTDigiForNoiseTask.h.