#include #include #include #include //------------------------------------------------------------------------ void ToFPatch::Clear(Option_t *option) { // L2 = 0; OBT = 0; PKT = 0; atime = 0; tr = 0; //sntr = 0; // Set arrays and initialize structure eDEDXpmt.Set(48); eDEDXpmt.Reset(-1); // Set array size and reset structure eDEDXpmtraw.Set(48); eDEDXpmtraw.Reset(-1); // Set array size and reset structure eDEDXpad.Set(24); eDEDXpad.Reset(-1); eDEDXlayer.Set(6); eDEDXlayer.Reset(-1); INFOpmt.Set(48); INFOpmt.Reset(0); INFOlayer.Set(6); INFOlayer.Reset(0); eDEDXpmtstd.Set(48); eDEDXpmtstd.Reset(-1); // Set array size and reset structure eDEDXpmtrawstd.Set(48); eDEDXpmtrawstd.Reset(-1); // Set array size and reset structure eDEDXpadstd.Set(24); eDEDXpadstd.Reset(-1); eDEDXlayerstd.Set(6); eDEDXlayerstd.Reset(-1); INFOpmtstd.Set(48); INFOpmtstd.Reset(0); INFOlayerstd.Set(6); INFOlayerstd.Reset(0); // }; //------------------------------------------------------------------------ void ToFPatch::Print(Option_t *option) { // printf("========================================================================\n"); printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime); }; //------------------------------------------------------------------------ void ToFPatch::InitPar(const char *pardir, const char *param) { // expensive function - call it once/run Define_PMTsat(); ReadParAtt(pardir, param); }; //------------------------------------------------------------------------ void ToFPatch::Process( PamLevel2 *l2p, const char* alg) { // the parameters should be already initialised by InitPar() Float_t thelp1,thelp2; Float_t dedx_corr[48]; Float_t xv[6],yv[6],zin[6]; Clear(); L2 = l2p; if(!L2) return; if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n"); TrkLevel2 *trkL2 = L2->GetTrkLevel2(); if(!trkL2) return; ToFLevel2 *tofL2 = L2->GetToFLevel2(); if(!tofL2) return; eNtr = trkL2->GetNTracks(); if(eNtr<1) return; trkAlg = alg; OBT = L2->GetOrbitalInfo()->OBT; PKT = L2->GetOrbitalInfo()->pkt_num; atime = L2->GetOrbitalInfo()->absTime; //---------------------------------------------------------------------- //cout< tmax_atten)) { ical_atten = 0; for (Int_t ii=0; ii<100; ii++) { //cout<T_int_min[ii]) && (atime<=T_int_max[ii])) { // time interval found ical_atten = ii; tmin_atten = T_int_min[ii]; tmax_atten = T_int_max[ii]; cout<<"Time Interval found: "< tmax_2nd)) { ical_2nd=0; for (Int_t ii=0; ii<1500; ii++) { //cout<mtime[ii]) && (atime<=mtime[ii+1])) { // time interval found ical_2nd = ii; tmin_2nd = mtime[ii]; tmax_2nd = mtime[ii+1]; //cout<<"Time Interval 2nd order corr "< "<GetNTracks(trkAlg)>=1 ){ // PamTrack *trackTRK = L2->GetTrack(itr); // 9th PamTrack *trackTRK = L2->GetTrack(0,trkAlg); // 10th Float_t betamean = fabs(trackTRK->GetToFTrack()->beta[12]); if(betamean<0.05 || betamean>2){ for(int i=0;i<48;i++)INFOpmt[i]=1; for(int i=0;i<6;i++)INFOlayer[i]=1; } // define angle: for (Int_t jj=0; jj<6; jj++){ xv[jj]=trackTRK->GetToFTrack()->xtr_tof[jj]; yv[jj]=trackTRK->GetToFTrack()->ytr_tof[jj]; zin[jj] = L2->GetToFLevel2()->GetZTOF(L2->GetToFLevel2()->GetToFPlaneID(jj)); } Float_t theta[6]; for (Int_t jj=0; jj<3; jj++){ Float_t dx=0.; Float_t dy=0.; Float_t dr=0.; Int_t kk=2*jj; theta[kk] =0; theta[kk+1]=0; Float_t dist = zin[kk] - zin[kk+1]; if ((xv[kk])<100.) { dx = xv[kk] - xv[kk+1]; dy = yv[kk] - yv[kk+1]; dr = sqrt(dx*dx+dy*dy); theta[kk] = atan(dr/dist); theta[kk+1] = atan(dr/dist); } } // jj // Clear ADC; Float_t adc[48]; for(int i=0;i<48;i++){ // adc[i]=0; adc[i]=4095; } for (Int_t ipmt=0; ipmtnpmt() ; ipmt++){ ToFPMT *tofpmt = tofL2->GetToFPMT(ipmt); Int_t pmt_id = tofpmt->pmt_id; adc[pmt_id] = tofpmt->adc ; // raw ADC } //loop on 48 pmts Int_t paddleidoftrack[6]= {0} ; for (Int_t ilay=0; ilay<6; ilay++) { paddleidoftrack[ilay] = L2->GetToFLevel2()->GetPaddleIdOfTrack(xv[ilay], yv[ilay], ilay, 0.2) ; } /* cout<<"paddleidoftrack trk "; for (Int_t ilay=0; ilay<6; ilay++) { cout<<" "<=PMTsat[iihelp]-5)INFOpmt[iihelp]=3; if( adc[ihelp] >= PMTsat[iihelp]-5 ) continue; if( adc[ihelp] <= 0. ) continue; double adcpC = f_adcPC( adc[iihelp] ); // - adc conversion in pC double adccorr = adcpC*fabs(cos(theta[ilay])); if(adccorr<=0)INFOpmt[ihelp]=4; if(adccorr<=0.) continue; */ adcl= adc[ihelp]; adcr= adc[ihelp+1]; adclraw = adcl; adcrraw = adcr; adcl = f_adcPC( adcl ); // - adc conversion in pC adcr = f_adcPC( adcr ); // - adc conversion in pC Float_t x; if (ilay==0) x=yv[0]; if (ilay==1) x=xv[1]; if (ilay==2) x=xv[2]; if (ilay==3) x=yv[3]; if (ilay==4) x=yv[4]; if (ilay==5) x=xv[5]; if (adclraw<4095) { adcl = adcl*cos(theta[ilay]); xkorr = atten(A0[ihelp],A1[ihelp],A2[ihelp],A3[ihelp],x); xkorr = xkorr/hepratio; dedxl = adcl/xkorr; eDEDXpmtraw[ihelp] = dedxl; Float_t dedxl1 = dedxl*4./dedx_corr[ihelp]; // 2nd order corr // cout< "< "<-1 } // ilay //----------------------------------------------------------------- // The GetdEdx method "handmade" //----------------------------------------------------------------- for (Int_t ilay=0; ilay<6; ilay++) { Float_t xhelp=1000.; Int_t i1 = paddleidoftrack[ilay]; if (i1 != -1) { ipad = ipad_a[ilay]+i1; ihelp = ipmt_a[ilay]+(i1*2); if ((eDEDXpmt[ihelp]<1000.) && (eDEDXpmt[ihelp+1]==1000.)) xhelp = eDEDXpmt[ihelp]; if ((eDEDXpmt[ihelp+1]<1000.) && (eDEDXpmt[ihelp]==1000.)) xhelp = eDEDXpmt[ihelp+1]; if ((eDEDXpmt[ihelp]<1000.) && (eDEDXpmt[ihelp+1]<1000.)) xhelp = 0.5*(eDEDXpmt[ihelp]+eDEDXpmt[ihelp+1]); eDEDXpad[ipad] = xhelp; eDEDXlayer[ilay] = xhelp; } } // ilay } // if( L2->GetNTracks(trkAlg)>=1 )... //================================================================ //================================================================ //============== standalone dEdx and beta ============= //================================================================ //================================================================ if (L2->GetToFStoredTrack(-1) ) { // ToF track ToFTrkVar *tof = L2->GetToFStoredTrack(-1); Float_t betamean = tof->CalcBeta(10., 10., 20.); if(betamean<0.05 || betamean>2){ for(int i=0;i<48;i++)INFOpmt[i]=1; for(int i=0;i<6;i++)INFOlayer[i]=1; } // define angle (simple way... all theta[i] are the same...) Float_t theta[6] = {0., 0., 0., 0., 0., 0. }; if (fabs((tof->xtofpos[0])<100) && (fabs(tof->xtofpos[2])<100) && (fabs(tof->ytofpos[0])<100) && (fabs(tof->ytofpos[2])<100)) { Float_t dx = tof->xtofpos[0] - tof->xtofpos[2]; Float_t dy = tof->ytofpos[0] - tof->ytofpos[2]; Float_t dr = sqrt(dx*dx+dy*dy); for (Int_t jj=0; jj<6; jj++) theta[jj]=atan(dr/77.31); // cout<xtofpos[0]<<" "<xtofpos[2]<<" => "<ytofpos[0]<<" "<ytofpos[2]<<" => "<npmt() ; ipmt++){ ToFPMT *tofpmt = tofL2->GetToFPMT(ipmt); Int_t pmt_id = tofpmt->pmt_id; adc[pmt_id] = tofpmt->adc ; // raw ADC } //loop on 48 pmts //==================================================================== //=========== Check ToF standalone using HitPaddle ================== //==================================================================== Int_t paddleidoftrack[6] = {-1, -1, -1, -1, -1, -1};; for(Int_t jj=0; jj<8; jj++){ Int_t HitPad = L2->GetToFLevel2()->HitPaddle(0,jj); if (HitPad==1) paddleidoftrack[0] = jj; } for(Int_t jj=0; jj<6; jj++){ Int_t HitPad = L2->GetToFLevel2()->HitPaddle(1,jj); if (HitPad==1) paddleidoftrack[1] = jj; } for(Int_t jj=0; jj<2; jj++){ Int_t HitPad = L2->GetToFLevel2()->HitPaddle(2,jj); if (HitPad==1) paddleidoftrack[2] = jj; } for(Int_t jj=0; jj<2; jj++){ Int_t HitPad = L2->GetToFLevel2()->HitPaddle(3,jj); if (HitPad==1) paddleidoftrack[3] = jj; } for(Int_t jj=0; jj<3; jj++){ Int_t HitPad = L2->GetToFLevel2()->HitPaddle(4,jj); if (HitPad==1) paddleidoftrack[4] = jj; } for(Int_t jj=0; jj<3; jj++){ Int_t HitPad = L2->GetToFLevel2()->HitPaddle(5,jj); if (HitPad==1) paddleidoftrack[5] = jj; } /* cout<<"paddleidoftrack std "; for (Int_t ilay=0; ilay<6; ilay++) { cout<<" "<=PMTsat[iihelp]-5)INFOpmt[iihelp]=3; if( adc[ihelp] >= PMTsat[iihelp]-5 ) continue; if( adc[ihelp] <= 0. ) continue; double adcpC = f_adcPC( adc[iihelp] ); // - adc conversion in pC double adccorr = adcpC*fabs(cos(theta[ilay])); if(adccorr<=0)INFOpmt[ihelp]=4; if(adccorr<=0.) continue; */ adcl= adc[ihelp]; adcr= adc[ihelp+1]; adclraw = adcl; adcrraw = adcr; adcl = f_adcPC( adcl ); // - adc conversion in pC adcr = f_adcPC( adcr ); // - adc conversion in pC Float_t x; if (ilay==0) x = tof->ytofpos[0]; if (ilay==1) x = tof->xtofpos[0]; if (ilay==2) x = tof->xtofpos[1]; if (ilay==3) x = tof->ytofpos[1]; if (ilay==4) x = tof->ytofpos[2]; if (ilay==5) x = tof->xtofpos[2]; /* Float_t xx; if (ilay==0) xx=yv[0]; if (ilay==1) xx=xv[1]; if (ilay==2) xx=xv[2]; if (ilay==3) xx=yv[3]; if (ilay==4) xx=yv[4]; if (ilay==5) xx=xv[5]; cout< "< "<-1 } // ilay //----------------------------------------------------------------- // The GetdEdx method "handmade" //----------------------------------------------------------------- for (Int_t ilay=0; ilay<6; ilay++) { Float_t xhelp=1000.; Int_t i1 = paddleidoftrack[ilay]; if (i1 != -1) { ipad = ipad_a[ilay]+i1; ihelp = ipmt_a[ilay]+(i1*2); if ((eDEDXpmtstd[ihelp]<1000.) && (eDEDXpmtstd[ihelp+1]==1000.)) xhelp = eDEDXpmtstd[ihelp]; if ((eDEDXpmtstd[ihelp+1]<1000.) && (eDEDXpmtstd[ihelp]==1000.)) xhelp = eDEDXpmtstd[ihelp+1]; if ((eDEDXpmtstd[ihelp]<1000.) && (eDEDXpmtstd[ihelp+1]<1000.)) xhelp = 0.5*(eDEDXpmtstd[ihelp]+eDEDXpmtstd[ihelp+1]); eDEDXpadstd[ipad] = xhelp; eDEDXlayerstd[ilay] = xhelp; } } // ilay } // if (pam_event->GetToFStoredTrack(-1) )... }; //------------------------------------------------------------------------ void ToFPatch::Define_PMTsat() { Float_t sat[48] = { 3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, 3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, 3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, 3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, 3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, 3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; PMTsat.Set(48,sat); } //------------------------------------------------------------------------ void ToFPatch::ReadParAtt(const char *pardir, const char *param) { char filename[100],filename1[100],filename2[100],name[50]; char str1[10]; //--------------------- flight --------------------------- if (strcmp(param,"simu") != 0){ //cout<<"Flight calibrations "<>t1>>tm>>t2; //cout<>idummy>>xmean1>>xwidth1; pmthelp[ii] = xmean1; } dedx_corr_m[jj].Set(48,pmthelp); jj=jj+1; } /* Int_t idummy; for (Int_t jj=0; jj<2000; jj++) { fin>>t1>>tm>>t2; cout<>idummy>>xmean1>>xwidth1; dedx_corr_m[jj][ii]=xmean1; } } */ fin.close(); } // flight //--------------------- simu --------------------------- if ( strcmp(param,"simu") == 0){ sprintf(filename2,"%sdedx_2nd_corr_simu.dat",pardir); cout<<"Filename 2nd order "<>t1>>tm>>t2; //cout<>idummy>>xmean1>>xwidth1; pmthelp[ii] = xmean1; } dedx_corr_m[jj].Set(48,pmthelp); jj=jj+1; } fin.close(); } // simu // set first time interval ical_2nd=0; tmin_2nd = mtime[0]; tmax_2nd = mtime[1]; cout<<"First time interval 2nd order corr.: "<