CMS 3D CMS Logo

Public Member Functions | Private Attributes

EcalPerEvtMatacqAnalyzer Class Reference

#include <EcalPerEvtMatacqAnalyzer.h>

Inheritance diagram for EcalPerEvtMatacqAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &c)
virtual void beginJob ()
 EcalPerEvtMatacqAnalyzer (const edm::ParameterSet &iConfig)
virtual void endJob ()
 ~EcalPerEvtMatacqAnalyzer ()

Private Attributes

unsigned int _highlev
unsigned int _lowlev
unsigned int _nevlasers
unsigned int _noiseCut
unsigned int _nsamplesaftmax
unsigned int _nsamplesbefmax
unsigned int _parabnaftmax
unsigned int _parabnbefmax
double _presample
unsigned int _thres
double ampl
std::string digiCollection_
std::string digiProducer_
int event
std::string eventHeaderCollection_
std::string eventHeaderProducer_
double fit
int iEvent
int IsFileCreated
int IsTreeCreated
int laser_color
double matacq [N_samples]
unsigned int maxsamp
TTree * mtqShape
unsigned int nsamples
TFile * outFile
std::string outfile
double peak
std::string resdir_
int runNum
int runType
TFile * sampFile
double sigma
int status
TTree * tree
double trise
double ttrig

Detailed Description

Definition at line 15 of file EcalPerEvtMatacqAnalyzer.h.


Constructor & Destructor Documentation

EcalPerEvtMatacqAnalyzer::EcalPerEvtMatacqAnalyzer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 35 of file EcalPerEvtMatacqAnalyzer.cc.

References digiCollection_, digiProducer_, eventHeaderCollection_, eventHeaderProducer_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and resdir_.

  :
  iEvent(0),
  // framework parameters with default values

  _presample(     iConfig.getUntrackedParameter< double       >( "nPresamples",   6.7 ) ),
  _nsamplesaftmax(iConfig.getUntrackedParameter< unsigned int >( "nSamplesAftMax", 80 ) ),
  _nsamplesbefmax(iConfig.getUntrackedParameter< unsigned int >( "nSamplesBefMax", 20 ) ),
  _noiseCut(      iConfig.getUntrackedParameter< unsigned int >( "noiseCut",        7 ) ),
  _parabnbefmax(  iConfig.getUntrackedParameter< unsigned int >( "paraBeforeMax",   8 ) ),
  _parabnaftmax(  iConfig.getUntrackedParameter< unsigned int >( "paraAfterMax",    7 ) ),
  _thres(         iConfig.getUntrackedParameter< unsigned int >( "threshold",      10 ) ),
  _lowlev(        iConfig.getUntrackedParameter< unsigned int >( "lowLevel",       20 ) ),
  _highlev(       iConfig.getUntrackedParameter< unsigned int >( "highLevel",      80 ) ),
  _nevlasers(     iConfig.getUntrackedParameter< unsigned int >( "nEventLaser",   600 ) )

//========================================================================
{


  //now do what ever initialization is needed

  resdir_                 = iConfig.getUntrackedParameter<std::string>("resDir");

  digiCollection_         = iConfig.getParameter<std::string>("digiCollection");
  digiProducer_           = iConfig.getParameter<std::string>("digiProducer");
  
  eventHeaderCollection_  = iConfig.getParameter<std::string>("eventHeaderCollection");
  eventHeaderProducer_    = iConfig.getParameter<std::string>("eventHeaderProducer");

}
EcalPerEvtMatacqAnalyzer::~EcalPerEvtMatacqAnalyzer ( )

