/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Diff of /PamelaLevel2/src/PamLevel2.cpp

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

revision 1.55 by pam-fi, Wed Nov 14 11:14:28 2007 UTC revision 1.80 by pam-fi, Wed Mar 25 14:42:36 2009 UTC
# Line 284  PamTrack::PamTrack(){ Line 284  PamTrack::PamTrack(){
284      trk_track  = 0;      trk_track  = 0;
285      calo_track = 0;      calo_track = 0;
286      tof_track  = 0;      tof_track  = 0;
287        orb_track  = 0;
288      candeleteobj = 0;      candeleteobj = 0;
289      pscore = 0;      pscore = 0;
290      iscore = 0;      iscore = 0;
# Line 295  PamTrack::PamTrack(){ Line 296  PamTrack::PamTrack(){
296  /**  /**
297   * Constructor   * Constructor
298   */   */
299  PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){  PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o, OrbitalInfoTrkVar *r){
300    
301      trk_track  = 0;      trk_track  = 0;
302      calo_track = 0;      calo_track = 0;
303      tof_track  = 0;      tof_track  = 0;
304        orb_track  = 0;
305  //     if(t)trk_track  = new TrkTrack(*t);  //     if(t)trk_track  = new TrkTrack(*t);
306  //     if(c)calo_track = new CaloTrkVar(*c);  //     if(c)calo_track = new CaloTrkVar(*c);
307  //     if(o)tof_track  = new ToFTrkVar(*o);  //     if(o)tof_track  = new ToFTrkVar(*o);
308      if(t)trk_track  = t;      if(t)trk_track  = t;
309      if(c)calo_track = c;      if(c)calo_track = c;
310      if(o)tof_track  = o;      if(o)tof_track  = o;
311      candeleteobj = 0;      if(r) orb_track  = r;
312    
313       candeleteobj = 0;
314    
315  };  };
316  PamTrack::PamTrack(const PamTrack& track){  PamTrack::PamTrack(const PamTrack& track){
# Line 314  PamTrack::PamTrack(const PamTrack& track Line 318  PamTrack::PamTrack(const PamTrack& track
318      TrkTrack   *t = track.trk_track;      TrkTrack   *t = track.trk_track;
319      CaloTrkVar *c = track.calo_track;      CaloTrkVar *c = track.calo_track;
320      ToFTrkVar  *o = track.tof_track;      ToFTrkVar  *o = track.tof_track;
321        OrbitalInfoTrkVar  *r = track.orb_track;
322    
323      trk_track  = 0;      trk_track  = 0;
324      calo_track = 0;      calo_track = 0;
325      tof_track  = 0;      tof_track  = 0;
326        orb_track  = 0;
327      if(t)trk_track  = new TrkTrack(*t);      if(t)trk_track  = new TrkTrack(*t);
328      if(c)calo_track = new CaloTrkVar(*c);      if(c)calo_track = new CaloTrkVar(*c);
329      if(o)tof_track  = new ToFTrkVar(*o);      if(o)tof_track  = new ToFTrkVar(*o);
330        if(r)orb_track  = new OrbitalInfoTrkVar(*r);
331      candeleteobj = 1;      candeleteobj = 1;
332            
333  }  }
# Line 331  void PamTrack::Clear(){ Line 338  void PamTrack::Clear(){
338          if(trk_track)  trk_track->TrkTrack::Clear();          if(trk_track)  trk_track->TrkTrack::Clear();
339          if(calo_track) calo_track->CaloTrkVar::Clear();//???          if(calo_track) calo_track->CaloTrkVar::Clear();//???
340          if(tof_track)  tof_track->ToFTrkVar::Clear();//???          if(tof_track)  tof_track->ToFTrkVar::Clear();//???
341            if(orb_track)  orb_track->OrbitalInfoTrkVar::Clear();//???
342      }else{      }else{
343          trk_track  = 0;          trk_track  = 0;
344          calo_track = 0;          calo_track = 0;
345          tof_track  = 0;          tof_track  = 0;
346            orb_track  = 0;
347      }      }
348      pscore = 0;      pscore = 0;
349      iscore = 0;      iscore = 0;
# Line 355  void PamTrack::Delete(){ Line 364  void PamTrack::Delete(){
364              tof_track->ToFTrkVar::Clear();//???              tof_track->ToFTrkVar::Clear();//???
365              delete tof_track;              delete tof_track;
366          }          }
367            if(orb_track){
368                orb_track->OrbitalInfoTrkVar::Clear();//???
369                delete orb_track;
370            }
371      }else{      }else{
372          Clear();          Clear();
373      }      }
# Line 384  PamLevel2::PamLevel2(){ Line 397  PamLevel2::PamLevel2(){
397   * If no options are specified, the default is assumed. Default is:   * If no options are specified, the default is assumed. Default is:
398   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB
399   */   */
400  PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){  PamLevel2::PamLevel2(TString ddir,TString llist,TString detlist){
401      Initialize();      Initialize();
402      GetPamTree(GetListOfLevel2Files(ddir,list),detlist);      TList*  listf = GetListOfLevel2Files(ddir,llist);
403      GetRunTree(GetListOfLevel2Files(ddir,list));      if(listf)GetPamTree(listf,detlist);
404        if(listf)GetRunTree(listf);
405  };  };
406    
407    PamLevel2::PamLevel2(TString ddir,TList *llist,TString detlist){
408        Initialize();
409        GetPamTree(llist,detlist);
410        GetRunTree(llist);
411    };
412  /**  /**
413   * Constructor   * Constructor
414   * @param ddir Name of directory where level2 files are stored.   * @param ddir Name of directory where level2 files are stored.
# Line 397  PamLevel2::PamLevel2(TString ddir,TStrin Line 416  PamLevel2::PamLevel2(TString ddir,TStrin
416   * Default trees/branches are loaded. Default is:   * Default trees/branches are loaded. Default is:
417   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB   * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB
418   */   */
419  PamLevel2::PamLevel2(TString ddir,TString list){  PamLevel2::PamLevel2(TString ddir,TString llist){
420      Initialize();      Initialize();
421      GetPamTree(GetListOfLevel2Files(ddir,list),"");      TList*  listf = GetListOfLevel2Files(ddir,llist);
422      GetRunTree(GetListOfLevel2Files(ddir,list));      GetPamTree(listf,"");
423        GetRunTree(listf);
424  };  };
425    
426    
# Line 426  void PamLevel2::Initialize(){ Line 446  void PamLevel2::Initialize(){
446      run_obj   = 0;//new GL_RUN();      run_obj   = 0;//new GL_RUN();
447      soft_obj   = 0;// Emiliano      soft_obj   = 0;// Emiliano
448      irun = -1LL;      irun = -1LL;
449        irunt = -1LL;
450      runfirstentry = 0LL;      runfirstentry = 0LL;
451      runlastentry = 0LL;      runlastentry = 0LL;
452        gltsync = 0; // Emiliano
453    
454      l0_file = NULL;      l0_file = NULL;
455      l0_tree = NULL;      l0_tree = NULL;
# Line 448  void PamLevel2::Initialize(){ Line 470  void PamLevel2::Initialize(){
470    
471      totdltime[0] = 0LL;      totdltime[0] = 0LL;
472      totdltime[1] = 0LL;      totdltime[1] = 0LL;
473        totdltime[2] = 0LL;
474    
475      host = "mysql://localhost/pamelaprod";      host = "mysql://localhost/pamelaprod";
476      user = "anonymous";      user = "anonymous";
# Line 488  void PamLevel2::Initialize(){ Line 511  void PamLevel2::Initialize(){
511    
512      ISGP = false;      ISGP = false;
513    
514        DBG = false;
515    
516      tsorted=0;      tsorted=0;
517      timage=0;      timage=0;
518            
# Line 534  void PamLevel2::Delete(){ Line 559  void PamLevel2::Delete(){
559          dbc->Close();          dbc->Close();
560          delete dbc;          delete dbc;
561      }      }
562    
563        if ( gltsync ) delete gltsync;
564            
565      if(l0_file)l0_file->Close();      if(l0_file)l0_file->Close();
566      //    if(pam_tree)pam_tree->Delete();;      //    if(pam_tree)pam_tree->Delete();;
# Line 575  void PamLevel2::Delete(){ Line 602  void PamLevel2::Delete(){
602      if(run_tree_clone)run_tree_clone->Delete();;      if(run_tree_clone)run_tree_clone->Delete();;
603      if(sel_tree_clone)sel_tree_clone->Delete();;      if(sel_tree_clone)sel_tree_clone->Delete();;
604            
605        if(irunoffset) delete [] irunoffset;
606    
607  };  };
608    
# Line 691  void PamLevel2::Reset(){ Line 719  void PamLevel2::Reset(){
719      run_obj   = 0;//new GL_RUN();      run_obj   = 0;//new GL_RUN();
720      soft_obj   = 0;// Emiliano      soft_obj   = 0;// Emiliano
721      irun = -1;      irun = -1;
722        irunt = -1;
723      runfirstentry = 0ULL;      runfirstentry = 0ULL;
724      runlastentry = 0ULL;          runlastentry = 0ULL;    
725      //      //
726      totdltime[0] = 0LL;      totdltime[0] = 0LL;
727      totdltime[1] = 0LL;      totdltime[1] = 0LL;
728        totdltime[2] = 0LL;
729      //      //
730  };  };
731    
732  Bool_t PamLevel2::IsGood(){  Bool_t PamLevel2::IsGood(Bool_t strict){
733      Bool_t goodev=true;    Bool_t goodev=true;
734      //  if(trk2_obj && trk2_obj->UnpackError() != 0 ) goodev = false;    //
735      if(calo2_obj && calo2_obj->good != 1) goodev = false;    if(calo2_obj && !calo2_obj->IsGood(strict) ) goodev = false;
736      //
737      if ( strict ){
738        if(trk2_obj && trk2_obj->UnpackError() != 0 ) goodev = false;
739      if(tof_obj && tof_obj->unpackError != 0) goodev = false;        if(tof_obj && tof_obj->unpackError != 0) goodev = false;  
740      if(trig_obj && trig_obj->unpackError != 0) goodev = false;      if(trig_obj && trig_obj->unpackError != 0) goodev = false;
741      if(s4_obj && s4_obj->unpackError != 0) goodev = false;        if(s4_obj && s4_obj->unpackError != 0) goodev = false;  
742      if(nd_obj && nd_obj->unpackError != 0) goodev = false;        if(nd_obj && nd_obj->unpackError != 0) goodev = false;  
743      if(ac_obj && ac_obj->unpackError != 255) goodev = false;        if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>2)&1) || ((ac_obj->status[1]>>2)&1)) ) goodev = false;      
744      //  if(orb_obj)        //  if(orb_obj)  
745      return goodev;    } else {
746        if(nd_obj && nd_obj->unpackError != 0) goodev = false;  
747        if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>2)&1) || ((ac_obj->status[1]>>2)&1)) ) goodev = false;      
748      };
749      return(goodev);
750  };  };
751    
752  //--------------------------------------  //--------------------------------------
# Line 735  void *PamLevel2::GetPointerTo(const char Line 772  void *PamLevel2::GetPointerTo(const char
772          return &trk2_obj;          return &trk2_obj;
773      };      };
774      if(!objname.CompareTo("TrkHough"))   {      if(!objname.CompareTo("TrkHough"))   {
775          if(!trkh_obj)  trkh_obj  = new TrkHough();          if(!trkh_obj)  {
776                trkh_obj  = new TrkHough();
777                trkh_obj->Set();
778            }
779          return &trkh_obj;          return &trkh_obj;
780      };      };
781      if(!objname.CompareTo("CaloLevel1")) {      if(!objname.CompareTo("CaloLevel1")) {
# Line 772  void *PamLevel2::GetPointerTo(const char Line 812  void *PamLevel2::GetPointerTo(const char
812          if(!ac_obj)    ac_obj    = new AcLevel2();          if(!ac_obj)    ac_obj    = new AcLevel2();
813          return &ac_obj;          return &ac_obj;
814      };      };
815      if(!objname.CompareTo("OrbitalInfo")){      if(!objname.CompareTo("OrbitalInfo"))  {
816          if(!orb_obj)   orb_obj   = new OrbitalInfo();          if(!orb_obj){
817                orb_obj   = new OrbitalInfo();
818                orb_obj->Set();
819            }
820          return &orb_obj;          return &orb_obj;
821      };      };
822    //     if(!objname.CompareTo("OrbitalInfo")){
823    //      if(!orb_obj)   orb_obj   = new OrbitalInfo();
824    //      return &orb_obj;
825    //     };
826      if(!objname.CompareTo("GPamela")){      if(!objname.CompareTo("GPamela")){
827          if(!gp_obj)   gp_obj   = new GPamela();          if(!gp_obj)   gp_obj   = new GPamela();
828          return &gp_obj;          return &gp_obj;
# Line 857  ToFTrkVar *PamLevel2::GetToFStoredTrack( Line 904  ToFTrkVar *PamLevel2::GetToFStoredTrack(
904  //  //
905  //--------------------------------------  //--------------------------------------
906  /**  /**
907   * Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information.   * Retrieves the OrbitalInfo track matching the seqno-th tracker stored track.
908     * (If seqno = -1 retrieves the tracker-independent tof related track)
909     */
910    OrbitalInfoTrkVar *PamLevel2::GetOrbitalInfoStoredTrack(int seqno){
911            
912        if( !orb_obj )return 0;
913    
914    
915        if( orb_obj->OrbitalInfo::ntrk()==0 ){
916    //       // TRICK BEGIN
917    //       OrbitalInfoTrkVar  *r = new OrbitalInfoTrkVar(); // TEMPORARY TRICK
918    //       Int_t nn = 0;
919    //       TClonesArray &tor = *orb_obj->OrbitalInfoTrk;
920    //       for(Int_t nt=0; nt < tof_obj->ToFLevel2::ntrk(); nt++){  
921    //      //
922    //      ToFTrkVar *ptt = tof_obj->ToFLevel2::GetToFTrkVar(nt);
923    //      if ( ptt->trkseqno != -1  ){
924    //        //
925    //        r->trkseqno = ptt->trkseqno;
926    //        //
927    //        r->Eij = 0;  
928    //        //
929    //        r->Sij = 0;
930    //        //        
931    //        r->pitch = -1000.;
932    //        //
933    //        r->cutoff = -1000.;
934    //        //
935    //        new(tor[nn]) OrbitalInfoTrkVar(*r);
936    //        nn++;
937    //        //
938    //        r->Clear();
939    //        //
940    //      };
941    //       };
942    //       delete r;
943    //       OrbitalInfoTrkVar *c = 0;
944    //       c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0);
945    //       return c;
946    //       //TRICK END
947          cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no OrbitalInfo tracks are stored"<<endl;
948          return NULL;
949        };
950        
951        OrbitalInfoTrkVar *c = 0;
952        Int_t it_tof=0;
953        
954        do{
955            c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(it_tof);
956            it_tof++;
957        } while( c && seqno != c->trkseqno && it_tof < orb_obj->OrbitalInfo::ntrk());      
958        
959        if(!c || seqno != c->trkseqno){
960            c = 0;
961            if(seqno!=-1)cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match OrbitalInfo stored tracks"<<endl;
962        };
963        return c;
964        
965    };
966    
967    //--------------------------------------
968    //
969    //
970    //--------------------------------------
971    /**
972     * Give the pamela track associated to a tracker track, retrieving related calorimeter, orbitalinfo and tof track information.
973   */   */
974  PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){  PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){
975            
# Line 866  PamTrack* PamLevel2::GetPamTrackAlong(Tr Line 978  PamTrack* PamLevel2::GetPamTrackAlong(Tr
978    
979      CaloTrkVar *c = 0;      CaloTrkVar *c = 0;
980      ToFTrkVar  *o = 0;      ToFTrkVar  *o = 0;
981        OrbitalInfoTrkVar  *r = 0;
982            
983      if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo());      if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo());
984      if(TOF) o = GetToFStoredTrack(t->GetSeqNo());      if(TOF) o = GetToFStoredTrack(t->GetSeqNo());
985        if(ORB) r = GetOrbitalInfoStoredTrack(t->GetSeqNo());
986            
987  //    if(t && c && o)track = new PamTrack(t,c,o);  //    if(t && c && o)track = new PamTrack(t,c,o);
988      PamTrack *track = new PamTrack(t,c,o);      PamTrack *track = new PamTrack(t,c,o,r);
989            
990      return track;      return track;
991    
# Line 889  PamTrack* PamLevel2::GetPamTrackAlong(Tr Line 1003  PamTrack* PamLevel2::GetPamTrackAlong(Tr
1003  PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){  PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){
1004            
1005      cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl;      cout <<"PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** "<<endl;
1006      cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack)"<<endl;      cout <<"for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack) OrbitalInfo::GetOrbitalInfoTrkVar(Int_t notrack)"<<endl;
1007      cout <<"(if you use it, remember to delete the PamTrack object)"<<endl;      cout <<"(if you use it, remember to delete the PamTrack object)"<<endl;
1008      PamTrack *track = 0;      PamTrack *track = 0;
1009            
# Line 1001  void PamLevel2::SortTracks(){ Line 1115  void PamLevel2::SortTracks(){
1115          TrkTrack   *ts = 0;          TrkTrack   *ts = 0;
1116          CaloTrkVar *cs = 0;          CaloTrkVar *cs = 0;
1117          ToFTrkVar  *os = 0;          ToFTrkVar  *os = 0;
1118            OrbitalInfoTrkVar  *rs = 0;
1119                    
1120          // get tracker tracks          // get tracker tracks
1121          TrkTrack   *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker          TrkTrack   *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker
1122          CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());          CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());
1123          ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());          ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());
1124            OrbitalInfoTrkVar  *rp = GetOrbitalInfoStoredTrack(tp->GetSeqNo());
1125    
1126          TrkTrack   *ti = 0; //tracker (image)          TrkTrack   *ti = 0; //tracker (image)
1127          CaloTrkVar *ci = 0;          CaloTrkVar *ci = 0;
1128          ToFTrkVar  *oi = 0;          ToFTrkVar  *oi = 0;
1129            OrbitalInfoTrkVar  *ri = 0;
1130          //      cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;          //      cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;
1131          // if track has an image, check image selection          // if track has an image, check image selection
1132    
# Line 1023  void PamLevel2::SortTracks(){ Line 1140  void PamLevel2::SortTracks(){
1140              ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)              ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)
1141              ci = GetCaloStoredTrack(ti->GetSeqNo());              ci = GetCaloStoredTrack(ti->GetSeqNo());
1142              oi = GetToFStoredTrack(ti->GetSeqNo());              oi = GetToFStoredTrack(ti->GetSeqNo());
1143                ri = GetOrbitalInfoStoredTrack(ti->GetSeqNo());
1144                            
1145              //      cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;              //      cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;
1146    
# Line 1364  void PamLevel2::SortTracks(){ Line 1482  void PamLevel2::SortTracks(){
1482                  ts = ti;//its image!!                  ts = ti;//its image!!
1483                  cs = ci;                  cs = ci;
1484                  os = oi;                  os = oi;
1485                    rs = ri;
1486                  Int_t totis = toti_score;                  Int_t totis = toti_score;
1487    
1488                  ti = tp;//its image!!                  ti = tp;//its image!!
1489                  ci = cp;                  ci = cp;
1490                  oi = op;                  oi = op;
1491                    ri = rp;
1492    
1493                  tp = ts;//its image!!                  tp = ts;//its image!!
1494                  cp = cs;                  cp = cs;
1495                  op = os;                  op = os;
1496                    rp = rs;
1497    
1498                  toti_score = totp_score;                  toti_score = totp_score;
1499                  totp_score = totis;                  totp_score = totis;
# Line 1402  void PamLevel2::SortTracks(){ Line 1523  void PamLevel2::SortTracks(){
1523          //      cout<<"o "<<cp<<endl;          //      cout<<"o "<<cp<<endl;
1524          //      cout<<"o "<<op<<endl;          //      cout<<"o "<<op<<endl;
1525    
1526          new(ttsorted[i]) PamTrack(tp,cp,op);          new(ttsorted[i]) PamTrack(tp,cp,op,rp);
1527          new(ttimage[i])  PamTrack(ti,ci,oi);          new(ttimage[i])  PamTrack(ti,ci,oi,ri);
1528    
1529          ((PamTrack*)(ttsorted[i]))->SetPScore(totp_score);          ((PamTrack*)(ttsorted[i]))->SetPScore(totp_score);
1530          ((PamTrack*)(ttsorted[i]))->SetIScore(toti_score);          ((PamTrack*)(ttsorted[i]))->SetIScore(toti_score);
# Line 1513  PamTrack *PamLevel2::GetTrack(int it){ Line 1634  PamTrack *PamLevel2::GetTrack(int it){
1634   */   */
1635  PamTrack *PamLevel2::GetTrackImage(int it){  PamTrack *PamLevel2::GetTrackImage(int it){
1636    
 //     if(!trk2_obj) return 0;  
   
 // //  *-*-*-*-*-*-*-*-*-*-*-*-*  
 //     SortTracks("+CAL+TOF");  
 // //  *-*-*-*-*-*-*-*-*-*-*-*-*  
 // //    if(!sorted_tracks)return 0;  
 //     if(sorted_tracks.IsEmpty())return 0;  
       
 //     PamTrack *image = 0;  
       
 //     if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){  
 //      TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it);  
 //      if( temp->HasImage() ){  
 //          TrkTrack   *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());  
 //          image = GetPamTrackAlong(t);  
 //      }else{  
 //          cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl;  
 //      };  
 //     }else{  
 //      cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl;  
 //     };  
       
 //     return image;  
   
   
1637  //  *-*-*-*-*-*-*-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
1638      SortTracks();      SortTracks();
1639  //  *-*-*-*-*-*-*-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
# Line 1611  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1707  TTree *PamLevel2::GetPamTree(TFile *f, T
1707      if(ORB)cout<<"ORB ";      if(ORB)cout<<"ORB ";
1708      if(GP)cout<<"GP ";      if(GP)cout<<"GP ";
1709      cout << endl;      cout << endl;
1710      if(SELLI)cout<<">>> Found selection-list <<<"<<endl;      if(SELLI && SELLI!=2)cout<<">>> Found selection-list <<<"<<endl; //EMILIANO
1711    
1712      f->cd();      f->cd();
1713    
# Line 1730  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1826  TTree *PamLevel2::GetPamTree(TFile *f, T
1826    
1827      TTree *L = (TTree*)f->Get("SelectionList");      TTree *L = (TTree*)f->Get("SelectionList");
1828      if(L && SELLI==1) {      if(L && SELLI==1) {
 //      L->SetBranchAddress("RunEntry",&irun);  
 //      cout << "SelectionList: set branch address RunEntry"<<endl;  
 //      L->SetBranchAddress("EventEntry",&irunentry);  
 //      cout << "SelectionList: set branch address EventEntry"<<endl;  
 //      if(!Trout)Trout=O;  
 //      else Trout->AddFriend("SelectionList");  
1829          cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemented!!!!"<<endl;          cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemented!!!!"<<endl;
1830          sel_tree = 0;          sel_tree = 0;
1831      }else{      }else{
# Line 1777  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1867  TTree *PamLevel2::GetPamTree(TFile *f, T
1867  TList*  PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){  TList*  PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){
1868                    
1869      TString wdir = gSystem->WorkingDirectory();      TString wdir = gSystem->WorkingDirectory();
1870        
     //    if(ddir=="")ddir = wdir;  
 //      TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);  
1871      if ( ddir != ""){      if ( ddir != ""){
1872          cout << "Level2 data directory : "<<  ddir << endl;          cout << "Level2 data directory : "<<  ddir << endl;
1873      } else {      } else {
# Line 1788  TList*  PamLevel2::GetListOfLevel2Files( Line 1876  TList*  PamLevel2::GetListOfLevel2Files(
1876      TList *contents  = new TList; // create output list      TList *contents  = new TList; // create output list
1877      contents->SetOwner();      contents->SetOwner();
1878            
1879  //    char *fullpath;      // --------------------------------------
1880  //    const char *fullpath;      // case 1 : input file/file-list provided
1881            // --------------------------------------
     // if no input file list is given:    
1882      if ( flisttxt != "" ){      if ( flisttxt != "" ){
1883                    
1884  //      if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){                  // --------------------------------------
1885  //      if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){          // a list of files given as input
1886  //          cout <<"File "<<flisttxt<<" not found"<<endl;          // --------------------------------------
 //          return 0;  
 //      }        
 //      flisttxt = fullpath;  
1887          if ( !flisttxt.EndsWith(".root") ){          if ( !flisttxt.EndsWith(".root") ){
1888    
1889              flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));              TString dir = gSystem->DirName(flisttxt);
1890    //          cout << " List directory "<<dir<<endl;
1891                if(dir == "." || dir == "")
1892                    flisttxt = gSystem->ConcatFileName(wdir.Data(),gSystem->BaseName(flisttxt));
1893    //              flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
1894    
1895              if( !gSystem->ChangeDirectory(ddir) ){              if( !gSystem->ChangeDirectory(ddir) ){
1896                  cout << "Cannot change directory : "<<ddir<<endl;                  cout << "Cannot change directory : "<<ddir<<endl;
# Line 1813  TList*  PamLevel2::GetListOfLevel2Files( Line 1901  TList*  PamLevel2::GetListOfLevel2Files(
1901              ifstream in;              ifstream in;
1902              in.open(flisttxt, ios::in); //open input file list              in.open(flisttxt, ios::in); //open input file list
1903              if(!in.good()){              if(!in.good()){
1904                  cout <<" ERROR opening the file "<<endl;                  cout <<" TList*  PamLevel2::GetListOfLevel2Files(TString, TString) --> ERROR opening the file "<<endl;
1905                  gSystem->ChangeDirectory(wdir); // back to the working directory                  gSystem->ChangeDirectory(wdir); // back to the working directory
1906                  return 0;                  return 0;
1907              }                }  
1908              int line=0;              int line=0;
1909                // ...........................
1910                // loop over file-list records
1911                // ...........................
1912              while (1) {              while (1) {
1913                  TString file;                  TString file;
1914                  in >> file;                  in >> file;
1915                  if (!in.good()) break;                  if (!in.good()) break;
1916                  line++;                  line++;
1917  //          cout <<"(1) " << file << endl;                  cout <<"(*) " << file << endl;
1918                  if(file.IsNull()){                  if(file.IsNull()){
1919                      cout << "-- list interrupted at line "<<line <<endl;                      cout << "-- list interrupted at line "<<line <<endl;
1920                      break;                      break;
1921                  }                  }
1922                  if(file.Contains("#"))file = file(0,file.First("#"));                  if(file.Contains("#"))file = file(0,file.First("#"));
1923  //          cout <<"(2) " << file << endl;                  //
1924  //          if( gSystem->IsFileInIncludePath(file,&fullpath) ){                  // take only root files
1925  //          if( (fullpath = gSystem->FindFile(ddir,file)) ){                  //
1926                  if( file.EndsWith(".root") ){                  if( file.EndsWith(".root") ){
1927                      TString filedir;                      TString filedir;
1928                        cout << ddir << endl;
1929                      if (ddir != ""){                      if (ddir != ""){
1930                          filedir = ddir; // take the input dir                          filedir = ddir; // take the input dir
1931                      } else {                      } else {
1932                          gSystem->ChangeDirectory(wdir); // back to the working directory                          gSystem->ChangeDirectory(wdir); // back to the working directory
1933                          filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir                          filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir
1934                      };                      };
1935                        filedir.Append("/");
1936                      char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file));                      char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file));
1937                      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
1938                        cout << fullpath << endl;
1939                      delete fullpath;                      delete fullpath;
1940                  }                  }
1941  //          }else{  //          }else{
# Line 1849  TList*  PamLevel2::GetListOfLevel2Files( Line 1943  TList*  PamLevel2::GetListOfLevel2Files(
1943  //          };  //          };
1944              };              };
1945              in.close();              in.close();
1946            // --------------------------------------
1947            // a single root file given as input
1948            // --------------------------------------
1949          } else {          } else {
1950              if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#"));              if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#"));
1951              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));              char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
1952              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
1953              delete fullpath;              delete fullpath;
1954          };                };      
1955        // ---------------------------------------------------------------------------------
1956        // case 2 : no input file/file-list provided --> read all files insede the directory
1957        // ---------------------------------------------------------------------------------
1958      }else{      }else{
1959                    
1960          cout << "No input file list given."<<endl;          cout << "No input file list given."<<endl;
# Line 1867  TList*  PamLevel2::GetListOfLevel2Files( Line 1967  TList*  PamLevel2::GetListOfLevel2Files(
1967    
1968          TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);          TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);
1969          TList *temp = datadir->GetListOfFiles();          TList *temp = datadir->GetListOfFiles();
1970            if(!temp)return 0;
1971  //              temp->Print();  //              temp->Print();
1972  //              cout << "*************************************" << endl;  //              cout << "*************************************" << endl;
1973                    
# Line 1919  TChain *PamLevel2::GetPamTree(TList *fl, Line 2020  TChain *PamLevel2::GetPamTree(TList *fl,
2020            
2021      TChain *Trout =0;      TChain *Trout =0;
2022    
2023            // -------------------------------------------
2024        // set flags to include/exclude trees/branches
2025        // -------------------------------------------
2026      if( detlist.Contains("+AUTO", TString::kIgnoreCase) ) {      if( detlist.Contains("+AUTO", TString::kIgnoreCase) ) {
2027          if( fl->GetEntries()>0 ){          if( fl->GetEntries()>0 ){
2028              cout << "+AUTO"<<endl;              cout << "+AUTO"<<endl;
2029              TFile *fprimo = new TFile( fl->At(0)->GetName() );              TFile *fprimo = new TFile( fl->At(0)->GetName() );
2030              GetWhichTrees(fprimo);              GetWhichTrees(fprimo);
2031                fprimo->Close();// AAAAARGGGGGHHHHH!!!!!!! non commentare questa riga, altrimenti si incasina il TChain
2032              fprimo->Delete();              fprimo->Delete();
2033          }          }
2034      };      };
2035      SetWhichTrees(detlist);          SetWhichTrees(detlist);    
2036    
2037    
2038        // -------------------------------------------
2039  //    if( !detlist.IsNull() )SetWhichTrees(detlist);      // build chains
2040  //          // -------------------------------------------
2041      TChain *T = 0;            TChain *T = 0;      
2042      TChain *C = 0;      TChain *C = 0;
2043      TChain *O = 0;      TChain *O = 0;
# Line 1977  TChain *PamLevel2::GetPamTree(TList *fl, Line 2081  TChain *PamLevel2::GetPamTree(TList *fl,
2081          };          };
2082      };      };
2083            
2084      cout << "done chain \n";      cout << "done chains\n";
2085      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
2086    
2087  //    UInt_t *found=0;  
2088        // -------------------------------------------
2089        // make friends
2090        // -------------------------------------------
2091    
2092  // Tracker  // Tracker
2093        cout << "Friends: "<<endl;
2094      if(T && (TRK2||TRK1||TRKh)) {      if(T && (TRK2||TRK1||TRKh)) {
 //      if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2"));  
 //      if(TRK2)cout << "Tracker      : set branch address TrkLevel2"<<endl;  
 //      if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1"));  
 //      if(TRK1)cout << "Tracker      : set branch address TrkLevel1"<<endl;  
 //      if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough"));  
 //      if(TRKh)cout << "Tracker      : set branch address TrkHough"<<endl;  
2095          if(!Trout)Trout=T;          if(!Trout)Trout=T;
2096          else Trout->AddFriend("Tracker");          else Trout->AddFriend("Tracker");
2097      }else{  //      cout << "+Tacker"<<endl;
 //        cout << "Tracker      : missing tree"<<endl;  
2098      };      };
2099      // Calorimeter      // Calorimeter
2100      if(C && (CAL2||CAL1)) {      if(C && (CAL2||CAL1)) {
 //        if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2"));  
 //        if(CAL2)cout << "Calorimeter  : set branch address CaloLevel2"<<endl;  
 //        if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1"));  
 //        if(CAL1)cout << "Calorimeter  : set branch address CaloLevel1"<<endl;  
2101          if(!Trout)Trout=C;          if(!Trout)Trout=C;
2102          else Trout->AddFriend("Calorimeter");          else Trout->AddFriend("Calorimeter");
2103      }else{  //      cout << "+Calorimeter"<<endl;
 //        cout << "Calorimeter  : missing tree"<<endl;  
2104      };      };
2105      // ToF          // ToF    
2106      if(O && TOF) {      if(O && TOF) {
 //        O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2"));  
 //        cout << "ToF          : set branch address ToFLevel2"<<endl;  
2107          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2108          else Trout->AddFriend("ToF");          else Trout->AddFriend("ToF");
2109      }else{  //      cout << "+ToF"<<endl;
 //        cout << "ToF         : missing tree"<<endl;  
2110      };      };
2111      // Trigger      // Trigger
2112      if(R && TRG) {      if(R && TRG) {
 //        R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2"));  
 //        cout << "Trigger      : set branch address TrigLevel2"<<endl;  
2113          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2114          else Trout->AddFriend("Trigger");          else Trout->AddFriend("Trigger");
2115      }else{  //      cout << "+Trigger"<<endl;
 //        cout << "Trigger      : missing tree"<<endl;  
2116      };      };
2117      // S4      // S4
2118      if(S && S4) {      if(S && S4) {
 //        S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2"));  
 //        cout << "S4           : set branch address S4Level2"<<endl;  
2119          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2120          else Trout->AddFriend("S4");          else Trout->AddFriend("S4");
2121      }else{  //      cout << "+S4"<<endl;
 //        cout << "S4           : missing tree"<<endl;  
2122      };      };
2123      // Neutron Detector      // Neutron Detector
2124      if(N && ND) {      if(N && ND) {
 //        N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2"));  
 //        cout << "NeutronD     : set branch address NDLevel2"<<endl;  
2125          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2126          else Trout->AddFriend("NeutronD");          else Trout->AddFriend("NeutronD");
2127      }else{  //      cout << "+NeutronD"<<endl;
 //        cout << "NeutronD     : missing tree"<<endl;  
2128      };      };
2129      // Anticounters      // Anticounters
2130      if(A && AC) {      if(A && AC) {
 //        A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2"));  
 //        cout << "Anticounter  : set branch address AcLevel2"<<endl;  
2131          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2132          else Trout->AddFriend("Anticounter");          else Trout->AddFriend("Anticounter");
2133      }else{  //      cout << "+Anticounter"<<endl;
 //        cout << "Anticounter  : missing tree"<<endl;  
2134      };      };
2135      // Orbital Info      // Orbital Info
2136      if(B && ORB) {      if(B && ORB) {
 //      B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo"));  
 //      cout << "OrbitalInfo  : set branch address OrbitalInfo"<<endl;  
2137          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2138          else Trout->AddFriend("OrbitalInfo");          else Trout->AddFriend("OrbitalInfo");
2139      }else{  //      cout << "+OrbitalInfo"<<endl;
 //      cout << "OrbitalInfo  : missing tree"<<endl;  
2140      };      };
2141      // GPamela      // GPamela
2142      if(G && GP) {      if(G && GP) {
         if(!gp_obj)gp_obj = new GPamela();  
 //      ------------------------------------  
 //      ATTENZIONE!!!  
 //      non so per quale arcano motivo,  
 //      per l'albero di gpamela il branch address lo devo settare  
 //      DOPO aver fatto friend  
 //      FGRRRVZZZZUTSALKJMSLKJ!!!  
 //      ------------------------------------  
 //      gp_obj->SetBranchAddress(G); //ho dovuto fare in maniera diversa dagli altri  
 //      cout << "h20          : set branch address GPamela "<<endl;  
2143          if(!Trout)Trout=G;          if(!Trout)Trout=G;
2144          else Trout->AddFriend("h20");          else Trout->AddFriend("h20");
2145      }else{  //      cout << "+h20"<<endl;
 //      cout << "h20          : missing tree"<<endl;  
2146      };      };
2147    
2148  //  =====================================  //  =====================================
# Line 2082  TChain *PamLevel2::GetPamTree(TList *fl, Line 2150  TChain *PamLevel2::GetPamTree(TList *fl,
2150  //  =====================================  //  =====================================
2151      SetBranchAddress(Trout);      SetBranchAddress(Trout);
2152    
2153    
2154    //  ------------------------------------
2155    //  finally handle selection trees...
2156    //  (it is not friend of pamela tree)
2157    //  ------------------------------------
2158    
2159      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
2160    
2161      // Selection List      // Selection List
2162      if(L && SELLI==1) {      if(L && SELLI==1) {
2163          cout<<">>> Found selection-list <<<"<<endl;          cout<<">>> Found selection-list <<<"<<endl;
2164  //      L->SetBranchAddress("RunEntry",&irun);  //      L->SetBranchAddress("RunEntry",&irun);
2165          L->SetBranchAddress("RunEntry",&irun);          L->SetBranchAddress("RunEntry",&irunt);//NEWNEW
2166          cout << "SelectionList: set branch address RunEntry"<<endl;          cout << "SelectionList: set branch address RunEntry"<<endl;
2167          L->SetBranchAddress("EventEntry",&irunentry);          L->SetBranchAddress("EventEntry",&irunentry);
2168          cout << "SelectionList: set branch address EventEntry"<<endl;          cout << "SelectionList: set branch address EventEntry"<<endl;
2169          sel_tree = L;          sel_tree = L;
2170  //      if(!Trout)Trout=O;  //      if(!Trout)Trout=O;
2171  //      else Trout->AddFriend("SelectionList");  //      else Trout->AddFriend("SelectionList");
2172          cout << "----------------------------------------------------" <<endl;          cout << "+SelectionList"<<endl;
2173            cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
2174      }else{      }else{
2175  //      cout << "SelectionList  : missing tree"<<endl;  //      cout << "SelectionList  : missing tree"<<endl;
2176          if(L)L->Delete();          if(L)L->Delete();
2177      };      };
       
 //    cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl;  
   
 //      ------------------------------------  
 //      ATTENZIONE!!!  
 //      non so per quale arcano motivo,  
 //      per l'albero di gpamela il branch address lo devo settare  
 //      DOPO aver fatto friend  
 //      FGRRRVZZZZUTSALKJMSLKJ!!!  
 //      ------------------------------------  
 //     cout << G << " --- "<<GP <<endl;  
 //     if(G && GP) {      
 //      gp_obj->SetBranchAddress(Trout); //ho dovuto fare in maniera diversa dagli altri  
 //      cout << "h20          : set branch address GPamela "<<endl;  
 //     }else{  
 //      cout << "h20          : missing tree"<<endl;  
 //     };  
