CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalGetLaserData Class Reference

#include <EcalGetLaserData.h>

Inheritance diagram for EcalGetLaserData:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup)
 EcalGetLaserData (const edm::ParameterSet &iConfig)
 ~EcalGetLaserData ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()

Private Attributes

std::map< std::string,
unsigned long long > 
m_cacheIDs
std::map< std::string,
std::string > 
m_records

Detailed Description

Definition at line 35 of file EcalGetLaserData.h.


Constructor & Destructor Documentation

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

Definition at line 57 of file EcalGetLaserData.cc.

References edm::ParameterSet::getParameter(), i, m_cacheIDs, m_records, record, GlobalPosition_Frontier_DevDB_cff::tag, and align_tpl::toGet.

                                                                 :
  // m_timetype(iConfig.getParameter<std::string>("timetype")),
  m_cacheIDs(),
  m_records()
{
  std::string container;
  std::string tag;
  std::string record;

  //m_firstRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("firstRun").c_str());
  //m_lastRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("lastRun").c_str());

  typedef std::vector< edm::ParameterSet > Parameters;
  Parameters toGet = iConfig.getParameter<Parameters>("toGet");
  for(Parameters::iterator i = toGet.begin(); i != toGet.end(); ++i) {
    container = i->getParameter<std::string>("container");
    record = i->getParameter<std::string>("record");
    m_cacheIDs.insert( std::make_pair(container, 0) );
    m_records.insert( std::make_pair(container, record) );

  } //now do what ever initialization is needed

}
EcalGetLaserData::~EcalGetLaserData ( )

Definition at line 82 of file EcalGetLaserData.cc.

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

}

Member Function Documentation

void EcalGetLaserData::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 97 of file EcalGetLaserData.cc.

References alpha, gather_cfg::cout, edm::EventSetup::get(), patZpeak::handle, EEDetId::hashedIndex(), EBDetId::hashedIndex(), i, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, m_records, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, edm::ESHandle< T >::product(), record, ecalTPGAnalyzer_cfg::recordName, EcalCondObjectContainer< T >::size(), EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, cond::timestamp, EEDetId::validDetId(), and edm::Timestamp::value().