Definition at line 68 of file EcalPerEvtMatacqAnalyzer.cc.

                                                   {
//========================================================================

  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 91 of file EcalPerEvtMatacqAnalyzer.cc.

References EcalMatacqDigi::adcCount(), edm::SortedCollection< T, SORT >::begin(), dtNoiseDBValidation_cfg::cerr, digiCollection_, digiProducer_, edm::SortedCollection< T, SORT >::end(), event, eventHeaderCollection_, exception, edm::Event::getByLabel(), i, iEvent, IsFileCreated, IsTreeCreated, laser_color, EcalDCCHeaderBlock::LASER_DELAY_SCAN, EcalDCCHeaderBlock::LASER_GAP, EcalDCCHeaderBlock::LASER_POWER_SCAN, EcalDCCHeaderBlock::LASER_STD, matacq, max(), maxsamp, N_channels, prof2calltree::namefile, nsamples, outFile, outfile, edm::Handle< T >::product(), resdir_, runNum, runType, EcalMatacqDigi::size(), tree, EcalMatacqDigi::tTrig(), ttrig, and EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength.

                                                                                   {
//========================================================================

  ++iEvent;

  // retrieving MATACQ :
  edm::Handle<EcalMatacqDigiCollection> pmatacqDigi;
  const EcalMatacqDigiCollection* matacqDigi=0;
  try {
    e.getByLabel(digiProducer_,digiCollection_, pmatacqDigi); 
    matacqDigi=pmatacqDigi.product();
  }catch ( std::exception& ex ) {
    std::cerr << "Error! can't get the product " << digiCollection_.c_str() << std::endl;

  }
  
  // retrieving DCC header

  edm::Handle<EcalRawDataCollection> pDCCHeader;
  const  EcalRawDataCollection* DCCHeader=0;
  try {
     e.getByLabel(digiProducer_, pDCCHeader); 
     //e.getByLabel(eventHeaderProducer_,eventHeaderCollection_, pDCCHeader);
    DCCHeader=pDCCHeader.product();
  }catch ( std::exception& ex ) {
    std::cerr << "Error! can't get the product " << eventHeaderCollection_.c_str() << std::endl;
  }


  // ====================================
  // Decode Basic DCCHeader Information 
  // ====================================

  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeader->begin();headerItr != DCCHeader->end(); 
    ++headerItr ) {
    event=headerItr->getLV1();
    EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings(); 

    laser_color = (int) settings.wavelength;
    
    // Get run type and run number 

    runType=headerItr->getRunType();
    runNum=headerItr->getRunNumber();
    
    // Cut on runType
    
    if(runType!=EcalDCCHeaderBlock::LASER_STD && runType!=EcalDCCHeaderBlock::LASER_GAP 
       && runType!=EcalDCCHeaderBlock::LASER_POWER_SCAN && runType!=EcalDCCHeaderBlock::LASER_DELAY_SCAN) return; 
    
    // Define output results files' names
    
    if (IsFileCreated==0){

      stringstream namefile;

      namefile << resdir_ <<"/MatacqPerEvt-Run"<<runNum<<".root";        
      outfile=namefile.str();    
      
      outFile = new TFile(outfile.c_str(),"RECREATE");
      
      
      // declaration of the tree to fill
      
      tree = new TTree("MatacqTree","MatacqTree");

      IsFileCreated=1;
      
    }
  }


// ===========================
// Decode Matacq Information
// ===========================

  int iCh=0;
  double max=0;

  for(EcalMatacqDigiCollection::const_iterator it = matacqDigi->begin(); it!=matacqDigi->end(); ++it){ // Loop on matacq channel 
    
    // 
    const EcalMatacqDigi& digis = *it;
    
    if(digis.size()==0 || iCh>=N_channels) continue; 

    max=0;
    maxsamp=0;
    nsamples=digis.size();

    if(IsTreeCreated==0){
      
      //List of branches
      
      stringstream mat;
      mat << "matacq["<<nsamples<<"]/D"<< endl;
 
      tree->Branch( "event",       &event,        "event/I"          );
      tree->Branch( "laser_color", &laser_color , "laser_color/I"    );
      //      tree->Branch( "nsamples",    &nsamples ,    "nsamples/I"       );
      tree->Branch( "matacq",      &matacq ,       mat.str().c_str() );
      tree->Branch( "maxsamp",     &maxsamp ,     "maxsamp/I"        );
      tree->Branch( "ttrig",       &ttrig ,       "ttrig/D"          );
      
      tree->SetBranchAddress( "event",       &event       );
      tree->SetBranchAddress( "laser_color", &laser_color );
      tree->SetBranchAddress( "matacq",      matacq       ); 
      //      tree->SetBranchAddress( "nsamples",    &nsamples    );
      tree->SetBranchAddress( "maxsamp",     &maxsamp     );
      tree->SetBranchAddress( "ttrig",       &ttrig       );
      
      IsTreeCreated=1;
    }

    ttrig=digis.tTrig();
    
    for(int i=0; i<digis.size(); ++i){ // Loop on matacq samples      
      matacq[i]=digis.adcCount(i);
      if(matacq[i]>max) {
        max=matacq[i];
        maxsamp=i;
      }
    }  
    
    
    iCh++; 
  }
  
  tree->Fill();
  
} // analyze
void EcalPerEvtMatacqAnalyzer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 79 of file EcalPerEvtMatacqAnalyzer.cc.