2178    
2179    //  --------------------------------------------
2180    //  return the pamela chain with all the friends
2181    //  --------------------------------------------
2182    
2183      pam_tree = Trout;      pam_tree = Trout;
2184            
# Line 2207  void PamLevel2::SetBranchAddress(TTree * Line 2268  void PamLevel2::SetBranchAddress(TTree *
2268      if(GP) {      if(GP) {
2269  //      GetPointerTo("GPamela");  //      GetPointerTo("GPamela");
2270          if(!gp_obj)gp_obj = new GPamela();          if(!gp_obj)gp_obj = new GPamela();
2271          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri  //      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2272    // //   t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2273            if(SELLI) t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2274            else      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2275    
2276          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2277      };      };
     // SelectionList  
     if(SELLI==1) {  
 //      t->SetBranchAddress("RunEntry", &irun);  
         t->SetBranchAddress("RunEntry", &irun);  
         cout << "SelectionList: set branch address RunEntry"<<endl;  
         t->SetBranchAddress("EventEntry", &irunentry);  
         cout << "SelectionList: set branch address EventEntry"<<endl;  
     };  
2278            
2279  }  }
2280  /**  /**
# Line 2297  void PamLevel2::SetBranchAddress(TChain Line 2354  void PamLevel2::SetBranchAddress(TChain
2354      if(GP) {      if(GP) {
2355  //      GetPointerTo("GPamela");  //      GetPointerTo("GPamela");
2356          if(!gp_obj)gp_obj = new GPamela();          if(!gp_obj)gp_obj = new GPamela();
2357          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri          if(SELLI) t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2358            else      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2359    //      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2360          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2361      };      };
2362      // SelectionList      // SelectionList
2363      if(SELLI==1) {  //     if(SELLI==1){
2364  //      t->SetBranchAddress("RunEntry", &irun);  //      t->SetBranchAddress("RunEntry",&irunt);//NEWNEW
2365          t->SetBranchAddress("RunEntry", &irun);  //      cout << "SelectionList: set branch address RunEntry"<<endl;
2366          cout << "SelectionList: set branch address RunEntry"<<endl;  //      t->SetBranchAddress("EventEntry",&irunentry);
2367          t->SetBranchAddress("EventEntry", &irunentry);  //      cout << "SelectionList: set branch address EventEntry"<<endl;
2368          cout << "SelectionList: set branch address EventEntry"<<endl;          
2369      };  //     }
2370        
2371  }  }
2372    
2373    
# Line 2330  TChain *PamLevel2::GetRunTree(TList *fl) Line 2389  TChain *PamLevel2::GetRunTree(TList *fl)
2389          return run_tree;          return run_tree;
2390      };        };  
2391      //      //
2392    
2393    
2394      TChain *R = new TChain("Run");      TChain *R = new TChain("Run");
2395            
2396      // loop over files and create chains              // loop over files and create chains        
# Line 2342  TChain *PamLevel2::GetRunTree(TList *fl) Line 2403  TChain *PamLevel2::GetRunTree(TList *fl)
2403              R->Add(name);              R->Add(name);
2404          };          };
2405      }      }
2406        
2407    
2408      if(R->GetNtrees()){      if(RUN && R->GetNtrees()){
2409            
2410          R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));          R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));
2411          cout << "Run         : set branch address RunInfo"<<endl;          cout << "Run         : set branch address RunInfo"<<endl;
2412          R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano          R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano
2413          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano
2414    
2415            irunoffset = new int[R->GetNtrees()];
2416            if(DBG){
2417                cout << "----------------------------------------------------"<<endl;
2418                cout << "irun\t | ";
2419                cout << "tree\t |";
2420    //      cout << "offset\t |";
2421                cout << "RUN\t";
2422                cout << "FRAG\t";
2423                cout << "NEVENTS\t";
2424                cout << "absolute time\t\t\t";
2425                cout << "on-board time";
2426                cout<<endl;
2427            }
2428            for (Int_t ii=0; ii<R->GetEntries(); ii++){
2429                R->GetEntry(ii);
2430                if(DBG){
2431                    cout << ii<< "\t | ";
2432                    cout << R->GetTreeNumber()<< "\t |";
2433    //          cout << R->GetChainOffset()<< "\t |";
2434                    cout <<GetRunInfo()->ID<<"\t";
2435                    cout <<GetRunInfo()->ID_RUN_FRAG<<"\t";
2436                    cout <<GetRunInfo()->NEVENTS<< "\t";
2437                    cout <<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME <<"\t";
2438                    cout <<GetRunInfo()->RUNHEADER_OBT<<" <---> "<<GetRunInfo()->RUNTRAILER_OBT<<"\t";
2439                    cout <<endl;
2440                }
2441                irunoffset[R->GetTreeNumber()]=R->GetChainOffset();
2442            }
2443            cout << "N.run = "<<R->GetEntries()<<endl;
2444            cout << "----------------------------------------------------"<<endl;
2445    
2446    
2447      }else{      }else{
2448          delete R;          delete R;
2449          R=0;          R=0;
2450      }      }
2451        
2452    
2453      run_tree = R;      run_tree = R;
2454    
# Line 2384  TTree *PamLevel2::GetRunTree(TFile *f){ Line 2480  TTree *PamLevel2::GetRunTree(TFile *f){
2480          cout << "Run         : set branch address RunInfo"<<endl;          cout << "Run         : set branch address RunInfo"<<endl;
2481          T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano          T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano
2482          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano
2483    
2484      }      }
2485    
2486      run_tree = (TChain*)T;      run_tree = (TChain*)T;
# Line 2452  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2549  Bool_t PamLevel2::UpdateRunInfo(TChain *
2549                 abstime <= GetRunInfo()->RUNTRAILER_TIME)                 abstime <= GetRunInfo()->RUNTRAILER_TIME)
2550              ){              ){
2551              irun = -1LL;              irun = -1LL;
2552                irunt = -1LL;
2553              runfirstentry = 0LL;              runfirstentry = 0LL;
2554              runlastentry = -1LL;              runlastentry = -1LL;
2555          };          };
# Line 2537  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2635  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2635        
2636      Int_t oldrun = irun; // store current run index      Int_t oldrun = irun; // store current run index
2637    
2638        // -----------------------------------------------------------------------
2639        // the first time the routine is called, set run search from the beginning
2640        // -----------------------------------------------------------------------
2641    
2642        if ( irun < 0 ){
2643            irun = 0LL;
2644            irunt = 0LL;
2645            irunentry = 0;
2646            prevshift = 0;
2647            run_tree->GetEntry(irun);
2648            if( !GetOrbitalInfo() )cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated "<<endl;
2649            if ( gltsync ) delete gltsync; //Emiliano
2650            if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection(); //Emiliano
2651            gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0,"ID",dbc,false); //Emiliano // the "false" means not to use level0 file (not necessary here)
2652            if ( dbc ) dbc->Close();// Emiliano
2653        };      
2654        // ---------------------------------------------------------------
2655        // retrieve OBT and absolute time of the event
2656        // ---------------------------------------------------------------
2657        ULong64_t abstime = 0LL;
2658        //    ULong64_t obt     = 0LL; // Emiliano
2659        Long64_t obt     = 0LL; // Emiliano, Long64_t GL_TIMESYNC::DBobt(UInt_t obt) since depending on the situation OBT is lowered or boosted
2660        if( GetOrbitalInfo() ){
2661            abstime = GetOrbitalInfo()->absTime;
2662            obt     = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano
2663        }else{
2664            abstime = GetRunInfo()->RUNHEADER_TIME;
2665            obt     = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano
2666        }
2667        
2668    
2669      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2670      // if it is a full file (not preselected)      // if it is a full file (not preselected)
2671      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2672      if(SELLI==0){      if(SELLI==0 || SELLI==2){ // Emiliano
2673    
2674          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2675          // increment dead and live-time counters          // increment dead and live-time counters
2676            // (only when reading a file not preselected)
2677          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2678          if( GetTrigLevel2() ){          if(SELLI==0){
2679              totdltime[0]+=GetTrigLevel2()->dltime[0];              if( GetTrigLevel2() ){
2680              totdltime[1]+=GetTrigLevel2()->dltime[1];                  totdltime[0]+=GetTrigLevel2()->dltime[0];
2681          }                  totdltime[1]+=GetTrigLevel2()->dltime[1];
         totdltime[2]++;  
   
 //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;  
   
         // ---------------------------------------------------------------  
         // retrieve OBT and absolute time of the event  
         // ---------------------------------------------------------------  
         ULong64_t abstime = 0;  
         ULong64_t obt     = 0;  
         if( GetOrbitalInfo() ){  
             abstime = GetOrbitalInfo()->absTime;  
             obt     = GetOrbitalInfo()->OBT;  
         }  
         // ---------------------------------------------------------------  
         // the absolute time is necessary to relate the event with the run  
         // ---------------------------------------------------------------  
         if( !GetOrbitalInfo() && !ISGP ){  
             cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;  
             return(false);  
         }  
         
         // -----------------------------------------------------------------------  
         // the first time the routine is called, set run search from the beginning  
         // -----------------------------------------------------------------------  
         if ( irun < 0 ){  
             irun = 0LL;  
             irunentry = 0;  
             prevshift = 0;  
             run_tree->GetEntry(irun);  
   
             if( ISGP && run_tree->GetEntries()!=1 ){  
                 cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl;  
                 cout << "** WARNING ** run will not be updated"<<endl;  
2682              }              }
2683          };                    totdltime[2]++;
   
         // -----------------------------------------------------------------------  
         // if it is simulation, assign abstime by hand (temporaneo!!!)  
         // -----------------------------------------------------------------------  
         if(ISGP){  
             abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO  
             obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO  
2684          }          }
2685    
2686          //          //
2687          bool fromfirst = true; // first loop over runs          bool fromfirst = true; // first loop over runs
2688    
 //      Bool_t hasfrag = false;  
 //      if( GetRunInfo()->ID_RUN_FRAG!=0 && GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID)hasfrag=true;  
 //      ULong64_t fragid = GetRunInfo()->ID_RUN_FRAG;  
2689    
2690          // ------------------------------------------------------          // ------------------------------------------------------
2691          // loop over runs to find the one that contains the event          // loop over runs to find the one that contains the event
2692          // ------------------------------------------------------          // ------------------------------------------------------
2693          while (          while (
2694              (              (
2695                  (  //              (
2696                      !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)  //                  !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2697                        abstime <= GetRunInfo()->RUNTRAILER_TIME) &&  //                    abstime <= GetRunInfo()->RUNTRAILER_TIME) &&
2698                      !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)  //                  !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2699                        obt <= GetRunInfo()->RUNTRAILER_OBT)  //                    obt <= GetRunInfo()->RUNTRAILER_OBT)
2700                      )  //                  )
2701                  || GetRunInfo()->NEVENTS==0                  
2702                    !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2703                      abstime <= GetRunInfo()->RUNTRAILER_TIME)
2704                    ||
2705                    !(obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) &&         // additional check on OBT (ms) // Emiliano
2706                      obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT))           // Emiliano
2707                    ||
2708                    GetRunInfo()->NEVENTS==0
2709  //              || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento  //              || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento
2710                  || !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift)                  ||
2711                    !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift)
2712                  )                  )
2713              && irun < run_tree->GetEntries() ){              && irun < run_tree->GetEntries() ){
2714    
2715    
2716    //          if( !(abstime >= GetRunInfo()->RUNHEADER_TIME &&abstime <= GetRunInfo()->RUNTRAILER_TIME)  )cout << "ABS TIME "<<abstime << " " <<GetRunInfo()->RUNTRAILER_TIME <<endl;
2717    //          if( !(obt >= GetRunInfo()->RUNHEADER_OBT && obt <= GetRunInfo()->RUNTRAILER_OBT) )cout << "OBT TIME "<< obt <<" "<< GetRunInfo()->RUNTRAILER_OBT << endl;
2718    //          if( GetRunInfo()->NEVENTS==0  )cout <<"GetRunInfo()->NEVENTS==0 "<<endl;
2719    //          if( !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift) ) cout << "irunentry > "<<GetRunInfo()->NEVENTS-1-prevshift << endl;
2720              // - - - - - - - - - - - - -              // - - - - - - - - - - - - -
2721              // irunentry = position of current entry, relative to the run              // irunentry = position of current entry, relative to the run
2722              // prevshift = shift needed to synchronize l0 and l2 data (nested events)              // prevshift = shift needed to synchronize l0 and l2 data (nested events)
# Line 2624  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2725  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2725              // -----------------------------------------              // -----------------------------------------
2726              // store dead and live-time of previous run              // store dead and live-time of previous run
2727              // -----------------------------------------              // -----------------------------------------
2728    //          if(SELLI==0){
2729              if(SELLI!=2){
2730              if(fromfirst){              if(fromfirst){
2731                  if(oldrun==irun){                  if(oldrun==irun){
2732                      /// decrement counters                      /// decrement counters
# Line 2632  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2735  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2735                          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time                          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2736                      }                      }
2737                      totdltime[2]--;                              //event counter                      totdltime[2]--;                              //event counter
2738                      cout << endl;                      if(DBG){
2739                      cout << "n.events     : "<<totdltime[2]<<endl;                          cout << endl;
2740                      cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;                          cout << "n.events     : "<<totdltime[2]<<endl;
2741                      cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;                                cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2742                            cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;          
2743                        }
2744                  }else{                  }else{
2745                      totdltime[0]=0;//live-time                      totdltime[0]=0;//live-time
2746                      totdltime[1]=0;//dead-time                      totdltime[1]=0;//dead-time
2747                      totdltime[2]=0;                             //event counter                      totdltime[2]=0;                             //event counter
2748                      cout << " *** JUMP RUN *** irun "<<irun<<endl;                      if(DBG)cout << " *** JUMP RUN *** irun "<<irun<<endl;
2749                  }                  }
2750                  /// add an entry                  /// add an entry
2751                  if(run_tree_clone)                  if(run_tree_clone)
# Line 2653  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2758  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2758                  }                  }
2759                  totdltime[2]=1;                             //event counter                  totdltime[2]=1;                             //event counter
2760              }              }
2761              }
2762              //        }
2763    
2764                irun++;        
             irun++;  
2765              // ------------------------------------              // ------------------------------------
2766              // if the end of run tree is reached...              // if the end of run tree is reached...
2767              // ------------------------------------              // ------------------------------------
# Line 2683  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2789  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2789              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2790              irunentry = 0;              irunentry = 0;
2791              prevshift = 0;                        prevshift = 0;          
2792              run_tree->GetEntry(irun);                    run_tree->GetEntry(irun);//update runinfo
2793              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              irunt = irun - irunoffset[run_tree->GetTreeNumber()];
2794                if ( gltsync ) delete gltsync; // Emiliano
2795                if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection(); //Emiliano
2796                gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0,"ID",dbc,false); // Emiliano
2797                if ( dbc ) dbc->Close(); // Emiliano
2798                if(gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT)>gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ){ // Emiliano
2799                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;
2800                  cout << "                                                            (NB!! in this case some events are assigned to a wrong run)"<<endl;                  cout << "                                                            (NB!! in this case some events are assigned to a wrong run)"<<endl;
2801              }              }
# Line 2705  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2816  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2816          // --------------------------------------          // --------------------------------------
2817    
2818    
   
 //      // -----------------------------------------  
 //      // store dead and live-time of previous run  
 //      // -----------------------------------------  
 //      // --------------------------------------------------------------  
 //      // if the run is empty, fill the dead-live time branch with zeros  
 //      // --------------------------------------------------------------  
 //      /// if some runs have been jumped, fill with zeros  
 //      if(irun-oldrun>1){  
 //          ULong64_t  temp[3];  
 //          temp[0]=totdltime[0];  
 //          temp[1]=totdltime[1];  
 //          temp[2]=totdltime[2];  
 //          for(int i=oldrun+1; i<irun; irun++){  
 //              totdltime[0]=0;  
 //              totdltime[1]=0;  
 //              totdltime[2]=0;  
 //              cout << " ** JUMPED RUN **"<<endl;  
 //              if(run_tree_clone)  
 //                  if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())  
 //                      run_tree_clone->GetBranch("DeadLiveTime")->Fill();  
 //          }  
 //          totdltime[0]=temp[0];  
 //          totdltime[1]=temp[1];  
 //          totdltime[2]=temp[2];  
 //      }  
 //      /// decrement counters  
 //      if( GetTrigLevel2() ){  
 //          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time  
 //          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time  
 //      }  
 //      totdltime[2]--;                              //event counter  
 //      /// add an entry  
 //      if(irun>0 ){  
 //          cout << endl;  
 //          cout << "n.events     : "<<totdltime[2]<<endl;  
 //          cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;  
 //          cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;        
 //          if(run_tree_clone)  
 //              if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())  
 //                  run_tree_clone->GetBranch("DeadLiveTime")->Fill();  
 //      }  
 //      /// reset counters  
 //      if( GetTrigLevel2() ){  
 //          totdltime[0]=GetTrigLevel2()->dltime[0];//live-time  
 //          totdltime[1]=0;                         //dead-time  
 //      }  
 //      totdltime[2]=1;                             //event counter  
           
   
2819          // --------------------------------------          // --------------------------------------
2820          // ---> exit with TRUE          // ---> exit with TRUE
2821          // --------------------------------------          // --------------------------------------
2822          cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;          if(DBG)cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
2823            // ----------------------------------------------------
2824            // update the tracker parameters
2825            // (non ho trovato nessun altro modo sicuro di farlo...)
2826            // ----------------------------------------------------
2827            if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection();
2828            TrkParams::Set(GetRunInfo() ,dbc);
2829            if(dbc)dbc->Close();
2830    
2831          // ----------------------------------------------------          // ----------------------------------------------------
2832          // then check if the run has a fragment          // then check if the run has a fragment
2833          // in this case we have to switch to the next fragment          // in this case we have to switch to the next fragment
# Line 2767  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2836  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2836          if(          if(
2837              GetRunInfo()->ID_RUN_FRAG != 0 &&              GetRunInfo()->ID_RUN_FRAG != 0 &&
2838  //          GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID &&  //          GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID &&
2839                DBG &&
2840              true ){              true ){
2841              cout << "* fragment *"<<endl;                            cout << "* fragment *"<<endl;              
2842          }          }
# Line 2776  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2846  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2846      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2847      // if it is a preselected file (there is SelectionList)      // if it is a preselected file (there is SelectionList)
2848      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2849        // irun  = run entry relative to the chain
2850        // irunt = run entry relative to the tree
2851      if(SELLI==1){            if(SELLI==1){      
2852          sel_tree->GetEntry(iev);          sel_tree->GetEntry(iev);// read irunt from SelectionList
2853          if(irun != oldrun){          irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW
2854              run_tree->GetEntry(irun);          if(irun != oldrun ){
2855              cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;              if( irun < run_tree->GetEntries() )run_tree->GetEntry(irun);
2856                // check if the time is ok (with merged files it is not...)
2857                // if not loop over run and look for the proper entry
2858                bool SECONDO_GIRO=false;
2859                //      Long64_t irun_start   = irun;
2860                int      offset_start = irunoffset[sel_tree->GetTreeNumber()];
2861                while (
2862                    (
2863                        (
2864                            !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2865                              abstime <= GetRunInfo()->RUNTRAILER_TIME)
2866    //                      ||
2867    //                      !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2868    //                        obt <= GetRunInfo()->RUNTRAILER_OBT)
2869                            )
2870                        || GetRunInfo()->NEVENTS==0
2871                        )
2872    //              && irun < run_tree->GetEntries()
2873                    ){
2874    
2875                    if(DBG){
2876                        cout << " (test) ";
2877                        cout << " tree "<<sel_tree->GetTreeNumber();
2878                        cout << " irunt "<<irunt;
2879                        cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2880                        cout << " abs "<<abstime;
2881                        cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2882                        cout << " obt "<<obt;
2883                        cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2884                        cout << " *** JUMP RUN *** irun "<<irun;
2885                        cout << endl;
2886                    }
2887    //              irun++;
2888                    irunoffset[sel_tree->GetTreeNumber()]++;
2889                    irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW          
2890                    if(irun == run_tree->GetEntries() && SECONDO_GIRO){
2891    //              if(irun == irun_start ){
2892                        cout << " ...grrrvzzkhhhajsdkj!!!! "<<endl;
2893                        irunoffset[sel_tree->GetTreeNumber()] = offset_start;
2894                        return false;
2895                    }
2896                    if( irun >= run_tree->GetEntries() || irun < 0){
2897                        cout << "irun = "<<irun<<" >>  search from the beginning... <<"<<endl;
2898                        SECONDO_GIRO=true;
2899                        irun=0;
2900                        irunoffset[sel_tree->GetTreeNumber()]=-irunt;
2901                    }
2902                    run_tree->GetEntry(irun);
2903                }
2904    
2905    
2906                if(DBG){
2907                    cout << " (test) ";
2908                    cout << " tree "<<sel_tree->GetTreeNumber();
2909                    cout << " irunt "<<irunt;
2910                    cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2911                    cout << " abs "<<abstime;
2912                    cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2913                    cout << " obt "<<obt;
2914                    cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2915                }
2916                if(DBG)cout << endl;
2917                if(DBG)cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" (run-entry "<<irun<<")"<<endl;
2918                // ----------------------------------------------------
2919                // update the tracker parameters
2920                // (non ho trovato nessun altro modo sicuro di farlo...)
2921                // ----------------------------------------------------
2922                if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection();
2923                TrkParams::Set(GetRunInfo() ,dbc);
2924                if(dbc)dbc->Close();
2925    //          cout << endl;
2926              prevshift = 0;              prevshift = 0;
2927              return true;              return true;
2928          }          }
# Line 2813  void PamLevel2::SetWhichTrees(TString de Line 2955  void PamLevel2::SetWhichTrees(TString de
2955      if( detlist.Contains("+ALL", TString::kIgnoreCase)){      if( detlist.Contains("+ALL", TString::kIgnoreCase)){
2956    
2957          cout << " ======================================================== "<<endl;          cout << " ======================================================== "<<endl;
2958          cout << "                       (( WARNING ))                      "<< endl;          cout << "                       (( WARNING ))                      "<<endl;
2959          cout << " The meaning of the option +ALL has changed!!             "<<endl;          cout << " The meaning of the option +ALL has changed!!             "<<endl;
2960          cout << " Now it includes really all (level0+level1+level2+gpamela)"<<endl;          cout << " Now it includes really all (level0+level1+level2+gpamela)"<<endl;
2961          cout << " and the file is discarded if it does not contain all     "<<endl;          cout << " and the file is discarded if it does not contain         "<<endl;
2962          cout << " trees or level0 files are not available!!                "<<endl;          cout << " all trees or  if level0 files are not available!!        "<<endl;
2963          cout << " ======================================================== "<<endl;          cout << " ======================================================== "<<endl;
2964                            
2965          CAL0 = true;          CAL0 = true;
# Line 2927  void PamLevel2::SetWhichTrees(TString de Line 3069  void PamLevel2::SetWhichTrees(TString de
3069      if( detlist.Contains("-GP", TString::kIgnoreCase) )GP = false;      if( detlist.Contains("-GP", TString::kIgnoreCase) )GP = false;
3070      else if( detlist.Contains("+GP", TString::kIgnoreCase) )GP = true;      else if( detlist.Contains("+GP", TString::kIgnoreCase) )GP = true;
3071    
3072      cout<< "Set detector list from input --> ";      cout<< "tree/branch list from input --> ";
3073      if(TRK0)cout<<"TRK0 ";      if(TRK0)cout<<"TRK0 ";
3074      if(TRK1)cout<<"TRK1 ";      if(TRK1)cout<<"TRK1 ";
3075      if(TRK2)cout<<"TRK2 ";      if(TRK2)cout<<"TRK2 ";
# Line 2987  void  PamLevel2::GetWhichTrees(TFile* f) Line 3129  void  PamLevel2::GetWhichTrees(TFile* f)
3129            
3130      RUN    = false;      RUN    = false;
3131                    
3132      cout << "Checking file: "<<f->GetName()<<endl;  //    cout << "Checking file: "<<f->GetName()<<endl;
3133      if( !f || f->IsZombie() ){      if( !f || f->IsZombie() ){
3134          cout << "File: "<< f->GetName() <<" Non valid root file"<< endl;          cout << "File: "<< f->GetName() <<" Non valid root file"<< endl;
3135          return;          return;
3136      }      }
3137    
3138      TList *lk = f->GetListOfKeys();      TList *lk = f->GetListOfKeys();
3139        if(!lk)return;
3140      TIter next(lk);      TIter next(lk);
3141      TKey *key =0;      TKey *key =0;
3142    
# Line 3106  void  PamLevel2::GetWhichTrees(TFile* f) Line 3249  void  PamLevel2::GetWhichTrees(TFile* f)
3249            
3250  //    delete lk;  //    delete lk;
3251    
3252      cout<< "Get detector list from input file --> ";      cout<< "tree/branch list from file  --> ";
3253      if(TRK1)cout<<"TRK1 ";      if(TRK1)cout<<"TRK1 ";
3254      if(TRK2)cout<<"TRK2 ";      if(TRK2)cout<<"TRK2 ";
3255      if(TRKh)cout<<"TRKH ";      if(TRKh)cout<<"TRKH ";
# Line 3154  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3297  Bool_t  PamLevel2::CheckLevel2File(TStri
3297            
3298      Bool_t SELLI__ok  = false;      Bool_t SELLI__ok  = false;
3299    
3300      cout << "Checking file: "<<name<<endl;  //    cout << "Checking file: "<<name<<endl;
3301      TFile *f = new TFile(name.Data());      TFile *f = new TFile(name.Data());
3302      if( !f || f->IsZombie() ){      if( !f || f->IsZombie() ){
3303          cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;
# Line 3316  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3459  Bool_t  PamLevel2::CheckLevel2File(TStri
3459              if(GP){              if(GP){
3460                  Int_t nevt = ((TTree*)f->Get("h20"))->GetEntries();                  Int_t nevt = ((TTree*)f->Get("h20"))->GetEntries();
3461                  if( nev && nevt!=nev){                  if( nev && nevt!=nev){
3462                      cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl;                      cout << "File: "<< f->GetName() <<" discarded ---- h20 tree has "<<nevt<<" events instead of "<<nev<< endl;
3463                      return false;                      return false;
3464                  }                  }
3465                  nev=nevt;                  nev=nevt;
# Line 3362  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3505  Bool_t  PamLevel2::CheckLevel2File(TStri
3505    
3506    
3507      if(!RUN__ok) {      if(!RUN__ok) {
3508          cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl;          cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree (NB: RUN infos will not be updated)"<< endl;
3509  //      return false;          RUN = false;
3510      };      };
3511    
3512      if(CAL1 && !CAL1__ok){      if(CAL1 && !CAL1__ok){
# Line 3486  void PamLevel2::CreateCloneTrees(TFile * Line 3629  void PamLevel2::CreateCloneTrees(TFile *
3629    
3630    
3631  //  if the pointer is null, create a default file  //  if the pointer is null, create a default file
3632        if(!run_tree)return;
3633    
3634      if(!ofile){      if(!ofile){
3635          cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;          cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;
# Line 3506  void PamLevel2::CreateCloneTrees(TFile * Line 3650  void PamLevel2::CreateCloneTrees(TFile *
3650      // ------------------      // ------------------
3651      // replicate run tree      // replicate run tree
3652      // ------------------      // ------------------
3653      cout << "----------------------------------------------------"<<endl;  //    cout << "----------------------------------------------------"<<endl;
3654      cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl;  //    cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl;
3655      for (Int_t i=0; i<run_tree->GetEntries(); i++){      for (Int_t i=0; i<run_tree->GetEntries(); i++){
3656          run_tree->GetEntry(i);          run_tree->GetEntry(i);
3657          cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;  //      cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;
3658          run_tree_clone->Fill();          run_tree_clone->Fill();
3659      }      }
3660      cout << "----------------------------------------------------"<<endl;      cout << "----------------------------------------------------"<<endl;
# Line 3518  void PamLevel2::CreateCloneTrees(TFile * Line 3662  void PamLevel2::CreateCloneTrees(TFile *
3662      // ------------------------------------      // ------------------------------------
3663      // add branch with dead and live times      // add branch with dead and live times
3664      // ------------------------------------      // ------------------------------------
3665      run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");      if ( SELLI != 2 ){ // EMILIANO
3666      cout << "Run          : branch DeadLiveTime"<<endl;        run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");
3667          cout << "Run          : branch DeadLiveTime"<<endl;
3668    
3669    
3670      sel_tree_clone = new TTree("SelectionList","List of selected events ");        sel_tree_clone = new TTree("SelectionList","List of selected events ");
3671  //    sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");        //    sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");
3672      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");        sel_tree_clone->Branch("RunEntry",&irunt,"runentry/L");//NEWNEW
3673      sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L");        sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L");
3674            };
3675    
3676      Int_t i=0;      Int_t i=0;
3677      if(TRK1||TRK2||TRKh){      if(TRK1||TRK2||TRKh){
# Line 3599  void PamLevel2::CreateCloneTrees(TFile * Line 3744  void PamLevel2::CreateCloneTrees(TFile *
3744      };      };
3745      // OrbitalInfo      // OrbitalInfo
3746      if(ORB) {      if(ORB) {
3747          pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info  ");            pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA orbital info  ");  
3748          pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo"));          pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo"));
3749          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;
3750          i++;          i++;
3751      };      };
3752      // GPamela      // GPamela
3753      if(GP) {      if(GP) {
3754          pam_tree_clone[i] = new TTree("h20","PAMELA oribital info  ");            pam_tree_clone[i] = new TTree("h20","GPAMELA info ");  
3755          pam_tree_clone[i]->Branch("GPamela","GPamela", GetPointerTo("GPamela"),32000,1);//split          pam_tree_clone[i]->Branch("GPamela","GPamela", GetPointerTo("GPamela"),32000,1);//split
3756          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;          cout << "OrbitalInfo  : branch OrbitalInfo"<<endl;
3757          i++;          i++;
# Line 3656  void PamLevel2::WriteCloneTrees(){ Line 3801  void PamLevel2::WriteCloneTrees(){
3801      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
3802      cout << "Write clones of PAMELA trees "<<endl;      cout << "Write clones of PAMELA trees "<<endl;
3803      cout << run_tree_clone->GetName()<<endl;        cout << run_tree_clone->GetName()<<endl;  
3804      if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())      if ( SELLI != 2){// Emiliano
3805          if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
3806          run_tree_clone->GetBranch("DeadLiveTime")->Fill();          run_tree_clone->GetBranch("DeadLiveTime")->Fill();
3807        };
3808      run_tree_clone->Write();      run_tree_clone->Write();
3809      cout << sel_tree_clone->GetName()<<endl;          if ( SELLI != 2){ //Emiliano
3810      sel_tree_clone->Write();        cout << sel_tree_clone->GetName()<<endl;    
3811          sel_tree_clone->Write();
3812        };
3813      for(Int_t i=0; i<NCLONES; i++){          for(Int_t i=0; i<NCLONES; i++){    
3814          if(pam_tree_clone[i]){          if(pam_tree_clone[i]){
3815              cout << pam_tree_clone[i]->GetName()<<endl;              cout << pam_tree_clone[i]->GetName()<<endl;
# Line 3698  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3847  Int_t PamLevel2::GetEntry(Long64_t iee){
3847      //-------------------------------      //-------------------------------
3848      ii = iee;      ii = iee;
3849      if( !pam_tree->GetEntry(ii) ){            if( !pam_tree->GetEntry(ii) ){      
3850          cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl;        cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<<endl;
3851          return 0;        return 0;
3852      }      }
   
 //    cout << " gp_obj->P0 "<<gp_obj->P0<<endl;  
3853      //      //
3854      // ... 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.      // ... 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.
3855      // 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      // 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
3856      // a problem if you don't check the return code of getentry.      // a problem if you don't check the return code of getentry.
3857      //      //
3858      if(!run_tree ){      if(!RUN || !run_tree ){
3859          if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1?          if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1?
3860              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl;              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl;
3861              return 0;              return 0;
# Line 3722  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3869  Int_t PamLevel2::GetEntry(Long64_t iee){
3869  //    Bool_t UPDATED = UpdateRunInfo(run_tree,ii);  //    Bool_t UPDATED = UpdateRunInfo(run_tree,ii);
3870  //    Bool_t UPDATED = UpdateRunInfo(ii);  //    Bool_t UPDATED = UpdateRunInfo(ii);
3871      UpdateRunInfo(ii);      UpdateRunInfo(ii);
3872      if(SELLI==0)irunentry = iee-runfirstentry;      if(SELLI==0||SELLI==2)irunentry = iee-runfirstentry;
3873  //    if(UPDATED && run_tree_clone)run_tree_clone->Fill();  //    if(UPDATED && run_tree_clone)run_tree_clone->Fill();
3874        
3875  //    cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl;  //    cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl;
# Line 3851  TTree* PamLevel2::GetYodaTree( ){ Line 3998  TTree* PamLevel2::GetYodaTree( ){
3998  //     }  //     }
3999    
4000      if ( TRK0 ){      if ( TRK0 ){
4001          TrkParams::Load(6);  //      TrkParams::Load(6);
4002          if( !TrkParams::IsLoaded(6) ){  //      if( !TrkParams::IsLoaded(6) ){
4003              cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl;  //          cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl;
4004          };  //      };
4005          if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection();  //      if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection();
4006          TrkParams::SetCalib(run_obj,dbc);          TrkParams::SetCalib(run_obj,dbc);
4007          TrkParams::LoadCalib( );          TrkParams::LoadCalib( );
4008          if( !TrkParams::CalibIsLoaded() ){          if( !TrkParams::CalibIsLoaded() ){
4009              cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl;              cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- Calibration not loaded"<<endl;
4010          };          };
4011          dbc->Close(); // EMILIANO, do not leave open connections, open only when needed  //      if(dbc)dbc->Close(); // EMILIANO, do not leave open connections, open only when needed
4012      }      }
4013    
4014    
# Line 3930  Int_t PamLevel2::GetYodaEntry(){ Line 4077  Int_t PamLevel2::GetYodaEntry(){
4077      do{      do{
4078          if(shift>0){              if(shift>0){    
4079              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
4080              cout << "         RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM  <<endl;              if(DBG)cout << "         RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM  <<endl;
4081              cout << "         L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl;              if(DBG)cout << "         L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl;
4082          }          }
4083          answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift);          answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift);
4084          shift++;          shift++;
# Line 3964  Int_t PamLevel2::GetYodaEntry(){ Line 4111  Int_t PamLevel2::GetYodaEntry(){
4111              && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);              && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);
4112    
4113      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {
4114          cout << " Big trouble here, no such event in Level0 data! " <<endl;          cout << " Big trouble here, no such event in Level0 data! (NB maxshift set to "<<maxshift<<" )" <<endl;
4115          return 0;          return 0;
4116      }      }
4117  //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl;  //    cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl;
# Line 3979  Int_t PamLevel2::GetYodaEntry(){ Line 4126  Int_t PamLevel2::GetYodaEntry(){
4126   */   */
4127  Bool_t PamLevel2::SetDBConnection(){  Bool_t PamLevel2::SetDBConnection(){
4128    
4129      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;  //    cout << "PamLevel2::SetDBConnection()" << endl;
4130      cout<<"Connecting to DB"<<endl;      if(DBG){
4131      cout<<"HOST "<<host<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
4132      cout<<"USER "<<user<<endl;          cout<<"Connecting to DB"<<endl;
4133      cout<<"PSW  "<<psw<<endl;          cout<<"HOST "<<host<<endl;
4134            cout<<"USER "<<user<<endl;
4135            cout<<"PSW  "<<psw<<endl;
4136        }
4137      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
4138      if( !dbc )return false;      if( !dbc )return false;
4139      if( !dbc->IsConnected() )return false;          if( !dbc->IsConnected() )return false;    
# Line 3991  Bool_t PamLevel2::SetDBConnection(){ Line 4141  Bool_t PamLevel2::SetDBConnection(){
4141      myquery.str("");  // EMILIANO      myquery.str("");  // EMILIANO
4142      myquery << "SET time_zone='+0:00'";  // EMILIANO      myquery << "SET time_zone='+0:00'";  // EMILIANO
4143      dbc->Query(myquery.str().c_str());  // EMILIANO      dbc->Query(myquery.str().c_str());  // EMILIANO
4144      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(DBG)cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
4145      return true;      return true;
4146    
4147  }  }

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.80

  ViewVC Help
Powered by ViewVC 1.1.23