CMS 3D CMS Logo

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 
43 {
44 }
45 
46 
47 void
49 {
50  // Gain Ratios
51  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
52  es.get<EcalGainRatiosRcd>().get(pRatio);
53  LogDebug("EcalUncalibRecHitDebug") << "done." ;
54 
55  // fetch the pedestals from the cond DB via EventSetup
56  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
57  es.get<EcalPedestalsRcd>().get( pedHandle );
58  LogDebug("EcalUncalibRecHitDebug") << "done." ;
59 }
60 
61 bool
65 {
66  using namespace edm;
67 
68  const EcalGainRatioMap & gainMap = pRatio.product()->getMap(); // map of gain ratios
69  const EcalPedestalsMap & pedMap = pedHandle.product()->getMap(); // map of pedestals
70 
71  EcalPedestalsMapIterator pedIter; // pedestal iterator
72  EcalPedestals::Item aped; // pedestal object for a single xtal
73 
74  EcalGainRatioMap::const_iterator gainIter; // gain iterator
75  EcalMGPAGainRatio aGain; // gain object for a single xtal
76 
77  DetId detid( itdg->id() );
78 
79  // find pedestals for this channel
80  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id(); // FIXME
81  pedIter = pedMap.find( detid );
82  if( pedIter != pedMap.end() ) {
83  aped = (*pedIter);
84  } else {
85  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find pedestals for channel: ";
86  if ( detid.subdetId() == EcalBarrel ) {
87  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId( detid );
88  } else {
89  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId( detid );
90  }
91  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
92  return false;
93  }
94  double pedVec[3];
95  pedVec[0] = aped.mean_x12;
96  pedVec[1] = aped.mean_x6;
97  pedVec[2] = aped.mean_x1;
98 
99 
100  // find gain ratios
101  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << itdg->id(); // FIXME
102  gainIter = gainMap.find( detid );
103  if( gainIter != gainMap.end() ) {
104  aGain = (*gainIter);
105  } else {
106  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find gain ratios for channel: ";
107  if ( detid.subdetId() == EcalBarrel ) {
108  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId( detid );
109  } else {
110  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId( detid );
111  }
112  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
113  return false;
114  }
115  double gainRatios[3];
116  gainRatios[0] = 1.;
117  gainRatios[1] = aGain.gain12Over6();
118  gainRatios[2] = aGain.gain6Over1()*aGain.gain12Over6();
119 
120  if ( detid.subdetId() == EcalBarrel ) {
121  EcalUncalibratedRecHit aHit = algoEB_.makeRecHit(*itdg, pedVec, gainRatios, 0 ,0);
122  result.push_back( aHit );
123  if(aHit.amplitude()>0.) {
124  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EBDataFrame with id: "
125  << EBDetId( detid )
126  << "\n" << "uncalib rechit amplitude: " << aHit.amplitude();
127  }
128  } else {
129  EcalUncalibratedRecHit aHit = algoEE_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
130  result.push_back( aHit );
131  if(aHit.amplitude()>0.) {
132  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EEDataFrame with id: "
133  << EEDetId( detid ) << "\n"
134  << "uncalib rechit amplitude: " << aHit.amplitude();
135  }
136  }
137  return true;
138 }
139 
142 
144 //psd.addNode(edm::ParameterSet<edm::InputTag>("EBdigiCollection", edm::InputTag("ecalDigis","ebDigis")) and
145 // edm::ParameterSet<std::string>("EEhitCollection", "EcalUncalibRecHitsEE") and
146 // edm::ParameterSet<edm::InputTag>("EEdigiCollection", edm::InputTag("ecalDigis","eeDigis")) and
147 // edm::ParameterSet<std::string>("algo", "EcalUncalibRecHitWorkerAnalFit") and
148 // edm::ParameterSet<std::string>("EBhitCollection", "EcalUncalibRecHitsEB"));
149 //
150  return psd;
151 }
152 
#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)
EcalUncalibRecHitRecAnalFitAlgo< EBDataFrame > algoEB_
EcalUncalibRecHitRecAnalFitAlgo< EEDataFrame > algoEE_
float gain6Over1() const
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:18
const T & get() const
Definition: EventSetup.h:56
std::vector< Item >::const_iterator const_iterator
float gain12Over6() const
edm::ESHandle< EcalGainRatios > pRatio
HLT enums.
const_iterator find(uint32_t rawId) const
#define DEFINE_EDM_PLUGIN(factory, type, name)
const_iterator end() const
edm::ParameterSetDescription getAlgoDescription()