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

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

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

revision 1.11 by pam-fi, Thu Jan 11 10:20:58 2007 UTC revision 1.18 by pam-fi, Thu May 24 14:17:00 2007 UTC
# Line 239  Bool_t TrkCluster::IsBad(Int_t nbad){ Line 239  Bool_t TrkCluster::IsBad(Int_t nbad){
239      il = indmax;      il = indmax;
240      ir = indmax;      ir = indmax;
241      for(Int_t i=1; i<nbad; i++){      for(Int_t i=1; i<nbad; i++){
242          if (ir == CLlength && il == 0)break;          if (ir == CLlength-1 && il == 0)break;
243          else if (ir == CLlength && il != 0)il--;          else if (ir == CLlength-1 && il != 0)il--;
244          else if (ir != CLlength && il == 0)ir++;          else if (ir != CLlength-1 && il == 0)ir++;
245          else{          else{
246              if(clsignal[il-1] > clsignal[ir+1])il--;              if(clsignal[il-1] > clsignal[ir+1])il--;
247              else ir++;              else ir++;
# Line 264  Bool_t TrkCluster::IsSaturated(Int_t nba Line 264  Bool_t TrkCluster::IsSaturated(Int_t nba
264      il = indmax;      il = indmax;
265      ir = indmax;      ir = indmax;
266      for(Int_t i=1; i<nbad; i++){      for(Int_t i=1; i<nbad; i++){
267          if (ir == CLlength && il == 0)break;          if (ir == CLlength-1 && il == 0)break;
268          else if (ir == CLlength && il != 0)il--;          else if (ir == CLlength-1 && il != 0)il--;
269          else if (ir != CLlength && il == 0)ir++;          else if (ir != CLlength-1 && il == 0)ir++;
270          else{          else{
271              if(clsignal[il-1] > clsignal[ir+1])il--;              if(clsignal[il-1] > clsignal[ir+1])il--;
272              else ir++;              else ir++;
# Line 291  void TrkCluster::Dump(){ Line 291  void TrkCluster::Dump(){
291      cout << "Position of maximun "<< maxs <<endl;      cout << "Position of maximun "<< maxs <<endl;
292      cout << "Multiplicity        "<< GetMultiplicity() <<endl;      cout << "Multiplicity        "<< GetMultiplicity() <<endl;
293      cout << "Tot signal          "<< GetSignal() << " (ADC channels)"<<endl ;      cout << "Tot signal          "<< GetSignal() << " (ADC channels)"<<endl ;
294      cout << "Signal/Noise        "<< GetSignalToNoise();      cout << "Signal/Noise        "<< GetSignalToNoise()<<endl;
295      cout <<endl<< "Strip signals       ";      cout << "COG                 "<< GetCOG(0)<<endl;;
296        cout << "Strip signals       ";
297      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];
298      cout <<endl<< "Strip sigmas        ";      cout <<endl<< "Strip sigmas        ";
299      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];
# Line 313  void TrkCluster::Dump(){ Line 314  void TrkCluster::Dump(){
314  /**  /**
315   * Method to fill a level1 struct with only one cluster (done to use F77 p.f.a. routines on a cluster basis).   * Method to fill a level1 struct with only one cluster (done to use F77 p.f.a. routines on a cluster basis).
316   */   */
317  cTrkLevel1* TrkCluster::GetLevel1Struct(){  void TrkCluster::GetLevel1Struct(cTrkLevel1* l1){
318                                    
319  //    cTrkLevel1* l1 = new cTrkLevel1;  //    cTrkLevel1* l1 = new cTrkLevel1;
320    
321      cTrkLevel1* l1 = &level1event_ ;  //    cTrkLevel1* l1 = &level1event_ ;
322                    
323      l1->nclstr1 = 1;      l1->nclstr1 = 1;
324      l1->view[0] = view;      l1->view[0] = view;
# Line 335  cTrkLevel1* TrkCluster::GetLevel1Struct( Line 336  cTrkLevel1* TrkCluster::GetLevel1Struct(
336          l1->clbad[i] = clbad[i];          l1->clbad[i] = clbad[i];
337      };      };
338            
339      return l1;  //    return l1;
340  };  };
341  //--------------------------------------  //--------------------------------------
342  //  //
# Line 397  Float_t TrkCluster::GetETA(Int_t neta, f Line 398  Float_t TrkCluster::GetETA(Int_t neta, f
398  //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;  //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;
399  //      LoadPfaParam();  //      LoadPfaParam();
400    
401        TrkParams::Load(4);
402        if( !TrkParams::IsLoaded(4) ){
403            cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
404            return 0;
405        }
406    
407      float ax = angle;      float ax = angle;
408      int ic = 1;      int ic = 1;
409      GetLevel1Struct();      GetLevel1Struct();
# Line 425  TrkLevel1::TrkLevel1(){ Line 432  TrkLevel1::TrkLevel1(){
432              cnn[j][i]=0;              cnn[j][i]=0;
433          };          };
434      };      };
435        TrkParams::SetTrackingMode();
436        TrkParams::SetPrecisionFactor();
437        TrkParams::SetStepMin();
438        TrkParams::SetPFA();
439    }
440    //--------------------------------------
441    //
442    //
443    //--------------------------------------
444    void TrkLevel1::Set(){
445        if(!Cluster)Cluster = new TClonesArray("TrkCluster");
446  }  }
447  //--------------------------------------  //--------------------------------------
448  //  //
# Line 450  void TrkLevel1::Dump(){ Line 468  void TrkLevel1::Dump(){
468      for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();      for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();
469            
470  }  }
471    /**
472     * \brief Dump processing status
473     */
474    void TrkLevel1::StatusDump(int view){
475        cout << "DSP n. "<<view+1<<" (level1-)status: "<<hex<<showbase<<good[view]<<dec<<endl;    
476    };
477    /**
478     * \brief Check event status
479     *
480     * Check the event status, according to a flag-mask given as input.
481     * Return true if the view passes the check.
482     *
483     * @param view View number (0-11)
484     * @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet,
485     *  no crc error, no software alarm)
486     *
487     * @see TrkLevel2 class definition to know how the status flag is defined
488     *
489     */
490    Bool_t TrkLevel1::StatusCheck(int view, int flagmask){
491    
492        if( view<0 || view >= 12)return false;
493        return !(good[view]&flagmask);
494    
495    };
496    
497    
498  //--------------------------------------  //--------------------------------------
499  //  //
500  //  //
# Line 459  void TrkLevel1::Dump(){ Line 504  void TrkLevel1::Dump(){
504   */   */
505  void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){  void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){
506    
507    //    cout << "void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full)"<<endl;
508        
509        Clear();
510      //  ---------------      //  ---------------
511      //  *** CLUSTER ***      //  *** CLUSTER ***
512      //  ---------------      //  ---------------
# Line 515  void TrkLevel1::SetFromLevel1Struct(cTrk Line 563  void TrkLevel1::SetFromLevel1Struct(cTrk
563   * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common).   * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common).
564   */   */
565    
566  cTrkLevel1* TrkLevel1::GetLevel1Struct() {  void TrkLevel1::GetLevel1Struct(cTrkLevel1* l1) {
567            
568      cTrkLevel1 *l1=0;  //    cTrkLevel1* l1 = &level1event_ ;
569      //      
570      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
571          l1->good[i] = good[i];          l1->good[i] = good[i];
572          for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
573              l1->cnev[j][i]    = cn[j][i];              l1->cnev[j][i]    = cn[j][i]  ;
574  //          l1->cnrmsev[j][i] = cnrms[j][i];              l1->cnnev[j][i]   = cnn[j][i] ;
575              l1->cnnev[j][i]   = cnn[j][i];              l1->cnrmsev[j][i] = 0. ;
576          };          };
577            l1->fshower[i] = 0;
578      };      };
579        
580  //  *** CLUSTERS ***      l1->nclstr1=0;
581        l1->totCLlength=0;
582        Int_t index=0;
583      if(Cluster){      if(Cluster){
584          l1->nclstr1 =  Cluster->GetEntries();          Int_t i=0;
585          for(Int_t i=0;i<l1->nclstr1;i++){          for(Int_t ii=0;ii<Cluster->GetEntries();ii++){
586                        TrkCluster *clu = GetCluster(ii);
587              l1->view[i]     = ((TrkCluster *)Cluster->At(i))->view;              // ----------------------------------------
588              l1->maxs[i]     = ((TrkCluster *)Cluster->At(i))->maxs;              // attenzione!!
589              // COMPLETARE //              // se il cluster non e` salvato (view = 0)
590              // COMPLETARE //              // DEVE essere escluso dal common F77
591              // COMPLETARE //              // ----------------------------------------
592              // COMPLETARE //              if(clu->view != 0 ){
593              // COMPLETARE //                  l1->view[i]     = clu->view;
594              // COMPLETARE //                  l1->ladder[i]   = clu->GetLadder();
595                            l1->maxs[i]     = clu->maxs;
596                    l1->mult[i]     = clu->GetMultiplicity();
597                    l1->dedx[i]     = clu->GetSignal();
598                    l1->indstart[i] = index+1;
599                    l1->indmax[i]   = l1->indstart[i] + clu->indmax;
600                    l1->totCLlength += clu->CLlength;
601                    for(Int_t iw=0; iw < clu->CLlength; iw++){
602                        l1->clsignal[index] = clu->clsignal[iw];
603                        l1->clsigma[index]  = clu->clsigma[iw];
604                        l1->cladc[index]    = clu->cladc[iw];
605                        l1->clbad[index]    = clu->clbad[iw];
606                        index++;
607                    }
608                    i++;
609                }
610          }          }
611          // COMPLETARE //          l1->nclstr1 =  i;      
         // COMPLETARE //  
         // COMPLETARE //  
         // COMPLETARE //  
         // COMPLETARE //  
         // COMPLETARE //  
612      }      }
613      return l1;  
614    //    return l1;
615  }  }
616  //--------------------------------------  //--------------------------------------
617  //  //
# Line 601  TrkCluster *TrkLevel1::GetCluster(int is Line 662  TrkCluster *TrkLevel1::GetCluster(int is
662  //  //
663  //  //
664  //--------------------------------------  //--------------------------------------
665    // /**
666    //  * Load Position-Finding-Algorythm parameters (call the F77 routine).
667    //  *
668    //  */
669    // int TrkLevel1::LoadPfaParam(TString path){
670            
671    //     if( path.IsNull() ){
672    //      path = gSystem->Getenv("PAM_CALIB");
673    //      if(path.IsNull()){
674    //          cout << " TrkLevel1::LoadPfaParam() ==> No PAMELA environment variables defined "<<endl;
675    //          return 0;
676    //      }
677    //      path.Append("/trk-param/eta_param-0/");
678    //     }
679    
680    //     strcpy(path_.path,path.Data());
681    //     path_.pathlen = path.Length();
682    //     path_.error   = 0;
683    //     cout <<"Loading p.f.a. parameters: "<<path<<endl;
684    //     return readetaparam_();
685    // }
686    
687    // /**
688    //  * Load magnetic field parameters (call the F77 routine).
689    //  *
690    //  */
691    // int TrkLevel1::LoadFieldParam(TString path){
692            
693    // //    if( strcmp(path_.path,path.Data()) ){
694    //     if( path.IsNull() ){
695    //      path = gSystem->Getenv("PAM_CALIB");
696    //      if(path.IsNull()){
697    //          cout << " TrkLevel1::LoadFieldParam() ==> No PAMELA environment variables defined "<<endl;
698    //          return 0;
699    //      }
700    //      path.Append("/trk-param/field_param-0/");
701    //     }
702    //     cout <<"Loading magnetic field "<<path<<endl;
703    //     strcpy(path_.path,path.Data());
704    //     path_.pathlen = path.Length();
705    //     path_.error   = 0;
706    //     return readb_();
707    // //    }      
708    // //    return 0;
709    // }
710    // /**
711    //  * Load magnetic field parameters (call the F77 routine).
712    //  *
713    //  */
714    // int TrkLevel1::LoadChargeParam(TString path){
715            
716    // //    if( strcmp(path_.path,path.Data()) ){
717    //     if( path.IsNull() ){
718    //      path = gSystem->Getenv("PAM_CALIB");
719    //      if(path.IsNull()){
720    //          cout << " TrkLevel1::LoadChargeParam() ==> No PAMELA environment variables defined "<<endl;
721    //          return 0;
722    //      }
723    //      path.Append("/trk-param/charge_param-1/");
724    //     }
725    //     cout <<"Loading charge-correlation parameters: "<<path<<endl;
726    //     strcpy(path_.path,path.Data());
727    //     path_.pathlen = path.Length();
728    //     path_.error   = 0;
729    //     return readchargeparam_();
730    // //    }      
731    // //    return 0;
732    // }
733    // /**
734    //  * Load magnetic field parameters (call the F77 routine).
735    //  *
736    //  */
737    // int TrkLevel1::LoadAlignmentParam(TString path){
738            
739    // //    if( strcmp(path_.path,path.Data()) ){
740    //     if( path.IsNull() ){
741    //      path = gSystem->Getenv("PAM_CALIB");
742    //      if(path.IsNull()){
743    //          cout << " TrkLevel1::LoadAlignmentParam() ==> No PAMELA environment variables defined "<<endl;
744    //          return 0;
745    //      }
746    //      path.Append("/trk-param/align_param-0/");
747    //     }
748    //     cout <<"Loading alignment parameters: "<<path<<endl;
749    //     strcpy(path_.path,path.Data());
750    //     path_.pathlen = path.Length();
751    //     path_.error   = 0;
752    //     return readalignparam_();
753    // //    }      
754    // //    return 0;
755    // }
756    // /**
757    //  * Load magnetic field parameters (call the F77 routine).
758    //  *
759    //  */
760    // int TrkLevel1::LoadMipParam(TString path){
761            
762    // //    if( strcmp(path_.path,path.Data()) ){
763    //     if( path.IsNull() ){
764    //      path = gSystem->Getenv("PAM_CALIB");
765    //      if(path.IsNull()){
766    //          cout << " TrkLevel1::LoadMipParam() ==> No PAMELA environment variables defined "<<endl;
767    //          return 0;
768    //      }
769    //      path.Append("/trk-param/mip_param-0/");
770    //     }
771    //     cout <<"Loading ADC-to-MIP conversion parameters: "<<path<<endl;
772    //     strcpy(path_.path,path.Data());
773    //     path_.pathlen = path.Length();
774    //     path_.error   = 0;
775    //     return readmipparam_();
776    // //    }      
777    // //    return 0;
778    // }
779    // /**
780    //  * Load magnetic field parameters (call the F77 routine).
781    //  *
782    //  */
783    // int TrkLevel1::LoadVKMaskParam(TString path){
784            
785    // //    if( strcmp(path_.path,path.Data()) ){
786    //     if( path.IsNull() ){
787    //      path = gSystem->Getenv("PAM_CALIB");
788    //      if(path.IsNull()){
789    //          cout << " TrkLevel1::LoadVKMaskParam() ==> No PAMELA environment variables defined "<<endl;
790    //          return 0;
791    //      }
792    //      path.Append("/trk-param/mask_param-1/");
793    //     }
794    //     cout <<"Loading VK-mask parameters: "<<path<<endl;
795    //     strcpy(path_.path,path.Data());
796    //     path_.pathlen = path.Length();
797    //     path_.error   = 0;
798    //     return readvkmask_();
799    // //    }      
800    // //    return 0;
801    // }
802    
803    // /**
804    //  * Load all (default) parameters. Environment variable must be defined.
805    //  *
806    //  */
807    // int TrkLevel1::LoadParams(){
808    
809    //     int result=0;
810        
811    //     result = result * LoadFieldParam();
812    //     result = result * LoadPfaParam();
813    //     result = result * LoadChargeParam();
814    //     result = result * LoadAlignmentParam();
815    //     result = result * LoadMipParam();
816    //     result = result * LoadVKMaskParam();
817    
818    //     return result;
819    // }
820    
821    
822    
823    int TrkLevel1::GetPfaNbinsAngle(){
824        TrkParams::Load(4);
825        if( !TrkParams::IsLoaded(4) ){
826            cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
827            return 0;
828        }
829        return pfa_.nangbin;
830    };
831    
832    int TrkLevel1::GetPfaNbinsETA(){
833        TrkParams::Load(4);
834        if( !TrkParams::IsLoaded(4) ){
835            cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters  not loaded"<<endl;
836            return 0;
837        }
838        return pfa_.netaval;
839    };
840    
841  /**  /**
842   * Load Position-Finding-Algorythm parameters (call the F77 routine).   *
843   *   *
844   */   */
845  int TrkLevel1::LoadPfaParam(TString path){  float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){
846            
847      if( strcmp(path_.path,path.Data()) ){      TrkParams::Load(4);
848          cout <<"Loading p.f.a. param::eters\n";      if( !TrkParams::IsLoaded(4) ){
849          strcpy(path_.path,path.Data());          cout << "float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
850          path_.pathlen = path.Length();          return 0;
851          path_.error   = 0;      }
852          return readetaparam_();    
853      }        int nbins = GetPfaNbinsETA();
854      return 0;      if(!nbins)return 0;
855    
856        float *fcorr = new float [nbins];
857    
858        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
859            for(int ib=0; ib<nbins; ib++){
860                fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
861                cout << pfa_.eta2[nang][ib] << " - " <<  pfa_.feta2[nang][nladder][nview][ib]<<endl;;
862            }
863        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
864            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
865        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
866            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
867        }else{
868            cout << pfa<<" pfa parameters not implemented "<<endl;
869            return 0;
870        }    
871    
872        return fcorr;
873    
874    };
875    
876    float* TrkLevel1::GetPfaAbs(TString pfa, int nang){
877      
878        TrkParams::Load(4);
879        if( !TrkParams::IsLoaded(4) ){
880            cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
881            return 0;
882        }
883    
884        int nbins = GetPfaNbinsETA();
885        if(!nbins)return 0;
886    
887        float *fcorr = new float [nbins];
888    
889        if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
890            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
891        }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
892            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
893        }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
894            for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
895        }else{
896            cout << pfa<<" pfa parameters not implemented "<<endl;
897            return 0;
898        }    
899    
900        return fcorr;
901    
902    };
903    
904    /**
905     * Method to call the F77 routine that performs level1->level2 processing.
906     * The level2 output is stored in a common block, which can be retrieved
907     * by mean of the method TrkLevel2::SetFromLevel2Struct().
908     * NB If the TrkLevel1 object is readout from a tree, and the
909     * TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention
910     * should be payed to the fact that single clusters (clusters not associated
911     * with any track) might not be stored. Full reprocessing should be done from
912     * level0 data.
913     */
914    int TrkLevel1::ProcessEvent(int pfa){
915    
916    //    cout << "int TrkLevel1::ProcessEvent()" << endl;
917        TrkParams::Load( );
918        if( !TrkParams::IsLoaded() )return 0;
919    
920        GetLevel1Struct();
921    
922    //    analysisflight_(&pfa);
923        TrkParams::SetPFA(pfa);
924        analysisflight_();
925    
926        return 1;
927    
928  }  }
929    
930    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.23