| 103 | 
      | 
      | 
| 104 | 
     h0_obj    = 0; | 
     h0_obj    = 0; | 
| 105 | 
     trk0_obj  = 0; | 
     trk0_obj  = 0; | 
| 106 | 
  | 
     calo0_obj  = 0; | 
| 107 | 
  | 
  | 
| 108 | 
     trk2_obj  = 0; | 
     trk2_obj  = 0; | 
| 109 | 
     trk1_obj  = 0; | 
     trk1_obj  = 0; | 
| 119 | 
  | 
  | 
| 120 | 
     run_obj   = 0;//new GL_RUN(); | 
     run_obj   = 0;//new GL_RUN(); | 
| 121 | 
     soft_obj   = 0;// Emiliano | 
     soft_obj   = 0;// Emiliano | 
| 122 | 
     irun = -1; | 
     irun = -1LL; | 
| 123 | 
     runfirstentry = 0ULL; | 
     runfirstentry = 0LL; | 
| 124 | 
     runlastentry = 0ULL; | 
     runlastentry = 0LL; | 
| 125 | 
  | 
  | 
| 126 | 
     l0_file = NULL; | 
     l0_file = NULL; | 
| 127 | 
     l0_tree = NULL; | 
     l0_tree = NULL; | 
| 128 | 
     iroot   = -1; | 
     iroot   = -1; | 
| 129 | 
     dbc     = 0; | 
     dbc     = 0; | 
| 130 | 
  | 
  | 
| 131 | 
  | 
     prevshift = 0; | 
| 132 | 
      | 
      | 
 | 
     irun = -1; | 
  | 
| 133 | 
     run_tree = NULL; | 
     run_tree = NULL; | 
| 134 | 
     run_tree_clone = NULL; | 
     run_tree_clone = NULL; | 
| 135 | 
     sel_tree = NULL; | 
     sel_tree = NULL; | 
| 136 | 
     sel_tree_clone = NULL; | 
     sel_tree_clone = NULL; | 
| 137 | 
      | 
      | 
| 138 | 
     irunentry = -1; | 
     irunentry = -1LL; | 
| 139 | 
     pam_tree = NULL; | 
     pam_tree = NULL; | 
| 140 | 
     for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; | 
     for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; | 
| 141 | 
  | 
  | 
| 190 | 
 //    cout << "void PamLevel2::Clear()"<<endl; | 
 //    cout << "void PamLevel2::Clear()"<<endl; | 
| 191 | 
     if(h0_obj)   delete h0_obj;  | 
     if(h0_obj)   delete h0_obj;  | 
| 192 | 
     if(trk0_obj) delete trk0_obj;        | 
     if(trk0_obj) delete trk0_obj;        | 
| 193 | 
  | 
     if(calo0_obj) delete calo0_obj;      | 
| 194 | 
     if(trk1_obj) delete trk1_obj;        | 
     if(trk1_obj) delete trk1_obj;        | 
| 195 | 
     if(trk2_obj) delete trk2_obj; | 
     if(trk2_obj) delete trk2_obj; | 
| 196 | 
     if(trkh_obj) delete trkh_obj; | 
     if(trkh_obj) delete trkh_obj; | 
| 244 | 
 //    if(soft_obj) soft_obj->Clear(); | 
 //    if(soft_obj) soft_obj->Clear(); | 
| 245 | 
  | 
  | 
| 246 | 
     if(h0_obj)   h0_obj->Clear();        | 
     if(h0_obj)   h0_obj->Clear();        | 
| 247 | 
     if(trk0_obj) trk0_obj->Clear();      | 
 //    if(trk0_obj) trk0_obj->Clear();    | 
| 248 | 
  | 
     if(calo0_obj) calo0_obj->Clear();    | 
| 249 | 
     if(trk1_obj) trk1_obj->Clear();      | 
     if(trk1_obj) trk1_obj->Clear();      | 
| 250 | 
     if(trk2_obj) trk2_obj->Clear(); | 
     if(trk2_obj) trk2_obj->Clear(); | 
| 251 | 
     if(trkh_obj) trkh_obj->Clear(); | 
     if(trkh_obj) trkh_obj->Clear(); | 
| 558 | 
                 use_CAL            && | 
                 use_CAL            && | 
