Skip to content

Commit

Permalink
Merge pull request #4 from gemc-eic/rsh_userHeader
Browse files Browse the repository at this point in the history
userHeader handling. Tested on BST evio output, produced identical results on bst bank and header bank.
  • Loading branch information
maureeungaro authored Nov 20, 2018
2 parents a92f792 + 09806a9 commit cb0729d
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 26 deletions.
111 changes: 89 additions & 22 deletions src/banks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,95 @@ map<string, double> getHeaderBank(evioDOMTree& EDT, gBank bank, double verbosity



return thisBank;
}

vector<string> getUserHeaderBankNames(evioDOMTree& EDT, gBank bank, double verbosity)
{
// Examine data to find out how many variables in userHeader bank and construct list of names

vector<string> names;
unsigned long sizeOfBank = 0;

evioDOMNodeListP thisBankNode = EDT.getNodeList(tagNumEquals(bank.idtag, 0));

for(evioDOMNodeList::const_iterator iter=thisBankNode->begin(); iter!=thisBankNode->end(); iter++)
{
const evioDOMNodeP node = *iter;
if(node->isContainer())
{
evioDOMNodeList *variablesNodes = node->getChildList();
for(evioDOMNodeList::const_iterator cIter=variablesNodes->begin(); cIter!=variablesNodes->end(); cIter++)
{
const evioDOMNodeP variable = *cIter;
unsigned vnum = variable->num;
if (variable->isLeaf() && sizeOfBank < vnum)
{
sizeOfBank = vnum;
}
}
}
}

for (unsigned i = 0; i < sizeOfBank; ++i)
{
string tmp = "userVar" ;
if(i<9) tmp +="00";
else if (i<99) tmp +="0";

tmp += to_string(i+1);
names.push_back (tmp);
}

if (verbosity > 0)
{
cout << "getUserHeaderBankNames" << endl;
for (vector<string>::iterator it = names.begin(); it != names.end(); it++)
{
cout << " > " << (*it) << endl;
}
cout << endl;
}

return names;
}

map<string, double> getUserHeaderBank(evioDOMTree& EDT, gBank bank, vector<string> names, double verbosity)
{
map<string, double> thisBank;

evioDOMNodeListP thisBankNode = EDT.getNodeList(tagNumEquals(bank.idtag, 0));

for(evioDOMNodeList::const_iterator iter=thisBankNode->begin(); iter!=thisBankNode->end(); iter++)
{
const evioDOMNodeP node = *iter;
if(node->isContainer())
{
evioDOMNodeList *variablesNodes = node->getChildList();
for(evioDOMNodeList::const_iterator cIter=variablesNodes->begin(); cIter!=variablesNodes->end(); cIter++)
{
const evioDOMNodeP variable = *cIter;
int vnum = variable->num;
if (variable->isLeaf())
{
const vector<double> *vec = (*cIter)->getVector<double>();
thisBank[names[vnum-1]] = (*vec)[0];
}
}
}
}

if(verbosity > 0)
{
for(map<string, double>::iterator it = thisBank.begin(); it != thisBank.end(); it++)
{
cout << " > " << it->first << ": " << it->second << endl;
}
cout << endl;
}



return thisBank;
}

Expand Down Expand Up @@ -447,25 +536,3 @@ Mevent::Mevent(evioDOMTree& EDT, vector<string> hitTypes, map<string, gBank> *ba
}
























2 changes: 2 additions & 0 deletions src/banks.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ gBank getBank(gBank bank, double verbosity);

// normal banks are just containers of leafs
map<string, double> getHeaderBank(evioDOMTree& EDT, gBank bank, double verbosity);
vector<string> getUserHeaderBankNames(evioDOMTree& EDT, gBank bank, double verbosity);
map<string, double> getUserHeaderBank(evioDOMTree& EDT, gBank bank, vector<string> names, double verbosity);

// integrated raw and digitized banks
vector<hitOutput> getRawIntDataBank(evioDOMTree& EDT, string hitType, map<string, gBank> *banksMap, double verbosity);
Expand Down
32 changes: 28 additions & 4 deletions src/evio2root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv)
allSystems[whichSystems[b]] = factories;

map<string, gBank> banksMap = read_banks(gemcOpt, allSystems);

// selecting input, output file
string inputfile = gemcOpt.optMap["INPUTF"].args ;

Expand All @@ -91,7 +91,12 @@ int main(int argc, char **argv)
else
rTrees["header"].addVariable(banksMap["header"].name[i], "Nd");
}


// user bank definitions
// can't add variables until we see the bank size
rTrees["userHeader"] = rTree(banksMap["userHeader"].bankName, banksMap["userHeader"].bdescription, verbosity);
vector<string> userHeaderNames;

// generated bank definitions
rTrees["generated"] = rTree(banksMap["generated"].bankName, banksMap["generated"].bdescription, verbosity);
for(unsigned i=0; i<banksMap["generated"].name.size(); i++)
Expand All @@ -100,7 +105,7 @@ int main(int argc, char **argv)

// hit banks definitions
for(map<string, gBank>::iterator it = banksMap.begin(); it != banksMap.end(); it++) {
if(it->first != "header" && it->first != "generated" && it->first != "raws" && it->first != "psummary") {
if(it->first != "header" && it->first != "userHeader" && it->first != "generated" && it->first != "raws" && it->first != "psummary") {
rTrees[it->first] = rTree(banksMap[it->first].bankName, banksMap[it->first].bdescription, verbosity);
for(unsigned i=0; i<banksMap[it->first].name.size(); i++)
{
Expand Down Expand Up @@ -168,6 +173,25 @@ int main(int argc, char **argv)
rTrees["header"].fill();
}

// userHeader
else if (it->first == "userHeader") {
if (userHeaderNames.size() == 0)
{
userHeaderNames = getUserHeaderBankNames (EDT, getBankFromMap("userHeader", &banksMap), 0);
for (vector<string>::iterator it = userHeaderNames.begin(); it != userHeaderNames.end(); it++)
{
rTrees["userHeader"].addVariable(*it, "Nd");
}
}
map<string, double> userHeaderBank = getUserHeaderBank(EDT, getBankFromMap("userHeader", &banksMap), userHeaderNames, 0);
rTrees["userHeader"].init();

for(map<string, double>::iterator userHead_it = userHeaderBank.begin(); userHead_it != userHeaderBank.end(); userHead_it++) {

rTrees["userHeader"].insertVariable(userHead_it->first, "Nd", userHead_it->second);
}
rTrees["userHeader"].fill();
}


// generated particles
Expand All @@ -193,7 +217,7 @@ int main(int argc, char **argv)

// hit banks
else if(it->first != "psummary" && it->first != "raws") {
vector<hitOutput> dgtHits = getDgtIntDataBank(EDT, it->first, &banksMap, verbosity);
vector<hitOutput> rawHits = getRawIntDataBank(EDT, it->first, &banksMap, verbosity);

Expand Down

0 comments on commit cb0729d

Please sign in to comment.