1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 //////////////////////////////////////////////////////////////////////
21 // ITS SPD Trigger Detector Class
23 // Several Fast-OR Algoritm are implemented
25 // Ref: ALICE-INT-2005-025
26 // (J. Conrad, J. G. Contreras and C. E. Jorgensen)
28 //////////////////////////////////////////////////////////////////////
33 #include "AliRunLoader.h"
34 #include "AliITSLoader.h"
35 #include "AliITSgeom.h"
36 #include "AliITSdigitSPD.h"
38 #include "AliTriggerInput.h"
39 #include "AliITSTrigger.h"
41 //______________________________________________________________________
42 ClassImp(AliITSTrigger)
44 //______________________________________________________________________
45 AliITSTrigger::AliITSTrigger()
46 : AliTriggerDetector()
52 //______________________________________________________________________
53 void AliITSTrigger::CreateInputs()
57 // Do not create inputs again!!
58 if( fInputs.GetEntriesFast() > 0 ) return;
60 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_GFO_L0", "Global, Fast OR all detectors", 0x01 ) );
61 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_LAYER_L0", "Layer, hit in each layer", 0x02 ) );
62 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SECTOR_L0", "Sector, hit coincidence in one sector", 0x04 ) );
63 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HSECTOR_L0", "Half Sector, hit coincidence in one half sector", 0x08 ) );
64 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SW1_L0", "Sliding Window 1, hit coincidence on phi windows", 0x10 ) );
65 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SW2_L0", "Sliding Window 2, hit coincidence on phi windows", 0x20 ) );
66 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_VERTEX_L0", "Vertex, hit coincidence on theta windows", 0x40 ) );
67 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SVERTEX_L0", "Sector+Vertex, hit coincidence on one sector and theta windows", 0x80 ) );
68 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HSVERTEX_L0","Half Sector+Vertex, hit coincidence on one half sector and theta windows", 0x100 ) );
69 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SWVERTEX_L0","Sliding Window+Vertex, hit coincidence on phi windows and theta windows", 0x200 ) );
70 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_LUCUT_L0", "Layer+Upper Cut, hit in each layer and FO occupancy cut", 0x400 ) );
71 // Not yet implemented
72 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HMULT_L0", "High Multiplicity, to be defined!!", 0x600 ) );
76 //______________________________________________________________________
77 void AliITSTrigger::Trigger()
80 // ********** Get run loader for the current event **********
81 AliRunLoader* runLoader = gAlice->GetRunLoader();
83 AliITSLoader * loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
84 AliITSgeom* geom = loader->GetITSgeom();
85 loader->LoadDigits("READ");
86 TTree *treeD = loader->TreeD();
88 TObjArray *digDet = 0;
89 digDet = new TObjArray(3);
91 Int_t startSPD = geom->GetStartSPD();
92 Int_t lastSPD = geom->GetLastSPD();
94 // Cut on Signal In the Pixel Detector
95 TBranch * br = treeD->GetBranch( "ITSDigitsSPD" );
96 br->SetAddress( &((*digDet)[0]) );
97 ((TClonesArray*)(digDet->At(0)))->Clear();
101 Int_t singhitthreshold = 1; // single hit threshold
104 // const Int_t nlay = 2; // not used
105 // const Int_t nlad = 240; // not used
106 // const Int_t nstave = 40; // not used
107 // const Int_t ndet = 4; // not used
108 // const Int_t nchip = 5; // not used
109 // const Int_t ntotal = 1200;
112 Int_t iFOperlayer[2];
113 Int_t iFOperladder[240];
114 Int_t iFOperstave[40][2];
115 // Int_t iFOperchip[ntotal]; // not used
116 Int_t iFOperChipinStave[20][40][2];
118 for (Int_t m=startSPD;m<lastSPD;m++) {
122 for (Int_t k = 0;k<2;k++){
124 for (Int_t o=0; o<40; o++) {
125 iFOperstave[o][k] = 0;
126 for (Int_t ich=0; ich<20; ich++) {
127 iFOperChipinStave[ich][o][k] = 0;
133 Int_t mInStaveCounter = 0;
134 Int_t checkStave = 0;
136 for (Int_t m=startSPD; m<lastSPD; m++) {
137 treeD->GetEvent( m );
138 TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
139 Int_t lay, stav, det;
140 geom->GetModuleId(m,lay,stav,det);
141 ndig = digits->GetEntriesFast();
142 for( Int_t l=0; l<5; l++ ) {
145 for( Int_t dig=0; dig<ndig; dig++) {
146 AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(dig);
147 Int_t column = dp->GetCoord1();
148 // Int_t row = dp->GetCoord2();
149 Int_t chip = Int_t(column/32.);
153 if (checkStave != stav) {
156 mInStaveCounter += 1;
162 // chipInStave 0,..,19
165 for (Int_t ichip=0; ichip<5; ichip++) {
166 //Int_t seq = (m*5+ichip);
167 Int_t chipInStave = (mInStaveCounter *5) + ichip;
169 if (ndigA[ichip] >= 1) {
171 iFOperlayer[lay-1]++;
172 iFOperstave[stav-1][lay-1]++;
173 //iFOperHstave[hstav-1][lay-1]++;
174 iFOperChipinStave[chipInStave][stav-1][lay-1]++;
178 // SIMPLE FO ---> ANY HIT TRIGGERS
181 } // endl loop over SPD's
185 Int_t upper_cut = 120;
187 if ( ndigfo >= singhitthreshold ) {
188 // Set input GLOBAL FO
189 SetInput( "ITS_SPD_GFO_L0" );
190 // or SetInput( "0x01" );
191 // or ((AliTriggerInput*)fInputs.At(0))->Set();
195 // if ( ndigfo <= upper_cut) { bit1 |= (1 << 10); }
197 if (iFOperlayer[0] >= threshold && iFOperlayer[1] >=threshold) {
200 SetInput( "ITS_SPD_LAYER_L0" );
201 if ( ndigfo <= upper_cut) {
203 // LAYER and UPPER CUT
204 SetInput( "ITS_SPD_LUCUT_L0" );
208 // Sector coincidence
215 // staves layer 1 1-20
216 // staves layer 2: 0-39
217 for (istav=1; istav<21; istav++) {
218 for (jstav = finstav; jstav<finstav+4; jstav++) {
219 if ((iFOperstave[istav-1][0] >= threshold) &&
220 (iFOperstave[jstav][1] >= threshold)) {
223 SetInput( "ITS_SPD_SECTOR_L0" );
224 if ( RequireZ10cm( iFOperChipinStave, istav-1, jstav ) == kTRUE ) {
225 // Set input SECTOR & VERTEX
227 SetInput( "ITS_SPD_SVERTEX_L0" );
232 if (TMath::Even(istav)) {
238 // half sector coincidence
241 for (istav=1; istav<21; istav++){
242 for (jstav = finstav; jstav<finstav+2; jstav++) {
243 if (iFOperstave[istav-1][0] >= threshold && iFOperstave[jstav][1] >= threshold) {
244 // Set input HALF SECTOR
246 SetInput( "ITS_SPD_HSECTOR_L0" );
247 if (RequireZ10cm(iFOperChipinStave,istav-1,jstav) == kTRUE) {
248 // Set input HALF SECTOR & VERTEX
249 SetInput( "ITS_SPD_HSVERTEX_L0" );
258 for (istav=1; istav<21; istav++) {
259 for (jstav = finstav-1; jstav<finstav+3; jstav++) {
260 Int_t probe_stav = jstav;
261 if (jstav == -1) probe_stav = 39;
262 if (jstav == 40) probe_stav = 0;
263 if (iFOperstave[istav-1][0] >= threshold && iFOperstave[probe_stav][1] >= threshold) {
264 // Set input SLIDING WINDOW1
265 SetInput( "ITS_SPD_SW1_L0" );
272 // sliding window coincidence (symmetric): 1 (layer 1), 5 (layer 2)
275 for (istav=1;istav<21; istav++) {
276 for (jstav = finstav-2; jstav<finstav+3; jstav++) {
277 Int_t probe_stav = jstav;
278 if (jstav == -2) probe_stav = 38;
279 if (jstav == -1) probe_stav = 39;
280 if (jstav == 40) probe_stav = 0;
281 if (jstav == 41) probe_stav = 1;
283 if ((iFOperstave[istav-1][0] >= threshold) && (iFOperstave[probe_stav][1] >= threshold)) {
284 // Set input SLIDING WINDOW 2
285 SetInput( "ITS_SPD_SW2_L0" );
287 if (RequireZ10cm(iFOperChipinStave,istav-1,probe_stav) == kTRUE) {
288 // Set input SLIDING WINDOW & VERTEX
289 SetInput( "ITS_SPD_SWVERTEX_L0" );
301 //______________________________________________________________________
302 Bool_t AliITSTrigger::RequireZ10cm(Int_t iFOperChipinStave[][40][2], Int_t stave1, Int_t stave2)
305 // Bool_t zFlag = kFALSE;
314 for (Int_t ic=0; ic<=19; ic++) {
316 for (Int_t jc=0;jc<=ic-1;jc++) {
317 if (iFOperChipinStave[ic][stave1][0] >=threshold) {
318 if (iFOperChipinStave[jc][stave2][1] >= threshold){
319 return kTRUE; // zFlag = kTRUE;
324 if (ic >= 6 && ic <= 8) {
325 for (Int_t jc=(2*start1-1);jc<=(2*start1-1)+5;jc++) {
326 if (iFOperChipinStave[ic][stave1][0] >=threshold) {
327 if (iFOperChipinStave[jc][stave2][1] >= threshold) {
328 return kTRUE; // zFlag = kTRUE;
334 if (ic >= 9 && ic <= 11) {
335 for (Int_t jc=(2*start2); jc<=(2*start2+5); jc++) {
336 if (iFOperChipinStave[ic][stave1][0] >= threshold) {
337 if (iFOperChipinStave[jc][stave2][1] >= threshold) {
338 return kTRUE; // zFlag = kTRUE;
344 if (ic >= 12 && ic <= 13) {
345 for (Int_t jc=(2*start3-1);jc<=(2*start3-1)+5;jc++) {
346 if (iFOperChipinStave[ic][stave1][0] >= threshold) {
347 if (iFOperChipinStave[jc][stave2][1] >= threshold){
348 return kTRUE; // zFlag = kTRUE;
355 for (Int_t jc=(2*start4);jc<=19;jc++) {
356 if (iFOperChipinStave[ic][stave1][0] >= threshold) {
357 if (iFOperChipinStave[jc][stave2][1] >= threshold){
358 return kTRUE; // zFlag = kTRUE;
366 return kFALSE; // zFlag;