CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CastorLEDMonitor Class Reference

#include <CastorLEDMonitor.h>

Inheritance diagram for CastorLEDMonitor:
CastorBaseMonitor

List of all members.

Public Member Functions

 CastorLEDMonitor ()
void done ()
void processEvent (const CastorDigiCollection &cast, const CastorDbService &cond)
void reset ()
void setup (const edm::ParameterSet &ps, DQMStore *dbe)
 ~CastorLEDMonitor ()

Private Member Functions

void createFEDmap (unsigned int fed)
void perChanHists (const HcalCastorDetId DetID, float *vals, std::map< HcalCastorDetId, MonitorElement * > &tShape, std::map< HcalCastorDetId, MonitorElement * > &tTime, std::map< HcalCastorDetId, MonitorElement * > &tEnergy, std::string baseFolder)

Private Attributes

float adcThresh_
CastorCalibrations calibs_
struct {
   std::map< HcalCastorDetId,
MonitorElement * >   energy
   MonitorElement *   energyALL
   MonitorElement *   mean_energy
   MonitorElement *   mean_shape
   MonitorElement *   mean_time
   MonitorElement *   rms_energy
   MonitorElement *   rms_shape
   MonitorElement *   rms_time
   std::map< HcalCastorDetId,
MonitorElement * >   shape
   MonitorElement *   shapeALL
   MonitorElement *   shapePED
   std::map< HcalCastorDetId,
MonitorElement * >   time
   MonitorElement *   timeALL
castHists
bool doPerChannel_
std::map< unsigned int,
MonitorElement * >::iterator 
fedIter
int ievt_
int jevt_
std::map< unsigned int,
MonitorElement * > 
MEAN_MAP_ENERGY_DCC
std::map< unsigned int,
MonitorElement * > 
MEAN_MAP_SHAPE_DCC
std::map< unsigned int,
MonitorElement * > 
MEAN_MAP_TIME_DCC
MonitorElementMEAN_MAP_TIME_L1
MonitorElementMEAN_MAP_TIME_L2
MonitorElementMEAN_MAP_TIME_L3
MonitorElementMEAN_MAP_TIME_L4
MonitorElementmeEVT_
std::map< HcalCastorDetId,
MonitorElement * >::iterator 
meIter
std::map< unsigned int,
MonitorElement * > 
RMS_MAP_ENERGY_DCC
std::map< unsigned int,
MonitorElement * > 
RMS_MAP_SHAPE_DCC
std::map< unsigned int,
MonitorElement * > 
RMS_MAP_TIME_DCC
MonitorElementRMS_MAP_TIME_L1
MonitorElementRMS_MAP_TIME_L2
MonitorElementRMS_MAP_TIME_L3
MonitorElementRMS_MAP_TIME_L4
int sigS0_
int sigS1_

Detailed Description

Definition at line 36 of file CastorLEDMonitor.h.


Constructor & Destructor Documentation

CastorLEDMonitor::CastorLEDMonitor ( )

Definition at line 15 of file CastorLEDMonitor.cc.

References doPerChannel_, sigS0_, and sigS1_.

                                   {
  doPerChannel_ = false;
  sigS0_=0;
  sigS1_=9;
}
CastorLEDMonitor::~CastorLEDMonitor ( )

Definition at line 24 of file CastorLEDMonitor.cc.

{}

Member Function Documentation

void CastorLEDMonitor::createFEDmap ( unsigned int  fed) [private]

Definition at line 90 of file CastorLEDMonitor.cc.

References CastorBaseMonitor::baseFolder_, DQMStore::book2D(), fedIter, CastorBaseMonitor::m_dbe, mean_energy, MEAN_MAP_ENERGY_DCC, MEAN_MAP_SHAPE_DCC, MEAN_MAP_TIME_DCC, mean_shape, mean_time, mergeVDriftHistosByStation::name, rms_energy, RMS_MAP_ENERGY_DCC, RMS_MAP_SHAPE_DCC, RMS_MAP_TIME_DCC, rms_shape, rms_time, and DQMStore::setCurrentFolder().

Referenced by reset().

