Prod4Loaders.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 Prod4LoadersBase::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  SetLoaderPaths(prefix+"_nonswap_"+suffix,
39  prefix+"_fluxswap_"+suffix);
40  else // set all three beam MC paths
41  SetLoaderPaths(prefix+"_nonswap_"+suffix,
42  prefix+"_fluxswap_"+suffix,
43  prefix+"_tau_"+suffix);
44  }
45 
46  //..........................................................................
48  {
49  SetLoaderPaths("", "", "", ndmc);
50  }
51 
52  //..........................................................................
54  {
55  const std::map<ECAFType, std::string> mapStringECAFType {
56  {ECAFType::kFullCAF, "caf"},
57  {ECAFType::kDecaf, "nue_or_numu_or_nus_contain"},
58  {ECAFType::kNueConcat, "nue2018"},
59  {ECAFType::kNumuConcat, "numu2018"},
60  {ECAFType::kNusConcat, "nus2018"}
61  };
62 
63  auto it = mapStringECAFType.find(type);
64  if(it == mapStringECAFType.end()) {
65  std::cout << "Unknown ECAFType " << type << std::endl;
66  std::cout << "Aborting..." << std::endl;
67  abort();
68  }
69  return it->second;
70  }
71 
72  //..........................................................................
74  EFlatness flat) const
75  {
76  // TODO - remove this logic once flatcafs are more widely available
77  if(flat == kFlatCAF){
78  if(type == kFullCAF){
79  std::cerr << "\nWARNING: FlatCAFs not available, using regular CAFs"
80  << std::endl << std::endl;
81  flat = kNormalCAF;
82  }
83  if(type == kDecaf){
84  std::cerr << "\nWARNING: FlatDecafs not available, using regular decafs"
85  << std::endl << std::endl;
86  flat = kNormalCAF;
87  }
88  }
89 
90 
92 
93  switch(type){
94  case ECAFType::kFullCAF: ret = "caf"; break;
95  case ECAFType::kDecaf: ret = "decaf"; break;
96  case ECAFType::kNueConcat: // fallthrough
97  case ECAFType::kNumuConcat: // fallthrough
98  case ECAFType::kNusConcat: ret = "sumdecaf"; break;
99  default:
100  std::cout << "Unknown ECAFType " << type << std::endl;
101  std::cout << "Aborting..." << std::endl;
102  abort();
103  }
104 
105  if(flat == kFlatCAF) return "flat"+ret; else return ret;
106  }
107 
108  //..........................................................................
110  FluxType flux,
111  std::string WhichPeriod,
112  std::string WhichNDPeriod,
113  EFlatness flat)
114  : cafType(ECAFTypeToString(type)),
115  dataTier(ECAFTypeFlatToTier(type, flat)),
116  fluxType(flux==kFHC? "fhc":"rhc")
117  {
118  std::string nddata = "";
119  const std::string ndrel = (flux==kFHC ? "f":"f"); // same at the moment,
120  // but could change
121 
122  // Some period/flux validation checks
123  // Only need to do these once --> in DataLoaders
124  const bool isRHCPeriod = (
125  (WhichNDPeriod == "period4") || (WhichPeriod == "period4") ||
126  (WhichNDPeriod == "epoch6a") || (WhichPeriod == "epoch6a") ||
127  (WhichNDPeriod == "epoch7a") || (WhichPeriod == "epoch7a"));
128 
129  const bool isFull = ((WhichNDPeriod == "full") || (WhichPeriod == "full"));
130 
131  if(flux == kFHC)
132  if(isRHCPeriod && !isFull) // Warn that it's not an FHC period
133  std::cerr << "\nWARNING: ND " << WhichNDPeriod << " and FD "
134  << WhichPeriod << " contains no FHC data" << std::endl << std::endl;
135  if(flux == kRHC)
136  {
137  if(!isRHCPeriod && !isFull) // Now warn that it's not an RHC period
138  std::cerr << "\nWARNING: ND " << WhichNDPeriod << " and FD "
139  << WhichPeriod << " contains no RHC data" << std::endl << std::endl;
140  if(isFull)
141  std::cerr << "\nWARNING: " << WhichPeriod
142  << " does not include RHC data in epoch7a" << std::endl << std::endl;
143  }
144 
145  // Concat definition
146  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
147  nddata = "prod_"+dataTier+"_R17-09-05-prod4recopreview." + ndrel +
148  "_nd_numi_" + fluxType + "_" + WhichNDPeriod +
149  "_v1_addShortSimpleCVN_goodruns_" + cafType;
150  // Decaf definition
151  if(type == kDecaf)
152  nddata = "prod_"+dataTier+"_R17-09-05-prod4recopreview." + ndrel +
153  "_nd_numi_" + fluxType + "_" + WhichNDPeriod + "_" +
154  cafType + "_v1_addShortSimpleCVN_goodruns";
155  // CAF definition
156  if(type == kFullCAF)
157  nddata = "prod_"+dataTier+"_R17-09-05-prod4recopreview." + ndrel +
158  "_nd_numi_" + fluxType + "_" + WhichNDPeriod +
159  "_v1_addShortSimpleCVN_goodruns";
160 
163  }
164 
165  //..........................................................................
167  FluxType flux,
168  std::string WhichPeriod,
169  std::string WhichNDPeriod,
170  EFlatness flat)
171  : Prod4DataLoaders(type, flux, WhichPeriod, WhichNDPeriod, flat)
172  {
173  const std::string rel = "c";
174  const std::string ndrel = "c";
175 
176  // Concats
177  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
178  {
179 
180  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
181  {
182  std::cerr << "\nWARNING: concats are only available for 'full' dataset"
183  << std::endl << std::endl;
185  "prod_"+dataTier+"_R17-11-14-prod4reco.neutron-respin." + rel +
186  "_fd_genie",
187  fluxType + "_nova_v08_" + WhichPeriod + "_v1_" + cafType);
189  "prod_"+dataTier+"_R17-11-14-prod4reco.neutron-respin." + ndrel +
190  "_nd_genie_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod +
191  "_v1_" + cafType);
192  }
193  }
194 
195  // Decafs
196  if(type == kDecaf)
197  {
198  std::cerr << "\nWARNING: decaf loaders not available, "
199  << "use full CAF or concats instead" << std::endl << std::endl;
200  abort();
201  }
202 
203  // Full CAFs
204  if(type == kFullCAF)
205  {
206  // Using neutron respin for all NDMC and FDMC
208  "prod_"+dataTier+"_R17-11-14-prod4reco.neutron-respin." + rel + "_fd_genie",
209  fluxType + "_nova_v08_" + WhichPeriod + "_v1");
211  "prod_"+dataTier+"_R17-11-14-prod4reco.neutron-respin." + ndrel +
212  "_nd_genie_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod + "_v1");
213  }
214  }
215 
216  //..........................................................................
218  FluxType flux,
219  int sign,
220  std::string WhichPeriod,
221  std::string WhichNDPeriod)
222  : Prod4DataLoaders(type, flux, WhichPeriod, WhichNDPeriod)
223  {
224  assert(abs(sign) == 1);
225 
226  const std::string rel = "f"; // assuming same for FHC/RHC
227  const std::string ndrel = "g"; // assuming same for FHC/RHC
228 
229  const std::string posneg = (sign > 0) ? "pos" : "neg";
230 
231  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
232  {
233  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
234  {
236  "prod_sumdecaf_R17-11-14-prod4reco." + rel + "_fd_genie",
237  fluxType + "_nova_v08_" + WhichPeriod + "_calib-shift-fd-xyview-" +
238  posneg + "-offset_v1_" + cafType);
240  "prod_sumdecaf_R17-11-14-prod4reco." + ndrel + "_nd_genie_nonswap_" +
241  fluxType + "_nova_v08_" + WhichNDPeriod + "_calib-shift-nd-xyview-" +
242  posneg + "-offset_v1_" + cafType);
243  }
244  }
245 
246  if(type == kDecaf)
247  {
248  std::cerr << "\nWARNING: decaf loaders not available, "
249  << "use full CAF or concats instead" << std::endl << std::endl;
250  abort();
251  }
252 
253  if(type == kFullCAF)
254  {
256  "prod_caf_R17-11-14-prod4reco." + rel + "_fd_genie",
257  fluxType + "_nova_v08_" + WhichPeriod + "_calib-shift-fd-xyview-" +
258  posneg + "-offset_v1");
260  "prod_caf_R17-11-14-prod4reco." + ndrel + "_nd_genie_nonswap_" +
261  fluxType + "_nova_v08_" + WhichNDPeriod + "_calib-shift-nd-xyview-" +
262  posneg + "-offset_v1");
263  }
264  }
265 
266  //..........................................................................
268  FluxType flux,
269  int sign,
270  std::string WhichPeriod,
271  std::string WhichNDPeriod)
272  : Prod4DataLoaders(type, flux, WhichPeriod, WhichNDPeriod)
273  {
274  assert((abs(sign) == 1) || (sign == 0));
275 
276  const std::string rel = (sign == 0) ? "i":"g"; // assuming same for FHC/RHC
277  const std::string ndrel = "g"; // assuming same for FHC/RHC
278 
279  std::string updown;
280  if(sign == 1) updown = "lightup-calibdown";
281  else if (sign == -1) updown = "lightdown-calibup";
282  // We do still need noshift for light level in prod4
283  else if (sign == 0) updown = "noshift";
284 
285  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
286  {
287  if (sign == 0)
288  {
289  // TODO: remove this when the definitions are available
290  std::cerr << "\nWARNING: concats not available for noshift sample yet "
291  << "---> use full CAFs" << std::endl << std::endl;
292  }
293  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
294  {
296  "prod_sumdecaf_R17-11-14-prod4reco." + rel + "_fd_genie",
297  fluxType + "_nova_v08_" + WhichPeriod + "_lightmodel-" +
298  updown + "_v1_" + cafType);
299  if (abs(sign) == 1) // noshift is for FD only
301  "prod_sumdecaf_R17-11-14-prod4reco." + ndrel +
302  "_nd_genie_nonswap_" + fluxType + "_nova_v08_" + WhichNDPeriod +
303  "_lightmodel-" + updown + "_v1_" + cafType);
304  else
305  std::cerr << "\nWARNING: skipping NDMC loader for LightLevelNom"
306  << std::endl << std::endl;
307  }
308  }
309 
310  if(type == kDecaf)
311  {
312  std::cerr << "\nWARNING: decaf loaders not available, "
313  << "use full CAF or concats instead" << std::endl << std::endl;
314  abort();
315  }
316 
317  if(type == kFullCAF)
318  {
320  "prod_caf_R17-11-14-prod4reco." + rel + "_fd_genie",
321  fluxType + "_nova_v08_" + WhichPeriod + "_lightmodel-" + updown +
322  "_v1");
323  if (abs(sign) == 1) // noshift is for FD only
325  "prod_caf_R17-11-14-prod4reco." + ndrel + "_nd_genie_nonswap_" +
326  fluxType + "_nova_v08_" + WhichNDPeriod + "_lightmodel-" + updown +
327  "_v1");
328  else
329  std::cerr << "\nWARNING: skipping NDMC loader for LightLevelNom"
330  << std::endl << std::endl;
331  }
332  }
333 
334  //..........................................................................
336  FluxType flux,
337  std::string WhichPeriod,
338  std::string WhichNDPeriod)
339  : Prod4DataLoaders(type, flux, WhichPeriod, WhichNDPeriod)
340  {
341  const std::string rel = "g"; // assuming same for FHC/RHC
342  const std::string ndrel = "g"; // assuming same for FHC/RHC
343 
344 
345  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
346  {
347  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
348  {
350  "prod_sumdecaf_R17-11-14-prod4reco." + rel + "_fd_genie",
351  fluxType + "_nova_v08_" + WhichPeriod +
352  "_ckv-proton-shift-down_v1_" + cafType);
354  "prod_sumdecaf_R17-11-14-prod4reco." + ndrel + "_nd_genie_nonswap_" +
355  fluxType + "_nova_v08_" + WhichNDPeriod +
356  "_ckv-proton-shift-down_v1_" + cafType);
357  }
358  }
359 
360  if(type == kDecaf)
361  {
362  std::cerr << "\nWARNING: decaf loaders not available, "
363  << "use full CAF or concats instead" << std::endl << std::endl;
364  abort();
365  }
366 
367  if(type == kFullCAF)
368  {
370  "prod_caf_R17-11-14-prod4reco." + rel + "_fd_genie",
371  fluxType + "_nova_v08_" + WhichPeriod + "_ckv-proton-shift-down_v2");
373  "prod_caf_R17-11-14-prod4reco." + ndrel+ "_nd_genie_nonswap_" +
374  fluxType + "_nova_v08_" + WhichNDPeriod + "_ckv-proton-shift-down_v1");
375  }
376  }
377 
378  //..........................................................................
380  FluxType flux,
381  std::string WhichPeriod,
382  std::string WhichNDPeriod)
383  : Prod4DataLoaders(type, flux, WhichPeriod, WhichNDPeriod)
384  {
385  const std::string rel = "f"; // assuming same for FHC/RHC
386  const std::string ndrel = "g"; // assuming same for FHC/RHC
387 
388  if(type == kNueConcat || type == kNumuConcat || type == kNusConcat)
389  {
390  if(WhichPeriod == "full" && WhichNDPeriod == "full") // only "full"
391  {
393  "prod_sumdecaf_R17-11-14-prod4reco." + rel + "_fd_genie",
394  fluxType + "_nova_v08_" + WhichPeriod +
395  "_calib-shift-fd-func_v1_" + cafType);
397  "prod_sumdecaf_R17-11-14-prod4reco." + ndrel + "_nd_genie_nonswap_" +
398  fluxType + "_nova_v08_" + WhichNDPeriod + "_calib-shift-nd-func_v1_" +
399  cafType);
400  }
401  }
402 
403  if(type == kDecaf)
404  {
405  std::cerr << "\nWARNING: decaf loaders not available, "
406  << "use full CAF or concats instead" << std::endl << std::endl;
407  abort();
408  }
409 
410  if(type == kFullCAF)
411  {
413  "prod_caf_R17-11-14-prod4reco." + rel + "_fd_genie",
414  fluxType + "_nova_v08_" + WhichPeriod + "_calib-shift-fd-func_v1");
416  "prod_caf_R17-11-14-prod4reco." + ndrel + "_nd_genie_nonswap_" +
417  fluxType + "_nova_v08_" + WhichNDPeriod + "_calib-shift-nd-func_v1");
418  }
419  }
420 
421 } // namespace
Near Detector underground.
Definition: SREnums.h:10
Prod4CherenkovLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full")
void SetLoaderNDMCPath(const std::string &ndmc)
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
const std::string cafType
Definition: Prod4Loaders.h:88
EFlatness
Definition: Loaders.h:20
Prod4LightLevelLoaders(ECAFType type, FluxType flux, int sign, std::string WhichPeriod="full", std::string WhichNDPeriod="full")
OStream cerr
Definition: OStream.cxx:7
void abs(TH1 *hist)
Prod4NomLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
const std::string fluxType
Definition: Prod4Loaders.h:91
Loaders::FluxType flux
string rel
Definition: shutoffs.py:11
Prod4AbsCalibLoaders(ECAFType type, FluxType flux, int sign, std::string WhichPeriod="full", std::string WhichNDPeriod="full")
const XML_Char * prefix
Definition: expat.h:380
const std::string ECAFTypeToString(ECAFType type)
OStream cout
Definition: OStream.cxx:6
std::string ECAFTypeFlatToTier(ECAFType type, EFlatness flat) const
assert(nhit_max >=nhit_nbins)
Provide the data loaders only, base class for other loaders.
Definition: Prod4Loaders.h:65
const std::string dataTier
from "caf" to "flatsumdecaf"
Definition: Prod4Loaders.h:90
Prod4CalibShapeLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full")
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: Prod4Loaders.cxx:9
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
Prod4DataLoaders(ECAFType type, FluxType flux, std::string WhichPeriod="full", std::string WhichNDPeriod="full", EFlatness flat=kNormalCAF)
void SetLoaderFDMCPaths(const std::string &prefix, const std::string &suffix, const bool noTau=false)
def sign(x)
Definition: canMan.py:197
ECAFType
Definition: Loaders.h:19
enum BeamMode string