CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

testChannel Class Reference

calculate the best DAC value to obtain a pedestal = 200 More...

#include <testChannel.h>

Inheritance diagram for testChannel:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (edm::Event const &event, edm::EventSetup const &eventSetup)
 ! Analyze
void beginJob ()
 BeginJob.
void endJob (void)
 EndJob.
void subscribe (void)
 Subscribe/Unsubscribe to Monitoring Elements.
void subscribeNew (void)
 testChannel (const edm::ParameterSet &ps)
 Constructor.
void unsubscribe (void)
virtual ~testChannel ()
 Destructor.

Private Member Functions

int getHeaderSMId (const int headerId)

Private Attributes

int m_bestPed
int m_DACmax
int m_DACmin
 name of the xml file to be saved
std::string m_digiCollection
std::string m_digiProducer
 secondary name given to collection of digis
std::string m_headerProducer
 name of module/plugin/producer making digis
TH2F m_pedVSDAC
double m_RMSmax
TH2F m_singlePedVSDAC_1
TH2F m_singlePedVSDAC_2
TH2F m_singlePedVSDAC_3
std::string m_xmlFile
 name of module/plugin/producer making headers
int m_xtal

Detailed Description

calculate the best DAC value to obtain a pedestal = 200

Date:
2010/01/04 15:06:29
Revision:
1.6
Author:
P. Govoni (testChannel.govoni@cernNOSPAM.ch)

Definition at line 39 of file testChannel.h.


Constructor & Destructor Documentation

testChannel::testChannel ( const edm::ParameterSet ps)

Constructor.

ctor

Definition at line 19 of file testChannel.cc.

