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 **************************************************************************/
15 //This class produces PHOS trigger digits of one event.
16 //Authors: Henrik Qvigstad, Boris Polishchuk.
18 #include "AliPHOSTriggerRawDigiProducer.h"
19 #include "AliPHOSTriggerRawReader.h"
20 #include "AliPHOSTRURawReader.h"
21 #include "AliPHOSTriggerParameters.h"
22 #include "AliPHOSTriggerRawDigit.h"
23 #include "AliPHOSGeometry.h"
24 #include "AliRawReader.h"
25 #include "AliCaloRawStreamV3.h"
33 ClassImp(AliPHOSTriggerRawDigiProducer)
35 AliPHOSTriggerRawDigiProducer::AliPHOSTriggerRawDigiProducer()
36 :fModules(kNMods, false),
37 fSaturationThreshold(950),
44 AliPHOSTriggerRawDigiProducer::AliPHOSTriggerRawDigiProducer(AliRawReader *rawReader)
45 :fModules(kNMods, false),
46 fSaturationThreshold(950),
48 fRawReader(rawReader),
50 fTriggerReader(new AliPHOSTriggerRawReader)
56 fRawStream = new AliCaloRawStreamV3(rawReader,"PHOS");
59 AliPHOSTriggerRawDigiProducer::~AliPHOSTriggerRawDigiProducer()
62 delete fTriggerReader;
65 void AliPHOSTriggerRawDigiProducer::ProcessEvent(TClonesArray* tdigits)
68 fTriggerReader->Reset();
73 while (fRawStream->NextDDL()) {
74 while (fRawStream->NextChannel()) {
76 if (fRawStream->IsTRUData()) {
77 fTriggerReader->ReadFromStream(fRawStream);
83 for(unsigned int mod = 0; mod < fModules.size(); ++mod) {
86 // Loop over 4x4 cells
87 for(int TRURow = 0; TRURow < kNTRURows; ++TRURow) {
88 for(int branch = 0; branch < kNBranches; ++branch) {
90 AliPHOSTRURawReader* truReader = fTriggerReader->GetTRU(mod, TRURow, branch);
91 if( truReader->IsActive() ) {
93 for(int xIdx = 0; xIdx < kN4x4XPrTRURow; ++xIdx) {
94 for(int zIdx = 0; zIdx < kN4x4ZPrBranch; ++zIdx) {
96 // Determin if Trigger is flagged for any timeBin
97 bool triggered = false;
99 for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin){
100 if(truReader->IsActive(timeBin)) {
101 if( fTriggerReader->GetTRU(mod, TRURow, branch)->GetTriggerFlag(xIdx, zIdx, timeBin) ){
103 } // end "if TriggerBit"
109 const int TSmax = Get4x4Max(fTriggerReader, fParameters, mod, TRURow, branch, xIdx, zIdx);
110 new((*tdigits)[iDigit]) AliPHOSTriggerRawDigit(mod,xIdx,zIdx,TRURow,branch,TSmax);
112 }// end "if triggered"
116 } // truReader->IsActive
124 int AliPHOSTriggerRawDigiProducer::Get2x2Max(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int xIdx, int zIdx)
127 for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) {
128 const int signal = Get2x2Signal(reader, params, mod, xIdx, zIdx, timeBin);
137 int AliPHOSTriggerRawDigiProducer::Get2x2Signal(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* parameters, int mod, int xIdx, int zIdx, int timeBin)
139 const int TRURow = xIdx / kN2x2XPrTRURow;
140 const int branch = zIdx / kN2x2ZPrBranch;
141 const int TRUX = xIdx % kN2x2XPrTRURow; // 2x2 coordinates
142 const int TRUZ = zIdx % kN2x2ZPrBranch; // 2x2 coordinates
144 if( reader->GetTRU(mod, TRURow, branch)->IsActive() ){
145 const int signal = reader->GetTRU(mod, TRURow, branch)->GetTriggerSignal( TRUX, TRUZ, timeBin);
147 return signal - parameters->GetTRUPedestal(mod, TRURow, branch, TRUX, TRUZ);
149 return signal - AliPHOSTRURawReader::GetDefaultSignalValue();
155 int AliPHOSTriggerRawDigiProducer::Get4x4Max(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int TRURow, int branch, int xIdx, int zIdx)
158 for(int timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) {
159 const int signal = Get4x4Signal(reader, params, mod, TRURow, branch, xIdx, zIdx, timeBin);
168 int AliPHOSTriggerRawDigiProducer::Get4x4Signal(AliPHOSTriggerRawReader* reader, AliPHOSTriggerParameters* params, int mod, int TRURow, int branch, int xIdx, int zIdx, int timeBin)
170 const int modX = xIdx + TRURow * kN2x2XPrTRURow;
171 const int modZ = zIdx + branch * kN2x2ZPrBranch;
174 = Get2x2Signal(reader, params, mod, modX , modZ , timeBin)
175 + Get2x2Signal(reader, params, mod, modX+1, modZ , timeBin)
176 + Get2x2Signal(reader, params, mod, modX , modZ+1, timeBin)
177 + Get2x2Signal(reader, params, mod, modX+1, modZ+1, timeBin);
181 bool AliPHOSTriggerRawDigiProducer::Is2x2Active(AliPHOSTriggerRawReader* reader, int mod, int xIdx, int zIdx)
183 const int TRURow = xIdx / kN2x2XPrTRURow;
184 const int branch = zIdx / kN2x2ZPrBranch;
186 return reader->GetTRU(mod, TRURow, branch)->IsActive();
189 bool AliPHOSTriggerRawDigiProducer::Is2x2Active(AliPHOSTriggerRawReader* reader, int mod, int xIdx, int zIdx, int timeBin)
191 const int TRURow = xIdx / kN2x2XPrTRURow;
192 const int branch = zIdx / kN2x2ZPrBranch;
194 return reader->GetTRU(mod, TRURow, branch)->IsActive(timeBin);