729 |
} |
} |
730 |
|
|
731 |
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre){ |
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++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
739 |
dexy[l][m][e] = dexyc[l][m][e]; |
dexy[l][m][e] = dexyc[l][m][e]; |
740 |
}; |
}; |
741 |
this->FindBaseRaw(l,m,pre); |
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 |
|
// |
785 |
|
nst = (Int_t)strip6s; |
786 |
|
// |
787 |
if ( debug && l==1 ){ |
if ( debug && l==1 ){ |
788 |
printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n",l,m,pre,minstrip,rms); |
printf(" strip6s %f \n",strip6s); |
789 |
}; |
}; |
790 |
if ( minstrip != 100000. ) { |
// if ( strip6s >= 9. ){ |
791 |
Float_t strip6s = 0.; |
if ( strip6s >= 2. ){ |
792 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
Double_t arro = base[l][m][pre]/strip6s; |
793 |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
Float_t deci = 1000.*((float)arro - float(int(arro))); |
794 |
strip6s += 1.; |
if ( deci < 500. ) { |
795 |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
arro = double(int(arro)); |
796 |
}; |
} else { |
797 |
// |
arro = 1. + double(int(arro)); |
798 |
// compression |
}; |
799 |
// |
base[l][m][pre] = arro; |
800 |
if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
// |
801 |
dexyc[l][m][e] = 0.; |
// 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 |
} else { |
// |
803 |
dexyc[l][m][e] = dexy[l][m][e]; |
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 |
}; |
// |
805 |
}; |
if ( strip6s < 4 && base[l][m][pre] > 1.02*sbase[l][m][pre] && sbase[l][m][pre] > 0. ){ |
806 |
if ( debug && l==1 ){ |
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 |
printf(" strip6s %f \n",strip6s); |
base[l][m][pre] = 31000.; |
808 |
}; |
}; |
|
// if ( strip6s >= 9. ){ |
|
|
if ( strip6s >= 2. ){ |
|
|
Double_t arro = base[l][m][pre]/strip6s; |
|
|
Float_t deci = 1000.*((float)arro - float(int(arro))); |
|
|
if ( deci < 500. ) { |
|
|
arro = double(int(arro)); |
|
|
} else { |
|
|
arro = 1. + double(int(arro)); |
|
|
}; |
|
|
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){ |
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 |
// |
// |
966 |
if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { |
if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { |
967 |
base[l][m][pre] = de->base[l][m][pre] ; |
base[l][m][pre] = de->base[l][m][pre] ; |
968 |
} else { |
} else { |
969 |
FindBaseCompress(l,m,pre); |
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 |