AlignmentVariation.h
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <vector>
4 #include <cstdlib>
5 
7 
8  std::string m_variation_type; // macro, location, or current
9 
12  std::vector<std::string> m_variation_names;
14 
15  std::string m_version; // e.g. v3r0p4
17 
20 
23 
25 
27 
29 
31 
33 
34  public:
38 
39  m_variation_type = type;
40  m_quantity_varied = quantity;
41  m_label = "";
42 
43  m_version = version;
44  m_nominal_version = version;
45 
46  m_user = std::getenv("USER");
47  m_nominal_user = std::getenv("USER");
48 
49  m_nominal_plist = "QGSP_BERT";
50  m_nominal_current = "200kA";
51 
52  m_tolerance = "";
53 
54  m_cv = "0";
55 
56  m_scale_factor = 1.0;
57 
58  m_disk = "/lbne/data/";
59 
60  m_macro_suffix = "";
61  }
62 
63  void SetDisk(std::string disk) {
64  m_disk = disk;
65  }
66 
67 
68  void SetUnits(std::string units) {
69  m_units=units;
70  }
71 
73  m_tolerance=tolerance;
74  }
75 
77  m_nominal_version = v;
78  }
79 
80  void SetLabel(std::string label) {
81  m_label = label;
82  }
83 
84  void SetUser(std::string u) {
85  m_user = u;
86  }
87 
89  m_nominal_user = u;
90  }
91 
93  m_cv = cv;
94  }
95 
96  void SetScaleFactor(double scale_factor) {
97  m_scale_factor = scale_factor;
98  }
99 
100  void SetMacroSuffix(std::string macro_suffix) {
101  m_macro_suffix = macro_suffix;
102  }
103 
105  m_variation_names.push_back(variation);
106  }
107 
109  return m_quantity_varied;
110  }
111 
113  return m_label;
114  }
115 
117  return m_variation_type;
118  }
119 
120  std::vector<std::string> GetVariationNames() {
121  return m_variation_names;
122  }
123 
125  return m_units;
126  }
127 
129  return m_tolerance;
130  }
131 
132  std::string GetNominalHistoFile(std::string beam_mode = "nu",std::string loc="LBNEFD",bool fastmc=false) {
133 
134  std::string temp_current = m_nominal_current;
135  if(beam_mode=="antinu") temp_current = "-"+m_nominal_current;
136 
137  std::string fmc = "";
138  if(fastmc) fmc="_fastmc";
139 
140  std::string the_file = m_disk+"/users/"+m_nominal_user+"/fluxfiles/g4lbne/"+m_nominal_version;
141 
142  the_file += "/"+m_nominal_plist+"/Nominal/"+temp_current+"/flux/";
143  the_file += "histos_g4lbne_"+m_nominal_version+"_"+m_nominal_plist+"_Nominal_"+temp_current+"_"+loc+fmc+".root";
144 
145  std::cout<<"Nominal file: "<<the_file<<std::endl;
146  return the_file;
147  }
148 
149  std::vector<std::string> GetVariedHistoFiles(std::string beam_mode = "nu",std::string loc="LBNEFD",bool fastmc=false) {
150 
151  std::string fmc = "";
152  if(fastmc) fmc="_fastmc";
153 
154  std::vector<std::string> the_files;
155 
156  std::cout<<"Looking up flux histograms for variation "<<m_quantity_varied<<" which has type "<<m_variation_type<<std::endl;
157 
158  if(m_variation_type=="shift") {
159 
160  // "shift" type variations don't have multiple variations. Example: baffle scraping involves shifting the nominal flux by a fraction of the flux from the baffle
161 
162  std::string temp_current = m_nominal_current;
163  if(beam_mode=="antinu") temp_current = "-"+m_nominal_current;
164 
165  std::string the_file = m_disk+"/users/"+m_user+"/fluxfiles/g4lbne/"+m_version;
166  the_file += "/"+m_nominal_plist+"/"+m_quantity_varied+m_units+m_macro_suffix+"/"+temp_current+"/flux/";
167  the_file += "histos_g4lbne_"+m_version+"_"+m_nominal_plist+"_"+m_quantity_varied+m_units+m_macro_suffix+"_"+temp_current+"_"+loc+fmc+".root";
168  the_files.push_back(the_file);
169  }
170  else
171  for(unsigned int i = 0; i<m_variation_names.size(); i++) {
172  std::string variation = m_quantity_varied+m_variation_names[i]+m_units+m_macro_suffix;
173  if(m_variation_type=="current")
174  variation = m_variation_names[i]+m_units+m_macro_suffix;
175 
176  std::string the_file = m_disk+"/users/"+m_user+"/fluxfiles/g4lbne/"+m_version;
177 
178  if(m_variation_type=="macro") {
179  std::string temp_current = m_nominal_current;
180  if(beam_mode=="antinu") temp_current = "-"+m_nominal_current;
181 
182  the_file += "/"+m_nominal_plist+"/"+variation+"/"+temp_current+"/flux/";
183  the_file += "histos_g4lbne_"+m_version+"_"+m_nominal_plist+"_"+variation+"_"+temp_current+"_"+loc+fmc+".root";
184  }
185  else if(m_variation_type=="current") {
186  std::string current_sign = "";
187  if(beam_mode=="antinu") current_sign = "-";
188 
189  the_file += "/"+m_nominal_plist+"/Nominal/"+current_sign+variation+"/flux/";
190  the_file += "histos_g4lbne_"+m_nominal_version+"_"+m_nominal_plist+"_Nominal_"+current_sign+variation+"_"+loc+fmc+".root";
191  }
192  else if(m_variation_type=="location") {
193  std::string temp_current = m_nominal_current;
194  if(beam_mode=="antinu") temp_current = "-"+m_nominal_current;
195 
196  std::cout<<" i "<<i<<" m_variation_names[i] "<<m_variation_names[i]<<std::endl;
197  std::cout<<"m_quantity_varied "<<m_quantity_varied<<" loc "<<loc<<std::endl;
198  std::string temploc = loc;
199  if(m_quantity_varied.find(loc)==0) {
200  temploc = m_quantity_varied+m_variation_names[i];
201  std::cout<<"temploc "<<temploc<<std::endl;
202  }
203  the_file += "/"+m_nominal_plist+"/Nominal/"+temp_current+"/flux/";
204  the_file += "histos_g4lbne_"+m_nominal_version+"_"+m_nominal_plist+"_Nominal_"+temp_current+"_"+temploc+fmc+".root";
205  }
206  else {
207  std::cout<<"Variation type"<<m_variation_type<<" not yet supported"<<std::endl;
208  return the_files;
209  }
210  the_files.push_back(the_file);
211  std::cout<<"varied file "<<the_file<<std::endl;
212  }
213  return the_files;
214  }
215 
216  std::string GetCV() { return m_cv; }
217 
218  double GetScaleFactor() { return m_scale_factor; }
219 
220  std::string GetUser() { return m_user; }
221 
223 
224  };
225 
226 
std::string GetNominalHistoFile(std::string beam_mode="nu", std::string loc="LBNEFD", bool fastmc=false)
void SetScaleFactor(double scale_factor)
std::string string
Definition: nybbler.cc:12
double const tolerance
std::string m_variation_type
void SetUnits(std::string units)
void SetUser(std::string u)
std::string m_macro_suffix
void AddVariation(std::string variation)
std::string GetVariedQuantity()
void SetNominalUser(std::string u)
quantity
Definition: statistics_t.cc:15
std::string getenv(std::string const &name)
Definition: getenv.cc:15
std::string m_nominal_version
std::vector< std::string > m_variation_names
std::string GetMacroSuffix()
std::string GetTolerance()
void SetNominalVersion(std::string v)
void SetTolerance(std::string tolerance)
void SetDisk(std::string disk)
std::vector< std::string > GetVariedHistoFiles(std::string beam_mode="nu", std::string loc="LBNEFD", bool fastmc=false)
AlignmentVariation(std::string quantity, std::string type, std::string version)
static QCString type
Definition: declinfo.cpp:672
void SetCV(std::string cv)
std::string m_nominal_current
void SetLabel(std::string label)
void SetMacroSuffix(std::string macro_suffix)
std::string m_nominal_user
std::string GetVariationType()
std::string m_nominal_plist
QTextStream & endl(QTextStream &s)
std::vector< std::string > GetVariationNames()
std::string m_quantity_varied