/[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.2 by mocchiut, Thu Feb 5 09:12:35 2009 UTC revision 1.3 by mocchiut, Mon Nov 23 09:38:05 2009 UTC
# Line 57  TString   DIR; Line 57  TString   DIR;
57  TString   OUTF;  TString   OUTF;
58  TString   LIST;  TString   LIST;
59  TString   OPTIONS;  TString   OPTIONS;
60    TString   CALIBF;
61    
62  PamLevel2 *pam_event = NULL;  PamLevel2 *pam_event = NULL;
63    
# Line 75  Int_t Loop(TString ddir,TString list, TS Line 76  Int_t Loop(TString ddir,TString list, TS
76    pam_event->SetSELLI(2);    pam_event->SetSELLI(2);
77    TTree::SetMaxTreeSize(1000*Long64_t(2000000000));    TTree::SetMaxTreeSize(1000*Long64_t(2000000000));
78    //    //
79    TString outfile_t =0;    TString outfile_t = "";
80    outfile_t = OUTF;    outfile_t = OUTF;
81    outfile_t.Append("b.root");    outfile_t.Append(".root");
82    TFile *outft = (TFile*)gROOT->FindObject(outfile_t);    TFile *outft = (TFile*)gROOT->FindObject(outfile_t);
83    if (outft) outft->Close();    if (outft) outft->Close();
84    outft = new TFile(outfile_t,"RECREATE");    outft = new TFile(outfile_t,"RECREATE");
# Line 89  Int_t Loop(TString ddir,TString list, TS Line 90  Int_t Loop(TString ddir,TString list, TS
90    //    //
91    outft->cd();    outft->cd();
92    ToFLevel2 *tof = new ToFLevel2();    ToFLevel2 *tof = new ToFLevel2();
93      ToFdEdx *tofdedx = new ToFdEdx();
94    TTree *toft = new TTree("ToF","PAMELA Level2 ToF data");    TTree *toft = new TTree("ToF","PAMELA Level2 ToF data");
95    toft->SetAutoSave(900000000000000LL);              toft->SetAutoSave(900000000000000LL);          
96    tof->Set();//ELENA **TEMPORANEO?**    tof->Set();//ELENA **TEMPORANEO?**
# Line 167  Int_t Loop(TString ddir,TString list, TS Line 169  Int_t Loop(TString ddir,TString list, TS
169          //      printf(" rhtime %u myrun %i mysrun %i \n",pam_event->GetRunInfo()->RUNHEADER_TIME,(int)myrun,(int)mysrun);          //      printf(" rhtime %u myrun %i mysrun %i \n",pam_event->GetRunInfo()->RUNHEADER_TIME,(int)myrun,(int)mysrun);
170          mysrun = myrun;          mysrun = myrun;
171          //          //
172          Int_t error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table  
173    
174    
175    
176            Int_t error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,204,dbc); // parameters stored in DB in GL_PRAM table
177            if ( error<0 ) {
178              return(1);
179            };
180            //
181            tofdedx->ReadParAtt((glparam->PATH+glparam->NAME).Data());
182            
183            //
184            error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,205,dbc); // parameters stored in DB in GL_PRAM table
185            if ( error<0 ) {
186              return(1);
187            };
188            //
189            tofdedx->ReadParPos((glparam->PATH+glparam->NAME).Data());
190            
191            //
192            error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,206,dbc); // parameters stored in DB in GL_PRAM table
193            if ( error<0 ) {
194              return(1);
195            };
196            //
197            tofdedx->ReadParBBneg((glparam->PATH+glparam->NAME).Data());
198            
199            //
200            error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,207,dbc); // parameters stored in DB in GL_PRAM table
201            if ( error<0 ) {
202              return(1);
203            };
204            //
205            tofdedx->ReadParBBpos((glparam->PATH+glparam->NAME).Data());
206            
207            //
208            error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,208,dbc); // parameters stored in DB in GL_PRAM table
209            if ( error<0 ) {
210              return(1);
211            };
212            //
213            tofdedx->ReadParDesatBB((glparam->PATH+glparam->NAME).Data());
214            
215            
216            tofdedx->CheckConnectors(pam_event->GetRunInfo()->RUNHEADER_TIME,glparam,dbc);
217            
218            
219            
220            error=glparam->Query_GL_PARAM(pam_event->GetRunInfo()->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table
221          if ( error<0 ) {          if ( error<0 ) {
222            return(1);            return(1);
223          };          };
# Line 186  Int_t Loop(TString ddir,TString list, TS Line 236  Int_t Loop(TString ddir,TString list, TS
236        //================================================================        //================================================================
237        //==================================================================        //==================================================================
238        //---  Define absolute time        //---  Define absolute time
239        Float_t tabs=pam_event->GetOrbitalInfo()->absTime;        UInt_t tabs=pam_event->GetOrbitalInfo()->absTime;
240          
241          printf(" ATIME %u re %u \n",(Int_t)tabs,(UInt_t)iev);
242    
243        //==================================================================        //==================================================================
244        Float_t dedx_corr_m[2000][48],dedx_corr[48];        Float_t dedx_corr_m[2000][48],dedx_corr[48];
# Line 206  Int_t Loop(TString ddir,TString list, TS Line 258  Int_t Loop(TString ddir,TString list, TS
258    
259          jj=0;          jj=0;
260    
261          ifstream fin("adcmonitor.7th.100k.cut.dat");          ifstream fin(CALIBF.Data());
262    
263          while (! fin.eof()) {          while (! fin.eof()) {
264            fin>>t1>>tm>>t2;            fin>>t1>>tm>>t2;
# Line 261  Int_t Loop(TString ddir,TString list, TS Line 313  Int_t Loop(TString ddir,TString list, TS
313    
314        for (ii=0; ii<48;ii++) {        for (ii=0; ii<48;ii++) {
315          yhelp1 = dedx_corr_m[ical][ii];          yhelp1 = dedx_corr_m[ical][ii];
316            //      yhelp1 = 6.;
317            if ( yhelp1 < 0.1 ) yhelp1 = 6.;
318          yhelp2 = dedx_corr_m[ical+1][ii];          yhelp2 = dedx_corr_m[ical+1][ii];
319            //      yhelp2 = 6.;
320            if ( yhelp2 < 0.1 ) yhelp2 = 6.;
321          slope  = (yhelp2-yhelp1)/(thelp2-thelp1);          slope  = (yhelp2-yhelp1)/(thelp2-thelp1);
322          inter  = yhelp1 - slope*thelp1;          inter  = yhelp1 - slope*thelp1;
323          dedx_corr[ii] = slope*tabs + inter;          dedx_corr[ii] = slope*tabs + inter;
# Line 316  Int_t Loop(TString ddir,TString list, TS Line 372  Int_t Loop(TString ddir,TString list, TS
372          //        Int_t pppid = tof->GetPMTid(hh,gg);          //        Int_t pppid = tof->GetPMTid(hh,gg);
373          //      printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc);          //      printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc);
374        };        };
375          for (Int_t hh=0; hh<12;hh++){
376            for (Int_t kk=0; kk<4;kk++){      
377              tofdedx->Init(kk,hh,adc[kk][hh]);
378            };
379          };
380        //      for (Int_t pm=0; pm <48 ; pm++){        //      for (Int_t pm=0; pm <48 ; pm++){
381        //        tof->GetPMTIndex(pm, gg, hh);        //        tof->GetPMTIndex(pm, gg, hh);
382        //        tofinput_.tdc[hh][gg] = (int)500.;        //        tofinput_.tdc[hh][gg] = (int)500.;
# Line 373  Int_t Loop(TString ddir,TString list, TS Line 432  Int_t Loop(TString ddir,TString list, TS
432          t_tof->beta[kk] = tofoutput_.betatof_a[kk];              t_tof->beta[kk] = tofoutput_.betatof_a[kk];    
433        }        }
434        //        //
435          memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
436          memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
437          memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
438          memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
439          {
440            Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]};
441            Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.};
442            tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp);
443          }
444        t_tof->npmtadc = 0;        t_tof->npmtadc = 0;
445    
446    
447        for (Int_t hh=0; hh<12;hh++){        for (Int_t hh=0; hh<12;hh++){
448          for (Int_t kk=0; kk<4;kk++){          for (Int_t kk=0; kk<4;kk++){
449            if ( tofoutput_.adctof_c[hh][kk] < 1000 ){            pmt_id = tof->GetPMTid(kk,hh);
450              //      t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO            if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. ){
451              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  
452              t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);              t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
453              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
454              t_tof->npmtadc++;              t_tof->npmtadc++;
455            };            };
456          };          };
457        };        };
458    //       for (Int_t hh=0; hh<12;hh++){
459    //      for (Int_t kk=0; kk<4;kk++){
460    //           if ( tofoutput_.adctof_c[hh][kk] < 1000 ){
461    //          //      t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO
462    //          pmt_id = tof->GetPMTid(kk,hh);
463    //          t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO
464    //          t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
465    //          t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
466    //          t_tof->npmtadc++;
467    //        };
468    //      };
469    //       };
470        //        //
471        memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));  
       memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));  
       memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));  
       memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));  
