1 #ifndef ecaltimingcalibproducer_h
2 #define ecaltimingcalibproducer_h
32 #define RAWIDCRY 838904321
35 #define EBCRYex 838861346
36 #define EECRYex 872422180
43 #define SPEEDOFLIGHT 30.0 // (cm/ns)
44 #define HW_UNIT 1.1 //(ns)
52 #include "FWCore/ServiceRegistry/interface/Service.h"
53 #include "CommonTools/UtilAlgos/interface/TFileService.h"
56 #include "FWCore/Framework/interface/Frameworkfwd.h"
57 #include "FWCore/Framework/interface/EDConsumerBase.h"
59 #include "FWCore/Framework/interface/EDProducer.h"
60 #include "FWCore/Framework/interface/Event.h"
62 #include "FWCore/Framework/interface/MakerMacros.h"
63 #include "FWCore/Utilities/interface/InputTag.h"
64 #include "FWCore/ParameterSet/interface/ParameterSet.h"
66 #include "DataFormats/Common/interface/Handle.h"
69 #include "FWCore/Framework/interface/EDFilter.h"
70 #include "FWCore/Framework/interface/ESHandle.h"
71 #include "FWCore/Framework/interface/ESProducts.h"
72 #include "FWCore/Framework/interface/Event.h"
74 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
76 #include "Calibration/Tools/interface/EcalRingCalibrationTools.h"
77 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
78 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
79 #include "Geometry/Records/interface/CaloGeometryRecord.h"
80 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
81 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
84 #include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h"
85 #include "CondFormats/DataRecord/interface/EcalTimeCalibErrorsRcd.h"
86 #include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h"
87 #include "CondTools/Ecal/interface/EcalTimeCalibConstantsXMLTranslator.h"
88 #include "CondTools/Ecal/interface/EcalTimeCalibErrorsXMLTranslator.h"
89 #include "CondTools/Ecal/interface/EcalTimeOffsetXMLTranslator.h"
90 #include "CondTools/Ecal/interface/EcalCondHeader.h"
92 #include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h"
93 #include "CondFormats/EcalObjects/interface/EcalTimeCalibErrors.h"
94 #include "CondFormats/EcalObjects/interface/EcalTimeOffsetConstant.h"
96 #include "EcalTiming/EcalTiming/interface/EcalTimingEvent.h"
97 #include "EcalTiming/EcalTiming/interface/EcalCrystalTimingCalibration.h"
99 #include "DataFormats/EcalDetId/interface/EBDetId.h"
100 #include "DataFormats/EcalDetId/interface/EEDetId.h"
102 #include "TProfile.h"
103 #include "TGraphErrors.h"
108 #include "TProfile2D.h"
117 #include <functional>
123 #include <Math/VectorUtil.h>
126 #include "EcalTiming/EcalTiming/interface/EcalTimeCalibrationMapFwd.h"
152 virtual void beginJob()
override;
153 virtual bool filter(edm::Event&,
const edm::EventSetup&)
override;
154 virtual void endJob()
override;
175 float _maxSkewnessForDump;
178 void dumpCalibration(std::string filename);
179 void dumpCorrections(std::string filename);
184 void FillHWCorrectionHists(EcalTimeCalibrationMap::const_iterator cal_itr);
185 void FillEnergyStabilityHists(EcalTimeCalibrationMap::const_iterator cal_itr, std::vector< std::pair<float, EcalCrystalTimingCalibration*> > energyStability);
186 void initHists(TFileDirectory dir);
187 void initEventHists(TFileDirectory dir);
188 void initTree(TFileDirectory dir);
215 unsigned int getElecID(DetId
id)
217 return (elecMap_->getElectronicsId(
id).rawId() >> 6) & 0x3FFF;
220 std::map<DetId, float> _CrysEnergyMap;
221 float getEnergyThreshold(
const DetId detid)
223 auto itr = _CrysEnergyMap.find(detid);
224 if(itr == _CrysEnergyMap.end())
226 int iRing = _ringTools.getRingIndexInSubdet(detid);
230 return _CrysEnergyMap[detid];
233 edm::Service<TFileService> fileService_;
234 TFileDirectory histDir_;
238 TTree * energyStabilityTree;
242 TProfile2D* EneMapEEP_;
244 TProfile2D* TimeMapEEP_;
245 TProfile2D* TimeMapEEM_;
247 TProfile2D* EneMapEB_;
248 TProfile2D* TimeMapEB_;
251 TProfile2D* TimeErrorMapEEP_;
252 TProfile2D* TimeErrorMapEEM_;
254 TProfile2D* TimeErrorMapEB_;
257 TProfile2D * Event_EneMapEEP_;
258 TProfile2D * Event_EneMapEEM_;
259 TProfile2D * Event_EneMapEB_;
261 TProfile2D* Event_TimeMapEEP_;
262 TProfile2D* Event_TimeMapEEM_;
263 TProfile2D* Event_TimeMapEB_;
265 TProfile2D* Event_TimeMapEEP_OOT;
266 TProfile2D* Event_TimeMapEEM_OOT;
267 TProfile2D* Event_TimeMapEB_OOT;
272 TH1F* RechitTimeEEM_;
274 TH1F* RechitTimeEEP_;
277 TProfile2D* HWTimeMapEEP_;
278 TProfile2D* HWTimeMapEEM_;
279 TProfile2D* HWTimeMapEB_;
281 TH2F* RechitEnergyTimeEB;
282 TH2F* RechitEnergyTimeEEM;
283 TH2F* RechitEnergyTimeEEP;
289 EcalRingCalibrationTools _ringTools;
290 const CaloSubdetectorGeometry * endcapGeometry_;
291 const CaloSubdetectorGeometry * barrelGeometry_;
293 const EcalElectronicsMapping * elecMap_;
void FillCalibrationCorrectionHists(EcalTimeCalibrationMap::const_iterator cal_itr)
fill histograms with the measured shifts (that will become -corrections for the next step) ...
Definition: EcalTimingCalibProducer.cc:400
double _energyThresholdOffsetEB
energy to add to the minimum energy thresholc
Definition: EcalTimingCalibProducer.h:168
EcalCrystalTimingCalibration timeEEpRing
global time calibration of one EE+ ring
Definition: EcalTimingCalibProducer.h:143
EcalCrystalTimingCalibration timeEECRYex
global time calibration of one EE channel
Definition: EcalTimingCalibProducer.h:145
EcalTimeCalibConstants _timeCalibConstants
container of calibrations updated iter by iter
Definition: EcalTimingCalibProducer.h:190
EcalTimeCalibrationMap _timeCalibMap
calibration map: contains the time shift for each crystal
Definition: EcalTimingCalibProducer.h:132
EcalCrystalTimingCalibration timeEEP
global time calibration of EE+
Definition: EcalTimingCalibProducer.h:138
void plotRecHit(const EcalTimingEvent &recHit)
Adds the recHit to the per Event histograms.
Definition: EcalTimingCalibProducer.cc:101
EventTimeMap _eventTimeMap
container of recHits passing selection in the event (reset at each event)
Definition: EcalTimingCalibProducer.h:133
EcalHWCalibrationMap _HWCalibrationMap
calibration map for the CCU's (Hardware Constants).
Definition: EcalTimingCalibProducer.h:134
double _minRecHitEnergyNStep
number of steps to check energy stability
Definition: EcalTimingCalibProducer.h:167
Plugin that derives the calibration constants.
Definition: EcalTimingCalibProducer.h:128
Definition: EcalTimingEvent.h:16
EcalTimingEvent correctGlobalOffset(const EcalTimingEvent &ev, int splashDir, float bunchCorr)
Definition: EcalTimingCalibProducer.cc:134
EcalCrystalTimingCalibration timeEEmRing
global time calibration of one EE- ring
Definition: EcalTimingCalibProducer.h:142
EcalCrystalTimingCalibration timeEB
global time calibration of EB
Definition: EcalTimingCalibProducer.h:140
EcalCrystalTimingCalibration timeEEM
global time calibration of EE-
Definition: EcalTimingCalibProducer.h:139
unsigned int _minEntries
require a minimum number of entries in a ring to do averages
Definition: EcalTimingCalibProducer.h:170
TProfile2D * EneMapEEM_
Using TProfile2D so we don't paint empty bins.
Definition: EcalTimingCalibProducer.h:243
bool addRecHit(const EcalTimingEvent &recHit, EventTimeMap &eventTimeMap_)
If recHit passes the selection it is added to the list of recHits to be used for calibration.
Definition: EcalTimingCalibProducer.cc:87
float _globalOffset
time to subtract from every event
Definition: EcalTimingCalibProducer.h:171
double _energyThresholdOffsetEE
energy to add to the minimum energy thresholc
Definition: EcalTimingCalibProducer.h:169
bool _produceNewCalib
true if you don't want to use the values in DB and what to extract new absolute calibrations, if false iteration does not work
Definition: EcalTimingCalibProducer.h:173
unsigned int _recHitMin
require at least this many rec hits to count the event
Definition: EcalTimingCalibProducer.h:165
double _minRecHitEnergyStep
to check step size to check energy stability
Definition: EcalTimingCalibProducer.h:166
Definition: EcalCrystalTimingCalibration.h:19
edm::EDGetTokenT< EcalTimingCollection > _timingEvents
input collection
Definition: EcalTimingCalibProducer.h:164
EcalCrystalTimingCalibration timeEBCRYex
global time calibration of one EB channel
Definition: EcalTimingCalibProducer.h:144
std::string _outputDumpFileName
name of the output file for the calibration constants' dump
Definition: EcalTimingCalibProducer.h:174
bool _makeEventPlots
flag for making plots for each event (meant for splashes)
Definition: EcalTimingCalibProducer.h:163
EcalCrystalTimingCalibration timeEBRing
global time calibration of one EB ring
Definition: EcalTimingCalibProducer.h:141
bool _isSplash
flag to activate for splash analysis
Definition: EcalTimingCalibProducer.h:162