CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CalibTracker/SiPixelESProducers/plugins/SiPixelQualityESProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiPixelQualityESProducer
00004 // Class:      SiPixelQualityESProducer
00005 // 
00013 //
00014 // Original Author: Gemma Tinti
00015 //         Created:  Jan 13 2011
00016 //
00017 //
00018 
00019 // user include files
00020 
00021 #include <cassert>
00022 #include "CalibTracker/SiPixelESProducers/interface/SiPixelQualityESProducer.h"
00023 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h"
00024 #include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
00025 #include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
00026 #include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"
00027 #include "CalibTracker/Records/interface/SiStripDependentRecords.h"
00028 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00029 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 #include "FWCore/Framework/interface/ESHandle.h"
00032 #include "FWCore/Framework/interface/EventSetup.h"
00033 //
00034 // constructors and destructor
00035 //
00036 using namespace edm;
00037 
00038 SiPixelQualityESProducer::SiPixelQualityESProducer(const edm::ParameterSet& conf_) 
00039   : //fp_(conf_.getParameter<edm::FileInPath>("file")),
00040     toGet(conf_.getParameter<Parameters>("ListOfRecordToMerge"))
00041 {
00042    edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
00043   //the following line is needed to tell the framework what
00044   // data is being produced
00045   setWhatProduced(this);
00046   findingRecord<SiPixelQualityRcd>();
00047 }
00048 
00049 
00050 SiPixelQualityESProducer::~SiPixelQualityESProducer()
00051 {
00052  
00053    // do anything here that needs to be done at desctruction time
00054    // (e.g. close files, deallocate resources etc.)
00055 
00056 }
00057 
00058 std::auto_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd & iRecord)
00059 {
00060   
00061   std::string recordName;
00062 
00064   //  errortype "whole" = int 0 in DB  BadRocs = 65535 //
00065   //  errortype "tbmA" = int 1 in DB  BadRocs = 255    //
00066   //  errortype "tbmB" = int 2 in DB  Bad Rocs = 65280 //
00067   //  errortype "none" = int 3 in DB                   //
00069   
00070   //if I have understood this is the one got from the DB or file, but in any case the ORIGINAL(maybe i need to get the record for it)
00071   //SiPixelQuality * obj = new SiPixelQuality();
00072   //SiPixelQuality::disabledModuleType BadModule;
00073   //BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);
00074   
00075     //start with the record thta existed already to decouple the debugging
00076   //here i can do whatever i need with the detVoff
00077  
00078   edm::ESHandle<SiStripDetVOff> Voff;
00079   edm::ESHandle<SiPixelQuality> dbobject;
00080   
00081   for( Parameters::iterator itToGet = toGet.begin(); itToGet != toGet.end(); ++itToGet ) {
00082 
00083     recordName = itToGet->getParameter<std::string>("record");
00084     
00085     if (recordName=="SiPixelDetVOffRcd")
00086       iRecord.getRecord<SiPixelDetVOffRcd>().get(Voff); 
00087     if (recordName=="SiPixelQualityFromDbRcd")
00088       iRecord.getRecord<SiPixelQualityFromDbRcd>().get(dbobject);
00089   } //end getting the records from the parameters
00090   
00091   //now the dbobject is the one copied from the db
00092   //here make a copy of dbobject, but now the label has to be empty not to interfeare with the Reco
00093   std::auto_ptr<SiPixelQuality> dbptr(new SiPixelQuality(*(dbobject)));
00094   
00095   //here is the magic line in which it switches off Bad Modules
00096   dbptr->add(Voff.product());
00097 
00098   return dbptr;
00099 }
00100 
00101 void SiPixelQualityESProducer::setIntervalFor( const edm::eventsetup::EventSetupRecordKey&, 
00102                                                 const edm::IOVSyncValue& iosv, 
00103                                                 edm::ValidityInterval& oValidity ) {
00104   edm::ValidityInterval infinity( iosv.beginOfTime(), iosv.endOfTime() );
00105   oValidity = infinity;  
00106 }