| 82 |
|
|
| 83 |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
| 84 |
crosst = ct; |
crosst = ct; |
| 85 |
}; |
} |
| 86 |
|
|
| 87 |
void CaloLevel0::SetCrossTalkType(Bool_t ct){ |
void CaloLevel0::SetCrossTalkType(Bool_t ct){ |
| 88 |
ctground = ct; |
ctground = ct; |
| 89 |
}; |
} |
| 90 |
|
|
| 91 |
void CaloLevel0::SetVerbose(Bool_t ct){ |
void CaloLevel0::SetVerbose(Bool_t ct){ |
| 92 |
verbose = ct; |
verbose = ct; |
| 93 |
}; |
} |
| 94 |
|
|
| 95 |
/** |
/** |
| 96 |
* Initialize CaloLevel0 object |
* Initialize CaloLevel0 object |
| 307 |
fread(&tmp,sizeof(clevel1->xalig),1,f); |
fread(&tmp,sizeof(clevel1->xalig),1,f); |
| 308 |
fread(&tmp,sizeof(clevel1->yalig),1,f); |
fread(&tmp,sizeof(clevel1->yalig),1,f); |
| 309 |
fread(&tmp,sizeof(clevel1->zalig),1,f); |
fread(&tmp,sizeof(clevel1->zalig),1,f); |
| 310 |
|
// clevel1->zalig = -265.82; |
| 311 |
// |
// |
| 312 |
}; |
}; |
| 313 |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
| 726 |
}; |
}; |
| 727 |
// |
// |
| 728 |
return(0); |
return(0); |
| 729 |
}; |
} |
| 730 |
|
|
| 731 |
|
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre){ |
| 732 |
|
Int_t n = 0; |
| 733 |
|
Float_t q = 0; |
| 734 |
|
this->FindBaseCompress(l,m,pre,n,q); |
| 735 |
|
} |
| 736 |
|
|
| 737 |
|
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ |
| 738 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 739 |
|
dexy[l][m][e] = dexyc[l][m][e]; |
| 740 |
|
}; |
| 741 |
|
this->FindBaseRaw(l,m,pre,nst,qp); |
| 742 |
|
} |
| 743 |
|
|
| 744 |
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ |
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ |
| 745 |
Float_t minstrip = 100000.; |
Int_t n = 0; |
| 746 |
Float_t rms = 0.; |
Float_t q = 0; |
| 747 |
base[l][m][pre] = 0.; |
this->FindBaseRaw(l,m,pre,n,q); |
| 748 |
|
} |
| 749 |
|
|
| 750 |
|
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ |
| 751 |
|
// |
| 752 |
|
Float_t minstrip = 100000.; |
| 753 |
|
Float_t rms = 0.; |
| 754 |
|
base[l][m][pre] = 0.; |
| 755 |
|
qp = 0.; |
| 756 |
|
// |
| 757 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 758 |
|
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0.) { |
| 759 |
|
minstrip = dexy[l][m][e]-calped[l][m][e]; |
| 760 |
|
rms = calthr[l][m][pre]; |
| 761 |
|
}; |
| 762 |
|
qp += (dexy[l][m][e]-calped[l][m][e]-sbase[l][m][e]); |
| 763 |
|
}; |
| 764 |
|
// |
| 765 |
|
if ( debug && l==1 ){ |
| 766 |
|
printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n => qp = %f \n",l,m,pre,minstrip,rms,qp); |
| 767 |
|
}; |
| 768 |
|
if ( minstrip != 100000. ) { |
| 769 |
|
Float_t strip6s = 0.; |
| 770 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 771 |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0.) { |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
| 772 |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
strip6s += 1.; |
| 773 |
rms = calthr[l][m][pre]; |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
| 774 |
}; |
}; |
| 775 |
|
// |
| 776 |
|
// compression |
| 777 |
|
// |
| 778 |
|
if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
| 779 |
|
dexyc[l][m][e] = 0.; |
| 780 |
|
} else { |
| 781 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
| 782 |
|
}; |
| 783 |
}; |
}; |
| 784 |
if ( minstrip != 100000. ) { |
// |
| 785 |
Float_t strip6s = 0.; |
nst = (Int_t)strip6s; |
| 786 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
// |
| 787 |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
if ( debug && l==1 ){ |
| 788 |
strip6s += 1.; |
printf(" strip6s %f \n",strip6s); |
| 789 |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
}; |
| 790 |
}; |
// if ( strip6s >= 9. ){ |
| 791 |
// |
if ( strip6s >= 2. ){ |
| 792 |
// compression |
Double_t arro = base[l][m][pre]/strip6s; |
| 793 |
// |
Float_t deci = 1000.*((float)arro - float(int(arro))); |
| 794 |
if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
if ( deci < 500. ) { |
| 795 |
dexyc[l][m][e] = 0.; |
arro = double(int(arro)); |
| 796 |
} else { |
} else { |
| 797 |
dexyc[l][m][e] = dexy[l][m][e]; |
arro = 1. + double(int(arro)); |
| 798 |
}; |
}; |
| 799 |
}; |
base[l][m][pre] = arro; |
| 800 |
if ( strip6s >= 9. ){ |
// |
| 801 |
Double_t arro = base[l][m][pre]/strip6s; |
// if too few strips were used to determine the baseline check if it is comparable with the previous event, if not mark it as bad |
| 802 |
Float_t deci = 1000.*((float)arro - float(int(arro))); |
// |
| 803 |
if ( deci < 500. ) { |
if ( debug && l==1 ) printf(" Calculated baseline: base %f sbase*1.02 %f \n",base[l][m][pre],1.02*sbase[l][m][pre]); |
| 804 |
arro = double(int(arro)); |
// |
| 805 |
} else { |
if ( strip6s < 4 && base[l][m][pre] > 1.02*sbase[l][m][pre] && sbase[l][m][pre] > 0. ){ |
| 806 |
arro = 1. + double(int(arro)); |
if ( debug ) printf(" Suspicious calculated baseline: base %f sbase*1.02 %f strip6s %i \n",base[l][m][pre],1.02*sbase[l][m][pre],(Int_t)strip6s); |
| 807 |
}; |
base[l][m][pre] = 31000.; |
| 808 |
base[l][m][pre] = arro; |
}; |
|
} else { |
|
|
base[l][m][pre] = 31000.; |
|
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
|
|
dexyc[l][m][e] = dexy[l][m][e]; |
|
|
}; |
|
|
}; |
|
| 809 |
} else { |
} else { |
| 810 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
| 811 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
| 812 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
| 813 |
|
}; |
| 814 |
}; |
}; |
| 815 |
|
} else { |
| 816 |
|
base[l][m][pre] = 31000.; |
| 817 |
|
}; |
| 818 |
} |
} |
| 819 |
|
|
| 820 |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
| 825 |
// |
// |
| 826 |
// if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. |
// if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. |
| 827 |
// |
// |
| 828 |
|
clevel2->nsatstrip = 0.; |
| 829 |
Int_t val = 0; |
Int_t val = 0; |
| 830 |
Int_t del = 1100; |
Int_t del = 1100; |
| 831 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
| 950 |
// |
// |
| 951 |
pre = -1; |
pre = -1; |
| 952 |
cbase0 = 0.; |
cbase0 = 0.; |
| 953 |
|
Int_t nstt[2]; |
| 954 |
|
Float_t rqp[2]; |
| 955 |
for (Int_t i = 0; i < 3; i++){ |
for (Int_t i = 0; i < 3; i++){ |
| 956 |
|
nstt[0] = 0; |
| 957 |
|
nstt[1] = 0; |
| 958 |
|
rqp[0] = 0.; |
| 959 |
|
rqp[1] = 0.; |
| 960 |
for (Int_t j = 0; j < 2; j++){ |
for (Int_t j = 0; j < 2; j++){ |
| 961 |
pre = j + i*2; |
pre = j + i*2; |
| 962 |
// |
// |
| 963 |
// baseline check and calculation |
// baseline check and calculation |
| 964 |
// |
// |
| 965 |
if ( !isRAW ) { |
if ( !isRAW ){ |
| 966 |
base[l][m][pre] = de->base[l][m][pre] ; |
if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { |
| 967 |
|
base[l][m][pre] = de->base[l][m][pre] ; |
| 968 |
|
} else { |
| 969 |
|
FindBaseCompress(l,m,pre,nstt[j],rqp[j]); |
| 970 |
|
}; |
| 971 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
| 972 |
} else { |
} else { |
| 973 |
// |
// |
| 974 |
// if it is a raw event and we haven't checked |
// if it is a raw event calculate the baseline. |
|
// yet, calculate the baseline. |
|
| 975 |
// |
// |
| 976 |
FindBaseRaw(l,m,pre); |
FindBaseRaw(l,m,pre,nstt[j],rqp[j]); |
| 977 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
| 978 |
}; |
}; |
| 979 |
}; |
}; |
| 980 |
|
// |
| 981 |
|
// if we are able to calculate the baseline with more than 3 strips on one pre and not in the other one choose the pre with more calculated strips |
| 982 |
|
// |
| 983 |
|
if ( nstt[0] < 4 && nstt[1] >= 4 ) base[l][m][pre-1] = 31000.; |
| 984 |
|
if ( nstt[0] >= 4 && nstt[1] < 4 ) base[l][m][pre] = 31000.; |
| 985 |
|
// // |
| 986 |
|
// // if we are NOT able to calculate the baseline with more than 3 strips on both pres take the baseline (if any) of the one which has less energy |
| 987 |
|
// // |
| 988 |
|
// if ( nstt[0] < 4 && nstt[1] < 4 ){ |
| 989 |
|
// if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; |
| 990 |
|
// if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; |
| 991 |
|
// }; |
| 992 |
}; |
}; |
| 993 |
// |
// |
| 994 |
// run over strips |
// run over strips |
| 1038 |
case 0: |
case 0: |
| 1039 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
| 1040 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 1041 |
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = base l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,base[l][m][pre],calbase[l][m][pre]); |
| 1042 |
break; |
break; |
| 1043 |
case 1: |
case 1: |
| 1044 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
| 1045 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
| 1046 |
if ( debug ) printf(" base0 = base l m ip(i) = %f base2 = calbase l m ip(i) = %f \n",base[l][m][ip[i]],calbase[l][m][ip[i]]); |
if ( debug ) printf(" base0 = base l%i m%i ip(i)%i = %f base2 = calbase l m ip(i) = %f \n",l,m,ip[i],base[l][m][ip[i]],calbase[l][m][ip[i]]); |
| 1047 |
break; |
break; |
| 1048 |
case 2: |
case 2: |
| 1049 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
| 1050 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 1051 |
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = sbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,sbase[l][m][pre],calbase[l][m][pre]); |
| 1052 |
break; |
break; |
| 1053 |
case 3: |
case 3: |
| 1054 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
| 1055 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
| 1056 |
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = calbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,calbase[l][m][pre],calbase[l][m][pre]); |
| 1057 |
break; |
break; |
| 1058 |
}; |
}; |
| 1059 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
| 1153 |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
| 1154 |
clevel1->estrip[j4][m][l] = 0.; |
clevel1->estrip[j4][m][l] = 0.; |
| 1155 |
}; |
}; |
| 1156 |
// |
// |
| 1157 |
// code and save the energy for each strip in svstrip |
// code and save the energy for each strip in svstrip |
| 1158 |
// |
// |
| 1159 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
| 1160 |
// |
// |
| 1161 |
|
Float_t savel1 = clevel1->estrip[j4][m][l]; |
| 1162 |
|
if ( dexyc[l][m][j4] == 32767. ){ |
| 1163 |
|
savel1 += 5000.; |
| 1164 |
|
clevel2->nsatstrip += 1.; |
| 1165 |
|
}; |
| 1166 |
|
// |
| 1167 |
tim = 100000.; |
tim = 100000.; |
| 1168 |
plo = m; |
plo = m; |
| 1169 |
fbi = 0; |
fbi = 0; |
| 1170 |
if ( clevel1->estrip[j4][m][l] > 0.99995 ){ |
if ( savel1 > 0.99995 ){ |
| 1171 |
tim = 10000.; |
tim = 10000.; |
| 1172 |
plo = m; |
plo = m; |
| 1173 |
fbi = 1; |
fbi = 1; |
| 1174 |
}; |
}; |
| 1175 |
if ( clevel1->estrip[j4][m][l] > 9.9995 ){ |
if ( savel1 > 9.9995 ){ |
| 1176 |
tim = 1000.; |
tim = 1000.; |
| 1177 |
plo = 22 + m; |
plo = 22 + m; |
| 1178 |
fbi = 1; |
fbi = 1; |
| 1179 |
}; |
}; |
| 1180 |
if ( clevel1->estrip[j4][m][l] > 99.995 ){ |
if ( savel1 > 99.995 ){ |
| 1181 |
tim = 100.; |
tim = 100.; |
| 1182 |
plo = 22 + m; |
plo = 22 + m; |
| 1183 |
fbi = 0; |
fbi = 0; |
| 1184 |
}; |
}; |
| 1185 |
if ( clevel1->estrip[j4][m][l] > 999.95 ){ |
if ( savel1 > 999.95 ){ |
| 1186 |
tim = 10.; |
tim = 10.; |
| 1187 |
plo = 44 + m; |
plo = 44 + m; |
| 1188 |
fbi = 0; |
fbi = 0; |
| 1189 |
}; |
}; |
| 1190 |
if ( clevel1->estrip[j4][m][l] > 9999.5 ){ |
if ( savel1 > 9999.5 ){ |
| 1191 |
tim = 1.; |
tim = 1.; |
| 1192 |
plo = 66 + m; |
plo = 66 + m; |
| 1193 |
fbi = 0; |
fbi = 0; |
| 1194 |
}; |
}; |
| 1195 |
// |
// |
| 1196 |
cle = (Int_t)lroundf(tim*clevel1->estrip[j4][m][l]); |
cle = (Int_t)lroundf(tim*savel1); |
| 1197 |
// |
// |
| 1198 |
if ( l == 0 ){ |
if ( l == 0 ){ |
| 1199 |
// |
// |
| 1314 |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
| 1315 |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
| 1316 |
ca->nstrip = (Int_t)clevel2->nstrip; |
ca->nstrip = (Int_t)clevel2->nstrip; |
| 1317 |
|
ca->nsatstrip = (Int_t)clevel2->nsatstrip; |
| 1318 |
ca->qtot = clevel2->qtot; |
ca->qtot = clevel2->qtot; |
| 1319 |
// ca->impx = clevel2->impx; |
// ca->impx = clevel2->impx; |
| 1320 |
// ca->impy = clevel2->impy; |
// ca->impy = clevel2->impy; |
| 1405 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
| 1406 |
clevel2->good = 0; |
clevel2->good = 0; |
| 1407 |
clevel2->nstrip = 0.; |
clevel2->nstrip = 0.; |
| 1408 |
|
clevel2->nsatstrip = 0.; |
| 1409 |
clevel2->qtot = 0.; |
clevel2->qtot = 0.; |
| 1410 |
// clevel2->impx = 0.; |
// clevel2->impx = 0.; |
| 1411 |
// clevel2->impy = 0.; |
// clevel2->impy = 0.; |