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