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 "AliEMCALTriggerDCSConfig.h"
32 #include "AliEMCALTriggerData.h"
33 #include "AliEMCALDigit.h"
34 #include "AliCaloRawStreamV3.h"
35 #include "AliEMCALTriggerSTURawStream.h"
36 #include "AliEMCALDigit.h"
37 #include "AliEMCALRawDigit.h"
40 #include <TClonesArray.h>
44 const Int_t kNTRU = 32;
47 ClassImp(AliEMCALTriggerElectronics)
50 AliEMCALTriggerElectronics::AliEMCALTriggerElectronics(const AliEMCALTriggerDCSConfig *dcsConf) : TObject(),
51 fTRU(new TClonesArray("AliEMCALTriggerTRU",32)),
59 for (Int_t i=0;i<kNTRU;i++)
61 AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(i);
62 new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, int(i/3) % 2);
65 rSize.Set( 48., 64. );
68 AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
69 fSTU = new AliEMCALTriggerSTU(stuConf, rSize);
71 for (Int_t i=0;i<kNTRU;i++) fSTU->BuildMap( i,
72 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
73 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
78 AliEMCALTriggerElectronics::~AliEMCALTriggerElectronics()
86 void AliEMCALTriggerElectronics::Digits2Trigger(const TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data)
89 AliEMCALGeometry* geom = 0x0;
91 AliRunLoader *rl = AliRunLoader::Instance();
92 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
93 geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
95 geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
97 if (!geom) AliError("Cannot access geometry!");
99 TIter NextDigit(digits);
100 while (AliEMCALRawDigit* digit = (AliEMCALRawDigit*)NextDigit())
104 Int_t id = digit->GetId();
109 Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
111 for (Int_t i = 0; i < digit->GetNSamples(); i++)
114 Bool_t isOK2 = digit->GetTimeSample(i, time, amp);
116 if (isOK1 && isOK2 && amp) (static_cast<AliEMCALTriggerTRU*>(fTRU->At(iTRU)))->SetADC(iADC, time, amp);
121 for (Int_t i=0; i<kNTRU; i++)
123 printf("===========< TRU %2d >============\n",i);
124 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Scan();
129 // At this point all FastOR are available for digitization
130 // digitization is done in the TRU and produces time samples
131 // Now run the trigger algo & consecutively write trigger outputs in TreeD dedicated branch
133 for (Int_t i=0; i<kNTRU; i++)
135 AliDebug(1,Form("===========< TRU %2d >============\n",i));
137 AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
141 // Int_t vL0Peaks[96][2]; iTRU->Peaks( vL0Peaks );
143 data->SetL0Patches( i , iTRU->Patches() );
144 // data->SetL0Peaks( i , vL0Peaks );
146 if ( !i ) // do it once since identical for all TRU
148 data->SetL0RegionSize( *iTRU->RegionSize() );
149 data->SetL0SubRegionSize( *iTRU->SubRegionSize() );
150 data->SetL0PatchSize( *iTRU->PatchSize() );
153 // if ( i == 31 ) i = 35;
155 // if ( ( i / 3 ) % 2 ) {
156 // TRU->Print( 15 - 2 + ( i - int( i / 3 ) * 3 ) - 3 * ( (i / 3) / 2 ) , runLoader->GetEventNumber() );
157 // printf("print data of TRU: from %2d to %2d\n",i,15 - 2 + ( i - int( i / 3 ) * 3 ) - 3 * ( (i / 3) / 2));
161 // TRU->Print( 31 - i % 3 - 3 * ( (i / 3) / 2 ) , runLoader->GetEventNumber() );
162 // printf("print data of TRU: from %2d to %2d\n",i,31 - i % 3 - 3 * ( (i / 3) / 2 ));
166 // A L0 has been issued, run L1
169 for (Int_t i=0; i<kNTRU; i++) fSTU->FetchFOR( i,
170 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Region(),
171 (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
174 fSTU->SetV0Multiplicity( V0M , 2 ); // C/A
179 fSTU->SetSubRegionSize( size ); data->SetL1GammaSubRegionSize( size );
182 fSTU->SetPatchSize( size ); data->SetL1GammaPatchSize( size );
186 data->SetL1GammaPatches( fSTU->Patches() );
191 fSTU->SetSubRegionSize( size ); data->SetL1JetSubRegionSize( size );
194 fSTU->SetPatchSize( size ); data->SetL1JetPatchSize( size );
198 data->SetL1JetPatches( fSTU->Patches() );
199 data->SetL1RegionSize( *fSTU->RegionSize() );
201 Int_t** region = fSTU->Region();
202 data->SetL1Region( region );
203 const Int_t* mv0 = fSTU->V0();
204 data->SetL1V0( mv0 );
207 // Now reset the electronics for a fresh start with next event
212 void AliEMCALTriggerElectronics::Reset()
216 while ( AliEMCALTriggerTRU *TRU = (AliEMCALTriggerTRU*)NextTRU() ) TRU->Reset();