| 559 | 
                 calo2_obj->npcfit[1] > 15     &&   //no. of fit planes on Y view | 
                 calo2_obj->npcfit[1] > 15     &&   //no. of fit planes on Y view | 
| 560 | 
                 calo2_obj->varcfit[1] < 1000. &&  //fit variance on Y view | 
                 calo2_obj->varcfit[1] < 1000. &&  //fit variance on Y view | 
| 561 | 
  | 
                 cp && ci && | 
| 562 | 
                 true){ | 
                 true){ | 
| 563 | 
  | 
  | 
| 564 | 
                  | 
                  | 
| 580 | 
                 cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; | 
                 cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; | 
| 581 | 
                 return; | 
                 return; | 
| 582 | 
             }; | 
             }; | 
| 583 | 
             if( use_TOF ){ | 
             if( use_TOF && op && oi ){ | 
| 584 | 
                  | 
                  | 
| 585 | 
                 Int_t nphit_p =0; | 
                 Int_t nphit_p =0; | 
| 586 | 
                 Int_t nphit_i =0; | 
                 Int_t nphit_i =0; | 
| 973 | 
     }; | 
     }; | 
| 974 | 
      | 
      | 
| 975 | 
     cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; | 
     cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; | 
 | 
      | 
  | 
 | 
     pam_tree = (TChain*)Trout; | 
  | 
| 976 | 
  | 
  | 
| 977 | 
  | 
     pam_tree = (TChain*)Trout; | 
| 978 | 
  | 
      | 
| 979 | 
     return Trout; | 
     return Trout; | 
| 980 | 
      | 
      | 
| 981 | 
 } | 
 } | 
| 1004 | 
 //    char *fullpath; | 
 //    char *fullpath; | 
| 1005 | 
 //    const char *fullpath; | 
 //    const char *fullpath; | 
| 1006 | 
      | 
      | 
| 1007 | 
     // if input file list is given:      | 
     // if no input file list is given:   | 
| 1008 | 
     if ( flisttxt != "" ){ | 
     if ( flisttxt != "" ){ | 
| 1009 | 
          | 
          | 
| 1010 | 
 //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){         | 
 //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){         | 
| 1013 | 
 //          return 0; | 
 //          return 0; | 
| 1014 | 
 //      }        | 
 //      }        | 
| 1015 | 
 //      flisttxt = fullpath; | 
 //      flisttxt = fullpath; | 
 | 
  | 
  | 
| 1016 | 
       if ( !flisttxt.EndsWith(".root") ){ | 
       if ( !flisttxt.EndsWith(".root") ){ | 
| 1017 | 
  | 
  | 
| 1018 | 
         flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); | 
         flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); | 
| 1019 | 
  | 
  | 
| 1020 | 
         if( !gSystem->ChangeDirectory(ddir) ){ | 
         if( !gSystem->ChangeDirectory(ddir) ){ | 
| 1059 | 
           char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); | 
           char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); | 
| 1060 | 
           contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list | 
           contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list | 
| 1061 | 
           delete fullpath; | 
           delete fullpath; | 
| 1062 | 
       };        | 
       };         | 
