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 EMCal trigger electronics manager L0/L1
20 can handle both simulated digits and raw data
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
24 #include "AliEMCALTriggerElectronics.h"
25 #include "AliEMCALTriggerTRU.h"
26 #include "AliEMCALTriggerSTU.h"
27 #include "AliEMCALGeometry.h"
28 #include "AliRunLoader.h"
31 #include "AliEMCALTriggerData.h"
32 #include "AliEMCALDigit.h"
33 #include "AliCaloRawStreamV3.h"
34 //#include "AliVZERORawStream.h"
35 #include "AliEMCALTriggerSTURawStream.h"
36 #include "AliEMCALDigit.h"
37 #include "AliEMCALRawDigit.h"
40 #include <TClonesArray.h>
41 //#include <Riostream.h>
45 const Int_t kNTRU = 32;
48 ClassImp(AliEMCALTriggerElectronics)
51 AliEMCALTriggerElectronics::AliEMCALTriggerElectronics(AliEMCALCalibData *calibData) : TObject(),
52 fTRU(new TClonesArray("AliEMCALTriggerTRU",32)),
60 for (Int_t i=0;i<kNTRU;i++) new ((*fTRU)[i]) AliEMCALTriggerTRU(calibData, rSize, int(i/3) % 2);
62 rSize.Set( 48., 64. );
65 fSTU = new AliEMCALTriggerSTU(calibData, rSize);
67 for (Int_t i=0;i<kNTRU;i++) fSTU->BuildMap( i,
68 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
69 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
74 AliEMCALTriggerElectronics::~AliEMCALTriggerElectronics()
82 void AliEMCALTriggerElectronics::Digits2Trigger(const TClonesArray* digits, const TTree* treeV0, AliEMCALTriggerData* data)
85 AliEMCALGeometry* geom = 0x0;
87 AliRunLoader *rl = AliRunLoader::Instance();
88 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
89 geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
91 geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
93 if (!geom) AliError("Cannot access geometry!");
95 TIter NextDigit(digits);
96 while (AliEMCALRawDigit* digit = (AliEMCALRawDigit*)NextDigit())
100 Int_t id = digit->GetId();
105 Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
107 for (Int_t i = 0; i < digit->GetNSamples(); i++)
110 Bool_t isOK2 = digit->GetTimeSample(i, time, amp);
112 if (isOK1 && isOK2 && amp) (static_cast<AliEMCALTriggerTRU*>(fTRU->At(iTRU)))->SetADC(iADC, time, amp);
117 for (Int_t i=0; i<kNTRU; i++)
119 printf("===========< TRU %2d >============\n",i);
120 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Scan();
125 // At this point all FastOR are available for digitization
126 // digitization is done in the TRU and produces time samples
127 // Now run the trigger algo & consecutively write trigger outputs in TreeD dedicated branch
129 for (Int_t i=0; i<kNTRU; i++)
131 AliDebug(1,Form("===========< TRU %2d >============\n",i));
133 AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
137 Int_t vL0Peaks[96][2]; iTRU->Peaks( vL0Peaks );
139 data->SetL0Patches( i , iTRU->Patches() );
140 data->SetL0Peaks( i , vL0Peaks );
142 if ( !i ) // do it once since identical for all TRU
144 data->SetL0RegionSize( *iTRU->RegionSize() );
145 data->SetL0SubRegionSize( *iTRU->SubRegionSize() );
146 data->SetL0PatchSize( *iTRU->PatchSize() );
149 // if ( i == 31 ) i = 35;
151 // if ( ( i / 3 ) % 2 ) {
152 // TRU->Print( 15 - 2 + ( i - int( i / 3 ) * 3 ) - 3 * ( (i / 3) / 2 ) , runLoader->GetEventNumber() );
153 // printf("print data of TRU: from %2d to %2d\n",i,15 - 2 + ( i - int( i / 3 ) * 3 ) - 3 * ( (i / 3) / 2));
157 // TRU->Print( 31 - i % 3 - 3 * ( (i / 3) / 2 ) , runLoader->GetEventNumber() );
158 // printf("print data of TRU: from %2d to %2d\n",i,31 - i % 3 - 3 * ( (i / 3) / 2 ));
162 // A L0 has been issued, run L1
165 for (Int_t i=0; i<kNTRU; i++) fSTU->FetchFOR( i,
166 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Region(),
167 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
172 TTree* tr = const_cast<TTree*>(treeV0);
173 if ( tr ) fSTU->V0Multiplicity( *tr );
178 fSTU->SetSubRegionSize( size ); data->SetL1GammaSubRegionSize( size );
181 fSTU->SetPatchSize( size ); data->SetL1GammaPatchSize( size );
185 data->SetL1GammaPatches( fSTU->Patches() );
190 fSTU->SetSubRegionSize( size ); data->SetL1JetSubRegionSize( size );
193 fSTU->SetPatchSize( size ); data->SetL1JetPatchSize( size );
197 data->SetL1JetPatches( fSTU->Patches() );
198 data->SetL1RegionSize( *fSTU->RegionSize() );
200 Int_t** region = fSTU->Region();
201 data->SetL1Region( region );
202 const Int_t* mv0 = fSTU->V0();
203 data->SetL1V0( mv0 );
206 // Now reset the electronics for a fresh start with next event
211 void AliEMCALTriggerElectronics::Reset()
215 while ( AliEMCALTriggerTRU *TRU = (AliEMCALTriggerTRU*)NextTRU() ) TRU->Reset();