]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/Pixel.C
Bug fix
[u/mrichter/AliRoot.git] / ITS / Pixel.C
CommitLineData
e628c711 1// inserted you find the pixel routine: From a macro it is called like:
2
3// Int_t spdTriggerBit = CalculateFOTrigger(itsLoader,geom,hDigits,nFO);
4
5
6// spdTriggerBit is a bit array which can be queried like:
7
8// if (spdTriggerBit & (1 << 1)) globalFO = kTRUE;
9
10//The arguments hDigits and NFO are things that you don't need. The routine
11//CalculateFOTrigger uses anouther subroutine RequireZ10cm() which
12//calculates the VERTEX coincidence requirement.
13
14//Don't hesitate to contact me in case of questions. My suggestion to you is
15//that you first only implement a simple version of the trigger (for example
16//the OR of all signals).
17
18
19//Best regards,
20
21//Jan
22
23
24
25Int_t CalculateFOTrigger( AliITSLoader *itsl, AliITSgeom* geom, TH1F* hDigits, Float_t& nFO)
26{
27
28 TObjArray *digDet = 0;
29 digDet = new TObjArray(3);
30
31 Int_t startSPD = geom->GetStartSPD();
32 Int_t lastSPD = geom->GetLastSPD();
33
34 // Cut on Signal In the Pixel Detector
35 treeD = itsl->TreeD();
36 br = treeD->GetBranch("ITSDigitsSPD");
37 br->SetAddress(&((*digDet)[0]));
38 ((TClonesArray*)(digDet->At(0)))->Clear();
39
40 Int_t ndig = 0;
41 Int_t ndigfo = 0;
42
43 Int_t singhitthreshold = 1; // single hit threshold
44 Int_t threshold = 1;
45
46 const Int_t nlay =2;
47 const Int_t nlad =240;
48 const Int_t nstave=40;
49 const Int_t ndet =4;
50 const Int_t nchip =5;
51 const Int_t ntotal = 1200;
52
53 Int_t ndigA[5];
54 Int_t FOperlayer[2];
55 Int_t FOperladder[240];
56 Int_t FOperstave[40][2];
57 Int_t FOperchip[ntotal];
58 Int_t FOperChipinStave[20][40][2];
59
60 for (Int_t m=startSPD;m<lastSPD;m++) {
61 FOperladder[m] = 0;
62 }
63
64 for (Int_t k = 0;k<2;k++){
65 FOperlayer[k] = 0;
66 for (Int_t o=0;o<40;o++) {
67 FOperstave[o][k] = 0;
68 for (Int_t ich=0;ich<20;ich++) {
69 FOperChipinStave[ich][o][k] = 0;
70 }
71 }
72 }
73
74
75 nFO=0.0;
76
77 Int_t mInStaveCounter = 0.;
78
79 Int_t checkStave = 0;
80
81
82 for (m=startSPD;m<lastSPD;m++) {
83
84 treeD->GetEvent(m);
85 digits = (TClonesArray*) (digDet->At(0)); // SPD only.
86
87
88 Int_t lay,stav,det; geom->GetModuleId(m,lay,stav,det);
89
90 ndig = digits->GetEntriesFast();
91
92 for(Int_t l = 0;l<5;l++){
93 ndigA[l] =0 ;
94 }
95
96 //
97
98 for(Int_t dig=0; dig<ndig; dig++){
99 dp = (AliITSdigitSPD*) digits->At(dig);
100 Int_t column = dp->GetCoord1();
101 // Int_t row = dp->GetCoord2();
102 Int_t chip = Int_t(column/32.);
103 ndigA[chip]++;
104 }
105
106 if (checkStave !=stav){
107 mInStaveCounter = 0;
108 } else{
109 mInStaveCounter += 1;
110 }
111
112 // m 0,.., 239
113 // stav 1,..,40
114 // mInStave 0,..,3
115 // chipInStave 0,..,19
116
117 //cout << "m " << m << " stav " << stav << " mInStave " <<
118mInStaveCounter << " " <<lay << endl;
119
120 for (Int_t ichip=0;ichip<5;ichip++){
121 Int_t seq = (m*5+ichip);
122 Int_t chipInStave = (mInStaveCounter *5) + ichip;
123
124 if (ndigA[ichip] >= 1) {
125 FOperladder[m]++;
126 FOperlayer[lay-1]++;
127 FOperstave[stav-1][lay-1]++;
128 //FOperHstave[hstav-1][lay-1]++;
129 FOperChipinStave[chipInStave][stav-1][lay-1]++;
130 nFO++;
131 }
132
133 }
134 // SIMPLE FO ---> ANY HIT TRIGGERS
135 ndigfo += ndig;
136 checkStave = stav;
137
138 }
139
140 //cout << 2 << endl;
141
142 Int_t bit1 = 0;
143 Int_t upper_cut = 120;
144
145 hDigits->Fill(ndigfo);
146
147
148 // nFO = ndigfo;
149
150
151 //cout << nFO << endl;
152
153 if ( ndigfo >= singhitthreshold) {bit1 |= (1 << 1);}
154
155 // if ( ndigfo <= upper_cut) {bit1 |= (1 << 10);}
156
157
158
159 if (FOperlayer[0] >= threshold && FOperlayer[1] >=threshold) {
160 bit1 |= (1 << 2);
161 if ( ndigfo <= upper_cut) {bit1 |= (1 << 10);}
162 }
163
164
165 // Sector coincidence
166
167 Int_t nsec = 0;
168 Int_t finstav = 0;
169
170 // staves layer 1 1-20
171 // staves layer 2: 0-39
172
173 //cout << 3 << endl;
174
175
176 for (Int_t istav=1;istav<21;istav++){
177 for (Int_t jstav = finstav; jstav<finstav+4;jstav++) {
178 if ((FOperstave[istav-1][0] >= threshold) &&
179 (FOperstave[jstav][1] >= threshold)) {
180 bit1 |= (1 << 3);
181
182
183 if (RequireZ10cm(FOperChipinStave,istav-1,jstav) == kTRUE) {
184 //cout << (RequireZ(FOperChipinStave,istav-1,probe_stav) <<
185endl;
186 bit1 |= (1 << 7);
187 }
188
189 // cout << " " << istav << " " << jstav << " " << endl;
190 }
191
192 }
193 if (TMath::Even(istav)) {
194 finstav = jstav;
195 }
196
197 }
198 //cout << 4 << endl;
199
200 // half sector coincidence
201
202 Int_t finstav = 0;
203 for (Int_t istav=1;istav<21;istav++){
204 for (Int_t jstav = finstav; jstav<finstav+2;jstav++)
205 {
206 if (FOperstave[istav-1][0] >= threshold && FOperstave[jstav][1] >=
207threshold)
208 {
209 bit1 |= (1 << 4);
210
211 if (RequireZ10cm(FOperChipinStave,istav-1,jstav) == kTRUE) {
212
213 bit1 |= (1 << 8);
214 }
215 }
216 }
217
218 finstav = jstav;
219
220 }
221
222
223
224
225 Int_t finstav = 0;
226
227 for (Int_t istav=1;istav<21;istav++){
228
229 for (Int_t jstav = finstav-1; jstav<finstav+3;jstav++) {
230
231 Int_t probe_stav = jstav;
232
233 if (jstav == -1) probe_stav = 39;
234 if (jstav == 40) probe_stav = 0;
235
236 if (FOperstave[istav-1][0] >= threshold &&
237FOperstave[probe_stav][1] >= threshold) {
238 bit1 |= (1 << 5);
239 }
240
241 }
242
243 finstav = jstav-1;
244
245 }
246
247
248
249
250 // sliding window coincidence (symmetric): 1 (layer 1), 5 (layer 2)
251
252 Int_t finstav = 0;
253
254 for (Int_t istav=1;istav<21;istav++) {
255 for (Int_t jstav = finstav-2; jstav<finstav+3;jstav++) {
256
257 // cout << 7 << endl;
258
259 probe_stav = jstav;
260 if (jstav == -2) probe_stav = 38;
261 if (jstav == -1) probe_stav = 39;
262 if (jstav == 40) probe_stav = 0;
263 if (jstav == 41) probe_stav = 1;
264
265 if ((FOperstave[istav-1][0] >= threshold) &&
266 (FOperstave[probe_stav][1] >= threshold)) {
267 bit1 |= (1 << 6);
268 if (RequireZ10cm(FOperChipinStave,istav-1,probe_stav) ==
269kTRUE) {
270 bit1 |= (1 << 9);
271 }
272
273
274
275 }
276 }
277 finstav = jstav-1;
278 }
279
280 return bit1;
281}
282
283
284
285Bool_t RequireZ10cm(Int_t FOperChipinStave[][40][2], Int_t stave1, Int_t
286stave2){
287
288// z sliding window
289
290 Bool_t zFlag = kFALSE;
291
292 Int_t threshold = 1;
293 Int_t start1 = 1;
294 Int_t start2 = 3;
295 Int_t start3 = 6;
296 Int_t start4 = 7;
297 Int_t i = 1;
298
299 for (Int_t ic=0;ic<=19;ic++) {
300
301
302 if(ic <= 5) {
303
304
305 for (Int_t jc=0;jc<=ic-1;jc++) {
306 if (FOperChipinStave[ic][stave1][0] >=threshold) {
307 if (FOperChipinStave[jc][stave2][1] >= threshold){
308 zFlag = kTRUE;
309 }
310 }
311 }
312 }
313
314 if(ic >=6 && ic <=8){
315 for (jc=(2*start1-1);jc<=(2*start1-1)+5;jc++) {
316 if (FOperChipinStave[ic][stave1][0] >=threshold) {
317 if (FOperChipinStave[jc][stave2][1] >= threshold){
318 zFlag = kTRUE;
319 }
320 }
321
322 }
323 start1++;
324 }
325
326 if(ic >=9 && ic <=11){
327
328 for (jc=(2*start2);jc<=(2*start2+5);jc++) {
329 if (FOperChipinStave[ic][stave1][0] >=threshold) {
330 if (FOperChipinStave[jc][stave2][1] >= threshold){
331 zFlag = kTRUE;
332 }
333 }
334 }
335 start2++;
336 }
337
338 if(ic >=12 && ic <=13){
339
340 for (jc=(2*start3-1);jc<=(2*start3-1)+5;jc++) {
341 if (FOperChipinStave[ic][stave1][0] >=threshold) {
342 if (FOperChipinStave[jc][stave2][1] >= threshold){
343 zFlag = kTRUE;
344 }
345 }
346 }
347 start3++;
348 }
349
350
351 if(ic >=14){
352 for (jc=(2*start4);jc<=19;jc++) {
353 if (FOperChipinStave[ic][stave1][0] >=threshold) {
354 if (FOperChipinStave[jc][stave2][1] >= threshold){
355 zFlag = kTRUE;
356 }
357 }
358 }
359 start4++;
360
361 }
362
363 }
364
365 return zFlag;
366
367}