| 1063 | 
     }else{ | 
     }else{ | 
| 1064 | 
          | 
          | 
| 1065 | 
         cout << "No input file list given."<<endl; | 
         cout << "No input file list given."<<endl; | 
| 1520 | 
  * @param run Pointer to the chain/tree which contains run infos  | 
  * @param run Pointer to the chain/tree which contains run infos  | 
| 1521 | 
  * @return true if a new run has been read, false if it is still the same run | 
  * @return true if a new run has been read, false if it is still the same run | 
| 1522 | 
  */ | 
  */ | 
| 1523 | 
 Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){ | 
 Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev){ | 
| 1524 | 
   // | 
   // | 
| 1525 | 
   // check if we have already called once GetEntry, if not call it | 
   // check if we have already called once GetEntry, if not call it | 
| 1526 | 
   // | 
   // | 
| 1527 | 
   if ( run->GetEntries() <= 0 ) return(false); | 
     if(!run){ | 
| 1528 | 
  | 
           cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; | 
| 1529 | 
  | 
           return(false);         | 
| 1530 | 
  | 
     } | 
| 1531 | 
  | 
     if ( run->GetEntries() <= 0 ) return(false); | 
| 1532 | 
   // | 
   // | 
| 1533 | 
    | 
    | 
| 1534 | 
   Int_t oldrun = irun; | 
 //  Int_t oldrun = irun; | 
| 1535 | 
  | 
   Long64_t oldrun = irun; | 
| 1536 | 
   // -------------------------------------- | 
   // -------------------------------------- | 
| 1537 | 
   // if it is a full file (not preselected) | 
   // if it is a full file (not preselected) | 
| 1538 | 
   // -------------------------------------- | 
   // -------------------------------------- | 
| 1539 | 
   if(SELLI==0){ | 
   if(SELLI==0){ | 
 | 
       if ( irun < 0 ){ | 
  | 
 | 
           irun = 0; | 
  | 
 | 
           run->GetEntry(0); | 
  | 
 | 
           runfirstentry = 0ULL; | 
  | 
 | 
           runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; | 
  | 
 | 
       };       | 
  | 
| 1540 | 
  | 
  | 
| 1541 | 
       if( !GetOrbitalInfo() ){ | 
       if( !GetOrbitalInfo() ){ | 
| 1542 | 
           cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; | 
           cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; | 
| 1543 | 
           return(false); | 
           return(false); | 
| 1544 | 
       } | 
       } | 
| 1545 | 
  | 
  | 
| 1546 | 
  | 
       if ( irun < 0 ){ | 
| 1547 | 
  | 
           irun = 0; | 
| 1548 | 
  | 
           run->GetEntry(irun); | 
| 1549 | 
  | 
           runfirstentry = 0LL; | 
| 1550 | 
  | 
           runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); | 
| 1551 | 
  | 
           if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; | 
| 1552 | 
  | 
 //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; | 
| 1553 | 
  | 
 //        cout << "runfirstentry "<<runfirstentry<<endl; | 
| 1554 | 
  | 
 //        return(true);  | 
| 1555 | 
  | 
       };       | 
| 1556 | 
  | 
  | 
| 1557 | 
       // modificato il controllo sull'aggiornamento del run, per evitare problemi | 
       // modificato il controllo sull'aggiornamento del run, per evitare problemi | 
| 1558 | 
       // dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) | 
       // dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) | 
| 1559 | 
       while ( GetOrbitalInfo()->absTime > GetRunInfo()->RUNTRAILER_TIME && irun < run->GetEntries() ){ | 
       // | 
| 1560 | 
  | 
       bool fromfirst = true; | 
| 1561 | 
  | 
       // | 
| 1562 | 
  | 
       while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1 ){ | 
| 1563 | 
 //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ | 
 //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ | 
 | 
           //    printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); | 
  | 
| 1564 | 
           irun++; | 
           irun++; | 
| 1565 | 
           run->GetEntry(irun); | 
           run->GetEntry(irun); | 
| 1566 | 
           runfirstentry = runlastentry+1ULL; | 
           runfirstentry = runlastentry; | 
| 1567 | 
           runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); | 
           if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runfirstentry += 1LL; | 
| 1568 | 
  | 
           runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); | 
| 1569 | 
  | 
 //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; | 
| 1570 | 
  | 
 //        cout << "runfirstentry "<<runfirstentry<<endl; | 
| 1571 | 
  | 
           //      printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); | 
| 1572 | 
  | 
           //      printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); | 
| 1573 | 
  | 
           //      printf(" IDRUN %u \n",GetRunInfo()->ID); | 
| 1574 | 
  | 
           // | 
| 1575 | 
  | 
 //        prevshift = 0; | 
| 1576 | 
  | 
           // | 
| 1577 | 
  | 
           if ( irun == run->GetEntries()-1 && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ | 
| 1578 | 
  | 
               printf(" resetting irun  (it should NOT happen!!!)\n"); | 
| 1579 | 
  | 
               fromfirst = false; | 
| 1580 | 
  | 
               irun = 0; | 
| 1581 | 
  | 
               run->GetEntry(irun); | 
| 1582 | 
  | 
               runfirstentry = 0ULL; | 
| 1583 | 
  | 
               runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); | 
| 1584 | 
  | 
               if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; | 
| 1585 | 
  | 
           }; | 
| 1586 | 
  | 
           // | 
| 1587 | 
       }; | 
       }; | 
| 1588 | 
        | 
       // | 
