/[PAMELA software]/tof/flight/ToFReprocessing/ToFreproc.cpp
ViewVC logotype

Diff of /tof/flight/ToFReprocessing/ToFreproc.cpp

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

revision 1.3 by mocchiut, Mon Nov 23 09:38:05 2009 UTC revision 1.4 by mocchiut, Wed Mar 10 09:43:19 2010 UTC
# Line 100  Int_t Loop(TString ddir,TString list, TS Line 100  Int_t Loop(TString ddir,TString list, TS
100    //    //
101    Int_t ntrkentry = 0;    Int_t ntrkentry = 0;
102    Int_t npmtentry = 0;    Int_t npmtentry = 0;
103      Float_t xleft=0;
104      Float_t xright=0;
105      Float_t yleft=0;
106      Float_t yright=0;
107    //    //
108    ULong64_t nevents = pam_event->GetEntries();    ULong64_t nevents = pam_event->GetEntries();
109    printf("\n\n Running on %llu events \n\n",nevents);    printf("\n\n Running on %llu events \n\n",nevents);
# Line 238  Int_t Loop(TString ddir,TString list, TS Line 242  Int_t Loop(TString ddir,TString list, TS
242        //---  Define absolute time        //---  Define absolute time
243        UInt_t tabs=pam_event->GetOrbitalInfo()->absTime;        UInt_t tabs=pam_event->GetOrbitalInfo()->absTime;
244                
245        printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev);        if ( !(iev%1000) ) printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev);
246    
247        //==================================================================        //==================================================================
248        Float_t dedx_corr_m[2000][48],dedx_corr[48];        Float_t dedx_corr_m[2000][48],dedx_corr[48];
# Line 257  Int_t Loop(TString ddir,TString list, TS Line 261  Int_t Loop(TString ddir,TString list, TS
261          //-----------------------------------------------------------          //-----------------------------------------------------------
262    
263          jj=0;          jj=0;
264            printf(" READING NEW CALIBRATION FILE: %s \n",CALIBF.Data());
265    
266          ifstream fin(CALIBF.Data());          ifstream fin(CALIBF.Data());
267    
# Line 312  Int_t Loop(TString ddir,TString list, TS Line 317  Int_t Loop(TString ddir,TString list, TS
317        thelp2 = mtime[ical+1];        thelp2 = mtime[ical+1];
318    
319        for (ii=0; ii<48;ii++) {        for (ii=0; ii<48;ii++) {
320          yhelp1 = dedx_corr_m[ical][ii];          yhelp1 = fabs(dedx_corr_m[ical][ii]);
321          //      yhelp1 = 6.;          //      yhelp1 = 6.;
322          if ( yhelp1 < 0.1 ) yhelp1 = 6.;          if ( yhelp1 < 0.1 ) yhelp1 = 4.;
323          yhelp2 = dedx_corr_m[ical+1][ii];          yhelp2 = fabs(dedx_corr_m[ical+1][ii]);
324          //      yhelp2 = 6.;          //      yhelp2 = 6.;
325          if ( yhelp2 < 0.1 ) yhelp2 = 6.;          if ( yhelp2 < 0.1 ) yhelp2 = 4.;
326          slope  = (yhelp2-yhelp1)/(thelp2-thelp1);          slope  = (yhelp2-yhelp1)/(thelp2-thelp1);
327          inter  = yhelp1 - slope*thelp1;          inter  = yhelp1 - slope*thelp1;
328          dedx_corr[ii] = slope*tabs + inter;          dedx_corr[ii] = slope*tabs + inter;
# Line 436  Int_t Loop(TString ddir,TString list, TS Line 441  Int_t Loop(TString ddir,TString list, TS
441        memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));        memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
442        memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));        memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
443        memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));        memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
444        {        //      {
445          Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]};  //      Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]};
446          Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.};  //      Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.};
447          tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp);  //      tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp);
448        }  //       }
449        t_tof->npmtadc = 0;  //       t_tof->npmtadc = 0;
450    
451    
       for (Int_t hh=0; hh<12;hh++){  
         for (Int_t kk=0; kk<4;kk++){  
           pmt_id = tof->GetPMTid(kk,hh);  
           if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. ){  
             t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc);  
             t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);  
             t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07  
             t_tof->npmtadc++;  
           };  
         };  
       };  
