13 #include <sys/types.h> 43 for(namedVMap::const_iterator it = sijList.begin();
44 it != sijList.end(); it++){
46 (*this)[it->second] = h;
53 (*this)[histo.
coord()].add(histo, weight);
57 for(std::map< DalitzCoordSet, DalitzHistogram>::const_iterator it = hL.
begin();
60 this->
add(it->second, weight);
65 (*this)[histo.
coord()].multiply(histo);
69 for(map< DalitzCoordSet, DalitzHistogram>::const_iterator it = hL.
begin();
77 (*this)[histo.
coord()].divide(histo);
81 for(map< DalitzCoordSet, DalitzHistogram>::const_iterator it = hL.
begin();
93 for(map< DalitzCoordSet, DalitzHistogram>::iterator
97 it->second.addEvent(evt, weight);
103 if(this->
empty())
return;
104 for(map< DalitzCoordSet, DalitzHistogram>::iterator
108 it->second.scale(sf);
114 if(this->
empty())
return;
115 for(map< DalitzCoordSet, DalitzHistogram>::iterator
119 it->second.setNormFactor(sf);
125 if(this->
empty())
return;
126 for(map< DalitzCoordSet, DalitzHistogram>::iterator
130 it->second.setTitle(title);
135 if(this->
empty())
return;
136 for(map< DalitzCoordSet, DalitzHistogram>::iterator
140 it->second.histo()->SetFillColor(fcolor);
145 if(this->
empty())
return;
146 for(map< DalitzCoordSet, DalitzHistogram>::iterator
150 it->second.histo()->SetLineColor(fcolor);
151 it->second.histo()->SetLineWidth(2);
159 if(this->
empty())
return;
160 for(map< DalitzCoordSet, DalitzHistogram>::iterator
164 it->second.clearHisto();
170 _name =
"DalitzHistoSet";
183 TFile* f = TFile::Open(filename.c_str(),
"RECREATE");
185 for(map< DalitzCoordSet, DalitzHistogram>::const_iterator
189 if(0 == it->second.histo())
continue;
190 it->second.histo()->Write();
220 mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
225 int zeroForSuccess = 0;
226 zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
227 zeroForSuccess |= mkdir( (asSubdirOf +
"/" +
dirName() ).c_str(), mode );
228 return (0 == zeroForSuccess);
233 return asSubdirOf +
"/" +
dirName() +
"/" +
"directoryList.txt";
240 if(dbThis) cout <<
"DalitzHistoSet::saveAsDir: called with " 241 <<
"asSubdirOf = " << asSubdirOf << endl;
244 std::string dir = asSubdirOf +
"/" +
dirName();
246 std::vector<std::string> directoryList;
247 for(map< DalitzCoordSet, DalitzHistogram>::const_iterator
251 if(dbThis) cout <<
"DalitzHistoSet::saveAsDir: saving DalitzHistogram" << endl;
252 sc &= it->second.saveAsDir(dir);
253 directoryList.push_back(it->second.dirName());
257 , NamedParameterBase::QUIET);
258 dirNames = directoryList;
262 cout <<
"ERROR in DalitzHistoSet::saveAsDir of \n\t" <<
name()
263 <<
"\n\t unable to create file: " 273 cout <<
"I've just written this: " 292 std::string path=asSubdirOf +
"/" +
dirName();
293 for(
int i=0; i < dirNames.
size(); i++){
296 if(dbThis) cout <<
"hs.pattern()" << hs.
pattern() << endl;
300 cout <<
"after adding:" << endl;
301 for(std::map< DalitzCoordSet, DalitzHistogram>::const_iterator it =
302 this->
begin(); it != this->
end(); it++){
303 cout <<
"\n" << it->second.pattern() << endl;
311 ,
const std::string& drawOpt
312 ,
const std::string& format
315 for(map< DalitzCoordSet, DalitzHistogram>::const_iterator
319 sc &= it->second.draw(baseName, drawOpt, format);
325 ,
const std::string& baseName
326 ,
const std::string& format
327 ,
const std::string& fitDrawOpt
330 for(map< DalitzCoordSet, DalitzHistogram>::const_iterator
334 map< DalitzCoordSet, DalitzHistogram >::const_iterator jt
335 = fit.
find(it->first);
336 if(jt == fit.
end())
continue;
337 sc &= it->second.drawWithFit(jt->second, baseName, format, fitDrawOpt);
345 , std::vector<DalitzHistoSet>& amps
346 ,
const std::string& baseName
351 std::vector<DalitzHistoSet>::iterator amps_it;
353 for(map< DalitzCoordSet, DalitzHistogram>::iterator it = data.
begin();it != data.
end();it++){
358 map< DalitzCoordSet, DalitzHistogram >::iterator jt= fit.
find(it->first);
359 if(jt == fit.
end())
continue;
361 std::cout << it->first << endl;
364 TLegend* leg =
new TLegend(0.5
370 leg->SetTextSize(0.03);
371 if ((it->first).name() ==
"sij(2,3,4)" ||
372 (it->first).
name() ==
"sij(1,3,4)" ||
373 (it->first).
name() ==
"sij(1,2,4)" ||
374 (it->first).
name() ==
"sij(1,2,3)" )
380 TLegend* leg2 =
new TLegend(0.,0.,1.,1.,
"");
381 leg2->SetLineStyle(0);
382 leg2->SetLineColor(0);
384 (*dataHisto).Scale(1./(*dataHisto).Integral());
385 (*dataHisto).SetMinimum(0.0001);
386 double max = (*dataHisto).GetMaximum();
387 if((*FitHisto).GetMaximum()>max)max= (*FitHisto).GetMaximum();
388 (*dataHisto).SetMaximum(max*1.1);
389 (*dataHisto).SetLineColor(kBlack);
390 (*dataHisto).SetMarkerStyle(20);
391 (*dataHisto).SetMarkerSize(0.6);
392 (*dataHisto).Draw(
"E");
394 (*FitHisto).SetLineColor(kBlack);
395 (*FitHisto).Draw(
"HIST C SAME");
400 (*FitHisto).GetEntries();
402 (*FitHisto).GetNormFactor();
406 for (amps_it = amps.begin(); amps_it < amps.end(); amps_it++)
408 map< DalitzCoordSet, DalitzHistogram >::iterator it2 = (*amps_it).find(it->first);
411 histo = it2->second.getHisto();
413 if (counter == 9) counter++;
414 (*histo).SetLineColor(1+counter);
416 const char* title = (*histo).GetTitle();
417 leg->AddEntry(&(*histo),title,
"l");
418 leg2->AddEntry(&(*histo),title,
"l");
420 (*histo).Draw(
"HIST C SAME");
422 (*histo).GetNormFactor();
425 std::string SaveName = it->first.name();
426 TString SaveFull = baseName+SaveName+
".eps";
427 TString SaveFullLeg = baseName+SaveName+
"_leg.eps";
428 TString SaveFullLog = baseName+SaveName+
"_log.eps";
429 TString SaveLeg = baseName+
"_leg.eps";
431 SaveFull.ReplaceAll(
"(",
"");
432 SaveFull.ReplaceAll(
")",
"");
433 SaveFull.ReplaceAll(
",",
"_");
434 SaveFullLeg.ReplaceAll(
"(",
"");
435 SaveFullLeg.ReplaceAll(
")",
"");
436 SaveFullLeg.ReplaceAll(
",",
"_");
437 SaveFullLog.ReplaceAll(
"(",
"");
438 SaveFullLog.ReplaceAll(
")",
"");
439 SaveFullLog.ReplaceAll(
",",
"_");
440 SaveLeg.ReplaceAll(
"(",
"");
441 SaveLeg.ReplaceAll(
")",
"");
442 SaveLeg.ReplaceAll(
",",
"_");
447 can.Print(SaveFullLog);
450 leg->SetFillColor(4000);
451 leg->SetShadowColor(4000);
453 can.Print(SaveFullLeg);
457 leg2->SetFillColor(4000);
458 leg2->SetShadowColor(4000);
469 , std::vector<DalitzHistoSet>& amps
470 ,
const std::string& baseName
475 std::vector<DalitzHistoSet>::iterator amps_it;
477 for(map< DalitzCoordSet, DalitzHistogram>::iterator it = data.
begin();it != data.
end();it++){
482 map< DalitzCoordSet, DalitzHistogram >::iterator jt= fit.
find(it->first);
483 if(jt == fit.
end())
continue;
485 std::cout << it->first << endl;
488 map< DalitzCoordSet, DalitzHistogram >::iterator jt_interference = interference.
find(it->first);
489 if(jt_interference == interference.
end())
continue;
493 TLegend* leg =
new TLegend(0.5
499 leg->SetTextSize(0.01);
500 if ((it->first).name() ==
"sij(2,3,4)" ||
501 (it->first).
name() ==
"sij(1,3,4)" ||
502 (it->first).
name() ==
"sij(1,2,4)" ||
503 (it->first).
name() ==
"sij(1,2,3)" )
509 TLegend* leg2 =
new TLegend(0.,0.,1.,1.,
"");
510 leg2->SetLineStyle(0);
511 leg2->SetLineColor(0);
513 (*dataHisto).Scale(1./(*dataHisto).Integral());
514 double max = (*dataHisto).GetMaximum();
515 if((*FitHisto).GetMaximum()>max)max= (*FitHisto).GetMaximum();
516 (*dataHisto).SetMaximum(max*1.1);
517 (*dataHisto).SetLineColor(kBlack);
518 (*dataHisto).SetMarkerStyle(20);
519 (*dataHisto).SetMarkerSize(0.6);
520 (*dataHisto).Draw(
"E");
522 (*FitHisto).SetLineColor(kBlack);
523 (*FitHisto).Draw(
"HIST C SAME");
527 (*interferenceHisto).SetLineColor(kBlack);
528 (*interferenceHisto).SetLineStyle(kDashed);
529 (*interferenceHisto).Draw(
"HIST C SAME");
530 leg->AddEntry(&(*interferenceHisto),
"Interference",
"l");
531 leg2->AddEntry(&(*interferenceHisto),
"Interference",
"l");
534 (*FitHisto).GetEntries();
536 (*FitHisto).GetNormFactor();
540 for (amps_it = amps.begin(); amps_it < amps.end(); amps_it++)
542 map< DalitzCoordSet, DalitzHistogram >::iterator it2 = (*amps_it).find(it->first);
545 histo = it2->second.getHisto();
547 if (counter == 9) counter++;
548 (*histo).SetLineColor(1+counter);
550 const char* title = (*histo).GetTitle();
551 leg->AddEntry(&(*histo),title,
"l");
552 leg2->AddEntry(&(*histo),title,
"l");
554 (*histo).Draw(
"HIST C SAME");
556 (*histo).GetNormFactor();
559 std::string SaveName = it->first.name();
560 TString SaveFull = baseName+SaveName+
".eps";
561 TString SaveFullLeg = baseName+SaveName+
"_leg.eps";
562 TString SaveLeg = baseName+
"_leg.eps";
564 SaveFull.ReplaceAll(
"(",
"");
565 SaveFull.ReplaceAll(
")",
"");
566 SaveFull.ReplaceAll(
",",
"_");
567 SaveFullLeg.ReplaceAll(
"(",
"");
568 SaveFullLeg.ReplaceAll(
")",
"");
569 SaveFullLeg.ReplaceAll(
",",
"_");
570 SaveLeg.ReplaceAll(
"(",
"");
571 SaveLeg.ReplaceAll(
")",
"");
572 SaveLeg.ReplaceAll(
",",
"_");
576 leg->SetFillColor(4000);
577 leg->SetShadowColor(4000);
579 can.Print(SaveFullLeg);
583 leg2->SetFillColor(4000);
584 leg2->SetShadowColor(4000);
593 ,
const std::string& baseName
594 ,
const std::string& format
595 ,
const std::string& fitDrawOpt
601 return me.
drawWithFit(you, baseName, format, fitDrawOpt);
604 if(this->
empty())
return 0;
605 return this->
begin()->second.integral();
643 this->
add(rhs, -1.0);
DalitzHistoSet & operator *=(double sf)
bool drawWithFitNorm(const DalitzHistoSet &fit, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
void setFillColour(Color_t fcolor)
DalitzHistoSet operator *(double sf, const DalitzHistoSet &dhs)
const std::string & name() const
std::string fullDirListFname(const std::string &asSubdirOf=".") const
DalitzHistoSet operator *(double sf) const
std::map< Key, Val >::iterator end()
void divide(const DalitzHistogram &hL)
void makeHistograms(const DalitzEventPattern &pat)
DalitzHistoSet operator+(const DalitzHistoSet &rhs) const
void multiply(const DalitzHistogram &hL)
bool drawWithFit(const DalitzHistoSet &fit, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
bool retrieveFromDir(const std::string &asSubDirOf=".")
DalitzHistoSet & operator+=(const DalitzHistoSet &rhs)
const DalitzEventPattern & pattern() const
DalitzHistoSet & operator-=(const DalitzHistoSet &rhs)
bool retrieveFromDir(const std::string &asSubdirOf=".", const char *theName=0)
bool draw(const std::string &baseName="", const std::string &drawOpt="", const std::string &format="eps") const
void setLineColour(Color_t fcolor)
void setTitle(const std::string &title)
DalitzHistoSet operator/(double sf) const
const DalitzCoordSet & coord() const
bool drawWithFitAndEachAmps(DalitzHistoSet &data, DalitzHistoSet &fit, std::vector< DalitzHistoSet > &s, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
DalitzHistoSet operator-(const DalitzHistoSet &rhs) const
virtual const DalitzEventPattern & eventPattern() const =0
bool makeDirectory(const std::string &asSubdirOf) const
void addEvent(const IDalitzEvent &evt, double weight=1)
bool reloadFile(const std::string &id)
std::map< Key, Val >::iterator begin()
bool drawWithFitAndEachAmpsAndInterference(DalitzHistoSet &data, DalitzHistoSet &fit, DalitzHistoSet &interference, std::vector< DalitzHistoSet > &s, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
void setNormFactor(double sf=1)
bool saveAsDir(const std::string &asSubdirOf=".") const
std::map< Key, Val >::iterator find(const Key &c)
virtual ~DalitzHistoSet()
virtual const T & getVal(int i=0) const
DalitzHistoSet & operator/=(double sf)
const std::string & dirName() const
bool save(const std::string &filename="DalitzHistos.root") const
void add(const DalitzHistogram &histo, double weight=1)
const std::string & makeName()