CMS 3D CMS Logo

CastorSimpleReconstructor.cc

Go to the documentation of this file.
00001 using namespace std;
00002 #include "CastorSimpleReconstructor.h"
00003 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00004 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00005 #include "DataFormats/Common/interface/EDCollection.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/Framework/interface/Selector.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "CalibFormats/CastorObjects/interface/CastorCoderDb.h"
00011 #include "CalibFormats/CastorObjects/interface/CastorCalibrations.h"
00012 #include "CalibFormats/CastorObjects/interface/CastorDbService.h"
00013 #include "CalibFormats/CastorObjects/interface/CastorDbRecord.h"
00014 
00015 #include <iostream>
00016 
00017     
00018 CastorSimpleReconstructor::CastorSimpleReconstructor(edm::ParameterSet const& conf):
00019   reco_(conf.getParameter<int>("firstSample"),conf.getParameter<int>("samplesToAdd"),conf.getParameter<bool>("correctForTimeslew"),
00020         conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
00021   det_(DetId::Hcal),
00022   inputLabel_(conf.getParameter<edm::InputTag>("digiLabel"))    
00023 {
00024   std::string subd=conf.getParameter<std::string>("Subdetector");
00025   if (!strcasecmp(subd.c_str(),"CASTOR")) {
00026     det_=DetId::Calo;
00027     subdet_=HcalCastorDetId::SubdetectorId;
00028     produces<CastorRecHitCollection>();
00029   } else {
00030     std::cout << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
00031   }       
00032   
00033 }
00034 
00035 CastorSimpleReconstructor::~CastorSimpleReconstructor() {
00036 }
00037 
00038 void CastorSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00039 {
00040   // get conditions
00041   edm::ESHandle<CastorDbService> conditions;
00042   eventSetup.get<CastorDbRecord>().get(conditions);
00043   const CastorQIEShape* shape = conditions->getCastorShape (); // this one is generic
00044   
00045   CastorCalibrations calibrations;
00046   
00047   if (det_==DetId::Hcal) {
00048      if (det_==DetId::Calo && subdet_==HcalCastorDetId::SubdetectorId) {
00049     edm::Handle<CastorDigiCollection> digi;
00050     e.getByLabel(inputLabel_,digi);
00051     
00052     // create empty output
00053     std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
00054     // run the algorithm
00055     CastorDigiCollection::const_iterator i;
00056     for (i=digi->begin(); i!=digi->end(); i++) {
00057       HcalCastorDetId cell = i->id();     
00058       // const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);
00059 
00060 
00061 conditions->makeCastorCalibration (cell, &calibrations);
00062 
00063       const CastorQIECoder* channelCoder = conditions->getCastorCoder (cell);
00064       CastorCoderDb coder (*channelCoder, *shape);
00065       rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00066     }
00067     // return result
00068     e.put(rec);     
00069      }
00070   }
00071 }

Generated on Tue Jun 9 17:43:44 2009 for CMSSW by  doxygen 1.5.4