// -*- C++ -*- // // Package: HFPedAnalyzer // Class: HFPedAnalyzer // /**\class HFPedAnalyzer HFPedAnalyzer.cc Analyzers/HFPedAnalyzer/src/HFPedAnalyzer.cc Description: [one line class summary] Implementation: [Notes on implementation] */ // // Original Author: Sercan Sen,510 1-003,+41227679098, // Created: Thu Nov 3 13:32:30 CET 2011 // $Id$ // // // system include files #include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" // Analysis include files #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" #include "CalibFormats/HcalObjects/interface/HcalDbService.h" #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h" #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h" #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h" //TFile Service #include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" // // class declaration // class HFPedAnalyzer:public edm::EDAnalyzer { public: explicit HFPedAnalyzer(const edm::ParameterSet &); ~HFPedAnalyzer(); static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: virtual void beginJob(); virtual void analyze(const edm::Event &, const edm::EventSetup &); virtual void endJob(); virtual void beginRun(edm::Run const &, edm::EventSetup const &); virtual void endRun(edm::Run const &, edm::EventSetup const &); virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &); virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &); edm::ESHandle < HcalDbService > conditions_; edm::Service histServ; TH1F *h_plotADC; TH1F *h_plotADC_ped; // ----------member data --------------------------- }; // // constants, enums and typedefs // // // static data member definitions // // // constructors and destructor // HFPedAnalyzer::HFPedAnalyzer(const edm::ParameterSet & iConfig) { //now do what ever initialization is needed } HFPedAnalyzer::~HFPedAnalyzer() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ method called for each event ------------ void HFPedAnalyzer::analyze(const edm::Event & iEvent, const edm::EventSetup & iSetup) { using namespace edm; iSetup.get < HcalDbRecord > ().get(conditions_); // hf digis Handle < HFDigiCollection > hf_digi_h; iEvent.getByType(hf_digi_h); const HFDigiCollection *hf_digi = hf_digi_h.failedToGet()? 0 : &*hf_digi_h; if (hf_digi) { for (HFDigiCollection::const_iterator j = hf_digi->begin(); j != hf_digi->end(); j++) { const HFDataFrame digi = (const HFDataFrame)(*j); HcalDetId id = digi.id(); std::cout << "NEW DIGI [eta, phi, dep] = " << id.ieta() << ", " << id.iphi() << ", " << id.depth() << std::endl; const HcalQIECoder *channelCoder2 = conditions_->getHcalCoder(digi.id()); const HcalQIEShape *theShape = conditions_->getHcalShape(); HcalCoderDb coder2(*channelCoder2, *theShape); const HcalPedestal* m_ped; HcalCalibrations calibs_; calibs_ = conditions_->getHcalCalibrations(digi.id()); m_ped = conditions_->getPedestal(digi.id()); float SignalADC = 0.; float SignalADCPed = 0.; int nTS = digi.size(); for (int i = 0; i < nTS; ++i) { int capid = digi[i].capid(); float fC = channelCoder2->charge(*theShape,digi[i].adc(),digi[i].capid()); int ped = m_ped->getValue(capid); float Signal = fC - ped; // in this case, pedestals are in ADC . SignalADC += digi[i].adc(); SignalADCPed += digi[i].adc()-ped; std::cout << "[Time Slice, capid, ped, adc, linADC, fC, signal] = [" << i << ", " << capid << ", " << ped << ", " << digi[i].adc() << ", " << digi[i].nominal_fC() << ", " << fC << ", " << Signal << ", " << "]" << std::endl; } h_plotADC->Fill( SignalADC / nTS ); h_plotADC_ped->Fill( SignalADCPed / nTS ); } // digi loop } else { std::cout << "HF Digi is not available " << std::endl; } } // ------------ method called once each job just before starting event loop ------------ void HFPedAnalyzer::beginJob() { TFileDirectory PULSE = histServ->mkdir("PLOTS"); h_plotADC = PULSE.make("ADC","ADC",40,-2.,8.); h_plotADC_ped = PULSE.make("ADC_ped","Pedestal substracted ADC",40,-2.,8.); } // ------------ method called once each job just after ending the event loop ------------ void HFPedAnalyzer::endJob() { } // ------------ method called when starting to processes a run ------------ void HFPedAnalyzer::beginRun(edm::Run const &, edm::EventSetup const &) { } // ------------ method called when ending the processing of a run ------------ void HFPedAnalyzer::endRun(edm::Run const &, edm::EventSetup const &) { } // ------------ method called when starting to processes a luminosity block ------------ void HFPedAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) { } // ------------ method called when ending the processing of a luminosity block ------------ void HFPedAnalyzer::endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) { } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void HFPedAnalyzer::fillDescriptions(edm::ConfigurationDescriptions & descriptions) { //The following says we do not know what parameters are allowed so do no validation // Please change this to state exactly what you do use, even if it is no parameters edm::ParameterSetDescription desc; desc.setUnknown(); descriptions.addDefault(desc); } //define this as a plug-in DEFINE_FWK_MODULE(HFPedAnalyzer);