452  //       for (Int_t hh=0; hh<12;hh++){  //       for (Int_t hh=0; hh<12;hh++){
453  //      for (Int_t kk=0; kk<4;kk++){  //      for (Int_t kk=0; kk<4;kk++){
454  //           if ( tofoutput_.adctof_c[hh][kk] < 1000 ){  //        pmt_id = tof->GetPMTid(kk,hh);
455  //          //      t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO  //        if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. ){
456  //          pmt_id = tof->GetPMTid(kk,hh);  //          t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc);
 //          t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO  
457  //          t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);  //          t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
458  //          t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07  //          t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
459  //          t_tof->npmtadc++;  //          t_tof->npmtadc++;
460  //        };  //        };
461  //      };  //      };
462  //       };  //       };
463        //       {
464    
465        //          Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.};
466        new(t[ntrkentry]) ToFTrkVar(*t_tof);          Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.};
467        ntrkentry++;        
468        t_tof->Clear();          if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){
469        //            xtof_temp[1]=t_tof->xtofpos[0];
470        //            ytof_temp[0]=t_tof->ytofpos[0];
471        //          }else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){
472        t_pmt->Clear();            ytof_temp[0]=t_tof->ytofpos[0];
473        //            tof->GetPaddleGeometry(0,(Int_t)log2(tof->tof_j_flag[0]),xleft, xright, yleft, yright);
474              xtof_temp[1]=xleft+2.55;
475            }else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){
476              xtof_temp[1]=t_tof->xtofpos[0];
477              tof->GetPaddleGeometry(1,(Int_t)log2(tof->tof_j_flag[1]),xleft, xright, yleft, yright);
478              ytof_temp[0]=yleft+2.75;
479            }
480    
481            if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){
482              xtof_temp[2]=t_tof->xtofpos[1];
483              ytof_temp[3]=t_tof->ytofpos[1];
484            }else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){
485              ytof_temp[3]=t_tof->ytofpos[1];
486              tof->GetPaddleGeometry(3,(Int_t)log2(tof->tof_j_flag[3]),xleft, xright, yleft, yright);
487              xtof_temp[2]=xleft+4.5;
488            }else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){
489              xtof_temp[2]=t_tof->xtofpos[1];
490              tof->GetPaddleGeometry(2,(Int_t)log2(tof->tof_j_flag[2]),xleft, xright, yleft, yright);
491              ytof_temp[3]=yleft+3.75;
492            }
493    
494            if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){
495              xtof_temp[5]=t_tof->xtofpos[2];
496              ytof_temp[4]=t_tof->ytofpos[2];
497            }else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){
498              ytof_temp[4]=t_tof->ytofpos[2];
499              tof->GetPaddleGeometry(4,(Int_t)log2(tof->tof_j_flag[4]),xleft, xright, yleft, yright);
500              xtof_temp[5]=xleft+3;
501            }else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){
502              xtof_temp[5]=t_tof->xtofpos[2];
503              tof->GetPaddleGeometry(5,(Int_t)log2(tof->tof_j_flag[5]),xleft, xright, yleft, yright);
504              ytof_temp[4]=yleft+2.5;
505            }
506    //       Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]};
507    //       Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.};
508    //      tofdedx->Process(atime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp);
509            tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp);
510            t_tof->npmtadc = 0;
511            for (Int_t hh=0; hh<12;hh++){
512              for (Int_t kk=0; kk<4;kk++){
513                pmt_id = tof->GetPMTid(kk,hh);
514                Int_t Iplane=-1;
515                Int_t Ipaddle=-1;
516                //      Int_t IpaddleT=-1;
517                tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle);
518                tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright);
519                if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. &&((xtof_temp[Iplane]>=xleft&&xtof_temp[Iplane]<=xright) || (ytof_temp[Iplane]>=yleft&&ytof_temp[Iplane]<=yright)) ){  //attenzione:qui va inserito un controllo sulla traccia tof o sulle variabili di posizione !!!!
520                  t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc);
521                  t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
522                  t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
523                  t_tof->npmtadc++;
524                };
525              };
526            };
527          };
528    
529    
530    
531    
532    
533    
534    
535    
536    
537        
538         //       for (Int_t hh=0; hh<12;hh++){
539         //         for (Int_t kk=0; kk<4;kk++){
540         //           if ( tofoutput_.adctof_c[hh][kk] < 1000 ){
541         //             //      t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO
542         //             pmt_id = tof->GetPMTid(kk,hh);
543         //             t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO
544         //             t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
545         //             t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
546         //             t_tof->npmtadc++;
547         //           };
548         //         };
549         //       };
550         //
551        
552         //
553         new(t[ntrkentry]) ToFTrkVar(*t_tof);
554         ntrkentry++;      
555         t_tof->Clear();
556         //
557         //
558         //
559         t_pmt->Clear();
560         //
561        for (Int_t hh=0; hh<12;hh++){        for (Int_t hh=0; hh<12;hh++){
562          for (Int_t kk=0; kk<4;kk++){          for (Int_t kk=0; kk<4;kk++){
563            // new WM            // new WM
# Line 514  Int_t Loop(TString ddir,TString list, TS Line 594  Int_t Loop(TString ddir,TString list, TS
594            for (Int_t e = 0; e < 5 ; e++){            for (Int_t e = 0; e < 5 ; e++){
595              tofinput_.al_pp[e] = ptt->al[e];              tofinput_.al_pp[e] = ptt->al[e];
596            };                  };      
597    
598              // new input for 9th reduction: tracker dEdx
599              tofinput_.trkmip = ptt->GetDEDX();
600    
601            //            //
602            // Get tracker related variables for this track            // Get tracker related variables for this track
603            //            //
# Line 544  Int_t Loop(TString ddir,TString list, TS Line 628  Int_t Loop(TString ddir,TString list, TS
628            //            //
629            tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof);            tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof);
630            t_tof->npmtadc = 0;            t_tof->npmtadc = 0;
631    
632            for (Int_t hh=0; hh<12;hh++){            for (Int_t hh=0; hh<12;hh++){
633              for (Int_t kk=0; kk<4;kk++){              for (Int_t kk=0; kk<4;kk++){
634                pmt_id = tof->GetPMTid(kk,hh);                pmt_id = tof->GetPMTid(kk,hh);
635                if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. ){                Int_t Iplane=-1;
636                  t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc);                Int_t Ipaddle=-1;
637                  Int_t IpaddleT=-1;
638                  tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle);
639                  IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0);
640                  if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && Ipaddle==IpaddleT ){
641                    t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc);
642                  t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);                  t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
643                  t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07                  t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
                 printf(" nt %i npmtadc %i dedx %f dedx corr %f\n",nt,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),dedx_corr[pmt_id]);  
644                  t_tof->npmtadc++;                  t_tof->npmtadc++;
645                };                };
646                                
647              };              };
648            };            };
649    
650    
651    //        for (Int_t hh=0; hh<12;hh++){
652    //          for (Int_t kk=0; kk<4;kk++){
653    //            pmt_id = tof->GetPMTid(kk,hh);
654    //            if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. ){
655    //              t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),t_tof->npmtadc);
656    //              t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
657    //              t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
658    //              printf(" nt %i npmtadc %i dedx %f dedx corr %f\n",nt,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*36./pow(dedx_corr[pmt_id],2)),dedx_corr[pmt_id]);
659    //              t_tof->npmtadc++;
660    //            };
661                  
662    //          };
663    //        };
664  //        t_tof->npmtadc = 0;  //        t_tof->npmtadc = 0;
665  //        for (Int_t hh=0; hh<12;hh++){  //        for (Int_t hh=0; hh<12;hh++){
666  //          for (Int_t kk=0; kk<4;kk++){  //          for (Int_t kk=0; kk<4;kk++){

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23