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 "FWCore/MessageLogger/interface/MessageLogger.h"
00016 #include <iostream>
00017
00018
00019 CastorSimpleReconstructor::CastorSimpleReconstructor(edm::ParameterSet const& conf):
00020 reco_(conf.getParameter<int>("firstSample"),conf.getParameter<int>("samplesToAdd"),conf.getParameter<bool>("correctForTimeslew"),
00021 conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
00022 det_(DetId::Hcal),
00023 inputLabel_(conf.getParameter<edm::InputTag>("digiLabel"))
00024 {
00025 std::string subd=conf.getParameter<std::string>("Subdetector");
00026 if (!strcasecmp(subd.c_str(),"CASTOR")) {
00027 det_=DetId::Calo;
00028 subdet_=HcalCastorDetId::SubdetectorId;
00029 produces<CastorRecHitCollection>();
00030 } else {
00031 edm::LogWarning("CastorSimpleReconstructor") << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
00032 }
00033
00034 }
00035
00036 CastorSimpleReconstructor::~CastorSimpleReconstructor() {
00037 }
00038
00039 void CastorSimpleReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00040 {
00041
00042 edm::ESHandle<CastorDbService> conditions;
00043 eventSetup.get<CastorDbRecord>().get(conditions);
00044 const CastorQIEShape* shape = conditions->getCastorShape ();
00045
00046
00047
00048 int runNumber = e.run();
00049 if (runNumber < 129456) { CastorSimpleRecAlgo usedRecAlgo2009(1,4,false,false,0.0); reco_ = usedRecAlgo2009;}
00050
00051 CastorCalibrations calibrations;
00052
00053
00054 if (det_==DetId::Calo && subdet_==HcalCastorDetId::SubdetectorId) {
00055 edm::Handle<CastorDigiCollection> digi;
00056 e.getByLabel(inputLabel_,digi);
00057
00058
00059 std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
00060
00061 CastorDigiCollection::const_iterator i;
00062 for (i=digi->begin(); i!=digi->end(); i++) {
00063 HcalCastorDetId cell = i->id();
00064 const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);
00065
00066
00067
00068
00069 const CastorQIECoder* channelCoder = conditions->getCastorCoder (cell);
00070 CastorCoderDb coder (*channelCoder, *shape);
00071 rec->push_back(reco_.reconstruct(*i,coder,calibrations));
00072 }
00073
00074 e.put(rec);
00075
00076 }
00077 }