| 1589 | 
  | 
       if ( !fromfirst &&  | 
| 1590 | 
  | 
            !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&  | 
| 1591 | 
  | 
              GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)  | 
| 1592 | 
  | 
           ) { | 
| 1593 | 
  | 
           printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); | 
| 1594 | 
  | 
           return false; | 
| 1595 | 
  | 
       } | 
| 1596 | 
       // | 
       // | 
| 1597 | 
       if ( irun == oldrun || irun >= run->GetEntries() ) return(false); | 
       if ( irun == oldrun || irun >= run->GetEntries() ) return(false); | 
| 1598 | 
       // | 
       // | 
| 1599 | 
       //  printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); | 
       //  printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); | 
| 1600 | 
       // | 
       // | 
| 1601 | 
  | 
       prevshift = 0; | 
| 1602 | 
  | 
       cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; | 
| 1603 | 
  | 
 //      cout << "runfirstentry "<<runfirstentry<<endl; | 
| 1604 | 
       return(true);     | 
       return(true);     | 
| 1605 | 
   }; | 
   }; | 
| 1606 | 
   // ---------------------------------------------------- | 
   // ---------------------------------------------------- | 
| 1609 | 
   // ---------------------------------------------------- | 
   // ---------------------------------------------------- | 
| 1610 | 
   if(SELLI==1){       | 
   if(SELLI==1){       | 
| 1611 | 
       sel_tree->GetEntry(iev); | 
       sel_tree->GetEntry(iev); | 
| 1612 | 
  | 
 //      cout << irun << " "<< irunentry << endl; | 
| 1613 | 
       if(irun != oldrun){ | 
       if(irun != oldrun){ | 
| 1614 | 
           run->GetEntry(irun); | 
           run->GetEntry(irun); | 
| 1615 | 
  | 
           cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; | 
| 1616 | 
  | 
           prevshift = 0; | 
| 1617 | 
           return true; | 
           return true; | 
| 1618 | 
       } | 
       } | 
| 1619 | 
       return false; | 
       return false; | 
| 1622 | 
   return false; | 
   return false; | 
| 1623 | 
   // | 
   // | 
| 1624 | 
 }; | 
 }; | 
| 1625 | 
  | 
  | 
| 1626 | 
  | 
 // Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev){ | 
| 1627 | 
  | 
 //   // | 
| 1628 | 
  | 
 //   // check if we have already called once GetEntry, if not call it | 
| 1629 | 
  | 
 //   // | 
| 1630 | 
  | 
 //     if(!run_tree){ | 
| 1631 | 
  | 
 //      cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; | 
| 1632 | 
  | 
 //      return false; | 
| 1633 | 
  | 
 //     } | 
| 1634 | 
  | 
 //     if ( run_tree->GetEntries() <= 0 ) { | 
| 1635 | 
  | 
 //      cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; | 
| 1636 | 
  | 
 //      return(false); | 
| 1637 | 
  | 
 //     } | 
| 1638 | 
  | 
 //   // | 
| 1639 | 
  | 
    | 
| 1640 | 
  | 
 //   Int_t oldrun = irun; | 
| 1641 | 
  | 
 //   // -------------------------------------- | 
| 1642 | 
  | 
 //   // if it is a full file (not preselected) | 
| 1643 | 
  | 
 //   // -------------------------------------- | 
| 1644 | 
  | 
 //   if(SELLI==0){ | 
| 1645 | 
  | 
  | 
| 1646 | 
  | 
 //       if( !GetOrbitalInfo() ){ | 
| 1647 | 
  | 
 //        cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; | 
| 1648 | 
  | 
 //        return(false); | 
| 1649 | 
  | 
 //       } | 
| 1650 | 
  | 
  | 
| 1651 | 
  | 
 //       if ( irun < 0 ){ | 
| 1652 | 
  | 
 //        irun = 0; | 
| 1653 | 
  | 
 //        run_tree->GetEntry(irun); | 
| 1654 | 
  | 
 //        runfirstentry = iev; | 
| 1655 | 
  | 
 //        if( iev != 0){ | 
| 1656 | 
  | 
 //            cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- WARNING -- "<<endl;  | 
| 1657 | 
  | 
 //        } | 
| 1658 | 
  | 
 //       };       | 
| 1659 | 
  | 
  | 
| 1660 | 
  | 
 //       bool fromfirst = true; | 
| 1661 | 
  | 
  | 
