CMS 3D CMS Logo

SiStripNoiseDB Class Reference

Description: <one line="" class="" summary>="">. More...

#include <CalibTracker/SiStripPedestals/interface/SiStripNoiseDB.h>

Inheritance diagram for SiStripNoiseDB:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (edm::EventSetup const &)
virtual void endJob ()
 SiStripNoiseDB (const edm::ParameterSet &)
 ~SiStripNoiseDB ()

Private Attributes

ApvAnalysisFactoryapvFactory_
edm::ParameterSet conf_
DaqMonitorBEInterface * dbe_
SiStripFedCablingfedCabling_
std::vector< std::pair
< uint32_t,
SiStripNoises::InputVector > > 
mSiStripNoises
int nEvTot_
int NumCMstripsInGroup_
std::string outPutFileName
edm::ParameterSet pedsPSet_
std::vector< uint32_t > SelectedDetIds
SiStripNoisesSiStripNoises_
SiStripQualitySiStripQuality_
int theEventInitNumber_
int theEventIterNumber_


Detailed Description

Description: <one line="" class="" summary>="">.

Usage: <usage>

Definition at line 69 of file SiStripNoiseDB.h.


Constructor & Destructor Documentation

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

Definition at line 20 of file SiStripNoiseDB.cc.

References apvFactory_, conf_, edm::ParameterSet::getParameter(), nEvTot_, NumCMstripsInGroup_, pedsPSet_, theEventInitNumber_, and theEventIterNumber_.

00021 {
00022    conf_ = iConfig;
00023    pedsPSet_ = conf_.getParameter<edm::ParameterSet>("PedestalsPSet");
00024    nEvTot_=0;
00025    apvFactory_=0;
00026    theEventInitNumber_ =  pedsPSet_.getParameter<int>("NumberOfEventsForInit");
00027    theEventIterNumber_ = pedsPSet_.getParameter<int>("NumberOfEventsForIteration");
00028    NumCMstripsInGroup_ = pedsPSet_.getParameter<int>("NumCMstripsInGroup");
00029 
00030 }

SiStripNoiseDB::~SiStripNoiseDB (  ) 

Definition at line 33 of file SiStripNoiseDB.cc.

References apvFactory_.

00034 {
00035   if (apvFactory_) {delete apvFactory_;} 
00036 }


Member Function Documentation

void SiStripNoiseDB::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 79 of file SiStripNoiseDB.cc.

References apvFactory_, conf_, reco_application_tbsim_simpleTBanalysis_cfg::digiProducer, edm::Event::getByLabel(), ApvAnalysisFactory::getMask(), ApvAnalysisFactory::getNoise(), edm::ParameterSet::getParameter(), mSiStripNoises, nEvTot_, SelectedDetIds, SiStripNoises::setData(), SiStripNoises_, pyDBSRunClass::temp, theEventInitNumber_, theEventIterNumber_, and ApvAnalysisFactory::update().