References m_bestPed, m_DACmax, m_DACmin, and m_RMSmax.

                                                         :
  m_digiCollection (paramSet.getParameter<std::string> ("digiCollection")) ,
  m_digiProducer (paramSet.getParameter<std::string> ("digiProducer")) ,
  m_headerProducer (paramSet.getParameter<std::string> ("headerProducer")) ,
  m_xmlFile (paramSet.getParameter<std::string> ("xmlFile")) ,
  m_DACmin (paramSet.getParameter<int> ("DACmin")) ,
  m_DACmax (paramSet.getParameter<int> ("DACmax")) ,
  m_RMSmax (paramSet.getParameter<double> ("RMSmax")) ,
  m_bestPed (paramSet.getParameter<int> ("bestPed")) ,
  m_xtal (paramSet.getParameter<int> ("xtal")) ,
  m_pedVSDAC ("pedVSDAC","pedVSDAC",100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
  m_singlePedVSDAC_1 ("singlePedVSDAC_1","pedVSDAC (g1) for xtal "+m_xtal,100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
  m_singlePedVSDAC_2 ("singlePedVSDAC_2","pedVSDAC (g2) for xtal "+m_xtal,100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
  m_singlePedVSDAC_3 ("singlePedVSDAC_3","pedVSDAC (g3) for xtal "+m_xtal,100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax)
{
  edm::LogInfo ("testChannel") << " reading "
                               << " m_DACmin: " << m_DACmin
                               << " m_DACmax: " << m_DACmax
                               << " m_RMSmax: " << m_RMSmax
                               << " m_bestPed: " << m_bestPed ;
}
testChannel::~testChannel ( ) [virtual]

Destructor.

dtor

Definition at line 43 of file testChannel.cc.

{
}

Member Function Documentation

void testChannel::analyze ( edm::Event const &  event,
edm::EventSetup const &  eventSetup 
) [virtual]

! Analyze

perform te analysis

loop over the headers

Implements edm::EDAnalyzer.

Definition at line 56 of file testChannel.cc.

References EcalMGPASample::adc(), ecalMGPA::gainId(), EcalMGPASample::gainId(), getHeaderSMId(), ecalpyutils::ism(), edm::HandleBase::isValid(), LogDebug, m_digiCollection, m_digiProducer, m_headerProducer, m_pedVSDAC, m_singlePedVSDAC_1, m_singlePedVSDAC_2, m_singlePedVSDAC_3, m_xtal, EcalDataFrame::MAXSAMPLES, EcalDCCHeaderBlock::EcalDCCEventSettings::ped_offset, and EcalDataFrame::sample().

{
   LogDebug ("testChannel") << "entering analyze ..." ;

   // get the headers
   // (one header for each supermodule)
   edm::Handle<EcalRawDataCollection> DCCHeaders ;
   event.getByLabel (m_headerProducer, DCCHeaders) ;
   if(!DCCHeaders.isValid())
   {
     edm::LogError ("testChannel") << "Error! can't get the product " 
                                   << m_headerProducer.c_str () ;
   }

   std::map <int,int> DACvalues ;
   
   // loop over the headers
   for ( EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin () ;
         headerItr != DCCHeaders->end () ; 
             ++headerItr ) 
     {
       EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings () ;
       DACvalues[getHeaderSMId (headerItr->id ())] = settings.ped_offset ;
//       std::cout << "DCCid: " << headerItr->id () << "" ;
//       std::cout << "Ped offset DAC: " << settings.ped_offset << "" ;
     } 

   // get the digis
   // (one digi for each crystal)
   edm::Handle<EBDigiCollection> pDigis;
   event.getByLabel (m_digiProducer, pDigis) ;
   if(!pDigis.isValid())
   {
     edm::LogError ("testChannel") << "Error! can't get the product " 
                                   << m_digiCollection.c_str () ;
   }
   
   // loop over the digis
   for (EBDigiCollection::const_iterator itdigi = pDigis->begin () ; 
        itdigi != pDigis->end () ; 
        ++itdigi) 
    {    
       EBDataFrame df( *itdigi );
       int gainId = df.sample (0).gainId () ;
       int crystalId = EBDetId(itdigi->id ()).ic () ;
       int smId = EBDetId(itdigi->id ()).ism () ;

       edm::LogInfo ("testChannel") << "channel " << event.id ()  
                                    << "\tcry: " << crystalId 
                                    << "\tG: " << gainId 
                                    << "\tDAC: " << DACvalues[smId] ;

       // loop over the samples
       for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES ; ++iSample) 
         {
            edm::LogInfo ("testChannel") << "\t`-->" << df.sample (iSample).adc () ;
            m_pedVSDAC.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
            if (crystalId == m_xtal)
              { 
                if (gainId == 1) m_singlePedVSDAC_1.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
                if (gainId == 2) m_singlePedVSDAC_2.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
                if (gainId == 3) m_singlePedVSDAC_3.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
              }
         } // loop over the samples
    } // loop over the digis

}
void testChannel::beginJob ( void  ) [virtual]

BeginJob.

begin the job

Reimplemented from edm::EDAnalyzer.

Definition at line 49 of file testChannel.cc.

References LogDebug.

{
   LogDebug ("testChannel") << "entering beginJob ..." ;
}
void testChannel::endJob ( void  ) [virtual]

EndJob.

perform the minimiation and write results

Reimplemented from edm::EDAnalyzer.

Definition at line 126 of file testChannel.cc.

References m_pedVSDAC, m_singlePedVSDAC_1, m_singlePedVSDAC_2, m_singlePedVSDAC_3, m_xtal, and dbtoconf::out.

{
  char ccout[80] ;
  sprintf (ccout,"out_%d.root",m_xtal) ;
  TFile out (ccout,"RECREATE") ;
  out.cd () ;
  m_pedVSDAC.Write () ;
  m_singlePedVSDAC_1.Write () ;
  m_singlePedVSDAC_2.Write () ;
  m_singlePedVSDAC_3.Write () ;
  TProfile * profilo1 = m_singlePedVSDAC_1.ProfileX () ;
  TProfile * profilo2 = m_singlePedVSDAC_2.ProfileX () ;
  TProfile * profilo3 = m_singlePedVSDAC_3.ProfileX () ;
  profilo1->Write ("singleProfile_1") ;
  profilo2->Write ("singleProfile_2") ;
  profilo3->Write ("singleProfile_3") ;
  out.Close () ;
}
int testChannel::getHeaderSMId ( const int  headerId) [private]

Definition at line 151 of file testChannel.cc.

Referenced by analyze().

{
  //PG FIXME temporary solution
  //PG FIXME check it is consistent with the TB!
  return 1 ;
}
void testChannel::subscribe ( void  )

Subscribe/Unsubscribe to Monitoring Elements.

Definition at line 161 of file testChannel.cc.

{}
void testChannel::subscribeNew ( void  )

Definition at line 164 of file testChannel.cc.

{}
void testChannel::unsubscribe ( void  )

Definition at line 167 of file testChannel.cc.

{}

Member Data Documentation

int testChannel::m_bestPed [private]

Definition at line 77 of file testChannel.h.

Referenced by testChannel().

int testChannel::m_DACmax [private]

Definition at line 75 of file testChannel.h.

Referenced by testChannel().

int testChannel::m_DACmin [private]

name of the xml file to be saved

Definition at line 74 of file testChannel.h.

Referenced by testChannel().

std::string testChannel::m_digiCollection [private]

Definition at line 68 of file testChannel.h.

Referenced by analyze().

std::string testChannel::m_digiProducer [private]

secondary name given to collection of digis

Definition at line 69 of file testChannel.h.

Referenced by analyze().

std::string testChannel::m_headerProducer [private]

name of module/plugin/producer making digis

Definition at line 70 of file testChannel.h.

Referenced by analyze().

TH2F testChannel::m_pedVSDAC [private]

Definition at line 81 of file testChannel.h.

Referenced by analyze(), and endJob().

double testChannel::m_RMSmax [private]

Definition at line 76 of file testChannel.h.

Referenced by testChannel().

Definition at line 82 of file testChannel.h.

Referenced by analyze(), and endJob().

Definition at line 83 of file testChannel.h.

Referenced by analyze(), and endJob().

Definition at line 84 of file testChannel.h.

Referenced by analyze(), and endJob().

std::string testChannel::m_xmlFile [private]

name of module/plugin/producer making headers

Definition at line 72 of file testChannel.h.

int testChannel::m_xtal [private]

Definition at line 79 of file testChannel.h.

Referenced by analyze(), and endJob().