CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/SiStripMonitorDigi/src/SiStripBaselineValidator.cc

Go to the documentation of this file.
00001 // Original Author:  Ivan Amos Cali
00002 //         Created:  Mon Jul 28 14:10:52 CEST 2008
00003 // $Id: SiStripBaselineValidator.cc,v 1.3 2011/11/02 00:39:33 gowdy Exp $
00004 //
00005 //
00006  
00007 
00008 // system include files
00009 #include <memory>
00010 #include <iostream>
00011 
00012 // user include files
00013 #include "DQM/SiStripMonitorDigi/interface/SiStripBaselineValidator.h"
00014 #include "FWCore/Framework/interface/Frameworkfwd.h"
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00017 #include "FWCore/Framework/interface/ESHandle.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/ServiceRegistry/interface/Service.h"
00020 #include "DataFormats/Common/interface/DetSet.h"
00021 #include "DataFormats/Common/interface/DetSetVector.h"
00022 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00023 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
00024 #include "DQMServices/Core/interface/DQMStore.h"
00025 
00026 /*#include "DataFormats/TrackReco/interface/Track.h"
00027 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h" 
00028 #include "DataFormats/TrackCandidate/interface/TrackCandidate.h" 
00029 #include "DataFormats/TrackReco/interface/Track.h" 
00030 #include "DataFormats/TrackReco/interface/TrackFwd.h" 
00031 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00032 #include "DataFormats/VertexReco/interface/Vertex.h"
00033 */
00034 
00035 //ROOT inclusion
00036 #include "TH1F.h"
00037 #include "TH2F.h"
00038 #include "TString.h"
00039 #include "assert.h"
00040 #include <fstream>
00041 
00042 class TFile;
00043 
00044 
00045 
00046 using namespace edm;
00047 using namespace std;
00048 
00049 SiStripBaselineValidator::SiStripBaselineValidator(const edm::ParameterSet& conf){
00050 
00051   srcProcessedRawDigi_ =  conf.getParameter<edm::InputTag>( "srcProcessedRawDigi" );
00052  // hiSelectedTracks =  conf.getParameter<edm::InputTag>( "hiSelectedTracks" );
00053   createOutputFile_ = conf.getUntrackedParameter<bool>("saveFile",false);
00054   outputFile_   = conf.getParameter<std::string>("outputFile");
00055   dbe = &*edm::Service<DQMStore>();
00056 
00057 
00058 
00059 
00060 }
00061 
00062 SiStripBaselineValidator::~SiStripBaselineValidator()
00063 {
00064 }
00065 
00066 // ------------ method called once each job just before starting event loop  ------------
00067 void SiStripBaselineValidator::beginJob()
00068 {
00069 
00070  if(dbe){
00072     dbe->setCurrentFolder("SiStrip/BaselineValidator");
00073 
00074 
00075     h1NumbadAPVsRes_ = dbe->book1D("ResAPVs",";#ResAPVs", 100, 1.0, 10001);
00076     dbe->tag(h1NumbadAPVsRes_->getFullname(),1);
00077 
00078     h1ADC_vs_strip_ = dbe->book2D("ADCvsAPVs",";ADCvsAPVs", 768,-0.5,767.5,  1023, -0.5, 1022.5);
00079     dbe->tag(h1ADC_vs_strip_->getFullname(),2);
00080 
00081 
00082  }  
00083   
00084    return;
00085 
00086 }
00087 
00088 void SiStripBaselineValidator::analyze(const edm::Event& e, const edm::EventSetup& es)
00089 {
00090   /* edm::Handle<reco::TrackCollection> tracks;
00091    e.getByLabel("hiSelectedTracks", tracks);
00092 
00093    int ntracks =0;
00094    for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); track++) {
00095    ntracks++;
00096     
00097    }
00098 */
00099 
00100 
00101   edm::Handle< edm::DetSetVector<SiStripRawDigi> > moduleRawDigi;
00102   e.getByLabel(srcProcessedRawDigi_,moduleRawDigi);
00103   edm::DetSetVector<SiStripRawDigi>::const_iterator itRawDigis = moduleRawDigi->begin();
00104  
00105   //  uint32_t Nmodule = moduleRawDigi->size();     
00106 
00107    int NumResAPVs=0;
00108    for (; itRawDigis != moduleRawDigi->end(); ++itRawDigis) {   
00109      
00110 
00111      edm::DetSet<SiStripRawDigi>::const_iterator itRaw = itRawDigis->begin(); 
00112      int strip =0, totADC=0;
00113 
00114      for(;itRaw != itRawDigis->end(); ++itRaw, ++strip){  
00115        
00116        float adc = itRaw->adc();
00117        h1ADC_vs_strip_->Fill(strip,adc); 
00118 
00119 
00120 
00121        totADC+= adc;
00122        
00123        if(strip%127 ==0){
00124          if(totADC!= 0){
00125            totADC =0;
00126            
00127            NumResAPVs++;
00128 
00129          }
00130        }
00131        
00132      } 
00133    
00134      
00135    }  
00136 
00138 
00139    h1NumbadAPVsRes_->Fill(NumResAPVs); 
00140 
00141 
00142 
00143 } 
00144 
00145 
00146 
00147 // ------------ method called once each job just after ending the event loop  ------------
00148 void 
00149 SiStripBaselineValidator::endJob() {
00150 
00151     if (!outputFile_.empty() && createOutputFile_) {
00152        dbe->save(outputFile_);
00153     }  
00154 }
00155 
00156 //define this as a plug-in
00157 DEFINE_FWK_MODULE(SiStripBaselineValidator);
00158