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 #include <TClonesArray.h>
23 #include "AliRunLoader.h"
24 #include "AliTriggerInput.h"
26 #include "AliITSTrigger.h"
27 #include "AliITSdigitSPD.h"
28 #include "AliITSgeom.h"
29 #include "AliITSLoader.h"
31 //______________________________________________________________________
32 ClassImp(AliITSTrigger)
33 ////////////////////////////////////////////////////////////////////////
36 // Modified by D. Elia, C. Jorgensen //
40 // Written by J. Conrad, E. Lopez Torres //
43 // AliITSTrigger: implementation of the SPD Fast-OR based triggers. //
45 ////////////////////////////////////////////////////////////////////////
47 //______________________________________________________________________
48 AliITSTrigger::AliITSTrigger()
49 : AliTriggerDetector(),
50 fGlobalFOThreshold(1),
51 fHighMultFOThreshold(150){
53 //standard constructor
57 // set parameters to define trigger condition thresholds
58 //fGlobalFOThreshold = 1;
59 //fHighMultFOThreshold = 150;
62 //______________________________________________________________________
63 void AliITSTrigger::CreateInputs()
67 // Do not create inputs again!!
68 if( fInputs.GetEntriesFast() > 0 ) return;
70 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_GFO_L0", "Global, Fast OR all detectors", 0x01 ) );
71 fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HMULT_L0", "High Multiplicity", 0x02 ) );
75 //______________________________________________________________________
76 void AliITSTrigger::Trigger()
79 // ********** Get run loader for the current event **********
80 AliRunLoader* runLoader = gAlice->GetRunLoader();
82 AliITSLoader* loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
83 AliITSgeom* geom = loader->GetITSgeom();
84 loader->LoadDigits("READ");
85 TTree *treeD = loader->TreeD();
88 TObjArray *digDet = 0;
89 digDet = new TObjArray(3);
92 // Cut on Signal In the Pixel Detector
93 TBranch* br = treeD->GetBranch( "ITSDigitsSPD" );
94 br->SetAddress( &((*digDet)[0]) );
95 ((TClonesArray*)(digDet->At(0)))->Clear();
97 MultiplicityTriggers(digDet, treeD, geom);
98 // GeometryTriggers(digDet, treeD, geom);
100 // Debug : FIX change to AliLog
101 // cout << "=================================================" << endl;
102 // cout << " Pixel Trigger Mask ( " << hex << "0x" << GetMask() << " )" << endl << endl;
103 // cout << " Global Fast OR " << "0x" << GetInput( "ITS_SPD_GFO_L0" )->GetValue() << endl;
104 // cout << " High Multiplicity " << "0x" << GetInput( "ITS_SPD_HMULT_L0" )->GetValue() << endl;
105 // cout << "=================================================" << endl << endl;
109 //______________________________________________________________________
110 void AliITSTrigger::MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
112 // simple FO triggers that only cares about the multiplicity
114 Int_t startSPD = geom->GetStartSPD();
115 Int_t lastSPD = geom->GetLastSPD();
117 Int_t totalNumberOfFO = 0;
118 Int_t ndigitsInChip[5];
120 // loop over modules (ladders)
121 for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++) {
122 treeD->GetEvent(moduleIndex);
123 TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
125 // get number of digits in this module
126 Int_t ndigitsInModule = digits->GetEntriesFast();
128 // get number of digits in each chip of the module
129 for( Int_t iChip=0; iChip<5; iChip++ ) {
130 ndigitsInChip[iChip]=0;
132 for( Int_t iDig=0; iDig<ndigitsInModule; iDig++ ) {
133 AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(iDig);
134 Int_t column = dp->GetCoord1();
135 Int_t isChip = Int_t(column/32.);
136 ndigitsInChip[isChip]++;
138 // get number of FOs in the module
139 for( Int_t ifChip=0; ifChip<5; ifChip++ ) {
140 if( ndigitsInChip[ifChip] >= 1 ) {
144 // end of loop over modules
147 // produce input trigger condition
148 if (totalNumberOfFO>=fGlobalFOThreshold)
149 SetInput( "ITS_SPD_GFO_L0" );
151 if (totalNumberOfFO>=fHighMultFOThreshold)
152 SetInput( "ITS_SPD_HMULT_L0" );
158 //______________________________________________________________________
159 // void AliITSTrigger::GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
160 void AliITSTrigger::GeometryTriggers()
163 // // const Int_t nlay = 2; // not used
164 // // const Int_t nlad = 240; // not used
165 // // const Int_t nstave = 40; // not used
166 // // const Int_t ndet = 4; // not used
167 // // const Int_t nchip = 5; // not used
168 // // const Int_t ntotal = 1200;
171 // Int_t iFOperlayer[2];
172 // Int_t iFOperladder[240];
173 // Int_t iFOperstave[40][2];
174 // // Int_t iFOperchip[ntotal]; // not used
175 // Int_t iFOperChipinStave[20][40][2];
177 // for (Int_t m=startSPD;m<lastSPD+1;m++) {
178 // iFOperladder[m] = 0;
181 // for (Int_t k = 0;k<2;k++){
182 // iFOperlayer[k] = 0;
183 // for (Int_t o=0; o<40; o++) {
184 // iFOperstave[o][k] = 0;
185 // for (Int_t ich=0; ich<20; ich++) {
186 // iFOperChipinStave[ich][o][k] = 0;
192 // Int_t mInStaveCounter = 0;
193 // Int_t checkStave = 0;
195 // // loop over modules
196 // for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++) {
197 // treeD->GetEvent(moduleIndex);
198 // TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
200 // Int_t lay, stav, det;
201 // geom->GetModuleId(moduleIndex,lay,stav,det);
203 // ndig = digits->GetEntriesFast();
205 // for( Int_t l=0; l<5; l++ ) {
208 // for( Int_t dig=0; dig<ndig; dig++) {
209 // AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(dig);
210 // Int_t column = dp->GetCoord1();
211 // // Int_t row = dp->GetCoord2();
212 // Int_t chip = Int_t(column/32.);
216 // if (checkStave != stav) {
217 // mInStaveCounter = 0;
219 // mInStaveCounter += 1;
224 // // mInStave 0,..,3
225 // // chipInStave 0,..,19
227 // //cout << "m " << m << " stav " << stav << " mInStave " << mInStaveCounter << " " <<lay << endl;
229 // for (Int_t ichip=0; ichip<5; ichip++) {
230 // //Int_t seq = (m*5+ichip);
231 // Int_t chipInStave = (mInStaveCounter *5) + ichip;
233 // if (ndigA[ichip] >= 1) {
234 // iFOperladder[moduleIndex]++;
235 // iFOperlayer[lay-1]++;
236 // iFOperstave[stav-1][lay-1]++;
237 // //iFOperHstave[hstav-1][lay-1]++;
238 // iFOperChipinStave[chipInStave][stav-1][lay-1]++;
242 // // SIMPLE FO ---> ANY HIT TRIGGERS
244 // checkStave = stav;
245 // } // endl loop over SPD's
249 // if ( ndigfo >= singhitthreshold ) {
250 // // Set input GLOBAL FO
251 // SetInput( "ITS_SPD_GFO_L0" );
252 // // or SetInput( "0x01" );
253 // // or ((AliTriggerInput*)fInputs.At(0))->Set();
254 // // bit1 |= (1 << 1);