                                                   {
  fedIter = MEAN_MAP_SHAPE_DCC.find(fed);
  
  if(fedIter==MEAN_MAP_SHAPE_DCC.end()){
    m_dbe->setCurrentFolder(baseFolder_);
    char name[256];

    sprintf(name,"DCC %d Mean Shape Map",fed);
    MonitorElement* mean_shape = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
    sprintf(name,"DCC %d RMS Shape Map",fed);
    MonitorElement* rms_shape = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);

    MEAN_MAP_SHAPE_DCC[fed] = mean_shape;
    RMS_MAP_SHAPE_DCC[fed] = rms_shape;

    sprintf(name,"DCC %d Mean Time Map",fed);
    MonitorElement* mean_time = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
    sprintf(name,"DCC %d RMS Time Map",fed);
    MonitorElement* rms_time = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
    MEAN_MAP_TIME_DCC[fed] = mean_time;
    RMS_MAP_TIME_DCC[fed] = rms_time;
    
    sprintf(name,"DCC %d Mean Energy Map",fed);
    MonitorElement* mean_energy = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
    sprintf(name,"DCC %d RMS Energy Map",fed);
    MonitorElement* rms_energy = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
    MEAN_MAP_ENERGY_DCC[fed] = mean_energy;
    RMS_MAP_ENERGY_DCC[fed] = rms_energy;
  }   
}
void CastorLEDMonitor::done ( ) [virtual]

Reimplemented from CastorBaseMonitor.

Definition at line 214 of file CastorLEDMonitor.cc.

Referenced by CastorMonitorModule::endJob().

                           {
  return;
}
void CastorLEDMonitor::perChanHists ( const HcalCastorDetId  DetID,
float *  vals,
std::map< HcalCastorDetId, MonitorElement * > &  tShape,
std::map< HcalCastorDetId, MonitorElement * > &  tTime,
std::map< HcalCastorDetId, MonitorElement * > &  tEnergy,
std::string  baseFolder 
) [private]

Definition at line 223 of file CastorLEDMonitor.cc.

References DQMStore::book1D(), energy, MonitorElement::Fill(), CastorBaseMonitor::fVerbosity, i, CastorBaseMonitor::m_dbe, meIter, HcalCastorDetId::module(), mergeVDriftHistosByStation::name, NULL, HcalCastorDetId::sector(), DQMStore::setCurrentFolder(), sigS0_, sigS1_, and HcalCastorDetId::zside().

Referenced by processEvent().

                                                       {
  
  std::string type = "CastorLEDPerChannel";
  if(m_dbe) m_dbe->setCurrentFolder(baseFolder+"/"+type);

  MonitorElement* me;
  if(m_dbe==NULL) return;
  meIter=tShape.begin();
  meIter = tShape.find(DetID);
 
 if (meIter!=tShape.end()){
    me= meIter->second;
    if(me==NULL && fVerbosity>0) printf("CastorLEDAnalysis::perChanHists  This histo is NULL!!??\n");
    else{
      float energy=0;
      float ts =0; float bs=0;
      int maxi=0; float maxa=0;
      for(int i=sigS0_; i<=sigS1_; i++){
        if(vals[i]>maxa){maxa=vals[i]; maxi=i;}
      }
      for(int i=sigS0_; i<=sigS1_; i++){          
        energy += vals[i];
        if(i>=(maxi-1) && i<=maxi+1){
          ts += i*vals[i];
          bs += vals[i];
        }
        me->Fill(i,vals[i]);
      }
      me = tTime[DetID];      
      if(bs!=0) me->Fill(ts/bs);
      me = tEnergy[DetID];  
      me->Fill(energy); 
    }
  }
  else{
    char name[1024];
    sprintf(name,"Castor LED Shape zside=%d  module=%d  sector=%d",DetID.zside(),DetID.module(),DetID.sector());      
    MonitorElement* insert1;
    insert1 =  m_dbe->book1D(name,name,10,-0.5,9.5);
    float energy=0;
    float ts =0; float bs=0;
    int maxi=0; float maxa=0;
    for(int i=sigS0_; i<=sigS1_; i++){
      if(vals[i]>maxa){maxa=vals[i]; maxi=i;}
      insert1->Fill(i,vals[i]); 
    }
    for(int i=sigS0_; i<=sigS1_; i++){    
      energy += vals[i];
      if(i>=(maxi-1) && i<=maxi+1){
        ts += i*vals[i];
        bs += vals[i];
      }
    }
    tShape[DetID] = insert1;
    
    sprintf(name,"Castor LED Time  zside=%d  module=%d  sector=%d",DetID.zside(),DetID.module(),DetID.sector());      
    MonitorElement* insert2 =  m_dbe->book1D(name,name,100,0,10);
    if(bs!=0) insert2->Fill(ts/bs); 
    tTime[DetID] = insert2;     


    sprintf(name,"Castor LED Energy zside=%d  module=%d  sector=%d",DetID.zside(),DetID.module(),DetID.sector());      
    MonitorElement* insert3 =  m_dbe->book1D(name,name,500,0,500);
    insert3->Fill(energy); 
    tEnergy[DetID] = insert3;   
    
  } 

  return;

}  
void CastorLEDMonitor::processEvent ( const CastorDigiCollection cast,
const CastorDbService cond 
)

