All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ana::MultiExperimentSBN Class Reference

Combine multiple component experiments. More...

#include <MultiExperimentSBN.h>

Inheritance diagram for ana::MultiExperimentSBN:
ana::IExperiment

Public Member Functions

 MultiExperimentSBN (std::vector< const IExperiment * > expts={}, std::vector< int > exptnames={})
 
void Add (const IExperiment *expt, float l)
 
virtual double ChiSq (osc::IOscCalcAdjustable *osc, const SystShifts &syst=SystShifts::Nominal()) const override
 
void SetSystCorrelations (int idx, const std::vector< std::pair< const ISyst *, const ISyst * >> &corrs)
 
virtual void SaveTo (TDirectory *dir) const override
 
- Public Member Functions inherited from ana::IExperiment
virtual ~IExperiment ()
 

Static Public Member Functions

static std::unique_ptr
< MultiExperimentSBN
LoadFrom (TDirectory *dir)
 

Protected Attributes

std::vector< const IExperiment * > fExpts
 
std::vector< int > fExptNames
 
std::vector< std::vector
< std::pair< const ISyst
*, const ISyst * > > > 
fSystCorrelations
 

Detailed Description

Combine multiple component experiments.

Definition at line 13 of file MultiExperimentSBN.h.

Constructor & Destructor Documentation

ana::MultiExperimentSBN::MultiExperimentSBN ( std::vector< const IExperiment * >  expts = {},
std::vector< int >  exptnames = {} 
)
inline

Definition at line 19 of file MultiExperimentSBN.h.

19  {},
20  std::vector<int> exptnames = {})
21  : fExpts(expts), fExptNames(exptnames)
22  {
23  fSystCorrelations.resize(expts.size());
24  }
std::vector< std::vector< std::pair< const ISyst *, const ISyst * > > > fSystCorrelations
std::vector< const IExperiment * > fExpts
std::vector< int > fExptNames

Member Function Documentation

void ana::MultiExperimentSBN::Add ( const IExperiment expt,
float  l 
)
inline

Definition at line 26 of file MultiExperimentSBN.h.

26  {
27  fExpts.push_back(expt);
28  fExptNames.push_back(l);
29  }
std::vector< const IExperiment * > fExpts
std::vector< int > fExptNames
double ana::MultiExperimentSBN::ChiSq ( osc::IOscCalcAdjustable osc,
const SystShifts syst = SystShifts::Nominal() 
) const
overridevirtual

Implements ana::IExperiment.

Definition at line 13 of file MultiExperimentSBN.cxx.

15  {
16  assert(fExpts.size() == fExptNames.size());
17 
18  double ret = 0;
19 
20  for(unsigned int n = 0; n < fExpts.size(); ++n){
21  // Set baseline for each of the experiments
22  osc->SetL(kBLs[fExptNames[n]]);
23 
24  // Don't waste time fiddling with the systematics if for sure there's
25  // nothing to do.
26  if(fSystCorrelations[n].empty()){
27  ret += fExpts[n]->ChiSq(osc, syst);
28  }
29  else{
30  // Make a local copy we're going to rewrite into the terms this
31  // sub-experiment will accept.
32  SystShifts localShifts = syst;
33  for(auto it: fSystCorrelations[n]){
34  // We're mapping prim -> sec
35  const ISyst* prim = it.first;
36  const ISyst* sec = it.second;
37  if(syst.GetShift(prim) != 0){
38  // sec can be unset, which means there's no representation needed
39  // of prim in the sub-experiment.
40  if(sec) localShifts.SetShift(sec, syst.GetShift(prim));
41  // We've either translated or discarded prim, so drop it here.
42  localShifts.SetShift(prim, 0);
43  }
44  }
45  ret += fExpts[n]->ChiSq(osc, localShifts);
46  }
47  }
48  return ret;
49  }
std::vector< std::vector< std::pair< const ISyst *, const ISyst * > > > fSystCorrelations
std::vector< const IExperiment * > fExpts
std::vector< int > fExptNames
const std::vector< double > kBLs
Definition: ExpInfo.h:14
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
std::unique_ptr< MultiExperimentSBN > ana::MultiExperimentSBN::LoadFrom ( TDirectory *  dir)
static

