CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibRecHitWorkerAnalFit.cc
Go to the documentation of this file.
1 
13 
14 #include <iostream>
15 #include <cmath>
16 
18 
20 
21 //#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
22 //#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
25 
26 //#include "CLHEP/Matrix/Matrix.h"
27 //#include "CLHEP/Matrix/SymMatrix.h"
28 #include <vector>
29 
32 
36 
39 {
40 }
41 
42 
43 void
45 {
46  // Gain Ratios
47  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
48  es.get<EcalGainRatiosRcd>().get(pRatio);
49  LogDebug("EcalUncalibRecHitDebug") << "done." ;
50 
51  // fetch the pedestals from the cond DB via EventSetup
52  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
53  es.get<EcalPedestalsRcd>().get( pedHandle );
54  LogDebug("EcalUncalibRecHitDebug") << "done." ;
55 }
56 
57 bool
61 {
62  using namespace edm;
63 
64  const EcalGainRatioMap & gainMap = pRatio.product()->getMap(); // map of gain ratios
65  const EcalPedestalsMap & pedMap = pedHandle.product()->getMap(); // map of pedestals
66 
67  EcalPedestalsMapIterator pedIter; // pedestal iterator
68  EcalPedestals::Item aped; // pedestal object for a single xtal
69 
70  EcalGainRatioMap::const_iterator gainIter; // gain iterator
71  EcalMGPAGainRatio aGain; // gain object for a single xtal
72 
73  DetId detid( itdg->id() );
74 
75  // find pedestals for this channel
76  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id(); // FIXME
77  pedIter = pedMap.find( detid );
78  if( pedIter != pedMap.end() ) {
79  aped = (*pedIter);
80  } else {
81  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find pedestals for channel: ";
82  if ( detid.subdetId() == EcalBarrel ) {
83  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId( detid );
84  } else {
85  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId( detid );
86  }
87  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
88  return false;
89  }
90  double pedVec[3];
91  pedVec[0] = aped.mean_x12;
92  pedVec[1] = aped.mean_x6;
93  pedVec[2] = aped.mean_x1;
94 
95 
96  // find gain ratios
97  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << itdg->id(); // FIXME
98  gainIter = gainMap.find( detid );
99  if( gainIter != gainMap.end() ) {
100  aGain = (*gainIter);
101  } else {
102  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find gain ratios for channel: ";
103  if ( detid.subdetId() == EcalBarrel ) {
104  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId( detid );
105  } else {
106  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId( detid );
107  }
108  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
109  return false;
110  }
111  double gainRatios[3];
112  gainRatios[0] = 1.;
113  gainRatios[1] = aGain.gain12Over6();
114  gainRatios[2] = aGain.gain6Over1()*aGain.gain12Over6();
115 
116  if ( detid.subdetId() == EcalBarrel ) {
117  EcalUncalibratedRecHit aHit = algoEB_.makeRecHit(*itdg, pedVec, gainRatios, 0 ,0);
118  result.push_back( aHit );
119  if(aHit.amplitude()>0.) {
120  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EBDataFrame with id: "
121  << EBDetId( detid )
122  << "\n" << "uncalib rechit amplitude: " << aHit.amplitude();
123  }
124  } else {
125  EcalUncalibratedRecHit aHit = algoEE_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
126  result.push_back( aHit );
127  if(aHit.amplitude()>0.) {
128  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EEDataFrame with id: "
129  << EEDetId( detid ) << "\n"
130  << "uncalib rechit amplitude: " << aHit.amplitude();
131  }
132  }
133  return true;
134 }
135 
#define LogDebug(id)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void push_back(T const &t)
edm::ESHandle< EcalPedestals > pedHandle
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:52
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
tuple result
Definition: query.py:137
EcalUncalibRecHitRecAnalFitAlgo< EBDataFrame > algoEB_
EcalUncalibRecHitRecAnalFitAlgo< EEDataFrame > algoEE_
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix)
Compute parameters.
EcalUncalibRecHitWorkerAnalFit(const edm::ParameterSet &ps, edm::ConsumesCollector &c)
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
edm::ESHandle< EcalGainRatios > pRatio
#define DEFINE_EDM_PLUGIN(factory, type, name)