--- tof/flight/ToFReprocessing/ToFreproc.cpp 2009/11/23 09:38:05 1.3 +++ tof/flight/ToFReprocessing/ToFreproc.cpp 2010/03/10 12:31:40 1.5 @@ -100,6 +100,10 @@ // Int_t ntrkentry = 0; Int_t npmtentry = 0; + Float_t xleft=0; + Float_t xright=0; + Float_t yleft=0; + Float_t yright=0; // ULong64_t nevents = pam_event->GetEntries(); printf("\n\n Running on %llu events \n\n",nevents); @@ -238,7 +242,7 @@ //--- Define absolute time UInt_t tabs=pam_event->GetOrbitalInfo()->absTime; - 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); //================================================================== Float_t dedx_corr_m[2000][48],dedx_corr[48]; @@ -257,6 +261,7 @@ //----------------------------------------------------------- jj=0; + printf(" READING NEW CALIBRATION FILE: %s \n",CALIBF.Data()); ifstream fin(CALIBF.Data()); @@ -312,12 +317,12 @@ thelp2 = mtime[ical+1]; for (ii=0; ii<48;ii++) { - yhelp1 = dedx_corr_m[ical][ii]; + yhelp1 = fabs(dedx_corr_m[ical][ii]); // yhelp1 = 6.; - if ( yhelp1 < 0.1 ) yhelp1 = 6.; - yhelp2 = dedx_corr_m[ical+1][ii]; + if ( yhelp1 < 0.1 ) yhelp1 = 4.; + yhelp2 = fabs(dedx_corr_m[ical+1][ii]); // yhelp2 = 6.; - if ( yhelp2 < 0.1 ) yhelp2 = 6.; + if ( yhelp2 < 0.1 ) yhelp2 = 4.; slope = (yhelp2-yhelp1)/(thelp2-thelp1); inter = yhelp1 - slope*thelp1; dedx_corr[ii] = slope*tabs + inter; @@ -436,48 +441,123 @@ 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)); - { - Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]}; - Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.}; - tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); - } - t_tof->npmtadc = 0; + // { +// Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]}; +// Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.}; +// tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); +// } +// t_tof->npmtadc = 0; - 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++; - }; - }; - }; // for (Int_t hh=0; hh<12;hh++){ // for (Int_t kk=0; kk<4;kk++){ -// if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ -// // t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO -// pmt_id = tof->GetPMTid(kk,hh); -// t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO +// 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(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 +// t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 // t_tof->npmtadc++; // }; // }; // }; - // + { - // - new(t[ntrkentry]) ToFTrkVar(*t_tof); - ntrkentry++; - t_tof->Clear(); - // - // - // - t_pmt->Clear(); - // + Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.}; + Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.}; + + if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){ + xtof_temp[1]=t_tof->xtofpos[0]; + ytof_temp[0]=t_tof->ytofpos[0]; + }else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){ + ytof_temp[0]=t_tof->ytofpos[0]; + tof->GetPaddleGeometry(0,(Int_t)log2(tof->tof_j_flag[0]),xleft, xright, yleft, yright); + xtof_temp[1]=xleft+2.55; + }else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){ + xtof_temp[1]=t_tof->xtofpos[0]; + tof->GetPaddleGeometry(1,(Int_t)log2(tof->tof_j_flag[1]),xleft, xright, yleft, yright); + ytof_temp[0]=yleft+2.75; + } + + if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){ + xtof_temp[2]=t_tof->xtofpos[1]; + ytof_temp[3]=t_tof->ytofpos[1]; + }else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){ + ytof_temp[3]=t_tof->ytofpos[1]; + tof->GetPaddleGeometry(3,(Int_t)log2(tof->tof_j_flag[3]),xleft, xright, yleft, yright); + xtof_temp[2]=xleft+4.5; + }else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){ + xtof_temp[2]=t_tof->xtofpos[1]; + tof->GetPaddleGeometry(2,(Int_t)log2(tof->tof_j_flag[2]),xleft, xright, yleft, yright); + ytof_temp[3]=yleft+3.75; + } + + if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){ + xtof_temp[5]=t_tof->xtofpos[2]; + ytof_temp[4]=t_tof->ytofpos[2]; + }else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){ + ytof_temp[4]=t_tof->ytofpos[2]; + tof->GetPaddleGeometry(4,(Int_t)log2(tof->tof_j_flag[4]),xleft, xright, yleft, yright); + xtof_temp[5]=xleft+3; + }else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){ + xtof_temp[5]=t_tof->xtofpos[2]; + tof->GetPaddleGeometry(5,(Int_t)log2(tof->tof_j_flag[5]),xleft, xright, yleft, yright); + ytof_temp[4]=yleft+2.5; + } +// Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]}; +// Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.}; +// tofdedx->Process(atime,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); + t_tof->npmtadc = 0; + for (Int_t hh=0; hh<12;hh++){ + for (Int_t kk=0; kk<4;kk++){ + pmt_id = tof->GetPMTid(kk,hh); + Int_t Iplane=-1; + Int_t Ipaddle=-1; + // Int_t IpaddleT=-1; + tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); + tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright); + 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 !!!! + t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),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++; + }; + }; + }; + }; + + + + + + + + + + + // for (Int_t hh=0; hh<12;hh++){ + // for (Int_t kk=0; kk<4;kk++){ + // if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ + // // t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); // EMILIANO + // pmt_id = tof->GetPMTid(kk,hh); + // t_tof->dedx.AddAt((tofoutput_.adctof_c[hh][kk]*4./dedx_corr[pmt_id]),t_tof->npmtadc); // EMILIANO + // t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); + // t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 + // t_tof->npmtadc++; + // }; + // }; + // }; + // + + // + new(t[ntrkentry]) ToFTrkVar(*t_tof); + ntrkentry++; + t_tof->Clear(); + // + // + // + t_pmt->Clear(); + // for (Int_t hh=0; hh<12;hh++){ for (Int_t kk=0; kk<4;kk++){ // new WM @@ -514,6 +594,10 @@ for (Int_t e = 0; e < 5 ; e++){ tofinput_.al_pp[e] = ptt->al[e]; }; + + // new input for 9th reduction: tracker dEdx + tofinput_.trkmip = ptt->GetDEDX(); + // // Get tracker related variables for this track // @@ -544,19 +628,39 @@ // tofdedx->Process(pam_event->GetOrbitalInfo()->absTime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof); t_tof->npmtadc = 0; + 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); + Int_t Iplane=-1; + Int_t Ipaddle=-1; + Int_t IpaddleT=-1; + tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); + IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0); + if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && Ipaddle==IpaddleT ){ + t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); 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]); t_tof->npmtadc++; }; }; }; + + +// 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 +// 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]); +// t_tof->npmtadc++; +// }; + +// }; +// }; // t_tof->npmtadc = 0; // for (Int_t hh=0; hh<12;hh++){ // for (Int_t kk=0; kk<4;kk++){ @@ -687,7 +791,7 @@ // -----------------------------------------------------// else if (!strcmp(argv[i], "-calibFile")){ if (++i >= argc) throw -1; - CALIBF = argv[i]; + CALIBF = gSystem->ExpandPathName(argv[i]); cout << "calibFile "<