CMS 3D CMS Logo

Public Member Functions | Private Attributes

SiStripDetVOffFakeBuilder Class Reference

#include <SiStripDetVOffFakeBuilder.h>

Inheritance diagram for SiStripDetVOffFakeBuilder:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void initialize (const edm::EventSetup &)
 SiStripDetVOffFakeBuilder (const edm::ParameterSet &iConfig)
 ~SiStripDetVOffFakeBuilder ()

Private Attributes

std::vector< uint32_t > detids
bool printdebug_

Detailed Description

Definition at line 13 of file SiStripDetVOffFakeBuilder.h.


Constructor & Destructor Documentation

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

Definition at line 23 of file SiStripDetVOffFakeBuilder.cc.

                                                                                    :
  printdebug_(iConfig.getUntrackedParameter<bool>("printDebug",false)){}
SiStripDetVOffFakeBuilder::~SiStripDetVOffFakeBuilder ( )

Definition at line 26 of file SiStripDetVOffFakeBuilder.cc.

{}

Member Function Documentation

void SiStripDetVOffFakeBuilder::analyze ( const edm::Event evt,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 52 of file SiStripDetVOffFakeBuilder.cc.

References detids, exception, edm::EventBase::id(), initialize(), edm::Service< T >::isAvailable(), SiStripDetVOff::put(), edm::EventID::run(), CrabTask::run, and cms::Exception::what().

{
  initialize(iSetup);

  unsigned int run=evt.id().run();

  edm::LogInfo("SiStripDetVOffFakeBuilder") << "... creating dummy SiStripDetVOff Data for Run " << run << "\n " << std::endl;



  SiStripDetVOff* SiStripDetVOff_ = new SiStripDetVOff();

   // std::vector<uint32_t> TheDetIdHVVector;

    for(std::vector<uint32_t>::const_iterator it = detids.begin(); it != detids.end(); it++){

    //Generate HV and LV for each channel, if at least one of the two is off fill the value
    int hv=rand() % 20;
    int lv=rand() % 20;
    if( hv<=2 ) {
      edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid: " <<  *it << " HV\t OFF" << std::endl;
      SiStripDetVOff_->put( *it, 1, -1 );
      // TheDetIdHVVector.push_back(*it);
    }
    if( lv<=2 ) {
      edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid: " <<  *it << " LV\t OFF" << std::endl;
      SiStripDetVOff_->put( *it, -1, 1 );
      // TheDetIdHVVector.push_back(*it);
    }
    if( lv<=2 || hv<=2 ) edm::LogInfo("SiStripDetVOffFakeBuilder") << "detid: " <<  *it << " V\t OFF" << std::endl;
  }

  // SiStripDetVOff_->put(TheDetIdHVVector);



  //End now write DetVOff data in DB
  edm::Service<cond::service::PoolDBOutputService> mydbservice;
  
  if( mydbservice.isAvailable() ){
    try{
      if( mydbservice->isNewTagRequest("SiStripDetVOffRcd") ){
        mydbservice->createNewIOV<SiStripDetVOff>(SiStripDetVOff_,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripDetVOffRcd");      
      } else {
        mydbservice->appendSinceTime<SiStripDetVOff>(SiStripDetVOff_,mydbservice->currentTime(),"SiStripDetVOffRcd");      
      }
    }catch(const cond::Exception& er){
      edm::LogError("SiStripDetVOffFakeBuilder")<<er.what()<<std::endl;
    }catch(const std::exception& er){
      edm::LogError("SiStripDetVOffFakeBuilder")<<"caught std::exception "<<er.what()<<std::endl;
    }catch(...){
      edm::LogError("SiStripDetVOffFakeBuilder")<<"Funny error"<<std::endl;
    }
  }else{
    edm::LogError("SiStripDetVOffFakeBuilder")<<"Service is unavailable"<<std::endl;
  }
}
void SiStripDetVOffFakeBuilder::initialize ( const edm::EventSetup iSetup) [virtual]

Definition at line 29 of file SiStripDetVOffFakeBuilder.cc.

References cond::rpcobgas::detid, detids, cmsRelvalreport::exit, edm::EventSetup::get(), StripTopology::nstrips(), L1TEmulatorMonitor_cff::p, and printdebug_.

Referenced by analyze().

                                                                        {

  edm::ESHandle<TrackerGeometry> pDD;
  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
  edm::LogInfo("SiStripDetVOffFakeBuilder") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
  
  for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
  
    if( dynamic_cast<StripGeomDetUnit*>((*it))!=0){
      uint32_t detid=((*it)->geographicalId()).rawId();            
      const StripTopology& p = dynamic_cast<StripGeomDetUnit*>((*it))->specificTopology();
      unsigned short Nstrips = p.nstrips();
      if(Nstrips<1 || Nstrips>768 ) {
        edm::LogError("SiStripDetVOffFakeBuilder")<<" Problem with Number of strips in detector.. "<< p.nstrips() <<" Exiting program"<<endl;
        exit(1);
      }
      detids.push_back(detid);
      if (printdebug_)
        edm::LogInfo("SiStripDetVOffFakeBuilder")<< "detid " << detid;
    }
  }
}

Member Data Documentation

std::vector<uint32_t> SiStripDetVOffFakeBuilder::detids [private]

Definition at line 27 of file SiStripDetVOffFakeBuilder.h.

Referenced by analyze(), and initialize().

Definition at line 26 of file SiStripDetVOffFakeBuilder.h.

Referenced by initialize().