/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkLevel2.cpp
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/TrkLevel2.cpp

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

revision 1.5 by pam-fi, Fri Jun 30 09:48:15 2006 UTC revision 1.7 by pam-fi, Fri Jul 21 11:03:14 2006 UTC
# Line 240  TrkLevel2::TrkLevel2(){ Line 240  TrkLevel2::TrkLevel2(){
240      Track    = new TClonesArray("TrkTrack");      Track    = new TClonesArray("TrkTrack");
241      SingletX = new TClonesArray("TrkSinglet");      SingletX = new TClonesArray("TrkSinglet");
242      SingletY = new TClonesArray("TrkSinglet");      SingletY = new TClonesArray("TrkSinglet");
243  //    Track    = 0;  
244  //    Singlet = 0;  //      PhysicalTrack = new TClonesArray("TrkTrack");
245  //    SingletY = 0;          //sostituire con TRefArray... appena ho capito come si usa
246  }  }
247  //--------------------------------------  //--------------------------------------
248  //  //
# Line 270  void TrkLevel2::Dump(){ Line 270  void TrkLevel2::Dump(){
270  /**  /**
271   * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).   * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).
272   */   */
273  void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){  void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){
274      //      //
275  //    Track    = new TClonesArray("TrkTrack");  //    Track    = new TClonesArray("TrkTrack");
276  //    SingletX = new TClonesArray("TrkSinglet");  //    SingletX = new TClonesArray("TrkSinglet");
# Line 337  void TrkLevel2::FillCommonVar(cTrkLevel2 Line 337  void TrkLevel2::FillCommonVar(cTrkLevel2
337          delete t_track;          delete t_track;
338          delete t_singlet;          delete t_singlet;
339  }  }
340    /**
341     * Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common).
342     */
343    
344    void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const {
345      
346    //  general variables
347        l2->good2 = good2 ;
348        for(Int_t i=0; i<12 ; i++){
349            l2->crc[i] = crc[i];
350        };
351    //  *** TRACKS ***
352    
353        l2->ntrk              =  Track->GetEntries();    
354        for(Int_t i=0;i<l2->ntrk;i++){
355          l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image;
356          l2->chi2_nt[i] =  ((TrkTrack *)Track->At(i))->chi2;
357          for(int it1=0;it1<5;it1++){
358            l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1];
359            for(int it2=0;it2<5;it2++)
360              l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2];
361          };
362          for(int ip=0;ip<6;ip++){
363            l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip];
364            l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip];
365            l2->xm_nt[i][ip]    = ((TrkTrack *)Track->At(i))->xm[ip];
366            l2->ym_nt[i][ip]    = ((TrkTrack *)Track->At(i))->ym[ip];
367            l2->zm_nt[i][ip]    = ((TrkTrack *)Track->At(i))->zm[ip];
368            l2->resx_nt[i][ip]  = ((TrkTrack *)Track->At(i))->resx[ip];
369            l2->resy_nt[i][ip]  = ((TrkTrack *)Track->At(i))->resy[ip];
370            l2->xv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->xv[ip];
371            l2->yv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->yv[ip];
372            l2->zv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->zv[ip];
373            l2->axv_nt[i][ip]   = ((TrkTrack *)Track->At(i))->axv[ip];
374            l2->ayv_nt[i][ip]   = ((TrkTrack *)Track->At(i))->ayv[ip];
375            l2->dedx_x[i][ip]   = ((TrkTrack *)Track->At(i))->dedx_x[ip];
376            l2->dedx_y[i][ip]   = ((TrkTrack *)Track->At(i))->dedx_y[ip];
377          };
378        }
379    
380    //  *** SINGLETS ***    
381        l2->nclsx              = SingletX->GetEntries();
382        for(Int_t i=0;i<l2->nclsx;i++){
383          l2->planex[i]  = ((TrkSinglet *)SingletX->At(i))->plane;
384          l2->xs[i][0]   = ((TrkSinglet *)SingletX->At(i))->coord[0];
385          l2->xs[i][1]   = ((TrkSinglet *)SingletX->At(i))->coord[1];
386          l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl;
387        }
388        l2->nclsy              = SingletY->GetEntries();
389        for(Int_t i=0;i<l2->nclsy;i++){
390          l2->planey[i]  = ((TrkSinglet *)SingletY->At(i))->plane;
391          l2->ys[i][0]   = ((TrkSinglet *)SingletY->At(i))->coord[0];
392          l2->ys[i][1]   = ((TrkSinglet *)SingletY->At(i))->coord[1];
393          l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl;
394        }
395    }
396  //--------------------------------------  //--------------------------------------
397  //  //
398  //  //
# Line 365  void TrkLevel2::Clear(){ Line 421  void TrkLevel2::Clear(){
421  TClonesArray *TrkLevel2::GetTracks(){  TClonesArray *TrkLevel2::GetTracks(){
422      TClonesArray *sorted = GetTracks_NFitSorted();      TClonesArray *sorted = GetTracks_NFitSorted();
423      return sorted;      return sorted;
424            
425            // fare di meglio...
426    /*      PhysicalTrack->Clear();
427            if(ntrk() > 0) GetTracks_NFitSorted();
428            return PhysicalTrack;*/
429  };  };
430    
431  TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){  /*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){
432    
433      TClonesArray *sorted = new TClonesArray("TrkTrack");      TClonesArray *sorted = new TClonesArray("TrkTrack");
434      TClonesArray &t = *Track;      TClonesArray &t = *Track;
# Line 395  TClonesArray *TrkLevel2::GetTracks_Chi2S Line 456  TClonesArray *TrkLevel2::GetTracks_Chi2S
456          indo++;          indo++;
457      }      }
458      return sorted;      return sorted;
459  }  }*/
460  TClonesArray *TrkLevel2::GetTracks_NFitSorted(){  TClonesArray *TrkLevel2::GetTracks_NFitSorted(){
461    
462      TClonesArray *sorted = new TClonesArray("TrkTrack");          TClonesArray *sorted = new TClonesArray("TrkTrack");    
463      TClonesArray &t = *Track;      TClonesArray &t = *Track;
464      TClonesArray &ts = *sorted;          TClonesArray &ts = *sorted;
465      int N=this->ntrk();  //    TClonesArray &ts = *PhysicalTrack;
466            int N=this->ntrk();
467      vector<int> m(N); for(int i=0; i<N; i++)m[i]=1;      vector<int> m(N); for(int i=0; i<N; i++)m[i]=1;
468    
469      int indo=0;      int indo=0;
# Line 441  TClonesArray *TrkLevel2::GetTracks_NFitS Line 503  TClonesArray *TrkLevel2::GetTracks_NFitS
503          indo++;          indo++;
504      }      }
505      return sorted;      return sorted;
506    //    return PhysicalTrack;
507  }  }
508  //--------------------------------------  //--------------------------------------
509  //  //
# Line 467  TrkTrack *TrkLevel2::GetStoredTrack(int Line 530  TrkTrack *TrkLevel2::GetStoredTrack(int
530  //  //
531  //--------------------------------------  //--------------------------------------
532  /**  /**
533     * Retrieves the is-th stored X singlet.
534     * @param it Singlet number, ranging from 0 to nclsx().
535     */
536    TrkSinglet *TrkLevel2::GetSingletX(int is){
537    
538            if(is >= this->nclsx()){
539                    cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl;
540                    cout << "                Stored x-singlets nclsx() = "<< this->nclsx() << endl;
541                    return 0;
542            }
543            TClonesArray &t = *(SingletX);
544            TrkSinglet *singlet = (TrkSinglet*)t[is];
545            return singlet;
546    }
547    //--------------------------------------
548    //
549    //
550    //--------------------------------------
551    /**
552     * Retrieves the is-th stored Y singlet.
553     * @param it Singlet number, ranging from 0 to nclsx().
554     */
555    TrkSinglet *TrkLevel2::GetSingletY(int is){
556    
557            if(is >= this->nclsy()){
558                    cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl;
559                    cout << "                Stored y-singlets nclsy() = "<< this->nclsx() << endl;
560                    return 0;
561            }
562            TClonesArray &t = *(SingletY);
563            TrkSinglet *singlet = (TrkSinglet*)t[is];
564            return singlet;
565    }
566    //--------------------------------------
567    //
568    //
569    //--------------------------------------
570    /**
571   * Retrieves the it-th "physical" track, sorted by the method GetNTracks().   * Retrieves the it-th "physical" track, sorted by the method GetNTracks().
572   * @param it Track number, ranging from 0 to GetNTracks().   * @param it Track number, ranging from 0 to GetNTracks().
573   */   */
# Line 481  TrkTrack *TrkLevel2::GetTrack(int it){ Line 582  TrkTrack *TrkLevel2::GetTrack(int it){
582          GetTracks()->Delete();////TEMPORANEO          GetTracks()->Delete();////TEMPORANEO
583      return track;      return track;
584  }  }
585    /**
586     * Give the number of "physical" tracks, sorted by the method GetTracks().
587     */
588  Int_t TrkLevel2::GetNTracks(){  Int_t TrkLevel2::GetNTracks(){
589          Int_t ntot=0;          Int_t ntot=0;
590          ntot = GetTracks()->GetEntries();          ntot = GetTracks()->GetEntries();
# Line 508  TrkTrack *TrkLevel2::GetTrackImage(int i Line 612  TrkTrack *TrkLevel2::GetTrackImage(int i
612          return 0;          return 0;
613      }      }
614      TrkTrack *image = (TrkTrack*)(*Track)[track->image];      TrkTrack *image = (TrkTrack*)(*Track)[track->image];
615            GetTracks()->Delete(); ////TEMPORANEO
616      return image;      return image;
617            
618  }  }
# Line 527  void TrkLevel2::LoadField(TString s){ Line 632  void TrkLevel2::LoadField(TString s){
632  //  //
633  //--------------------------------------  //--------------------------------------
634  /**  /**
635     * Get tracker-plane (mechanical) z-coordinate
636     * @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM)
637     */
638    Float_t TrkLevel2::GetZTrk(Int_t plane_id){
639            switch(plane_id){
640                    case 1: return ZTRK1;
641                    case 2: return ZTRK2;
642                    case 3: return ZTRK3;
643                    case 4: return ZTRK4;
644                    case 5: return ZTRK5;
645                    case 6: return ZTRK6;
646                    default: return 0.;
647            };
648    };
649    //--------------------------------------
650    //
651    //
652    //--------------------------------------
653    /**
654   * Trajectory default constructor.   * Trajectory default constructor.
655   * (By default is created with z-coordinates inside the tracking volume)   * (By default is created with z-coordinates inside the tracking volume)
656    */    */
# Line 538  Trajectory::Trajectory(){ Line 662  Trajectory::Trajectory(){
662      thx = new float[npoint];      thx = new float[npoint];
663      thy = new float[npoint];      thy = new float[npoint];
664      tl = new float[npoint];      tl = new float[npoint];
665      float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1);      float dz = ((ZTRK1)-(ZTRK6))/(npoint-1);
666      for(int i=0; i<npoint; i++){      for(int i=0; i<npoint; i++){
667          x[i] = 0;          x[i] = 0;
668          y[i] = 0;          y[i] = 0;
669          z[i] = (ZTRKUP) - i*dz;          z[i] = (ZTRK1) - i*dz;
670          thx[i] = 0;          thx[i] = 0;
671          thy[i] = 0;          thy[i] = 0;
672          tl[i] = 0;          tl[i] = 0;
# Line 569  Trajectory::Trajectory(int n){ Line 693  Trajectory::Trajectory(int n){
693      thx = new float[npoint];      thx = new float[npoint];
694      thy = new float[npoint];      thy = new float[npoint];
695      tl = new float[npoint];      tl = new float[npoint];
696      float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1);      float dz = ((ZTRK1)-(ZTRK6))/(npoint-1);
697      for(int i=0; i<npoint; i++){      for(int i=0; i<npoint; i++){
698          x[i] = 0;          x[i] = 0;
699          y[i] = 0;          y[i] = 0;
700          z[i] = (ZTRKUP) - i*dz;          z[i] = (ZTRK1) - i*dz;
701          thx[i] = 0;          thx[i] = 0;
702          thy[i] = 0;          thy[i] = 0;
703          tl[i] = 0;          tl[i] = 0;
# Line 647  float Trajectory::GetLength(int ifirst, Line 771  float Trajectory::GetLength(int ifirst,
771      return l;      return l;
772    
773  }  }
774    
775  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
776  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
777  ClassImp(TrkTrack);  ClassImp(TrkTrack);

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.23