/[PAMELA software]/PadmeAmidala/src/RunGlue.cpp
ViewVC logotype

Diff of /PadmeAmidala/src/RunGlue.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by mocchiut, Fri Jan 30 09:37:18 2009 UTC revision 1.19 by mocchiut, Fri Oct 17 10:21:02 2014 UTC
# Line 42  RunGlue::RunGlue(TSQLServer *da, UInt_t Line 42  RunGlue::RunGlue(TSQLServer *da, UInt_t
42      runmode = false;      runmode = false;
43      createlist = true;      createlist = true;
44    };    };
45      fUpgrade = true;
46    //    //
47    //  lList = new TList();    //  lList = new TList();
48    //    //
# Line 114  TList *RunGlue::GetRunList(){ Line 115  TList *RunGlue::GetRunList(){
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      //      //
# Line 281  TList *RunGlue::GetRunList(){ Line 282  TList *RunGlue::GetRunList(){
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      //      //
# Line 394  Bool_t RunGlue::OpenFile(){ Line 395  Bool_t RunGlue::OpenFile(){
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" );      //    Target = TFile::Open((this->GetFilename()).Data(), "RECREATE" );
425      Target = TFile::Open((this->GetFilename()).Data(), "NEW" );          Target = TFile::Open((this->GetFilename()).Data(), "NEW" );    
426      //          //    
# Line 478  void RunGlue::UpdateDB(TList *dlist){ Line 505  void RunGlue::UpdateDB(TList *dlist){
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    //    //
# Line 503  void RunGlue::UpdateDB(TList *dlist){ Line 520  void RunGlue::UpdateDB(TList *dlist){
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    //    //
# Line 537  void RunGlue::MergeRootfile(TList *sourc Line 565  void RunGlue::MergeRootfile(TList *sourc
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");

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.23