Newer
Older
#include <iostream>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <TStopwatch.h>
#include <boost/shared_ptr.hpp>
#include "Examples/MATpbarpToOmegaPi/OmegaPiEventList.hh"
#include "Examples/MATpbarpToOmegaPi/OmegaPiHist.hh"
#include "Examples/MATpbarpToOmegaPi/OmegaPiData.hh"
#include "Examples/MATpbarpToOmegaPi/pbarpToOmegaPi0States.hh"
#include "Examples/MATpbarpToOmegaPi/OmegaPiLh.hh"
#include "Examples/MATpbarpToOmegaPi/MOmegaPiFcn.hh"
#include "Setup/PwaEnv.hh"
#include "Particle/ParticleTable.hh"
#include "Particle/Particle.hh"
#include "Event/EventList.hh"
#include "Event/Event.hh"
#include "Event/CBElsaReader.hh"
#include "Particle/PdtParser.hh"
#include "qft++/topincludes/tensor.hh"
#include "ErrLogger/ErrLogger.hh"
//#include "Minuit2/MnUserParameters.h"
//#include "Minuit2/MnMigrad.h"
//#include "Minuit2/FunctionMinimum.h"
//#include "Minuit2/MnMinos.h"
//#include "Minuit2/MnStrategy.h"
#include "Examples/MATpbarpToOmegaPi/PwaIntMinuit.hh"
//#include "Minuit2/MnUserTransformation.h"
using namespace ROOT::Minuit2;
int main(int __argc,char *__argv[]){
TStopwatch timer;
timer.Start();
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
if( __argc>1 && ( strcmp( __argv[1], "-help" ) == 0
|| strcmp( __argv[1], "--help" ) == 0 ) ){
Info << "This application is a PWA fit for the reaction\n\n"
<< "pbar p -> omega + pi0 ; omega -> pi0 + gamma\n\n"
<< "It makes use of the Helicity Formalism\n"
<< "The fit determines the content of the initial states formed via the pbar p reaction "
<< "and the content of the LS combinations for the dacay to omega pi0\n\n"
<< "For the steering of the application one can use the following flags\n"
<< "-jmax: maximum spin concidering in the fit (default 3)\n"
<< "-pbarmom: pbar momentum of the input data (available so far: 600, 1940) (default 600)\n"
<< "-msg <errorLogMode> you can choose the mode for the error logger\n\n"
<< "i.e. with './MpbarpToOmegaPiApp -jmax 5 -pbarmom 1940 -msg debugging' you start the fit with jmax=3, reconstructed data and MCs at 1940 MeV/c in the debugging mode for the error logger\n"
<< endmsg;
return 0;
}
std::string msgModeStr="default";
std::string jmaxStr="3";
std::string pbarmomStr="600";
// decode arguments
while ((optind < (__argc-1) ) && (__argv[optind][0]=='-')) {
bool found=false;
std::string sw = __argv[optind];
if (sw=="-msg"){
optind++;
msgModeStr = __argv[optind];
found=true;
}
if (sw=="-jmax"){
optind++;
jmaxStr = __argv[optind];
found=true;
}
if (sw=="-pbarmom"){
optind++;
pbarmomStr = __argv[optind];
found=true;
}
if (!found){
Warning << "Unknown switch: "
<< __argv[optind] << endmsg;
optind++;
}
while ( (optind < __argc ) && __argv[optind][0]!='-' ) optind++;
}
if(msgModeStr == "debugging") ErrLogger::instance()->setLevel(log4cpp::Priority::DEBUG);
else if(msgModeStr == "trace") ErrLogger::instance()->setLevel(log4cpp::Priority::INFO);
else if(msgModeStr == "routine") ErrLogger::instance()->setLevel(log4cpp::Priority::INFO);
else if(msgModeStr == "warning") ErrLogger::instance()->setLevel(log4cpp::Priority::WARN);
else if(msgModeStr == "error") ErrLogger::instance()->setLevel(log4cpp::Priority::ERROR);
else {
ErrLogger::instance()->setLevel(log4cpp::Priority::DEBUG);
Warning << "ErrorLogger not (properly) set -> Use mode 'DEBUG' " << endmsg;
}
std::stringstream jmaxStrStr(jmaxStr);
std::stringstream pbarmomStrStr(pbarmomStr);
unsigned jMax=3;
jmaxStrStr >> jMax;
unsigned pbarMom=600;
pbarmomStrStr >> pbarMom;
Info << "Maximum spin content: " << jMax << endmsg;
Info << "pbar momentum: " << pbarMom << endmsg;
std::string theSourcePath=getenv("CMAKE_SOURCE_DIR");
std::string piomegaDatFile;
std::string piomegaMcFile;
if(pbarMom==600){
piomegaDatFile=theSourcePath+"/Examples/pbarpToOmegaPi/data/510_0600.dat";
piomegaMcFile=theSourcePath+"/Examples/pbarpToOmegaPi/data/mc510_0600.dat";
}
else if (pbarMom==1940){
piomegaDatFile=theSourcePath+"/Examples/pbarpToOmegaPi/data/510_1940.dat";
piomegaMcFile=theSourcePath+"/Examples/pbarpToOmegaPi/data/mc510_1940.dat";
}
else{
Alert <<"data for pbarMom= " << pbarMom << "not available; use 600 or 1940!!!" << endmsg;
exit(1);
}
Info << "data file: " << piomegaDatFile << endmsg;
Info << "mc file: " << piomegaMcFile << endmsg;
ParticleTable pTable;
PdtParser parser;
std::string pdtFile(theSourcePath+"/Particle/pdt.table");
if (!parser.parse(pdtFile, pTable)) {
Alert << "Error: could not parse " << pdtFile << endmsg;
exit(1);
}
std::vector<std::string> fileNames;
fileNames.push_back(piomegaDatFile);
CBElsaReader eventReader(fileNames, 3, 0);
EventList piOmegaEventsData;
eventReader.fillAll(piOmegaEventsData);
if (!piOmegaEventsData.findParticleTypes(pTable))
Warning << "could not find all particles" << endmsg;
Info << "\nFile has " << piOmegaEventsData.size() << " events. Each event has "
<< piOmegaEventsData.nextEvent()->size() << " final state particles.\n" << endmsg;
piOmegaEventsData.rewind();
Event* anEvent;
int evtCount = 0;
while ((anEvent = piOmegaEventsData.nextEvent()) != 0 && evtCount < 20) {
Info << "\n"
<< *(anEvent->p4(0)) << "\tm = " << anEvent->p4(0)->Mass() << "\n"
<< *(anEvent->p4(1)) << "\tm = " << anEvent->p4(1)->Mass() << "\n"
<< *(anEvent->p4(2)) << "\tm = " << anEvent->p4(2)->Mass() << "\n"
<< endmsg;
++evtCount;
}
piOmegaEventsData.rewind();
std::vector<std::string> fileNamesMc;
fileNamesMc.push_back(piomegaMcFile);
CBElsaReader eventReaderMc(fileNamesMc, 3, 0);
EventList piOmegaEventsMc;
eventReaderMc.fillAll(piOmegaEventsMc);
piOmegaEventsMc.rewind();
//boost::shared_ptr<const OmegaPiEventList> theOmegaPiEventPtr(new OmegaPiEventList(piOmegaEventsData, piOmegaEventsMc, jMax, pbarMom));
boost::shared_ptr<OmegaPiEventList> theOmegaPiEventPtr = OmegaPiEventList::getList(piOmegaEventsData, piOmegaEventsMc, jMax, pbarMom);
boost::shared_ptr<pbarpStates> pbarpStatesPtr(new pbarpStates(jMax));
//boost::shared_ptr<pbarpToOmegaPi0States> pbarpToOmegaPi0StatesPtr(new pbarpToOmegaPi0States(pbarpStatesPtr));
boost::shared_ptr<pbarpToOmegaPi0States> pbarpToOmegaPi0StatesPtr = pbarpToOmegaPi0States::getStates(pbarpStatesPtr);
boost::shared_ptr<OmegaPiLh> theOmegaLhPtr(new OmegaPiLh(pbarpToOmegaPi0StatesPtr));
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// get pbarpToOmegaPi0States pointer back
boost::shared_ptr<const pbarpToOmegaPi0States> theOmegaPi0StatesPtr=theOmegaLhPtr->omegaPi0States();
theOmegaPi0StatesPtr->print(std::cout);
MOmegaPiFcn mOmegaPiFcn(theOmegaLhPtr);
/*MnUserParameters upar;
mOmegaPiFcn.setMnUsrParams(upar);
MnMigrad migrad(mOmegaPiFcn, upar);
Info <<"start migrad "<< endmsg;
FunctionMinimum min = migrad();
if(!min.IsValid()) {
//try with higher strategy
Info <<"FM is invalid, try with strategy = 2."<< endmsg;
MnMigrad migrad2(mOmegaPiFcn, min.UserState(), MnStrategy(2));
min = migrad2();
}
MnUserParameters finalUsrParameters=min.UserParameters();
const std::vector<double> finalParamVec=finalUsrParameters.Params();*/
PwaIntMinuit test;
cout << "bla" << endl;
const std::vector<double> finalParamVec=test.exec(&mOmegaPiFcn);
OmegaPiData::fitParamVal finalFitParams;
mOmegaPiFcn.setFitParamVal(finalFitParams, finalParamVec);
OmegaPiHist theHistogrammer(theOmegaLhPtr, finalFitParams);
// OmegaPiHist theHistogrammer(theOmegaPiEventPtr);
timer.Stop();
Info << "Real time: " << timer.RealTime() << " s, CPU time: " << timer.CpuTime() << " s\a\a\n";