Definition at line 143 of file CastorLEDMonitor.cc.

References HcalQIESample::adc(), adcThresh_, CastorBaseMonitor::baseFolder_, edm::SortedCollection< T, SORT >::begin(), calibs_, HcalQIESample::capid(), castHists, gather_cfg::cout, doPerChannel_, edm::SortedCollection< T, SORT >::end(), energy, MonitorElement::Fill(), CastorBaseMonitor::fVerbosity, i, CastorDataFrame::id(), ievt_, j, LedMonAdc2fc, CastorBaseMonitor::m_dbe, meEVT_, CastorCalibrations::pedestal(), perChanHists(), CastorDataFrame::sample(), sigS0_, sigS1_, edm::SortedCollection< T, SORT >::size(), CastorDataFrame::size(), tmp, and create_public_pileup_plots::vals.

                                                                                                        {


  meEVT_->Fill(ievt_);


  if(!m_dbe){ 
    if(fVerbosity>0) std::cout<<"CastorLEDMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;  
    return; 
  }
  float vals[10];

  
   if(castorDigis.size()>0) {

    for (CastorDigiCollection::const_iterator j=castorDigis.begin(); j!=castorDigis.end(); j++){
      const CastorDataFrame digi = (const CastorDataFrame)(*j); 
     

      float energy=0;
      float ts =0; float bs=0;
      int maxi=0; float maxa=0;
      for(int i=sigS0_; i<=sigS1_; i++){
        if(digi.sample(i).adc()>maxa){maxa=digi.sample(i).adc(); maxi=i;}
      }
      for(int i=sigS0_; i<=sigS1_; i++){          
        float tmp1 =0;   
        int j1=digi.sample(i).adc();
        tmp1 = (LedMonAdc2fc[j1]+0.5);            
        energy += tmp1-calibs_.pedestal(digi.sample(i).capid());
        if(i>=(maxi-1) && i<=maxi+1){
          ts += i*(tmp1-calibs_.pedestal(digi.sample(i).capid()));
          bs += tmp1-calibs_.pedestal(digi.sample(i).capid());
        }
      }
      if(energy<adcThresh_) continue;
     
      castHists.energyALL->Fill(energy);
      if(bs!=0) castHists.timeALL->Fill(ts/bs);

      //     if(ievt_%1000 == 0 ){
       for (int i=0; i<digi.size(); i++) {
        float tmp =0;
        int j=digi.sample(i).adc();
        tmp = (LedMonAdc2fc[j]+0.5);
        castHists.shapeALL->Fill(i,tmp);
        castHists.shapePED->Fill(i,tmp-calibs_.pedestal(digi.sample(i).capid()));
        vals[i] = tmp-calibs_.pedestal(digi.sample(i).capid());
       }
       //      }
      //do per channel histograms once for each 100 events
      if( doPerChannel_) perChanHists(digi.id(),vals,castHists.shape, castHists.time, castHists.energy, baseFolder_);
    }        
  } else {
    if(fVerbosity > 0) std::cout << "CastorPSMonitor::processEvent NO Castor Digis !!!" << std::endl;
  }
 

  ievt_++;
  
  return;
}
void CastorLEDMonitor::reset ( void  )

