42 |
runmode = false; |
runmode = false; |
43 |
createlist = true; |
createlist = true; |
44 |
}; |
}; |
45 |
|
fUpgrade = true; |
46 |
// |
// |
47 |
// lList = new TList(); |
// lList = new TList(); |
48 |
// |
// |
115 |
TTimeStamp *llim = new TTimeStamp(YY,MM,DD,0,0,0,0,true,0); |
TTimeStamp *llim = new TTimeStamp(YY,MM,DD,0,0,0,0,true,0); |
116 |
// |
// |
117 |
UInt_t lowerlimit = llim->GetSec(); |
UInt_t lowerlimit = llim->GetSec(); |
118 |
UInt_t upperlimit = lowerlimit + 86401; |
UInt_t upperlimit = lowerlimit + 86400; |
119 |
// |
// |
120 |
if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit); |
if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit); |
121 |
// |
// |
282 |
TTimeStamp *llim = new TTimeStamp(YY,MM,DD,0,0,0,0,true,0); |
TTimeStamp *llim = new TTimeStamp(YY,MM,DD,0,0,0,0,true,0); |
283 |
// |
// |
284 |
UInt_t lowerlimit = llim->GetSec(); |
UInt_t lowerlimit = llim->GetSec(); |
285 |
UInt_t upperlimit = lowerlimit + 86401; |
UInt_t upperlimit = lowerlimit + 86400; |
286 |
// |
// |
287 |
if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit); |
if ( DebugMode() ) printf(" YY %u MM %u DD %u ll %u ul %u \n",YY,MM,DD,lowerlimit,upperlimit); |
288 |
// |
// |
395 |
return(false); |
return(false); |
396 |
} else { |
} else { |
397 |
// |
// |
398 |
|
// try to lock tables and work on a db level to avoid multiple file simultaneous access |
399 |
|
// |
400 |
|
stringstream oss; |
401 |
|
// |
402 |
|
if ( fUpgrade ){ |
403 |
|
oss.str(""); |
404 |
|
oss << "lock table GL_ROOT write;"; |
405 |
|
TSQLResult *result = 0; |
406 |
|
TSQLRow *row = 0; |
407 |
|
result = dbc->Query(oss.str().c_str()); |
408 |
|
oss.str(""); |
409 |
|
oss << "select ID from GL_ROOT where NAME='" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "';"; |
410 |
|
result = dbc->Query(oss.str().c_str()); |
411 |
|
row = result->Next(); |
412 |
|
if ( row ){ |
413 |
|
printf("Error opening target file (does %s exist? already in the DB? are the permissions ok?)\n",(this->GetFilename()).Data()); |
414 |
|
return(false); |
415 |
|
} else { |
416 |
|
oss.str(""); |
417 |
|
oss << "insert into GL_ROOT (PATH,NAME) values ('$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
418 |
|
result = dbc->Query(oss.str().c_str()); |
419 |
|
}; |
420 |
|
oss.str(""); |
421 |
|
oss << "unlock tables;"; |
422 |
|
result = dbc->Query(oss.str().c_str()); |
423 |
|
}; |
424 |
|
// Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" ); |
425 |
|
Target = TFile::Open((this->GetFilename()).Data(), "NEW" ); |
426 |
|
// |
427 |
printf(" Output file does not exist, creating it\n"); |
printf(" Output file does not exist, creating it\n"); |
428 |
// |
// |
429 |
Long64_t maxsize = 99900000000LL; |
Long64_t maxsize = 99900000000LL; |
430 |
// |
// |
431 |
Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" ); |
if ( !Target || Target->IsZombie()) { |
432 |
|
printf("Error opening target file (does %s exist? are the permissions ok?)\n",(this->GetFilename()).Data()); |
433 |
|
// exit(1); |
434 |
|
return(false); |
435 |
|
} |
436 |
|
// |
437 |
|
Target->Write(); |
438 |
|
// |
439 |
//fastMethod = kTRUE; |
//fastMethod = kTRUE; |
440 |
fastMethod = kFALSE; |
fastMethod = kFALSE; |
441 |
// |
// |
|
// |
|
|
if ( !Target || Target->IsZombie()) { |
|
|
printf("Error opening target file (does %s exist?)\n",(this->GetFilename()).Data()); |
|
|
exit(1); |
|
|
} |
|
442 |
// |
// |
443 |
TTree::SetMaxTreeSize(maxsize); |
TTree::SetMaxTreeSize(maxsize); |
444 |
// Target->SetCompressionLevel(2); |
// Target->SetCompressionLevel(2); |
505 |
}; |
}; |
506 |
// |
// |
507 |
myquery.str(""); |
myquery.str(""); |
|
// 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 << ",'$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
|
|
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
|
|
// |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
|
|
if ( !pResult ){ |
|
|
printf(" ERROR WRITING ON DB!\n"); |
|
|
return; |
|
|
}; |
|
|
myquery.str(""); |
|
508 |
myquery << "select ID from GL_ROOT where NAME='" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "';"; |
myquery << "select ID from GL_ROOT where NAME='" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "';"; |
509 |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
510 |
// |
// |
520 |
} else { |
} else { |
521 |
idl2 = (UInt_t)atoll(Row->GetField(0)); |
idl2 = (UInt_t)atoll(Row->GetField(0)); |
522 |
}; |
}; |
523 |
|
myquery.str(""); |
524 |
|
// myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'" << outdir.Data() << "','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
525 |
|
// myquery << "insert into GL_ROOT (ID_RAW,PATH,NAME) values (" << idr << ",'$PAM_L2','" << ((TString)gSystem->BaseName(this->GetFilename())).Data() << "');"; |
526 |
|
myquery << "update GL_ROOT set ID_RAW=" << idr << " where ID=" << idl2 << ";"; |
527 |
|
if ( DebugMode() ) printf(" query is %s \n",myquery.str().c_str()); |
528 |
|
// |
529 |
|
pResult = dbc->Query(myquery.str().c_str()); |
530 |
|
if ( !pResult ){ |
531 |
|
printf(" ERROR WRITING ON DB!\n"); |
532 |
|
return; |
533 |
|
}; |
534 |
// |
// |
535 |
// |
// |
536 |
// |
// |
565 |
// |
// |
566 |
merged = true; |
merged = true; |
567 |
// |
// |
568 |
if ( li ) li->Delete(); |
// if ( li ) li->Delete(); |
569 |
li = new PamLevel2(wd,sourcelist,fDList); |
PamLevel2 *nli = new PamLevel2(wd,sourcelist,fDList); |
570 |
li->SetSELLI(2); |
nli->SetSELLI(2); |
571 |
// |
// |
572 |
Target->cd(); |
Target->cd(); |
573 |
// |
// |
574 |
li->CreateCloneTrees(Target); |
nli->CreateCloneTrees(Target); |
575 |
ULong64_t nevents = li->GetEntries(); |
// |
576 |
|
/* nli->GetCloneTree("Tracker")->SetAutoSave(900000000000000LL); |
577 |
|
nli->GetCloneTree("Trigger")->SetAutoSave(900000000000000LL); |
578 |
|
nli->GetCloneTree("Calorimeter")->SetAutoSave(900000000000000LL); |
579 |
|
nli->GetCloneTree("S4")->SetAutoSave(900000000000000LL); |
580 |
|
nli->GetCloneTree("Anticounter")->SetAutoSave(900000000000000LL); |
581 |
|
nli->GetCloneTree("NeutronD")->SetAutoSave(900000000000000LL); |
582 |
|
nli->GetCloneTree("OrbitalInfo")->SetAutoSave(900000000000000LL); |
583 |
|
nli->GetCloneTree("Run")->SetAutoSave(900000000000000LL); |
584 |
|
nli->GetCloneTree("ToF")->SetAutoSave(900000000000000LL);*/ |
585 |
|
// |
586 |
|
ULong64_t nevents = nli->GetEntries(); |
587 |
printf(" NEVENTS %llu \n",nevents); |
printf(" NEVENTS %llu \n",nevents); |
588 |
for(ULong64_t iev=0; iev<nevents; iev++){ |
for(ULong64_t iev=0; iev<nevents; iev++){ |
589 |
li->Clear(); |
nli->Clear(); |
590 |
if( li->GetEntry(iev) ){ |
if( nli->GetEntry(iev) ){ |
591 |
li->FillCloneTrees(); |
nli->FillCloneTrees(); |
592 |
}; |
}; |
593 |
}; |
}; |
594 |
Target->cd(); |
Target->cd(); |
595 |
li->WriteCloneTrees(); |
nli->WriteCloneTrees(); |
596 |
printf("Written file %s \n",Target->GetName()); |
printf("Written file %s \n",Target->GetName()); |
597 |
// Target->Write(); |
// Target->Write(); |
598 |
// TTree *slist = (TTree*)Target->Get("SelectionList"); |
// TTree *slist = (TTree*)Target->Get("SelectionList"); |
599 |
// slist->Delete("all"); |
// slist->Delete("all"); |
600 |
|
if ( !nli->GetCloneTree("ProcessingInfo") ){ |
601 |
|
TChain *P = new TChain("ProcessingInfo"); |
602 |
|
// loop over files and create chains |
603 |
|
TIter next(sourcelist); |
604 |
|
TSystemFile *questo = 0; |
605 |
|
while ((questo = (TSystemFile*) next())) { |
606 |
|
TString name = questo->GetName(); |
607 |
|
P->Add(name); |
608 |
|
} |
609 |
|
if ( P->GetEntries() ){ |
610 |
|
TTree *Pclone = P->CloneTree(); |
611 |
|
Target->cd(); |
612 |
|
Pclone->Write("ProcessingInfo",TObject::kOverwrite); |
613 |
|
P->Delete(); |
614 |
|
P=0; |
615 |
|
} |
616 |
|
} |
617 |
|
// |
618 |
Target->Close(); |
Target->Close(); |
619 |
|
|
620 |
// // |
// // |