/[PAMELA software]/tracker/flight/PamelaViewer/src/CaloViewer.cpp
ViewVC logotype

Annotation of /tracker/flight/PamelaViewer/src/CaloViewer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Jan 20 10:29:57 2009 UTC (15 years, 10 months ago) by pam-fi
Branch point for: MAIN, tracker
Initial revision

1 pam-fi 1.1 /**
2     * \file CaloViewer.cpp
3     * \author Elena Vannuccini
4     */
5     #include <CaloViewer.h>
6    
7     #define TUNGSIZE 26 // ACCERTARSI!!!!!!!
8     #define TUNGTICK 0.26
9     #define VCOL 1 // volume color
10     #define TCOL 13 // tungsten plane color
11     #define SSIZE 0.12 // strip hit half-size
12     #define STICK 0.16 // strip hit half-tickness
13    
14     // (mechanical) z-parameter of the calorimeter planes
15    
16     /**
17     * Method to retrieve x(y)-coordinate of a calorimeter strip
18     */
19     Float_t GetCoordXY(Int_t view, Int_t plane, Int_t strip){
20    
21     // Float_t pich = 0.24;
22     // Float_t edge = 0.16;
23     // // ------------------------
24     // Float_t shift = 0;
25     // if( !view ){ // view=0 -> X
26     // if( plane%2 ) shift = 0.05;
27     // else shift = -0.05;
28     // }else{ // view=1 -> Y
29     // if( plane%2 ) shift = -0.15;
30     // else shift = -0.05;
31     // }
32     // // ------------------------
33     // Float_t coord = 0;
34     // // coord = coord + strip*pich; //strip = 0-95
35     // coord = coord + strip*pich; //strip = 0-95
36     // coord = coord + (Int_t)(strip/32)*edge*2;
37     // coord = coord - 12.28;
38     // coord = coord + shift;
39     // return coord;
40    
41     CaloStrip st = CaloStrip(1);
42     // st.UseMechanicalAlig();
43    
44     st.Set(view,plane,strip);
45     if( !view ) return st.GetX();
46     else return st.GetY();
47     }
48    
49     /**
50     * Method to retrieve z-coordinate of a calorimeter strip
51     */
52     Float_t GetCoordZ(Int_t view, Int_t plane){
53    
54     // Float_t coord = 0;
55     // if( !view ){ // view=0 -> X
56     // if( plane%2 ) coord = -0.809*plane - 0.2*(plane-1)/2 - 26.762;
57     // else coord = -0.809*plane - 0.2*plane/2 - 26.762;
58     // }else{ // view=1 -> Y
59     // if( plane%2 ) coord = -0.809*plane - 0.2*(plane-1)/2 - 26.181;
60     // else coord = -0.809*plane - 0.2*plane/2 - 26.181;
61     // }
62     // return coord;
63    
64     CaloStrip st = CaloStrip(1);
65     // st.UseMechanicalAlig();
66    
67     st.Set(view,plane,0);
68     return st.GetZ();
69     }
70    
71     /**
72     * Calorimeter volume (projections) constructor
73     */
74     GCaloVolume::GCaloVolume(){
75    
76     Float_t marg = 0.5;
77     // cavity_l = new TBox(-1*TUNGSIZE/2,-26.181+0.16,TUNGSIZE/2,-45.751-0.16);
78     cavity_l = new TBox(GetCoordXY(0,21,0)-marg-SSIZE,GetCoordZ(0,21)-marg-STICK,GetCoordXY(0,21,95)+marg+SSIZE,GetCoordZ(1,0)+marg+STICK);
79     cavity_l->SetFillColor(VCOL);
80     cavity_l->SetLineColor(1);
81    
82     // cavity_r = new TBox(-1*TUNGSIZE/2-0.1,-26.181+0.16,TUNGSIZE/2-0.1,-45.751-0.16);
83     cavity_r = new TBox(GetCoordXY(1,21,0)-marg-SSIZE,GetCoordZ(0,21)-marg-STICK,GetCoordXY(1,21,95)+marg+SSIZE,GetCoordZ(1,0)+marg+STICK);
84     cavity_r->SetFillColor(VCOL);
85     cavity_r->SetLineColor(1);
86    
87     for(Int_t ip=0; ip<22; ip++){
88     Float_t zp =0;
89     if( ip%2 ) zp = -0.809*ip-0.2*(ip-1)/2-26.4715;
90     else zp = -0.809*ip-0.2*ip/2-26.4715;
91     // tplane_l[ip] = new TBox(-1*TUNGSIZE/2,zp-TUNGTICK/2,TUNGSIZE/2,zp+TUNGTICK/2 );
92     tplane_l[ip] = new TBox(GetCoordXY(0,21,0)-marg-SSIZE,zp-TUNGTICK/2,GetCoordXY(0,21,95)+marg+SSIZE,zp+TUNGTICK/2 );
93     tplane_l[ip]->SetFillColor(TCOL);
94     // tplane_r[ip] = new TBox(-1*TUNGSIZE/2-0.1,zp-TUNGTICK/2,TUNGSIZE/2-0.1,zp+TUNGTICK/2 );
95     tplane_r[ip] = new TBox(GetCoordXY(1,21,0)-marg-SSIZE,zp-TUNGTICK/2,GetCoordXY(1,21,95)+marg+SSIZE,zp+TUNGTICK/2 );
96     tplane_r[ip]->SetFillColor(TCOL);
97     }
98    
99     }
100     //
101     void GCaloVolume::DrawProjectionX(){
102     cavity_l->Draw();
103     for(Int_t ip=0; ip<22; ip++)tplane_l[ip]->Draw();
104     }
105     //
106     void GCaloVolume::DrawProjectionY(){
107     cavity_r->Draw();
108     for(Int_t ip=0; ip<22; ip++)tplane_r[ip]->Draw();
109     }
110     //
111     void GCaloVolume::Delete(){
112     cavity_l->Delete();
113     cavity_r->Delete();
114     for(Int_t ip=0; ip<22; ip++)tplane_l[ip]->Delete();
115     for(Int_t ip=0; ip<22; ip++)tplane_r[ip]->Delete();
116     };
117    
118     //===============================================================
119     //
120     //
121     //===============================================================
122    
123    
124     /**
125     * Constructor
126     */
127     GCaloLevel2::GCaloLevel2(){
128     HitX = new TClonesArray("GCaloHit");
129     HitY = new TClonesArray("GCaloHit");
130     DRAWCBAR=false;
131     }
132     GCaloLevel2::GCaloLevel2(CaloLevel1 *l1){
133     HitX = new TClonesArray("GCaloHit");
134     HitY = new TClonesArray("GCaloHit");
135     SetLevel1(l1);
136     DRAWCBAR=false;
137     }
138     GCaloLevel2::GCaloLevel2(PamLevel2* event){
139     HitX = new TClonesArray("GCaloHit");
140     HitY = new TClonesArray("GCaloHit");
141     if(event->GetCaloLevel1())SetLevel1(event->GetCaloLevel1());
142     if(event->GetCaloLevel2())SetLevel2(event->GetCaloLevel2());
143     DRAWCBAR=false;
144     }
145     /**
146     * Set level1 variables
147     */
148     void GCaloLevel2::SetLevel1(CaloLevel1* l1){
149    
150    
151     TClonesArray &hx = *HitX; Int_t nhx =0;
152     TClonesArray &hy = *HitY; Int_t nhy =0;
153    
154    
155     // cout<<"Calo event: "<<l1->istrip<<" hit strips \n";
156     for(Int_t ih=0; ih<l1->istrip; ih++){
157     Int_t view = -1;
158     Int_t plane = -1;
159     Int_t strip = -1;
160     Float_t mip = l1->DecodeEstrip(ih,view,plane,strip);
161     // if(strip==96)cout<<"strip "<<strip<<endl;
162     GCaloHit h = GCaloHit( GetCoordXY(view,plane,strip), GetCoordZ(view,plane), mip);
163     if( !view ){
164     new(hx[nhx]) GCaloHit(&h);
165     nhx++;
166     }else{
167     new(hy[nhy]) GCaloHit(&h);
168     nhy++;
169     }
170     }
171    
172     }
173     /**
174     * Set level1 variables
175     */
176     void GCaloLevel2::SetLevel2(CaloLevel2* l2){
177    
178     float cbarx[22];
179     float cbary[22];
180     float cbarxz[22];
181     float cbaryz[22];
182     for(Int_t ip=0; ip<22; ip++){
183     cbarx[ip]=l2->cbar[ip][0];
184     cbary[ip]=l2->cbar[ip][1];
185     cbarxz[ip]=GetCoordZ(0,ip);
186     cbaryz[ip]=GetCoordZ(1,ip);
187     }
188     cbarX = new TPolyMarker(22,cbarx,cbarxz);
189     cbarY = new TPolyMarker(22,cbary,cbaryz);
190     cbarX->SetMarkerSize(0.5);
191     cbarX->SetMarkerColor(0);
192     cbarY->SetMarkerSize(0.5);
193     cbarY->SetMarkerColor(0);
194    
195    
196     }
197    
198     void GCaloLevel2::Delete(){
199     HitX->Delete();
200     HitY->Delete();
201     if(cbarX)cbarX->Delete();
202     if(cbarY)cbarY->Delete();
203     }
204     void GCaloLevel2::Clear(){
205     HitX->Clear("C");
206     HitY->Clear("C");
207     if(cbarX)cbarX->Delete();
208     if(cbarY)cbarY->Delete();
209     }
210    
211     void GCaloLevel2::DrawProjectionX(){
212     TClonesArray &s = *(HitX);
213     // cout<<"Calorimeter: X hits: "<<HitX->GetEntries()<<endl;
214     for(Int_t is=0; is<HitX->GetEntries(); is++){
215     ((GCaloHit*)s[is])->Draw();
216     };
217     if(DRAWCBAR)cbarX->Draw();
218     }
219    
220     void GCaloLevel2::DrawProjectionY(){
221     TClonesArray &s = *(HitY);
222     // cout<<"Calorimeter: Y hits: "<<HitY->GetEntries()<<endl;
223     for(Int_t is=0; is<HitY->GetEntries(); is++){
224     ((GCaloHit*)s[is])->Draw();
225     };
226     if(DRAWCBAR)cbarY->Draw();
227     }
228     //===============================================================
229     //
230     //
231     //===============================================================
232     GCaloHit::GCaloHit(){
233     hit = new TBox();
234     }
235    
236     GCaloHit::GCaloHit(Float_t x, Float_t y, Float_t w){
237    
238     // cout << "box "<<x<<" "<<y<<endl;
239     // hit = new TBox(x-0.12,y-0.2745,x+0.12,y+0.2745);
240     hit = new TBox(x-SSIZE,y-STICK,x+SSIZE,y+STICK);
241     //set color according to w
242     Int_t colo = 10;
243     if ( w > 0.7 ) colo = 38;
244     if ( w > 2. ) colo = 4;
245     if ( w > 10. ) colo = 3;
246     if ( w > 100. ) colo = 2;
247     if ( w > 500. ) colo = 6;
248     hit->SetFillColor(colo);
249    
250     }
251    
252     GCaloHit::GCaloHit( GCaloHit* gc ){
253     hit = new TBox(*(gc->hit));
254     }
255    
256     ClassImp(GCaloVolume);
257     ClassImp(GCaloLevel2);
258     ClassImp(GCaloHit);

  ViewVC Help
Powered by ViewVC 1.1.23