/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Annotation of /PamelaLevel2/src/PamLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Fri Jun 16 16:43:55 2006 UTC (18 years, 6 months ago) by pam-fi
Branch: MAIN
Branch point for: PamelaLevel2
Initial revision

1 pam-fi 1.1 #include <PamLevel2.h>
2     //--------------------------------------
3     //
4     //
5     //--------------------------------------
6     /**
7     * Default constructor
8     */
9     PamTrack::PamTrack(){
10     trk_track = this->TrkTrack::GetTrkTrack();
11     calo_track = this->CaloTrkVar::GetCaloTrkVar();
12     tof_track = this->ToFTrkVar::GetToFTrkVar();
13     };
14     //--------------------------------------
15     //
16     //
17     //--------------------------------------
18     /**
19     * Constructor
20     */
21     PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){
22     trk_track = this->TrkTrack::GetTrkTrack();
23     calo_track = this->CaloTrkVar::GetCaloTrkVar();
24     tof_track = this->ToFTrkVar::GetToFTrkVar();
25     if(t) *trk_track = *t;
26     if(c) *calo_track = *c;
27     if(o) *tof_track = *o;
28     };
29    
30     //--------------------------------------
31     //
32     //
33     //--------------------------------------
34     /**
35     * Constructor
36     */
37     PamLevel2::PamLevel2(){
38     trk_obj = this->TrkLevel2::GetTrkLevel2();
39     calo_obj = this->CaloLevel2::GetCaloLevel2();
40     tof_obj = this->ToFLevel2::GetToFLevel2();
41     trig_obj = this->TrigLevel2::GetTrigLevel2();
42     s4_obj = this->S4Level2::GetS4Level2();
43     nd_obj = this->NDLevel2::GetNDLevel2();
44     ac_obj = this->AcLevel2::GetAcLevel2();
45     };
46     //--------------------------------------
47     //
48     //
49     //--------------------------------------
50     /**
51     * Retrieves the it-th stored track.
52     * It override TrkLevel2::GetTrack(int it).
53     * @param itrk Track number, ranging from 0 to GetNTracks().
54     */
55    
56     PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){
57    
58     // retrieve itrk-th tracker stored track
59     TrkTrack *t = 0;
60     CaloTrkVar *c = 0;
61     ToFTrkVar *o = 0;
62    
63     if( itrk >=0 && itrk < TrkLevel2::ntrk() ){
64     t = TrkLevel2::GetStoredTrack(itrk);
65     c = CaloLevel2::GetCaloTrkVar(t->GetSeqNo());
66     o = ToFLevel2::GetToFTrkVar(t->GetSeqNo());
67     };
68     // retrieve related ToF-track
69    
70     // hence create a "PamTrack" object
71     PamTrack *track = 0;
72     if(t && c && o)track = new PamTrack(t,c,o);
73     return track;
74    
75     }
76     //--------------------------------------
77     //
78     //
79     //--------------------------------------
80     /**
81     * Sort physical (tracker) tracks and stores them in a TObjectArray (of TrkTrack objects).
82     * The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it).
83     * This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2.
84     * PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information.
85     */
86     TClonesArray *PamLevel2::GetTracks(){
87    
88     // define new array for sorted tracker tracks
89     TClonesArray *aa = new TClonesArray("TrkTrack");
90     TClonesArray &sorted = *aa;
91    
92     // loop over the tracks sorted by the tracker
93     for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){
94    
95     TrkTrack *ts=0;
96    
97     // get tracker tracks
98     TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker
99     CaloTrkVar *cp = CaloLevel2::GetCaloTrkVar(tp->GetSeqNo()); //calorimeter
100     ToFTrkVar *op = ToFLevel2::GetToFTrkVar(tp->GetSeqNo()); //tof
101    
102     // if track has an image, check image selection
103     if(tp->HasImage()){
104     TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image)
105     CaloTrkVar *ci = CaloLevel2::GetCaloTrkVar(ti->GetSeqNo());//calorimeter (image)
106     ToFTrkVar *oi = ToFLevel2::GetToFTrkVar(ti->GetSeqNo()); //tof (image)
107    
108     //assign starting scores
109     Int_t tp_score = 1;
110     Int_t ti_score = 0;
111     // ------------------------
112     // calorimeter check
113     // ------------------------
114     if(
115     npcfit[1] > 3 && //no. of fit planes on Y view
116     // varcfit[1] < 50.&& //fit variance on Y view
117     true){
118    
119     Float_t resy_p = cp->tbar[0][1] - cbar[0][1];if(resy_p < 0)resy_p= - resy_p;
120     Float_t resy_i = ci->tbar[0][1] - cbar[0][1];if(resy_i < 0)resy_i= - resy_i;
121    
122     if(resy_p <= resy_i) tp_score++;
123     else ti_score++;
124     };
125     // ------------------------
126     // TOF check
127     // ------------------------
128    
129     // ------------------------
130     // the winner is....
131     // ------------------------
132     if(tp_score > ti_score) ts = tp;//the track sorted by the tracker!!
133     else ts = ti;//its image!!
134    
135     }else{
136     ts = tp;
137     };
138    
139     new(sorted[i]) TrkTrack(*ts); //save the track in the sorted array
140     };
141    
142     return aa;
143     };
144     //--------------------------------------
145     //
146     //
147     //--------------------------------------
148     /**
149     * Retrieves the it-th Pamela "physical" track.
150     * It override TrkLevel2::GetTrack(int it).
151     * @param it Track number, ranging from 0 to GetNTracks().
152     */
153     PamTrack *PamLevel2::GetTrack(int it){
154    
155     TClonesArray *aa = this->GetTracks();
156     TClonesArray &sorted = *aa;
157    
158     TrkTrack *t = 0;
159     CaloTrkVar *c = 0;
160     ToFTrkVar *o = 0;
161    
162     if( it >=0 && it < TrkLevel2::GetNTracks() ){
163     t = (TrkTrack*)sorted[it];
164     c = CaloLevel2::GetCaloTrkVar(t->GetSeqNo());
165     o = ToFLevel2::GetToFTrkVar(t->GetSeqNo());
166     };
167    
168     // hence create a "PamTrack" object
169     PamTrack *track = 0;
170     if(t && c && o)track = new PamTrack(t,c,o);
171     return track;
172    
173     };
174     //--------------------------------------
175     //
176     //
177     //--------------------------------------
178     /**
179     * Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::GetTracks().
180     * @param it Track number, ranging from 0 to GetNTracks().
181     */
182     PamTrack *PamLevel2::GetTrackImage(int it){
183    
184     TClonesArray *aa = this->GetTracks();
185     TClonesArray &sorted = *aa;
186    
187     TrkTrack *t = 0;
188     CaloTrkVar *c = 0;
189     ToFTrkVar *o = 0;
190    
191     if( it >=0 && it < TrkLevel2::GetNTracks() ){
192     TrkTrack *temp = (TrkTrack*)sorted[it];
193     if( temp->HasImage() ){
194     t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());
195     c = CaloLevel2::GetCaloTrkVar(temp->GetImageSeqNo());
196     o = ToFLevel2::GetToFTrkVar(temp->GetImageSeqNo());
197     };
198     };
199    
200     // hence create a "PamTrack" object
201     PamTrack *image = 0;
202     if(t && c && o)image = new PamTrack(t,c,o);
203     return image;
204    
205     }
206    
207     //--------------------------------------
208     //
209     //
210     //--------------------------------------
211     /**
212     * Get the Pamela detector trees and make them friends.
213     */
214     TTree *PamLevel2::LoadPamTrees(TFile *f){
215    
216     TTree *Tout =0;
217    
218     // Tracker
219     TTree *T = (TTree*)f->Get("Tracker");
220     if(T) {
221     T->SetBranchAddress("TrkLevel2", GetPointerToTrk());
222     cout << "Tracker : set branch address TrkLevel2"<<endl;
223     if(!Tout)Tout=T;
224     }else{
225     cout << "Tracker : missing tree"<<endl;
226     };
227     // Calorimeter
228     TTree *C = (TTree*)f->Get("Calorimeter");
229     if(C) {
230     C->SetBranchAddress("CaloLevel2", GetPointerToCalo());
231     cout << "Calorimeter : set branch address CaloLevel2"<<endl;
232     if(!Tout)Tout=C;
233     else Tout->AddFriend(C);
234     }else{
235     cout << "Calorimeter : missing tree"<<endl;
236     };
237     // ToF
238     TTree *O = (TTree*)f->Get("ToF");
239     if(O) {
240     O->SetBranchAddress("ToFLevel2", GetPointerToToF());
241     cout << "ToF : set branch address ToFLevel2"<<endl;
242     if(!Tout)Tout=O;
243     else Tout->AddFriend(O);
244     }else{
245     cout << "ToF : missing tree"<<endl;
246     };
247     // Trigger
248     TTree *R = (TTree*)f->Get("Trigger");
249     if(R) {
250     R->SetBranchAddress("TrigLevel2", GetPointerToTrig());
251     cout << "Trigger : set branch address TrigLevel2"<<endl;
252     if(!Tout)Tout=O;
253     else Tout->AddFriend(R);
254     }else{
255     cout << "Trigger : missing tree"<<endl;
256     };
257     // S4
258     TTree *S = (TTree*)f->Get("S4");
259     if(S) {
260     S->SetBranchAddress("S4Level2", GetPointerToS4());
261     cout << "S4 : set branch address S4Level2"<<endl;
262     if(!Tout)Tout=O;
263     else Tout->AddFriend(S);
264     }else{
265     cout << "S4 : missing tree"<<endl;
266     };
267     // Neutron Detector
268     TTree *N = (TTree*)f->Get("NeutronD");
269     if(N) {
270     N->SetBranchAddress("NDLevel2", GetPointerToND());
271     cout << "NeutronD : set branch address NDLevel2"<<endl;
272     if(!Tout)Tout=O;
273     else Tout->AddFriend(N);
274     }else{
275     cout << "NeutronD : missing tree"<<endl;
276     };
277     // Anticounters
278     TTree *A = (TTree*)f->Get("Anticounter");
279     if(A) {
280     A->SetBranchAddress("AcLevel2", GetPointerToAc());
281     cout << "Anticounter : set branch address AcLevel2"<<endl;
282     if(!Tout)Tout=O;
283     else Tout->AddFriend(A);
284     }else{
285     cout << "Anticounter : missing tree"<<endl;
286     };
287    
288     return Tout;
289    
290     }

  ViewVC Help
Powered by ViewVC 1.1.23