00080 {
00081   nEvTot_++;
00082   //Increment # of Events
00083   using namespace edm;
00084   // retrieve producer name of input StripDigiCollection
00085     std::string digiProducer = conf_.getParameter<std::string>("DigiProducer");
00086     // get DigiCollection object from Event
00087     edm::Handle< edm::DetSetVector<SiStripRawDigi> > digi_collection;
00088     std::string digiType = "VirginRaw";
00089     //you have a collection as there are all the digis for the event for every detector
00090     iEvent.getByLabel(digiProducer, digiType, digi_collection);
00091     //Noises object ...
00092 
00093     SiStripNoises_ = new SiStripNoises();
00094     
00095     // loop over all DetIds to be implement
00096     for(vector<uint32_t>::const_iterator myDet = SelectedDetIds.begin();myDet!=SelectedDetIds.end();myDet++)
00097       {
00098         uint32_t detid = *myDet;
00099         vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid );
00100         if ( digis->data.empty() ) { 
00101           edm::LogError("MonitorDigi_tmp") << "[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!"; 
00102         } 
00103         //cout <<"Data size "<<digis->data.size()<<endl;
00104         apvFactory_->update(detid, (*digis));
00105         //asking for the status
00106         if((nEvTot_ - theEventInitNumber_)%theEventIterNumber_ == 1)
00107           {
00108             mSiStripNoises.clear();
00109             //Generate Pedestal for det detid
00110             SiStripNoises::InputVector theSiStripVector;  
00111             vector<float> tmp_noise;
00112             tmp_noise.clear();
00113             apvFactory_->getNoise(detid, tmp_noise);
00114             TkApvMask::MaskType temp;
00115             apvFactory_->getMask(detid, temp);
00116             int ibin=0;
00117             for (vector<float>::const_iterator iped=tmp_noise.begin(); iped!=tmp_noise.end();iped++) {
00118               float noise = *iped;
00119               bool disable = true;
00120               if(temp[ibin] == 0) disable = false;
00121 
00122               SiStripNoises_->setData(noise,theSiStripVector);
00123               ibin++;
00124             } 
00125             mSiStripNoises.push_back(make_pair(detid,theSiStripVector));
00126           }
00127       }
00128 }

void SiStripNoiseDB::beginJob ( edm::EventSetup const &  es  )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file SiStripNoiseDB.cc.

References apvFactory_, SiStripFedCabling::connection(), FedChannelConnection::detId(), fedCabling_, SiStripFedCabling::feds(), edm::EventSetup::get(), ApvAnalysisFactory::instantiateApvs(), FedChannelConnection::nApvPairs(), pedsPSet_, edm::ESHandle< T >::product(), and SelectedDetIds.

00039                                                     {
00040    // retrieve parameters from configuration file
00041   using namespace edm;
00042   SelectedDetIds.clear();
00043 
00044   //ApvAnalysisFactory
00045   apvFactory_ = new ApvAnalysisFactory(pedsPSet_);
00046   
00047 //getting det id from the fed cabling
00048   edm::ESHandle<SiStripFedCabling> cabling;
00049   es.get<SiStripFedCablingRcd>().get( cabling );
00050   fedCabling_ = const_cast<SiStripFedCabling*>( cabling.product() );
00051 
00052   
00053   map<uint32_t, int> detIdApv;
00054   detIdApv.clear();
00055   //To do so I need to access cabling from FED and so on ... see rob's code
00056    // Retrieve FED ids from cabling map and iterate through 
00057   const vector<uint16_t>& fed_ids = fedCabling_->feds(); 
00058   vector<uint16_t>::const_iterator ifed;
00059   for ( ifed = fed_ids.begin(); ifed != fed_ids.end(); ifed++ ) {  
00060     for ( uint16_t channel = 0; channel < 96; channel++ ) {
00061       const FedChannelConnection& conn = fedCabling_->connection( *ifed, channel );
00062       uint32_t key_id =  conn.detId();
00063       int napvs = (conn.nApvPairs())*2;
00064       if(key_id > 0 && napvs >0) { 
00065         
00066         //      cout <<"DetId before the map "<<key_id<< " "<<conn.nApvPairs()<<endl;
00067         bool newDetId =   apvFactory_->instantiateApvs(key_id,napvs);
00068         if(newDetId) 
00069           SelectedDetIds.push_back(key_id);
00070       }
00071     }
00072     
00073   }
00074 
00075 }

void SiStripNoiseDB::endJob ( void   )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 130 of file SiStripNoiseDB.cc.

References lat::endl(), exception, edm::Service< T >::isAvailable(), iter, mSiStripNoises, SiStripNoises::put(), SiStripNoises_, and cms::Exception::what().

00130                                {
00131 
00132   edm::LogInfo("SiStripNoiseDB") << "... now write sistripnoise data in DB" << std::endl;
00133 
00134   for (std::vector< std::pair<uint32_t, SiStripNoises::InputVector > >::const_iterator iter=mSiStripNoises.begin(); iter!=mSiStripNoises.end();iter++)
00135     {
00136       if ( ! SiStripNoises_->put(iter->first,iter->second) )
00137         edm::LogError("SiStripNoiseDB") <<"[SiStripNoiseDB::analyze] detid " << iter->first << "already exists"<<endl;
00138     }    
00139         
00140   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00141   
00142   if( mydbservice.isAvailable() ){
00143     try{
00144       edm::LogInfo("SiStripNoiseDB")<<"current time "<<mydbservice->currentTime()<<std::endl;
00145       mydbservice->createNewIOV<SiStripNoises>(SiStripNoises_,mydbservice->beginOfTime(),mydbservice->endOfTime(), "SiStripNoisesRcd");      
00146     }catch(const cond::Exception& er){
00147       edm::LogError("SiStripNoiseDB")<<er.what()<<std::endl;
00148     }catch(const std::exception& er){
00149       edm::LogError("SiStripNoiseDB")<<"caught std::exception "<<er.what()<<std::endl;
00150     }catch(...){
00151       edm::LogError("SiStripNoiseDB")<<"Funny error"<<std::endl;
00152     }
00153   }else{
00154     edm::LogError("SiStripNoiseDB")<<"Service is unavailable"<<std::endl;
00155   }
00156 }


Member Data Documentation

ApvAnalysisFactory* SiStripNoiseDB::apvFactory_ [private]

Definition at line 91 of file SiStripNoiseDB.h.

Referenced by analyze(), beginJob(), SiStripNoiseDB(), and ~SiStripNoiseDB().

edm::ParameterSet SiStripNoiseDB::conf_ [private]

Definition at line 81 of file SiStripNoiseDB.h.

Referenced by analyze(), and SiStripNoiseDB().

DaqMonitorBEInterface* SiStripNoiseDB::dbe_ [private]

Definition at line 80 of file SiStripNoiseDB.h.

SiStripFedCabling* SiStripNoiseDB::fedCabling_ [private]

Definition at line 82 of file SiStripNoiseDB.h.

Referenced by beginJob().

std::vector< std::pair<uint32_t,SiStripNoises::InputVector > > SiStripNoiseDB::mSiStripNoises [private]

Definition at line 85 of file SiStripNoiseDB.h.

Referenced by analyze(), and endJob().

int SiStripNoiseDB::nEvTot_ [private]

Definition at line 93 of file SiStripNoiseDB.h.

Referenced by analyze(), and SiStripNoiseDB().

int SiStripNoiseDB::NumCMstripsInGroup_ [private]

Definition at line 96 of file SiStripNoiseDB.h.

Referenced by SiStripNoiseDB().

std::string SiStripNoiseDB::outPutFileName [private]

Definition at line 97 of file SiStripNoiseDB.h.

edm::ParameterSet SiStripNoiseDB::pedsPSet_ [private]

Definition at line 92 of file SiStripNoiseDB.h.

Referenced by beginJob(), and SiStripNoiseDB().

std::vector<uint32_t> SiStripNoiseDB::SelectedDetIds [private]

Definition at line 89 of file SiStripNoiseDB.h.

Referenced by analyze(), and beginJob().

SiStripNoises* SiStripNoiseDB::SiStripNoises_ [private]

Definition at line 84 of file SiStripNoiseDB.h.

Referenced by analyze(), and endJob().

SiStripQuality* SiStripNoiseDB::SiStripQuality_ [private]

Definition at line 87 of file SiStripNoiseDB.h.

int SiStripNoiseDB::theEventInitNumber_ [private]

Definition at line 94 of file SiStripNoiseDB.h.

Referenced by analyze(), and SiStripNoiseDB().

int SiStripNoiseDB::theEventIterNumber_ [private]

Definition at line 95 of file SiStripNoiseDB.h.

Referenced by analyze(), and SiStripNoiseDB().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:26 2009 for CMSSW by  doxygen 1.5.4