CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

SiPixelClusterSource Class Reference

#include <SiPixelClusterSource.h>

Inheritance diagram for SiPixelClusterSource:
edm::EDAnalyzer

List of all members.

Public Types

typedef edmNew::DetSet
< SiPixelCluster >
::const_iterator 
ClusterIterator

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginRun (const edm::Run &, edm::EventSetup const &)
virtual void bookMEs ()
virtual void buildStructure (edm::EventSetup const &)
virtual void endJob ()
 SiPixelClusterSource (const edm::ParameterSet &conf)
 ~SiPixelClusterSource ()

Private Attributes

int bigEventSize
MonitorElementbigFpixClusterEventRate
bool bladeOn
edm::ParameterSet conf_
bool diskOn
int eventNo
bool firstRun
bool isPIB
bool ladOn
bool layOn
int lumSec
MonitorElementmeClPosDisk1mz
MonitorElementmeClPosDisk1pz
MonitorElementmeClPosDisk2mz
MonitorElementmeClPosDisk2pz
MonitorElementmeClPosLayer1
MonitorElementmeClPosLayer2
MonitorElementmeClPosLayer3
bool modOn
int nBigEvents
int nLumiSecs
bool phiOn
bool reducedSet
bool ringOn
bool saveFile
bool slowDown
bool smileyOn
edm::InputTag src_
DQMStoretheDMBE
std::map< uint32_t,
SiPixelClusterModule * > 
thePixelStructure
bool twoDimOn

Detailed Description

Definition at line 60 of file SiPixelClusterSource.h.


Member Typedef Documentation

Definition at line 65 of file SiPixelClusterSource.h.


Constructor & Destructor Documentation

SiPixelClusterSource::SiPixelClusterSource ( const edm::ParameterSet conf) [explicit]

Definition at line 45 of file SiPixelClusterSource.cc.

References cmsCodeRules::cppFunctionSkipper::operator, and theDMBE.

                                                                         :
  conf_(iConfig),
  src_( conf_.getParameter<edm::InputTag>( "src" ) ),
  saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
  isPIB( conf_.getUntrackedParameter<bool>("isPIB",false) ),
  slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
  modOn( conf_.getUntrackedParameter<bool>("modOn",true) ),
  twoDimOn( conf_.getUntrackedParameter<bool>("twoDimOn",true) ),
  reducedSet( conf_.getUntrackedParameter<bool>("reducedSet",false) ),
  ladOn( conf_.getUntrackedParameter<bool>("ladOn",false) ), 
  layOn( conf_.getUntrackedParameter<bool>("layOn",false) ), 
  phiOn( conf_.getUntrackedParameter<bool>("phiOn",false) ), 
  ringOn( conf_.getUntrackedParameter<bool>("ringOn",false) ), 
  bladeOn( conf_.getUntrackedParameter<bool>("bladeOn",false) ), 
  diskOn( conf_.getUntrackedParameter<bool>("diskOn",false) ),
  smileyOn(conf_.getUntrackedParameter<bool>("smileyOn",false) ),
  bigEventSize( conf_.getUntrackedParameter<int>("bigEventSize",100) )
{
   theDMBE = edm::Service<DQMStore>().operator->();
   LogInfo ("PixelDQM") << "SiPixelClusterSource::SiPixelClusterSource: Got DQM BackEnd interface"<<endl;
}
SiPixelClusterSource::~SiPixelClusterSource ( )

Definition at line 68 of file SiPixelClusterSource.cc.

References thePixelStructure.

{
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)
  LogInfo ("PixelDQM") << "SiPixelClusterSource::~SiPixelClusterSource: Destructor"<<endl;

  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
  for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++){
    delete struct_iter->second;
    struct_iter->second = 0;
  }
}

Member Function Documentation

void SiPixelClusterSource::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 133 of file SiPixelClusterSource.cc.

References bigEventSize, bladeOn, diskOn, eventNo, MonitorElement::Fill(), edm::EventSetup::get(), DQMStore::get(), edm::Event::getByLabel(), MonitorElement::getEntries(), collect_tpl::input, ladOn, layOn, edm::EventBase::luminosityBlock(), modOn, phiOn, reducedSet, MonitorElement::Reset(), ringOn, slowDown, smileyOn, src_, theDMBE, thePixelStructure, patCandidatesForDimuonsSequences_cff::tracker, and twoDimOn.