References IsFileCreated, and IsTreeCreated.

                                        {
//========================================================================

    //Initializations

    IsFileCreated=0;
    IsTreeCreated=0;

}
void EcalPerEvtMatacqAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 225 of file EcalPerEvtMatacqAnalyzer.cc.

References outFile, and tree.

{
  
  tree->Write();
  outFile->Close();


}

Member Data Documentation

unsigned int EcalPerEvtMatacqAnalyzer::_highlev [private]

Definition at line 77 of file EcalPerEvtMatacqAnalyzer.h.

unsigned int EcalPerEvtMatacqAnalyzer::_lowlev [private]

Definition at line 76 of file EcalPerEvtMatacqAnalyzer.h.

unsigned int EcalPerEvtMatacqAnalyzer::_nevlasers [private]

Definition at line 78 of file EcalPerEvtMatacqAnalyzer.h.

unsigned int EcalPerEvtMatacqAnalyzer::_noiseCut [private]

Definition at line 72 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 70 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 71 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 74 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 73 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 69 of file EcalPerEvtMatacqAnalyzer.h.

unsigned int EcalPerEvtMatacqAnalyzer::_thres [private]

Definition at line 75 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 60 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 31 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and EcalPerEvtMatacqAnalyzer().

Definition at line 32 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and EcalPerEvtMatacqAnalyzer().

Definition at line 47 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 33 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and EcalPerEvtMatacqAnalyzer().

Definition at line 34 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by EcalPerEvtMatacqAnalyzer().

Definition at line 60 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 38 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 56 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and beginJob().

Definition at line 57 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and beginJob().

Definition at line 48 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

double EcalPerEvtMatacqAnalyzer::matacq[N_samples] [private]

Definition at line 49 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

unsigned int EcalPerEvtMatacqAnalyzer::maxsamp [private]

Definition at line 50 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 61 of file EcalPerEvtMatacqAnalyzer.h.

unsigned int EcalPerEvtMatacqAnalyzer::nsamples [private]

Definition at line 51 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 58 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and endJob().

std::string EcalPerEvtMatacqAnalyzer::outfile [private]

Definition at line 36 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 60 of file EcalPerEvtMatacqAnalyzer.h.

std::string EcalPerEvtMatacqAnalyzer::resdir_ [private]

Definition at line 30 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and EcalPerEvtMatacqAnalyzer().

Definition at line 43 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 42 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().

Definition at line 53 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 60 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 59 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 54 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze(), and endJob().

Definition at line 60 of file EcalPerEvtMatacqAnalyzer.h.

Definition at line 60 of file EcalPerEvtMatacqAnalyzer.h.

Referenced by analyze().