/[PAMELA software]/PamelaDigitizer/DigitizeS4.cxx
ViewVC logotype

Contents of /PamelaDigitizer/DigitizeS4.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Wed Oct 15 14:03:18 2008 UTC (16 years, 1 month ago) by pamelats
Branch: MAIN
CVS Tags: v3r04, v3r05, v3r03, HEAD
Changes since 1.1: +0 -28 lines
Cambiamenti principali: TOF, AC; cambiamenti di struttura (tutti *h esterni si trovano in Digitizer.h)

1 #include "Digitizer.h"
2
3 using namespace std;
4
5 void Digitizer::DigitizeS4(){
6 Int_t DEBUG=0;
7 // creato: S. Borisov, INFN Roma2 e MEPHI, Sett 2007
8 TString ciao,modo="ns";
9 Int_t i,j,t,NdF,pmt,NdFT,S4,S4v=0,S4p=32;
10 Float_t E0,E1=1e-6,Ert,X,Y,Z,x,y,z,V[3],Xs[2],Ys[2],Zs[2],Yp[6],q,w,p=0.1,l,l0=500;
11 Xs[0]=-24.1;
12 Xs[1]=24.1;
13 Ys[0]=-24.1;
14 Ys[1]=24.1;
15 Zs[0]=-0.5;
16 Zs[1]=0.5;
17 Yp[0]=-20.;
18 Yp[2]=-1.;
19 Yp[4]=17.;
20 for(i=0;i<3;i++)
21 Yp[2*i+1]=Yp[2*i]+3;
22 srand(time(NULL));
23 // --- activate branches:
24 // fhBookTree->SetBranchStatus("Nthtof",1); //modified by E.Vannuccini 03/08
25 // fhBookTree->SetBranchStatus("Ipltof",1);
26 // fhBookTree->SetBranchStatus("Ipaddle",1);
27
28 // fhBookTree->SetBranchStatus("Xintof",1);
29 // fhBookTree->SetBranchStatus("Yintof",1);
30 // fhBookTree->SetBranchStatus("Xouttof",1);
31 // fhBookTree->SetBranchStatus("Youttof",1);
32
33 // fhBookTree->SetBranchStatus("Ereltof",1);
34 // fhBookTree->SetBranchStatus("Timetof",1);
35 NdFT=0;
36 Ert=0;
37 for(i=0;i<Nthtof;i++){
38 if(Ipltof[i]!=6) continue;
39 Ert+=Ereltof[i];
40 if(modo=="ns") continue;
41 NdF=Int_t(Ereltof[i]/E1);
42 NdFT=0;
43 X=Xintof[i];
44 Y=Yintof[i];
45 Z=(Float_t)(random())/(Float_t)(0x7fffffff)-0.5;
46 //cout<<"XYZ "<<X<<" "<<Y<<" "<<Z<<endl;
47 for(j=0;j<NdF;j++){
48 q=(Float_t)random()/(Float_t)0x7fffffff;
49 w=(Float_t)random()/(Float_t)0x7fffffff;
50 // cout<<"qw "<<q<<" "<<w<<endl;
51 V[0]=p*cos(6.28318*q);
52 V[1]=p*sin(6.28318*q);
53 V[2]=p*(2.*w-1.);
54 pmt=0;
55 x=X;
56 y=Y;
57 z=Z;
58 while(pmt==0 && (x>Xs[0] && x<Xs[1])&&(y>Ys[0] && y<Ys[1])&&(z>Zs[0] && z<Zs[1])){
59 l=0;
60 while(pmt==0 && (x>Xs[0] && x<Xs[1])&&(y>Ys[0] && y<Ys[1])&&(z>Zs[0] && z<Zs[1])){
61 x+=V[0];
62 y+=V[1];
63 z+=V[2];
64 l+=p;
65 //cout<<x<<" "<<y<<" "<<z<<" "<<l<<endl;
66 //cin>>ciao;
67 }
68 if((x<Xs[0]+p || x>Xs[1]-p)&&(y>Ys[0]+p && y<Ys[1]-p)&&(z>Zs[0]+p && z<Zs[1]-p)){
69 for(t=0;t<3;t++){
70 if(y>=Yp[2*t] && y<Yp[2*t+1]){
71 if(pmt==0)NdFT++;
72 pmt=1;
73 //cout<<NdFT<<endl;
74 break;
75 }
76 }
77 if(pmt==1)break;
78 V[0]=-V[0];
79 }
80 q=(Float_t)random()/(Float_t)0x7fffffff;
81 w=1-exp(-l/l0);
82 if(q<w)break;
83 q=(Float_t)random()/(Float_t)0x7fffffff;
84 w=0.5;
85 if(q<w)break;
86 if((x>Xs[0]+p && x<Xs[1]-p)&&(y<Ys[0]+p || y>Ys[1]-p)&&(z>Zs[0]+p && z<Zs[1]-p))V[1]=-V[1];
87 if((x>Xs[0]+p && x<Xs[1]-p)&&(y>Ys[0]+p && y<Ys[1]-p)&&(z<Zs[0]+p || z>Zs[1]-p))V[2]=-V[2];
88 x+=V[0];
89 y+=V[1];
90 z+=V[2];
91 l=0;
92 //cout<<x<<" "<<y<<" "<<z<<" "<<l<<endl;
93 //cin>>ciao;
94 }
95 }
96 }
97 Ert=Ert/0.002;
98 q=(Float_t)(random())/(Float_t)0x7fffffff;
99 w=0.7;
100 //E0=(Float_t)(4064./7.);
101 E0=4064./7.;
102 if(Ert<1) S4=0;
103 else S4=(Int_t)(4064.*(1.-exp(-(Ert-1.)/E0)));
104 i=S4/4;
105 if(S4%4==0)
106 S4v=S4+S4p;
107 else if(S4%4==1){
108 if(q<w) S4v=S4-1+S4p;
109 else S4v=S4+1+S4p;
110 } else if(S4%4==2) S4v=S4+S4p;
111 else if(S4%4==3){
112 if(q<w) S4v=S4+1+S4p;
113 else S4v=S4-1+S4p;
114 }
115 if (DEBUG)
116 cout<<"Ert_S4 = " << Ert << " --- S4v = " << S4v << endl;
117 fDataS4[0]=S4v;//0xf028;
118 fDataS4[1]=0xd800;
119 fDataS4[2]=0x0300;
120 //cout<<" PMT "<<NdFT<<" "<<NdF<<endl;
121 //cin>>ciao;
122 }

  ViewVC Help
Powered by ViewVC 1.1.23