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 
16 
17 #include <iostream>
18 #include <cmath>
19 
21 
23 
24 //#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
25 //#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
28 
29 //#include "CLHEP/Matrix/Matrix.h"
30 //#include "CLHEP/Matrix/SymMatrix.h"
31 #include <vector>
32 
35 
39 
42 {
43 }
44 
45 
46 void
48 {
49  // Gain Ratios
50  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
51  es.get<EcalGainRatiosRcd>().get(pRatio);
52  LogDebug("EcalUncalibRecHitDebug") << "done." ;
53 
54  // fetch the pedestals from the cond DB via EventSetup
55  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
56  es.get<EcalPedestalsRcd>().get( pedHandle );
57  LogDebug("EcalUncalibRecHitDebug") << "done." ;
58 }
59 
60 bool
64 {
65  using namespace edm;
66 
67  const EcalGainRatioMap & gainMap = pRatio.product()->getMap(); // map of gain ratios
68  const EcalPedestalsMap & pedMap = pedHandle.product()->getMap(); // map of pedestals
69 
70  EcalPedestalsMapIterator pedIter; // pedestal iterator
71  EcalPedestals::Item aped; // pedestal object for a single xtal
72 
73  EcalGainRatioMap::const_iterator gainIter; // gain iterator
74  EcalMGPAGainRatio aGain; // gain object for a single xtal
75 
76  DetId detid( itdg->id() );
77 
78  // find pedestals for this channel
79  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id(); // FIXME
80  pedIter = pedMap.find( detid );
81  if( pedIter != pedMap.end() ) {
82  aped = (*pedIter);
83  } else {
84  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find pedestals for channel: ";
85  if ( detid.subdetId() == EcalBarrel ) {
86  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId( detid );
87  } else {
88  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId( detid );
89  }
90  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
91  return false;
92  }
93  double pedVec[3];
94  pedVec[0] = aped.mean_x12;
95  pedVec[1] = aped.mean_x6;
96  pedVec[2] = aped.mean_x1;
97 
98 
99  // find gain ratios
100  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << itdg->id(); // FIXME
101  gainIter = gainMap.find( detid );
102  if( gainIter != gainMap.end() ) {
103  aGain = (*gainIter);
104  } else {
105  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find gain ratios for channel: ";
106  if ( detid.subdetId() == EcalBarrel ) {
107  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId( detid );
108  } else {
109  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId( detid );
110  }
111  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
112  return false;
113  }
114  double gainRatios[3];
115  gainRatios[0] = 1.;
116  gainRatios[1] = aGain.gain12Over6();
117  gainRatios[2] = aGain.gain6Over1()*aGain.gain12Over6();
118 
119  if ( detid.subdetId() == EcalBarrel ) {
120  EcalUncalibratedRecHit aHit = algoEB_.makeRecHit(*itdg, pedVec, gainRatios, 0 ,0);
121  result.push_back( aHit );
122  if(aHit.amplitude()>0.) {
123  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EBDataFrame with id: "
124  << EBDetId( detid )
125  << "\n" << "uncalib rechit amplitude: " << aHit.amplitude();
126  }
127  } else {
128  EcalUncalibratedRecHit aHit = algoEE_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
129  result.push_back( aHit );
130  if(aHit.amplitude()>0.) {
131  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EEDataFrame with id: "
132  << EEDetId( detid ) << "\n"
133  << "uncalib rechit amplitude: " << aHit.amplitude();
134  }
135  }
136  return true;
137 }
138 
#define LogDebug(id)
EcalUncalibRecHitWorkerAnalFit(const edm::ParameterSet &ps)
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:37
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.
Definition: DetId.h:20
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)