00001 #ifndef ENERGYCORRECTIONS_H 00002 #define ENERGYCORRECTIONS_H 00004 // 00005 // EnergyCorrections.h 00006 // 00007 // Corrections to energy based quantities. EnergyCorrections is the home for 00008 // all those functions that provide corrections to energy and related 00009 // quantities. This file provides access to both Calibration Group correction 00010 // factors and also CC shower and muon momentum corrections. 00011 // 00012 // Created: M. Kordosky -- December, 2005 00013 // Modified: R. Nichol -- May, 2007 00014 // xbhuang -- July, 2009 00015 // 00016 // $Author: xbhuang $ 00017 // 00018 // $Revision: 1.24 $ 00019 // 00020 // $Name: $ 00021 // 00022 // $Id: EnergyCorrections.h,v 1.24 2009/08/05 16:08:43 xbhuang Exp $ 00023 // 00024 // $Log: EnergyCorrections.h,v $ 00025 // Revision 1.24 2009/08/05 16:08:43 xbhuang 00026 // 00027 // Modified in order to add correction function for Dogwood0 reconstruction. 00028 // 00029 // Revision 1.23 2009/07/22 17:46:44 xbhuang 00030 // 00031 // The same as previous version except change function ShowerEnergyCorrectionNearDogwood1() to ShowerEnergyCorrectionNearDogwood(). 00032 // 00033 // Revision 1.22 2009/07/04 01:53:52 rhatcher 00034 // Remove tabs (replaced w/ spaces per coding conventions). Did a bit of 00035 // other coding convention cleanup, but there is still a lot of ugliness 00036 // about the formatting that makes the code very hard to read. 00037 // 00038 // Revision 1.21 2009/07/02 22:43:44 xbhuang 00039 // 00040 // kDogwood defined! 00041 // 00042 // Revision 1.20 2007/12/21 15:36:08 rjn 00043 // Added switch for the ability to go back to the May version of the Masaki conversion 00044 // 00045 // Revision 1.19 2007/12/21 11:12:32 rjn 00046 // Added a WeightedShowerEnergyConversionDogwood function 00047 // 00048 // Revision 1.18 2007/12/19 16:39:48 rjn 00049 // Added Masaki's correction from DocDB 3895_v4 00050 // 00051 // Revision 1.17 2007/11/16 11:43:21 rjn 00052 // Added ShowerEnergyConversionDogwood which is the function to be called by CandShowerHandle to apply ourbest knowledge of the conversion from MEU to GeV for the dogwood reconstruction, such that to first order the GeV number in the tree is correct (until we know more at least). 00053 // 00054 // Revision 1.16 2007/11/11 06:41:26 rhatcher 00055 // Part of the ongoing purge of "DetectorType" in favor of "Detector" 00056 // (the former is a synonym of the latter ...) 00057 // 00058 // Revision 1.15 2007/09/28 17:37:10 rjn 00059 // Adding the latest version of EnergyCorrections to the repository. I'm sure this is going to upset somebody, but then again it always does. 00060 // 00061 // Revision 1.14 2007/06/04 18:28:23 rjn 00062 // The preliminary version of the Calibration Group final MEU scale fudge factors are now available. 00063 // 00064 // Things to note for those users who are only interested in calibrating shower energy scale for the CC analysis, you can use the FullyCorrectShowerEnergy function, to apply both Calibration Group corrections and Masaki's shower energy tuning. Note that it is very important that you get the release type correct, for the analysis you should be using: 00065 // Data -- Cedar_phy 00066 // MC -- Cedar R1.24.1 00067 // These are the only data sets for which calibration numbers are provided. 00068 // 00069 // 00070 // If you are interested in making data or MC plots in fully calibrated MEU numbers you can use the CalibrationGroupEnergyCorrections function. This will convert MEU's from the sntp into fully calibrated MEU's. NB: It is very inmportant to be careful not to apply the corrections twice by calling both CalibrationGroupEnergyCorrections and FullyCorrectShowerEnergy. If you wish to do this investigate the WhichCorrection_t options and particular the kNoCalGroup option. 00071 // 00072 // Revision 1.13 2007/05/21 09:55:48 rjn 00073 // Just a tidying up sort of commit. Moved the Calibration Group corrections from the obliquely named CorrectionsForMasaki to the rather easier to understand EnergyCorrections::CalibrationGroupEnergyCorrections. NB: This function is called automatically by FullyCorrectShowerEnergy, so do not pass already corrected values to FullyCorrectShowerEnergy. 00074 // 00075 // Revision 1.12 2007/05/19 12:18:39 rjn 00076 // Added to the FullyCorrect family of EnergyCorrections. Now have corrections for shower energy and track momentum/energy from range. At this point users are encouraged to use these. There will still be a few under the hood changes but at this point I think there is a workable interface. 00077 // 00078 // Revision 1.11 2007/05/18 16:24:54 rjn 00079 // Added FullyCorrectShowerEnergy function that should replaces the previously used shower energy corrections. Should work with birch and cedar. It also applies the appropriate calibration group corrections. Everyone should use this who used any of the previous functions. 00080 // 00081 // Revision 1.10 2007/02/01 20:06:50 ishi 00082 // Semicolons at the end of namespace{} were removed. 00083 // 00084 // Revision 1.9 2007/02/01 17:47:33 kordosky 00085 // New version of EnergyCorrections. EnergyCorrections is now a namespace and calling code should invoke "using namespace EnergyCorrections". This is not expected 00086 // to cause problems since in the previous version all the correction functions were at global scope. Indeed, code including EnergyCorrections.h have been modified. Will handle cedar and birch by using static variables fVersion and fSubVersion, modified via SetCorrectionVersion(). Users need to do this, perhaps in their job macro. So far there is only one correction of each type and fSubVersion should be held at the default 0. Also, note the utility VersionFromFilename(). 00087 // 00088 // Revision 1.8 2006/02/15 15:57:30 kordosky 00089 // add correction from for momentum via curvature as advocated in 1430-v2. Only modifies momenta of positively charged tracks. 00090 // 00091 // Revision 1.7 2006/02/13 00:20:02 kordosky 00092 // correction of +1.8% to FD data shower energy 00093 // 00094 // Revision 1.6 2006/02/12 22:09:58 kordosky 00095 // Update momentum correction to account for new density and thickness measurements. 00096 // 00097 // Revision 1.5 2005/12/16 03:38:51 kordosky 00098 // place implementation in a cxx file 00099 // 00100 // Revision 1.4 2005/12/16 02:52:43 kordosky 00101 // Forgot the include guards. Thansk Niki. 00102 // 00103 // Revision 1.3 2005/12/15 22:44:31 kordosky 00104 // retweaked A Culling formulae in reaction to his presentation this morning 00105 // 00106 // Revision 1.2 2005/12/15 22:26:19 kordosky 00107 // E=sqrt(p*p+m*m) != p (almost negligible) 00108 // 00109 // Revision 1.1 2005/12/15 21:57:09 kordosky 00110 // moved from Mad 00111 // 00112 // Revision 1.2 2005/12/14 20:35:59 kordosky 00113 // Updated energy corrections. 00114 // 00115 // Revision 1.1 2005/12/13 19:41:35 kordosky 00116 // Standalone routines to correct the momentum via range to to groom et al range tables. Also, correct data to 7.755 g/cc which is our current best estimate of the detector density. 00117 // 00118 #include <string> 00119 #include "Conventions/Detector.h" 00120 #include "Conventions/ReleaseType.h" 00121 #include "RecoBase/CandShowerHandle.h" 00122 00123 // Shower Energy Correction 00124 // ========================== 00125 // 00126 // All users are recommended to use the FullyCorrectShowerEnergy function to 00127 // apply corrections to shower energy. This function can be used for all 00128 // shower types and performs Calibration Group + other corrections. NB: 00129 // one now needs access to the offline database to call this function. 00130 // 00171 00172 00173 00175 // 00176 // All users are recommended to use the FullyCorrect family of track functions 00177 // apply corrections to track momentum/energy. 00178 // 00187 00188 00232 00233 namespace EnergyCorrections { 00234 00235 typedef enum EWhichCorrection { 00236 kDefault = 0, 00237 kVersion1, 00238 kVersion2, 00239 kVersion3, 00240 kVersion4, 00241 kVersion5, 00242 kVersion6, 00243 kNoCalGroup 00244 } WhichCorrection_t; 00245 00246 00247 // The one stop shop for shower energy corrections is 00248 // FullyCorrectShowerEnergy 00249 float FullyCorrectShowerEnergy(float E,// Input calorimetric shower energy 00250 const CandShowerHandle::ShowerType_t& st, 00251 VldContext vc, //Context of this specific event 00252 ReleaseType::Release_t release, // Release version of the batch processing 00253 EnergyCorrections::WhichCorrection_t whichCor=EnergyCorrections::kDefault); 00254 00255 00256 //The following routines should be used to correct track energy 00257 //and momentum. 00258 float FullyCorrectMomentumFromRange(float p, //Momentum from range 00259 VldContext vc, //Context of this specific event 00260 ReleaseType::Release_t release, //Release verion of the batch processing 00261 EnergyCorrections::WhichCorrection_t whichCor=EnergyCorrections::kDefault); 00262 00263 float FullyCorrectEnergyFromRange(float E, //Energy from range 00264 VldContext vc, //Context of this specific event 00265 ReleaseType::Release_t release, //Release verion of the batch processing 00266 EnergyCorrections::WhichCorrection_t whichCor=EnergyCorrections::kDefault); 00267 00268 float FullyCorrectSignedMomentumFromCurvature(float p, //Momentum from curvature 00269 VldContext vc, //Context of this specific event 00270 ReleaseType::Release_t release, //Release verion of the batch processing 00271 EnergyCorrections::WhichCorrection_t whichCor=EnergyCorrections::kDefault); 00272 00273 00274 00275 float CalibrationGroupEnergyCorrections(float E, //Energy in MEU, GeV or SigMap 00276 VldContext vc, //Context of this specific event 00277 ReleaseType::Release_t release, //Release verion of the batch processing 00278 EnergyCorrections::WhichCorrection_t whichCor=EnergyCorrections::kDefault); 00279 00280 00281 00282 00283 //New under the hood shower functions 00284 float ShowerEnergyCorrectionNearDogwood(float energy, 00285 const CandShowerHandle::ShowerType_t& st, 00286 EnergyCorrections::WhichCorrection_t whichCor); 00287 00288 float ShowerEnergyCorrectionFarDogwood(float energy, 00289 const CandShowerHandle::ShowerType_t& st, 00290 EnergyCorrections::WhichCorrection_t whichCor); 00291 00292 float ShowerEnergyCorrectionNearDogwood0(float energy, 00293 const CandShowerHandle::ShowerType_t& st, 00294 EnergyCorrections::WhichCorrection_t whichCor); 00295 00296 float ShowerEnergyCorrectionFarDogwood0(float energy, 00297 const CandShowerHandle::ShowerType_t& st, 00298 EnergyCorrections::WhichCorrection_t whichCor); 00299 00300 float ShowerEnergyCorrectionNearCedarPhyBhcurve(float energy, 00301 const CandShowerHandle::ShowerType_t& st, 00302 EnergyCorrections::WhichCorrection_t whichCor); 00303 00304 float ShowerEnergyCorrectionFarCedarPhyBhcurve(float energy, 00305 const CandShowerHandle::ShowerType_t& st, 00306 EnergyCorrections::WhichCorrection_t whichCor); 00307 00308 float ShowerEnergyCorrectionNearCedar(float energy, 00309 const CandShowerHandle::ShowerType_t& st, 00310 EnergyCorrections::WhichCorrection_t whichCor); 00311 00312 float ShowerEnergyCorrectionFarCedar(float energy, 00313 const CandShowerHandle::ShowerType_t& st, 00314 EnergyCorrections::WhichCorrection_t whichCor); 00315 00316 //Masaki's correction 00317 00318 float MasakiNearJune30_2009(float energy, 00319 const CandShowerHandle::ShowerType_t& st); 00320 float MasakiFarJune30_2009(float energy, 00321 const CandShowerHandle::ShowerType_t& st); 00322 00323 float MasakiNear_forDogwood0(float energy, 00324 const CandShowerHandle::ShowerType_t& st); 00325 float MasakiFar_forDogwood0(float energy, 00326 const CandShowerHandle::ShowerType_t& st); 00327 00328 float MasakiNearDec15th(float energy, 00329 const CandShowerHandle::ShowerType_t& st); 00330 float MasakiFarDec15th(float energy, 00331 const CandShowerHandle::ShowerType_t& st); 00332 00333 float MasakiNearDec15thScaled(float energy, 00334 const CandShowerHandle::ShowerType_t& st); 00335 float MasakiFarDec15thScaled(float energy, 00336 const CandShowerHandle::ShowerType_t& st); 00337 00338 float MasakiNearMay17th(float energy, 00339 const CandShowerHandle::ShowerType_t& st); 00340 float MasakiFarMay17th(float energy, 00341 const CandShowerHandle::ShowerType_t& st); 00342 00343 //Masaki's correction scaled by CG group correction 00344 float MasakiNearMay17thScaled(float energy, 00345 const CandShowerHandle::ShowerType_t& st); 00346 float MasakiFarMay17thScaled(float energy, 00347 const CandShowerHandle::ShowerType_t& st); 00348 00349 00350 //New under the hood track functions 00351 float SignedMomentumCurvatureCorrectionCedar(float p, VldContext vc, 00352 WhichCorrection_t whichCor); 00353 float SignedMomentumCurvatureCorrectionBirch(float p, VldContext vc, 00354 WhichCorrection_t whichCor); 00355 float MomentumRangeCorrectionBirch(float p, VldContext vc, 00356 WhichCorrection_t whichCor); 00357 float MomentumRangeCorrectionCedar(float p, VldContext vc, 00358 WhichCorrection_t whichCor); 00359 float EnergyRangeCorrectionCedar(float E, VldContext vc, 00360 WhichCorrection_t whichCor); 00361 00362 00363 //New function to be called directly from CandShowerHandle to set the GeV 00364 // value in the reco tree to be as close as possible to correct for the 00365 // forthcoming Dogwood release 00366 float ShowerEnergyConversionDogwood(float E, VldContext vc); 00367 float WeightedShowerEnergyConversionDogwood(float E, VldContext vc); 00368 00369 00370 //**************** Legacy **************************************** 00371 //****************************************************************** 00372 // At some point in the future these legacy functions will be removed. 00373 // Use the supported functions above 00374 //CorrectionVersion_t is now deprecated only remains for legacy code 00375 typedef enum ECorrectionVersion { 00376 kUnknown, 00377 kBirch, 00378 kCedar, 00379 kDogwood 00380 } CorrectionVersion_t; 00381 00382 00383 //These following functions are now deprecated and only remain for legacy use 00384 // set static variables to control corrections 00385 void SetCorrectionVersion(const CorrectionVersion_t& ver, 00386 Short_t subver=0); 00387 std::string GetCorrectionAsString(); 00388 void WarnUnknownVersion(const char* caller_routine); 00389 CorrectionVersion_t VersionFromFilename(const char*); 00390 00391 // **************************************************************** 00392 // **************** Legacy **************************************** 00393 00394 00395 // Track momentum and energy corrections 00396 // routines to make energy corrections 00397 float CorrectMomentumFromRange(float p, bool isdata=true, 00398 Detector::Detector_t det=Detector::kNear); 00399 00400 float CorrectEnergyFromRange(float E, bool isdata=true, 00401 Detector::Detector_t det=Detector::kNear); 00402 00403 float CorrectSignedMomentumFromCurvature(float p, 00404 bool isdata=true, 00405 Detector::Detector_t det=Detector::kNear); 00406 00407 00408 // The following code is no longer the correct function to call 00409 // use FullyCorrectShowerEnergy instead 00410 //Shower energy corrections 00411 float CorrectShowerEnergy(float E, 00412 const Detector::Detector_t& det, 00413 const CandShowerHandle::ShowerType_t& st, 00414 int mode=1, bool isdata=true); 00415 00416 00417 // prefer CorrectShowerEnergy to the following two routines 00418 // should've really put these "under the hood" 00419 float CorrectShowerEnergyNear(float E, 00420 const CandShowerHandle::ShowerType_t& st, 00421 int mode=1, bool isdata=true); 00422 00423 float CorrectShowerEnergyFar(float E, 00424 const CandShowerHandle::ShowerType_t& st, 00425 int mode=1, bool isdata=true); 00426 00427 // private: 00428 // actual workhorse routines 00429 00430 // static CorrectionVersion_t fVersion = EnergyCorrections::kUnknown; 00431 // static Short_t fSubVersion = 0; 00432 00433 00434 // corrections for birch 00435 00436 float CorrectMomentumFromRange_Birch(float p, bool isdata=true, 00437 Detector::Detector_t det=Detector::kNear); 00438 00439 float CorrectSignedMomentumFromCurvature_Birch(float p, 00440 bool isdata=true, 00441 Detector::Detector_t det=Detector::kNear); 00442 00443 float CorrectShowerEnergyNear_Birch(float E, 00444 const CandShowerHandle::ShowerType_t& st, 00445 int mode=1, bool isdata=true); 00446 00447 float CorrectShowerEnergyFar_Birch(float E, 00448 const CandShowerHandle::ShowerType_t& st, 00449 int mode=1, bool isdata=true); 00450 00451 // corrections for cedar 00452 00453 float CorrectMomentumFromRange_Cedar(float p, bool isdata=true, 00454 Detector::Detector_t det=Detector::kNear); 00455 00456 float CorrectSignedMomentumFromCurvature_Cedar(float p, 00457 bool isdata=true, 00458 Detector::Detector_t det=Detector::kNear); 00459 00460 00461 float CorrectShowerEnergyNear_Cedar(float E, 00462 const CandShowerHandle::ShowerType_t& st, 00463 int mode=1, bool isdata=true); 00464 00465 00466 float CorrectShowerEnergyFar_Cedar(float E, 00467 const CandShowerHandle::ShowerType_t& st, 00468 int mode=1, bool isdata=true); 00469 00470 } 00471 #endif