00001 #ifndef CALIBRATION_ECALCALIBALGOS_ZEECALIBRATION
00002 #define CALIBRATION_ECALCALIBALGOS_ZEECALIBRATION
00003
00004
00005
00006
00007
00008
00016
00017
00018
00019
00020
00021
00022
00023 #include <memory>
00024 #include <vector>
00025 #include <map>
00026
00027
00028 #include "FWCore/Framework/interface/LooperFactory.h"
00029 #include "FWCore/Framework/interface/ESProducerLooper.h"
00030 #include "FWCore/Framework/interface/ESHandle.h"
00031 #include "FWCore/Framework/interface/Frameworkfwd.h"
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033 #include "FWCore/Framework/interface/EDProducer.h"
00034 #include "FWCore/Framework/interface/Event.h"
00035 #include "FWCore/Framework/interface/EventSetup.h"
00036 #include "FWCore/Framework/interface/ESHandle.h"
00037
00038 #include "Calibration/Tools/interface/ZIterativeAlgorithmWithFit.h"
00039 #include "Calibration/Tools/interface/CalibElectron.h"
00040
00041 #include "Calibration/EcalCalibAlgos/interface/ZeePlots.h"
00042 #include "Calibration/EcalCalibAlgos/interface/ZeeRescaleFactorPlots.h"
00043
00044 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00045 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00046
00047 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00048 #include "DataFormats/DetId/interface/DetId.h"
00049
00050 #include "TTree.h"
00051 #include "TFile.h"
00052 #include "TGraph.h"
00053 #include "TGraphErrors.h"
00054 #include "TH1.h"
00055 #include "TH2.h"
00056
00057 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00058 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
00059 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00060 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00061 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00062
00063 #include "FWCore/Framework/interface/Event.h"
00064 #include "FWCore/Framework/interface/EDAnalyzer.h"
00065 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00066
00067 #include "FWCore/Framework/interface/TriggerNames.h"
00068 #include<vector>
00069 #include<string>
00070
00071
00072
00073
00074 class ZeeCalibration : public edm::ESProducerLooper {
00075
00076 public:
00077
00079 ZeeCalibration( const edm::ParameterSet& iConfig );
00080
00082 ~ZeeCalibration();
00083
00085 virtual void produce(edm::Event&, const edm::EventSetup&) {};
00086
00088 virtual void beginOfJob(const edm::EventSetup&);
00089
00091 virtual void endOfJob();
00092
00094 virtual void startingNewLoop( unsigned int iLoop );
00095
00097 virtual Status endOfLoop( const edm::EventSetup&, unsigned int iLoop );
00098
00100 virtual Status duringLoop( const edm::Event&, const edm::EventSetup& );
00101
00103 virtual boost::shared_ptr<EcalIntercalibConstants> produceEcalIntercalibConstants( const EcalIntercalibConstantsRcd& iRecord );
00104
00105 private:
00106
00107
00108
00109
00110 double fEtaBarrelBad(double scEta) const;
00111 double fEtaBarrelGood(double scEta) const;
00112 double fEtaEndcapBad(double scEta) const;
00113 double fEtaEndcapGood(double scEta) const;
00114
00115 int ringNumberCorrector(int k);
00116 double getEtaCorrection(const reco::PixelMatchGsfElectron*);
00117
00118
00119 void fillEleInfo(std::vector<HepMC::GenParticle*>& a, std::map<HepMC::GenParticle*,const reco::PixelMatchGsfElectron*>& b);
00120 void fillMCInfo(HepMC::GenParticle* mcele);
00121
00122 void fillMCmap(const std::vector<const reco::PixelMatchGsfElectron*>* electronCollection, const std::vector<HepMC::GenParticle*>& mcEle,std::map<HepMC::GenParticle*,const reco::PixelMatchGsfElectron*>& myMCmap);
00123
00124
00125 float EvalDPhi(float Phi,float Phi_ref);
00126 float EvalDR(float Eta,float Eta_ref,float Phi,float Phi_ref);
00127
00128
00129 void bookHistograms();
00130
00131 void resetVariables();
00132
00133 void resetHistograms();
00134
00135 void printStatistics();
00136
00137 std::pair<DetId, double> getHottestDetId(std::vector<DetId> mySCRecHits, const EBRecHitCollection* ebhits , const EERecHitCollection* eehits);
00138
00139 bool xtalIsOnModuleBorder( EBDetId myEBDetId );
00140
00141 float computeCoefficientDistanceAtIteration( float v1[250], float v2[250], int size);
00142
00143
00144
00145
00146
00147
00148 TTree* myTree;
00149
00150 std::string outputFileName_;
00151
00152 std::string rechitProducer_;
00153 std::string rechitCollection_;
00154 std::string erechitProducer_;
00155 std::string erechitCollection_;
00156 std::string scProducer_;
00157 std::string scCollection_;
00158
00159 std::string scIslandProducer_;
00160 std::string scIslandCollection_;
00161
00162 std::string mcProducer_;
00163 std::string calibMode_;
00164
00165 std::string electronProducer_;
00166 std::string electronCollection_;
00167
00168 std::string RecalibBarrelHits_;
00169
00170 unsigned int etaBins_;
00171 unsigned int etBins_;
00172
00173 double etaMin_;
00174 double etMin_;
00175 double etaMax_;
00176 double etMax_;
00177
00178 std::string barrelfile_;
00179 std::string endcapfile_;
00180
00181 double minInvMassCut_;
00182 double maxInvMassCut_;
00183 double mass;
00184
00185 float mass4tree;
00186 float massDiff4tree;
00187
00188 int read_events;
00189
00190 int loopFlag_;
00191
00192 float calibCoeff[nMaxChannels];
00193 float NewCalibCoeff[nMaxChannels];
00194 float calibCoeffError[nMaxChannels];
00195 float initCalibCoeff[nMaxChannels];
00196
00197 boost::shared_ptr<EcalIntercalibConstants> ical;
00198
00199 ZIterativeAlgorithmWithFit* theAlgorithm_;
00200
00201 ZeePlots* myZeePlots_;
00202 ZeeRescaleFactorPlots* myZeeRescaleFactorPlots_;
00203
00204
00205
00206 edm::ParameterSet theParameterSet;
00207
00208
00209
00210 TH1F* h1_eventsBeforeEWKSelection_;
00211 TH1F* h1_eventsAfterEWKSelection_;
00212
00213 TH1F* h1_eventsBeforeBorderSelection_;
00214 TH1F* h1_eventsAfterBorderSelection_;
00215
00216
00217 TH2F* h2_fEtaBarrelGood_;
00218 TH2F* h2_fEtaBarrelBad_;
00219 TH2F* h2_fEtaEndcapGood_;
00220 TH2F* h2_fEtaEndcapBad_;
00221 TH1F* h1_nEleReco_;
00222 TH1F* h1_eleClasses_;
00223
00224 TH1F* h_eleEffEta[2];
00225 TH1F* h_eleEffPhi[2];
00226 TH1F* h_eleEffPt[2];
00227
00228 TH1F* h1_seedOverSC_;
00229 TH1F* h1_preshowerOverSC_;
00230
00231 TH1F* h1_zMassResol_;
00232 TH1F* h1_zEtaResol_;
00233 TH1F* h1_zPhiResol_;
00234 TH1F* h1_reco_ZMass_;
00235
00236 TH1F* h1_reco_ZMassCorr_;
00237 TH1F* h1_reco_ZMassCorrBB_;
00238 TH1F* h1_reco_ZMassCorrEE_;
00239 TH1F* h1_reco_ZMassGood_;
00240 TH1F* h1_reco_ZMassBad_;
00241 TH1F* h1_ZCandMult_;
00242 TH1F* h1_RMin_;
00243 TH1F* h1_RMinZ_;
00244 TH1F* h1_eleERecoOverEtrue_;
00245
00246 TH1F* h1_eleEtaResol_;
00247 TH1F* h1_elePhiResol_;
00248
00249 TH1F* h_eleEffEta_[2];
00250 TH1F* h_eleEffPhi_[2];
00251 TH1F* h_eleEffPt_[2];
00252 TH1F* h_ESCEtrue_[25];
00253 TH2F* h_ESCEtrueVsEta_[25];
00254
00255 TH1F* h_ESCcorrEtrue_[25];
00256 TH2F* h_ESCcorrEtrueVsEta_[25];
00257
00258 TH2F* h2_coeffVsEta_;
00259 TH2F* h2_coeffVsEtaGrouped_;
00260 TH2F* h2_zMassVsLoop_;
00261 TH2F* h2_zMassDiffVsLoop_;
00262 TH2F* h2_zWidthVsLoop_;
00263 TH2F* h2_coeffVsLoop_;
00264
00265 TH2F* h2_miscalRecal_;
00266
00267 TH1F* h1_mc_;
00268 TH1F* h1_mcParz_[25];
00269
00270
00271
00272
00273 TH2F* h2_residualSigma_;
00274 TH2F* h2_miscalRecalEB_;
00275
00276 TH1F* h1_mcEB_;
00277 TH1F* h1_mcEBParz_[25];
00278 TH2F* h2_miscalRecalEE_;
00279
00280 TH1F* h1_mcEE_;
00281 TH1F* h1_mcEEParz_[25];
00282
00283 TH2F* h2_chi2_[25];
00284 TH2F* h2_iterations_[25];
00285
00286 TH2F * h2_xtalRecalibCoeffBarrel_[25];
00287 TH2F * h2_xtalRecalibCoeffEndcapMinus_[25];
00288 TH2F * h2_xtalRecalibCoeffEndcapPlus_[25];
00289
00290 TH2F* h2_xtalMiscalibCoeffBarrel_;
00291 TH2F* h2_xtalMiscalibCoeffEndcapMinus_;
00292 TH2F* h2_xtalMiscalibCoeffEndcapPlus_;
00293
00294 TH1F* h1_weightSumMeanBarrel_;
00295 TH1F* h1_weightSumMeanEndcap_;
00296
00297 TH1F* h1_occupancyVsEta_;
00298 TH1F* h1_occupancyVsEtaGold_;
00299 TH1F* h1_occupancyVsEtaSilver_;
00300 TH1F* h1_occupancyVsEtaCrack_;
00301 TH1F* h1_occupancyVsEtaShower_;
00302 TH1F* h1_occupancy_;
00303 TH1F* h1_occupancyBarrel_;
00304 TH1F* h1_occupancyEndcap_;
00305
00306 TH1F* h1_electronCosTheta_TK_;
00307 TH1F* h1_electronCosTheta_SC_;
00308 TH1F* h1_electronCosTheta_SC_TK_;
00309
00310 TH1F* h1_borderElectronClassification_;
00311
00312
00313 Int_t BBZN,EBZN,EEZN,BBZN_gg,EBZN_gg,EEZN_gg,BBZN_tt,EBZN_tt,EEZN_tt,BBZN_t0,EBZN_t0,EEZN_t0;
00314 Int_t NEVT, MCZBB, MCZEB, MCZEE;
00315
00316 TFile* outputFile_;
00317
00318 unsigned int theMaxLoops;
00319
00320 bool wantEtaCorrection_;
00321
00322 unsigned int electronSelection_;
00323
00324 double loopArray[50];
00325 double sigmaArray[50];
00326 double sigmaErrorArray[50];
00327 double coefficientDistanceAtIteration[50];
00328
00329 int BARREL_ELECTRONS_BEFORE_BORDER_CUT;
00330 int BARREL_ELECTRONS_AFTER_BORDER_CUT;
00331
00332 int TOTAL_ELECTRONS_IN_BARREL;
00333 int TOTAL_ELECTRONS_IN_ENDCAP;
00334
00335 int GOLDEN_ELECTRONS_IN_BARREL;
00336 int GOLDEN_ELECTRONS_IN_ENDCAP;
00337
00338 int SILVER_ELECTRONS_IN_BARREL;
00339 int SILVER_ELECTRONS_IN_ENDCAP;
00340
00341 int SHOWER_ELECTRONS_IN_BARREL;
00342 int SHOWER_ELECTRONS_IN_ENDCAP;
00343
00344 int CRACK_ELECTRONS_IN_BARREL;
00345 int CRACK_ELECTRONS_IN_ENDCAP;
00346
00347
00348 edm::InputTag hlTriggerResults_;
00349 edm::TriggerNames triggerNames_;
00350
00351 unsigned int nEvents_;
00352
00353 unsigned int nWasRun_;
00354 unsigned int nAccept_;
00355 unsigned int nErrors_;
00356
00357 std::vector<unsigned int> hlWasRun_;
00358 std::vector<unsigned int> hlAccept_;
00359 std::vector<unsigned int> hlErrors_;
00360
00361 std::vector<std::string> hlNames_;
00362 bool init_;
00363
00364 Int_t triggerCount;
00365 char aTriggerNames[200][30];
00366 bool aTriggerResults[200];
00367
00368 Int_t hltCount;
00369 char aHLTNames[6000];
00370 Int_t hltNamesLen;
00371 TString aNames[200];
00372 bool aHLTResults[200];
00373
00374 };
00375 #endif