| 1662 | 
  | 
 //       while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries() ){ | 
| 1663 | 
  | 
 //        irun++; | 
| 1664 | 
  | 
 //        if( irun == run->GetEntries() ){ | 
| 1665 | 
  | 
 //            if(!fromfirst){ | 
| 1666 | 
  | 
 //                cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; | 
| 1667 | 
  | 
 //                return false; | 
| 1668 | 
  | 
 //            } | 
| 1669 | 
  | 
 //            cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- reached end of run tree. searchin again from beginning (should not happen)" <<endl; | 
| 1670 | 
  | 
 //            fromfirst = false; | 
| 1671 | 
  | 
 //            irun =0; | 
| 1672 | 
  | 
 //        } | 
| 1673 | 
  | 
 //        run_tree->GetEntry(irun); | 
| 1674 | 
  | 
 //        runfirstentry = iev; | 
| 1675 | 
  | 
 //       }; | 
| 1676 | 
  | 
 //       // | 
| 1677 | 
  | 
 //       if ( irun == oldrun ) return(false); | 
| 1678 | 
  | 
 //       // | 
| 1679 | 
  | 
 //       cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; | 
| 1680 | 
  | 
 //       cout << "runfirstentry "<<runfirstentry<<endl; | 
| 1681 | 
  | 
 //       prevshift = 0; | 
| 1682 | 
  | 
 //       return(true);     | 
| 1683 | 
  | 
 //   }; | 
| 1684 | 
  | 
 //   // ---------------------------------------------------- | 
| 1685 | 
  | 
 //   // if it is a preselected file (there is SelectionList) | 
| 1686 | 
  | 
 //   // NBNB - the event tree MUST be read first  | 
| 1687 | 
  | 
 //   // ---------------------------------------------------- | 
| 1688 | 
  | 
 //   if(SELLI==1){       | 
| 1689 | 
  | 
 //       sel_tree->GetEntry(iev); | 
| 1690 | 
  | 
 //       if(irun != oldrun){ | 
| 1691 | 
  | 
 //        run->GetEntry(irun); | 
| 1692 | 
  | 
 //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; | 
| 1693 | 
  | 
 //        prevshift = 0; | 
| 1694 | 
  | 
 //        return true; | 
| 1695 | 
  | 
 //       } | 
| 1696 | 
  | 
 //       return false; | 
| 1697 | 
  | 
 //   } | 
| 1698 | 
  | 
  | 
| 1699 | 
  | 
 //   return false; | 
| 1700 | 
  | 
 //   // | 
| 1701 | 
  | 
 // }; | 
| 1702 | 
 /** | 
 /** | 
| 1703 | 
  * Update the runinfo informations (to be used to have Run infos event by event basis) | 
  * Update the runinfo informations (to be used to have Run infos event by event basis) | 
| 1704 | 
  * @param run Pointer to the chain/tree which contains run infos  | 
  * @param run Pointer to the chain/tree which contains run infos  | 
| 1705 | 
  * @return true if a new run has been read, false if it is still the same run | 
  * @return true if a new run has been read, false if it is still the same run | 
| 1706 | 
  */ | 
  */ | 
| 1707 | 
 Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){ | 
 Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev){ | 
| 1708 | 
   return(UpdateRunInfo((TChain*)run,iev)); | 
   return(UpdateRunInfo((TChain*)run,iev)); | 
| 1709 | 
 }; | 
 }; | 
| 1710 | 
  | 
  | 
| 2343 | 
  | 
  | 
| 2344 | 
  | 
  | 
| 2345 | 
     sel_tree_clone = new TTree("SelectionList","List of selected events "); | 
     sel_tree_clone = new TTree("SelectionList","List of selected events "); | 
| 2346 | 
     sel_tree_clone->Branch("RunEntry",&irun,"runentry/I"); | 
     sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); | 
| 2347 | 
     sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/I"); | 
     sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); | 
| 2348 | 
      | 
      | 
| 2349 | 
  | 
  | 
| 2350 | 
     Int_t i=0; | 
     Int_t i=0; | 
| 2484 | 
 /** | 
 /** | 
| 2485 | 
  * Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. | 
  * Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. | 
| 2486 | 
  */ | 
  */ | 
