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] ; |
// |
967 |
|
// if it is a compress event with fully transmitted pre try to calculate the baseline |
968 |
|
// |
969 |
|
if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { |
970 |
|
base[l][m][pre] = de->base[l][m][pre] ; |
971 |
|
} else { |
972 |
|
FindBaseCompress(l,m,pre,nstt[j],rqp[j]); |
973 |
|
}; |
974 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
975 |
} else { |
} else { |
976 |
// |
// |
977 |
// if it is a raw event and we haven't checked |
// if it is a raw event calculate the baseline. |
|
// yet, calculate the baseline. |
|
978 |
// |
// |
979 |
FindBaseRaw(l,m,pre); |
FindBaseRaw(l,m,pre,nstt[j],rqp[j]); |
980 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
981 |
}; |
}; |
982 |
}; |
}; |
983 |
|
// |
984 |
|
// 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 |
985 |
|
// |
986 |
|
if ( nstt[0] < 4 && nstt[1] >= 4 ) base[l][m][pre-1] = 31000.; |
987 |
|
if ( nstt[0] >= 4 && nstt[1] < 4 ) base[l][m][pre] = 31000.; |
988 |
|
// // |
989 |
|
// // 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 |
990 |
|
// // |
991 |
|
// if ( nstt[0] < 4 && nstt[1] < 4 ){ |
992 |
|
// if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; |
993 |
|
// if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; |
994 |
|
// }; |
995 |
}; |
}; |
996 |
// |
// |
997 |
// run over strips |
// run over strips |
1041 |
case 0: |
case 0: |
1042 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
1043 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1044 |
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]); |
1045 |
break; |
break; |
1046 |
case 1: |
case 1: |
1047 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
1048 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
1049 |
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]]); |
1050 |
break; |
break; |
1051 |
case 2: |
case 2: |
1052 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
1053 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1054 |
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]); |
1055 |
break; |
break; |
1056 |
case 3: |
case 3: |
1057 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
1058 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1059 |
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]); |
1060 |
break; |
break; |
1061 |
}; |
}; |
1062 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
1162 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
1163 |
// |
// |
1164 |
Float_t savel1 = clevel1->estrip[j4][m][l]; |
Float_t savel1 = clevel1->estrip[j4][m][l]; |
1165 |
if ( dexyc[j4][m][l] == 32767. ) savel1 += 5000.; |
if ( dexyc[l][m][j4] == 32767. ){ |
1166 |
|
savel1 += 5000.; |
1167 |
|
clevel2->nsatstrip += 1.; |
1168 |
|
}; |
1169 |
// |
// |
1170 |
tim = 100000.; |
tim = 100000.; |
1171 |
plo = m; |
plo = m; |
1317 |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
1318 |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
1319 |
ca->nstrip = (Int_t)clevel2->nstrip; |
ca->nstrip = (Int_t)clevel2->nstrip; |
1320 |
|
ca->nsatstrip = (Int_t)clevel2->nsatstrip; |
1321 |
ca->qtot = clevel2->qtot; |
ca->qtot = clevel2->qtot; |
1322 |
// ca->impx = clevel2->impx; |
// ca->impx = clevel2->impx; |
1323 |
// ca->impy = clevel2->impy; |
// ca->impy = clevel2->impy; |
1408 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
1409 |
clevel2->good = 0; |
clevel2->good = 0; |
1410 |
clevel2->nstrip = 0.; |
clevel2->nstrip = 0.; |
1411 |
|
clevel2->nsatstrip = 0.; |
1412 |
clevel2->qtot = 0.; |
clevel2->qtot = 0.; |
1413 |
// clevel2->impx = 0.; |
// clevel2->impx = 0.; |
1414 |
// clevel2->impy = 0.; |
// clevel2->impy = 0.; |