1 |
// |
// // C/C++ headers // |
|
// C/C++ headers |
|
|
// |
|
2 |
#include <fstream> |
#include <fstream> |
3 |
#include <string.h> |
#include <string.h> |
4 |
#include <iomanip> |
#include <iomanip> |
763 |
jumped = 0; |
jumped = 0; |
764 |
// |
// |
765 |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){ |
766 |
|
// for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+100); re++){ // QUIIIIIII |
767 |
// |
// |
768 |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000); |
769 |
// |
// |
900 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
901 |
tofinput_.tdc[hh][gg] = (0xFFF & tofEvent->tdc[gg][hh]); // exclude warning bits |
tofinput_.tdc[hh][gg] = (0xFFF & tofEvent->tdc[gg][hh]); // exclude warning bits |
902 |
tofinput_.adc[hh][gg] = (0xFFF & tofEvent->adc[gg][hh]); // exclude warning bits |
tofinput_.adc[hh][gg] = (0xFFF & tofEvent->adc[gg][hh]); // exclude warning bits |
903 |
|
/* if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
904 |
|
printf(" g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
905 |
|
printf(" g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
906 |
|
}*/ |
907 |
}; |
}; |
908 |
}; |
}; |
909 |
// |
// |
910 |
tofdedx->Init(tofEvent); |
tofdedx->Init(tofEvent); |
911 |
|
/* for (Int_t gg=0; gg<4;gg++){ |
912 |
|
for (Int_t hh=0; hh<12;hh++){ |
913 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
914 |
|
printf("A g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
915 |
|
printf("A g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
916 |
|
} |
917 |
|
}; |
918 |
|
};*/ |
919 |
|
|
920 |
warning = 0; |
warning = 0; |
921 |
// |
// |
922 |
for (Int_t hh=0; hh<5;hh++){ |
for (Int_t hh=0; hh<5;hh++){ |
932 |
// Calculate tracks informations from ToF alone |
// Calculate tracks informations from ToF alone |
933 |
// |
// |
934 |
tofl2com(); |
tofl2com(); |
935 |
|
/* for (Int_t gg=0; gg<4;gg++){ |
936 |
|
for (Int_t hh=0; hh<12;hh++){ |
937 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
938 |
|
printf("B g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
939 |
|
printf("B g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
940 |
|
} |
941 |
|
}; |
942 |
|
};*/ |
943 |
// |
// |
944 |
memcpy(tof->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
memcpy(tof->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
945 |
// |
// |
1015 |
} |
} |
1016 |
// 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]}; |
1017 |
// 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.}; |
1018 |
|
/* for (Int_t gg=0; gg<4;gg++){ |
1019 |
|
for (Int_t hh=0; hh<12;hh++){ |
1020 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
1021 |
|
printf("B0 g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
1022 |
|
printf("B0 g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
1023 |
|
} |
1024 |
|
}; |
1025 |
|
};*/ |
1026 |
tofdedx->Process(atime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); |
tofdedx->Process(atime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp); |
1027 |
|
/* for (Int_t gg=0; gg<4;gg++){ |
1028 |
|
for (Int_t hh=0; hh<12;hh++){ |
1029 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
1030 |
|
printf("B1 g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
1031 |
|
printf("B1 g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
1032 |
|
} |
1033 |
|
}; |
1034 |
|
};*/ |
1035 |
t_tof->npmtadc = 0; |
t_tof->npmtadc = 0; |
1036 |
for (Int_t hh=0; hh<12;hh++){ |
for (Int_t hh=0; hh<12;hh++){ |
1037 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t kk=0; kk<4;kk++){ |
1041 |
// Int_t IpaddleT=-1; |
// Int_t IpaddleT=-1; |
1042 |
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle); |
1043 |
tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright); |
tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright); |
1044 |
|
if (tofEvent->tdc[kk][hh] < 4095 || tofEvent->adc[kk][hh] < 4095 || tofinput_.tdc[hh][kk] < 4095 || tofinput_.adc[hh][kk] < 4095 ) { |
1045 |
if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. && (inter_dedx[pmt_id]+slope_dedx[pmt_id]*tofdedx->GetdEdx_pmt(pmt_id)) > 0. &&((xtof_temp[Iplane]>=xleft&&xtof_temp[Iplane]<=xright) || (ytof_temp[Iplane]>=yleft&&ytof_temp[Iplane]<=yright)) ){ |
if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. && (inter_dedx[pmt_id]+slope_dedx[pmt_id]*tofdedx->GetdEdx_pmt(pmt_id)) > 0. &&((xtof_temp[Iplane]>=xleft&&xtof_temp[Iplane]<=xright) || (ytof_temp[Iplane]>=yleft&&ytof_temp[Iplane]<=yright)) ){ |
1046 |
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
1047 |
|
|
1050 |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1051 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
1052 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |
1053 |
|
}; |
1054 |
}; |
}; |
1055 |
}; |
}; |
1056 |
}; |
}; |
1073 |
// |
// |
1074 |
t_pmt->Clear(); |
t_pmt->Clear(); |
1075 |
// |
// |
1076 |
for (Int_t hh=0; hh<12;hh++){ |
/* for (Int_t gg=0; gg<4;gg++){ |
1077 |
for (Int_t kk=0; kk<4;kk++){ |
for (Int_t hh=0; hh<12;hh++){ |
1078 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
1079 |
|
printf("B2 g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
1080 |
|
printf("B2 g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
1081 |
|
} |
1082 |
|
}; |
1083 |
|
};*/ |
1084 |
|
for (Int_t gg=0; gg<4;gg++){ |
1085 |
|
for (Int_t hh=0; hh<12;hh++){ |
1086 |
// new WM |
// new WM |
1087 |
if ( tofoutput_.tdc_c[hh][kk] < 4095 || (0xFFF & tofEvent->adc[kk][hh]) < 4095 || (0xFFF & tofEvent->tdc[kk][hh]) < 4095 ){ |
if ( tofoutput_.tdc_c[hh][gg] < 4095 || (0xFFF & tofEvent->adc[gg][hh]) < 4095 || (0xFFF & tofEvent->tdc[gg][hh]) < 4095 ){ |
1088 |
// |
// |
1089 |
t_pmt->pmt_id = tof->GetPMTid(kk,hh); |
/* printf(" FILL h %i k %i TDC event %i masked %i \n",hh,gg,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
1090 |
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
printf(" FILL h %i k %i ADC event %i masked %i \n",hh,gg,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
1091 |
t_pmt->adc = (Float_t)(0xFFF & tofEvent->adc[kk][hh]); |
printf(" FILL h %i k %i TDC_C event %f \n",hh,gg,tofoutput_.tdc_c[hh][gg]);*/ |
1092 |
t_pmt->tdc = (Float_t)(0xFFF & tofEvent->tdc[kk][hh]); |
|
1093 |
t_pmt->l0flag_adc = (Float_t)(tofEvent->adc[kk][hh]>>12); |
t_pmt->pmt_id = tof->GetPMTid(gg,hh); |
1094 |
t_pmt->l0flag_tdc = (Float_t)(tofEvent->tdc[kk][hh]>>12); |
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][gg]; |
1095 |
|
t_pmt->adc = (Float_t)(0xFFF & tofEvent->adc[gg][hh]); |
1096 |
|
t_pmt->tdc = (Float_t)(0xFFF & tofEvent->tdc[gg][hh]); |
1097 |
|
t_pmt->l0flag_adc = (Float_t)(tofEvent->adc[gg][hh]>>12); |
1098 |
|
t_pmt->l0flag_tdc = (Float_t)(tofEvent->tdc[gg][hh]>>12); |
1099 |
if ( t_pmt->l0flag_adc || t_pmt->l0flag_tdc ) warning |= 1 << 0; |
if ( t_pmt->l0flag_adc || t_pmt->l0flag_tdc ) warning |= 1 << 0; |
1100 |
// |
// |
1101 |
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
1104 |
}; |
}; |
1105 |
}; |
}; |
1106 |
}; |
}; |
1107 |
|
/* for (Int_t gg=0; gg<4;gg++){ |
1108 |
|
for (Int_t hh=0; hh<12;hh++){ |
1109 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
1110 |
|
printf("B3 g %i h %i TDC event %i masked %i \n",gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
1111 |
|
printf("B3 g %i h %i ADC event %i masked %i \n",gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
1112 |
|
} |
1113 |
|
}; |
1114 |
|
};*/ |
1115 |
// |
// |
1116 |
if ( debug ) printf(" ATIME %u re %u \n",atime,(UInt_t)re); |
if ( debug ) printf(" ATIME %u re %u \n",atime,(UInt_t)re); |
1117 |
// Calculate track-related variables |
// Calculate track-related variables |
1140 |
// Get tracker related variables for this track |
// Get tracker related variables for this track |
1141 |
// |
// |
1142 |
toftrk(); |
toftrk(); |
1143 |
|
/* for (Int_t gg=0; gg<4;gg++){ |
1144 |
|
for (Int_t hh=0; hh<12;hh++){ |
1145 |
|
if (tofEvent->tdc[gg][hh] < 4095 || tofEvent->adc[gg][hh] < 4095 || tofinput_.tdc[hh][gg] < 4095 || tofinput_.adc[hh][gg] < 4095 ) { |
1146 |
|
printf("C%i g %i h %i TDC event %i masked %i \n",nt,gg,hh,tofEvent->tdc[gg][hh],tofinput_.tdc[hh][gg]); |
1147 |
|
printf("C%i g %i h %i ADC event %i masked %i \n",nt,gg,hh,tofEvent->adc[gg][hh],tofinput_.adc[hh][gg]); |
1148 |
|
} |
1149 |
|
}; |
1150 |
|
};*/ |
1151 |
// |
// |
1152 |
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
1153 |
// |
// |
1185 |
IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0); |
IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0); |
1186 |
//if ( debug ) printf(" 1nt %i pmt_id %i npmtadc %i dedx %f dedx corr %f\n",nt,pmt_id,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),dedx_corr[pmt_id]); |
//if ( debug ) printf(" 1nt %i pmt_id %i npmtadc %i dedx %f dedx corr %f\n",nt,pmt_id,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),dedx_corr[pmt_id]); |
1187 |
if ( debug ) printf(" 1nt %i pmt_id %i npmtadc %i dedx %f dedx slope %f dedx inter %f\n",nt,pmt_id,t_tof->npmtadc,(inter_dedx[pmt_id]+slope_dedx[pmt_id]*tofdedx->GetdEdx_pmt(pmt_id)),inter_dedx[pmt_id],slope_dedx[pmt_id]); |
if ( debug ) printf(" 1nt %i pmt_id %i npmtadc %i dedx %f dedx slope %f dedx inter %f\n",nt,pmt_id,t_tof->npmtadc,(inter_dedx[pmt_id]+slope_dedx[pmt_id]*tofdedx->GetdEdx_pmt(pmt_id)),inter_dedx[pmt_id],slope_dedx[pmt_id]); |
1188 |
|
|
1189 |
|
if (tofEvent->tdc[kk][hh] < 4095 || tofEvent->adc[kk][hh] < 4095 || tofinput_.tdc[hh][kk] < 4095 || tofinput_.adc[hh][kk] < 4095 ) { |
1190 |
|
|
1191 |
if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && (inter_dedx[pmt_id]+slope_dedx[pmt_id]*tofdedx->GetdEdx_pmt(pmt_id)) > 0. && Ipaddle==IpaddleT ){ |
if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && (inter_dedx[pmt_id]+slope_dedx[pmt_id]*tofdedx->GetdEdx_pmt(pmt_id)) > 0. && Ipaddle==IpaddleT ){ |
1192 |
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
//t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc); |
1193 |
|
|
1199 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07 |
1200 |
t_tof->npmtadc++; |
t_tof->npmtadc++; |
1201 |
}; |
}; |
1202 |
|
|
1203 |
|
}; |
1204 |
}; |
}; |
1205 |
}; |
}; |
1206 |
// |
// |
1297 |
if ( l0File ) l0File->Close(); |
if ( l0File ) l0File->Close(); |
1298 |
if ( tempfile ) tempfile->Close(); |
if ( tempfile ) tempfile->Close(); |
1299 |
if ( myfold ) gSystem->Unlink(tempname.str().c_str()); |
if ( myfold ) gSystem->Unlink(tempname.str().c_str()); |
|
if ( tracker ) tracker->Delete(); // delete tracker tree from memory only to avoid writing a copy to file! |
|
1300 |
// |
// |
1301 |
if ( code < 0 && verbose ) printf("\n TOF - ERROR: an error occurred, try to save anyway...\n"); |
if ( code < 0 && verbose ) printf("\n TOF - ERROR: an error occurred, try to save anyway...\n"); |
1302 |
if ( verbose ) printf("\n Writing and closing rootple\n"); |
if ( verbose ) printf("\n Writing and closing rootple\n"); |
|
if ( runinfo ) runinfo->Close(); |
|
1303 |
if ( toft ) toft->SetName("ToF"); |
if ( toft ) toft->SetName("ToF"); |
1304 |
if ( file ){ |
if ( file ){ |
1305 |
file->cd(); |
file->cd(); |
1306 |
file->Write("ToF"); |
toft->Write(0, TObject::kOverwrite); |
1307 |
}; |
}; |
1308 |
// |
// |
1309 |
if ( myfold ) gSystem->Unlink(toffolder.str().c_str()); |
if ( myfold ) gSystem->Unlink(toffolder.str().c_str()); |
1311 |
// the end |
// the end |
1312 |
// |
// |
1313 |
if ( verbose ) printf("\n Exiting...\n"); |
if ( verbose ) printf("\n Exiting...\n"); |
|
if(toft)toft->Delete(); |
|
1314 |
// |
// |
|
if ( tof ) delete tof; |
|
|
if ( tofclone ) delete tofclone; |
|
1315 |
if ( tofdedx ) delete tofdedx; |
if ( tofdedx ) delete tofdedx; |
1316 |
if ( glroot ) delete glroot; |
if ( glroot ) delete glroot; |
1317 |
|
if ( glparam ) delete glparam; |
1318 |
|
if ( runinfo ) runinfo->Close(); |
1319 |
if ( runinfo ) delete runinfo; |
if ( runinfo ) delete runinfo; |
1320 |
// |
// |
1321 |
if ( code < 0 ) throw code; |
if ( code < 0 ) throw code; |