| 2487 | 
 Int_t PamLevel2::GetEntry(Int_t iee){ | 
 //Int_t PamLevel2::GetEntry(Int_t iee){ | 
| 2488 | 
  | 
 Int_t PamLevel2::GetEntry(Long64_t iee){ | 
| 2489 | 
      | 
      | 
| 2490 | 
     if(!pam_tree){ | 
     if(!pam_tree){ | 
| 2491 | 
         cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; | 
         cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; | 
| 2492 | 
         return 0; | 
         return 0; | 
| 2493 | 
     } | 
     } | 
| 2494 | 
  | 
  | 
| 2495 | 
     Int_t ii=0; | 
  | 
| 2496 | 
  | 
     // | 
| 2497 | 
  | 
     // This is a sort of bug: if you don't have the run tree you don't want to exit here you want to have loaded the event anyway... | 
| 2498 | 
  | 
     // | 
| 2499 | 
  | 
     //    if(!run_tree ){ | 
| 2500 | 
  | 
     //  cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loeaded"<<endl; | 
| 2501 | 
  | 
     //  return 0; | 
| 2502 | 
  | 
     //    } | 
| 2503 | 
  | 
  | 
| 2504 | 
  | 
     Long64_t ii=0; | 
| 2505 | 
     //------------------------------- | 
     //------------------------------- | 
| 2506 | 
     ii = iee; | 
     ii = iee; | 
| 2507 | 
     if( !pam_tree->GetEntry(ii) ) return 0; | 
     if( !pam_tree->GetEntry(ii) ){       | 
| 2508 | 
     //------------------------------- | 
         cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl; | 
 | 
  | 
  | 
 | 
     if(!run_tree ){ | 
  | 
 | 
         cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; | 
  | 
| 2509 | 
         return 0; | 
         return 0; | 
| 2510 | 
     } | 
     } | 
| 2511 | 
  | 
     // | 
| 2512 | 
  | 
     // ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0.  | 
| 2513 | 
  | 
     // in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not | 
| 2514 | 
  | 
     // a problem if you don't check the return code of getentry. | 
| 2515 | 
  | 
     // | 
| 2516 | 
  | 
     if(!run_tree ){ | 
| 2517 | 
  | 
         if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? | 
| 2518 | 
  | 
                 cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; | 
| 2519 | 
  | 
                 return 0; | 
| 2520 | 
  | 
         }  else { | 
| 2521 | 
  | 
                 return 1; //cosi` se non c'e` run esce qua... | 
| 2522 | 
  | 
         } | 
| 2523 | 
  | 
     } | 
| 2524 | 
  | 
  | 
| 2525 | 
  | 
     //------------------------------- | 
| 2526 | 
     ii = iee; | 
     ii = iee; | 
| 2527 | 
     Bool_t UPDATED = UpdateRunInfo(run_tree,ii); | 
 //    Bool_t UPDATED = UpdateRunInfo(run_tree,ii); | 
| 2528 | 
  | 
     Bool_t UPDATED = UpdateRunInfo(ii); | 
| 2529 | 
     if(SELLI==0)irunentry = iee-runfirstentry; | 
     if(SELLI==0)irunentry = iee-runfirstentry; | 
| 2530 | 
     if(UPDATED && run_tree_clone)run_tree_clone->Fill(); | 
     if(UPDATED && run_tree_clone)run_tree_clone->Fill(); | 
| 2531 | 
  | 
  | 
| 2551 | 
     // check if iroot has changed | 
     // check if iroot has changed | 
| 2552 | 
     //=================================== | 
     //=================================== | 
| 2553 | 
     if( irun<0 ){ | 
     if( irun<0 ){ | 
| 2554 | 
         cout << "PamLevel2::GetYodaTree() -- ERROR "<<endl; | 
         cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = "<<irun<<endl; | 
| 2555 | 
         cout << "In order to use this method you have to load the RunInfo tree "<<endl; | 
 //      cout << "In order to use this method you have to first load the RunInfo tree "<<endl; | 
 | 
         cout << "with the method TChain* PamLevel2::GetRunTree(TString, TString)"<<endl; | 
  | 
 | 
 //      cout << " - read the event with PamLevel2::GetEntry(Int_t)"<<endl; | 
  | 
| 2556 | 
         return NULL; | 
         return NULL; | 
| 2557 | 
     }     | 
     }     | 
| 2558 | 
     Int_t irootnew = run_obj->ID_ROOT_L0; | 
     Int_t irootnew = run_obj->ID_ROOT_L0; | 
| 2604 | 
         l0_tree = (TTree*)l0_file->Get("Physics"); | 
         l0_tree = (TTree*)l0_file->Get("Physics"); | 
| 2605 | 
         if(!h0_obj)h0_obj = new EventHeader(); | 
         if(!h0_obj)h0_obj = new EventHeader(); | 
| 2606 | 
         l0_tree->SetBranchAddress("Header" ,&h0_obj); | 
         l0_tree->SetBranchAddress("Header" ,&h0_obj); | 
| 2607 | 
  | 
         prevshift = 0; | 
| 2608 | 
         //--------------------------------------------------- | 
         //--------------------------------------------------- | 
| 2609 | 
         // TRACKER: | 
         // TRACKER: | 
| 2610 | 
         if(TRK0){ | 
         if(TRK0){ | 
| 2613 | 
                 trk0_obj->Set(); | 
                 trk0_obj->Set(); | 
| 2614 | 
             }; | 
             }; | 
| 2615 | 
             l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); | 
             l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); | 
 | 
             TrkParams::SetCalib(run_obj,dbc); | 
  | 