Definition at line 126 of file CastorLEDMonitor.cc.

References b, createFEDmap(), DQMStore::get(), MonitorElement::getBinContent(), MonitorElement::getNbinsX(), and CastorBaseMonitor::m_dbe.

Referenced by CastorMonitorModule::reset().

                            {
  
  MonitorElement* unpackedFEDS = m_dbe->get("Castor/FEDs Unpacked");
  if(unpackedFEDS){
    for(int b=1; b<=unpackedFEDS->getNbinsX(); b++){
      if(unpackedFEDS->getBinContent(b)>0){
        createFEDmap(700+(b-1));  
      }
    }
  }
}
void CastorLEDMonitor::setup ( const edm::ParameterSet ps,
DQMStore dbe 
) [virtual]

Reimplemented from CastorBaseMonitor.

Definition at line 31 of file CastorLEDMonitor.cc.

References adcThresh_, CastorBaseMonitor::baseFolder_, DQMStore::book1D(), DQMStore::bookInt(), castHists, gather_cfg::cout, doPerChannel_, MonitorElement::Fill(), edm::ParameterSet::getUntrackedParameter(), ievt_, CastorBaseMonitor::m_dbe, meEVT_, CastorBaseMonitor::rootFolder_, DQMStore::setCurrentFolder(), sigS0_, and sigS1_.

                                                                    {

  CastorBaseMonitor::setup(ps,dbe);

  baseFolder_ = rootFolder_+"CastorLEDMonitor";

  if ( ps.getUntrackedParameter<bool>("LEDPerChannel", false) ) 
    doPerChannel_ = true;

  sigS0_ = ps.getUntrackedParameter<int>("FirstSignalBin", 0);
  sigS1_ = ps.getUntrackedParameter<int>("LastSignalBin", 9);
  adcThresh_ = ps.getUntrackedParameter<double>("LED_ADC_Thresh", 0);
  std::cout << "LED Monitor threshold set to " << adcThresh_ << std::endl;
  std::cout << "LED Monitor signal window set to " << sigS0_ <<"-"<< sigS1_ << std::endl;  

  if(sigS0_<0){
    std::cout << "CastorLEDMonitor::setup, illegal range for first sample: " << sigS0_ << std::endl;
    sigS0_=0;
  }
  if(sigS1_>9){
    std::cout << "CastorLEDMonitor::setup, illegal range for last sample: " << sigS1_ << std::endl;
    sigS1_=9;
  }

  if(sigS0_ > sigS1_){ 
    std::cout<< "CastorLEDMonitor::setup, illegal range for first: "<< sigS0_ << " and last sample: " << sigS1_ << std::endl;
    sigS0_=0; sigS1_=9;
  }

  ievt_=0;

  if ( m_dbe ) {

    m_dbe->setCurrentFolder(baseFolder_);
    meEVT_ = m_dbe->bookInt("LED Task Event Number");    
    meEVT_->Fill(ievt_);
   
    castHists.shapePED =  m_dbe->book1D("Castor Ped Subtracted Pulse Shape","Castor Ped Subtracted Pulse Shape",10,-0.5,9.5);
    castHists.shapeALL =  m_dbe->book1D("Castor Average Pulse Shape","Castor Average Pulse Shape",10,-0.5,9.5);
    castHists.energyALL =  m_dbe->book1D("Castor Average Pulse Energy","Castor Average Pulse Energy",500,0,500);
    castHists.timeALL =  m_dbe->book1D("Castor Average Pulse Time","Castor Average Pulse Time",200,-1,10);
    castHists.rms_shape =  m_dbe->book1D("Castor LED Shape RMS Values","Castor LED Shape RMS Values",100,0,5);
    castHists.mean_shape =  m_dbe->book1D("Castor LED Shape Mean Values","Castor LED Shape Mean Values",100,-0.5,9.5);
    castHists.rms_time =  m_dbe->book1D("Castor LED Time RMS Values","Castor LED Time RMS Values",100,0,5);
    castHists.mean_time =  m_dbe->book1D("Castor LED Time Mean Values","Castor LED Time Mean Values",100,-1,10);
    castHists.rms_energy =  m_dbe->book1D("Castor LED Energy RMS Values","Castor LED Energy RMS Values",100,0,500);
    castHists.mean_energy =  m_dbe->book1D("Castor LED Energy Mean Values","Castor LED Energy Mean Values",100,0,1000);
    
  }

  return;
}

