/[PAMELA software]/calo/flight/CaloDoubleShower/src/CaloDoubleShower.cpp
ViewVC logotype

Annotation of /calo/flight/CaloDoubleShower/src/CaloDoubleShower.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Fri Aug 10 12:23:35 2007 UTC (17 years, 4 months ago) by mocchiut
Branch: CaloDoubleShower
CVS Tags: start, v1r00
Changes since 1.1: +0 -0 lines
Imported sources

1 mocchiut 1.1 /**
2     * \file CaloDoubleShower.cpp
3     * \author Emiliano Mocchiutti (2007/08/10)
4     */
5     //
6     // headers
7     //
8     #include <CaloDoubleShower.h>
9     //--------------------------------------
10     /**
11     * Default constructor
12     */
13     CaloDoubleShower::CaloDoubleShower(){
14     Clear();
15     };
16    
17     CaloDoubleShower::CaloDoubleShower(PamLevel2 *l2p){
18     //
19     L2 = l2p;
20     //
21     if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n");
22     //
23     OBT = 0;
24     PKT = 0;
25     atime = 0;
26     //
27     // Default variables
28     //
29     extern struct Calo2sh sdouble_;
30     c2s = &sdouble_;
31     event = new CaloLevel0();
32     cstrip = new CaloStrip(false);
33     debug = false;
34     simulation = false;
35     //
36     Clear();
37     //
38     };
39    
40     void CaloDoubleShower::LoadMagneticField(){
41     //
42     // loading magnetic field...
43     //
44     TrkLevel2 *trk = new TrkLevel2();
45     GL_PARAM *q4 = new GL_PARAM();
46     TSQLServer *dbc = 0;
47     TString host = "mysql://localhost/pamelaprod";
48     TString user = "anonymous";
49     TString psw = "";
50     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
51     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
52     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
53     if ( !pamdbhost ) pamdbhost = "";
54     if ( !pamdbuser ) pamdbuser = "";
55     if ( !pamdbpsw ) pamdbpsw = "";
56     if ( strcmp(pamdbhost,"") ) host = pamdbhost;
57     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
58     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
59     dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
60     q4->Query_GL_PARAM(1,1,dbc);
61     printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data());
62     trk->LoadField(q4->PATH+q4->NAME);
63     //
64     };
65    
66     void CaloDoubleShower::Clear(){
67     //
68     dbls = 0;
69     qdbls = 0.;
70     //
71     };
72    
73     void CaloDoubleShower::Print(){
74     Print(0);
75     };
76    
77     void CaloDoubleShower::Print(UInt_t nt){
78     //
79     Process(nt);
80     //
81     printf("========================================================================\n");
82     printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime);
83     printf(" debug [debug flag]:.. %i\n",debug);
84     printf(" simulation [simulation flag]:.. %i\n",simulation);
85     printf(" dbls [double shower flag]:.. %i\n",dbls);
86     printf(" qdbls [double shower energy]:.. %f\n",qdbls);
87     printf("========================================================================\n");
88     //
89     };
90    
91     void CaloDoubleShower::Delete(){
92     Clear();
93     };
94    
95    
96     void CaloDoubleShower::Process(){
97     Process(0);
98     };
99    
100     void CaloDoubleShower::Process(UInt_t ntr){
101     //
102     if ( !L2 ){
103     printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n");
104     printf(" ERROR: CaloDoubleShower variables _NOT_ filled \n");
105     return;
106     };
107     //
108     Bool_t newentry = false;
109     //
110     if ( L2->IsORB() ){
111     if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr){
112     newentry = true;
113     OBT = L2->GetOrbitalInfo()->OBT;
114     PKT = L2->GetOrbitalInfo()->pkt_num;
115     atime = L2->GetOrbitalInfo()->absTime;
116     sntr = ntr;
117     };
118     } else {
119     newentry = true;
120     };
121     //
122     if ( !newentry ) return;
123     //
124     // check track
125     //
126     PamTrack *ptrack = 0;
127     if ( ntr >= 0 ){
128     ptrack = L2->GetTrack(ntr);
129     };
130     //
131     if ( !ptrack ){
132     printf(" ERROR: cannot find requested track!\n");
133     printf(" ERROR: CaloDoubleShower variables _NOT_ filled \n");
134     return;
135     };
136     //
137     tr = ntr;
138     //
139     if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime);
140     //
141     this->Clear();
142     //
143     // Some variables
144     //
145    
146     //
147     if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n");
148     //
149     // Fill the estrip matrix
150     //
151     memset(event->clevel1->estrip, 0, 2*22*96*sizeof(Float_t));
152     Int_t view = 0;
153     Int_t plane = 0;
154     Int_t strip = 0;
155     Float_t mip = 0.;
156     for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){
157     //
158     mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
159     event->clevel1->estrip[strip][plane][view] = mip;
160     //
161     };
162     //
163     // if data comes from the simulation we must use mechanical alignment parameters (default is flight parameters)
164     //
165     if ( simulation ){
166     cstrip->UseMechanicalAlig();
167     };
168     //
169     // Set alignment parameter
170     //
171     event->clevel1->xalig = cstrip->GetXalig();
172     event->clevel1->yalig = cstrip->GetYalig();
173     event->clevel1->zalig = cstrip->GetZalig();
174     //
175     event->clevel1->emin = 0.7;
176     event->clevel1->npla = 22;
177     event->clevel1->reverse = 0; // if the number of planes is even we have taken away a full module no need to do anything strange...
178     //
179     if ( debug ) printf(" xalig = %f \n",event->clevel1->xalig);
180     if ( debug ) printf(" yalig = %f \n",event->clevel1->yalig);
181     if ( debug ) printf(" zalig = %f \n",event->clevel1->zalig);
182     //
183     // let's go
184     //
185     TrkTrack *ptt = ptrack->GetTrkTrack();
186     //
187     // Copy the alpha vector in the input structure
188     //
189     for (Int_t e = 0; e < 5 ; e++){
190     event->clevel1->al_p[e][0] = ptt->al[e];
191     };
192     //
193     Float_t m = (ptrack->GetToFTrack()->xtr_tof[0] - ptrack->GetToFTrack()->xtr_tof[3])/(ZTOF11-ZTOF21);
194     Float_t q = ptrack->GetToFTrack()->xtr_tof[3] - m * ZTOF21;
195     //
196     c2s->pos = (m * event->clevel1->zalig + q)*10. + event->clevel1->xalig;
197     c2s->angol = m;
198     //
199     // call fortran routine
200     //
201     getdblsh();
202     //
203     // retrieve calculated variables;
204     //
205     dbls = (Int_t)c2s->dbls;
206     qdbls = c2s->dblsq;
207     //
208     if ( debug ) this->Print();
209     if ( debug ) printf(" exit \n");
210     //
211     };

  ViewVC Help
Powered by ViewVC 1.1.23