{
  using namespace edm;
  
  // loop on offline DB conditions to be transferred as from config file 
  std::string container;
  std::string record;
  typedef std::map<std::string, std::string>::const_iterator recordIter;
  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
    container = (*i).first;
    record = (*i).second;
    
    std::string recordName = m_records[container];

    
    if (container == "EcalLaserAPDPNRatios") {
      
      // get from offline DB the last valid laser set 
      edm::ESHandle<EcalLaserAPDPNRatios> handle;
      evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(handle);

      // this is the offline object 
      EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp;
      EcalLaserAPDPNRatios::EcalLaserAPDPNpair apdpnpair;
            
      const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = handle.product()->getLaserMap(); 
      const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = handle.product()->getTimeMap(); 

      // loop through ecal barrel
      for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
        if(iEta==0) continue;
        for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
          
          EBDetId ebdetid(iEta,iPhi);
          int hi = ebdetid.hashedIndex();
          
          if (hi<static_cast<int>(laserRatiosMap.size())) {
            apdpnpair = laserRatiosMap[hi];
            std::cout << "A sample value of APDPN pair EB : " 
                      << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;               
          } else {
            edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;     
          }
          
        }
      }  

      // loop through ecal endcap      
      for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
        for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {

          if (!EEDetId::validDetId(iX,iY,1))
            continue;
          
          EEDetId eedetidpos(iX,iY,1);
          int hi = eedetidpos.hashedIndex();
          
          if (hi< static_cast<int>(laserRatiosMap.size())) {
            apdpnpair = laserRatiosMap[hi];
            std::cout << "A sample value of APDPN pair EE+ : " 
                      << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
          } else {
            edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;     
          }
          
          if (!EEDetId::validDetId(iX,iY,-1))
            continue;
          EEDetId eedetidneg(iX,iY,1);
          hi = eedetidneg.hashedIndex();
          
          if (hi< static_cast<int>(laserRatiosMap.size())) {
            apdpnpair = laserRatiosMap[hi];
            std::cout << "A sample value of APDPN pair EE- : " 
                      << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
          } else {
            edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;     
          }
        }
      }
      
      for(int i=0; i<92; i++){
        timestamp = laserTimeMap[i];  
        std::cout << "A value of timestamp pair : "  
                  << i << " " << timestamp.t1.value() << " , " << timestamp.t2.value() << std::endl;    
      }
      
      std::cout <<".. just retrieved the last valid record from DB "<< std::endl;

    } else if(container == "EcalLaserAPDPNRatiosRef") { 

      // get from offline DB the last valid laser set 
      edm::ESHandle<EcalLaserAPDPNRatiosRef> handle;
      evtSetup.get<EcalLaserAPDPNRatiosRefRcd>().get(handle);

      EcalLaserAPDPNref apdpnref;      
      const EcalLaserAPDPNRatiosRefMap& laserRefMap = handle.product()->getMap(); 
      
      // first barrel
      for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
        if(iEta==0) continue;
        for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
          
          EBDetId ebdetid(iEta,iPhi);
          int hi = ebdetid.hashedIndex();
          
          if (hi< static_cast<int>(laserRefMap.size())) {
            apdpnref = laserRefMap[hi];
            std::cout << "A sample value of APDPN Reference value EB : "  
                 << hi << " : " << apdpnref << std::endl;                 
          } else { 
            edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;     
          }               
        }
      }
      
      // now for endcap
      for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
        for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {

          if (!EEDetId::validDetId(iX,iY,1))
            continue;
          
          EEDetId eedetidpos(iX,iY,1);
          int hi = eedetidpos.hashedIndex();
          
          if (hi< static_cast<int>(laserRefMap.size())) {
            apdpnref = laserRefMap[hi];
            std::cout << "A sample value of APDPN Reference value EE+ : "  
                 << hi << " : " << apdpnref << std::endl;                                 
            
          } else { 
            edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;     
          }
          
          if (!EEDetId::validDetId(iX,iY,-1))
            continue;
          EEDetId eedetidneg(iX,iY,-1);
          hi = eedetidneg.hashedIndex();
          
          if (hi< static_cast<int>(laserRefMap.size())) {
            apdpnref = laserRefMap[hi];
            std::cout << "A sample value of APDPN Reference value EE- : "  
                 << hi << " : " << apdpnref << std::endl;                
          } else { 
            edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;     
          }           
        }
      }
      
      std::cout << "... just retrieved the last valid record from DB "<< std::endl;
      
    } else if (container == "EcalLaserAlphas") { 

      // get from offline DB the last valid laser set 
      edm::ESHandle<EcalLaserAlphas> handle;
      evtSetup.get<EcalLaserAlphasRcd>().get(handle);

      // this is the offline object 
      EcalLaserAlpha alpha;     
      const EcalLaserAlphaMap& laserAlphaMap = handle.product()->getMap(); // map of apdpns

      // first barrel
      for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
        if(iEta==0) continue;
        for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
          
          EBDetId ebdetid(iEta,iPhi);
          int hi = ebdetid.hashedIndex();
          
          if (hi< static_cast<int>(laserAlphaMap.size())) {
            alpha = laserAlphaMap[hi];
            std::cout << " A sample value of Alpha value EB : " << hi << " : " << alpha << std::endl;
          } else {
            edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;     
          }       
        }
      }
      
      // next endcap
      for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
        for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {

          if (!EEDetId::validDetId(iX,iY,1))
            continue;

          EEDetId eedetidpos(iX,iY,1);
          int hi = eedetidpos.hashedIndex();
          
          if (hi< static_cast<int>(laserAlphaMap.size())) {
            alpha = laserAlphaMap[hi];
            std::cout << " A sample value of Alpha value EE+ : " << hi << " : " << alpha << std::endl;  
          } else {
            edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;     
          }                   
          

          if (!EEDetId::validDetId(iX,iY,-1))
            continue;
          EEDetId eedetidneg(iX,iY,-1);
          hi = eedetidneg.hashedIndex();
          
          if (hi< static_cast<int>(laserAlphaMap.size())) {
            alpha = laserAlphaMap[hi];
            std::cout << " A sample value of Alpha value EE- : " << hi << " : " << alpha << std::endl;
          } else {
            edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;     
          }       
        }
      }
      
      std::cout <<"... just retrieved the last valid record from DB "<< std::endl;

    } else {
      edm::LogError("EcalGetLaserData") << "Cannot retrieve for container: " 
                                        << container << std::endl;           
    }
    
  }

}
void EcalGetLaserData::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 321 of file EcalGetLaserData.cc.

{
}
void EcalGetLaserData::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 327 of file EcalGetLaserData.cc.

                         {
}

Member Data Documentation

std::map<std::string, unsigned long long> EcalGetLaserData::m_cacheIDs [private]

Definition at line 47 of file EcalGetLaserData.h.

Referenced by EcalGetLaserData().

std::map<std::string, std::string> EcalGetLaserData::m_records [private]

Definition at line 48 of file EcalGetLaserData.h.

Referenced by analyze(), and EcalGetLaserData().