CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

SiStripBadChannelBuilder Class Reference

#include <SiStripBadChannelBuilder.h>

Inheritance diagram for SiStripBadChannelBuilder:
ConditionDBWriter< SiStripBadStrip > edm::EDAnalyzer

List of all members.

Public Member Functions

void algoAnalyze (const edm::Event &event, const edm::EventSetup &iSetup)
 SiStripBadChannelBuilder (const edm::ParameterSet &)
 ~SiStripBadChannelBuilder ()

Private Types

typedef std::vector
< edm::ParameterSet
Parameters

Private Member Functions

SiStripBadStripgetNewObject ()

Private Attributes

Parameters BadComponentList_
edm::FileInPath fp_
SiStripBadStripobj
bool printdebug_

Detailed Description

Definition at line 19 of file SiStripBadChannelBuilder.h.


Member Typedef Documentation

typedef std::vector< edm::ParameterSet > SiStripBadChannelBuilder::Parameters [private]

Definition at line 37 of file SiStripBadChannelBuilder.h.


Constructor & Destructor Documentation

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

Definition at line 8 of file SiStripBadChannelBuilder.cc.

References BadComponentList_, fp_, edm::ParameterSet::getUntrackedParameter(), and printdebug_.

                                                                                 : ConditionDBWriter<SiStripBadStrip>(iConfig){

  fp_ = iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug",false);
  BadComponentList_ =  iConfig.getUntrackedParameter<Parameters>("BadComponentList");
}
SiStripBadChannelBuilder::~SiStripBadChannelBuilder ( )

Definition at line 16 of file SiStripBadChannelBuilder.cc.

                                                   {
}

Member Function Documentation

void SiStripBadChannelBuilder::algoAnalyze ( const edm::Event event,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from ConditionDBWriter< SiStripBadStrip >.

Definition at line 19 of file SiStripBadChannelBuilder.cc.

References BadComponentList_, SiStripBadStrip::encode(), fp_, edm::FileInPath::fullPath(), edm::Service< T >::isAvailable(), obj, printdebug_, SiStripBadStrip::put(), matplotRender::reader, and DTTTrigCorrFirst::run.

                                                                                             {
  
  unsigned int run=event.id().run();

  edm::LogInfo("SiStripBadChannelBuilder") << "... creating dummy SiStripBadStrip Data for Run " << run << "\n " << std::endl;
  
  SiStripBadStrip* obj = new SiStripBadStrip();

  SiStripDetInfoFileReader reader(fp_.fullPath());
  
  const std::vector<uint32_t> DetIds = reader.getAllDetIds();
  
  for(Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end(); ++iBadComponent ) {
    
    uint32_t BadModule_ = iBadComponent->getParameter<uint32_t>("BadModule");
    std::vector<uint32_t> BadChannelList_ = iBadComponent->getParameter<std::vector<uint32_t> >("BadChannelList");

    std::vector<unsigned int> theSiStripVector;
    unsigned int NStrips=reader.getNumberOfApvsAndStripLength(BadModule_).first*128;   
    
    uint32_t lastBad=999;
    unsigned short firstBadStrip=0, NconsecutiveBadStrips=0;
    unsigned int theBadStripRange;

    for(std::vector<uint32_t>::const_iterator is=BadChannelList_.begin(); is!=BadChannelList_.end(); ++is){
      if (*is>NStrips-1)
        break;
      if (*is!=lastBad+1){
        //new set 

        if ( lastBad!=999 ){
          //save previous set
          theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);

          if (printdebug_)
            edm::LogInfo("SiStripBadChannelBuilder") << "detid " << BadModule_ << " \t"
                                                   << " firstBadStrip " << firstBadStrip << "\t "
                                                   << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
                                                   << " packed integer " << std::hex << theBadStripRange  << std::dec
                                                   << std::endl;            
          
          theSiStripVector.push_back(theBadStripRange);
        }
        
        firstBadStrip=*is;
        NconsecutiveBadStrips=0;
      }         
      NconsecutiveBadStrips++;
      lastBad=*is;
    }

    theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);
    if (printdebug_)
      edm::LogInfo("SiStripBadChannelBuilder") << "detid " << BadModule_ << " \t"
                                             << " firstBadStrip " << firstBadStrip << "\t "
                                             << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
                                             << " packed integer " << std::hex << theBadStripRange  << std::dec
                                             << std::endl;          
          
    theSiStripVector.push_back(theBadStripRange);
        
    SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
    if ( ! obj->put(BadModule_,range) )
    edm::LogError("SiStripBadChannelBuilder")<<"[SiStripBadChannelBuilder::analyze] detid already exists"<<std::endl;
  }
 //End now write sistripbadChannel data in DB
  edm::Service<cond::service::PoolDBOutputService> mydbservice;

  if( mydbservice.isAvailable() ){
    if ( mydbservice->isNewTagRequest("SiStripBadStripRcd") ){
      mydbservice->createNewIOV<SiStripBadStrip>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripBadStripRcd");
    } else {
      //mydbservice->createNewIOV<SiStripBadStrip>(obj,mydbservice->currentTime(),"SiStripBadStripRcd");
      mydbservice->appendSinceTime<SiStripBadStrip>(obj,mydbservice->currentTime(),"SiStripBadStripRcd");
    }
  }else{
    edm::LogError("SiStripBadStripBuilder")<<"Service is unavailable"<<std::endl;
  }

}
SiStripBadStrip* SiStripBadChannelBuilder::getNewObject ( ) [inline, private, virtual]

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 30 of file SiStripBadChannelBuilder.h.

References obj.

{return obj;}

Member Data Documentation

Definition at line 38 of file SiStripBadChannelBuilder.h.

Referenced by algoAnalyze(), and SiStripBadChannelBuilder().

Definition at line 33 of file SiStripBadChannelBuilder.h.

Referenced by algoAnalyze(), and SiStripBadChannelBuilder().

Definition at line 35 of file SiStripBadChannelBuilder.h.

Referenced by algoAnalyze(), and getNewObject().

Definition at line 34 of file SiStripBadChannelBuilder.h.

Referenced by algoAnalyze(), and SiStripBadChannelBuilder().