{
  eventNo++;
  
  if(modOn){
    MonitorElement* meReset = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_1");
    MonitorElement* meReset1 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_2");
    MonitorElement* meReset2 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_Layer_3");
    MonitorElement* meReset3 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_1");
    MonitorElement* meReset4 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_mz_Disk_2");
    MonitorElement* meReset5 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_1");
    MonitorElement* meReset6 = theDMBE->get("Pixel/Clusters/OffTrack/position_siPixelClusters_pz_Disk_2");
    if(meReset && meReset->getEntries()>150000){
      meReset->Reset();
      meReset1->Reset();
      meReset2->Reset();
      meReset3->Reset();
      meReset4->Reset();
      meReset5->Reset();
      meReset6->Reset();
    }
  }
  
  // get input data
  edm::Handle< edmNew::DetSetVector<SiPixelCluster> >  input;
  iEvent.getByLabel( src_, input );

  edm::ESHandle<TrackerGeometry> pDD;
  iSetup.get<TrackerDigiGeometryRecord> ().get (pDD);
  const TrackerGeometry* tracker = &(* pDD);
//  const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(detId) );

  //float iOrbitSec = iEvent.orbitNumber()/11223.;
  //int bx = iEvent.bunchCrossing();
  //long long tbx = (long long)iEvent.orbitNumber() * 3564 + bx;
  int lumiSection = (int)iEvent.luminosityBlock();
  int nEventFpixClusters = 0;


  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
  for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++) {
    
    int numberOfFpixClusters = (*struct_iter).second->fill(*input, tracker,  modOn, 
                                                           ladOn, layOn, phiOn, 
                                                           bladeOn, diskOn, ringOn, 
                                                           twoDimOn, reducedSet, smileyOn);
    nEventFpixClusters = nEventFpixClusters + numberOfFpixClusters;    
    
  }

//  if(lumiSection>lumSec){ lumSec = lumiSection; nLumiSecs++; }
//  if(nEventFpixClusters>bigEventSize) nBigEvents++;
//  if(nLumiSecs%5==0){

  if(nEventFpixClusters>bigEventSize){
    MonitorElement* me = theDMBE->get("Pixel/bigFpixClusterEventRate");
    if(me){ 
      me->Fill(lumiSection,1./23.);    
    }
  }
  //std::cout<<"nEventFpixClusters: "<<nEventFpixClusters<<" , nLumiSecs: "<<nLumiSecs<<" , nBigEvents: "<<nBigEvents<<std::endl;
  
  // slow down...
  if(slowDown) usleep(10000);
  
}
void SiPixelClusterSource::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 82 of file SiPixelClusterSource.cc.

