CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoLocalCalo/HcalRecProducers/src/ZdcHitReconstructor.cc

Go to the documentation of this file.
00001 #include "ZdcHitReconstructor.h"
00002 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00003 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00004 #include "DataFormats/Common/interface/EDCollection.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/Framework/interface/Selector.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00010 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00011 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00012 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00013 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00014 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00015 
00016 #include <iostream>
00017 
00018 /*  Zdc Hit reconstructor allows for CaloRecHits with status words */
00019 
00020 ZdcHitReconstructor::ZdcHitReconstructor(edm::ParameterSet const& conf):
00021   reco_(conf.getParameter<bool>("correctForTimeslew"),
00022         conf.getParameter<bool>("correctForPhaseContainment"),
00023         conf.getParameter<double>("correctionPhaseNS"),
00024         conf.getParameter<int>("recoMethod")),
00025   det_(DetId::Hcal),
00026   inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
00027   correctTiming_(conf.getParameter<bool>("correctTiming")),
00028   setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
00029   setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
00030   setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
00031   setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
00032   dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
00033   AuxTSvec_(conf.getParameter<std::vector<int> >("AuxTSvec"))
00034   
00035 { 
00036   std::sort(AuxTSvec_.begin(),AuxTSvec_.end()); // sort vector in ascending TS order
00037   std::string subd=conf.getParameter<std::string>("Subdetector");
00038  
00039  if (setSaturationFlags_)
00040     {
00041       const edm::ParameterSet& pssat      = conf.getParameter<edm::ParameterSet>("saturationParameters");
00042       saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
00043     }
00044   if (!strcasecmp(subd.c_str(),"ZDC")) {
00045     det_=DetId::Calo;
00046     subdet_=HcalZDCDetId::SubdetectorId;
00047     produces<ZDCRecHitCollection>();
00048   } else if (!strcasecmp(subd.c_str(),"CALIB")) {
00049     subdet_=HcalOther;
00050     subdetOther_=HcalCalibration;
00051     produces<HcalCalibRecHitCollection>();
00052   } else {
00053     std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
00054   }       
00055   
00056 }
00057 
00058 ZdcHitReconstructor::~ZdcHitReconstructor() {;
00059 }
00060 void ZdcHitReconstructor::beginRun(edm::Run&r, edm::EventSetup const & es){
00061 
00062    edm::ESHandle<HcalLongRecoParams> p;
00063    es.get<HcalLongRecoParamsRcd>().get(p);
00064    myobject = new HcalLongRecoParams(*p.product());
00065 }
00066 
00067 void ZdcHitReconstructor::endRun(edm::Run&r, edm::EventSetup const & es){
00068   if (myobject) delete myobject;
00069 }
00070 void ZdcHitReconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00071 {
00072   // get conditions
00073   edm::ESHandle<HcalDbService> conditions;
00074   eventSetup.get<HcalDbRecord>().get(conditions);
00075   const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
00076   
00077   edm::ESHandle<HcalChannelQuality> p;
00078   eventSetup.get<HcalChannelQualityRcd>().get(p);
00079   HcalChannelQuality* myqual = new HcalChannelQuality(*p.product());
00080 
00081   edm::ESHandle<HcalSeverityLevelComputer> mycomputer;
00082   eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
00083   const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
00084   
00085   // define vectors to pass noiseTS and signalTS
00086   std::vector<unsigned int> mySignalTS;
00087   std::vector<unsigned int> myNoiseTS;
00088   
00089    if (det_==DetId::Calo && subdet_==HcalZDCDetId::SubdetectorId) {
00090      edm::Handle<ZDCDigiCollection> digi;
00091      e.getByLabel(inputLabel_,digi);
00092      
00093      // create empty output
00094      std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
00095      rec->reserve(digi->size());
00096      // run the algorithm
00097      ZDCDigiCollection::const_iterator i;
00098      for (i=digi->begin(); i!=digi->end(); i++) {
00099        HcalZDCDetId cell = i->id();
00100       DetId detcell=(DetId)cell;
00101       // check on cells to be ignored and dropped: (rof,20.Feb.09)
00102       const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
00103       if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
00104         if (dropZSmarkedPassed_)
00105           if (i->zsMarkAndPass()) continue;
00106         const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
00107         const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
00108         HcalCoderDb coder (*channelCoder, *shape);
00109 
00110 // get db values for signalTSs and noiseTSs
00111    const HcalLongRecoParam* myParams = myobject->getValues(detcell);
00112    mySignalTS.clear();
00113    myNoiseTS.clear();
00114    mySignalTS = myParams->signalTS();
00115    myNoiseTS = myParams->noiseTS(); 
00116 
00117         rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
00118         (rec->back()).setFlags(0);
00119         if (setSaturationFlags_)
00120           saturationFlagSetter_->setSaturationFlag(rec->back(),*i);     
00121 
00122         // Set auxiliary flag with subset of digi information
00123         // ZDC aux flag can store non-contiguous set of values
00124         int auxflag=0;
00125         for (unsigned int xx=0; xx<AuxTSvec_.size() && xx<4;++xx)
00126           {
00127             if (AuxTSvec_[xx]<0 || AuxTSvec_[xx]>9) continue; // don't allow 
00128             auxflag+=(i->sample(AuxTSvec_[xx]).adc())<<(7*xx); // store the time slices in the first 28 bits of aux, a set of 4 7-bit a dc values
00129           }
00130         // bits 28 and 29 are reserved for capid of the first time slice saved in aux
00131         if (AuxTSvec_.size()>0)
00132           auxflag+=((i->sample(AuxTSvec_[0]).capid())<<28);
00133         (rec->back()).setAux(auxflag);
00134      }
00135      // return result
00136      e.put(rec);     
00137    } // else if (det_==DetId::Calo...)
00138 
00139    delete myqual;
00140 } // void HcalHitReconstructor::produce(...)