/[PAMELA software]/eventviewer/flight/doc/ffilter.cxx
ViewVC logotype

Contents of /eventviewer/flight/doc/ffilter.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Jul 14 14:17:50 2006 UTC (19 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New _BETA_ and buggy version

1 //#############################################################################################################################################################
2 //
3 // filter.c # by Emiliano Mocchiutti (2005/11/25)
4 //
5 // Changelog:
6 //
7 // (2006/02/24) Cannot load tracker level0 and level2 data simultaneously, fixed.
8 //
9 //#############################################################################################################################################################
10 //
11 // Template for the event selection using the EventViewer. The function must be called "filter" while the filename where the function is defined can be anyone.
12 //
13 //#############################################################################################################################################################
14 //
15 // The idea of the event selection is the following:
16 // 1) you must know which kind of data the EventViewer program is using (for example tracker level0, level1 or level2 data?)
17 // 2) depending on the available data you can define your selection.
18 // 3) information about data used can be found in the structure "level" which contains the following variables:
19 // typedef struct Levels {
20 // Int_t calo; // if equal to 0 calorimeter level 0 , if equal to 1 calorimeter level 1 data.
21 // Int_t calol2; // for the moment this is always 0
22 // Int_t tof; // tof/trigger level 1 or level 0 data
23 // Int_t track; // tracker level 1 or level 0 data
24 // Int_t track2; // if set to one there are tracker level2 data
25 // Int_t s4; // S4 level 1 or level0 data
26 // Int_t ac; // AC level 1 or level0 data
27 // Int_t nd; // always 0 for the moment
28 // } level;
29 // evno is the event number to be processed.
30 // All data coming from yoda are stored in the tree called "otr", tree "ttr" contains only level2 tracker data.
31 // 4) to learn how to change things look at examples below.
32 // 5) to stop the eventviewer this function must return 1 as value, when returning 0 means go on searching.
33 // 6) is it possible to combine information from different detectors.
34 //
35
36 int filter(Int_t evno, TTree *otr, TTree *ttr, Levels & level){
37 //
38 // example n. 1
39 // select events where the energy deposit in S4 is greater than 0.7 MIP
40 //
41 Bool_t S4 = true;
42 //
43 // check the data level
44 //
45 if ( level.s4 == 0 ) {
46 S4 = false;
47 //
48 // determine in which branch we can find S4 data in the tree otr.
49 //
50 pamela::S4::S4Event *s4 = 0;
51 otr->SetBranchAddress("S4.Event", &s4);
52 otr->GetEntry(evno);
53 //
54 // if we have level0 data we must calibrate the data to make a selection in MIP.
55 //
56 Float_t s4data = ((float)s4->S4_DATA -32.) * 0.29;
57 //
58 // if the condition is satisfied S4 is true.
59 //
60 if ( s4data>0.7 ) S4 = true;
61 };
62
63 //
64 // example n. 2
65 // select events with one or more tracks
66 //
67 Bool_t TRACKER = true;
68 //
69 // check we have tracker LEVEL2 data
70 //
71 if ( level.track2 == 1 ){
72 TRACKER = false;
73 //
74 // access tracker level2 data, store variables in the structure trk.
75 //
76 struct Tracklev2 trk;
77 settrklev2(ttr,trk);
78 //
79 // get entry, here we are assuming we have syncronized data.
80 //
81 ttr->GetEntry(evno);
82 //
83 if ( trk.ntrk > 0 ){
84 //
85 TRACKER = true;
86 //
87 // example of how to calculate rigidity from deflection and select negative particles with rigidity less than 1 GV:
88 //
89 // Float_t rig = 0.;
90 //
91 // notice that in the structure trk columns and rows of matrixes are inverted respect to the fortran style al[0][4] is deflection for the first track
92 // al[1][4] would be deflection for the second track, etc.
93 //
94 // if ( trk.al[0][4] != 0. ) rig = 1./trk.al[0][4];
95 // if ( abs(rig) < 1. ) TRACKER = true;
96 };
97 };
98
99 //
100 // example n. 3
101 // select events with 6 hist in the X-view of the tracker and 6 hit in the Y-view of the tracker
102 //
103 Bool_t TRACKER2 = true;
104 //
105 if ( level.track == 0 ){
106 TRACKER2 = false;
107 Int_t fnclx = 0;
108 Int_t fncly = 0;
109 pamela::tracker::TrackerEvent *ttrk = 0;
110 otr->SetBranchAddress("Tracker.Event", &ttrk);
111 otr->GetEntry(evno);
112 for (Int_t l = 0; l<12; l++){
113 Int_t planeno = ttrk->DSPnumber[l]-1;
114 if ( planeno < 0 || planeno > 11 ) planeno = 0;
115 if ( planeno >= 0 ) {
116 if ( (planeno+1)%2 ){
117 for (Int_t m = 0; m<3; m++){
118 if ( ttrk->signcluster[l][m] != 0. ){
119 fncly++;
120 };
121 };
122 } else {
123 for (Int_t m = 0; m<3; m++){
124 if ( ttrk->signcluster[l][m] != 0. ){
125 fnclx++;
126 };
127 };
128 };
129 };
130 };
131 if ( fnclx == 6 && fncly == 6 ) TRACKER2 = true;
132 };
133
134 //
135 // example n. 4
136 // select events with qtot greater than 100 and nstrip greater than 100 in the calorimeter (interacting particles)
137 //
138 Bool_t CALO = true;
139 //
140 // check if we have calorimeter level1 data
141 //
142 if ( level.calo == 1 ){
143 CALO = false;
144 CalorimeterLevel1 *calo = new CalorimeterLevel1();
145 otr->SetBranchAddress("CaloLevel1.Event", &calo);
146 otr->GetEntry(evno);
147 if ( calo->qtot > 100 && calo->nstrip > 100) CALO = true;
148 };
149
150 //
151 // example n. 5
152 // select calorimeter selftrigger events
153 //
154 Bool_t TRIGGER = true;
155 if ( level.tof == 0 || level.tof == 1 ){
156 //
157 Bool_t TRIGGER = false;
158 //
159 // define where to find in the tree otr the Trigger.Event branch
160 //
161 pamela::trigger::TriggerEvent *trig = 0;
162 otr->SetBranchAddress("Trigger.Event", &trig);
163 //
164 // get the entry number "evno" passed by the main EventViewer program
165 //
166 otr->GetEntry(evno);
167 //
168 // check the first element of the variable patterntrig which tell us if this one is a calorimeter trigger
169 //
170 if ( trig->patterntrig[0] ) {
171 //
172 // set the boolean variable TRIGGER to true. Instead of setting this variable it is possible to return(1) here.
173 //
174 TRIGGER = true;
175 };
176 //
177 // example if one want to select S4/pulser triggers
178 //
179 //if ( trig->patterntrig[1] & (1<<0) ) TRIGGER = true;
180 };
181
182 //
183 // example n. 6
184 // select events with AC hits
185 //
186 Bool_t AC = true;
187 //
188 // in the case of level0 data
189 //
190 if ( level.ac == 0){
191 AC = false;
192 pamela::anticounter::AnticounterEvent *ace = 0;
193 otr->SetBranchAddress("Anticounter.Event", &ace);
194 otr->GetEntry(evno);
195 Int_t hitmapA = 0;
196 Int_t hitmapB = 0;
197 //
198 // hitmap variable contain the information
199 //
200 hitmapA = ace->hitmap[0];
201 hitmapB = ace->hitmap[1];
202 if ( hitmapA || hitmapB ) AC = true;
203 };
204 //
205 // in the case of level1 data
206 //
207 if ( level.ac == 1){
208 AC = false;
209 AnticounterLevel1 *ace = new AnticounterLevel1();
210 otr->SetBranchAddress("AcLevel1.Event", &ace);
211 otr->GetEntry(evno);
212 Int_t hitmapA = 0;
213 Int_t hitmapB = 0;
214 hitmapA = ace->hitmap[0];
215 hitmapB = ace->hitmap[1];
216 if ( hitmapA || hitmapB ) AC = true;
217 };
218
219 //
220 // example n. 7
221 // select events in which we have at least one AC hit outside the trigger time window (we need level1 data)
222 //
223 Bool_t AC2 = true;
224 if ( level.ac == 1){
225 AC2 = false;
226 AnticounterLevel1 *ace = new AnticounterLevel1();
227 otr->SetBranchAddress("AcLevel1.Event", &ace);
228 otr->GetEntry(evno);
229 Int_t hitstatusA = 0;
230 Int_t hitstatusB = 0;
231 Int_t hitmapA = 0;
232 Int_t hitmapB = 0;
233 hitmapA = ace->hitmap[0];
234 hitmapB = ace->hitmap[1];
235 hitstatusA = ace->hitstatus[0];
236 hitstatusB = ace->hitstatus[1];
237 Int_t deltaA = hitstatusA - hitmapA;
238 Int_t deltaB = hitstatusB - hitmapB;
239 if ( deltaA || deltaB ) AC2 = true;
240 };
241
242
243 //
244 // example n. 8
245 // select events with one or more detected neutrons:
246 //
247 Bool_t ND = true;
248 if ( level.nd == 0){
249 ND = false;
250 Int_t tmpSize;
251 Int_t nTrig = 0;
252 pamela::neutron::NeutronEvent *ne = 0;
253 pamela::neutron::NeutronRecord *nr = 0;
254 otr->SetBranchAddress("Neutron.Event", &ne);
255 otr->GetEntry(evno);
256 tmpSize = ne->Records->GetEntries();
257 for (Int_t j = 0; j < tmpSize; j++){
258 nr = (pamela::neutron::NeutronRecord*)ne->Records->At(j);
259 nTrig += (int)nr->trigPhysics;
260 };
261 if ( nTrig > 0 ) ND = true;
262 };
263
264 //
265 // Here we can use the boolean variables and decide if the event passed the selecion or not.
266 //
267 // if the event pass the selection return one, zero otherwise.
268 //
269
270 //
271 // Some examples:
272 //
273
274 // A - select only calorimeter selftrigger events
275 //
276 // if ( TRIGGER ) return(1);
277
278 // B - select calorimeter self-trigger events with at least one fitted track:
279 //
280 // if ( TRIGGER && TRACKER ) return(1);
281
282 // C - select events with at least one track (default behaviour so it is uncommented)
283 //
284 if ( TRACKER ) return(1);
285
286 // D - select interacting events in the calorimeter
287 //
288 // if ( CALO ) return(1);
289
290
291 // E - select events with hit in the anticounters
292 //
293 // if ( AC ) return(1);
294
295 // F - select events with energy release in S4 greater than 0.7 MIPs, at least one track, no hit in the anticounters and at least one neutron detected:
296 //
297 // if ( S4 && TRACKER && !AC && ND ) return(1);
298
299 //
300 // if nothing match, return 0.
301 //
302 return(0);
303 };

  ViewVC Help
Powered by ViewVC 1.1.23