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

Annotation of /PamelaDigitizer/DigitizeS4.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Wed May 21 09:50:41 2008 UTC (16 years, 6 months ago) by pamelats
Branch: MAIN
CVS Tags: v3r00, v3r01, v3r02
*** empty log message ***

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

  ViewVC Help
Powered by ViewVC 1.1.23