| 2616 | 
         } | 
         } | 
| 2617 | 
         //--------------------------------------------------- | 
         //--------------------------------------------------- | 
| 2618 | 
         // CALORIMETER: | 
         // CALORIMETER: | 
| 2619 | 
         if(CAL0){ | 
         if(CAL0){ | 
| 2620 | 
             cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; | 
             if(!calo0_obj){ | 
| 2621 | 
  | 
                 calo0_obj = new CaloLevel0(); | 
| 2622 | 
  | 
                 calo0_obj->Set(); | 
| 2623 | 
  | 
             }; | 
| 2624 | 
  | 
             l0_tree->SetBranchAddress("Calorimeter" ,calo0_obj->GetPointerToCalorimeterEvent()); | 
| 2625 | 
  | 
             //      cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; | 
| 2626 | 
         } | 
         } | 
| 2627 | 
         //--------------------------------------------------- | 
         //--------------------------------------------------- | 
| 2628 | 
         // TOF: | 
         // TOF: | 
| 2632 | 
  | 
  | 
| 2633 | 
     }; | 
     }; | 
| 2634 | 
  | 
  | 
| 2635 | 
  | 
     if(!dbc || (dbc && !dbc->IsConnected())){ | 
| 2636 | 
  | 
         cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; | 
| 2637 | 
  | 
     } | 
| 2638 | 
  | 
  | 
| 2639 | 
  | 
     if ( TRK0 ){ | 
| 2640 | 
  | 
         TrkParams::Load(6); | 
| 2641 | 
  | 
         if( !TrkParams::IsLoaded(6) ){ | 
| 2642 | 
  | 
             cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; | 
| 2643 | 
  | 
         }; | 
| 2644 | 
  | 
         TrkParams::SetCalib(run_obj,dbc); | 
| 2645 | 
  | 
         TrkParams::LoadCalib( ); | 
| 2646 | 
  | 
         if( !TrkParams::CalibIsLoaded() ){ | 
| 2647 | 
  | 
             cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl; | 
| 2648 | 
  | 
         }; | 
| 2649 | 
  | 
     } | 
| 2650 | 
  | 
  | 
| 2651 | 
 //    cout << l0_tree << endl; | 
 //    cout << l0_tree << endl; | 
| 2652 | 
      | 
      | 
| 2653 | 
     return l0_tree; | 
     return l0_tree; | 
| 2662 | 
 //    cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; | 
 //    cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; | 
| 2663 | 
     if(!GetYodaTree())return 0; | 
     if(!GetYodaTree())return 0; | 
| 2664 | 
      | 
      | 
| 2665 | 
  | 
     // patch | 
| 2666 | 
  | 
     if( irunentry < 0){ | 
| 2667 | 
  | 
         cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; | 
| 2668 | 
  | 
         irunentry=0LL; | 
| 2669 | 
  | 
     } | 
| 2670 | 
     //  --------------------------------- | 
     //  --------------------------------- | 
| 2671 | 
     //  if file is NOT a preselected file | 
     //  if file is NOT a preselected file | 
| 2672 | 
     //  --------------------------------- | 
     //  --------------------------------- | 
