CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTPInputAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Class:      EcalTPInputAnalyzer
00004 // 
00010 //
00011 //
00012 // Original Author:  Ursula Berthon
00013 //         Created:  Thu Jul 4 11:38:38 CEST 2005
00014 // $Id: EcalTPInputAnalyzer.cc,v 1.5 2008/01/17 13:40:52 uberthon Exp $
00015 //
00016 //
00017 
00018 
00019 // system include files
00020 #include <memory>
00021 #include <utility>
00022 
00023 // user include files
00024 #include "FWCore/Framework/interface/Frameworkfwd.h"
00025 #include "FWCore/Framework/interface/EDAnalyzer.h"
00026 
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/Framework/interface/MakerMacros.h"
00029 
00030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032 
00033 #include "EcalTPInputAnalyzer.h"
00034 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00035 #include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h"
00036 
00037 using namespace edm;
00038 
00039 EcalTPInputAnalyzer::EcalTPInputAnalyzer(const edm::ParameterSet& iConfig)
00040 
00041 {
00042   histfile_=new TFile("histos.root","UPDATE");
00043   histEndc = new TH1I("AdcE","Adc-s for Endcap",100,0.,5000.);
00044   histBar = new TH1I("AdcB","Adc-s for Barrel",100,0.,5000.);
00045   ecal_parts_.push_back("Barrel");
00046   ecal_parts_.push_back("Endcap");
00047 
00048 //   for (unsigned int i=0;i<2;++i) {
00049 //     ecal_et_[i]=new TH1I(ecal_parts_[i].c_str(),"Et",255,0,255);
00050 //     char title[30];
00051 //     sprintf(title,"%s_ttf",ecal_parts_[i].c_str());
00052 //     ecal_tt_[i]=new TH1I(title,"TTF",10,0,10);
00053 //     sprintf(title,"%s_fgvb",ecal_parts_[i].c_str());
00054 //     ecal_fgvb_[i]=new TH1I(title,"FGVB",10,0,10);
00055 //   }
00056    producer_= iConfig.getParameter<std::string>("Producer");
00057    ebLabel_= iConfig.getParameter<std::string>("EBLabel");
00058    eeLabel_= iConfig.getParameter<std::string>("EELabel");
00059 }
00060 
00061 
00062 EcalTPInputAnalyzer::~EcalTPInputAnalyzer()
00063 {
00064  
00065    // do anything here that needs to be done at desctruction time
00066    // (e.g. close files, deallocate resources etc.)
00067 
00068   histfile_->Write();
00069   histfile_->Close();
00070 
00071 }
00072 
00073 
00074 //
00075 // member functions
00076 //
00077 
00078 // ------------ method called to analyze the data  ------------
00079 void
00080 EcalTPInputAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00081 {
00082   using namespace edm;
00083   using namespace std;
00084 
00085   bool barrel=true;
00086   edm::Handle<EBDigiCollection> ebDigis;
00087   edm::Handle<EEDigiCollection> eeDigis;
00088   if (!iEvent.getByLabel(producer_,ebLabel_,ebDigis)) {
00089     barrel=false;
00090     edm::LogWarning("EcalTPG") <<" Couldnt find Barrel dataframes with Producer:"<<producer_<<" and label: "<<ebLabel_;
00091   }
00092   bool endcap=true;
00093   if (!iEvent.getByLabel(producer_,eeLabel_,eeDigis)) {
00094     endcap=false;
00095     edm::LogWarning("EcalTPG") <<" Couldnt find Endcap dataframes with Producer:"<<producer_<<" and label: "<<eeLabel_;
00096   }
00097   //barrel
00098   if (barrel) {
00099     const EBDigiCollection *ebdb=ebDigis.product();
00100     for (unsigned int i=0;i<ebDigis->size();++i) {
00101       EBDataFrame ebdf=(*ebdb)[i];
00102       int nrSamples=ebdf.size();
00103       //unsigned int nrSamples=(ebDigis.product())[i].size();
00104       for (int is=0;is<nrSamples;++is) {
00105         //      EcalMGPASample sam=((ebDigis.product())[i])[is];
00106         EcalMGPASample sam=ebdf[is];
00107         histBar->Fill(sam.adc());
00108       }
00109     }
00110   }
00111   //endcap
00112   if (endcap) {
00113     const EEDigiCollection *eedb=eeDigis.product();
00114     for (unsigned int i=0;i<eeDigis->size();++i) {
00115       EEDataFrame eedf=(*eedb)[i];
00116       int nrSamples=eedf.size();
00117       for (int is=0;is<nrSamples;++is) {
00118         EcalMGPASample sam=eedf[is];
00119         histEndc->Fill(sam.adc());
00120       }
00121     }
00122   }
00123 //   // Get input
00124 //   edm::Handle<EcalTrigPrimDigiCollection> tp;
00125 //   iEvent.getByLabel(label_,producer_,tp);
00126 //   for (unsigned int i=0;i<tp.product()->size();i++) {
00127 //     EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
00128 //     int subdet=d.id().subDet()-1;
00129 //       ecal_et_[subdet]->Fill(d.compressedEt());
00130 //       ecal_tt_[subdet]->Fill(d.ttFlag());
00131 //       ecal_fgvb_[subdet]->Fill(d.fineGrain());
00132 //   }
00133 }
00134 
00135 void
00136 EcalTPInputAnalyzer::endJob(){
00137   histEndc ->Write();
00138   histBar  ->Write();
00139 }
00140   
00141     
00142 
00143