Definition at line 103 of file MultiExperimentSBN.cxx.

104  {
105  TObjString* ptag = (TObjString*)dir->Get("type");
106  assert(ptag);
107  assert(ptag->GetString() == "MultiExperimentSBN");
108 
109  std::vector<const IExperiment*> expts;
110 
111  for(int i = 0; ; ++i){
112  TDirectory* subdir = dir->GetDirectory(TString::Format("expt%d", i));
113  if(!subdir) break;
114 
115  expts.push_back(ana::LoadFrom<IExperiment>(subdir).release());
116  }
117 
118  assert(!expts.empty());
119 
120  return std::unique_ptr<MultiExperimentSBN>(new MultiExperimentSBN(expts));
121  }
MultiExperimentSBN(std::vector< const IExperiment * > expts={}, std::vector< int > exptnames={})
tuple dir
Definition: dropbox.py:28
std::unique_ptr< IExperiment > LoadFrom< IExperiment >(TDirectory *dir)
Definition: IExperiment.cxx:22
void ana::MultiExperimentSBN::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::IExperiment.

Definition at line 81 of file MultiExperimentSBN.cxx.

82  {
83  bool hasCorr = false;
84  for(auto it: fSystCorrelations) if(!it.empty()) hasCorr = true;
85 
86  if(hasCorr){
87  std::cerr << "Warning in MultiExperimentSBN: systematic correlations are set and will not be serialized by this call to SaveTo(). You will have to re-set them once you load the experiment back in." << std::endl;
88  }
89 
90  TDirectory* tmp = dir;
91 
92  dir->cd();
93  TObjString("MultiExperimentSBN").Write("type");
94 
95  for(unsigned int i = 0; i < fExpts.size(); ++i){
96  fExpts[i]->SaveTo(dir->mkdir(TString::Format("expt%d", i)));
97  }
98 
99  tmp->cd();
100  }
BEGIN_PROLOG could also be cerr
std::vector< std::vector< std::pair< const ISyst *, const ISyst * > > > fSystCorrelations
std::vector< const IExperiment * > fExpts
tuple dir
Definition: dropbox.py:28
void ana::MultiExperimentSBN::SetSystCorrelations ( int  idx,
const std::vector< std::pair< const ISyst *, const ISyst * >> &  corrs 
)

For the subexperiment idx, set up a mapping between systematics

Each element in the vector is a pair from a "primary" systematic to a "secondary". When this MultiExperiment is called with a primary systematic shifted, the sub-experiment will be called with the secondary systematic set to the same value (and the primary unset).

You can pass NULL for a secondary to indicate that the systematic simply has no effect on the experiment in question and should be filtered out.

Definition at line 53 of file MultiExperimentSBN.cxx.

55  {
56  // Sanity-check the mapping
57  std::map<const ISyst*, const ISyst*> already;
58  for(auto it: corrs){
59  assert(it.first != it.second);
60 
61  // Don't worry if second element is null pointer
62  if (!it.second) continue;
63  if(already.find(it.second) == already.end()){
64  already[it.second] = it.first;
65  }
66  else{
67  std::cout << "MultiExperimentSBN::SetSystCorrelations(): Warning!\n"
68  << "In experiment " << idx << " both "
69  << already[it.second]->ShortName() << " and "
70  << it.first->ShortName()
71  << " are configured to map to " << it.second->ShortName()
72  << ". That's probably not what you want." << std::endl;
73  }
74  }
75 
76  // Apply it
77  fSystCorrelations[idx] = corrs;
78  }
std::vector< std::vector< std::pair< const ISyst *, const ISyst * > > > fSystCorrelations
BEGIN_PROLOG could also be cout

Member Data Documentation

std::vector<int> ana::MultiExperimentSBN::fExptNames
protected

Definition at line 53 of file MultiExperimentSBN.h.

std::vector<const IExperiment*> ana::MultiExperimentSBN::fExpts
protected

Definition at line 52 of file MultiExperimentSBN.h.

std::vector<std::vector<std::pair<const ISyst*, const ISyst*> > > ana::MultiExperimentSBN::fSystCorrelations
protected

Definition at line 54 of file MultiExperimentSBN.h.


The documentation for this class was generated from the following files: