]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSTrigger.cxx
Formatting changes.
[u/mrichter/AliRoot.git] / ITS / AliITSTrigger.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                         *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16
17 /* $Id$ */
18
19
20 #include "AliLog.h"
21 #include "AliRun.h"
22 #include "AliRunLoader.h"
23 #include "AliTriggerInput.h"
24
25 #include "AliITSTrigger.h"
26 #include "AliITSdigitSPD.h"
27 #include "AliITSgeom.h"
28 #include "AliITSLoader.h"
29
30 //______________________________________________________________________
31 ClassImp(AliITSTrigger)
32 ////////////////////////////////////////////////////////////////////////
33 //                                                                    //
34 // Version 1                                                          //
35 // Modified by D. Elia, C. Jorgensen                                  //
36 // March 2006                                                         //
37 //                                                                    //
38 // Version 0                                                          //
39 // Written by J. Conrad, E. Lopez Torres                              //
40 // October 2005                                                       //
41 //                                                                    //
42 // AliITSTrigger: implementation of the SPD Fast-OR based triggers.   //
43 //                                                                    //
44 ////////////////////////////////////////////////////////////////////////
45
46 //______________________________________________________________________
47 AliITSTrigger::AliITSTrigger()
48   : AliTriggerDetector(),
49 fGlobalFOThreshold(1),
50 fHighMultFOThreshold(150){
51
52   //standard constructor
53   SetName("ITS");
54   CreateInputs();
55
56   // set parameters to define trigger condition thresholds
57   //fGlobalFOThreshold = 1;
58   //fHighMultFOThreshold = 150; 
59 }
60
61 //______________________________________________________________________
62 void AliITSTrigger::CreateInputs()
63 {
64    // inputs
65
66    // Do not create inputs again!!
67    if( fInputs.GetEntriesFast() > 0 ) return;
68    
69    fInputs.AddLast( new AliTriggerInput( "ITS_SPD_GFO_L0",     "Global, Fast OR all detectors", 0x01 ) );
70    fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HMULT_L0",   "High Multiplicity",             0x02 ) );
71
72 }
73
74 //______________________________________________________________________
75 void AliITSTrigger::Trigger()
76 {
77
78   //  ********** Get run loader for the current event **********
79   AliRunLoader* runLoader = gAlice->GetRunLoader();
80
81   AliITSLoader* loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
82   AliITSgeom* geom = loader->GetITSgeom();
83   loader->LoadDigits("READ");
84   TTree *treeD = loader->TreeD();
85   if (!treeD) return;
86
87   TObjArray *digDet = 0;
88   digDet = new TObjArray(3);
89
90
91   // Cut on Signal In the Pixel Detector
92   TBranch* br = treeD->GetBranch( "ITSDigitsSPD" );
93   br->SetAddress( &((*digDet)[0]) );
94   ((TClonesArray*)(digDet->At(0)))->Clear();
95
96   MultiplicityTriggers(digDet, treeD, geom);
97   //  GeometryTriggers(digDet, treeD, geom);
98
99   // Debug : FIX change to AliLog
100 //  cout << "=================================================" << endl;
101 //  cout << "  Pixel Trigger Mask ( " << hex << "0x" << GetMask() << " )" << endl << endl;
102 //  cout << " Global Fast OR        " << "0x" << GetInput( "ITS_SPD_GFO_L0"      )->GetValue() << endl;
103 //  cout << " High Multiplicity     " << "0x" << GetInput( "ITS_SPD_HMULT_L0"      )->GetValue() << endl;
104 //  cout << "=================================================" << endl << endl;
105
106 }
107
108 //______________________________________________________________________
109 void AliITSTrigger::MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
110 {
111   // simple FO triggers that only cares about the multiplicity
112
113   Int_t startSPD = geom->GetStartSPD();
114   Int_t lastSPD  = geom->GetLastSPD();
115
116   Int_t totalNumberOfFO = 0;
117   Int_t ndigitsInChip[5];
118
119   // loop over modules (ladders)
120   for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++) {
121     treeD->GetEvent(moduleIndex);
122     TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
123     
124     // get number of digits in this module
125     Int_t ndigitsInModule = digits->GetEntriesFast();
126
127     // get number of digits in each chip of the module
128     for( Int_t iChip=0; iChip<5; iChip++ ) {
129         ndigitsInChip[iChip]=0;
130     }   
131     for( Int_t iDig=0; iDig<ndigitsInModule; iDig++ ) {
132         AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(iDig);
133         Int_t column = dp->GetCoord1();
134         Int_t isChip = Int_t(column/32.);
135         ndigitsInChip[isChip]++;
136     }
137     // get number of FOs in the module
138     for( Int_t ifChip=0; ifChip<5; ifChip++ ) {
139         if( ndigitsInChip[ifChip] >= 1 ) {
140                 totalNumberOfFO++;
141         }       
142     }
143   // end of loop over modules
144   }
145
146   // produce input trigger condition
147   if (totalNumberOfFO>=fGlobalFOThreshold) 
148     SetInput( "ITS_SPD_GFO_L0" );
149
150   if (totalNumberOfFO>=fHighMultFOThreshold) 
151     SetInput( "ITS_SPD_HMULT_L0" );
152
153   return;
154
155 }
156
157 //______________________________________________________________________
158 // void AliITSTrigger::GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
159 void AliITSTrigger::GeometryTriggers()
160 {
161
162 //   //   const Int_t nlay = 2;      // not used
163 //   //   const Int_t nlad = 240;    // not used
164 //   //   const Int_t nstave = 40;   // not used
165 //   //   const Int_t ndet = 4;      // not used
166 //   //   const Int_t nchip = 5;     // not used
167 //   //   const Int_t ntotal = 1200;
168   
169 //   Int_t ndigA[5];
170 //   Int_t iFOperlayer[2];
171 //   Int_t iFOperladder[240];
172 //   Int_t iFOperstave[40][2];
173 //   //   Int_t iFOperchip[ntotal];   // not used
174 //   Int_t iFOperChipinStave[20][40][2];
175   
176 //   for (Int_t m=startSPD;m<lastSPD+1;m++) {
177 //     iFOperladder[m] = 0;
178 //   }
179
180 //   for (Int_t k = 0;k<2;k++){
181 //     iFOperlayer[k] = 0;
182 //     for (Int_t o=0; o<40; o++) {
183 //       iFOperstave[o][k] = 0;
184 //       for (Int_t ich=0; ich<20; ich++) {
185 //      iFOperChipinStave[ich][o][k] = 0;
186 //       }
187 //     }
188 //   }
189
190 //   // nFO = 0.0;
191 //   Int_t mInStaveCounter = 0;
192 //   Int_t checkStave = 0;
193   
194 //   // loop over modules
195 //   for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++) {
196 //     treeD->GetEvent(moduleIndex);
197 //     TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
198
199 //     Int_t lay, stav, det;
200 //     geom->GetModuleId(moduleIndex,lay,stav,det);
201
202 //     ndig = digits->GetEntriesFast();
203
204 //     for( Int_t l=0; l<5; l++ ) {
205 //       ndigA[l] = 0 ;
206 //     }
207 //     for( Int_t dig=0; dig<ndig; dig++) {
208 //       AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(dig);
209 //       Int_t column = dp->GetCoord1();
210 //       //   Int_t row = dp->GetCoord2();
211 //       Int_t chip = Int_t(column/32.);
212 //       ndigA[chip]++;
213 //     }
214     
215 //     if (checkStave != stav) {
216 //       mInStaveCounter = 0;
217 //     } else {
218 //       mInStaveCounter += 1;
219 //     }
220
221 //     // m 0,.., 239
222 //     // stav 1,..,40
223 //     // mInStave 0,..,3
224 //     // chipInStave 0,..,19
225     
226 //     //cout << "m " << m << " stav "  << stav  << " mInStave " << mInStaveCounter << " " <<lay << endl;
227     
228 //     for (Int_t ichip=0; ichip<5; ichip++) {
229 //       //Int_t seq = (m*5+ichip);
230 //       Int_t chipInStave = (mInStaveCounter *5) + ichip;
231       
232 //       if (ndigA[ichip] >= 1) {
233 //      iFOperladder[moduleIndex]++;
234 //      iFOperlayer[lay-1]++;
235 //      iFOperstave[stav-1][lay-1]++;
236 //      //iFOperHstave[hstav-1][lay-1]++;
237 //      iFOperChipinStave[chipInStave][stav-1][lay-1]++;
238 //         //    nFO++;
239 //       }
240 //     }
241 //     // SIMPLE FO ---> ANY HIT TRIGGERS
242 //     ndigfo += ndig;
243 //     checkStave = stav;
244 //   } // endl loop over SPD's
245
246
247
248 //    if ( ndigfo >= singhitthreshold ) {
249 //       // Set input GLOBAL FO
250 //       SetInput( "ITS_SPD_GFO_L0" );
251 //       // or SetInput( "0x01" );
252 //       // or ((AliTriggerInput*)fInputs.At(0))->Set();
253 //       // bit1 |= (1 << 1);
254 //    }
255
256    // return bit1;
257 }