From 8ba07a692a309874ac7409fe826c6f13adf83ee0 Mon Sep 17 00:00:00 2001 From: nemu Date: Mon, 22 Sep 2008 06:24:52 +0000 Subject: [PATCH] added a NPP, PPC switch and performed some clean-up --- src/classes/PFitter.cpp | 12 +++-- src/classes/PFunction.cpp | 4 +- src/classes/PFunctionHandler.cpp | 18 +++---- src/classes/PMusrCanvas.cpp | 1 + src/classes/PRunDataHandler.cpp | 72 ++++++++++++++----------- src/classes/PRunListCollection.cpp | 8 +-- src/classes/PTheory.cpp | 15 +++--- src/include/PRunDataHandler.h | 2 +- src/tests/fourier/PMusrFourier.cpp | 1 + src/tests/fourier/fourier.cpp | 2 +- src/tests/rootMinuit2Test/minuit2test.C | 22 ++++---- 11 files changed, 90 insertions(+), 67 deletions(-) diff --git a/src/classes/PFitter.cpp b/src/classes/PFitter.cpp index ca8dec02..9584868d 100644 --- a/src/classes/PFitter.cpp +++ b/src/classes/PFitter.cpp @@ -154,9 +154,11 @@ bool PFitter::DoFit() break; case PMN_MINOS: status = ExecuteMinos(); - // set positive errors true - for (unsigned int i=0; iSetMsrParamPosErrorPresent(i, true); + // set positive errors true if minos has been successfull + if (status) { + for (unsigned int i=0; iSetMsrParamPosErrorPresent(i, true); + } } break; case PMN_PLOT: @@ -366,10 +368,12 @@ bool PFitter::ExecuteMigrad() ROOT::Minuit2::FunctionMinimum min = migrad(maxfcn, tolerance); if (!min.IsValid()) { cout << endl << "**WARNING**: PFitter::ExecuteMigrad(): Fit did not converge, sorry ..."; +/* // set flag positive error present to false for (unsigned int i=0; iSetMsrParamPosErrorPresent(i, false); } +*/ return false; } @@ -435,10 +439,12 @@ bool PFitter::ExecuteMinimize() ROOT::Minuit2::FunctionMinimum min = minimize(maxfcn, tolerance); if (!min.IsValid()) { cout << endl << "**WARNING**: PFitter::ExecuteMinimize(): Fit did not converge, sorry ..."; +/* // set flag positive error present to false for (unsigned int i=0; iSetMsrParamPosErrorPresent(i, false); } +*/ return false; } diff --git a/src/classes/PFunction.cpp b/src/classes/PFunction.cpp index da040e47..7f6311d0 100644 --- a/src/classes/PFunction.cpp +++ b/src/classes/PFunction.cpp @@ -59,7 +59,7 @@ using namespace std; */ PFunction::PFunction(tree_parse_info<> info) { - cout << endl << "in PFunction ..."; +// cout << endl << "in PFunction ..."; fInfo = info; @@ -528,7 +528,7 @@ void PFunction::EvalTreeForStringExpression(iter_t const& i) } else if (i->value.id() == PFunctionGrammar::termID) { termOp++; if (*i->value.begin() == '*') { -cout << endl << ">> i->children.size() = " << i->children.size() << endl; +//cout << endl << ">> i->children.size() = " << i->children.size() << endl; assert(i->children.size() == 2); EvalTreeForStringExpression(i->children.begin()); fFuncString += " * "; diff --git a/src/classes/PFunctionHandler.cpp b/src/classes/PFunctionHandler.cpp index 529518a3..7d511969 100644 --- a/src/classes/PFunctionHandler.cpp +++ b/src/classes/PFunctionHandler.cpp @@ -47,7 +47,7 @@ PFunctionHandler::PFunctionHandler(PMsrLines lines) fValid = true; fLines = lines; - cout << endl << "in PFunctionHandler(PMsrLines lines)"; +// cout << endl << "in PFunctionHandler(PMsrLines lines)"; } //------------------------------------------------------------- @@ -59,7 +59,7 @@ PFunctionHandler::PFunctionHandler(PMsrLines lines) */ PFunctionHandler::~PFunctionHandler() { - cout << endl << "in ~PFunctionHandler()" << endl << endl; +// cout << endl << "in ~PFunctionHandler()" << endl << endl; fLines.clear(); fFuncs.clear(); @@ -74,7 +74,7 @@ PFunctionHandler::~PFunctionHandler() */ bool PFunctionHandler::DoParse() { - cout << endl << "in PFunctionHandler::DoParse() ..."; +// cout << endl << "in PFunctionHandler::DoParse() ..."; bool success = true; PFunctionGrammar function; @@ -82,7 +82,7 @@ bool PFunctionHandler::DoParse() // feed the function block into the parser. Start with i=1, since i=0 is FUNCTIONS for (unsigned int i=1; i info = ast_parse(line.Data(), function, space_p); if (info.full) { - cout << endl << "parse successful ..." << endl; +// cout << endl << "parse successful ..." << endl; PFunction func(info); fFuncs.push_back(func); } else { @@ -115,10 +115,10 @@ cout << endl << "fLines[" << i << "] = '" << fLines[i].fLine.Data() << "'"; } } - if (success) { - for (unsigned int i=0; i> dval = " << dval << " (Engery)"; if (dval == -9.9e99) { tstr += TString("??,"); } else { diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 13319df6..9701c9f7 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -161,9 +161,9 @@ bool PRunDataHandler::ReadFile() return false; // everything looks fine, hence try to read the data file if (!run_it->fFileFormat.CompareTo("root-npp")) // not post pile up corrected histos - success = ReadRootFile(); + success = ReadRootFile(true); else if (!run_it->fFileFormat.CompareTo("root-ppc")) // post pile up corrected histos - success = ReadRootFile(); + success = ReadRootFile(false); else if (!run_it->fFileFormat.CompareTo("nexus")) success = ReadNexusFile(); else if (!run_it->fFileFormat.CompareTo("psi-bin")) @@ -342,12 +342,15 @@ cout << endl << ">> generated path: " << str.Data() << endl; /** *