References firstRun.

                                   {
  firstRun = true;
}
void SiPixelClusterSource::beginRun ( const edm::Run r,
edm::EventSetup const &  iSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file SiPixelClusterSource.cc.

References bladeOn, DQMStore::book2D(), bookMEs(), buildStructure(), diskOn, eventNo, firstRun, ladOn, layOn, lumSec, meClPosDisk1mz, meClPosDisk1pz, meClPosDisk2mz, meClPosDisk2pz, meClPosLayer1, meClPosLayer2, meClPosLayer3, modOn, nBigEvents, nLumiSecs, phiOn, ringOn, DQMStore::setCurrentFolder(), smileyOn, theDMBE, and twoDimOn.

                                                                               {

  LogInfo ("PixelDQM") << " SiPixelClusterSource::beginJob - Initialisation ... " << std::endl;
  LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/" 
            << layOn << "/" << phiOn << std::endl;
  LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/" 
            << ringOn << std::endl;
  LogInfo ("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
  LogInfo ("PixelDQM") << "Smiley (Cluster sizeY vs. Cluster eta) is " << smileyOn << "\n";

  if(firstRun){
    eventNo = 0;
    lumSec = 0;
    nLumiSecs = 0;
    nBigEvents = 0;
    // Build map
    buildStructure(iSetup);
    // Book Monitoring Elements
    bookMEs();
    // Book occupancy maps in global coordinates for all clusters:
    theDMBE->setCurrentFolder("Pixel/Clusters/OffTrack");
    //bpix
    meClPosLayer1 = theDMBE->book2D("position_siPixelClusters_Layer_1","Clusters Layer1;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
    meClPosLayer2 = theDMBE->book2D("position_siPixelClusters_Layer_2","Clusters Layer2;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
    meClPosLayer3 = theDMBE->book2D("position_siPixelClusters_Layer_3","Clusters Layer3;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
    //fpix
    meClPosDisk1pz = theDMBE->book2D("position_siPixelClusters_pz_Disk_1","Clusters +Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
    meClPosDisk2pz = theDMBE->book2D("position_siPixelClusters_pz_Disk_2","Clusters +Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
    meClPosDisk1mz = theDMBE->book2D("position_siPixelClusters_mz_Disk_1","Clusters -Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
    meClPosDisk2mz = theDMBE->book2D("position_siPixelClusters_mz_Disk_2","Clusters -Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
    
    firstRun = false;
  }
}
void SiPixelClusterSource::bookMEs ( ) [virtual]

Create folder tree and book histograms

Definition at line 263 of file SiPixelClusterSource.cc.

References bigEventSize, bigFpixClusterEventRate, bladeOn, DQMStore::book1D(), conf_, diskOn, Exception, isPIB, ladOn, layOn, LogDebug, modOn, cmsCodeRules::cppFunctionSkipper::operator, phiOn, reducedSet, ringOn, DQMStore::setCurrentFolder(), SiPixelFolderOrganizer::setModuleFolder(), smileyOn, theDMBE, thePixelStructure, indexGen::title, and twoDimOn.

Referenced by beginRun().

                                  {
  
  // Get DQM interface
  DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
  theDMBE->setCurrentFolder("Pixel");
  char title[256]; snprintf(title, 256, "Rate of events with >%i FPIX clusters;LumiSection;Rate of large FPIX events per LS [Hz]",bigEventSize);
  bigFpixClusterEventRate = theDMBE->book1D("bigFpixClusterEventRate",title,5000,0.,5000.);


  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
    
  SiPixelFolderOrganizer theSiPixelFolder;
  
  for(struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++){
    
    if(modOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first)){
        (*struct_iter).second->book( conf_,0,twoDimOn,reducedSet);
      } else {
        
        if(!isPIB) throw cms::Exception("LogicError")
          << "[SiPixelClusterSource::bookMEs] Creation of DQM folder failed";
      }
    }
    if(ladOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,1)){
        (*struct_iter).second->book( conf_,1,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
      }
    }
    if(layOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,2)){
        (*struct_iter).second->book( conf_,2,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
      }
    }
    if(phiOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,3)){
        (*struct_iter).second->book( conf_,3,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
      }
    }
    if(bladeOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,4)){
        (*struct_iter).second->book( conf_,4,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
      }
    }
    if(diskOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,5)){
        (*struct_iter).second->book( conf_,5,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
      }
    }
    if(ringOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,6)){
        (*struct_iter).second->book( conf_,6,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
      }
    }
    if(smileyOn){
      if(theSiPixelFolder.setModuleFolder((*struct_iter).first,7)){
        (*struct_iter).second->book( conf_,7,twoDimOn,reducedSet);
        } else {
        LogDebug ("PixelDQM") << "PROBLEM WITH BARREL-FOLDER\n";
      }
    }

  }

}
void SiPixelClusterSource::buildStructure ( edm::EventSetup const &  iSetup) [virtual]

Definition at line 203 of file SiPixelClusterSource.cc.

References PixelEndcapName::bladeName(), PixelEndcapName::diskName(), edm::EventSetup::get(), PixelEndcapName::halfCylinder(), isPIB, LogDebug, PixelEndcapName::pannelName(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, PixelEndcapName::plaquetteName(), DetId::rawId(), PixelGeomDetUnit::specificTopology(), DetId::subdetId(), and thePixelStructure.

Referenced by beginRun().

                                                                    {

  LogInfo ("PixelDQM") <<" SiPixelClusterSource::buildStructure" ;
  edm::ESHandle<TrackerGeometry> pDD;
  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );

  LogVerbatim ("PixelDQM") << " *** Geometry node for TrackerGeom is  "<<&(*pDD)<<std::endl;
  LogVerbatim ("PixelDQM") << " *** I have " << pDD->dets().size() <<" detectors"<<std::endl;
  LogVerbatim ("PixelDQM") << " *** I have " << pDD->detTypes().size() <<" types"<<std::endl;
  
  for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
    
    if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){

      DetId detId = (*it)->geographicalId();
      const GeomDetUnit      * geoUnit = pDD->idToDetUnit( detId );
      const PixelGeomDetUnit * pixDet  = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
      int nrows = (pixDet->specificTopology()).nrows();
      int ncols = (pixDet->specificTopology()).ncolumns();

      
      if((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
         (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))){ 
        uint32_t id = detId();
        SiPixelClusterModule* theModule = new SiPixelClusterModule(id, ncols, nrows);
        if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
          if(isPIB) continue;
          LogDebug ("PixelDQM") << " ---> Adding Barrel Module " <<  detId.rawId() << endl;
          thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
        }else if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
          LogDebug ("PixelDQM") << " ---> Adding Endcap Module " <<  detId.rawId() << endl;
          PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(id)).halfCylinder();
          int disk   = PixelEndcapName(DetId(id)).diskName();
          int blade  = PixelEndcapName(DetId(id)).bladeName();
          int panel  = PixelEndcapName(DetId(id)).pannelName();
          int module = PixelEndcapName(DetId(id)).plaquetteName();
          char sside[80];  sprintf(sside,  "HalfCylinder_%i",side);
          char sdisk[80];  sprintf(sdisk,  "Disk_%i",disk);
          char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
          char spanel[80]; sprintf(spanel, "Panel_%i",panel);
          char smodule[80];sprintf(smodule,"Module_%i",module);
          std::string side_str = sside;
          std::string disk_str = sdisk;
          bool mask = side_str.find("HalfCylinder_1")!=string::npos||
                      side_str.find("HalfCylinder_2")!=string::npos||
                      side_str.find("HalfCylinder_4")!=string::npos||
                      disk_str.find("Disk_2")!=string::npos;
          // clutch to take all of FPIX, but no BPIX:
          mask = false;
          if(isPIB && mask) continue;
          thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
        }
      }
    }
  }
  LogInfo ("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
}
void SiPixelClusterSource::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 122 of file SiPixelClusterSource.cc.

