Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:29

0001 // -*- C++ -*-
0002 //
0003 // Class:      EcalTPInputAnalyzer
0004 //
0005 /**\class EcalTPInputAnalyzer
0006 
0007  Description: test of the input of EcalTrigPrimProducer
0008 
0009 */
0010 //
0011 //
0012 // Original Author:  Ursula Berthon
0013 //         Created:  Thu Jul 4 11:38:38 CEST 2005
0014 //
0015 //
0016 
0017 // system include files
0018 #include <memory>
0019 #include <utility>
0020 
0021 // user include files
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 
0025 #include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h"
0026 #include "EcalTPInputAnalyzer.h"
0027 
0028 EcalTPInputAnalyzer::EcalTPInputAnalyzer(const edm::ParameterSet &iConfig)
0029     : producer_(iConfig.getParameter<std::string>("Producer")),
0030       ebLabel_(iConfig.getParameter<std::string>("EBLabel")),
0031       eeLabel_(iConfig.getParameter<std::string>("EELabel")),
0032       ebToken_(consumes<EBDigiCollection>(edm::InputTag(producer_, ebLabel_))),
0033       eeToken_(consumes<EEDigiCollection>(edm::InputTag(producer_, eeLabel_))) {
0034   usesResource(TFileService::kSharedResource);
0035 
0036   edm::Service<TFileService> fs;
0037   histEndc = fs->make<TH1I>("AdcE", "Adc-s for Endcap", 100, 0., 5000.);
0038   histBar = fs->make<TH1I>("AdcB", "Adc-s for Barrel", 100, 0., 5000.);
0039   ecal_parts_.push_back("Barrel");
0040   ecal_parts_.push_back("Endcap");
0041 
0042   //   for (unsigned int i=0;i<2;++i) {
0043   //     ecal_et_[i] = fs->make<TH1I>(ecal_parts_[i].c_str(),"Et",255,0,255);
0044   //     char title[30];
0045   //     sprintf(title,"%s_ttf",ecal_parts_[i].c_str());
0046   //     ecal_tt_[i] = fs->make<TH1I>(title,"TTF",10,0,10);
0047   //     sprintf(title,"%s_fgvb",ecal_parts_[i].c_str());
0048   //     ecal_fgvb_[i] = fs->make<TH1I>(title,"FGVB",10,0,10);
0049   //   }
0050 }
0051 
0052 //
0053 // member functions
0054 //
0055 
0056 // ------------ method called to analyze the data  ------------
0057 void EcalTPInputAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0058   bool barrel = true;
0059   const edm::Handle<EBDigiCollection> &ebDigis = iEvent.getHandle(ebToken_);
0060   if (!ebDigis.isValid()) {
0061     barrel = false;
0062     edm::LogWarning("EcalTPG") << " Couldnt find Barrel dataframes with Producer:" << producer_
0063                                << " and label: " << ebLabel_;
0064   }
0065   bool endcap = true;
0066   const edm::Handle<EEDigiCollection> &eeDigis = iEvent.getHandle(eeToken_);
0067   if (!eeDigis.isValid()) {
0068     endcap = false;
0069     edm::LogWarning("EcalTPG") << " Couldnt find Endcap dataframes with Producer:" << producer_
0070                                << " and label: " << eeLabel_;
0071   }
0072   // barrel
0073   if (barrel) {
0074     const EBDigiCollection *ebdb = ebDigis.product();
0075     for (unsigned int i = 0; i < ebDigis->size(); ++i) {
0076       EBDataFrame ebdf = (*ebdb)[i];
0077       int nrSamples = ebdf.size();
0078       // unsigned int nrSamples=(ebDigis.product())[i].size();
0079       for (int is = 0; is < nrSamples; ++is) {
0080         //  EcalMGPASample sam=((ebDigis.product())[i])[is];
0081         EcalMGPASample sam = ebdf[is];
0082         histBar->Fill(sam.adc());
0083       }
0084     }
0085   }
0086   // endcap
0087   if (endcap) {
0088     const EEDigiCollection *eedb = eeDigis.product();
0089     for (unsigned int i = 0; i < eeDigis->size(); ++i) {
0090       EEDataFrame eedf = (*eedb)[i];
0091       int nrSamples = eedf.size();
0092       for (int is = 0; is < nrSamples; ++is) {
0093         EcalMGPASample sam = eedf[is];
0094         histEndc->Fill(sam.adc());
0095       }
0096     }
0097   }
0098   //   // Get input
0099   //   const edm::Handle<EcalTrigPrimDigiCollection>& tp = iEvent.getHandle(tpToken_);
0100   //   for (unsigned int i=0;i<tp.product()->size();i++) {
0101   //     EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
0102   //     int subdet=d.id().subDet()-1;
0103   //       ecal_et_[subdet]->Fill(d.compressedEt());
0104   //       ecal_tt_[subdet]->Fill(d.ttFlag());
0105   //       ecal_fgvb_[subdet]->Fill(d.fineGrain());
0106   //   }
0107 }