00001
00002
00004
00005 #ifndef ANALYSISCALIBRATIONDATAINTERFACEROOT_H
00006 #define ANALYSISCALIBRATIONDATAINTERFACEROOT_H
00007
00008
00009 #include "CalibrationDataInterface/CalibrationDataVariables.h"
00010 #include "CalibrationDataInterface/CalibrationDataInterfaceBase.h"
00011
00012
00013 #include "TMatrixDSym.h"
00014 #include "TH1.h"
00015 #include <vector>
00016 #include <string>
00017 #include <map>
00018
00019 class TFile;
00020 class TMap;
00021
00022 namespace Analysis
00023 {
00024 class CalibrationDataContainer;
00025
00026 class CalibrationDataEigenVariations;
00027
00066 enum Uncertainty { None, Total, Statistical, Systematic, Extrapolation, SFEigen, SFNamed, TauExtrapolation };
00067
00069 enum EVReductionStrategy { Tight = 0, Medium = 1, Loose = 2};
00070
00078 enum OutOfBoundsStrategy { Ignore, Flag, GiveUpExtrapolated, GiveUp };
00079
00081 enum OutOfBoundsType { Main, Extrapolated, Eta, TagWeight };
00082
00083 class CalibrationDataInterfaceROOT: public CalibrationDataInterfaceBase
00084 {
00085 public:
00087 CalibrationDataInterfaceROOT(const std::string& taggerName, std::string configname = "BTagCalibration.env", std::string pathname = "");
00088
00090 CalibrationDataInterfaceROOT(const std::string& taggerName,
00091 const char* fileSF, const char* fileEff,
00092 const std::vector<std::string>& jetAliases,
00093 const std::map<std::string, std::string>& SFNames,
00094 const std::map<std::string, std::vector<std::string> >& EffNames,
00095 const std::vector<std::string>& excludeFromEV,
00096 const std::map<std::string, Analysis::EVReductionStrategy> EVReductions,
00097 bool useEV = true, bool useMCMCSF = true, bool useTopologyRescaling = false);
00098
00100 CalibrationDataInterfaceROOT();
00101
00103 CalibrationDataInterfaceROOT(const CalibrationDataInterfaceROOT& other);
00104
00106 virtual ~CalibrationDataInterfaceROOT();
00107
00108
00109
00110
00111
00112
00113
00115 CalibResult getScaleFactor (const CalibrationDataVariables& variables,
00116 const std::string& label, const std::string& OP,
00117 Uncertainty unc, unsigned int numVariation = 0,
00118 unsigned int mapIndex = 0) const;
00119
00121 CalibResult getEfficiency (const CalibrationDataVariables& variables,
00122 const std::string& label, const std::string& OP,
00123 Uncertainty unc, unsigned int numVariation = 0,
00124 unsigned int mapIndex = 0) const;
00125
00127 CalibResult getInefficiencyScaleFactor(const CalibrationDataVariables& variables,
00128 const std::string& label, const std::string& OP,
00129 Uncertainty unc, unsigned int numVariation = 0,
00130 unsigned int mapIndex = 0) const;
00131
00133 CalibResult getInefficiency (const CalibrationDataVariables& variables,
00134 const std::string& label, const std::string& OP,
00135 Uncertainty unc, unsigned int numVariation = 0,
00136 unsigned int mapIndex = 0) const;
00137
00139 CalibResult getMCEfficiency (const CalibrationDataVariables& variables, const std::string& label,
00140 const std::string& OP, Uncertainty unc = None, unsigned int mapIndex = 0) const;
00141
00143 CalibResult getMCInefficiency (const CalibrationDataVariables& variables, const std::string& label,
00144 const std::string& OP, Uncertainty unc = None, unsigned int mapIndex = 0) const;
00145
00146
00156 std::vector<std::string> listScaleFactorUncertainties(const std::string& author,
00157 const std::string& label,
00158 const std::string& OP,
00159 bool named = false) const;
00160
00164 unsigned int getNumVariations(const std::string& author, const std::string& label,
00165 const std::string& OP, Uncertainty unc) const;
00166
00167
00168
00169
00170
00171
00172
00173
00174
00177 bool retrieveCalibrationIndex (const std::string& label, const std::string& OP,
00178 const std::string& author, bool isSF, unsigned int& index,
00179 unsigned int mapIndex = 0) const;
00180
00182 std::string nameFromIndex (unsigned int index) const;
00183
00185 CalibResult getScaleFactor (const CalibrationDataVariables& variables,
00186 unsigned int indexSF, unsigned int indexEff,
00187 Uncertainty unc, unsigned int numVariation = 0) const;
00188
00190 CalibResult getEfficiency (const CalibrationDataVariables& variables,
00191 unsigned int indexSF, unsigned int indexEff,
00192 Uncertainty unc, unsigned int numVariation = 0) const;
00193
00195 CalibResult getInefficiencyScaleFactor(const CalibrationDataVariables& variables,
00196 unsigned int indexSF, unsigned int indexEff,
00197 Uncertainty unc, unsigned int numVariation = 0) const;
00198
00200 CalibResult getInefficiency (const CalibrationDataVariables& variables,
00201 unsigned int indexSF, unsigned int indexEff,
00202 Uncertainty unc, unsigned int numVariation = 0) const;
00203
00205 CalibResult getMCEfficiency (const CalibrationDataVariables& variables, unsigned int index,
00206 Uncertainty unc = None) const;
00207
00209 CalibResult getMCInefficiency (const CalibrationDataVariables& variables, unsigned int index,
00210 Uncertainty unc = None) const;
00211
00214 double getMCMCScaleFactor(const CalibrationDataVariables& variables,
00215 unsigned indexSF, unsigned int indexEff) const;
00216
00226 std::vector<std::string> listScaleFactorUncertainties(unsigned int index,
00227 bool named = false) const;
00228
00232 unsigned int getNumVariations(unsigned int index, Uncertainty unc) const;
00233
00235 std::string fullName(const std::string& author, const std::string& OP,
00236 const std::string& label, bool isSF, unsigned mapIndex = 0) const;
00237
00238
00239
00240
00241
00242
00243
00244
00245
00247 CalibrationStatus getScaleFactor (const CalibrationDataVariables& variables,
00248 unsigned int indexSF, unsigned int indexEff,
00249 Uncertainty unc, unsigned int numVariation,
00250 CalibResult& result) const;
00251
00253 CalibrationStatus getEfficiency (const CalibrationDataVariables& variables,
00254 unsigned int indexSF, unsigned int indexEff,
00255 Uncertainty unc, unsigned int numVariation,
00256 CalibResult& result) const;
00257
00259 CalibrationStatus getInefficiencyScaleFactor(const CalibrationDataVariables& variables,
00260 unsigned int indexSF, unsigned int indexEff,
00261 Uncertainty unc, unsigned int numVariation,
00262 CalibResult& result) const;
00263
00265 CalibrationStatus getInefficiency (const CalibrationDataVariables& variables,
00266 unsigned int indexSF, unsigned int indexEff,
00267 Uncertainty unc, unsigned int numVariation,
00268 CalibResult& result) const;
00269
00271 CalibrationStatus getMCEfficiency (const CalibrationDataVariables& variables,
00272 unsigned int index, Uncertainty unc,
00273 CalibResult& result) const;
00274
00275
00276
00277
00278
00279
00280
00281
00282
00284 CalibResult getWeightScaleFactor (const CalibrationDataVariables& variables, const std::string& label,
00285 Uncertainty unc, unsigned int numVariation = 0, unsigned int mapIndex = 0) const;
00286
00288 CalibResult getWeightScaleFactor (const CalibrationDataVariables& variables,
00289 unsigned int indexSF, unsigned int indexEff,
00290 Uncertainty unc, unsigned int numVariation = 0) const;
00291
00293 CalibrationStatus getWeightScaleFactor (const CalibrationDataVariables& variables,
00294 unsigned int indexSF, unsigned int indexEff,
00295 Uncertainty unc, unsigned int numVariation,
00296 CalibResult& result) const;
00297
00298
00299
00300
00301
00307 const TObject* getMCEfficiencyObject (const std::string& author, const std::string& label,
00308 const std::string& OP, unsigned int mapIndex = 0) const;
00309
00314 const TH1* getBinnedScaleFactors (const std::string& author, const std::string& label,
00315 const std::string& OP) const;
00316
00324 const TH1* getShiftedScaleFactors (const std::string& author, const std::string& label,
00325 const std::string& OP, const std::string& unc,
00326 double sigmas) const;
00327
00333 TMatrixDSym getScaleFactorCovarianceMatrix (const std::string& author, const std::string& label,
00334 const std::string& OP, const std::string& unc = "all") const;
00335
00336
00337
00338
00339
00340
00341 class HadronisationReferenceHelper {
00342 public:
00343 HadronisationReferenceHelper(TMap* mapSF, TMap* mapEff);
00344
00345 HadronisationReferenceHelper() {;}
00350 bool getReference(const std::string& spec, std::string& ref) const;
00351
00352 private:
00354 std::map<std::string, std::string> m_refs;
00355 };
00356
00357
00358
00360 void initialize(const std::string& jetauthor, const std::string& OP, Uncertainty unc);
00361
00362 private:
00363
00365 TFile* m_fileEff;
00366 TFile* m_fileSF;
00367
00370 std::map<std::string, std::string> m_aliases;
00371
00375 std::vector<CalibrationDataContainer*> m_objects;
00376 std::map<std::string, unsigned int> m_objectIndices;
00377
00379
00380 CalibrationDataContainer* retrieveContainer(const std::string& dir, const std::string& cntname, bool isSF);
00381
00383
00384
00386 std::string getAlias(const std::string& author) const;
00387
00389 std::string m_filenameSF;
00390 std::string m_filenameEff;
00391
00392
00393
00394
00395
00397 mutable std::map<const CalibrationDataContainer*,const CalibrationDataEigenVariations*> m_eigenVariationsMap;
00398
00400 bool m_runEigenVectorMethod;
00401
00403 std::map<std::string, Analysis::EVReductionStrategy> m_EVReductions;
00404
00406 std::vector<std::string> m_excludeFromCovMatrix;
00407
00408
00409
00410
00411
00414 bool m_useMCMCSF;
00417 bool m_useTopologyRescaling;
00418
00421 mutable std::map<std::string, HadronisationReferenceHelper*> m_refMap;
00423 mutable std::vector<int> m_hadronisationReference;
00424
00425
00426
00427
00428
00430 double m_maxAbsEta;
00431 OutOfBoundsStrategy m_absEtaStrategy;
00432 OutOfBoundsStrategy m_otherStrategy;
00433 void checkAbsEta(const CalibrationDataVariables& variables, unsigned int index) const;
00435 std::vector<unsigned int> m_etaCounters;
00436 std::vector<unsigned int> m_mainCounters;
00437 std::vector<unsigned int> m_extrapolatedCounters;
00438
00439 void increaseCounter(unsigned int index, OutOfBoundsType oob = Main);
00440
00441
00442 void checkWeightScaleFactors(unsigned int indexSF, unsigned int indexEff) const;
00443 mutable std::vector<std::pair<unsigned int, unsigned int> > m_checkedWeightScaleFactors;
00444 double m_maxTagWeight;
00445
00446
00447 ClassDef(CalibrationDataInterfaceROOT,1)
00448 };
00449
00450 }
00451
00452 #endif // ANALYSISCALIBRATIONDATAINTERFACEROOT_H