00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00160
00161 #include <cmath>
00162 #include "TString.h"
00163
00164 #include "Conventions/BeamType.h"
00165 #include "Conventions/Detector.h"
00166 #include "Conventions/Munits.h"
00167 #include "Conventions/ReleaseType.h"
00168 #include "MessageService/MsgService.h"
00169 #include "MCReweight/MCReweight.h"
00170 #include "MCReweight/NeugenWeightCalculator.h"
00171 #include "NeugenInterface/ccnc.h"
00172 #include "NeugenInterface/flavor.h"
00173 #include "NeugenInterface/init_state.h"
00174 #include "NeugenInterface/interaction.h"
00175 #include "NeugenInterface/nucleus.h"
00176 #include "NeugenInterface/process.h"
00177 #include "NeugenInterface/neugen_cuts.h"
00178 #include "NeugenInterface/neugen_config.h"
00179 #include "NeugenInterface/neugen_wrapper.h"
00180 #include "NtupleUtils/NuEvent.h"
00181 #include "NtupleUtils/NuFluctuator.h"
00182 #include "NtupleUtils/NuSystematic.h"
00183 #include "NtupleUtils/NuXMLConfig.h"
00184 #include "Registry/Registry.h"
00185
00186 ClassImp(NuSystematic)
00187
00188 CVSID("$Id: NuSystematic.cxx,v 1.28 2008/04/14 15:39:54 evans Exp $");
00189
00190 Bool_t NuSystematic::firstMCReweight = true;
00191
00192
00193 NuSystematic::NuSystematic()
00194 {
00195 MSG("NuSystematic.cxx",Msg::kInfo)
00196 << "Constructing default NuSystematic object" << endl;
00197
00198 this->ConfigureSystematics();
00199 this->ConfigureNeugenDefaults();
00200 fSystematicID = NuSyst::kUnknown;
00201 fShiftSizeAsSigma = 0.0;
00202 fFluctuator = new NuFluctuator();
00203 }
00204
00205
00206 NuSystematic::NuSystematic(const NuXMLConfig& xmlConfig)
00207 {
00208 this->ConfigureSystematics();
00209 this->ConfigureNeugenDefaults();
00210 fFluctuator = 0;
00211
00212 TString systName = xmlConfig.Name();
00213 if (systName.Contains("Nominal",TString::kIgnoreCase)){
00214 fSystematicID = NuSyst::kNominal;
00215 }
00216 else if (systName.Contains("Scraping",TString::kIgnoreCase) ||
00217 systName.Contains("DecayPipe",TString::kIgnoreCase)){
00218 fSystematicID = NuSyst::kScraping;
00219 }
00220 else if (systName.Contains("ShowerEnergyOffset",TString::kIgnoreCase)){
00221 fSystematicID = NuSyst::kShowerEnergyOffset;
00222 }
00223 else if (systName.Contains("ShowerEnergyScaleBoth",TString::kIgnoreCase) ||
00224 systName.Contains("AbsoluteEnergyCalibration",TString::kIgnoreCase)){
00225 fSystematicID = NuSyst::kShowerEnergyScale;
00226 }
00227 else if (systName.Contains("ShowerEnergyScaleFunctionBoth",TString::kIgnoreCase)){
00228 fSystematicID = NuSyst::kShowerEnergyFunction;
00229 }
00230 else if (systName.Contains("ShowerEnergyScaleNear",TString::kIgnoreCase) ||
00231 systName.Contains("RelativeEnergyCalibrationNear",TString::kIgnoreCase)){
00232 fSystematicID = NuSyst::kShowerEnergyScaleNear;
00233 }
00234 else if (systName.Contains("ShowerEnergyScaleFar",TString::kIgnoreCase) ||
00235 systName.Contains("RelativeEnergyCalibrationFar",TString::kIgnoreCase)){
00236 fSystematicID = NuSyst::kShowerEnergyScaleFar;
00237 }
00238 else if (systName.Contains("ShowerEnergyScaleRelative",TString::kIgnoreCase) ||
00239 systName.Contains("RelativeEnergyCalibration",TString::kIgnoreCase)){
00240 fSystematicID = NuSyst::kShowerEnergyScaleRelative;
00241 }
00242 else if (systName.Contains("TrackEnergyCurvatureBoth",TString::kIgnoreCase)){
00243 fSystematicID = NuSyst::kTrackEnergyCurvatureBoth;
00244 }
00245 else if (systName.Contains("TrackEnergyCurvatureFar",TString::kIgnoreCase)){
00246 fSystematicID = NuSyst::kTrackEnergyCurvatureFar;
00247 }
00248 else if (systName.Contains("TrackEnergyRange",TString::kIgnoreCase)){
00249 fSystematicID = NuSyst::kTrackEnergyRange;
00250 }
00251 else if (systName.Contains("TrackEnergyOverall",TString::kIgnoreCase)){
00252 fSystematicID = NuSyst::kTrackEnergyOverall;
00253 }
00254 else if (systName.Contains("Beam",TString::kIgnoreCase) ||
00255 systName.Contains("SKZP",TString::kIgnoreCase) ||
00256 systName.Contains("Flux",TString::kIgnoreCase)){
00257 fSystematicID = NuSyst::kBeam;
00258 }
00259 else if (systName.Contains("NCBackground",TString::kIgnoreCase)){
00260 fSystematicID = NuSyst::kNCBackground;
00261 }
00262 else if (systName.Contains("NormalisationBoth",TString::kIgnoreCase) ||
00263 systName.Contains("NormalizationBoth",TString::kIgnoreCase)){
00264 fSystematicID = NuSyst::kNormalisationBoth;
00265 }
00266 else if (systName.Contains("NormalisationNear",TString::kIgnoreCase) ||
00267 systName.Contains("NormalizationNear",TString::kIgnoreCase)){
00268 fSystematicID = NuSyst::kNormalisationNear;
00269 }
00270 else if (systName.Contains("NormalisationFar",TString::kIgnoreCase) ||
00271 systName.Contains("NormalizationFar",TString::kIgnoreCase)){
00272 fSystematicID = NuSyst::kNormalisationFar;
00273 }
00274 else if (systName.Contains("CombinedXSecCCMA",TString::kIgnoreCase)){
00275 fSystematicID = NuSyst::kCombinedXSecCCMA;
00276 }
00277 else if (systName.Contains("CombinedXSecMaRes",TString::kIgnoreCase)){
00278 fSystematicID = NuSyst::kCombinedXSecMaRes;
00279 }
00280 else if (systName.Contains("CombinedXSecMaQE",TString::kIgnoreCase)){
00281 fSystematicID = NuSyst::kCombinedXSecMaQE;
00282 }
00283 else if (systName.Contains("CombinedXSecOverall",TString::kIgnoreCase)){
00284 fSystematicID = NuSyst::kCombinedXSecOverall;
00285 }
00286 else if (systName.Contains("CombinedXSecDISMultip2",TString::kIgnoreCase)){
00287 fSystematicID = NuSyst::kCombinedXSecDISMultip2;
00288 }
00289 else if (systName.Contains("CombinedXSecDISMultip3",TString::kIgnoreCase)){
00290 fSystematicID = NuSyst::kCombinedXSecDISMultip3;
00291 }
00292 else if (systName.Contains("NuMuBarXSecCCMA",TString::kIgnoreCase)){
00293 fSystematicID = NuSyst::kNuMuBarXSecCCMA;
00294 }
00295 else if (systName.Contains("NuMuBarXSecQEL",TString::kIgnoreCase)){
00296 fSystematicID = NuSyst::kNuMuBarXSecQEL;
00297 }
00298 else if (systName.Contains("NuMuBarXSecRes",TString::kIgnoreCase)){
00299 fSystematicID = NuSyst::kNuMuBarXSecRes;
00300 }
00301 else if (systName.Contains("NuMuBarXSecOverall",TString::kIgnoreCase)){
00302 fSystematicID = NuSyst::kNuMuBarXSecOverall;
00303 }
00304 else if (systName.Contains("NuMuBarXSecDISMultip2",TString::kIgnoreCase)){
00305 fSystematicID = NuSyst::kNuMuBarXSecDISMultip2;
00306 }
00307 else if (systName.Contains("BFieldBoth",TString::kIgnoreCase)){
00308 fSystematicID = NuSyst::kBFieldBoth;
00309 fFluctuator = new NuFluctuator();
00310 }
00311 else if (systName.Contains("BFieldNear",TString::kIgnoreCase)){
00312 fSystematicID = NuSyst::kBFieldNear;
00313 fFluctuator = new NuFluctuator();
00314 }
00315 else if (systName.Contains("BFieldFar",TString::kIgnoreCase)){
00316 fSystematicID = NuSyst::kBFieldFar;
00317 fFluctuator = new NuFluctuator();
00318 }
00319 else if (systName.Contains("JitterVDPID",TString::kIgnoreCase)){
00320 fSystematicID = NuSyst::kJitterVDPID;
00321 }
00322 else if (systName.Contains("TFProb",TString::kIgnoreCase)){
00323 fSystematicID = NuSyst::kTFProb;
00324 }
00325 else {
00326 fSystematicID = NuSyst::kUnknown;
00327 }
00328
00329 fShiftSizeAsSigma = this->ConvertShiftToSigma(xmlConfig.Shift());
00330
00331 MSG("NuSystematic.cxx",Msg::kInfo)
00332 << "Constructed NuSystematic object for "
00333 << xmlConfig.Name() << " "
00334 << fShiftSizeAsSigma << "sigma" << endl;
00335 }
00336
00337
00338 NuSystematic::~NuSystematic()
00339 {
00340 if (fFluctuator){delete fFluctuator; fFluctuator = 0;}
00341 }
00342
00343
00344 void NuSystematic::ConfigureSystematics()
00345 {
00346 fShwEnOff1Sigma = 100*Munits::MeV;
00347 fShwEnScale1Sigma = 1.10;
00348 fShwEnFunction1Sigma = 1.0;
00349 fShwEnScaleFar1Sigma = 1.023;
00350 fShwEnScaleNear1Sigma = 1.031;
00351 fShwEnScaleRelative1Sigma = 1.039;
00352 fTrkEnCurvBoth1Sigma = 1.03;
00353 fTrkEnCurvFar1Sigma = 1.03;
00354 fTrkEnRange1Sigma = 1.02;
00355 fBeam1Sigma = 1.0;
00356 fBFieldBoth1Sigma = 2.0;
00357 fBFieldNear1Sigma = 2.0;
00358 fBFieldFar1Sigma = 2.0;
00359 fNCBackground1Sigma = 1.50;
00360 fNormalisationBoth1Sigma = 1.04;
00361 fNormalisationNear1Sigma = 1.04;
00362 fNormalisationFar1Sigma = 1.04;
00363 fCombinedXSecOverall1Sigma = 1.035;
00364 fCombinedXSecCCMA1Sigma = 1.15;
00365 fCombinedXSecMaRes1Sigma = 1.15;
00366 fCombinedXSecMaQE1Sigma = 1.15;
00367 fCombinedXSecDISMultip21Sigma = 0.1;
00368 fCombinedXSecDISMultip31Sigma = 0.2;
00369 fNuMuBarXSecOverall1Sigma = 1.04;
00370 fNuMuBarXSecCCMA1Sigma = 1.08;
00371 fNuMuBarXSecQEL1Sigma = 1.08;
00372 fNuMuBarXSecRes1Sigma = 1.08;
00373 fNuMuBarXSecDISMultip21Sigma = 0.2;
00374 fScraping1Sigma = 1.25;
00375 fJitter1Sigma = 0.01;
00376 fDPID1Sigma = 0.03;
00377 fTFProb1Sigma = 0.005;
00378 }
00379
00380
00381 void NuSystematic::ConfigureNeugenDefaults()
00382 {
00383 fkno_r112Default = 0.1;
00384 fkno_r122Default = 0.3;
00385 fkno_r132Default = 0.3;
00386 fkno_r142Default = 0.1;
00387 fkno_r113Default = 1.0;
00388 fkno_r123Default = 1.0;
00389 fkno_r133Default = 1.0;
00390 fkno_r143Default = 1.0;
00391 fkno_r212Default = 0.1;
00392 fkno_r222Default = 0.3;
00393 fkno_r232Default = 0.3;
00394 fkno_r242Default = 0.1;
00395 fkno_r213Default = 1.0;
00396 fkno_r223Default = 1.0;
00397 fkno_r233Default = 1.0;
00398 fkno_r243Default = 1.0;
00399 fma_qeDefault = 0.99;
00400 fma_resDefault = 1.12;
00401 }
00402
00403
00404 const Float_t NuSystematic::ConvertSigmaToShift(const Float_t sigma)
00405 const
00406 {
00407 if (NuSyst::kNominal == fSystematicID){
00408 return 0.0;
00409 }
00410 else if(NuSyst::kScraping == fSystematicID){
00411 return sigma*(fScraping1Sigma-1.0)+1.0;
00412 }
00413 else if(NuSyst::kShowerEnergyOffset == fSystematicID){
00414 return sigma*fShwEnOff1Sigma;
00415 }
00416 else if(NuSyst::kShowerEnergyScale == fSystematicID){
00417 return sigma*(fShwEnScale1Sigma-1.0)+1.0;
00418 }
00419 else if(NuSyst::kShowerEnergyFunction == fSystematicID){
00420 return sigma;
00421 }
00422 else if(NuSyst::kShowerEnergyScaleNear == fSystematicID){
00423 return sigma*(fShwEnScaleNear1Sigma-1.0)+1.0;
00424 }
00425 else if(NuSyst::kShowerEnergyScaleFar == fSystematicID){
00426 return sigma*(fShwEnScaleFar1Sigma-1.0)+1.0;
00427 }
00428 else if(NuSyst::kShowerEnergyScaleRelative == fSystematicID){
00429 return sigma*(fShwEnScaleRelative1Sigma-1.0)+1.0;
00430 }
00431 else if(NuSyst::kTrackEnergyCurvatureBoth == fSystematicID){
00432 return sigma*(fTrkEnCurvBoth1Sigma-1.0)+1.0;
00433 }
00434 else if(NuSyst::kTrackEnergyCurvatureFar == fSystematicID){
00435 return sigma*(fTrkEnCurvFar1Sigma-1.0)+1.0;
00436 }
00437 else if(NuSyst::kTrackEnergyRange == fSystematicID){
00438 return sigma*(fTrkEnRange1Sigma-1.0)+1.0;
00439 }
00440 else if(NuSyst::kTrackEnergyOverall == fSystematicID){
00441 return sigma;
00442 }
00443 else if(NuSyst::kBeam == fSystematicID){
00444 return sigma;
00445 }
00446 else if (NuSyst::kBFieldBoth == fSystematicID){
00447 return sigma*(fBFieldBoth1Sigma-1.0)+1.0;
00448 }
00449 else if (NuSyst::kBFieldNear == fSystematicID){
00450 return sigma*(fBFieldNear1Sigma-1.0)+1.0;
00451 }
00452 else if (NuSyst::kBFieldFar == fSystematicID){
00453 return sigma*(fBFieldFar1Sigma-1.0)+1.0;
00454 }
00455 else if(NuSyst::kNCBackground == fSystematicID){
00456 return sigma*(fNCBackground1Sigma-1.0)+1.0;
00457 }
00458 else if(NuSyst::kNormalisationBoth == fSystematicID){
00459 return sigma*(fNormalisationBoth1Sigma-1.0)+1.0;
00460 }
00461 else if(NuSyst::kNormalisationNear == fSystematicID){
00462 return sigma*(fNormalisationNear1Sigma-1.0)+1.0;
00463 }
00464 else if(NuSyst::kNormalisationFar == fSystematicID){
00465 return sigma*(fNormalisationFar1Sigma-1.0)+1.0;
00466 }
00467 else if(NuSyst::kCombinedXSecOverall == fSystematicID){
00468 return sigma*(fCombinedXSecOverall1Sigma-1.0)+1.0;
00469 }
00470 else if(NuSyst::kCombinedXSecCCMA == fSystematicID){
00471 return sigma*(fCombinedXSecCCMA1Sigma-1.0)+1.0;
00472 }
00473 else if(NuSyst::kCombinedXSecMaRes == fSystematicID){
00474 return sigma*(fCombinedXSecMaRes1Sigma-1.0)+1.0;
00475 }
00476 else if(NuSyst::kCombinedXSecMaQE == fSystematicID){
00477 return sigma*(fCombinedXSecMaQE1Sigma-1.0)+1.0;
00478 }
00479 else if(NuSyst::kCombinedXSecDISMultip2 == fSystematicID){
00480 return sigma*fCombinedXSecDISMultip21Sigma;
00481 }
00482 else if(NuSyst::kCombinedXSecDISMultip3 == fSystematicID){
00483 return sigma*fCombinedXSecDISMultip31Sigma;
00484 }
00485 else if(NuSyst::kNuMuBarXSecOverall == fSystematicID){
00486 return sigma*(fNuMuBarXSecOverall1Sigma-1.0)+1.0;
00487 }
00488 else if(NuSyst::kNuMuBarXSecCCMA == fSystematicID){
00489 return sigma*(fNuMuBarXSecCCMA1Sigma-1.0)+1.0;
00490 }
00491 else if(NuSyst::kNuMuBarXSecQEL == fSystematicID){
00492 return sigma*(fNuMuBarXSecQEL1Sigma-1.0)+1.0;
00493 }
00494 else if(NuSyst::kNuMuBarXSecRes == fSystematicID){
00495 return sigma*(fNuMuBarXSecRes1Sigma-1.0)+1.0;
00496 }
00497 else if(NuSyst::kNuMuBarXSecDISMultip2 == fSystematicID){
00498 return sigma*fNuMuBarXSecDISMultip21Sigma;
00499 }
00500 else if(NuSyst::kJitterVDPID == fSystematicID){
00501 return sigma;
00502 }
00503 else if(NuSyst::kTFProb == fSystematicID){
00504 return sigma;
00505 }
00506 else {
00507 return 0.0;
00508 }
00509 }
00510
00511
00512 const Float_t NuSystematic::ConvertShiftToSigma(const Float_t shift)
00513 const
00514 {
00515 if (NuSyst::kNominal == fSystematicID){
00516 return 0.0;
00517 }
00518 else if(NuSyst::kScraping == fSystematicID){
00519 return (shift-1.0)/(fScraping1Sigma-1.0);
00520 }
00521 else if(NuSyst::kShowerEnergyOffset == fSystematicID){
00522 return shift/fShwEnOff1Sigma;
00523 }
00524 else if(NuSyst::kShowerEnergyScale == fSystematicID){
00525 return (shift-1.0)/(fShwEnScale1Sigma-1.0);
00526 }
00527 else if(NuSyst::kShowerEnergyFunction == fSystematicID){
00528 return shift;
00529 }
00530 else if(NuSyst::kShowerEnergyScaleNear == fSystematicID){
00531 return (shift-1.0)/(fShwEnScaleNear1Sigma-1.0);
00532 }
00533 else if(NuSyst::kShowerEnergyScaleFar == fSystematicID){
00534 return (shift-1.0)/(fShwEnScaleFar1Sigma-1.0);
00535 }
00536 else if(NuSyst::kShowerEnergyScaleRelative == fSystematicID){
00537 return (shift-1.0)/(fShwEnScaleRelative1Sigma-1.0);
00538 }
00539 else if(NuSyst::kTrackEnergyRange == fSystematicID){
00540 return (shift-1.0)/(fTrkEnRange1Sigma-1.0);
00541 }
00542 else if(NuSyst::kTrackEnergyCurvatureBoth == fSystematicID){
00543 return (shift-1.0)/(fTrkEnCurvBoth1Sigma-1.0);
00544 }
00545 else if(NuSyst::kTrackEnergyCurvatureFar == fSystematicID){
00546 return (shift-1.0)/(fTrkEnCurvFar1Sigma-1.0);
00547 }
00548 else if(NuSyst::kTrackEnergyOverall == fSystematicID){
00549 return shift;
00550 }
00551 else if(NuSyst::kBeam == fSystematicID){
00552 return shift;
00553 }
00554 else if (NuSyst::kBFieldBoth == fSystematicID){
00555 return (shift-1.0)/(fBFieldBoth1Sigma-1.0);
00556 }
00557 else if (NuSyst::kBFieldNear == fSystematicID){
00558 return (shift-1.0)/(fBFieldNear1Sigma-1.0);
00559 }
00560 else if (NuSyst::kBFieldFar == fSystematicID){
00561 return (shift-1.0)/(fBFieldFar1Sigma-1.0);
00562 }
00563 else if(NuSyst::kNCBackground == fSystematicID){
00564 return (shift-1.0)/(fNCBackground1Sigma-1.0);
00565 }
00566 else if(NuSyst::kNormalisationBoth == fSystematicID){
00567 return (shift-1.0)/(fNormalisationBoth1Sigma-1.0);
00568 }
00569 else if(NuSyst::kNormalisationNear == fSystematicID){
00570 return (shift-1.0)/(fNormalisationNear1Sigma-1.0);
00571 }
00572 else if(NuSyst::kNormalisationFar == fSystematicID){
00573 return (shift-1.0)/(fNormalisationFar1Sigma-1.0);
00574 }
00575 else if(NuSyst::kCombinedXSecOverall == fSystematicID){
00576 return (shift-1.0)/(fCombinedXSecOverall1Sigma-1.0);
00577 }
00578 else if(NuSyst::kCombinedXSecCCMA == fSystematicID){
00579 return (shift-1.0)/(fCombinedXSecCCMA1Sigma-1.0);
00580 }
00581 else if(NuSyst::kCombinedXSecMaRes == fSystematicID){
00582 return (shift-1.0)/(fCombinedXSecMaRes1Sigma-1.0);
00583 }
00584 else if(NuSyst::kCombinedXSecMaQE == fSystematicID){
00585 return (shift-1.0)/(fCombinedXSecMaQE1Sigma-1.0);
00586 }
00587 else if(NuSyst::kCombinedXSecDISMultip2 == fSystematicID){
00588 return shift/fCombinedXSecDISMultip21Sigma;
00589 }
00590 else if(NuSyst::kCombinedXSecDISMultip3 == fSystematicID){
00591 return shift/fCombinedXSecDISMultip31Sigma;
00592 }
00593 else if(NuSyst::kNuMuBarXSecOverall == fSystematicID){
00594 return (shift-1.0)/(fNuMuBarXSecOverall1Sigma-1.0);
00595 }
00596 else if(NuSyst::kNuMuBarXSecQEL == fSystematicID){
00597 return (shift-1.0)/(fNuMuBarXSecQEL1Sigma-1.0);
00598 }
00599 else if(NuSyst::kNuMuBarXSecRes == fSystematicID){
00600 return (shift-1.0)/(fNuMuBarXSecRes1Sigma-1.0);
00601 }
00602 else if(NuSyst::kNuMuBarXSecDISMultip2 == fSystematicID){
00603 return shift/fNuMuBarXSecDISMultip21Sigma;
00604 }
00605 else if(NuSyst::kJitterVDPID == fSystematicID){
00606 return shift;
00607 }
00608 else if(NuSyst::kTFProb == fSystematicID){
00609 return shift;
00610 }
00611 else {
00612 return 0.0;
00613 }
00614 }
00615
00616
00617 void NuSystematic::Shift(NuEvent& event) const
00618 {
00619 if (NuSyst::kNominal == fSystematicID){
00620 return;
00621 }
00622 else if(NuSyst::kScraping == fSystematicID){
00623 this->ScrapingShift(event);
00624 return;
00625 }
00626 else if(NuSyst::kShowerEnergyOffset == fSystematicID){
00627 this->ShowerEnergyOffset(event);
00628 return;
00629 }
00630 else if(NuSyst::kShowerEnergyScale == fSystematicID){
00631 this->ShowerEnergyScale(event);
00632 return;
00633 }
00634 else if(NuSyst::kShowerEnergyFunction == fSystematicID){
00635 this->ShowerEnergyFunction(event);
00636 return;
00637 }
00638 else if(NuSyst::kShowerEnergyScaleNear == fSystematicID){
00639 if (Detector::kNear==event.detector){
00640 this->ShowerEnergyScale(event);
00641 }
00642 return;
00643 }
00644 else if(NuSyst::kShowerEnergyScaleFar == fSystematicID){
00645 if (Detector::kFar==event.detector){
00646 this->ShowerEnergyScale(event);
00647 }
00648 return;
00649 }
00650 else if(NuSyst::kShowerEnergyScaleRelative == fSystematicID){
00651 if (Detector::kNear==event.detector){
00652 this->ShowerEnergyScale(event);
00653 }
00654 return;
00655 }
00656 else if(NuSyst::kTrackEnergyRange == fSystematicID){
00657 if (event.usedRange){
00658 this->TrackEnergyRange(event);
00659 }
00660 return;
00661 }
00662 else if(NuSyst::kTrackEnergyCurvatureBoth == fSystematicID){
00663 if (event.usedCurv){
00664 this->TrackEnergyCurvatureBoth(event);
00665 }
00666 return;
00667 }
00668 else if(NuSyst::kTrackEnergyCurvatureFar == fSystematicID){
00669 if (event.usedCurv && Detector::kFar==event.detector){
00670 this->TrackEnergyCurvatureFar(event);
00671 }
00672 return;
00673 }
00674 else if(NuSyst::kTrackEnergyOverall == fSystematicID){
00675 this->TrackEnergyOverall(event);
00676 return;
00677 }
00678 else if(NuSyst::kBeam == fSystematicID){
00679 this->BeamShift(event);
00680 return;
00681 }
00682 else if (NuSyst::kBFieldBoth == fSystematicID){
00683 this->BFieldBothShift(event);
00684 }
00685 else if (NuSyst::kBFieldNear == fSystematicID){
00686 if (Detector::kNear==event.detector){
00687 this->BFieldNearShift(event);
00688 }
00689 return;
00690 }
00691 else if (NuSyst::kBFieldFar == fSystematicID){
00692 if (Detector::kFar==event.detector){
00693 this->BFieldFarShift(event);
00694 }
00695 return;
00696 }
00697 else if(NuSyst::kNCBackground == fSystematicID){
00698 this->NCBackgroundShift(event);
00699 return;
00700 }
00701 else if(NuSyst::kNormalisationBoth == fSystematicID){
00702 this->NormalisationBothShift(event);
00703 return;
00704 }
00705 else if(NuSyst::kNormalisationNear == fSystematicID){
00706 if (Detector::kNear == event.detector){
00707 this->NormalisationNearShift(event);
00708 }
00709 return;
00710 }
00711 else if(NuSyst::kNormalisationFar == fSystematicID){
00712 if (Detector::kFar == event.detector){
00713 this->NormalisationFarShift(event);
00714 }
00715 return;
00716 }
00717 else if(NuSyst::kCombinedXSecOverall == fSystematicID ||
00718 NuSyst::kNuMuBarXSecOverall == fSystematicID){
00719 this->OverallXSecShift(event);
00720 return;
00721 }
00722 else if(NuSyst::kNuMuBarXSecQEL == fSystematicID ||
00723 NuSyst::kNuMuBarXSecQEL == fSystematicID){
00724 this->NuMuBarQELXSecShift(event);
00725 return;
00726 }
00727 else if(NuSyst::kNuMuBarXSecRes == fSystematicID ||
00728 NuSyst::kNuMuBarXSecRes == fSystematicID){
00729 this->NuMuBarResXSecShift(event);
00730 return;
00731 }
00732 else if(NuSyst::kCombinedXSecCCMA == fSystematicID ||
00733 NuSyst::kCombinedXSecMaRes == fSystematicID ||
00734 NuSyst::kCombinedXSecMaQE == fSystematicID ||
00735 NuSyst::kCombinedXSecDISMultip2 == fSystematicID ||
00736 NuSyst::kCombinedXSecDISMultip3 == fSystematicID ||
00737 NuSyst::kNuMuBarXSecCCMA == fSystematicID ||
00738 NuSyst::kNuMuBarXSecDISMultip2 == fSystematicID){
00739 this->NeugenXSecShift(event);
00740 return;
00741 }
00742 else if(NuSyst::kJitterVDPID == fSystematicID){
00743 this->JitterVDPIDShift(event);
00744 return;
00745 }
00746 else {
00747 return;
00748 }
00749 }
00750
00751
00752 void NuSystematic::BeamShift(NuEvent& event) const
00753 {
00754 MAXMSG("NuSystematic",Msg::kInfo,1)
00755 << "Performing beam shift" << endl;
00756 event.rw *= 1.0 +
00757 this->ConvertSigmaToShift(this->ShiftAsSigma()) *
00758 (event.fluxErr-1.0);
00759 return;
00760 }
00761
00762
00763 void NuSystematic::JitterVDPIDShift(NuEvent& event) const
00764 {
00765 MAXMSG("NuSystematic",Msg::kInfo,1)
00766 << "Performing track jitter & DPID shift" << endl;
00767 event.jitter += this->ShiftAsSigma()*fJitter1Sigma;
00768 event.dpID += this->ShiftAsSigma()*fDPID1Sigma;
00769 return;
00770 }
00771
00772
00773 void NuSystematic::TFProbShift(NuEvent& event) const
00774 {
00775 MAXMSG("NuSystematic",Msg::kInfo,1)
00776 << "Performing track fit probability shift" << endl;
00777 event.prob += this->ShiftAsSigma()*fTFProb1Sigma;
00778 return;
00779 }
00780
00781
00782 void NuSystematic::NeugenXSecShift(NuEvent& event) const
00783 {
00784 MAXMSG("NuSystematic",Msg::kInfo,1)
00785 << "Performing a Neugen cross section shift" << endl;
00786 if (0 == event.iaction){return;}
00787 if (NuSyst::kNuMuBarXSecCCMA == this->SystematicID() ||
00788 NuSyst::kNuMuBarXSecDISMultip2 == this->SystematicID()){
00789 if (14 == event.inu){return;}
00790 }
00791
00792 MCReweight& mcReweight = MCReweight::Instance();
00793 if (firstMCReweight){
00794 NeugenWeightCalculator* wc = new NeugenWeightCalculator();
00795 mcReweight.AddWeightCalculator(wc);
00796 firstMCReweight = false;
00797 }
00798
00799 Registry reweightConfigRegistry;
00800 Registry defaultRegistry;
00801
00802
00803 if (ReleaseType::IsDaikon(event.releaseType)){
00804 reweightConfigRegistry.Set("neugen:config_name","MODBYRS");
00805 reweightConfigRegistry.Set("neugen:config_no",4);
00806 defaultRegistry.Set("neugen:config_name","MODBYRS");
00807 defaultRegistry.Set("neugen:config_no",4);
00808 }
00809 else{
00810 MSG("NuSystematic.cxx",Msg::kError)
00811 << "Using non-daikon MC. I don't know how to apply Neugen "
00812 << "parameters to that."
00813 << endl;
00814 }
00815
00816
00817 this->SetShiftedNeugenParameters(reweightConfigRegistry,
00818 this->SystematicID());
00819
00820
00821 MCEventInfo mcEventInfo = this->CreateMCEventInfo(event);
00822 NuParent* nuParent = 0;
00823
00824 mcReweight.ResetAllReweightConfigs();
00825
00826
00827
00828 Double_t weight = mcReweight.ComputeWeight(&mcEventInfo,
00829 nuParent,
00830 &reweightConfigRegistry);
00831
00832
00833
00834
00835 this->SetNeugenDefaults(defaultRegistry);
00836 mcReweight.ResetAllReweightConfigs();
00837 Double_t defaultWeight = mcReweight.ComputeWeight(&mcEventInfo,
00838 nuParent,
00839 &defaultRegistry);
00840
00841 if (defaultWeight>0.0){
00842 event.rw *= weight/defaultWeight;
00843 }
00844 else{
00845 MSG("NuSystematic.cxx",Msg::kError)
00846 << "Default weight <= 0."
00847 << endl;
00848 }
00849 return;
00850 }
00851
00852
00853 void NuSystematic::OverallXSecShift(NuEvent& event) const
00854 {
00855 MAXMSG("NuSystematic",Msg::kInfo,1)
00856 << "Performing overall cross section shift" << endl;
00857 if (1 != event.iaction){return;}
00858 if (!((14 == event.inu) || (-14 == event.inu))){return;}
00859 if (NuSyst::kNuMuBarXSecOverall == this->SystematicID()){
00860 if (-14 != event.inu){return;}
00861 }
00862 event.rw *= this->ShiftAsValue();
00863 return;
00864 }
00865
00866
00867 void NuSystematic::NuMuBarQELXSecShift(NuEvent& event) const
00868 {
00869 MAXMSG("NuSystematic",Msg::kInfo,1)
00870 << "Performing NuMuBar QEL cross section shift" << endl;
00871 if (1 != event.iaction){return;}
00872 if (-14 != event.inu){return;}
00873 if (1001 != event.iresonance){return;}
00874 event.rw *= this->ShiftAsValue();
00875 return;
00876 }
00877
00878
00879 void NuSystematic::NuMuBarResXSecShift(NuEvent& event) const
00880 {
00881 MAXMSG("NuSystematic",Msg::kInfo,1)
00882 << "Performing NuMuBar Res cross section shift" << endl;
00883 if (1 != event.iaction){return;}
00884 if (-14 != event.inu){return;}
00885 if (1002 != event.iresonance){return;}
00886 event.rw *= this->ShiftAsValue();
00887 return;
00888 }
00889
00890
00891 void NuSystematic::BFieldBothShift(NuEvent& event) const
00892 {
00893 MAXMSG("NuSystematic",Msg::kInfo,1)
00894 << "Performing BFieldBoth shift"
00895 << this->ShiftAsValue() << endl;
00896 if (1==event.charge
00897 && 14 == event.inu && 1 == event.iaction){
00898 event.rw *= this->ShiftAsValue();
00899 }
00900 return;
00901 }
00902
00903
00904 void NuSystematic::BFieldNearShift(NuEvent& event) const
00905 {
00906 MAXMSG("NuSystematic",Msg::kInfo,1)
00907 << "Performing BFieldNear shift"
00908 << this->ShiftAsValue() << endl;
00909 if (1==event.charge
00910 && 14 == event.inu && 1 == event.iaction){
00911 event.rw *= this->ShiftAsValue();
00912 }
00913 return;
00914 }
00915
00916
00917 void NuSystematic::BFieldFarShift(NuEvent& event) const
00918 {
00919 MAXMSG("NuSystematic",Msg::kInfo,10)
00920 << "Performing BFieldFar shift "
00921 << this->ShiftAsValue() << endl;
00922
00923 if (1==event.charge
00924 && 14 == event.inu && 1 == event.iaction){
00925 event.rw *= this->ShiftAsValue();
00926 }
00927 return;
00928 }
00929
00930
00931 void NuSystematic::NCBackgroundShift(NuEvent& event) const
00932 {
00933 MAXMSG("NuSystematic",Msg::kInfo,1)
00934 << "Performing NC background shift" << endl;
00935 if (0 != event.iaction){return;}
00936 event.rw *= this->ShiftAsValue();
00937 return;
00938 }
00939
00940
00941 void NuSystematic::NormalisationBothShift(NuEvent& event) const
00942 {
00943 MAXMSG("NuSystematic",Msg::kInfo,1)
00944 << "Performing NormalisationBoth shift" << endl;
00945 event.rw *= this->ShiftAsValue();
00946 return;
00947 }
00948
00949
00950 void NuSystematic::NormalisationNearShift(NuEvent& event) const
00951 {
00952 MAXMSG("NuSystematic",Msg::kInfo,1)
00953 << "Performing NormalisationNear shift" << endl;
00954 event.rw *= this->ShiftAsValue();
00955 return;
00956 }
00957
00958
00959 void NuSystematic::NormalisationFarShift(NuEvent& event) const
00960 {
00961 MAXMSG("NuSystematic",Msg::kInfo,1)
00962 << "Performing NormalisationFar shift" << endl;
00963 event.rw *= this->ShiftAsValue();
00964 return;
00965 }
00966
00967
00968 void NuSystematic::ScrapingShift(NuEvent& event) const
00969 {
00970 MAXMSG("NuSystematic",Msg::kInfo,1)
00971 << "Performing scraping shift" << endl;
00972 Float_t r = sqrt(event.ppvx*event.ppvx +
00973 event.ppvy*event.ppvy);
00974 Float_t z = event.ppvz;
00975 Float_t Znom = 52.06;
00976 if (BeamType::kL250z200i == event.beamType){
00977 Znom = -187.06;
00978 }
00979 else if (BeamType::kL010z185i == event.beamType){
00980 Znom = 52.06;
00981 }
00982 else{
00983 Znom = 52.06;
00984 }
00985
00986 if (r < 1.65 && TMath::Abs(z - Znom) < 0.1)
00987 return;
00988
00989 if (TMath::Abs(r - 1.51) < 0.11 && z < Znom)
00990 return;
00991
00992
00993 event.rw *= this->ShiftAsValue();
00994
00995 return;
00996 }
00997
00998
00999 void NuSystematic::ShowerEnergyOffset(NuEvent& event) const
01000 {
01001 MAXMSG("NuSystematic",Msg::kInfo,1)
01002 << "Performing shower energy offset shift" << endl;
01003 event.shwEn +=
01004 this->ConvertSigmaToShift(this->ShiftAsSigma())/Munits::GeV;
01005 event.energy = event.shwEn+event.trkEn;
01006 return;
01007 }
01008
01009
01010 void NuSystematic::ShowerEnergyFunction(NuEvent& event) const
01011 {
01012 MAXMSG("NuSystematic",Msg::kInfo,1)
01013 << "Performing shower energy function scale "
01014 << this->ConvertSigmaToShift(this->ShiftAsSigma())
01015 << " sigma" << endl;
01016
01017 Double_t offset = 7.0;
01018 Double_t scale = 4.0;
01019 Double_t eLife = 1.5;
01020 Double_t enShift = 1.0 + this->ShiftAsSigma()*0.01*
01021 (offset + scale*TMath::Exp(-1.0*event.shwEn/eLife));
01022 event.shwEn *= enShift;
01023 event.energy = event.shwEn+event.trkEn;
01024 return;
01025 }
01026
01027
01028 void NuSystematic::ShowerEnergyScale(NuEvent& event) const
01029 {
01030 MAXMSG("NuSystematic",Msg::kInfo,1)
01031 << "Performing shower energy scale shift" << endl;
01032 event.shwEn *= this->ShiftAsValue();
01033 event.energy = event.shwEn+event.trkEn;
01034 return;
01035 }
01036
01037
01038 void NuSystematic::TrackEnergyRange(NuEvent& event) const
01039 {
01040 MAXMSG("NuSystematic",Msg::kInfo,1)
01041 << "Performing track energy range shift" << endl;
01042 event.trkEn *= this->ShiftAsValue();
01043 event.energy = event.shwEn+event.trkEn;
01044 return;
01045 }
01046
01047
01048 void NuSystematic::TrackEnergyCurvatureBoth(NuEvent& event) const
01049 {
01050 MAXMSG("NuSystematic",Msg::kInfo,1)
01051 << "Performing track energy curvature both shift" << endl;
01052 event.trkEn *= this->ShiftAsValue();
01053 event.energy = event.shwEn+event.trkEn;
01054 return;
01055 }
01056
01057
01058 void NuSystematic::TrackEnergyCurvatureFar(NuEvent& event) const
01059 {
01060 MAXMSG("NuSystematic",Msg::kInfo,1)
01061 << "Performing track energy curvature far shift" << endl;
01062 event.trkEn *= this->ShiftAsValue();
01063 event.energy = event.shwEn+event.trkEn;
01064 return;
01065 }
01066
01067
01068 void NuSystematic::TrackEnergyOverall(NuEvent& event) const
01069 {
01070 MAXMSG("NuSystematic",Msg::kInfo,1)
01071 << "Performing overall track energy shift "
01072 << this->ShiftAsSigma() << " sigma"
01073 << endl;
01074 Double_t eScale = 1.0;
01075 if (event.usedRange){
01076 eScale = 2.0;
01077 }
01078 else if (event.usedCurv){
01079 eScale = 3.0;
01080 }
01081 else {
01082 eScale = 1.0;
01083 }
01084 event.trkEn *= 1.0 + this->ShiftAsSigma()*0.01*eScale;
01085 event.energy = event.shwEn+event.trkEn;
01086 return;
01087 }
01088
01089
01090 void NuSystematic::SetNeugenDefaults(Registry& registry) const
01091 {
01092 registry.Set("neugen:kno_r112",fkno_r112Default);
01093 registry.Set("neugen:kno_r122",fkno_r122Default);
01094 registry.Set("neugen:kno_r132",fkno_r132Default);
01095 registry.Set("neugen:kno_r142",fkno_r142Default);
01096 registry.Set("neugen:kno_r113",fkno_r113Default);
01097 registry.Set("neugen:kno_r123",fkno_r123Default);
01098 registry.Set("neugen:kno_r133",fkno_r133Default);
01099 registry.Set("neugen:kno_r143",fkno_r143Default);
01100 registry.Set("neugen:ma_qe",fma_qeDefault);
01101 registry.Set("neugen:ma_res",fma_resDefault);
01102 return;
01103 }
01104
01105
01106 void NuSystematic
01107 ::SetShiftedNeugenParameters(Registry& registry,
01108 const NuSyst::NuSystematic_t syst) const
01109 {
01110 if (NuSyst::kCombinedXSecCCMA == syst){
01111
01112
01113
01114
01115
01116
01117
01118
01119 Float_t ma_qe = this->MA_QEDefault() * this->ShiftAsValue();
01120 Float_t ma_res = this->MA_ResDefault() * this->ShiftAsValue();
01121 registry.Set("neugen:ma_qe",ma_qe);
01122 registry.Set("neugen:ma_res",ma_res);
01123 return;
01124 }
01125 else if (NuSyst::kCombinedXSecMaRes == syst){
01126 Float_t ma_res = this->MA_ResDefault() * this->ShiftAsValue();
01127 registry.Set("neugen:ma_res",ma_res);
01128 return;
01129 }
01130 else if (NuSyst::kCombinedXSecMaQE == syst){
01131 Float_t ma_qe = this->MA_QEDefault() * this->ShiftAsValue();
01132 registry.Set("neugen:ma_qe",ma_qe);
01133 return;
01134 }
01135 else if (NuSyst::kCombinedXSecDISMultip2 == syst){
01136
01137
01138
01139
01140
01141
01142 Float_t kno112 = this->KNO112Default() + this->ShiftAsValue();
01143 if (kno112<0.0){kno112=0.0;}
01144 if (kno112>1.0){kno112=1.0;}
01145 Float_t kno122 = this->KNO122Default() + this->ShiftAsValue();
01146 if (kno122<0.0){kno122=0.0;}
01147 if (kno122>1.0){kno122=1.0;}
01148 Float_t kno132 = this->KNO132Default() + this->ShiftAsValue();
01149 if (kno132<0.0){kno132=0.0;}
01150 if (kno132>1.0){kno132=1.0;}
01151 Float_t kno142 = this->KNO142Default() + this->ShiftAsValue();
01152 if (kno142<0.0){kno142=0.0;}
01153 if (kno142>1.0){kno142=1.0;}
01154 Float_t kno212 = this->KNO212Default() + this->ShiftAsValue();
01155 if (kno212<0.0){kno212=0.0;}
01156 if (kno212>1.0){kno212=1.0;}
01157 Float_t kno222 = this->KNO222Default() + this->ShiftAsValue();
01158 if (kno222<0.0){kno222=0.0;}
01159 if (kno222>1.0){kno222=1.0;}
01160 Float_t kno232 = this->KNO232Default() + this->ShiftAsValue();
01161 if (kno232<0.0){kno232=0.0;}
01162 if (kno232>1.0){kno232=1.0;}
01163 Float_t kno242 = this->KNO242Default() + this->ShiftAsValue();
01164 if (kno242<0.0){kno242=0.0;}
01165 if (kno242>1.0){kno242=1.0;}
01166 registry.Set("neugen:kno_r112",kno112);
01167 registry.Set("neugen:kno_r122",kno122);
01168 registry.Set("neugen:kno_r132",kno132);
01169 registry.Set("neugen:kno_r142",kno142);
01170 registry.Set("neugen:kno_r212",kno212);
01171 registry.Set("neugen:kno_r222",kno222);
01172 registry.Set("neugen:kno_r232",kno232);
01173 registry.Set("neugen:kno_r242",kno242);
01174 }
01175 else if (NuSyst::kCombinedXSecDISMultip3 == syst){
01176
01177
01178
01179
01180
01181
01182 Float_t kno113 = this->KNO113Default() + this->ShiftAsValue();
01183 if (kno113<0.0){kno113=0.0;}
01184 if (kno113>1.0){kno113=1.0;}
01185 Float_t kno123 = this->KNO123Default() + this->ShiftAsValue();
01186 if (kno123<0.0){kno123=0.0;}
01187 if (kno123>1.0){kno123=1.0;}
01188 Float_t kno133 = this->KNO133Default() + this->ShiftAsValue();
01189 if (kno133<0.0){kno133=0.0;}
01190 if (kno133>1.0){kno133=1.0;}
01191 Float_t kno143 = this->KNO143Default() + this->ShiftAsValue();
01192 if (kno143<0.0){kno143=0.0;}
01193 if (kno143>1.0){kno143=1.0;}
01194 Float_t kno213 = this->KNO213Default() + this->ShiftAsValue();
01195 if (kno213<0.0){kno213=0.0;}
01196 if (kno213>1.0){kno213=1.0;}
01197 Float_t kno223 = this->KNO223Default() + this->ShiftAsValue();
01198 if (kno223<0.0){kno223=0.0;}
01199 if (kno223>1.0){kno223=1.0;}
01200 Float_t kno233 = this->KNO233Default() + this->ShiftAsValue();
01201 if (kno233<0.0){kno233=0.0;}
01202 if (kno233>1.0){kno233=1.0;}
01203 Float_t kno243 = this->KNO243Default() + this->ShiftAsValue();
01204 if (kno243<0.0){kno243=0.0;}
01205 if (kno243>1.0){kno243=1.0;}
01206 registry.Set("neugen:kno_r113",kno113);
01207 registry.Set("neugen:kno_r123",kno123);
01208 registry.Set("neugen:kno_r133",kno133);
01209 registry.Set("neugen:kno_r143",kno143);
01210 registry.Set("neugen:kno_r213",kno213);
01211 registry.Set("neugen:kno_r223",kno223);
01212 registry.Set("neugen:kno_r233",kno233);
01213 registry.Set("neugen:kno_r243",kno243);
01214 }
01215 else if (NuSyst::kNuMuBarXSecCCMA == syst){
01216
01217
01218
01219
01220
01221
01222
01223
01224 Float_t ma_qe = this->MA_QEDefault() * this->ShiftAsValue();
01225 Float_t ma_res = this->MA_ResDefault() * this->ShiftAsValue();
01226 registry.Set("neugen:ma_qe",ma_qe);
01227 registry.Set("neugen:ma_res",ma_res);
01228 return;
01229 }
01230 else if (NuSyst::kNuMuBarXSecDISMultip2 == syst){
01231
01232
01233
01234
01235
01236
01237
01238
01239 Float_t kno132 = this->KNO132Default() + this->ShiftAsValue();
01240 if (kno132<0.0){kno132=0.0;}
01241 if (kno132>1.0){kno132=1.0;}
01242 Float_t kno142 = this->KNO142Default() + this->ShiftAsValue();
01243 if (kno142<0.0){kno142=0.0;}
01244 if (kno142>1.0){kno142=1.0;}
01245 registry.Set("neugen:kno_r132",kno132);
01246 registry.Set("neugen:kno_r142",kno142);
01247 }
01248 }
01249
01250
01251 const MCEventInfo NuSystematic
01252 ::CreateMCEventInfo(const NuEvent& nuEvent) const
01253 {
01254 MCEventInfo mcEvent;
01255
01256 mcEvent.nuE = nuEvent.neuEnMC;
01257 mcEvent.nuPx = nuEvent.neuPxMC;
01258 mcEvent.nuPy = nuEvent.neuPyMC;
01259 mcEvent.nuPz = nuEvent.neuPzMC;
01260 mcEvent.tarE = nuEvent.tgtEnMC;
01261 mcEvent.tarPx = nuEvent.tgtPxMC;
01262 mcEvent.tarPy = nuEvent.tgtPyMC;
01263 mcEvent.tarPz = nuEvent.tgtPzMC;
01264 mcEvent.y = nuEvent.yMC;
01265 mcEvent.x = nuEvent.xMC;
01266 mcEvent.q2 = nuEvent.q2MC;
01267 mcEvent.w2 = nuEvent.w2MC;
01268 mcEvent.iaction = nuEvent.iaction;
01269 mcEvent.inu = nuEvent.inu;
01270 mcEvent.iresonance = nuEvent.iresonance;
01271 mcEvent.initial_state = nuEvent.initialStateMC;
01272 mcEvent.nucleus = nuEvent.nucleusMC;
01273 mcEvent.had_fs = nuEvent.hadronicFinalStateMC;
01274
01275 return mcEvent;
01276 }
01277
01278
01279 void NuSystematic
01280 ::SetShiftedNeugenParameters(neugen_config& config) const
01281 {
01282 NuSyst::NuSystematic_t syst = this->SystematicID();
01283 if (NuSyst::kCombinedXSecCCMA == syst){
01284 Float_t ma_qe = this->MA_QEDefault() * this->ShiftAsValue();
01285 Float_t ma_res = this->MA_ResDefault() * this->ShiftAsValue();
01286 config.set_ma_qe(ma_qe);
01287 config.set_ma_res(ma_res);
01288 return;
01289 }
01290 else if (NuSyst::kCombinedXSecMaRes == syst){
01291 Float_t ma_res = this->MA_ResDefault() * this->ShiftAsValue();
01292 config.set_ma_res(ma_res);
01293 return;
01294 }
01295 else if (NuSyst::kCombinedXSecMaQE == syst){
01296 Float_t ma_qe = this->MA_QEDefault() * this->ShiftAsValue();
01297 config.set_ma_qe(ma_qe);
01298 return;
01299 }
01300 else if (NuSyst::kCombinedXSecDISMultip2 == syst){
01301 Float_t kno112 = this->KNO112Default() + this->ShiftAsValue();
01302 if (kno112<0.0){kno112=0.0;}
01303 if (kno112>1.0){kno112=1.0;}
01304 Float_t kno122 = this->KNO122Default() + this->ShiftAsValue();
01305 if (kno122<0.0){kno122=0.0;}
01306 if (kno122>1.0){kno122=1.0;}
01307 Float_t kno132 = this->KNO132Default() + this->ShiftAsValue();
01308 if (kno132<0.0){kno132=0.0;}
01309 if (kno132>1.0){kno132=1.0;}
01310 Float_t kno142 = this->KNO142Default() + this->ShiftAsValue();
01311 if (kno142<0.0){kno142=0.0;}
01312 if (kno142>1.0){kno142=1.0;}
01313 Float_t kno212 = this->KNO212Default() + this->ShiftAsValue();
01314 if (kno212<0.0){kno212=0.0;}
01315 if (kno212>1.0){kno212=1.0;}
01316 Float_t kno222 = this->KNO222Default() + this->ShiftAsValue();
01317 if (kno222<0.0){kno222=0.0;}
01318 if (kno222>1.0){kno222=1.0;}
01319 Float_t kno232 = this->KNO232Default() + this->ShiftAsValue();
01320 if (kno232<0.0){kno232=0.0;}
01321 if (kno232>1.0){kno232=1.0;}
01322 Float_t kno242 = this->KNO242Default() + this->ShiftAsValue();
01323 if (kno242<0.0){kno242=0.0;}
01324 if (kno242>1.0){kno242=1.0;}
01325 config.set_dis_res(1,2,e_vp,kno112);
01326 config.set_dis_res(1,2,e_vn,kno122);
01327 config.set_dis_res(1,2,e_vbp,kno132);
01328 config.set_dis_res(1,2,e_vbn,kno142);
01329 config.set_dis_res(2,2,e_vp,kno212);
01330 config.set_dis_res(2,2,e_vn,kno222);
01331 config.set_dis_res(2,2,e_vbp,kno232);
01332 config.set_dis_res(2,2,e_vbn,kno242);
01333 }
01334 else if (NuSyst::kCombinedXSecDISMultip3 == syst){
01335 Float_t kno113 = this->KNO113Default() + this->ShiftAsValue();
01336 if (kno113<0.0){kno113=0.0;}
01337 if (kno113>1.0){kno113=1.0;}
01338 Float_t kno123 = this->KNO123Default() + this->ShiftAsValue();
01339 if (kno123<0.0){kno123=0.0;}
01340 if (kno123>1.0){kno123=1.0;}
01341 Float_t kno133 = this->KNO133Default() + this->ShiftAsValue();
01342 if (kno133<0.0){kno133=0.0;}
01343 if (kno133>1.0){kno133=1.0;}
01344 Float_t kno143 = this->KNO143Default() + this->ShiftAsValue();
01345 if (kno143<0.0){kno143=0.0;}
01346 if (kno143>1.0){kno143=1.0;}
01347 Float_t kno213 = this->KNO213Default() + this->ShiftAsValue();
01348 if (kno213<0.0){kno213=0.0;}
01349 if (kno213>1.0){kno213=1.0;}
01350 Float_t kno223 = this->KNO223Default() + this->ShiftAsValue();
01351 if (kno223<0.0){kno223=0.0;}
01352 if (kno223>1.0){kno223=1.0;}
01353 Float_t kno233 = this->KNO233Default() + this->ShiftAsValue();
01354 if (kno233<0.0){kno233=0.0;}
01355 if (kno233>1.0){kno233=1.0;}
01356 Float_t kno243 = this->KNO243Default() + this->ShiftAsValue();
01357 if (kno243<0.0){kno243=0.0;}
01358 if (kno243>1.0){kno243=1.0;}
01359 config.set_dis_res(1,3,e_vp,kno113);
01360 config.set_dis_res(1,3,e_vn,kno123);
01361 config.set_dis_res(1,3,e_vbp,kno133);
01362 config.set_dis_res(1,3,e_vbn,kno143);
01363 config.set_dis_res(2,3,e_vp,kno213);
01364 config.set_dis_res(2,3,e_vn,kno223);
01365 config.set_dis_res(2,3,e_vbp,kno233);
01366 config.set_dis_res(2,3,e_vbn,kno243);
01367 }
01368 else if (NuSyst::kNuMuBarXSecCCMA == syst){
01369 Float_t ma_qe = this->MA_QEDefault() * this->ShiftAsValue();
01370 Float_t ma_res = this->MA_ResDefault() * this->ShiftAsValue();
01371 config.set_ma_qe(ma_qe);
01372 config.set_ma_res(ma_res);
01373 return;
01374 }
01375 else if (NuSyst::kNuMuBarXSecDISMultip2 == syst){
01376 Float_t kno132 = this->KNO132Default() + this->ShiftAsValue();
01377 if (kno132<0.0){kno132=0.0;}
01378 if (kno132>1.0){kno132=1.0;}
01379 Float_t kno142 = this->KNO142Default() + this->ShiftAsValue();
01380 if (kno142<0.0){kno142=0.0;}
01381 if (kno142>1.0){kno142=1.0;}
01382 config.set_dis_res(1,2,e_vbp,kno132);
01383 config.set_dis_res(1,2,e_vbn,kno142);
01384 }
01385 }
01386
01387
01388 const Double_t NuSystematic
01389 ::XSecShiftScale(const Double_t energy,
01390 const NuParticle::NuParticleType_t particle) const
01391 {
01392 if (!(NuParticle::kNuMu == particle || NuParticle::kNuMuBar == particle)){
01393 MSG("NuSystematic.cxx",Msg::kWarning)
01394 << "I don't know how to systematically shift this particle"
01395 << endl;
01396 return 1.0;
01397 }
01398
01399 if (NuSyst::kCombinedXSecOverall == this->SystematicID()){
01400 return this->ShiftAsValue();
01401 }
01402 else if (NuSyst::kNuMuBarXSecOverall == this->SystematicID()){
01403 if (NuParticle::kNuMuBar == particle){
01404 return this->ShiftAsValue();
01405 }
01406 else {
01407 return 1.0;
01408 }
01409 }
01410 else if (NuSyst::kNuMuBarXSecCCMA == this->SystematicID() ||
01411 NuSyst::kNuMuBarXSecDISMultip2 == this->SystematicID()){
01412 if (NuParticle::kNuMuBar != particle){
01413 return 1.0;
01414 }
01415 else {return this->NeugenXSecShiftScale(energy,particle);}
01416 }
01417 else if(NuSyst::kCombinedXSecCCMA == this->SystematicID() ||
01418 NuSyst::kCombinedXSecDISMultip2 == this->SystematicID() ||
01419 NuSyst::kCombinedXSecDISMultip3 == this->SystematicID()){
01420 if (!(NuParticle::kNuMu == particle || NuParticle::kNuMuBar == particle)){
01421 return 1.0;
01422 }
01423 else if(NuSyst::kNuMuBarXSecQEL == this->SystematicID()){
01424 return this->QELXSecShiftScale(energy,particle);
01425 }
01426 else if (NuSyst::kNuMuBarXSecRes == this->SystematicID()){
01427 return this->ResXSecShiftScale(energy,particle);
01428 }
01429 else {return this->NeugenXSecShiftScale(energy,particle);}
01430 }
01431 else {return 1.0;}
01432 }
01433
01434
01435 const Double_t NuSystematic
01436 ::QELXSecShiftScale(const Double_t energy,
01437 const NuParticle::NuParticleType_t particle)
01438 const
01439 {
01440 neugen_config defaultConfig;
01441 neugen_wrapper defaultWrapper(&defaultConfig);
01442 init_state_t inlStateP;
01443 init_state_t inlStateN;
01444 if (NuParticle::kNuMu == particle){
01445 inlStateP = e_vp;
01446 inlStateN = e_vn;
01447 }
01448 else if (NuParticle::kNuMuBar == particle){
01449 inlStateP = e_vbp;
01450 inlStateN = e_vbn;
01451 }
01452 else{
01453 MSG("NuSystematic.cxx",kWarning)
01454 << "Bad particle type for cross section shift."
01455 << endl;
01456 inlStateP = e_undefined_init_state;
01457 inlStateN = e_undefined_init_state;
01458 }
01459 interaction interP(e_mu,e_Fe56,e_cc,inlStateP);
01460 interaction interN(e_mu,e_Fe56,e_cc,inlStateP);
01461 Double_t defaultXSec = defaultWrapper.xsec(energy,&interP,0);
01462 defaultXSec += defaultWrapper.xsec(energy,&interN,0);
01463
01464 neugen_cuts cuts;
01465 cuts.setOneProcess(e_qel);
01466 Double_t qelXSec = defaultWrapper.xsec(energy,&interP,&cuts);
01467 qelXSec += defaultWrapper.xsec(energy,&interN,&cuts);
01468
01469 if (!defaultXSec){return 1.0;}
01470 return (defaultXSec + (this->ShiftAsValue() - 1.0)*qelXSec)/defaultXSec;
01471 }
01472
01473
01474 const Double_t NuSystematic
01475 ::ResXSecShiftScale(const Double_t energy,
01476 const NuParticle::NuParticleType_t particle)
01477 const
01478 {
01479 neugen_config defaultConfig;
01480 neugen_wrapper defaultWrapper(&defaultConfig);
01481 init_state_t inlStateP;
01482 init_state_t inlStateN;
01483 if (NuParticle::kNuMu == particle){
01484 inlStateP = e_vp;
01485 inlStateN = e_vn;
01486 }
01487 else if (NuParticle::kNuMuBar == particle){
01488 inlStateP = e_vbp;
01489 inlStateN = e_vbn;
01490 }
01491 else{
01492 MSG("NuSystematic.cxx",kWarning)
01493 << "Bad particle type for cross section shift."
01494 << endl;
01495 inlStateP = e_undefined_init_state;
01496 inlStateN = e_undefined_init_state;
01497 }
01498 interaction interP(e_mu,e_Fe56,e_cc,inlStateP);
01499 interaction interN(e_mu,e_Fe56,e_cc,inlStateP);
01500 Double_t defaultXSec = defaultWrapper.xsec(energy,&interP,0);
01501 defaultXSec += defaultWrapper.xsec(energy,&interN,0);
01502
01503 neugen_cuts cuts;
01504 cuts.setOneProcess(e_res);
01505 Double_t qelXSec = defaultWrapper.xsec(energy,&interP,&cuts);
01506 qelXSec += defaultWrapper.xsec(energy,&interN,&cuts);
01507
01508 if (!defaultXSec){return 1.0;}
01509 return (defaultXSec + (this->ShiftAsValue() - 1.0)*qelXSec)/defaultXSec;
01510 }
01511
01512
01513 const Double_t NuSystematic
01514 ::NeugenXSecShiftScale(const Double_t energy,
01515 const NuParticle::NuParticleType_t particle) const
01516 {
01517 neugen_config shiftedConfig;
01518 this->SetShiftedNeugenParameters(shiftedConfig);
01519 neugen_config defaultConfig;
01520 neugen_wrapper shiftedWrapper(&shiftedConfig);
01521 neugen_wrapper defaultWrapper(&defaultConfig);
01522 init_state_t inlStateP;
01523 init_state_t inlStateN;
01524 if (NuParticle::kNuMu == particle){
01525 inlStateP = e_vp;
01526 inlStateN = e_vn;
01527 }
01528 else if (NuParticle::kNuMuBar == particle){
01529 inlStateP = e_vbp;
01530 inlStateN = e_vbn;
01531 }
01532 else{
01533 MSG("NuSystematic.cxx",kWarning)
01534 << "Bad particle type for cross section shift."
01535 << endl;
01536 inlStateP = e_undefined_init_state;
01537 inlStateN = e_undefined_init_state;
01538 }
01539 interaction interP(e_mu,e_Fe56,e_cc,inlStateP);
01540 interaction interN(e_mu,e_Fe56,e_cc,inlStateP);
01541 Double_t defaultXSec = defaultWrapper.xsec(energy,&interP,0);
01542 defaultXSec += defaultWrapper.xsec(energy,&interN,0);
01543 Double_t shiftedXSec = shiftedWrapper.xsec(energy,&interP,0);
01544 shiftedXSec = shiftedWrapper.xsec(energy,&interN,0);
01545 if (defaultXSec){return shiftedXSec/defaultXSec;}
01546 else {return 0;}
01547 }
01548
01549