Skip to content
Snippets Groups Projects
Commit 42aff6ed authored by deserevi's avatar deserevi
Browse files

* Fix bug in RootInput class

   - First Root file was not treated
   - Last Root file was treated twice
parent 1aab6987
No related branches found
No related tags found
No related merge requests found
No preview for this file type
TTreeName
SimulatedTree
RootFileName
../../Outputs/Simulation/mySimul.root
../../Outputs/Simulation/mySimul_0.root
../../Outputs/Simulation/mySimul_1.root
../../Outputs/Simulation/mySimul_0.root
......@@ -51,55 +51,57 @@ void RootInput::Destroy()
// fileNameBase doit etre le nom du TChain.
RootInput::RootInput(string configFileName)
{
bool CheckTreeName = false ;
bool CheckRootFileName = false ;
bool CheckTreeName = false;
bool CheckRootFileName = false;
// Read configuration file Buffer
// Read configuration file Buffer
string lineBuffer, dataBuffer;
// Open file
ifstream inputConfigFile;
inputConfigFile.open(configFileName.c_str());
pRootChain = new TChain() ;
pRootChain = new TChain();
if(!inputConfigFile) { cout << "Run to Read file :" << configFileName << " 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;
// initialize pRootChain
pRootChain->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 && pRootChain)
{
inputConfigFile >> dataBuffer;
while (!inputConfigFile.eof())
{
inputConfigFile >> dataBuffer;
pRootChain->Add(dataBuffer.c_str());
CheckRootFileName = true ;
}
}
}
}
cout << "/////////////////////////////////" << endl;
cout << "Initializing input TChain" << endl;
if (!inputConfigFile) {
cout << "Run to Read file :" << configFileName << " 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;
// initialize pRootChain
pRootChain->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 && pRootChain) {
CheckRootFileName = true ;
while (!inputConfigFile.eof()) {
inputConfigFile >> dataBuffer;
if (!inputConfigFile.eof()) {
pRootChain->Add(dataBuffer.c_str());
cout << "Adding file " << dataBuffer << " to TChain" << endl;
}
}
}
}
}
if(!CheckRootFileName || !CheckTreeName) cout << "WARNING: Token not found for InputTree Declaration : Input Tree may not be instantiate properly" << endl ;
if (!CheckRootFileName || !CheckTreeName)
cout << "WARNING: Token not found for InputTree Declaration : Input Tree may not be instantiate properly" << endl;
cout << "/////////////////////////////////" << endl;
}
......
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