CMS 3D CMS Logo

SiStripMonitorPedestals.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiStripMonitorPedestals
00004 // Class:      SiStripMonitorPedestals
00005 // 
00013 //
00014 // Original Author:  Simone Gennai and Suchandra Dutta
00015 //         Created:  Sat Feb  4 20:49:10 CET 2006
00016 // $Id: SiStripMonitorPedestals.cc,v 1.34 2008/04/12 15:16:05 dutta Exp $
00017 //
00018 //
00019 
00020 #include "FWCore/ServiceRegistry/interface/Service.h"
00021 #include "DataFormats/Common/interface/Handle.h"
00022 
00023 #include "DQMServices/Core/interface/DQMStore.h"
00024 #include "DQMServices/Core/interface/MonitorElement.h"
00025 
00026 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00027 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
00028 
00029 #include "CalibTracker/SiStripAPVAnalysis/interface/ApvAnalysisFactory.h"
00030 
00031 #include <FWCore/Framework/interface/EventSetup.h>
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033 
00034 #include "DQM/SiStripMonitorPedestals/interface/SiStripMonitorPedestals.h"
00035 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"
00036 #include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
00037 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
00038 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
00039 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00040 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00041 
00042 #include "TProfile.h"
00043 // std
00044 #include <cstdlib>
00045 #include <cmath>
00046 #include <numeric>
00047 #include <algorithm>
00048 
00049 const std::string SiStripMonitorPedestals::RunMode1 = "ConDBPlotsOnly";
00050 const std::string SiStripMonitorPedestals::RunMode2 = "CalculatedPlotsOnly";
00051 const std::string SiStripMonitorPedestals::RunMode3 = "AllPlots";
00052 
00053 SiStripMonitorPedestals::SiStripMonitorPedestals(edm::ParameterSet const& iConfig):
00054   dqmStore_(edm::Service<DQMStore>().operator->()),
00055   conf_(iConfig),
00056   pedsPSet_(iConfig.getParameter<edm::ParameterSet>("PedestalsPSet")),
00057   analyzed(false),
00058   firstEvent(true),
00059   signalCutPeds_(4),
00060   nEvTot_(0),
00061   nIteration_(0),
00062   apvFactory_(0),
00063   m_cacheID_(0)
00064 {
00065   edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals  " 
00066                                           << " Constructing....... ";     
00067 }
00068 //
00069 // -- Destructor
00070 //
00071 SiStripMonitorPedestals::~SiStripMonitorPedestals()
00072 {
00073   edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals  " 
00074                                           << " Destructing...... ";     
00075   if (apvFactory_) {delete apvFactory_;} 
00076 }
00077 //
00078 // -- Begin Job
00079 //
00080 void SiStripMonitorPedestals::beginJob(edm::EventSetup const& eSetup) {
00081   theEventInitNumber_ = pedsPSet_.getParameter<int>("NumberOfEventsForInit");
00082   theEventIterNumber_ = pedsPSet_.getParameter<int>("NumberOfEventsForIteration");
00083   NumCMstripsInGroup_ = pedsPSet_.getParameter<int>("NumCMstripsInGroup");
00084         runTypeFlag_  = conf_.getParameter<std::string>("RunTypeFlag");
00085 }
00086 //
00087 // -- BeginRun
00088 //
00089 void SiStripMonitorPedestals::beginRun(edm::Run const& run, edm::EventSetup const& eSetup) {
00090 
00091   unsigned long long cacheID = eSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
00092   if (m_cacheID_ != cacheID) {
00093     m_cacheID_ = cacheID;       
00094     eSetup.get<SiStripDetCablingRcd>().get( detcabling );
00095     edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::beginRun: " 
00096                                           << " Creating MEs for new Cabling ";     
00097     createMEs();
00098   } else {
00099     edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::beginRun: " 
00100                                           << " Resetting MEs ";        
00101     for (std::map<uint32_t, ModMEs >::const_iterator idet = PedMEs.begin() ; idet!=PedMEs.end() ; idet++) {
00102       resetMEs(idet->first);
00103     }
00104   }
00105   if (runTypeFlag_ == RunMode1 || runTypeFlag_ == RunMode3 ) fillCondDBMEs(eSetup);
00106 }
00107 //
00108 // -- Create Monitor Elements
00109 //
00110 void SiStripMonitorPedestals::createMEs() {
00111   std::vector<uint32_t> SelectedDetIds;
00112   
00113   //ApvAnalysisFactory
00114   if (apvFactory_) {delete apvFactory_;} 
00115   apvFactory_ = new ApvAnalysisFactory(pedsPSet_);
00116   
00117   detcabling->addActiveDetectorsRawIds(SelectedDetIds);
00118   
00119   // use SistripHistoId for producing histogram id (and title)
00120   SiStripHistoId hidmanager;
00121   // create SiStripFolderOrganizer
00122   SiStripFolderOrganizer folder_organizer;
00123   
00124   edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::createMEs: " 
00125           << "Number of Detector Present in cabling " << SelectedDetIds.size();
00126 
00127   for (std::vector<uint32_t>::const_iterator idetid=SelectedDetIds.begin(), iEnd=SelectedDetIds.end();idetid!=iEnd;++idetid){
00128     
00129     uint32_t detid = *idetid;
00130 
00131     // Check consistency in DetId
00132     if (detid == 0 || detid == 0xFFFFFFFF){
00133       edm::LogError("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::createMEs: " 
00134         << "Wrong DetId !!!!!! " <<  detid << " Neglecting !!!!!! ";
00135       continue;
00136     }
00137 
00138     unsigned int apv_pairs = detcabling->nApvPairs(detid);
00139     
00140     // Check consistency in Apv numbers
00141     if (apv_pairs < 1 || apv_pairs > 3) {
00142       edm::LogError("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::createMEs: Wrong APV Pairs  => detId "
00143                 << detid  << " APV pairs " << apv_pairs <<  " Neglecting !!!!!! ";
00144       continue;
00145     }
00146     unsigned int napvs = apv_pairs * 2;
00147     unsigned int nStrip  = napvs * 128;
00148 
00149     bool newDetId =   apvFactory_->instantiateApvs(detid,napvs);  
00150   
00151     if( newDetId ) {
00152       ModMEs local_modmes;
00153       std::string hid;
00154       // set appropriate folder using SiStripFolderOrganizer
00155       folder_organizer.setDetectorFolder(detid); // pass the detid to this method
00156       
00157       // if the deid already exists in the map, then reset MEs otherwise create them
00158       resetMEs(detid);
00159       
00160       if (runTypeFlag_ == RunMode1 || runTypeFlag_ == RunMode3 ) {
00161         //Pedestals histos
00162         hid = hidmanager.createHistoId("PedestalFromCondDB","det", detid);
00163         local_modmes.PedsPerStripDB = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5); //to modify the size binning 
00164         dqmStore_->tag(local_modmes.PedsPerStripDB, detid);
00165         (local_modmes.PedsPerStripDB)->setAxisTitle("Pedestal from CondDB(ADC) vs Strip Number",1);
00166         
00167         hid = hidmanager.createHistoId("NoiseFromCondDB","det", detid);
00168         local_modmes.CMSubNoisePerStripDB = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5);
00169         dqmStore_->tag(local_modmes.CMSubNoisePerStripDB, detid);
00170         (local_modmes.CMSubNoisePerStripDB)->setAxisTitle("CMSubNoise from CondDB(ADC) vs Strip Number",1);
00171         
00172         hid = hidmanager.createHistoId("BadStripFlagCondDB","det", detid);
00173         local_modmes.BadStripsDB = dqmStore_->book2D(hid, hid, nStrip,0.5,nStrip+0.5,6,-0.5,5.5);
00174         dqmStore_->tag(local_modmes.BadStripsDB, detid);
00175         (local_modmes.BadStripsDB)->setAxisTitle("Strip Flag from CondDB(ADC) vs Strip Number",1);
00176       }
00177       if (runTypeFlag_ == RunMode2 || runTypeFlag_ == RunMode3 ) { 
00178         //Pedestals histos
00179         hid = hidmanager.createHistoId("PedsPerStrip","det", detid);
00180         local_modmes.PedsPerStrip = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5); //to modify the size binning 
00181         dqmStore_->tag(local_modmes.PedsPerStrip, detid);
00182         (local_modmes.PedsPerStrip)->setAxisTitle("Pedestal (ADC)  vs Strip Number ",1);
00183         
00184         hid = hidmanager.createHistoId("PedsDistribution","det", detid);
00185         local_modmes.PedsDistribution = dqmStore_->book2D(hid, hid, napvs,-0.5,napvs-0.5, 300, 200, 500); //to modify the size binning 
00186         dqmStore_->tag(local_modmes.PedsDistribution, detid);
00187         (local_modmes.PedsDistribution)->setAxisTitle("Apv Number",1);
00188         (local_modmes.PedsDistribution)->setAxisTitle("Mean Pedestal Value (ADC)",2);
00189         
00190         hid = hidmanager.createHistoId("PedsEvolution","det", detid);
00191         local_modmes.PedsEvolution = dqmStore_->book2D(hid, hid, napvs,-0.5,napvs-0.5, 50, 0., 50.); //to modify the size binning 
00192         dqmStore_->tag(local_modmes.PedsEvolution, detid);
00193         (local_modmes.PedsEvolution)->setAxisTitle("Apv Number",1);
00194         (local_modmes.PedsEvolution)->setAxisTitle("Iteration Number",2);
00195         
00196         //Noise histos
00197         hid = hidmanager.createHistoId("CMSubNoisePerStrip","det", detid);
00198         local_modmes.CMSubNoisePerStrip = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5);
00199         dqmStore_->tag(local_modmes.CMSubNoisePerStrip, detid);
00200         (local_modmes.CMSubNoisePerStrip)->setAxisTitle("CMSubNoise (ADC) vs Strip Number",1);
00201         
00202         hid = hidmanager.createHistoId("RawNoisePerStrip","det", detid);
00203         local_modmes.RawNoisePerStrip = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5);
00204         dqmStore_->tag(local_modmes.RawNoisePerStrip, detid);
00205         (local_modmes.RawNoisePerStrip)->setAxisTitle("RawNoise(ADC) vs Strip Number",1);
00206         
00207         hid = hidmanager.createHistoId("CMSubNoiseProfile","det", detid);
00208         local_modmes.CMSubNoiseProfile = dqmStore_->bookProfile(hid, hid, nStrip,0.5,nStrip+0.5, 100, 0., 100.);
00209         dqmStore_->tag(local_modmes.CMSubNoiseProfile, detid);
00210         (local_modmes.CMSubNoiseProfile)->setAxisTitle("Mean of CMSubNoise (ADC) vs Strip Number",1);
00211         
00212         hid = hidmanager.createHistoId("RawNoiseProfile","det", detid);
00213         local_modmes.RawNoiseProfile = dqmStore_->bookProfile(hid, hid, nStrip,0.5,nStrip+0.5, 100, 0., 100.);
00214         dqmStore_->tag(local_modmes.RawNoiseProfile, detid);
00215         (local_modmes.RawNoiseProfile)->setAxisTitle("Mean of RawNoise (ADC) vs Strip Number",1);
00216         
00217         hid = hidmanager.createHistoId("NoisyStrips","det", detid);
00218         local_modmes.NoisyStrips = dqmStore_->book2D(hid, hid, nStrip,0.5,nStrip+0.5,6,-0.5,5.5);
00219         dqmStore_->tag(local_modmes.NoisyStrips, detid);
00220         (local_modmes.NoisyStrips)->setAxisTitle("Strip Number",1);
00221         (local_modmes.NoisyStrips)->setAxisTitle("Flag Value",2);
00222         
00223         hid = hidmanager.createHistoId("NoisyStripDistribution","det", detid);
00224         local_modmes.NoisyStripDistribution = dqmStore_->book1D(hid, hid, 11, -0.5,10.5);
00225         dqmStore_->tag(local_modmes.NoisyStripDistribution, detid);
00226         (local_modmes.NoisyStripDistribution)->setAxisTitle("Flag Value",1);
00227         
00228         //Common Mode histos
00229         hid = hidmanager.createHistoId("CMDistribution","det", detid);
00230         local_modmes.CMDistribution = dqmStore_->book2D(hid, hid, napvs,-0.5,napvs-0.5, 150, -15., 15.); 
00231         dqmStore_->tag(local_modmes.CMDistribution, detid);
00232         (local_modmes.CMDistribution)->setAxisTitle("Common Mode (ADC) vs APV Number",1);
00233       
00234         hid = hidmanager.createHistoId("CMSlopeDistribution","det", detid);
00235         local_modmes.CMSlopeDistribution = dqmStore_->book2D(hid, hid, napvs,-0.5,napvs-0.5, 100, -0.05, 0.05); 
00236         dqmStore_->tag(local_modmes.CMSlopeDistribution, detid);
00237         (local_modmes.CMSlopeDistribution)->setAxisTitle("Common Mode Slope vs APV Number",1);
00238         
00239       }
00240       // data from CondDB
00241       // append to PedMEs
00242       PedMEs.insert( std::make_pair(detid, local_modmes));
00243     } //newDetId
00244           
00245   }
00246   edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::createMEs: Number of DETS used "
00247                    <<PedMEs.size();
00248 }
00249 // ------------ method called to produce the data  ------------
00250 void SiStripMonitorPedestals::analyze(const edm::Event& iEvent, const edm::EventSetup& eSetup)
00251 {
00252 
00253   edm::LogInfo("SiStripMonitorPedestals") <<
00254                "SiStripMonitorPedestals::analyze: Run " << 
00255                iEvent.id().run()  << " Event " << iEvent.id().event();
00256 
00257   eSetup.get<SiStripDetCablingRcd>().get( detcabling );
00258 
00259   if (runTypeFlag_ != RunMode2 &&  runTypeFlag_ != RunMode3 ) return;
00260 
00261   //Increment # of Events
00262   nEvTot_++;
00263  
00264   // retrieve producer name of input StripDigiCollection
00265   std::string digiProducer = conf_.getParameter<std::string>("DigiProducer");
00266   // get DigiCollection object from Event
00267   edm::Handle< edm::DetSetVector<SiStripRawDigi> > digi_collection;
00268   std::string digiType = "VirginRaw";
00269   //you have a collection as there are all the digis for the event for every detector
00270   iEvent.getByLabel(digiProducer, digiType, digi_collection);
00271 
00272   //Increase the number of iterations ...
00273   if((nEvTot_ - theEventInitNumber_)%theEventIterNumber_ == 1) nIteration_++;
00274   
00275 
00276   // loop over all MEs
00277   for (std::map<uint32_t, ModMEs >::const_iterator i = PedMEs.begin() ; i!=PedMEs.end() ; i++) {
00278     uint32_t detid = i->first; ModMEs local_modmes = i->second;
00279     // get iterators for digis belonging to one DetId, it is an iterator, i.e. one element of the vector      
00280     std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid );
00281     if (digis == digi_collection->end() ||
00282         digis->data.size() == 0 || 
00283         digis->data.size() > 768) {
00284       if (digis == digi_collection->end()) {
00285         edm::LogError("SiStripMonitorPedestals") << " SiStripMonitorPedestals::analyze: Event " <<  nEvTot_ 
00286                << " DetId " <<  detid << " at the end of Digi Collection!!!"; 
00287       } else {
00288         edm::LogError("SiStripMonitorPedestals") << " [SiStripMonitorPedestals::analyze: Event " <<  nEvTot_ 
00289                << " DetId " <<  detid << " # of Digis " << digis->data.size() ;
00290       }
00291       std::vector<FedChannelConnection> fed_conns = detcabling->getConnections(detid);
00292       for (unsigned int  k = 0; k < fed_conns.size() ; k++) {
00293         if (k==0) edm::LogError("SiStripMonitorPedestals") <<" SiStripMonitorPedestals::analyze: Fed Id " <<
00294               fed_conns[k].fedId() << " Channel " << fed_conns[k].fedCh();
00295         else  edm::LogError("SiStripMonitorPedestals")  <<"  SiStripMonitorPedestals::analyze: Channel " <<
00296                             fed_conns[k].fedCh();
00297       }
00298       std::cout << std::endl;
00299       continue;
00300     }
00301 
00302     if ( digis->data.empty() ) { 
00303       edm::LogError("MonitorDigi_tmp") << "[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!"; 
00304     } 
00305     uint32_t id  = detid;
00306     //    cout <<"Data size "<<digis->data.size()<<endl;
00307     apvFactory_->update(id, (*digis));
00308       
00309     if(nEvTot_ > theEventInitNumber_) {
00310       if(local_modmes.CMDistribution != NULL){ 
00311         std::vector<float> tmp;
00312         tmp.clear();
00313         apvFactory_->getCommonMode(id, tmp);
00314         //unpacking the info looking at the right topology
00315         int numberCMBlocks = int(128. / NumCMstripsInGroup_);
00316         int ibin=0;
00317         for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
00318           int iapv = int (ibin/numberCMBlocks);
00319           (local_modmes.CMDistribution)->Fill(iapv,static_cast<float>(*iped));
00320           ibin++;
00321             
00322         }
00323       }
00324       if(local_modmes.CMSlopeDistribution != NULL){ 
00325         std::vector<float> tmp;
00326         tmp.clear();
00327         int iapv = 0;
00328         apvFactory_->getCommonModeSlope(id, tmp);
00329         for (std::vector<float>::const_iterator it=tmp.begin(); it!=tmp.end();it++) {
00330           (local_modmes.CMSlopeDistribution)->Fill(iapv,static_cast<float>(*it));
00331           iapv++;
00332         }
00333       }
00334     }
00335       
00336     //asking for the status
00337     if((nEvTot_ - theEventInitNumber_ - theEventIterNumber_)%theEventIterNumber_ == 1)
00338       {
00339               
00340         std::vector<float> tmp;
00341         tmp.clear();
00342         apvFactory_->getPedestal(id, tmp);
00343         if(local_modmes.PedsPerStrip != NULL){ 
00344           int numberOfApvs = int(tmp.size()/128.);
00345           for(int i=0; i<numberOfApvs;i++){
00346             std::vector<float> myPedPerApv;
00347             apvFactory_->getPedestal(id, i, myPedPerApv);
00348             float avarage = 0;
00349             avarage = accumulate(myPedPerApv.begin(), myPedPerApv.end(), avarage);
00350             avarage = avarage/128.;
00351             (local_modmes.PedsEvolution)->setBinContent(i+1,nIteration_,avarage);
00352               
00353           }
00354           int ibin=0;
00355           
00356           for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
00357             int napv = int(ibin / 128.);
00358             ibin++;
00359             float last_value = (local_modmes.PedsPerStrip)->getBinContent(ibin);
00360             if(last_value != 0.){
00361               (local_modmes.PedsPerStrip)->setBinContent(ibin,(static_cast<float>(*iped) + last_value)/2.);
00362             }else{
00363               (local_modmes.PedsPerStrip)->setBinContent(ibin,static_cast<float>(*iped));
00364             }
00365             (local_modmes.PedsDistribution)->Fill(napv,static_cast<float>(*iped));
00366           }
00367         }
00368           
00369         if(local_modmes.CMSubNoisePerStrip != NULL && local_modmes.CMSubNoiseProfile != NULL){ 
00370           tmp.clear();
00371           apvFactory_->getNoise(id, tmp);
00372           int ibin=0;
00373           for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
00374             ibin++;
00375             (local_modmes.CMSubNoiseProfile)->Fill(static_cast<double>(ibin*1.),static_cast<float>(*iped));
00376 
00377             float last_value = (local_modmes.CMSubNoisePerStrip)->getBinContent(ibin);
00378             if(last_value != 0.){
00379               (local_modmes.CMSubNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
00380             }else{
00381               (local_modmes.CMSubNoisePerStrip)->setBinContent(ibin,static_cast<float>(*iped));
00382             }
00383           }
00384         }
00385 
00386           
00387         if(local_modmes.RawNoisePerStrip != NULL && local_modmes.RawNoiseProfile != NULL){ 
00388           tmp.clear();
00389           apvFactory_->getRawNoise(id, tmp);
00390           int ibin=0;
00391           for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
00392             ibin++;
00393             (local_modmes.RawNoiseProfile)->Fill(static_cast<double>(ibin*1.),static_cast<float>(*iped));
00394             float last_value = (local_modmes.RawNoisePerStrip)->getBinContent(ibin);
00395             if(last_value != 0.){
00396               (local_modmes.RawNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
00397             }else{
00398               (local_modmes.RawNoisePerStrip)->setBinContent(ibin,static_cast<float>(*iped));
00399             }
00400           }
00401         }
00402 
00403         if(local_modmes.NoisyStrips != NULL){ 
00404           TkApvMask::MaskType temp;
00405           apvFactory_->getMask(id, temp);
00406           int ibin=0;
00407           for (TkApvMask::MaskType::const_iterator iped=temp.begin(); iped!=temp.end();iped++) {
00408             ibin++;
00409               
00410             if(nIteration_ <2){
00411               if(*iped == 1)
00412                 (local_modmes.NoisyStrips)->Fill(ibin,3.);
00413               if(*iped == 2)
00414                 (local_modmes.NoisyStrips)->Fill(ibin,4.);
00415               if(*iped == 0)
00416                 (local_modmes.NoisyStrips)->Fill(ibin,0.);
00417             }else{
00418               (local_modmes.NoisyStrips)->Fill(ibin,static_cast<float>(*iped));
00419               (local_modmes.NoisyStripDistribution)->Fill(static_cast<float>(*iped));
00420             }
00421           }
00422         }
00423 
00424 
00425       }    
00426   }
00427   if (firstEvent) firstEvent=false;  
00428 }
00429 //
00430 // -- End Run
00431 //    
00432 void SiStripMonitorPedestals::endRun(edm::Run const& run, edm::EventSetup const& eSetup) {
00433   bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00434   if (outputMEsInRootFile) {    
00435     std::string outPutFileName = conf_.getParameter<std::string>("OutPutFileName");
00436 //    dqmStore_->showDirStructure();
00437     dqmStore_->save(outPutFileName);
00438   }
00439 }
00440 //
00441 // -- End Job
00442 //    
00443 void SiStripMonitorPedestals::endJob(void){
00444   edm::LogInfo("SiStripMonitorPedestals") <<"SiStripMonitorPedestals::EndJob: " 
00445                                           << " Finishing!! ";        
00446 }
00447 //
00448 // -- Reset Monitor Elements corresponding to a detetor
00449 //    
00450 void SiStripMonitorPedestals::resetMEs(uint32_t idet){
00451   std::map<uint32_t, ModMEs >::iterator pos = PedMEs.find(idet);
00452   if (pos != PedMEs.end()) {
00453     ModMEs mod_me = pos->second;
00454 
00455     if (runTypeFlag_ == RunMode1 || runTypeFlag_ == RunMode3 ) { 
00456       mod_me.PedsPerStripDB->Reset();     
00457       mod_me.CMSubNoisePerStripDB->Reset();     
00458       mod_me.BadStripsDB->Reset();     
00459     }
00460     if (runTypeFlag_ == RunMode2 || runTypeFlag_ == RunMode3 ) { 
00461       mod_me.PedsPerStrip->Reset();      
00462       mod_me.PedsDistribution->Reset();      
00463       mod_me.PedsEvolution->Reset();      
00464       mod_me.CMSubNoisePerStrip->Reset();      
00465       mod_me.RawNoisePerStrip->Reset();      
00466       mod_me.CMSubNoiseProfile->Reset();      
00467       mod_me.RawNoiseProfile->Reset();      
00468       mod_me.NoisyStrips->Reset();      
00469       mod_me.CMDistribution->Reset();     
00470       mod_me.CMSlopeDistribution->Reset(); 
00471     }
00472   }
00473 }
00474 //
00475 // -- Fill CondDB Monitoring Elements
00476 //
00477 void SiStripMonitorPedestals::fillCondDBMEs(edm::EventSetup const& eSetup) {
00478   //get Pedestal and Noise  ES handle
00479   edm::ESHandle<SiStripPedestals> pedestalHandle;
00480   edm::ESHandle<SiStripNoises> noiseHandle;
00481   edm::ESHandle<SiStripQuality> qualityHandle;
00482   
00483   eSetup.get<SiStripPedestalsRcd>().get(pedestalHandle);
00484   eSetup.get<SiStripNoisesRcd>().get(noiseHandle);
00485   std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
00486   eSetup.get<SiStripQualityRcd>().get(quality_label, qualityHandle);
00487 
00488   for (std::map<uint32_t, ModMEs >::const_iterator i = PedMEs.begin() ; i!=PedMEs.end() ; i++) {
00489     uint32_t detid = i->first; 
00490     ModMEs local_modmes = i->second;
00491     edm::LogInfo("SiStripMonitorPedestals") <<" SiStripMonitorPedestals::analyze: " <<
00492       " Get Ped/Noise/Bad Strips from CondDb for DetId " << detid;
00493     int nStrip  = detcabling->nApvPairs(detid) * 256;
00494     // Get range of pedestal and noise for the detid
00495     SiStripNoises::Range noiseRange = noiseHandle->getRange(detid);
00496     SiStripPedestals::Range pedRange = pedestalHandle->getRange(detid);
00497     SiStripQuality::Range qualityRange = qualityHandle->getRange(detid);
00498     
00499     for(int istrip=0;istrip<nStrip;++istrip){
00500       try{
00501         //Fill Pedestals
00502         (local_modmes.PedsPerStripDB)->Fill(istrip+1,pedestalHandle->getPed(istrip,pedRange));
00503       }
00504       catch(cms::Exception& e){
00505         edm::LogError("SiStripMonitorPedestals") << "[SiStripMonitorPedestals::analyze]  cms::Exception accessing SiStripPedestalsService_.getPedestal("<<detid<<","<<istrip<<") :  "  << " " << e.what() ;
00506       }
00507       try{
00508         //Fill Noises
00509         (local_modmes.CMSubNoisePerStripDB)->Fill(istrip+1,noiseHandle->getNoise(istrip,noiseRange));
00510         
00511       }
00512       catch(cms::Exception& e){
00513         edm::LogError("SiStripMonitorPedestals") << "[SiStripMonitorPedestals::analyze]  cms::Exception accessing SiStripNoiseService_.getNoise("<<detid<<","<<istrip<<") :  "  << " " << e.what() ;
00514       }
00515       try{
00516         //Fill BadStripsNoise
00517         (local_modmes.BadStripsDB)->Fill(istrip+1,qualityHandle->IsStripBad(qualityRange,istrip)?1.:0.);
00518         
00519         
00520       }
00521       catch(cms::Exception& e){
00522         edm::LogError("SiStripMonitorPedestals") << "[SiStripMonitorPedestals::analyze]  cms::Exception accessing SiStripNoiseService_.getDisable("<<detid<<","<<istrip<<") :  "  << " " << e.what() ;
00523       }
00524     }//close istrip loop
00525   }
00526 }
00527 DEFINE_FWK_MODULE(SiStripMonitorPedestals);

Generated on Tue Jun 9 17:33:39 2009 for CMSSW by  doxygen 1.5.4