5 |
* The file contains implementation of the methods to query the DB. |
* The file contains implementation of the methods to query the DB. |
6 |
*/ |
*/ |
7 |
// |
// |
|
#include <sstream> |
|
|
#include <iostream> |
|
|
// |
|
|
#include <TFile.h> |
|
|
#include <TTree.h> |
|
|
#include <TTimeStamp.h> |
|
|
#include <TTreeCloner.h> |
|
8 |
#include <RunGlue.h> |
#include <RunGlue.h> |
9 |
// |
// |
10 |
ClassImp(RunGlue); |
ClassImp(RunGlue); |
15 |
this->Clear(); |
this->Clear(); |
16 |
} |
} |
17 |
|
|
18 |
RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi) { |
RunGlue::RunGlue(TSQLServer *da, UInt_t ru, TString di, TString wrkdi, Bool_t fcas) { |
19 |
fDBG = false; |
fDBG = false; |
20 |
|
castor = fcas; |
21 |
li = new PamLevel2(); |
li = new PamLevel2(); |
22 |
this->Clear(); |
this->Clear(); |
23 |
dbc = da; |
dbc = da; |
80 |
lList = new TList(); |
lList = new TList(); |
81 |
lList->Clear(); |
lList->Clear(); |
82 |
TString thisrun; |
TString thisrun; |
83 |
|
// TFile *su; |
84 |
TFile *su; |
TFile *su; |
85 |
// |
// |
86 |
TSQLResult *pResult; |
TSQLResult *pResult; |
164 |
// |
// |
165 |
if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data()); |
if ( DebugMode() ) printf(" Filename is %s \n",thisrun.Data()); |
166 |
// |
// |
167 |
|
//su = TFile::Open(thisrun); |
168 |
su = TFile::Open(thisrun); |
su = TFile::Open(thisrun); |
169 |
if ( li->CheckLevel2File(thisrun) ){ |
if ( li->CheckLevel2File(thisrun) ){ |
170 |
lList->Add(su); |
lList->Add(su); |
208 |
if ( DebugMode() ) printf(" fullpath = %s name %s \n",fullpath.Data(),name.Data()); |
if ( DebugMode() ) printf(" fullpath = %s name %s \n",fullpath.Data(),name.Data()); |
209 |
// |
// |
210 |
// |
// |
211 |
|
//su = TFile::Open(fullpath); |
212 |
su = TFile::Open(fullpath); |
su = TFile::Open(fullpath); |
213 |
if ( li->CheckLevel2File((TString)fullpath) ){ |
if ( li->CheckLevel2File((TString)fullpath) ){ |
214 |
fList->Add(su); |
fList->Add(su); |
332 |
// |
// |
333 |
su = TFile::Open(thisrun); |
su = TFile::Open(thisrun); |
334 |
if ( su ){ |
if ( su ){ |
335 |
|
// TFile *su0 = TFile::Open(thisrun); |
336 |
TFile *su0 = TFile::Open(thisrun); |
TFile *su0 = TFile::Open(thisrun); |
337 |
fDoneList->Add(su0); |
fDoneList->Add(su0); |
338 |
fNlistdone++; |
fNlistdone++; |
378 |
|
|
379 |
Bool_t RunGlue::OpenFile(){ |
Bool_t RunGlue::OpenFile(){ |
380 |
// |
// |
|
fOpen = false; |
|
|
printf(" Check if output file already exists \n"); |
|
381 |
ifstream myfile; |
ifstream myfile; |
382 |
myfile.open((this->GetFilename()).Data()); |
TString thename; |
383 |
if ( myfile ){ |
// |
384 |
|
Bool_t exi = false; |
385 |
|
fOpen = false; |
386 |
|
thename = Form("rfio://%s",(this->GetFilename()).Data()); |
387 |
|
Target = 0; |
388 |
|
if ( castor ){ |
389 |
|
Target = new TRFIOFile(thename.Data(),"READ","",1); |
390 |
|
if ( !Target->IsZombie()) exi = true; |
391 |
|
} else { |
392 |
|
// thename = Form("rfio://%s",(this->GetFilename()).Data()); |
393 |
|
printf(" Check if output file already exists \n"); |
394 |
|
myfile.open((this->GetFilename()).Data()); |
395 |
|
if ( myfile ) exi = true; |
396 |
|
}; |
397 |
|
if ( exi ){ |
398 |
// Target = TFile::Open((this->GetFilename()).Data(), "READ" ); |
// Target = TFile::Open((this->GetFilename()).Data(), "READ" ); |
399 |
// |
// |
400 |
// if ( Target ){ |
// if ( Target ){ |
401 |
// Target->Close(); |
// Target->Close(); |
402 |
myfile.close(); |
if ( myfile ) myfile.close(); |
403 |
printf("Error opening target file, %s already exist!\n",(this->GetFilename()).Data()); |
// |
404 |
|
if ( Target ) Target->Close(); |
405 |
|
// |
406 |
|
printf("Error opening target file, %s already exist!\n",thename.Data()); |
407 |
return(false); |
return(false); |
408 |
|
// |
409 |
} else { |
} else { |
410 |
// |
// |
411 |
printf(" Output file does not exist, creating it\n"); |
printf(" Output file does not exist, creating it\n"); |
412 |
// |
// |
413 |
Long64_t maxsize = 99900000000LL; |
Long64_t maxsize = 99900000000LL; |
414 |
// |
// |
415 |
Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" ); |
Target = new TRFIOFile(thename.Data(), "RECREATE", "", 2 ); |
416 |
|
// Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" ); |
417 |
|
// |
418 |
//fastMethod = kTRUE; |
//fastMethod = kTRUE; |
419 |
fastMethod = kFALSE; |
fastMethod = kFALSE; |
420 |
// |
// |
421 |
// |
// |
422 |
if ( !Target || Target->IsZombie()) { |
if ( !Target || Target->IsZombie()) { |
423 |
printf("Error opening target file (does %s exist?)\n",(this->GetFilename()).Data()); |
printf("Error opening target file (does %s exist?)\n",thename.Data()); |
424 |
exit(1); |
exit(1); |
425 |
} |
} |
426 |
// |
// |
487 |
}; |
}; |
488 |
// |
// |
489 |
myquery.str(""); |
myquery.str(""); |
490 |
myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'" << outdir.Data() << "','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
// myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'" << outdir.Data() << "','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
491 |
|
myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
492 |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
493 |
// |
// |
494 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
550 |
// |
// |
551 |
if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath()); |
if ( DebugMode() ) printf("\nTarget path is: %s \n",target->GetPath()); |
552 |
// |
// |
553 |
TString path( (char*)strstr( target->GetPath(), ":" ) ); |
TString path; |
554 |
|
//if ( castor ){ |
555 |
|
path = TString(":/"); |
556 |
|
// } else { |
557 |
|
// path = TString( (char*)strstr( target->GetPath(), ":" ) ); |
558 |
|
// }; |
559 |
path.Remove(0,2); |
path.Remove(0,2); |
560 |
|
if ( DebugMode() ) printf("path is %s \n",path.Data()); |
561 |
// |
// |
562 |
TDirectory *first_source = (TDirectory*)sourcelist->First(); |
TDirectory *first_source = (TDirectory*)sourcelist->First(); |
563 |
THashList allNames; |
THashList allNames; |
642 |
// |
// |
643 |
globChain->Add(first_source->GetName()); |
globChain->Add(first_source->GetName()); |
644 |
// |
// |
645 |
|
// TFile *nextsource = (TFile*)sourcelist->After( first_source ); |
646 |
TFile *nextsource = (TFile*)sourcelist->After( first_source ); |
TFile *nextsource = (TFile*)sourcelist->After( first_source ); |
647 |
// |
// |
648 |
while ( nextsource ) { |
while ( nextsource ) { |
650 |
//do not add to the list a file that does not contain this Tree |
//do not add to the list a file that does not contain this Tree |
651 |
// |
// |
652 |
TFile *curf = TFile::Open(nextsource->GetName()); |
TFile *curf = TFile::Open(nextsource->GetName()); |
653 |
|
// TFile *curf = TFile::Open(nextsource->GetName()); |
654 |
// |
// |
655 |
if ( curf ) { |
if ( curf ) { |
656 |
// |
// |
740 |
}; |
}; |
741 |
|
|
742 |
|
|
743 |
|
//Long64_t RunGlue::Mergy(TChain *mychain, TFile* file, Int_t basketsize, Option_t* option){ |
744 |
Long64_t RunGlue::Mergy(TChain *mychain, TFile* file, Int_t basketsize, Option_t* option){ |
Long64_t RunGlue::Mergy(TChain *mychain, TFile* file, Int_t basketsize, Option_t* option){ |
745 |
// We must have been passed a file, we will use it |
// We must have been passed a file, we will use it |
746 |
// later to reset the compression level of the branches. |
// later to reset the compression level of the branches. |