Member Data Documentation

Definition at line 70 of file CastorLEDMonitor.h.

Referenced by processEvent(), and setup().

Definition at line 73 of file CastorLEDMonitor.h.

Referenced by processEvent().

struct { ... } CastorLEDMonitor::castHists [private]

Referenced by processEvent(), and setup().

Definition at line 67 of file CastorLEDMonitor.h.

Referenced by CastorLEDMonitor(), processEvent(), and setup().

Definition at line 82 of file CastorLEDMonitor.h.

Referenced by perChanHists(), and processEvent().

Definition at line 87 of file CastorLEDMonitor.h.

std::map<unsigned int, MonitorElement*>::iterator CastorLEDMonitor::fedIter [private]

Definition at line 65 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

int CastorLEDMonitor::ievt_ [private]

Definition at line 72 of file CastorLEDMonitor.h.

Referenced by processEvent(), and setup().

int CastorLEDMonitor::jevt_ [private]

Definition at line 72 of file CastorLEDMonitor.h.

Definition at line 96 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

std::map<unsigned int,MonitorElement*> CastorLEDMonitor::MEAN_MAP_ENERGY_DCC [private]

Definition at line 115 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

std::map<unsigned int,MonitorElement*> CastorLEDMonitor::MEAN_MAP_SHAPE_DCC [private]

Definition at line 118 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

std::map<unsigned int,MonitorElement*> CastorLEDMonitor::MEAN_MAP_TIME_DCC [private]

Definition at line 121 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

Definition at line 101 of file CastorLEDMonitor.h.

Definition at line 104 of file CastorLEDMonitor.h.

Definition at line 107 of file CastorLEDMonitor.h.

Definition at line 110 of file CastorLEDMonitor.h.

Definition at line 90 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

Definition at line 93 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

Definition at line 77 of file CastorLEDMonitor.h.

Referenced by processEvent(), and setup().

std::map<HcalCastorDetId, MonitorElement*>::iterator CastorLEDMonitor::meIter [private]

Definition at line 64 of file CastorLEDMonitor.h.

Referenced by perChanHists().

Definition at line 95 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

std::map<unsigned int,MonitorElement*> CastorLEDMonitor::RMS_MAP_ENERGY_DCC [private]

Definition at line 116 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

std::map<unsigned int,MonitorElement*> CastorLEDMonitor::RMS_MAP_SHAPE_DCC [private]

Definition at line 119 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

std::map<unsigned int,MonitorElement*> CastorLEDMonitor::RMS_MAP_TIME_DCC [private]

Definition at line 122 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

Definition at line 102 of file CastorLEDMonitor.h.

Definition at line 105 of file CastorLEDMonitor.h.

Definition at line 108 of file CastorLEDMonitor.h.

Definition at line 111 of file CastorLEDMonitor.h.

Definition at line 89 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

Definition at line 92 of file CastorLEDMonitor.h.

Referenced by createFEDmap().

Definition at line 80 of file CastorLEDMonitor.h.

Definition at line 85 of file CastorLEDMonitor.h.

Definition at line 84 of file CastorLEDMonitor.h.

int CastorLEDMonitor::sigS0_ [private]

Definition at line 69 of file CastorLEDMonitor.h.

Referenced by CastorLEDMonitor(), perChanHists(), processEvent(), and setup().

int CastorLEDMonitor::sigS1_ [private]

Definition at line 69 of file CastorLEDMonitor.h.

Referenced by CastorLEDMonitor(), perChanHists(), processEvent(), and setup().

Definition at line 81 of file CastorLEDMonitor.h.

Definition at line 86 of file CastorLEDMonitor.h.