References conf_, edm::ParameterSet::getParameter(), download_sqlite_cfg::outputFile, DQMStore::save(), saveFile, and theDMBE.

                                     {
  if(saveFile){
    LogInfo ("PixelDQM") << " SiPixelClusterSource::endJob - Saving Root File " << std::endl;
    std::string outputFile = conf_.getParameter<std::string>("outputFile");
    theDMBE->save( outputFile.c_str() );
  }
}

Member Data Documentation

Definition at line 97 of file SiPixelClusterSource.h.

Referenced by analyze(), and bookMEs().

Definition at line 96 of file SiPixelClusterSource.h.

Referenced by bookMEs().

Definition at line 90 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 76 of file SiPixelClusterSource.h.

Referenced by bookMEs(), and endJob().

Definition at line 90 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 81 of file SiPixelClusterSource.h.

Referenced by analyze(), and beginRun().

Definition at line 92 of file SiPixelClusterSource.h.

Referenced by beginJob(), and beginRun().

Definition at line 79 of file SiPixelClusterSource.h.

Referenced by bookMEs(), and buildStructure().

Definition at line 88 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 88 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 93 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 104 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 102 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 105 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 103 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 99 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 100 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 101 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 84 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 95 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 94 of file SiPixelClusterSource.h.

Referenced by beginRun().

Definition at line 88 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 86 of file SiPixelClusterSource.h.

Referenced by analyze(), and bookMEs().

Definition at line 90 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 78 of file SiPixelClusterSource.h.

Referenced by endJob().

Definition at line 80 of file SiPixelClusterSource.h.

Referenced by analyze().

Definition at line 91 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().

Definition at line 77 of file SiPixelClusterSource.h.

Referenced by analyze().

Definition at line 82 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), bookMEs(), endJob(), and SiPixelClusterSource().

Definition at line 83 of file SiPixelClusterSource.h.

Referenced by analyze(), bookMEs(), buildStructure(), and ~SiPixelClusterSource().

Definition at line 85 of file SiPixelClusterSource.h.

Referenced by analyze(), beginRun(), and bookMEs().