Skip to content

Commit

Permalink
Control using flatMC via control.txt. Added README file. A few cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiSchluter committed Apr 14, 2011
1 parent d6de6f3 commit 1b07105
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The fit is controlled via a file control.txt. For an example see
controlExample.txt. If the keyword 'flatMC' is given, normalization
integrals are calculated from a flat distribution and the 'MCfile'
keyword is ignored.
8 changes: 7 additions & 1 deletion control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using namespace std;

string dataFile;
bool flatMC;
string MCFile;
double threshold;
int nBins;
Expand Down Expand Up @@ -50,6 +51,7 @@ readControlFile(string fileName)
}

bool haveDataFile = false;
bool flatMC = false;
bool haveMCFile = false;
bool haveNFits = false;
bool haveThreshold = false;
Expand All @@ -67,6 +69,10 @@ readControlFile(string fileName)
break;
haveDataFile = true;
}
else if (!strcasecmp(key, "flatMC"))
{
flatMC = true;
}
else if (!strcasecmp(key, "mcfile"))
{
if (!readString(fd, MCFile))
Expand Down Expand Up @@ -110,7 +116,7 @@ readControlFile(string fileName)
cerr << "No data file given." << endl;
good = false;
}
if (!haveMCFile)
if (!flatMC && !haveMCFile)
{
cerr << "No MC file given." << endl;
good = false;
Expand Down
1 change: 1 addition & 0 deletions control.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>

extern std::string dataFile;
extern bool flatMC;
extern std::string MCFile;
extern double threshold;
extern int nBins;
Expand Down
1 change: 1 addition & 0 deletions controlExample.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dataFile dataEtaPi.txt
flatMC
MCFile /data/zup/diefenbach/ToyMC/MCfit/1,5Mio_Eta_3Pi_flat_m5_1,2_0,2_1,5_tcut/dataMCEta.txt
threshold 0.7
nbins 80
Expand Down
23 changes: 11 additions & 12 deletions myFit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ using namespace std;

#include "control.h"

bool flatMC = false;
#define NFLATMCEVENTS 100000
double massLow = 0;
double massHigh = 9999;
Expand Down Expand Up @@ -81,7 +80,7 @@ class event {
return (this->mass >= massLow && this->mass < massHigh
//&& this->tPrime > 0.1 && this->tPrime < 0.3);
//&& this->tPrime > 0.3);
&& 1);
&& 1);
}
};

Expand Down Expand Up @@ -148,8 +147,8 @@ class likelihood : public ROOT::Minuit2::FCNBase {

// The amplitude is: Ylm(theta, phi) - epsilon (-)^m Yl-m(theta, phi)
// = Ylm(theta, phi) - epsilon Ylm(theta, phi)*
// = N Plm(theta) (e^(i m phi) - epsilon e^(-i m phi))
// = N' Plm(theta) {cos,sin}(m phi)
// = Ylm(theta, 0) (e^(i m phi) - epsilon e^(-i m phi))
// = 2 Ylm(theta, 0) {i sin, cos}(m phi)

// NOTE the phase is ignored, as different reflectivities don't interfere

Expand Down Expand Up @@ -179,6 +178,7 @@ event::MCweight(int reflectivity, int l1, int m1, int l2, int m2) const
* this->decayAmplitude(reflectivity,l2,m2));
}


complex<double>
coherent_waves::sum(const double* x, const event& e) const
{
Expand Down Expand Up @@ -234,14 +234,14 @@ likelihood::likelihood(waveset ws_,

if (!flatMC)
{
double countAllMC = 0;
double countAllMC = 0; // no of MC events generated in bin
for (size_t iEvent = 0; iEvent < MCallEvents.size(); iEvent++)
{
if (!MCallEvents[iEvent].accepted())
continue;
countAllMC += 1;
countAllMC++;
}
binnedEtaAcc[iBin] = binnedMCevents[iBin].size() / countAllMC;
binnedEtaAcc[iBin] = 1.*binnedMCevents[iBin].size() / countAllMC;
}
else
{
Expand Down Expand Up @@ -299,9 +299,8 @@ likelihood::MCweight(int reflectivity, const wave& w1, const wave& w2) const
}

/*
cout << "calculated MCweight " << sum / (nmcevents - countRejected)
<< " from " << (nmcevents - countRejected) << " MC events "
<< "out of " << countGenerated << " for "
cout << "calculated MCweight " << sum / pMCevents.size()
<< " from " << pMCevents.size() << " MC events for "
<< "(l1,m1,l2,m2) = "
<< "(" << w1.l << "," << w1.m << "," << w2.l << "," << w2.m << ")"
<< endl;
Expand Down Expand Up @@ -437,7 +436,6 @@ myFit()
};

TH2* hRD = new TH2D("hRD", "RD", 10, -1, 1, 10, -M_PI, M_PI);
TH2* hMC = new TH2D("hMC", "MC", 10, -1, 1, 10, -M_PI, M_PI);
TH1* hMass = new TH1D("hMass", "mass distribution",
250, 0.5, 3);
TH1* htprime = new TH1D("htprime", "t' distribution",
Expand Down Expand Up @@ -543,6 +541,7 @@ myFit()
TH1* hIntensity = new TH1D("hIntensity", "total intensity as predicted",
nBins, lower, upper);
//TH3* hPredict = new TH3D("hPredict", "prediction", nBins, 0, nBins, 100, -1, 1, 100, -M_PI, M_PI);

TStopwatch fulltime;
fulltime.Start();
for (iBin = 0; iBin < nBins; iBin++)
Expand All @@ -553,7 +552,7 @@ myFit()

minuit->Clear();
if (!flatMC)
// MCweights are the same in different mass bins for the
// flat MCweights are the same in different mass bins for the
// two-body amplitudes.
weights.clear();

Expand Down

0 comments on commit 1b07105

Please sign in to comment.