Skip to content

Commit

Permalink
Write the fit values to tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiSchluter committed Oct 10, 2011
1 parent 70806e9 commit 2bc88e8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
OBJECTS=myFit.o control.o wave.o event.o likelihood.o 3j.o
OBJECTS=myFit.o control.o wave.o event.o likelihood.o 3j.o fitInfo.o fitInfoDict.o
DEBUGFLAGS=-g -fopenmp
LDFLAGS=${DEBUGFLAGS}
CXXFLAGS=-Wall ${DEBUGFLAGS} -O2 `root-config --cflags`
LIBS=`root-config --libs --cflags` -lMinuit2 -lMathMore
CXXFLAGS:=-Wall ${DEBUGFLAGS} -O2 $(shell root-config --cflags)
LIBS:=$(shell root-config --libs --cflags) -lMinuit2 -lMathMore

myFit: ${OBJECTS}
g++ -o $@ ${LDFLAGS} ${OBJECTS} ${LIBS}

clean:
rm -f ${OBJECTS}
rm -f fitInfoDict.{cc,h}
rm -f myFit

.cc.o:
g++ -c ${CXXFLAGS} $< -o $@

myFit.o: myFit.cc control.h wave.h likelihood.h gHist.h startingValue.h
fitInfoDict.o: fitInfoDict.cc
fitInfoDict.cc: fitInfo.h startingValue.h LinkDef.h
rootcint -f $@ -c fitInfo.h+

myFit.o: myFit.cc control.h wave.h likelihood.h gHist.h startingValue.h fitInfo.h
control.o: control.cc control.h
wave.o: wave.cc wave.h event.h
event.o: event.cc event.h
likelihood.o: likelihood.cc likelihood.h event.h wave.h
3j.o: 3j.cc wave.h
fitInfo.o: fitInfo.cc fitInfo.h startingValue.h
15 changes: 15 additions & 0 deletions fitInfo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <vector>

#include "fitInfo.h"

fitInfo::fitInfo(const std::vector<tStartingValue>& fitVars)
{
for (size_t i = 0; i < fitVars.size(); i++)
{
paramNames.push_back(fitVars[i].name.c_str());
}
}

#ifndef __CINT__
ClassImp(fitInfo)
#endif
28 changes: 28 additions & 0 deletions fitInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef FITINFO_H__
#define FITINFO_H__

//
// The data stored in the output tree's UserInfo need to be put in a
// TList, which in turn means they have to be put in data structures
// inheriting from TObject, so we take care of this here.

#include <vector>
#include <string>

#include "TObject.h"
#include "TString.h"

#include "startingValue.h"

class fitInfo : public TObject
{
public:
fitInfo() {};
fitInfo(const std::vector<tStartingValue>& fitVars);
private:
std::vector<std::string> paramNames;

ClassDef(fitInfo, 1)
};

#endif
13 changes: 12 additions & 1 deletion myFit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using namespace std;
#include "event.h"
#include "likelihood.h"
#include "startingValue.h"
#include "fitInfo.h"
#include "gHist.h"

#define NFLATMCEVENTS 100000
Expand Down Expand Up @@ -276,6 +277,15 @@ myFit()
startingValues.push_back(tStartingValue("BR1", 1, true));
startingValues.push_back(tStartingValue("BR2", 0.57, false));

TTree *outTree = new TTree("tFitResults", "fit results tree");
double *values = new double[startingValues.size()];
char branchDesc[99];
snprintf(branchDesc, 99, "values[%zd]/D", startingValues.size());
outTree->Branch("massLow", &massLow, "massLow/D");
outTree->Branch("massHigh", &massHigh, "massHigh/D");
outTree->Branch("values", values, branchDesc);
outTree->GetUserInfo()->Add(new fitInfo(startingValues));

combinedLikelihood myL(ws, nBins, threshold, binWidth);

for (size_t iFile = 0; iFile < dataFiles.size(); iFile++)
Expand Down Expand Up @@ -593,8 +603,9 @@ myFit()
vector<double> vStartingValue(nParams);
for (size_t j = 0; j < nParams; j++)
{
vStartingValues[j] = minuit->GetParameter(j);
values[j] = vStartingValues[j] = minuit->GetParameter(j);
}
outTree->Fill();

for (int j = 0; j < minuit->GetNumberTotalParameters(); j++)
startingValues[j].value = minuit->GetParameter(j);
Expand Down
1 change: 1 addition & 0 deletions startingValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct tStartingValue {
Double_t value;
bool fixed;

tStartingValue() {}
tStartingValue(const std::string& n, Double_t v, bool f)
: name(n), value(v), fixed(f)
{}
Expand Down

0 comments on commit 2bc88e8

Please sign in to comment.