24 const std::string& outStem =
"");
26 bool makeDir(
const std::string& dirName);
27 void Copy(TFile*
source, TFile*
target,
const std::string& inDir,
const std::string& outDir,
28 const std::string& inHist =
"",
const std::string&
outHist =
"");
30 const std::string& inHist,
const std::string&
outHist);
34 std::string stream_ref =
"physics_MinBias";
35 int stream_check = -1;
36 stream_check = inFilename.find(stream_ref);
39 TFile*
f = TFile::Open(inFilename.c_str(),
"UPDATE");
40 if (
f == 0 || !
f->IsOpen()) {
44 if (
f->GetSize() < 1000.) {
49 bool dirExists =
false;
54 bool IsFirstTime =
true;
55 std::string AthenaTAG;
63 std::string out_inStem;
65 std::string out_LOCAL;
66 std::string out_outStem;
68 TIter run_keys(
f->GetListOfKeys());
69 TIter lb_keys(
f->GetListOfKeys());
72 while ((key_run =
dynamic_cast<TKey*
>(run_keys())) != 0) {
73 TObject* obj_run = key_run->ReadObj();
74 TDirectory* tdir_run =
dynamic_cast<TDirectory*
>(obj_run);
76 std::string tdir_run_name(tdir_run->GetName());
77 if (tdir_run_name.find(
"run") != std::string::npos) {
78 run_dir = tdir_run_name;
79 out_EOS =
"root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/perf-idtracking/VertexMonitoring/VxMon_" +
80 run_dir +
"_" + AthenaTAG +
".root";
81 out_LOCAL =
"VxMon_" + run_dir +
"_" + AthenaTAG +
".root";
83 lb_keys = tdir_run->GetListOfKeys();
84 while ((key_lb =
dynamic_cast<TKey*
>(lb_keys())) != 0) {
85 TObject* obj_lb = key_lb->ReadObj();
86 TDirectory* tdir_lb =
dynamic_cast<TDirectory*
>(obj_lb);
89 std::string tdir_lb_name(tdir_lb->GetName());
91 if (tdir_lb_name.find(
"lb") != std::string::npos) {
92 lb_dir = tdir_lb_name;
94 dirExists =
f->GetDirectory(run_dir +
"/" + lb_dir +
"/InDetGlobal/PrimaryVertexMultiplicity");
96 out_inStem = run_dir +
"/" + lb_dir +
"/InDetGlobal/PrimaryVertexMultiplicity/nVx";
97 out_outStem =
"nVx_" + lb_dir;
99 writeEOS =
updateHists(inFilename, out_inStem, out_EOS, out_outStem);
100 if (writeEOS != 0 && IsFirstTime) writeLOCAL =
updateHists(inFilename, out_inStem, out_LOCAL,
103 writeLOCAL =
updateHists(inFilename, out_inStem, out_LOCAL, out_outStem);
106 if (writeEOS != 0 && !IsFirstTime && writeLOCAL != 0) {
111 if (writeEOS != 0 && writeLOCAL != 0) {
124 if (writeEOS != 0 && writeLOCAL == 0) {
125 int return_code = system(
126 "xrdcp VxMon_" + run_dir +
"_" + AthenaTAG +
".root root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/perf-idtracking/VertexMonitoring/VxMon_" + run_dir +
"_" + AthenaTAG +
150 const std::string& stem) {
152 std::string outStem = stem;
162 std::string
path = inStem;
165 if (inStem[inStem.size() - 1] !=
'/') {
166 std::string::size_type lastSlash = inStem.find_last_of(
'/');
167 hist = inStem.substr(lastSlash + 1, inStem.size() - lastSlash - 1);
168 path = inStem.substr(0, lastSlash + 1);
169 isDir = (
source->FindObjectAny(
hist.c_str()))->InheritsFrom(
"TDirectory");
195 if (outStem.empty()) outStem = inStem;
196 std::string targetPath = outStem;
197 std::string targetHist;
199 std::string::size_type lastSlash = outStem.find_last_of(
'/');
200 targetPath = outStem.substr(0, lastSlash + 1);
201 targetHist = outStem.substr(lastSlash + 1, outStem.size() - lastSlash - 1);
204 if (targetPath[targetPath.size() - 1] ==
'/') targetPath.resize(targetPath.size() - 1);
212 if (!
target->IsWritable())
return 1;
224 if (!dirName.empty()) {
225 std::string::size_type firstSlash = dirName.find(
'/');
226 if (firstSlash == std::string::npos) {
229 std::string
subdir(dirName, 0, firstSlash);
232 std::string newSubdir(dirName, firstSlash + 1, dirName.size() - firstSlash);
241 std::cout << std::setw(
padding) <<
" ";
253 void Copy(TFile*
source, TFile*
target,
const std::string& inDir,
const std::string& outDir,
254 const std::string& inHist,
const std::string&
outHist) {
257 if (!inHist.empty()) {
260 TDirectory* sourceDir =
source->GetDirectory(inDir.c_str());
261 TDirectory* targetDir =
target->GetDirectory(outDir.c_str());
263 TIter nextKey(sourceDir->GetListOfKeys());
266 while ((
key = (TKey*) nextKey())) {
271 std::string newInDir = inDir;
275 std::string newOutDir = outDir;
279 if (!targetDir->FindKey(
keyName.c_str())) {
284 targetDir->mkdir(
keyName.c_str());
301 const std::string& inHist,
const std::string&
outHist) {
302 TDirectory* sourceDir =
source->GetDirectory(inDir.c_str());
303 TDirectory* targetDir =
target->GetDirectory(outDir.c_str());
306 TKey*
key = sourceDir->FindKey(inHist.c_str());
307 TObject*
object =
key->ReadObj();
308 bool permission =
true;
310 if (targetDir->FindKey(
outHist.c_str())) permission =
false;
311 if (permission)
object->Write(
outHist.c_str(), TObject::kOverwrite);