16 void GetMPV(
char name[100],TH1F*
histo, TDirectory* Dir,
double& peak,
double&
error,
double& sigma,
double& err_sigma);
18 void CalculateResponse(
bool UseRatioForResponse,
double x,
double ex,
double y,
double ey,
double&
r,
double&
e);
19 void CalculateCorrection(
bool UseRatioForResponse,
double x,
double ex,
double y,
double ey,
double&
c,
double&
e);
22 int getBin(
double x, std::vector<double> boundaries);
54 typedef std::map<std::string,std::pair<std::string,bool> >
OptionMap_t;
77 OptionMap_t::iterator it=
_options.find(name);
79 it->second.second =
true;
95 OptionMap_t::const_iterator it=
_options.find(name);
96 if (it!=
_options.end())
return getValue<T>(name);
100 ss>>default_as_string;
101 _options[
name] = std::make_pair(default_as_string,
true);
103 return default_value;
113 it->second.second =
true;
116 if (val_as_string==
"true")
return true;
117 if (val_as_string==
"false")
return false;
119 std::stringstream ss;
133 OptionMap_t::const_iterator it=
_options.find(name);
134 if (it!=
_options.end())
return getValue<bool>(name);
136 std::make_pair(
"true",
true) : std::make_pair(
"false",
true);
138 return default_value;
147 OptionMap_t::iterator it=
_options.find(name);
149 it->second.second =
true;
156 std::stringstream ss;
157 ss<<tmp.substr(0,pos);
161 result.push_back(element);
163 while (pos!=std::string::npos);
177 OptionMap_t::iterator it=
_options.find(name);
178 if (it==
_options.end())
_options[name] = std::make_pair(default_as_string,
false);
179 return getVector<T>(
name);
208 if(0!=opt.find(
"-")) {
211 if (!success)
return false;
215 std::cout<<
"CommandLine ERROR: options must start with '-'!"<<std::endl;
222 std::cout<<
"ERROR: option '"<<opt<<
"' requires value!"<<std::endl;
225 _options[opt] = std::make_pair(next,
false);
229 while (next.find(
"-")!=0) {
232 next = (
i<argc-1) ? argv[
i+1] :
"-";
243 OptionMap_t::const_iterator it;
245 if (!it->second.second) {
246 std::cout<<
"CommandLine WARNING: unused option '"<<it->first<<
"'!"<<std::endl;
254 <<
" the followingparameters *must* be provided:"<<std::endl;
264 std::cout<<
"------------------------------------------------------------"<<std::endl;
266 std::cout<<
"------------------------------------------------------------"<<std::endl;
269 OptionMap_t::const_iterator it=
_options.find(*itvec);
271 if (it->second.first.find(
",")<std::string::npos) {
277 if (tmp.length()==length) {
278 std::cout<<std::setiosflags(std::ios::left)<<std::setw(22)
280 <<std::resetiosflags(std::ios::left)
282 <<std::setiosflags(std::ios::right)<<std::setw(35)
284 <<std::resetiosflags(std::ios::right)
288 std::cout<<std::setiosflags(std::ios::right)<<std::setw(60)
290 <<std::resetiosflags(std::ios::right)
295 while (pos!=std::string::npos);
298 std::cout<<std::setiosflags(std::ios::left)<<std::setw(22)
300 <<std::resetiosflags(std::ios::left)
302 <<std::setiosflags(std::ios::right)<<std::setw(35)
304 <<std::resetiosflags(std::ios::right)
308 std::cout<<
"------------------------------------------------------------"<<std::endl;
313 std::ifstream
fin(file_name.c_str());
314 if (!
fin.is_open()) {
315 std::cout<<
"Can't open configuration file "<<file_name<<std::endl;
319 std::stringstream ss;
324 if (!filter&&next==
'$') filter=
true;
326 if (next==
'=') ss<<
" "<<next<<
" ";
329 if (filter&&next==
'\n') filter=
false;
336 if (key!=
""&&value!=
"")
_options[
key] = std::make_pair(value,
false);
341 else if (last_token!=
"") {
342 if (last_token.find(
"\"")==0) {
343 if (last_token.rfind(
"\"")==last_token.length()-1) {
344 last_token=last_token.substr(1,last_token.length()-2);
345 value+=(value!=
"")?
","+last_token:last_token;
348 else last_token+=
" "+token;
351 value+=(value!=
"")?
","+last_token:last_token;
352 last_token=(token==
"=")?
"":token;
355 else last_token=(token==
"=")?
"":token;
358 if (last_token!=
"") {
359 if (last_token.find(
"\"")==0&&last_token.rfind(
"\"")==last_token.length()-1)
360 last_token=last_token.substr(1,last_token.length()-2);
361 value+=(value!=
"")?
","+last_token:last_token;
363 if (key!=
""&&value!=
"")
_options[
key] = std::make_pair(value,
false);
368 void GetMPV(
char name[100],TH1F*
histo, TDirectory* Dir,
double& peak,
double&
error,
double& sigma,
double& err_sigma)
370 double norm,
mean,
rms,
integral,lowlimit,highlimit,LowResponse,HighResponse,
a;
372 LowResponse = histo->GetXaxis()->GetXmin();
373 HighResponse = histo->GetXaxis()->GetXmax();
376 TStyle *myStyle =
new TStyle(
"mystyle",
"mystyle");
378 myStyle->SetOptFit(1111);
379 myStyle->SetOptStat(2200);
380 myStyle->SetStatColor(0);
381 myStyle->SetTitleFillColor(0);
383 integral = histo->Integral();
384 mean = histo->GetMean();
385 rms = histo->GetRMS();
389 lowlimit =
TMath::Max(LowResponse,mean-a*rms);
390 highlimit=
TMath::Min(mean+a*rms,HighResponse);
391 norm = histo->GetMaximumStored();
396 g =
new TF1(
"g",
"gaus",lowlimit, highlimit);
397 g->SetParNames(
"N",
"#mu",
"#sigma");
398 g->SetParameter(0,norm);
399 g->SetParameter(1,peak);
400 g->SetParameter(2,sigma);
401 lowlimit =
TMath::Max(LowResponse,peak-a*sigma);
402 highlimit=
TMath::Min(peak+a*sigma,HighResponse);
403 g->SetRange(lowlimit,highlimit);
405 norm = g->GetParameter(0);
406 peak = g->GetParameter(1);
407 sigma = g->GetParameter(2);
411 peak = g->GetParameter(1);
412 sigma = g->GetParameter(2);
413 error = g->GetParError(1);
414 err_sigma = g->GetParError(2);
418 std::cout<<
"FIT FAILURE: histogram "<<name<<
"...Using MEAN and RMS."<<std::endl;
421 error = histo->GetMeanError();
422 err_sigma = histo->GetRMSError();
437 double N = histo->Integral();
440 peak = histo->GetMean();
441 sigma = histo->GetRMS();
442 error = histo->GetMeanError();
454 if (x>0 && fabs(y)>0)
456 if (UseRatioForResponse)
476 if (x>0 && fabs(y)>0)
478 if (UseRatioForResponse)
502 std::cout<<
"WARNING: empty file histogram list!!!!"<<std::endl;
508 std::cout<<
"Histogram: "<<hname<<
" NOT FOUND!!! Check list of existing objects."<<std::endl;
512 int getBin(
double x, std::vector<double> boundaries)
515 int n = boundaries.size()-1;
517 if (x<boundaries[0] || x>=boundaries[n])
521 if (x>=boundaries[i] && x<boundaries[i+1])
void CalculateResponse(bool UseRatioForResponse, double x, double ex, double y, double ey, double &r, double &e)
std::vector< T > getVector(const std::string &name)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
void Invert(TF1 *f, double Min, double Max, double y, double &x)
std::map< std::string, std::pair< std::string, bool > > OptionMap_t
T getValue(const std::string &name)
int getBin(double x, std::vector< double > boundaries)
void GetMPV(char name[100], TH1F *histo, TDirectory *Dir, double &peak, double &error, double &sigma, double &err_sigma)
Integral< F, X >::type integral(const F &f)
std::vector< std::string > StrVec_t
void GetMEAN(TH1F *histo, double &peak, double &error, double &sigma)
std::vector< std::vector< double > > tmp
void CalculateCorrection(bool UseRatioForResponse, double x, double ex, double y, double ey, double &c, double &e)
bool parse_file(const std::string &file_name)
bool parse(int argc, char **argv)
StrVec_t _ordered_options
bool HistoExists(std::vector< std::string > LIST, std::string hname)
Power< A, B >::type pow(const A &a, const B &b)