Prod5Loaders.cxx
Go to the documentation of this file.
1 #include "CAFAna/Analysis/Prod3Loaders.h" // ECAFType
3 
4 #include <iostream>
5 
6 namespace ana
7 {
8  //..........................................................................
9  void Prod5LoadersBase::SetLoaderPaths(const std::string& fdmc_nonswap,
10  const std::string& fdmc_fluxswap,
11  const std::string& fdmc_tauswap,
12  const std::string& ndmc,
13  const std::string& nddata)
14  {
15  if(!fdmc_nonswap.empty())
16  SetLoaderPath(fdmc_nonswap, caf::kFARDET,
18  if(!fdmc_fluxswap.empty())
19  SetLoaderPath(fdmc_fluxswap, caf::kFARDET,
21  if(!fdmc_tauswap.empty())
22  SetLoaderPath(fdmc_tauswap, caf::kFARDET,
24  if(!ndmc.empty())
27  if(!nddata.empty())
30  }
31 
32  //..........................................................................
34  const std::string& suffix,
35  const bool noTau)
36  {
37  if(noTau) // don't set tau path
38  // the previous way with "_" was rather confusing
39  SetLoaderPaths(prefix+"nonswap_"+suffix,
40  prefix+"fluxswap_"+suffix);
41  else // set all three beam MC paths
42  SetLoaderPaths(prefix+"nonswap_"+suffix,
43  prefix+"fluxswap_"+suffix,
44  prefix+"tau_"+suffix);
45  }
46 
47  //..........................................................................
49  {
50  SetLoaderPaths("", "", "", ndmc);
51  }
52 
53  //..........................................................................
55  {
56  const std::map<ECAFType, std::string> mapStringECAFType {
57  {ECAFType::kFullCAF, "caf"},
58  {ECAFType::kDecaf, "nue_or_numu_or_nus_contain"},
59  {ECAFType::kNueConcat, "nue2020"},
60  {ECAFType::kNumuConcat, "numu2020"},
61  {ECAFType::kNusConcat, "nus2020"}
62  };
63 
64  auto it = mapStringECAFType.find(type);
65  if(it == mapStringECAFType.end()) {
66  std::cout << "Unknown ECAFType " << type << std::endl;
67  std::cout << "Aborting..." << std::endl;
68  abort();
69  }
70  return it->second;
71  }
72 
73  //..........................................................................
76  bool flatCAFsExist) const
77  {
78  if(flat == kFlatCAF && !flatCAFsExist){
79  std::cout << "\nWARNING: FlatCAFs not available (yet) for " << GetSystString() << ", falling back to regular CAFs.\nIf they are in fact now available, please change the appropriate 'false' to 'true' in Prod5Loaders.cxx and commit." << std::endl;
80  flat = kNormalCAF;
81  }
82 
83  // TODO - remove this logic once flatcafs are more widely available
84  if(flat == kFlatCAF){
85  if(type == kFullCAF){
86  std::cerr << "\nWARNING: FlatCAFs not available, using regular CAFs"
87  << std::endl << std::endl;
88  flat = kNormalCAF;
89  }
90  if(type == kDecaf){
91  std::cerr << "\nWARNING: FlatDecafs not available, using regular decafs"
92  << std::endl << std::endl;
93  flat = kNormalCAF;
94  }
95  }
96 
97 
99 
100  switch(type){
101  case ECAFType::kFullCAF: ret = "caf"; break;
102  case ECAFType::kDecaf: ret = "decaf"; break;
103  case ECAFType::kNueConcat: // fallthrough
104  case ECAFType::kNumuConcat: // fallthrough
105  case ECAFType::kNusConcat: ret = "sumdecaf"; break;
106  default:
107  std::cout << "Unknown ECAFType " << type << std::endl;
108  std::cout << "Aborting..." << std::endl;
109  abort();
110  }
111 
112  if(flat == kFlatCAF) return "flat"+ret; else return ret;
113  }
114 
115  //..........................................................................
117  FluxType flux,
118  std::string WhichPeriod,
119  std::string WhichNDPeriod,
120  EFlatness flat)
121  : cafType(ECAFTypeToString(type)),
122  dataTier(ECAFTypeFlatToTier(type, flat, true)),
123  fluxType(flux==kFHC? "fhc":"rhc")
124  {
125  std::string nddata = "";
126  const bool isFull = ((WhichNDPeriod == "full") && (WhichPeriod == "full"));
127 
128  std::string ndrel = (flux == kFHC) ? "d.f.h.l":"g"; // could change
129 
130  if(type == kFullCAF)
131  {
132  if(flux == kFHC && !(WhichNDPeriod == "full"))
133  {
134  if(WhichNDPeriod == "period1")
135  ndrel = "l";
136  else if((WhichNDPeriod == "period9") || (WhichNDPeriod == "period10"))
137  ndrel = "h";
138  else
139  ndrel = "d.f";
140  }
141  }
142 
143  // Some period/flux validation checks
144  // Only need to do these once --> in DataLoaders
145  const bool isRHCPeriod = (
146  (WhichNDPeriod == "period4") || (WhichPeriod == "period4") ||
147  (WhichNDPeriod == "period6") || (WhichPeriod == "period6") ||
148  (WhichNDPeriod == "period7") || (WhichPeriod == "period7") ||
149  (WhichNDPeriod == "period8") || (WhichPeriod == "period8"));
150 
151  if(flux == kFHC)
152  if(isRHCPeriod && !isFull) // Warn that it's not an FHC period
153  std::cerr << "\nWARNING: ND " << WhichNDPeriod << " and FD "
154  << WhichPeriod << " contains no FHC data" << std::endl << std::endl;
155  if(flux == kRHC)
156  {
157  if(!isRHCPeriod && !isFull) // Now warn that it's not an RHC period
158  std::cerr << "\nWARNING: ND " << WhichNDPeriod << " and FD "
159  << WhichPeriod << " contains no RHC data" << std::endl << std::endl;
160  }
161 
162  // Concat definition
163  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
164  {
165  nddata = "prod_"+dataTier+"_R19-11-18-prod5reco." + ndrel +
166  "_nd_numi_" + fluxType + "_" + WhichNDPeriod +
167  "_v1_goodruns_" + cafType;
168 
169  if(!isFull)
170  {
171  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
172  abort();
173  }
174  }
175  // Decaf definition
176  if(type == kDecaf)
177  {
178  nddata = "prod_"+dataTier+"_R19-11-18-prod5reco." + ndrel +
179  "_nd_numi_" + fluxType + "_" + WhichNDPeriod + "_" +
180  cafType + "_v1_goodruns";
181 
182  std::cerr << "\nWARNING: " << cafType << " of definition " << nddata << " not available yet" << std::endl << std::endl;
183  }
184  // CAF definition
185  if(type == kFullCAF)
186  {
187  nddata = "prod_"+dataTier+"_R19-11-18-prod5reco." + ndrel +
188  "_nd_numi_" + fluxType + "_" + WhichNDPeriod +
189  "_v1";
190 
191  if(!(WhichNDPeriod == "period10"))
192  nddata += "_goodruns"; // period 10 does not have a goodruns definition
193  }
194 
197  }
198 
199  //..........................................................................
201  FluxType flux,
202  std::string WhichPeriod,
203  std::string WhichNDPeriod,
204  EFlatness flat)
205  : Prod5DataLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
206  {
207  const std::string rel = "f";
208  std::string ndrel = (flux==kFHC) ? "d.h.l":"d";
209 
210  if(flux == kFHC && !(WhichNDPeriod == "full"))
211  ndrel = (WhichNDPeriod=="period5") ? "l":"d";
212 
213  // Concats
214  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
215  {
216  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
217  {
219  "prod_"+dataTier+"_R19-11-18-prod5reco." + rel +
220  "_fd_genie_N1810j0211a_",
221  fluxType + "_nova_v08_" + WhichPeriod + "_v1_" + cafType);
223  "prod_"+dataTier+"_R19-11-18-prod5reco." + ndrel +
224  "_nd_genie_N1810j0211a_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod +
225  "_v1_" + cafType);
226  }
227  else
228  {
229  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
230  abort();
231  }
232  }
233 
234  // Decafs
235  if(type == kDecaf)
236  {
237  std::cerr << "\nWARNING: decaf loaders not available, "
238  << "use full CAF instead" << std::endl << std::endl;
239  abort();
240  }
241 
242  // Full CAFs
243  if(type == kFullCAF)
244  {
246  "prod_"+dataTier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
247  fluxType + "_nova_v08_" + WhichPeriod + "_v1");
249  "prod_"+dataTier+"_R19-11-18-prod5reco." + ndrel +
250  "_nd_genie_N1810j0211a_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod + "_v1");
251  }
252  }
253 
254  //..........................................................................
256  FluxType flux,
257  int sign,
258  std::string WhichPeriod,
259  std::string WhichNDPeriod,
260  EFlatness flat)
261  : Prod5NomLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
262  {
263  assert(abs(sign) == 1);
264 
265  const bool isFull = ((WhichNDPeriod == "full") && (WhichPeriod == "full"));
266  if(!isFull)
267  {
268  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
269  abort();
270  }
271 
272  const std::string rel = "l"; // assuming same for FHC/RHC
273  const std::string ndrel = "l"; // assuming same for FHC/RHC
274 
275  const std::string updown = (sign > 0) ? "calibup" : "calibdown";
276 
277  std::string ndsuffix = "";
278  if(flux == kFHC)
279  ndsuffix = "_prod5";
280 
281  const std::string tier = ECAFTypeFlatToTier(type, flat, false);
282 
283  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
284  {
285  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
286  {
288  "prod_" + tier + "_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
289  fluxType + "_nova_v08_" + WhichPeriod + "_" +
290  updown + "_v1_" + cafType, true);
292  "prod_" + tier + "_R19-11-18-prod5reco." + ndrel +
293  "_nd_genie_N1810j0211a_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod +
294  "_" + updown + "_v1" + ndsuffix + "_" + cafType);
295  }
296  }
297 
298  if(type == kDecaf)
299  {
300  std::cerr << "\nWARNING: decaf loaders not available, "
301  << "use full CAF instead" << std::endl << std::endl;
302  abort();
303  }
304 
305  if(type == kFullCAF)
306  {
308  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
309  fluxType + "_nova_v08_" + WhichPeriod + "_" + updown + "_v1",
310  true);
312  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
313  fluxType + "_nova_v08_" + WhichNDPeriod + "_" + updown + "_v1" + ndsuffix);
314  }
315  }
316 
317  //..........................................................................
319  FluxType flux,
320  int sign,
321  std::string WhichPeriod,
322  std::string WhichNDPeriod,
323  EFlatness flat)
324  : Prod5NomLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
325  {
326  assert((abs(sign) == 1));
327 
328  const bool isFull = ((WhichNDPeriod == "full") && (WhichPeriod == "full"));
329  if(!isFull)
330  {
331  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
332  abort();
333  }
334 
335  const std::string rel = "j"; // assuming same for FHC/RHC
336  const std::string ndrel = (flux == kFHC) ? "j.l":"j"; // assuming same for FHC/RHC
337 
338  const std::string updown = (sign == 1) ? "llup" : "lldown";
339 
340  const std::string tier = ECAFTypeFlatToTier(type, flat, false);
341 
342  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
343  {
345  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
346  fluxType + "_nova_v08_" + WhichPeriod + "_" +
347  updown + "_v1_" + cafType, true);
349  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel +
350  "_nd_genie_N1810j0211a_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod +
351  "_" + updown + "_v1_" + cafType);
352  }
353 
354  if(type == kDecaf)
355  {
356  std::cerr << "\nWARNING: decaf loaders not available, "
357  << "use full CAF instead" << std::endl << std::endl;
358  abort();
359  }
360 
361  if(type == kFullCAF)
362  {
364  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
365  fluxType + "_nova_v08_" + WhichPeriod + "_" + updown + "_v1",
366  true);
368  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
369  fluxType + "_nova_v08_" + WhichNDPeriod + "_" + updown + "_v1");
370  }
371  }
372 
373  //..........................................................................
375  FluxType flux,
376  std::string WhichPeriod,
377  std::string WhichNDPeriod,
378  EFlatness flat)
379  : Prod5NomLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
380  {
381  const bool isFull = ((WhichNDPeriod == "full") && (WhichPeriod == "full"));
382  if(!isFull)
383  {
384  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
385  abort();
386  }
387 
388  const std::string rel = "j"; // assuming same for FHC/RHC
389  const std::string ndrel = (flux == kFHC) ? "j.l":"j";; // assuming same for FHC/RHC
390 
391  const std::string tier = ECAFTypeFlatToTier(type, flat, false);
392 
393  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
394  {
396  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
397  fluxType + "_nova_v08_" + WhichPeriod +
398  "_cherenkov_v1_" + cafType, true);
400  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
401  fluxType + "_nova_v08_" + WhichNDPeriod +
402  "_cherenkov_v1_" + cafType);
403  }
404 
405  if(type == kDecaf)
406  {
407  std::cerr << "\nWARNING: decaf loaders not available, "
408  << "use full CAF instead" << std::endl << std::endl;
409  abort();
410  }
411 
412  if(type == kFullCAF)
413  {
415  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
416  fluxType + "_nova_v08_" + WhichPeriod + "_cherenkov_v1",
417  true);
419  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel+ "_nd_genie_N1810j0211a_nonswap_" +
420  fluxType + "_nova_v08_" + WhichNDPeriod + "_cherenkov_v1");
421  }
422  }
423 
424  //..........................................................................
426  FluxType flux,
427  std::string WhichPeriod,
428  std::string WhichNDPeriod,
429  EFlatness flat)
430  : Prod5NomLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
431  {
432  const bool isFull = ((WhichNDPeriod == "full") && (WhichPeriod == "full"));
433  if(!isFull)
434  {
435  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
436  abort();
437  }
438 
439  const std::string rel = "m"; // assuming same for FHC/RHC
440  const std::string ndrel = "m"; // assuming same for FHC/RHC
441 
442  std::string ndsuffix = "";
443  if(flux == kFHC)
444  ndsuffix = "_prod5";
445 
446  const std::string tier = ECAFTypeFlatToTier(type, flat, false);
447 
448  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
449  {
450  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
451  {
453  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
454  fluxType + "_nova_v08_" + WhichPeriod + "_calibshape_v1_" + cafType, true);
456  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
457  fluxType + "_nova_v08_" + WhichNDPeriod +
458  "_calibshape_v1" + ndsuffix + "_" + cafType);
459  }
460  }
461 
462  if(type == kDecaf)
463  {
464  std::cerr << "\nWARNING: decaf loaders not available, "
465  << "use full CAF or concats instead" << std::endl << std::endl;
466  abort();
467  }
468 
469  if(type == kFullCAF)
470  {
472  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
473  fluxType + "_nova_v08_" + WhichPeriod + "_calibshape_v1",
474  true);
476  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
477  fluxType + "_nova_v08_" + WhichNDPeriod + "_calibshape_v1");
478  }
479  }
480 
482  FluxType flux,
483  std::string WhichPeriod,
484  std::string WhichNDPeriod,
485  EFlatness flat)
486  : Prod5NomLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
487  {
488  const bool isFull = ((WhichNDPeriod == "full") && (WhichPeriod == "full"));
489  if(!isFull)
490  {
491  std::cerr << "\nWARNING: loaders not available for individual periods, only full sample" << std::endl << std::endl;
492  abort();
493  }
494 
495  const std::string rel = "m"; // assuming same for FHC/RHC
496  const std::string ndrel = "m"; // assuming same for FHC/RHC
497 
498  const std::string tier = ECAFTypeFlatToTier(type, flat, false);
499 
500  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
501  {
502  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
503  {
505  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
506  fluxType + "_nova_v08_" + WhichPeriod + "_detectoraging_v1_" + cafType, true);
508  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
509  fluxType + "_nova_v08_" + WhichNDPeriod +
510  "_detectoraging_v1_" + cafType);
511  }
512  }
513 
514  if(type == kDecaf)
515  {
516  std::cerr << "\nWARNING: decaf loaders not available, "
517  << "use full CAF or concats instead" << std::endl << std::endl;
518  abort();
519  }
520 
521  if(type == kFullCAF)
522  {
524  "prod_"+tier+"_R19-11-18-prod5reco." + rel + "_fd_genie_N1810j0211a_",
525  fluxType + "_nova_v08_" + WhichPeriod + "_detectoraging_v1",
526  true);
528  "prod_"+tier+"_R19-11-18-prod5reco." + ndrel + "_nd_genie_N1810j0211a_nonswap_" +
529  fluxType + "_nova_v08_" + WhichNDPeriod + "_detectoraging_v1");
530  }
531  }
532 
533 } // namespace
Near Detector underground.
Definition: SREnums.h:10
Prod5DataLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
const std::string ECAFTypeToString(ECAFType type)
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
set< int >::iterator it
void SetLoaderNDMCPath(const std::string &ndmc)
std::string ECAFTypeFlatToTier(ECAFType type, EFlatness flat, bool flatCAFsExist) const
EFlatness
Definition: Loaders.h:20
OStream cerr
Definition: OStream.cxx:7
void abs(TH1 *hist)
void SetLoaderFDMCPaths(const std::string &prefix, const std::string &suffix, const bool noTau=false)
Provide the data loaders only, base class for other loaders.
Definition: Prod5Loaders.h:72
Loaders::FluxType flux
Prod5CherenkovLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
const std::string dataTier
from "caf" to "flatsumdecaf"
Definition: Prod5Loaders.h:95
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod5Loaders.h:101
Prod5CalibDriftLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
Prod5CalibShapeLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
string rel
Definition: shutoffs.py:11
const XML_Char * prefix
Definition: expat.h:380
void SetLoaderPaths(const std::string &fdmc_nonswap, const std::string &fdmc_fluxswap, const std::string &fdmc_tauswap="", const std::string &ndmc="", const std::string &nddata="")
Definition: Prod5Loaders.cxx:9
OStream cout
Definition: OStream.cxx:6
Prod5LightLevelLoaders(ECAFType type, FluxType flux, int sign, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
virtual std::string GetSystString() const =0
const std::string cafType
Definition: Prod5Loaders.h:93
Prod5AbsCalibLoaders(ECAFType type, FluxType flux, int sign, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
assert(nhit_max >=nhit_nbins)
const std::string fluxType
Definition: Prod5Loaders.h:96
void SetLoaderPath(const std::string &path, caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Configure loader via wildcard path.
Definition: Loaders.cxx:25
def sign(x)
Definition: canMan.py:197
Prod5NomLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
ECAFType
Definition: Loaders.h:19
enum BeamMode string