1 |
/** |
/** |
2 |
* \file ToFLevel2.cpp |
* \file ToFLevel2.cpp |
3 |
* \author Gianfranca DeRosa, Wolfgang Menn |
* \author Gianfranca DeRosa, Wolfgang Menn |
4 |
|
* |
5 |
|
* WM dec 2008: Description of "GetdEdx" changed |
6 |
|
* WM dec 2008: "GetdEdxPaddle" modified: Now includes saturation limit |
7 |
|
* PMTs higher than the saturation limit are not used for dEdx |
8 |
*/ |
*/ |
9 |
|
|
10 |
|
#include <TObject.h> |
11 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
12 |
|
#include <iostream> |
13 |
using namespace std; |
using namespace std; |
|
|
|
14 |
ClassImp(ToFPMT); |
ClassImp(ToFPMT); |
15 |
ClassImp(ToFTrkVar); |
ClassImp(ToFTrkVar); |
16 |
ClassImp(ToFLevel2); |
ClassImp(ToFLevel2); |
220 |
return npad; |
return npad; |
221 |
}; |
}; |
222 |
|
|
223 |
|
//wm Nov 08 |
224 |
//gf Apr 07 |
//gf Apr 07 |
225 |
/** |
/** |
226 |
* Method to get the mean dEdx from a given ToF plane. This current version |
* Method to get the mean dEdx from a ToF layer - ATTENTION: |
227 |
* is just summing up all PMT signals, which will not give proper results, |
* It will sum up the dEdx of all the paddles, but since by definition |
228 |
* and needs a revision. |
* only the paddle hitted by the track gets a dEdx value and the other |
229 |
|
* paddles are set to zero, the output is just the dEdx of the hitted |
230 |
|
* paddle in each layer! |
231 |
|
* The "adcfl" option is not very useful (an artificial dEdx is per |
232 |
|
* definition= 1 mip and not a real measurement), anyway left in the code |
233 |
* @param notrack Track Number |
* @param notrack Track Number |
234 |
* @param plane Plane index (0,1,2,3,4,5) |
* @param plane Plane index (0,1,2,3,4,5) |
235 |
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
* @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
// wm Nov 08 revision - saturation values included |
393 |
/// gf Apr 07 |
/// gf Apr 07 |
|
|
|
394 |
/** |
/** |
395 |
* Method to get the dEdx from a given ToF paddle. |
* Method to get the dEdx from a given ToF paddle. |
396 |
|
* If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise |
397 |
|
* just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000 |
398 |
* @param notrack Track Number |
* @param notrack Track Number |
399 |
* @param Paddle index (0,1,...,23). |
* @param Paddle index (0,1,...,23). |
400 |
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
* @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; ) |
403 |
*/ |
*/ |
404 |
void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){ |
405 |
|
|
406 |
|
/* |
407 |
|
Float_t PMTsat[48] = { |
408 |
|
3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37, |
409 |
|
3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03, |
410 |
|
3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53, |
411 |
|
3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98, |
412 |
|
3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66, |
413 |
|
3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ; |
414 |
|
*/ |
415 |
|
|
416 |
|
// new values from Napoli dec 2008 |
417 |
|
Float_t PMTsat[48] = { |
418 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
419 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
420 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
421 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
422 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
423 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
424 |
|
|
425 |
|
for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.; // safety margin |
426 |
|
|
427 |
|
|
428 |
PadEdx = 0.; |
PadEdx = 0.; |
429 |
SatWarning = 1000; |
// SatWarning = 1000; |
430 |
|
SatWarning = 0; // 0=good, increase for each bad PMT |
431 |
|
|
432 |
Float_t dEdx[48] = {0}; |
Float_t dEdx[48] = {0}; |
433 |
Int_t pmt_id = -1; |
Int_t pmt_id = -1; |
459 |
adcraw[pmtright] = pmt->adc; |
adcraw[pmtright] = pmt->adc; |
460 |
} |
} |
461 |
} |
} |
462 |
|
|
463 |
|
|
464 |
for (Int_t i=0; i<trk->npmtadc; i++){ |
for (Int_t i=0; i<trk->npmtadc; i++){ |
465 |
|
|
472 |
} |
} |
473 |
} |
} |
474 |
|
|
475 |
if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; |
|
476 |
|
// if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1; //old version |
477 |
if(dEdx[pmtleft]!=0 && dEdx[pmtright]!=0){ |
|
478 |
PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
// Increase SatWarning Counter for each PMT>Sat |
479 |
} |
if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++; |
480 |
if(dEdx[pmtleft]==0 && dEdx[pmtright]!=0){ |
if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++; |
481 |
PadEdx = dEdx[pmtright]; |
|
482 |
} |
// if ADC > sat set dEdx=1000 |
483 |
if(dEdx[pmtleft]!=0 && dEdx[pmtright]==0){ |
if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.; |
484 |
PadEdx = dEdx[pmtleft]; |
if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ; |
485 |
} |
|
486 |
|
// if two PMT are good, take mean dEdx, otherwise only the good dEdx |
487 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5; |
488 |
|
if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright]; |
489 |
|
if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft]; |
490 |
|
|
|
return; |
|
491 |
}; |
}; |
492 |
// |
// |
493 |
|
|
544 |
|
|
545 |
}; |
}; |
546 |
|
|
547 |
|
// wm jun 08 |
|
// gf Apr 07 |
|
548 |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){ |
549 |
|
return GetPaddleIdOfTrack(xtr ,ytr ,plane, 0.4); |
550 |
|
} |
551 |
|
|
552 |
|
// gf Apr 07 |
553 |
|
Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin){ |
554 |
|
|
555 |
Double_t xt,yt,xl,xh,yl,yh; |
Double_t xt,yt,xl,xh,yl,yh; |
556 |
|
|
557 |
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
581 |
yh = 33.0/2. ; |
yh = 33.0/2. ; |
582 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
583 |
for (Int_t i1=0; i1<8;i1++){ |
for (Int_t i1=0; i1<8;i1++){ |
584 |
xl = tof11_x[i1] - (5.1-0.4)/2. ; |
xl = tof11_x[i1] - (5.1-margin)/2. ; |
585 |
xh = tof11_x[i1] + (5.1-0.4)/2. ; |
xh = tof11_x[i1] + (5.1-margin)/2. ; |
586 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
587 |
} |
} |
588 |
} |
} |
599 |
|
|
600 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
601 |
for (Int_t i1=0; i1<6;i1++){ |
for (Int_t i1=0; i1<6;i1++){ |
602 |
yl = tof12_y[i1] - (5.5-0.4)/2. ; |
yl = tof12_y[i1] - (5.5-margin)/2. ; |
603 |
yh = tof12_y[i1] + (5.5-0.4)/2. ; |
yh = tof12_y[i1] + (5.5-margin)/2. ; |
604 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
605 |
} |
} |
606 |
} |
} |
617 |
|
|
618 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
619 |
for (Int_t i1=0; i1<2;i1++){ |
for (Int_t i1=0; i1<2;i1++){ |
620 |
yl = tof21_y[i1] - (7.5-0.4)/2. ; |
yl = tof21_y[i1] - (7.5-margin)/2. ; |
621 |
yh = tof21_y[i1] + (7.5-0.4)/2. ; |
yh = tof21_y[i1] + (7.5-margin)/2. ; |
622 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
623 |
} |
} |
624 |
} |
} |
634 |
|
|
635 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
636 |
for (Int_t i1=0; i1<2;i1++){ |
for (Int_t i1=0; i1<2;i1++){ |
637 |
xl = tof22_x[i1] - (9.0-0.4)/2. ; |
xl = tof22_x[i1] - (9.0-margin)/2. ; |
638 |
xh = tof22_x[i1] + (9.0-0.4)/2. ; |
xh = tof22_x[i1] + (9.0-margin)/2. ; |
639 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
640 |
} |
} |
641 |
} |
} |
651 |
|
|
652 |
if ((yt>yl)&&(yt<yh)) { |
if ((yt>yl)&&(yt<yh)) { |
653 |
for (Int_t i1=0; i1<3;i1++){ |
for (Int_t i1=0; i1<3;i1++){ |
654 |
xl = tof31_x[i1] - (6.0-0.4)/2. ; |
xl = tof31_x[i1] - (6.0-margin)/2. ; |
655 |
xh = tof31_x[i1] + (6.0-0.4)/2. ; |
xh = tof31_x[i1] + (6.0-margin)/2. ; |
656 |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
if ((xt>xl)&&(xt<xh)) paddleidoftrack=i1; |
657 |
} |
} |
658 |
} |
} |
668 |
|
|
669 |
if ((xt>xl)&&(xt<xh)) { |
if ((xt>xl)&&(xt<xh)) { |
670 |
for (Int_t i1=0; i1<3;i1++){ |
for (Int_t i1=0; i1<3;i1++){ |
671 |
yl = tof32_y[i1] - (5.0-0.4)/2. ; |
yl = tof32_y[i1] - (5.0-margin)/2. ; |
672 |
yh = tof32_y[i1] + (5.0-0.4)/2. ; |
yh = tof32_y[i1] + (5.0-margin)/2. ; |
673 |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1; |
674 |
} |
} |
675 |
} |
} |
736 |
// gf Apr 07 |
// gf Apr 07 |
737 |
|
|
738 |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){ |
739 |
pmtleft=paddle*2; |
|
740 |
pmtright= pmtleft+1; |
if(paddle==0){ |
741 |
|
pmtleft=0; |
742 |
|
pmtright=1; |
743 |
|
} |
744 |
|
|
745 |
|
if(paddle==1){ |
746 |
|
pmtleft=2; |
747 |
|
pmtright=3; |
748 |
|
} |
749 |
|
|
750 |
|
if(paddle==2){ |
751 |
|
pmtleft=4; |
752 |
|
pmtright=5; |
753 |
|
} |
754 |
|
|
755 |
|
if(paddle==3){ |
756 |
|
pmtleft=6; |
757 |
|
pmtright=7; |
758 |
|
} |
759 |
|
|
760 |
|
if(paddle==4){ |
761 |
|
pmtleft=8; |
762 |
|
pmtright=9; |
763 |
|
} |
764 |
|
|
765 |
|
if(paddle==5){ |
766 |
|
pmtleft=10; |
767 |
|
pmtright=11; |
768 |
|
} |
769 |
|
|
770 |
|
if(paddle==6){ |
771 |
|
pmtleft=12; |
772 |
|
pmtright=13; |
773 |
|
} |
774 |
|
|
775 |
|
if(paddle==7){ |
776 |
|
pmtleft=14; |
777 |
|
pmtright=15; |
778 |
|
} |
779 |
|
|
780 |
|
if(paddle==8){ |
781 |
|
pmtleft=16; |
782 |
|
pmtright=17; |
783 |
|
} |
784 |
|
|
785 |
|
if(paddle==9){ |
786 |
|
pmtleft=18; |
787 |
|
pmtright=19; |
788 |
|
} |
789 |
|
|
790 |
|
if(paddle==10){ |
791 |
|
pmtleft=20; |
792 |
|
pmtright=21; |
793 |
|
} |
794 |
|
|
795 |
|
if(paddle==11){ |
796 |
|
pmtleft=22; |
797 |
|
pmtright=23; |
798 |
|
} |
799 |
|
|
800 |
|
if(paddle==12){ |
801 |
|
pmtleft=24; |
802 |
|
pmtright=25; |
803 |
|
} |
804 |
|
|
805 |
|
if(paddle==13){ |
806 |
|
pmtleft=26; |
807 |
|
pmtright=27; |
808 |
|
} |
809 |
|
|
810 |
|
if(paddle==14){ |
811 |
|
pmtleft=28; |
812 |
|
pmtright=29; |
813 |
|
} |
814 |
|
|
815 |
|
if(paddle==15){ |
816 |
|
pmtleft=30; |
817 |
|
pmtright=31; |
818 |
|
} |
819 |
|
|
820 |
|
if(paddle==16){ |
821 |
|
pmtleft=32; |
822 |
|
pmtright=33; |
823 |
|
} |
824 |
|
|
825 |
|
if(paddle==17){ |
826 |
|
pmtleft=34; |
827 |
|
pmtright=35; |
828 |
|
} |
829 |
|
|
830 |
|
if(paddle==18){ |
831 |
|
pmtleft=36; |
832 |
|
pmtright=37; |
833 |
|
} |
834 |
|
|
835 |
|
if(paddle==19){ |
836 |
|
pmtleft=38; |
837 |
|
pmtright=39; |
838 |
|
} |
839 |
|
|
840 |
|
if(paddle==20){ |
841 |
|
pmtleft=40; |
842 |
|
pmtright=41; |
843 |
|
} |
844 |
|
|
845 |
|
if(paddle==21){ |
846 |
|
pmtleft=42; |
847 |
|
pmtright=43; |
848 |
|
} |
849 |
|
|
850 |
|
if(paddle==22){ |
851 |
|
pmtleft=44; |
852 |
|
pmtright=45; |
853 |
|
} |
854 |
|
|
855 |
|
if(paddle==23){ |
856 |
|
pmtleft=46; |
857 |
|
pmtright=47; |
858 |
|
} |
859 |
|
|
860 |
return; |
return; |
861 |
} |
} |
862 |
|
|
970 |
*/ |
*/ |
971 |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle) |
972 |
{ |
{ |
973 |
|
|
974 |
Int_t padid=-1; |
Int_t padid=-1; |
975 |
Int_t pads[6]={8,6,2,2,3,3}; |
Int_t pads11=8; |
976 |
|
Int_t pads12=6; |
977 |
|
Int_t pads21=2; |
978 |
|
Int_t pads22=2; |
979 |
|
Int_t pads31=3; |
980 |
|
// Int_t pads32=3; |
981 |
|
|
982 |
|
|
983 |
|
if(plane == 0){ |
984 |
|
padid=paddle; |
985 |
|
} |
986 |
|
|
987 |
|
if(plane == 1){ |
988 |
|
padid=pads11+paddle; |
989 |
|
} |
990 |
|
|
991 |
|
if(plane == 2){ |
992 |
|
padid=pads11+pads12+paddle; |
993 |
|
} |
994 |
|
|
995 |
int somma=0; |
if(plane == 3){ |
996 |
int np=plane; |
padid=pads11+pads12+pads21+paddle; |
997 |
for(Int_t j=0; j<np; j++){ |
} |
998 |
somma+=pads[j]; |
|
999 |
|
if(plane == 4){ |
1000 |
|
padid=pads11+pads12+pads21+pads22+paddle; |
1001 |
} |
} |
1002 |
padid=paddle+somma; |
|
1003 |
|
if(plane == 5){ |
1004 |
|
padid=pads11+pads12+pads21+pads22+pads31+paddle; |
1005 |
|
} |
1006 |
|
|
1007 |
return padid; |
return padid; |
1008 |
|
|
1009 |
} |
} |
1010 |
|
|
1011 |
|
|
1089 |
|
|
1090 |
} |
} |
1091 |
|
|
1092 |
|
|
1093 |
|
|
1094 |
/// wm feb 08 |
/// wm feb 08 |
1095 |
|
|
1096 |
/** |
/** |
1237 |
//////////////////////////////////////////////////// |
//////////////////////////////////////////////////// |
1238 |
|
|
1239 |
|
|
|
|
|
1240 |
/** |
/** |
1241 |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
* Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common). |
1242 |
*/ |
*/ |
1283 |
} |
} |
1284 |
} //ELENA |
} //ELENA |
1285 |
} |
} |
|
|
|
|
|
|
|
// |
|
|
// Reprocessing tool // Emiliano 08/04/07 |
|
|
// |
|
|
Int_t ToFLevel2::Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force){ |
|
|
// |
|
|
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
// structures to communicate with F77 |
|
|
// |
|
|
extern struct ToFInput tofinput_; |
|
|
extern struct ToFOutput tofoutput_; |
|
|
// |
|
|
// DB connection |
|
|
// |
|
|
TString host; |
|
|
TString user; |
|
|
TString psw; |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
// |
|
|
// |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if ( !dbc->IsConnected() ) return 1; |
|
|
stringstream myquery; |
|
|
myquery.str(""); |
|
|
myquery << "SET time_zone='+0:00'"; |
|
|
dbc->Query(myquery.str().c_str()); |
|
|
GL_PARAM *glparam = new GL_PARAM(); |
|
|
glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
|
|
trk->LoadField(glparam->PATH+glparam->NAME); |
|
|
// |
|
|
Bool_t defcal = true; |
|
|
Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
|
|
if ( error<0 ) { |
|
|
return(1); |
|
|
}; |
|
|
printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
|
|
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
|
|
// |
|
|
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
|
|
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
|
|
// |
|
|
Int_t adc[4][12]; |
|
|
Int_t tdc[4][12]; |
|
|
Float_t tdcc[4][12]; |
|
|
// |
|
|
// process tof data |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
adc[kk][hh] = 4095; |
|
|
tdc[kk][hh] = 4095; |
|
|
tdcc[kk][hh] = 4095.; |
|
|
tofinput_.adc[hh][kk] = 4095; |
|
|
tofinput_.tdc[hh][kk] = 4095; |
|
|
}; |
|
|
}; |
|
|
Int_t ntrkentry = 0; |
|
|
Int_t npmtentry = 0; |
|
|
Int_t gg = 0; |
|
|
Int_t hh = 0; |
|
|
Int_t adcf[48]; |
|
|
memset(adcf, 0, 48*sizeof(Int_t)); |
|
|
Int_t tdcf[48]; |
|
|
memset(tdcf, 0, 48*sizeof(Int_t)); |
|
|
for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
|
|
ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
|
|
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
|
|
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
|
|
}; |
|
|
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
|
|
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
for (Int_t pm=0; pm < this->npmt() ; pm++){ |
|
|
ToFPMT *pmt = this->GetToFPMT(pm); |
|
|
this->GetPMTIndex(pmt->pmt_id, gg, hh); |
|
|
if ( adcf[pmt->pmt_id] == 0 ){ |
|
|
tofinput_.adc[gg][hh] = (int)pmt->adc; |
|
|
adc[hh][gg] = (int)pmt->adc; |
|
|
}; |
|
|
if ( tdcf[pmt->pmt_id] == 0 ){ |
|
|
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
|
|
tdc[hh][gg] = (int)pmt->tdc; |
|
|
}; |
|
|
tdcc[hh][gg] = (float)pmt->tdc_tw; |
|
|
// Int_t pppid = this->GetPMTid(hh,gg); |
|
|
// 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); |
|
|
}; |
|
|
// |
|
|
Int_t unpackError = this->unpackError; |
|
|
// |
|
|
for (Int_t hh=0; hh<5;hh++){ |
|
|
tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
|
|
}; |
|
|
// |
|
|
this->Clear(); |
|
|
// |
|
|
Int_t pmt_id = 0; |
|
|
ToFPMT *t_pmt = new ToFPMT(); |
|
|
if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
|
|
TClonesArray &tpmt = *this->PMT; |
|
|
ToFTrkVar *t_tof = new ToFTrkVar(); |
|
|
if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
|
|
TClonesArray &t = *this->ToFTrk; |
|
|
// |
|
|
// |
|
|
// Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
|
|
// |
|
|
npmtentry = 0; |
|
|
// |
|
|
ntrkentry = 0; |
|
|
// |
|
|
// Calculate tracks informations from ToF alone |
|
|
// |
|
|
tofl2com(); |
|
|
// |
|
|
memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
|
|
// |
|
|
t_tof->trkseqno = -1; |
|
|
// |
|
|
// and now we must copy from the output structure to the level2 class: |
|
|
// |
|
|
t_tof->npmttdc = 0; |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
|
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
|
|
t_tof->npmttdc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
for (Int_t kk=0; kk<13;kk++){ |
|
|
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
|
|
} |
|
|
// |
|
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
|
|
t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
|
// |
|
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
|
|
ntrkentry++; |
|
|
t_tof->Clear(); |
|
|
// |
|
|
// |
|
|
// |
|
|
t_pmt->Clear(); |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
// new WM |
|
|
if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
|
|
// if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
|
|
// |
|
|
t_pmt->pmt_id = this->GetPMTid(kk,hh); |
|
|
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
|
|
t_pmt->adc = (Float_t)adc[kk][hh]; |
|
|
t_pmt->tdc = (Float_t)tdc[kk][hh]; |
|
|
// |
|
|
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
|
|
npmtentry++; |
|
|
t_pmt->Clear(); |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
// Calculate track-related variables |
|
|
// |
|
|
if ( trk->ntrk() > 0 ){ |
|
|
// |
|
|
// We have at least one track |
|
|
// |
|
|
// |
|
|
// Run over tracks |
|
|
// |
|
|
for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
|
|
// |
|
|
TrkTrack *ptt = trk->GetStoredTrack(nt); |
|
|
// |
|
|
// Copy the alpha vector in the input structure |
|
|
// |
|
|
for (Int_t e = 0; e < 5 ; e++){ |
|
|
tofinput_.al_pp[e] = ptt->al[e]; |
|
|
}; |
|
|
// |
|
|
// Get tracker related variables for this track |
|
|
// |
|
|
toftrk(); |
|
|
// |
|
|
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
|
|
// |
|
|
t_tof->npmttdc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
|
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
|
|
t_tof->npmttdc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
for (Int_t kk=0; kk<13;kk++){ |
|
|
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
|
|
}; |
|
|
// |
|
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
|
|
t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
|
// |
|
|
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
|
|
// |
|
|
t_tof->trkseqno = nt; |
|
|
// |
|
|
// create a new object for this event with track-related variables |
|
|
// |
|
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
|
|
ntrkentry++; |
|
|
t_tof->Clear(); |
|
|
// |
|
|
}; // loop on all the tracks |
|
|
// |
|
|
this->unpackError = unpackError; |
|
|
if ( defcal ){ |
|
|
this->default_calib = 1; |
|
|
} else { |
|
|
this->default_calib = 0; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return(0); |
|
|
} |
|