| 2673 | 
     Int_t quellagiusta = irunentry + run_obj->EV_FROM; | 
     Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); | 
| 2674 | 
  | 
      | 
| 2675 | 
  | 
  | 
| 2676 | 
  | 
 //     cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; | 
| 2677 | 
  | 
 //     cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; | 
| 2678 | 
  | 
 //     cout << " time "<< GetOrbitalInfo()->absTime << endl; | 
| 2679 | 
  | 
 //     cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; | 
| 2680 | 
  | 
      | 
| 2681 | 
     if( !GetOrbitalInfo() ){ | 
     if( !GetOrbitalInfo() ){ | 
| 2682 | 
         cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; | 
         cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; | 
| 2683 | 
         return 0; | 
         return 0; | 
| 2684 | 
     } | 
     } | 
| 2685 | 
  | 
     if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ | 
| 2686 | 
  | 
         cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl;  | 
| 2687 | 
  | 
         return 0; | 
| 2688 | 
  | 
     } | 
| 2689 | 
  | 
  | 
| 2690 | 
     // --------------------------------------------------------------------- | 
     // --------------------------------------------------------------------- | 
| 2691 | 
     // ATTENTION!!! | 
     // ATTENTION!!! | 
| 2700 | 
     // --------------------------------------------------------------------- | 
     // --------------------------------------------------------------------- | 
| 2701 | 
     Int_t answer = 0; | 
     Int_t answer = 0; | 
| 2702 | 
     Int_t shift =0; | 
     Int_t shift =0; | 
| 2703 | 
  | 
     //    printf(" siamo qui %i %i \n",shift,prevshift); | 
| 2704 | 
     do{ | 
     do{ | 
| 2705 | 
 //      if(shift>0){ | 
         if(shift>0){      | 
| 2706 | 
 //          cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" )"<<endl; | 
             cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; | 
| 2707 | 
 //      } | 
         } | 
| 2708 | 
         answer = GetYodaTree()->GetEntry(quellagiusta+shift); | 
         answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); | 
| 2709 | 
         shift++; | 
         shift++; | 
| 2710 | 
         if( !GetEventHeader() ){ | 
         if( !GetEventHeader() ){ | 
| 2711 | 
             cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; | 
             cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; | 
| 2712 | 
             return 0; | 
             return 0; | 
| 2713 | 
         } | 
         } | 
| 2714 | 
 //      if( (quellagiusta+shift) == GetYodaTree()->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl;  | 
 //      cout << "PKTNUM "<<shift<<" ==  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; | 
| 2715 | 
     }while( ( (UInt_t)(GetOrbitalInfo()->OBT) != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+shift) < (UInt_t)(GetYodaTree()->GetEntries()) ); | 
 //      cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; | 
| 2716 | 
  | 
 //      if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl;  | 
| 2717 | 
  | 
 //      cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; | 
| 2718 | 
  | 
 //      cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; | 
| 2719 | 
  | 
 //      cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; | 
| 2720 | 
  | 
 //      cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; | 
| 2721 | 
  | 
 //      printf(" IDRUN %u \n",GetRunInfo()->ID); | 
| 2722 | 
  | 
 // | 
| 2723 | 
  | 
         if ( prevshift != 0 && (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ){ | 
| 2724 | 
  | 
           prevshift = 0; | 
| 2725 | 
  | 
           shift = -1; | 
| 2726 | 
  | 
         }; | 
| 2727 | 
  | 
  | 
| 2728 | 
  | 
     }while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() ); | 
| 2729 | 
  | 
  | 
| 2730 | 
  | 
     if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ) cout << " Big trouble here, no such event in Level0 data! " <<endl; | 
| 2731 | 
  | 
  | 
| 2732 | 
 //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; | 
 //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; | 
| 2733 | 
 //    return GetYodaTree()->GetEntry(quellagiusta); | 
 //    return GetYodaTree()->GetEntry(quellagiusta); | 
| 2734 | 
  | 
     if ( shift > 1 ) prevshift += (shift-1); | 
| 2735 | 
      | 
      | 
| 2736 | 
     return answer; | 
     return answer; | 
| 2737 | 
      | 
      | 
| 2738 | 
 } | 
 } | 
| 2739 | 
  | 
  | 
| 2740 | 
  | 
  |