* + * \param notPostPileup This flag is used as a switch between "Not Post Pileup Corrected" + * and "Post Pileup Corrected" histogramms. */ -bool PRunDataHandler::ReadRootFile() +bool PRunDataHandler::ReadRootFile(bool notPostPileup) { PDoubleVector histoData; PRawRunData runData; +//cout << endl << ">> in ReadRootFile() ..."; TFile f(fRunPathName.Data()); if (f.IsZombie()) { return false; @@ -379,6 +382,7 @@ bool PRunDataHandler::ReadRootFile() // get implantation energy runData.fEnergy = runHeader->GetImpEnergy(); +//cout << endl << ">> runData.fEnergy = " << runData.fEnergy; // get setup runData.fSetup = runHeader->GetLemSetup().GetString(); @@ -408,38 +412,42 @@ bool PRunDataHandler::ReadRootFile() } // get all the data char histoName[32]; - // read first the data which are NOT post pileup corrected - for (int i=0; i(folder->FindObjectAny(histoName)); - if (!histo) { - cout << endl << "PRunDataHandler::ReadRootFile: Couldn't get histo " << histoName; - return false; + if (notPostPileup) { // read the data which are NOT post pileup corrected + for (int i=0; i> histoName = " << histoName; + TH1F *histo = dynamic_cast(folder->FindObjectAny(histoName)); + if (!histo) { + cout << endl << "PRunDataHandler::ReadRootFile: Couldn't get histo " << histoName; + return false; + } + // fill data + for (int j=1; jGetNbinsX(); j++) + histoData.push_back(histo->GetBinContent(j)); + // store them in runData vector + runData.fDataBin.push_back(histoData); + // clear histoData for the next histo + histoData.clear(); } - // fill data - for (int j=1; jGetNbinsX(); j++) - histoData.push_back(histo->GetBinContent(j)); - // store them in runData vector - runData.fDataBin.push_back(histoData); - // clear histoData for the next histo - histoData.clear(); - } - // now read the data which ARE post pileup corrected - for (int i=0; i(folder->FindObjectAny(histoName)); - if (!histo) { - cout << endl << "PRunDataHandler::ReadRootFile: Couldn't get histo " << histoName; - return false; + } else { // read the data which ARE post pileup corrected + for (int i=0; i> histoName = " << histoName; + TH1F *histo = dynamic_cast(folder->FindObjectAny(histoName)); + if (!histo) { + cout << endl << "PRunDataHandler::ReadRootFile: Couldn't get histo " << histoName; + return false; + } + // fill data + for (int j=1; jGetNbinsX(); j++) + histoData.push_back(histo->GetBinContent(j)); + // store them in runData vector + runData.fDataBin.push_back(histoData); + // clear histoData for the next histo + histoData.clear(); } - // fill data - for (int j=1; jGetNbinsX(); j++) - histoData.push_back(histo->GetBinContent(j)); - // store them in runData vector - runData.fDataBin.push_back(histoData); - // clear histoData for the next histo - histoData.clear(); } +//cout << endl; f.Close(); diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp index 847e4d6f..ef11ae2f 100644 --- a/src/classes/PRunListCollection.cpp +++ b/src/classes/PRunListCollection.cpp @@ -92,11 +92,11 @@ bool PRunListCollection::Add(int runNo, EPMusrHandleTag tag) { bool success = true; - PMsrRunStructure *runList = &(*fMsrInfo->GetMsrRunList())[runNo]; +// PMsrRunStructure *runList = &(*fMsrInfo->GetMsrRunList())[runNo]; - cout << endl << "PRunListCollection::Add(): will add run no " << runNo; - cout << ", name = " << runList->fRunName.Data(); - cout << ", type = " << runList->fFitType; +// cout << endl << "PRunListCollection::Add(): will add run no " << runNo; +// cout << ", name = " << runList->fRunName.Data(); +// cout << ", type = " << runList->fFitType; int fitType = (*fMsrInfo->GetMsrRunList())[runNo].fFitType; diff --git a/src/classes/PTheory.cpp b/src/classes/PTheory.cpp index 57864b1d..7c1298b2 100644 --- a/src/classes/PTheory.cpp +++ b/src/classes/PTheory.cpp @@ -185,7 +185,7 @@ PTheory::PTheory(PMsrHandler *msrInfo, unsigned int runNo, const bool hasParent) // if userFcn, the first entry is the function name and needs to be handled specially if ((fType == THEORY_USER_FCN) && ((i == 1) || (i == 2))) { -cout << endl << ">> userFcn: i=" << i << ", str=" << str.Data() << endl; +//cout << endl << ">> userFcn: i=" << i << ", str=" << str.Data() << endl; if (i == 1) { fUserFcnSharedLibName = str; } @@ -282,7 +282,7 @@ cout << endl << ">> userFcn: i=" << i << ", str=" << str.Data() << endl; // invoke user function object fUserFcn = 0; fUserFcn = (PUserFcnBase*)TClass::GetClass(fUserFcnClassName.Data())->New(); -cout << endl << ">> fUserFcn = " << fUserFcn << endl; +//cout << endl << ">> fUserFcn = " << fUserFcn << endl; if (fUserFcn == 0) { cout << endl << "**ERROR**: PTheory: user function object could not be invoked. See line no " << line->fLineNo; fValid = false; @@ -690,7 +690,7 @@ void PTheory::MakeCleanAndTidyTheoryBlock(PMsrLines *fullTheoryBlock) str.Resize(index); // tokenize line tokens = str.Tokenize(" \t"); -cout << endl << ">> #tokens=" << tokens->GetEntries() << ", str=" << str.Data(); +//cout << endl << ">> #tokens=" << tokens->GetEntries() << ", str=" << str.Data(); // make a handable string out of the asymmetry token ostr = dynamic_cast(tokens->At(0)); str = ostr->GetString(); @@ -765,7 +765,7 @@ void PTheory::MakeCleanAndTidyPolynom(unsigned int i, PMsrLines *fullTheoryBlock TObjString *ostr; char substr[256]; -cout << endl << ">> MakeCleanAndTidyPolynom: " << (*fullTheoryBlock)[i].fLine.Data(); +//cout << endl << ">> MakeCleanAndTidyPolynom: " << (*fullTheoryBlock)[i].fLine.Data(); // init tidy tidy = TString("polynom "); @@ -811,7 +811,7 @@ void PTheory::MakeCleanAndTidyUserFcn(unsigned int i, PMsrLines *fullTheoryBlock TObjArray *tokens = 0; TObjString *ostr; -cout << endl << ">> MakeCleanAndTidyUserFcn: " << (*fullTheoryBlock)[i].fLine.Data(); +//cout << endl << ">> MakeCleanAndTidyUserFcn: " << (*fullTheoryBlock)[i].fLine.Data(); // init tidy tidy = TString("userFcn "); @@ -1448,6 +1448,7 @@ double PTheory::Polynom(register double t, const PDoubleVector& paramValues, con */ double PTheory::UserFcn(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const { +/* static bool first = true; if (first) { cout << endl << ">> UserFcn: fParamNo.size()=" << fParamNo.size() << ", fUserParam.size()=" << fUserParam.size(); @@ -1456,6 +1457,7 @@ if (first) { } cout << endl; } +*/ // check if FUNCTIONS are used for (unsigned int i=0; i> t=" << t << ", function value=" << (*fUserFcn)(t, fUserParam); cout << endl; } - +*/ return (*fUserFcn)(t, fUserParam); } diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index 90346814..ba16e90d 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -62,7 +62,7 @@ class PRunDataHandler virtual bool ReadFile(); virtual bool FileAlreadyRead(PMsrRunStructure &runInfo); virtual bool FileExistsCheck(PMsrRunStructure &runInfo); - virtual bool ReadRootFile(); + virtual bool ReadRootFile(bool notPostPileup); virtual bool ReadNexusFile(); virtual bool ReadNemuFile(); virtual bool ReadPsiBinFile(); diff --git a/src/tests/fourier/PMusrFourier.cpp b/src/tests/fourier/PMusrFourier.cpp index 8b18cea9..896cf0c7 100644 --- a/src/tests/fourier/PMusrFourier.cpp +++ b/src/tests/fourier/PMusrFourier.cpp @@ -505,6 +505,7 @@ void PMusrFourier::ApodizeData(int apodizationTag) { switch (apodizationTag) { case F_APODIZATION_NONE: + return; break; case F_APODIZATION_WEAK: c[0] = cweak[0]+cweak[1]+cweak[2]; diff --git a/src/tests/fourier/fourier.cpp b/src/tests/fourier/fourier.cpp index 33972669..07c28573 100644 --- a/src/tests/fourier/fourier.cpp +++ b/src/tests/fourier/fourier.cpp @@ -185,7 +185,7 @@ cout << endl << "#bins=" << histo->GetNbinsX(); cout << endl << ">> Do you wish to apodize your data (y/n)? "; cin >> answer; - unsigned int apodizationTag=0; + unsigned int apodizationTag = F_APODIZATION_NONE; if (strstr(answer, "y")) { cout << endl << ">> apodization (1=weak, 2=medium, 3=strong, 4=user) = "; cin >> apodizationTag; diff --git a/src/tests/rootMinuit2Test/minuit2test.C b/src/tests/rootMinuit2Test/minuit2test.C index 1a6b4eb5..3d333046 100644 --- a/src/tests/rootMinuit2Test/minuit2test.C +++ b/src/tests/rootMinuit2Test/minuit2test.C @@ -78,17 +78,17 @@ void minuit2test() // set parameters gFitFcn->SetParNames("N0", "asym", "lambda", "B", "phase", "Bkg"); gFitFcn->SetParameter(0, 30.0); // N0 -// gFitFcn->SetParLimits(0, 0.0, 1.0e6); + gFitFcn->SetParLimits(0, 0.0, 1.0e6); gFitFcn->SetParameter(1, 0.26); // asym -// gFitFcn->SetParLimits(1, 0.0, 0.33); + gFitFcn->SetParLimits(1, 0.0, 0.33); gFitFcn->SetParameter(2, 0.3); // lambda -// gFitFcn->SetParLimits(2, 0.0, 100.0); + gFitFcn->SetParLimits(2, 0.0, 100.0); gFitFcn->SetParameter(3, 100.0); // B -// gFitFcn->SetParLimits(3, 0.0, 1000.0); + gFitFcn->SetParLimits(3, 0.0, 1000.0); gFitFcn->SetParameter(4, 0.0); // phase -// gFitFcn->SetParLimits(4, -90.0, 90.0); + gFitFcn->SetParLimits(4, -90.0, 90.0); gFitFcn->SetParameter(5, 5.0); // Bkg -// gFitFcn->SetParLimits(5, 0.0, 1000.0); + gFitFcn->SetParLimits(5, 0.0, 1000.0); cout << endl << "gFitFcn->Integral(0.0, 12.0) = " << gFitFcn->Integral(0.0, 12.0); cout << endl; @@ -100,9 +100,13 @@ void minuit2test() histo->Draw(); - gFitFcn->SetParameter(0, 150.0); // N0 - gFitFcn->SetParameter(5, 23.0); // Bkg + gFitFcn->SetParameter(0, 1000.0); // N0 + gFitFcn->SetParameter(1, 0.1); // asym + gFitFcn->SetParameter(2, 1.0); // lambda + gFitFcn->SetParameter(3, 50.0); // B + gFitFcn->SetParameter(4, 0.0); // phase + gFitFcn->SetParameter(5, 300.0); // Bkg TVirtualFitter::SetDefaultFitter("Minuit2"); - histo->Fit("gFitFcn", "L"); // L->likleyhood, E->minos + histo->Fit("gFitFcn", ""); // L->likleyhood, E->minos }