472        //        //
473        new(t[ntrkentry]) ToFTrkVar(*t_tof);        new(t[ntrkentry]) ToFTrkVar(*t_tof);
474        ntrkentry++;              ntrkentry++;      
# Line 459  Int_t Loop(TString ddir,TString list, TS Line 537  Int_t Loop(TString ddir,TString list, TS
537              t_tof->beta[kk] = tofoutput_.beta_a[kk];                  t_tof->beta[kk] = tofoutput_.beta_a[kk];    
538            };            };
539            //            //
540              memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
541              memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
542              memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
543              memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
544              //
545              tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof);
546            t_tof->npmtadc = 0;            t_tof->npmtadc = 0;
547            for (Int_t hh=0; hh<12;hh++){            for (Int_t hh=0; hh<12;hh++){
548              for (Int_t kk=0; kk<4;kk++){              for (Int_t kk=0; kk<4;kk++){
549                if ( tofoutput_.adc_c[hh][kk] < 1000 ){                pmt_id = tof->GetPMTid(kk,hh);
550                  //          t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); // EMILIANO                if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. ){
551                  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_.adc_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO  
552                  t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);                  t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
553                  t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07                  t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
554                    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]);
555                  t_tof->npmtadc++;                  t_tof->npmtadc++;
556                };                };
557                  
558              };              };
559            };            };
560    //        t_tof->npmtadc = 0;
561    //        for (Int_t hh=0; hh<12;hh++){
562    //          for (Int_t kk=0; kk<4;kk++){
563    //            if ( tofoutput_.adc_c[hh][kk] < 1000 ){
564    //              //          t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); // EMILIANO
565    //              pmt_id = tof->GetPMTid(kk,hh);
566    //              t_tof->dedx.AddAt((tofoutput_.adc_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO
567    //              t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
568    //              t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
569    //              t_tof->npmtadc++;
570    //            };
571    //          };
572    //        };
573            //            //
574            memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));  
           memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));  
           memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));  
           memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));  
