CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondTools/SiStrip/plugins/SiStripBadFiberBuilder.cc

Go to the documentation of this file.
00001 #include "CondTools/SiStrip/plugins/SiStripBadFiberBuilder.h"
00002 
00003 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00004 
00005 #include <iostream>
00006 #include <fstream>
00007 #include <sstream>
00008 
00009 SiStripBadFiberBuilder::SiStripBadFiberBuilder(const edm::ParameterSet& iConfig) : ConditionDBWriter<SiStripBadStrip>(iConfig){
00010 
00011   fp_ = iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
00012   printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug",false);
00013   BadComponentList_ =  iConfig.getUntrackedParameter<Parameters>("BadComponentList");
00014 }
00015 
00016 
00017 SiStripBadFiberBuilder::~SiStripBadFiberBuilder(){
00018 }
00019 
00020 void SiStripBadFiberBuilder::algoAnalyze(const edm::Event & event, const edm::EventSetup& iSetup){
00021   
00022   unsigned int run=event.id().run();
00023 
00024   edm::LogInfo("SiStripBadFiberBuilder") << "... creating dummy SiStripBadStrip Data for Run " << run << "\n " << std::endl;
00025   
00026   obj = new SiStripBadStrip();
00027 
00028   SiStripDetInfoFileReader reader(fp_.fullPath());
00029   
00030   const std::vector<uint32_t> DetIds = reader.getAllDetIds();
00031 
00032   std::stringstream ss;
00033   for(Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end(); ++iBadComponent ) {
00034     
00035     uint32_t BadModule_ = iBadComponent->getParameter<uint32_t>("BadModule");
00036     std::vector<uint32_t> BadApvList_ = iBadComponent->getParameter<std::vector<uint32_t> >("BadApvList");
00037 
00038     std::vector<unsigned int> theSiStripVector;
00039     
00040     unsigned short firstBadStrip=0, NconsecutiveBadStrips=0;
00041     unsigned int theBadStripRange;
00042     
00043     for(std::vector<uint32_t>::const_iterator is=BadApvList_.begin(); is!=BadApvList_.end(); ++is){
00044 
00045       firstBadStrip=(*is)*128;
00046       NconsecutiveBadStrips=128;
00047       
00048       theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);
00049       
00050       if (printdebug_)
00051         ss << "detid " << BadModule_ << " \t"
00052            << " firstBadStrip " << firstBadStrip << "\t "
00053            << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
00054            << " packed integer " << std::hex << theBadStripRange  << std::dec
00055            << std::endl;            
00056       
00057       theSiStripVector.push_back(theBadStripRange);
00058     }      
00059      
00060     SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
00061     if ( ! obj->put(BadModule_,range) )
00062       edm::LogError("SiStripBadFiberBuilder")<<"[SiStripBadFiberBuilder::analyze] detid already exists"<<std::endl;
00063   }
00064   if (printdebug_)
00065     edm::LogInfo("SiStripBadFiberBuilder") << ss.str();
00066 }
00067 
00068