Skip to content
Snippets Groups Projects
Commit 83a85496 authored by deserevi's avatar deserevi
Browse files

merge of '32454d3855766c236aa73ae44094ef8af2f4a280'

     and '93d3ec1ada470cea68417892976ee6548fa3a7bc'
parents 18686e73 057597a3
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
*****************************************************************************/
#include <iostream>
#include <sstream>
#include <fstream>
#include <limits>
......@@ -48,10 +49,10 @@ void RootInput::Destroy()
}
}
// fileNameBase doit etre le nom du TChain.
RootInput::RootInput(string configFileName)
{
NumberOfFriend = 0;
bool CheckTreeName = false;
bool CheckRootFileName = false;
......@@ -110,7 +111,75 @@ RootInput::RootInput(string configFileName)
cout << "/////////////////////////////////" << endl;
}
void RootInput::AddFriendChain( string RunToAdd)
{
NumberOfFriend++;
ostringstream suffix_buffer;
suffix_buffer << "_" << NumberOfFriend ;
string suffix = suffix_buffer.str();
bool CheckTreeName = false;
bool CheckRootFileName = false;
// Read configuration file Buffer
string lineBuffer, dataBuffer;
// Open file
ifstream inputConfigFile;
inputConfigFile.open(RunToAdd.c_str());
TChain* localChain = new TChain();
cout << "/////////////////////////////////" << endl;
cout << "Adding frien to current TChain" << endl;
if (!inputConfigFile) {
cout << "Run to Add file :" << RunToAdd << " not found " << endl;
return;
}
else {
while (!inputConfigFile.eof()) {
getline(inputConfigFile, lineBuffer);
// search for token giving the TTree name
if (lineBuffer.compare(0, 9, "TTreeName") == 0) {
inputConfigFile >> dataBuffer;
// adding suffix to insure uniquity of the chain name
dataBuffer+suffix;
// initialize localChain
localChain->SetName(dataBuffer.c_str());
CheckTreeName = true ;
}
// search for token giving the list of Root files to treat
else if (lineBuffer.compare(0, 12, "RootFileName") == 0 && localChain) {
CheckRootFileName = true ;
while (!inputConfigFile.eof()) {
inputConfigFile >> dataBuffer;
// ignore comment Line
if (dataBuffer.compare(0, 1, "%") == 0) {
inputConfigFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
else if (!inputConfigFile.eof()) {
localChain->Add(dataBuffer.c_str());
cout << "Adding file " << dataBuffer << " to TChain" << endl;
}
}
}
}
}
if (!CheckRootFileName || !CheckTreeName)
cout << "WARNING: Token not found for InputTree Declaration : Input Tree has not be Added to the current Chain" << endl;
else
pRootChain->AddFriend( localChain->GetName() );
cout << "/////////////////////////////////" << endl;
}
RootInput::~RootInput()
{
......
......@@ -64,10 +64,15 @@ private:
static RootInput* instance;
public:
// Return the private chain
TChain* GetChain() {return pRootChain;};
// Add a Friend chain to the input chain
void AddFriendChain( string RunToAdd);
private:
TChain *pRootChain;
int NumberOfFriend;
};
#endif // ROOTINPUT_HH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment