1031 cout<<
"setupAnalysis"<<endl;
1036 unsigned int i=0,j=0;
1038 std::vector<int> daupdgs;
1039 unsigned int daucnt=0;
1040 unsigned int daulistcnt=0;
1043 unsigned int linecnt=0;
1048 bool defineOpen=
false;
1049 bool decaySet=
false;
1058 while (!cfgFile.eof()) {
1059 cfgFile.getline(line,200);
1065 char* token = tokenizer.
GetFirst(line,
" \t");
1068 tokenVec.push_back(token);
1069 token=tokenizer.
GetNext(
" \t");
1072 if (tokenVec.size()==0) {
continue; }
1079 if (tokenVec[0]==
"DefineList") {
1106 if (tokenVec[0]==
"decayMode") {
1115 for (i=3; i<tokenVec.size(); i++) {
1119 daucnt=daupdgs.size();
1132 if (tokenVec[0]==
"daughterList") {
1140 if (daulistcnt>daucnt) {
return ErrorMessage(302,linecnt); }
1143 if (tokenVec[1]==
"McTruth") {
return ErrorMessage(305,linecnt); }
1145 std::string dName=tokenVec[1];
1146 bool isgeneric=
false;
1154 if (dName==
"Charged")
1155 switch (abs(daupdgs[daulistcnt])) {
1157 dName=
"ElectronVeryLoose";
1160 dName=
"MuonVeryLoose";
1163 dName=
"PionVeryLoose";
1166 dName=
"KaonVeryLoose";
1169 dName=
"ProtonVeryLoose";
1173 float charge=TDatabasePDG::Instance()->GetParticle(daupdgs[daulistcnt])->Charge();
1174 if (charge<-0.1) { dName+=
"M"; }
1175 else if (charge>0.1) { dName+=
"P"; }
1187 int decpdg=daupdgs[daulistcnt];
1192 if (decpdg!=listpdg && decpdg!=alistpdg) {
return ErrorMessage(304,linecnt); }
1197 if (decpdg==listpdg) {
1198 currentList->
fDauIdx.push_back(idx);
1199 }
else if (decpdg==alistpdg) {
1213 if (tokenVec[0]==
"End" || tokenVec[0]==
"EndDefine") {
1217 if (!decaySet || daucnt<2 || daulistcnt!=daucnt) {
return ErrorMessage(400,linecnt); }
1228 std::vector<int> finstate;
1229 std::vector<int> ccstate;
1233 for (i=0; i<daulistcnt; i++) {
1237 finstate.push_back(idx);
1238 ccstate.push_back(ccidx);
1246 std::sort(finstate.begin(),finstate.end());
1247 std::sort(ccstate.begin(),ccstate.end());
1251 cout <<currentList->
fName<<
" : list indices of list and cc : ";
1252 for (i=0; i<finstate.size(); i++) {
1253 cout <<
"( "<<finstate[
i]<<
" , "<<ccstate[
i]<<
" ) ";
1254 if (finstate[i]!=ccstate[i]) { hasAnti=
true; }
1262 std::string aName=currentList->
fName+
"_A";
1272 for (i=0; i<ccstate.size(); i++) {
1276 currentAntiList->
fDauIdx.push_back(ccidx);
1287 currentAntiList->
fCharge=charge;
1289 currentAntiList->
fIsUsed=
true;
1308 if (tokenVec[0]==
"pbarMom") {
1311 double p = atof(tokenVec[1].c_str());
1312 double mp = 0.938272;
1313 double E =
sqrt(mp*mp+p*p)+
mp;
1315 fpInit.SetXYZT(0.0,0.0,p,E);
1318 if (tokenVec[0]==
"Ecms") {
1321 double M = atof(tokenVec[1].c_str());
1322 double mp = 0.938272;
1324 double X = (M*M-2*mp*
mp)/(2*mp);
1325 double p =
sqrt(X*X-mp*mp);
1326 double E =
sqrt(mp*mp+p*p)+
mp;
1328 fpInit.SetXYZT(0.0,0.0,p,E);
1350 if (tokenVec[0]==
"dumpList") {
1352 if (defineOpen && tokenVec.size()<2) {
return ErrorMessage(501,linecnt); }
1355 if (!defineOpen && tokenVec.size()<3) {
return ErrorMessage(502,linecnt); }
1359 unsigned int startcols=2;
1361 std::string dName=tokenVec[1];
1366 if (dName==
"Charged") { dName=
"PionVeryLoose"; }
1386 currentList->
fColName=tokenVec[startcols-1];
1388 if (tokenVec.size()==startcols) {
1389 tokenVec.push_back(
"p4");
1390 tokenVec.push_back(
"ch");
1391 tokenVec.push_back(
"m");
1394 for (i=startcols; i<tokenVec.size(); i++) {
1395 std::string
col=tokenVec[
i];
1398 cout <<
"-W- PndSimpleAnalysis::SetupAnalysis: In '"<<
fCfgFileName
1399 <<
"', line "<<linecnt<<
": ";
1400 cout <<
"Unknown column name '"<<col<<
"'."<<endl;
1408 if (key==520 || key==521) {
continue; }
1411 if (key>=150 && key<=154) {
continue; }
1414 if (key>=501 && key<=505) {
continue; }
1419 for (j=0; j<keylist.size(); j++) { tokenVec.push_back(keylist[j]); }
1421 }
else if (key<500) { currentList->
fNtpFNames.push_back(col); }
1422 else { currentList->
fNtpINames.push_back(col); }
1426 if (dName==
"McTruth") {
1436 if (tokenVec[0]==
"histogram") {
1444 mass=TDatabasePDG::Instance()->GetParticle(currentList->
fPdgCode)->Mass();
1447 if (tokenVec.size()==2) {
1448 width=atof(tokenVec[1].c_str());
1451 double min=mass - width;
1452 double max=mass + width;
1454 if (tokenVec.size()==3) {
1455 double num1=atof(tokenVec[1].c_str());
1456 double num2=atof(tokenVec[2].c_str());
1457 if (num1<num2) {min=num1; max=num2;}
1458 else {min=num2; max=num1;}
1461 std::string hname=currentList->
fName+
"_M";
1462 std::string htitle=currentList->
fName+
" mass";
1464 TH1F*
h=
new TH1F(hname.c_str(),htitle.c_str(),100,
min,
max);
1465 currentList->
fHisto.push_back(h);
1471 if (tokenVec[0]==
"select") {
1474 if (tokenVec[1]==
"Mass") {
1476 if (currentList->
fPdgCode==0 && tokenVec.size()<4) {
1480 double mean=TDatabasePDG::Instance()->GetParticle(currentList->
fPdgCode)->Mass();
1484 if (tokenVec.size()==3) {
1485 width=atof(tokenVec[2].c_str());
1488 if (tokenVec.size()>3) {
1489 mean=atof(tokenVec[2].c_str());
1490 width=atof(tokenVec[3].c_str());
1504 std::map<std::string, int> colMap;
1510 if (0==
ntp) {
ntp=
new TTree(
"ntp",
"PndSimpleAnalysis NTuple"); }
1511 std::string pre=currentList->
fColName;
1513 int nd=currentList->
GetNDau();
1516 if (nd>0) { currentList->
fNtpINames.push_back(
"d1"); }
1517 if (nd>1) { currentList->
fNtpINames.push_back(
"d2"); }
1518 if (nd>2) { currentList->
fNtpINames.push_back(
"d3"); }
1519 if (nd>3) { currentList->
fNtpINames.push_back(
"d4"); }
1520 if (nd>4) { currentList->
fNtpINames.push_back(
"d5"); }
1522 for (i=0; i<currentList->
fNtpFNames.size(); i++) {
1526 if (nd>0) { currentList->
fNtpFNames.push_back(
"d1m"); }
1527 if (nd>1) { currentList->
fNtpFNames.push_back(
"d2m"); }
1528 if (nd>2) { currentList->
fNtpFNames.push_back(
"d3m"); }
1529 if (nd>3) { currentList->
fNtpFNames.push_back(
"d4m"); }
1530 if (nd>4) { currentList->
fNtpFNames.push_back(
"d5m"); }
1536 std::string brname=
"n"+pre;
1537 if (colMap.find(brname)!=colMap.end()) {
return ErrorMessage(504,0,brname); }
1541 ntp->Branch(brname.c_str(),&(currentList->
fNEntries),(brname+
"/I").c_str());
1544 for (i=0; i<currentList->
fNtpFNames.size(); i++) {
1547 if (colMap.find(brname)!=colMap.end()) {
return ErrorMessage(504,0,brname); }
1553 ntp->Branch(brname.c_str(),currentList->
fNtpFArrays[
i],(brname+
"[n"+pre+
"]/F").c_str());
1557 for (i=0; i<currentList->
fNtpINames.size(); i++) {
1560 if (colMap.find(brname)!=colMap.end()) {
return ErrorMessage(504,0,brname); }
1565 ntp->Branch(brname.c_str(), currentList->
fNtpIArrays[
i], (brname+
"[n"+pre+
"]/I").c_str());
int GetPdgCode(std::string name)
int GetAntiPdgCode(std::string name)
std::vector< TH1F * > fHisto
std::vector< std::string > fNtpINames
friend F32vec4 sqrt(const F32vec4 &a)
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
bool IsGenericListName(std::string n)
std::vector< float * > fNtpFArrays
std::map< int, std::vector< std::string > > fColShortKeyMap
char * GetFirst(char *lpsz, const char *lpcszDelimiters)
std::vector< int > fDauIdx
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
bool ErrorMessage(int mid, int line=0, std::string arg="")
std::map< std::string, int > fColKeyMap
std::vector< int * > fNtpIArrays
char * GetNext(const char *lpcszDelimiters)
std::vector< std::string > ArgVector
std::vector< std::string > fNtpFNames
std::vector< RhoParticleSelectorBase * > fSelector
std::map< std::string, int > fListMap
std::vector< PndListDefiner * > fListDefiners