3 |
* \author Gianfranca DeRosa, Wolfgang Menn |
* \author Gianfranca DeRosa, Wolfgang Menn |
4 |
*/ |
*/ |
5 |
|
|
|
#include <TObject.h> |
|
6 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
7 |
#include <iostream> |
|
8 |
using namespace std; |
using namespace std; |
9 |
|
|
10 |
ClassImp(ToFPMT); |
ClassImp(ToFPMT); |
11 |
ClassImp(ToFTrkVar); |
ClassImp(ToFTrkVar); |
12 |
ClassImp(ToFLevel2); |
ClassImp(ToFLevel2); |
15 |
pmt_id = 0; |
pmt_id = 0; |
16 |
adc = 0.; |
adc = 0.; |
17 |
tdc_tw = 0.; |
tdc_tw = 0.; |
18 |
|
tdc = 0.; |
19 |
} |
} |
20 |
|
|
21 |
ToFPMT::ToFPMT(const ToFPMT &t){ |
ToFPMT::ToFPMT(const ToFPMT &t){ |
22 |
pmt_id = t.pmt_id; |
pmt_id = t.pmt_id; |
23 |
adc = t.adc; |
adc = t.adc; |
24 |
tdc_tw = t.tdc_tw; |
tdc_tw = t.tdc_tw; |
25 |
|
tdc = t.tdc; |
26 |
} |
} |
27 |
|
|
28 |
void ToFPMT::Clear(){ |
void ToFPMT::Clear(Option_t *t){ |
29 |
pmt_id = 0; |
pmt_id = 0; |
30 |
adc = 0.; |
adc = 0.; |
31 |
tdc_tw = 0.; |
tdc_tw = 0.; |
32 |
|
tdc = 0.; |
33 |
} |
} |
34 |
|
|
35 |
|
|
53 |
// |
// |
54 |
}; |
}; |
55 |
|
|
56 |
void ToFTrkVar::Clear() { |
void ToFTrkVar::Clear(Option_t *t) { |
57 |
trkseqno = 0; |
trkseqno = 0; |
58 |
npmttdc = 0; |
npmttdc = 0; |
59 |
npmtadc = 0; |
npmtadc = 0; |
107 |
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
108 |
}//ELENA |
}//ELENA |
109 |
|
|
110 |
void ToFLevel2::Clear(){ |
void ToFLevel2::Clear(Option_t *t){ |
111 |
// |
// |
112 |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
if(ToFTrk)ToFTrk->Delete(); //ELENA |
113 |
if(PMT)PMT->Delete(); //ELENA |
if(PMT)PMT->Delete(); //ELENA |
116 |
// |
// |
117 |
}; |
}; |
118 |
|
|
119 |
void ToFLevel2::Delete(){ //ELENA |
void ToFLevel2::Delete(Option_t *t){ //ELENA |
120 |
// |
// |
121 |
if(ToFTrk){ |
if(ToFTrk){ |
122 |
ToFTrk->Delete(); //ELENA |
ToFTrk->Delete(); //ELENA |
508 |
|
|
509 |
}; |
}; |
510 |
|
|
511 |
|
// wm jun 08 |
512 |
|
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
513 |
|
return GetPaddleIdOfTrack(xtr ,ytr ,plane, 0.4); |
514 |
|
} |
515 |
|
|
516 |
// gf Apr 07 |
// gf Apr 07 |
517 |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
// wm jun 08 introduced a margin as input parameter |
518 |
|
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin){ |
519 |
|
|
520 |
Double_t xt,yt,xl,xh,yl,yh; |
Double_t xt,yt,xl,xh,yl,yh; |
521 |
|
|
546 |
yh = 33.0/2. ; |
yh = 33.0/2. ; |
547 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
548 |
for (Int_t i1=0; i1<8;i1++){ |
for (Int_t i1=0; i1<8;i1++){ |
549 |
xl = tof11_x[i1] - (5.1-0.4)/2. ; |
xl = tof11_x[i1] - (5.1-margin)/2. ; |
550 |
xh = tof11_x[i1] + (5.1-0.4)/2. ; |
xh = tof11_x[i1] + (5.1-margin)/2. ; |
551 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
552 |
} |
} |
553 |
} |
} |
564 |
|
|
565 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
566 |
for (Int_t i1=0; i1<6;i1++){ |
for (Int_t i1=0; i1<6;i1++){ |
567 |
yl = tof12_y[i1] - (5.5-0.4)/2. ; |
yl = tof12_y[i1] - (5.5-margin)/2. ; |
568 |
yh = tof12_y[i1] + (5.5-0.4)/2. ; |
yh = tof12_y[i1] + (5.5-margin)/2. ; |
569 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
570 |
} |
} |
571 |
} |
} |
582 |
|
|
583 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
584 |
for (Int_t i1=0; i1<2;i1++){ |
for (Int_t i1=0; i1<2;i1++){ |
585 |
yl = tof21_y[i1] - (7.5-0.4)/2. ; |
yl = tof21_y[i1] - (7.5-margin)/2. ; |
586 |
yh = tof21_y[i1] + (7.5-0.4)/2. ; |
yh = tof21_y[i1] + (7.5-margin)/2. ; |
587 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
588 |
} |
} |
589 |
} |
} |
599 |
|
|
600 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
601 |
for (Int_t i1=0; i1<2;i1++){ |
for (Int_t i1=0; i1<2;i1++){ |
602 |
xl = tof22_x[i1] - (9.0-0.4)/2. ; |
xl = tof22_x[i1] - (9.0-margin)/2. ; |
603 |
xh = tof22_x[i1] + (9.0-0.4)/2. ; |
xh = tof22_x[i1] + (9.0-margin)/2. ; |
604 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
605 |
} |
} |
606 |
} |
} |
616 |
|
|
617 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
618 |
for (Int_t i1=0; i1<3;i1++){ |
for (Int_t i1=0; i1<3;i1++){ |
619 |
xl = tof31_x[i1] - (6.0-0.4)/2. ; |
xl = tof31_x[i1] - (6.0-margin)/2. ; |
620 |
xh = tof31_x[i1] + (6.0-0.4)/2. ; |
xh = tof31_x[i1] + (6.0-margin)/2. ; |
621 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
622 |
} |
} |
623 |
} |
} |
633 |
|
|
634 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
635 |
for (Int_t i1=0; i1<3;i1++){ |
for (Int_t i1=0; i1<3;i1++){ |
636 |
yl = tof32_y[i1] - (5.0-0.4)/2. ; |
yl = tof32_y[i1] - (5.0-margin)/2. ; |
637 |
yh = tof32_y[i1] + (5.0-0.4)/2. ; |
yh = tof32_y[i1] + (5.0-margin)/2. ; |
638 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
639 |
} |
} |
640 |
} |
} |
701 |
// gf Apr 07 |
// gf Apr 07 |
702 |
|
|
703 |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
704 |
|
pmtleft=paddle*2; |
705 |
if(paddle==0){ |
pmtright= pmtleft+1; |
|
pmtleft=0; |
|
|
pmtright=1; |
|
|
} |
|
|
|
|
|
if(paddle==1){ |
|
|
pmtleft=2; |
|
|
pmtright=3; |
|
|
} |
|
|
|
|
|
if(paddle==2){ |
|
|
pmtleft=4; |
|
|
pmtright=5; |
|
|
} |
|
|
|
|
|
if(paddle==3){ |
|
|
pmtleft=6; |
|
|
pmtright=7; |
|
|
} |
|
|
|
|
|
if(paddle==4){ |
|
|
pmtleft=8; |
|
|
pmtright=9; |
|
|
} |
|
|
|
|
|
if(paddle==5){ |
|
|
pmtleft=10; |
|
|
pmtright=11; |
|
|
} |
|
|
|
|
|
if(paddle==6){ |
|
|
pmtleft=12; |
|
|
pmtright=13; |
|
|
} |
|
|
|
|
|
if(paddle==7){ |
|
|
pmtleft=14; |
|
|
pmtright=15; |
|
|
} |
|
|
|
|
|
if(paddle==8){ |
|
|
pmtleft=16; |
|
|
pmtright=17; |
|
|
} |
|
|
|
|
|
if(paddle==9){ |
|
|
pmtleft=18; |
|
|
pmtright=19; |
|
|
} |
|
|
|
|
|
if(paddle==10){ |
|
|
pmtleft=20; |
|
|
pmtright=21; |
|
|
} |
|
|
|
|
|
if(paddle==11){ |
|
|
pmtleft=22; |
|
|
pmtright=23; |
|
|
} |
|
|
|
|
|
if(paddle==12){ |
|
|
pmtleft=24; |
|
|
pmtright=25; |
|
|
} |
|
|
|
|
|
if(paddle==13){ |
|
|
pmtleft=26; |
|
|
pmtright=27; |
|
|
} |
|
|
|
|
|
if(paddle==14){ |
|
|
pmtleft=28; |
|
|
pmtright=29; |
|
|
} |
|
|
|
|
|
if(paddle==15){ |
|
|
pmtleft=30; |
|
|
pmtright=31; |
|
|
} |
|
|
|
|
|
if(paddle==16){ |
|
|
pmtleft=32; |
|
|
pmtright=33; |
|
|
} |
|
|
|
|
|
if(paddle==17){ |
|
|
pmtleft=34; |
|
|
pmtright=35; |
|
|
} |
|
|
|
|
|
if(paddle==18){ |
|
|
pmtleft=36; |
|
|
pmtright=37; |
|
|
} |
|
|
|
|
|
if(paddle==19){ |
|
|
pmtleft=38; |
|
|
pmtright=39; |
|
|
} |
|
|
|
|
|
if(paddle==20){ |
|
|
pmtleft=40; |
|
|
pmtright=41; |
|
|
} |
|
|
|
|
|
if(paddle==21){ |
|
|
pmtleft=42; |
|
|
pmtright=43; |
|
|
} |
|
|
|
|
|
if(paddle==22){ |
|
|
pmtleft=44; |
|
|
pmtright=45; |
|
|
} |
|
|
|
|
|
if(paddle==23){ |
|
|
pmtleft=46; |
|
|
pmtright=47; |
|
|
} |
|
|
|
|
706 |
return; |
return; |
707 |
} |
} |
708 |
|
|
816 |
*/ |
*/ |
817 |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
818 |
{ |
{ |
|
|
|
819 |
Int_t padid=-1; |
Int_t padid=-1; |
820 |
Int_t pads11=8; |
Int_t pads[6]={8,6,2,2,3,3}; |
|
Int_t pads12=6; |
|
|
Int_t pads21=2; |
|
|
Int_t pads22=2; |
|
|
Int_t pads31=3; |
|
|
// Int_t pads32=3; |
|
|
|
|
|
|
|
|
if(plane == 0){ |
|
|
padid=paddle; |
|
|
} |
|
|
|
|
|
if(plane == 1){ |
|
|
padid=pads11+paddle; |
|
|
} |
|
|
|
|
|
if(plane == 2){ |
|
|
padid=pads11+pads12+paddle; |
|
|
} |
|
|
|
|
|
if(plane == 3){ |
|
|
padid=pads11+pads12+pads21+paddle; |
|
|
} |
|
821 |
|
|
822 |
if(plane == 4){ |
int somma=0; |
823 |
padid=pads11+pads12+pads21+pads22+paddle; |
int np=plane; |
824 |
|
for(Int_t j=0; j<np; j++){ |
825 |
|
somma+=pads[j]; |
826 |
} |
} |
827 |
|
padid=paddle+somma; |
|
if(plane == 5){ |
|
|
padid=pads11+pads12+pads21+pads22+pads31+paddle; |
|
|
} |
|
|
|
|
828 |
return padid; |
return padid; |
|
|
|
829 |
} |
} |
830 |
|
|
831 |
|
|
909 |
|
|
910 |
} |
} |
911 |
|
|
912 |
|
/// wm feb 08 |
913 |
|
|
914 |
|
/** |
915 |
|
* Method to calculate Beta from the 12 single measurements |
916 |
|
* we check the individual weights for artificial TDC values, then calculate |
917 |
|
* am mean beta for the first time. In a second step we loop again through |
918 |
|
* the single measurements, checking for the residual from the mean |
919 |
|
* The cut on the residual reject measurements > "x"-sigma. A chi2 value is |
920 |
|
* calculated, furthermore a "quality" value by adding the weights which |
921 |
|
* are finally used. If all measurements are taken, "quality" will be = 22.47. |
922 |
|
* A chi2 cut around 3-4 and a quality-cut > 20 is needed for clean beta |
923 |
|
* measurements like antiprotons etc. |
924 |
|
* The Level2 output is derived in the fortran routines using: 10.,10.,20. |
925 |
|
* @param notrack Track Number |
926 |
|
* @param cut on residual: difference between single measurement and mean |
927 |
|
* @param cut on "quality" |
928 |
|
* @param cut on chi2 |
929 |
|
*/ |
930 |
|
|
931 |
|
Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){ |
932 |
|
|
933 |
|
// cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl; |
934 |
|
|
935 |
|
Float_t bxx = 100.; |
936 |
|
// |
937 |
|
ToFTrkVar *trk = GetToFTrkVar(notrack); |
938 |
|
if(!trk) return 0; //ELENA |
939 |
|
|
940 |
|
|
941 |
|
Float_t chi2,xhelp,beta_mean; |
942 |
|
Float_t w_i[12],quality,sw,sxw,res,betachi,beta_mean_inv; |
943 |
|
Float_t b[12],tdcfl; |
944 |
|
Int_t pmt_id,pmt_plane; |
945 |
|
|
946 |
|
for (Int_t i=0; i<12; i++){ |
947 |
|
b[i] = trk->beta[i]; |
948 |
|
} |
949 |
|
|
950 |
|
|
951 |
|
//======================================================================== |
952 |
|
//--- Find out ToF layers with artificial TDC values & fill vector --- |
953 |
|
//======================================================================== |
954 |
|
|
955 |
|
Float_t w_il[6]; |
956 |
|
|
957 |
|
for (Int_t jj=0; jj<6;jj++) { |
958 |
|
w_il[jj] = 1000.; |
959 |
|
} |
960 |
|
|
961 |
|
|
962 |
|
for (Int_t i=0; i<trk->npmttdc; i++){ |
963 |
|
// |
964 |
|
pmt_id = (trk->pmttdc).At(i); |
965 |
|
pmt_plane = GetPlaneIndex(pmt_id); |
966 |
|
tdcfl = (trk->tdcflag).At(i); |
967 |
|
if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag |
968 |
|
}; |
969 |
|
|
970 |
|
//======================================================================== |
971 |
|
//--- Set weights for the 12 measurements using information for top and bottom: |
972 |
|
//--- if no measurements: weight = set to very high value=> not used |
973 |
|
//--- top or bottom artificial: weight*sqrt(2) |
974 |
|
//--- top and bottom artificial: weight*sqrt(2)*sqrt(2) |
975 |
|
//======================================================================== |
976 |
|
|
977 |
|
Int_t itop[12] = {0,0,1,1,2,2,3,3,0,0,1,1}; |
978 |
|
Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2,3}; |
979 |
|
|
980 |
|
xhelp= 1E09; |
981 |
|
|
982 |
|
for (Int_t jj=0; jj<12;jj++) { |
983 |
|
if (jj<4) xhelp = 0.11; // S1-S3 |
984 |
|
if ((jj>3)&&(jj<8)) xhelp = 0.18; // S2-S3 |
985 |
|
if (jj>7) xhelp = 0.28; // S1-S2 |
986 |
|
if ((w_il[itop[jj]] == 1000.) && (w_il[ibot[jj]] == 1000.)) xhelp = 1E09; |
987 |
|
if ((w_il[itop[jj]] == 1) || (w_il[ibot[jj]] == 1.)) xhelp = xhelp*1.414 ; |
988 |
|
if ((w_il[itop[jj]] == 1) && (w_il[ibot[jj]] == 1.)) xhelp = xhelp*2. ; |
989 |
|
|
990 |
|
w_i[jj] = 1./xhelp; |
991 |
|
} |
992 |
|
|
993 |
|
|
994 |
|
//======================================================================== |
995 |
|
//--- Calculate mean beta for the first time ----------------------------- |
996 |
|
//--- We are using "1/beta" since its error is gaussian ------------------ |
997 |
|
//======================================================================== |
998 |
|
|
999 |
|
Int_t icount=0; |
1000 |
|
sw=0.; |
1001 |
|
sxw=0.; |
1002 |
|
beta_mean=100.; |
1003 |
|
|
1004 |
|
for (Int_t jj=0; jj<12;jj++){ |
1005 |
|
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)) |
1006 |
|
{ |
1007 |
|
icount= icount+1; |
1008 |
|
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
1009 |
|
sw =sw + w_i[jj]*w_i[jj] ; |
1010 |
|
|
1011 |
|
} |
1012 |
|
} |
1013 |
|
|
1014 |
|
if (icount>0) beta_mean=1./(sxw/sw); |
1015 |
|
beta_mean_inv = 1./beta_mean; |
1016 |
|
|
1017 |
|
//======================================================================== |
1018 |
|
//--- Calculate beta for the second time, use residuals of the single |
1019 |
|
//--- measurements to get a chi2 value |
1020 |
|
//======================================================================== |
1021 |
|
|
1022 |
|
icount=0; |
1023 |
|
sw=0.; |
1024 |
|
sxw=0.; |
1025 |
|
betachi = 100.; |
1026 |
|
chi2 = 0.; |
1027 |
|
quality=0.; |
1028 |
|
|
1029 |
|
|
1030 |
|
for (Int_t jj=0; jj<12;jj++){ |
1031 |
|
if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)&&(w_i[jj]>0.01)) { |
1032 |
|
res = beta_mean_inv - (1./b[jj]) ; |
1033 |
|
if (fabs(res*w_i[jj])<resmax) {; |
1034 |
|
chi2 = chi2 + pow((res*w_i[jj]),2) ; |
1035 |
|
icount= icount+1; |
1036 |
|
sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ; |
1037 |
|
sw =sw + w_i[jj]*w_i[jj] ; |
1038 |
|
} |
1039 |
|
} |
1040 |
|
} |
1041 |
|
quality = sqrt(sw) ; |
1042 |
|
|
1043 |
|
if (icount==0) chi2 = 1000.; |
1044 |
|
if (icount>0) chi2 = chi2/(icount) ; |
1045 |
|
if (icount>0) betachi=1./(sxw/sw); |
1046 |
|
|
1047 |
|
bxx = 100.; |
1048 |
|
if ((chi2 < chi2cut)&&(quality>qualitycut)) bxx = betachi; |
1049 |
|
// |
1050 |
|
return(bxx); |
1051 |
|
}; |
1052 |
|
|
1053 |
|
|
1054 |
|
//////////////////////////////////////////////////// |
1055 |
//////////////////////////////////////////////////// |
//////////////////////////////////////////////////// |
1056 |
|
|
1057 |
|
|
1102 |
} |
} |
1103 |
} //ELENA |
} //ELENA |
1104 |
} |
} |
1105 |
|
|
1106 |
|
|
1107 |
|
// |
1108 |
|
// Reprocessing tool // Emiliano 08/04/07 |
1109 |
|
// |
1110 |
|
Int_t ToFLevel2::Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force){ |
1111 |
|
// |
1112 |
|
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
1113 |
|
// |
1114 |
|
|
1115 |
|
|
1116 |
|
|
1117 |
|
|
1118 |
|
// |
1119 |
|
// structures to communicate with F77 |
1120 |
|
// |
1121 |
|
extern struct ToFInput tofinput_; |
1122 |
|
extern struct ToFOutput tofoutput_; |
1123 |
|
// |
1124 |
|
// DB connection |
1125 |
|
// |
1126 |
|
TString host; |
1127 |
|
TString user; |
1128 |
|
TString psw; |
1129 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
1130 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
1131 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
1132 |
|
if ( !pamdbhost ) pamdbhost = ""; |
1133 |
|
if ( !pamdbuser ) pamdbuser = ""; |
1134 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
1135 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
1136 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
1137 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
1138 |
|
// |
1139 |
|
// |
1140 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
1141 |
|
if ( !dbc->IsConnected() ) return 1; |
1142 |
|
stringstream myquery; |
1143 |
|
myquery.str(""); |
1144 |
|
myquery << "SET time_zone='+0:00'"; |
1145 |
|
dbc->Query(myquery.str().c_str()); |
1146 |
|
GL_PARAM *glparam = new GL_PARAM(); |
1147 |
|
glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
1148 |
|
trk->LoadField(glparam->PATH+glparam->NAME); |
1149 |
|
// |
1150 |
|
Bool_t defcal = true; |
1151 |
|
Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
1152 |
|
if ( error<0 ) { |
1153 |
|
return(1); |
1154 |
|
}; |
1155 |
|
printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
1156 |
|
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
1157 |
|
// |
1158 |
|
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
1159 |
|
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
1160 |
|
// |
1161 |
|
Int_t adc[4][12]; |
1162 |
|
Int_t tdc[4][12]; |
1163 |
|
Float_t tdcc[4][12]; |
1164 |
|
// |
1165 |
|
// process tof data |
1166 |
|
// |
1167 |
|
for (Int_t hh=0; hh<12;hh++){ |
1168 |
|
for (Int_t kk=0; kk<4;kk++){ |
1169 |
|
adc[kk][hh] = 4095; |
1170 |
|
tdc[kk][hh] = 4095; |
1171 |
|
tdcc[kk][hh] = 4095.; |
1172 |
|
tofinput_.adc[hh][kk] = 4095; |
1173 |
|
tofinput_.tdc[hh][kk] = 4095; |
1174 |
|
}; |
1175 |
|
}; |
1176 |
|
Int_t ntrkentry = 0; |
1177 |
|
Int_t npmtentry = 0; |
1178 |
|
Int_t gg = 0; |
1179 |
|
Int_t hh = 0; |
1180 |
|
Int_t adcf[48]; |
1181 |
|
memset(adcf, 0, 48*sizeof(Int_t)); |
1182 |
|
Int_t tdcf[48]; |
1183 |
|
memset(tdcf, 0, 48*sizeof(Int_t)); |
1184 |
|
for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
1185 |
|
ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
1186 |
|
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
1187 |
|
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
1188 |
|
}; |
1189 |
|
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
1190 |
|
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
1191 |
|
}; |
1192 |
|
}; |
1193 |
|
// |
1194 |
|
for (Int_t pm=0; pm < this->npmt() ; pm++){ |
1195 |
|
ToFPMT *pmt = this->GetToFPMT(pm); |
1196 |
|
this->GetPMTIndex(pmt->pmt_id, gg, hh); |
1197 |
|
if ( adcf[pmt->pmt_id] == 0 ){ |
1198 |
|
tofinput_.adc[gg][hh] = (int)pmt->adc; |
1199 |
|
adc[hh][gg] = (int)pmt->adc; |
1200 |
|
}; |
1201 |
|
if ( tdcf[pmt->pmt_id] == 0 ){ |
1202 |
|
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
1203 |
|
tdc[hh][gg] = (int)pmt->tdc; |
1204 |
|
}; |
1205 |
|
tdcc[hh][gg] = (float)pmt->tdc_tw; |
1206 |
|
// Int_t pppid = this->GetPMTid(hh,gg); |
1207 |
|
// printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc); |
1208 |
|
}; |
1209 |
|
// |
1210 |
|
Int_t unpackError = this->unpackError; |
1211 |
|
// |
1212 |
|
for (Int_t hh=0; hh<5;hh++){ |
1213 |
|
tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
1214 |
|
}; |
1215 |
|
// |
1216 |
|
this->Clear(); |
1217 |
|
// |
1218 |
|
Int_t pmt_id = 0; |
1219 |
|
ToFPMT *t_pmt = new ToFPMT(); |
1220 |
|
if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
1221 |
|
TClonesArray &tpmt = *this->PMT; |
1222 |
|
ToFTrkVar *t_tof = new ToFTrkVar(); |
1223 |
|
if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
1224 |
|
TClonesArray &t = *this->ToFTrk; |
1225 |
|
// |
1226 |
|
// |
1227 |
|
// Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
1228 |
|
// |
1229 |
|
npmtentry = 0; |
1230 |
|
// |
1231 |
|
ntrkentry = 0; |
1232 |
|
// |
1233 |
|
// Calculate tracks informations from ToF alone |
1234 |
|
// |
1235 |
|
tofl2com(); |
1236 |
|
// |
1237 |
|
memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
1238 |
|
// |
1239 |
|
t_tof->trkseqno = -1; |
1240 |
|
// |
1241 |
|
// and now we must copy from the output structure to the level2 class: |
1242 |
|
// |
1243 |
|
t_tof->npmttdc = 0; |
1244 |
|
// |
1245 |
|
for (Int_t hh=0; hh<12;hh++){ |
1246 |
|
for (Int_t kk=0; kk<4;kk++){ |
1247 |
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1248 |
|
pmt_id = this->GetPMTid(kk,hh); |
1249 |
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1250 |
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1251 |
|
t_tof->npmttdc++; |
1252 |
|
}; |
1253 |
|
}; |
1254 |
|
}; |
1255 |
|
for (Int_t kk=0; kk<13;kk++){ |
1256 |
|
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
1257 |
|
} |
1258 |
|
// |
1259 |
|
t_tof->npmtadc = 0; |
1260 |
|
for (Int_t hh=0; hh<12;hh++){ |
1261 |
|
for (Int_t kk=0; kk<4;kk++){ |
1262 |
|
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
1263 |
|
t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
1264 |
|
pmt_id = this->GetPMTid(kk,hh); |
1265 |
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1266 |
|
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1267 |
|
t_tof->npmtadc++; |
1268 |
|
}; |
1269 |
|
}; |
1270 |
|
}; |
1271 |
|
// |
1272 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1273 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1274 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1275 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1276 |
|
// |
1277 |
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1278 |
|
ntrkentry++; |
1279 |
|
t_tof->Clear(); |
1280 |
|
// |
1281 |
|
// |
1282 |
|
// |
1283 |
|
t_pmt->Clear(); |
1284 |
|
// |
1285 |
|
for (Int_t hh=0; hh<12;hh++){ |
1286 |
|
for (Int_t kk=0; kk<4;kk++){ |
1287 |
|
// new WM |
1288 |
|
if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1289 |
|
// if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1290 |
|
// |
1291 |
|
t_pmt->pmt_id = this->GetPMTid(kk,hh); |
1292 |
|
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
1293 |
|
t_pmt->adc = (Float_t)adc[kk][hh]; |
1294 |
|
t_pmt->tdc = (Float_t)tdc[kk][hh]; |
1295 |
|
// |
1296 |
|
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
1297 |
|
npmtentry++; |
1298 |
|
t_pmt->Clear(); |
1299 |
|
}; |
1300 |
|
}; |
1301 |
|
}; |
1302 |
|
// |
1303 |
|
// Calculate track-related variables |
1304 |
|
// |
1305 |
|
if ( trk->ntrk() > 0 ){ |
1306 |
|
// |
1307 |
|
// We have at least one track |
1308 |
|
// |
1309 |
|
// |
1310 |
|
// Run over tracks |
1311 |
|
// |
1312 |
|
for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
1313 |
|
// |
1314 |
|
TrkTrack *ptt = trk->GetStoredTrack(nt); |
1315 |
|
// |
1316 |
|
// Copy the alpha vector in the input structure |
1317 |
|
// |
1318 |
|
for (Int_t e = 0; e < 5 ; e++){ |
1319 |
|
tofinput_.al_pp[e] = ptt->al[e]; |
1320 |
|
}; |
1321 |
|
// |
1322 |
|
// Get tracker related variables for this track |
1323 |
|
// |
1324 |
|
toftrk(); |
1325 |
|
// |
1326 |
|
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
1327 |
|
// |
1328 |
|
t_tof->npmttdc = 0; |
1329 |
|
for (Int_t hh=0; hh<12;hh++){ |
1330 |
|
for (Int_t kk=0; kk<4;kk++){ |
1331 |
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1332 |
|
pmt_id = this->GetPMTid(kk,hh); |
1333 |
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1334 |
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1335 |
|
t_tof->npmttdc++; |
1336 |
|
}; |
1337 |
|
}; |
1338 |
|
}; |
1339 |
|
for (Int_t kk=0; kk<13;kk++){ |
1340 |
|
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
1341 |
|
}; |
1342 |
|
// |
1343 |
|
t_tof->npmtadc = 0; |
1344 |
|
for (Int_t hh=0; hh<12;hh++){ |
1345 |
|
for (Int_t kk=0; kk<4;kk++){ |
1346 |
|
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
1347 |
|
t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
1348 |
|
pmt_id = this->GetPMTid(kk,hh); |
1349 |
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1350 |
|
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1351 |
|
t_tof->npmtadc++; |
1352 |
|
}; |
1353 |
|
}; |
1354 |
|
}; |
1355 |
|
// |
1356 |
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1357 |
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1358 |
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1359 |
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1360 |
|
// |
1361 |
|
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
1362 |
|
// |
1363 |
|
t_tof->trkseqno = nt; |
1364 |
|
// |
1365 |
|
// create a new object for this event with track-related variables |
1366 |
|
// |
1367 |
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1368 |
|
ntrkentry++; |
1369 |
|
t_tof->Clear(); |
1370 |
|
// |
1371 |
|
}; // loop on all the tracks |
1372 |
|
// |
1373 |
|
this->unpackError = unpackError; |
1374 |
|
if ( defcal ){ |
1375 |
|
this->default_calib = 1; |
1376 |
|
} else { |
1377 |
|
this->default_calib = 0; |
1378 |
|
}; |
1379 |
|
}; |
1380 |
|
|
1381 |
|
|
1382 |
|
|
1383 |
|
return(0); |
1384 |
|
} |