575            //            //
576            // Store the tracker track number in order to be sure to have shyncronized data during analysis            // Store the tracker track number in order to be sure to have shyncronized data during analysis
577            //            //
# Line 538  void usage(){ Line 633  void usage(){
633    cout << "-processDir  DIR     -  Level2 data directory \n";    cout << "-processDir  DIR     -  Level2 data directory \n";
634    cout << "-processList LIST    -  list  of files (.txt) or single file (.root) to be analysed \n";    cout << "-processList LIST    -  list  of files (.txt) or single file (.root) to be analysed \n";
635    cout << "-outputFile  PATH    -  name of the output file \n";    cout << "-outputFile  PATH    -  name of the output file \n";
636      cout << "-calibFile PATH+NAME -  name of the calibration file \n";
637    cout << "-NumEvents   XXX     -  number of events to be analysed \n";    cout << "-NumEvents   XXX     -  number of events to be analysed \n";
638    cout << "--debug, -g          -  debug mode \n";    cout << "--debug, -g          -  debug mode \n";
639    cout << "--help, -h           -  print this help \n";    cout << "--help, -h           -  print this help \n";
# Line 588  int HandleInputPar(int argc, char **argv Line 684  int HandleInputPar(int argc, char **argv
684          continue;          continue;
685        }          }  
686        // -----------------------------------------------------//        // -----------------------------------------------------//
687          // -----------------------------------------------------//
688          else if (!strcmp(argv[i], "-calibFile")){
689            if (++i >= argc) throw -1;
690            CALIBF = argv[i];
691            cout << "calibFile "<<CALIBF<<endl;
692            continue;
693          }  
694          // -----------------------------------------------------//
695        else if (!strcmp(argv[i], "-options")){        else if (!strcmp(argv[i], "-options")){
696          if (++i >= argc) throw -1;          if (++i >= argc) throw -1;
697          OPTIONS = argv[i];          OPTIONS = argv[i];

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

  ViewVC Help
Powered by ViewVC 1.1.23