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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // This class provides access to PHOS/EMCAL digits in raw data.
22 // It loops over all PHOS/EMCAL digits in the raw data given by the AliRawReader.
23 // The Next method goes to the next digit. If there are no digits left
25 // Several getters provide information about the current digit.
27 // AliRawReader *reader = AliRawReader::Create(fileName);
28 // AliCaloRawStreamV3 *stream = new AliCaloRawStreamV3(reader,calo);
29 // while (reader->NextEvent())
30 // while (stream->NextDDL())
31 // while (stream->NextChannel()) ...
33 /// Yuri Kharlov. 23 June 2009
34 ///////////////////////////////////////////////////////////////////////////////
40 #include "AliCaloRawStreamV3.h"
41 #include "AliRawReader.h"
42 #include "AliCaloAltroMapping.h"
44 ClassImp(AliCaloRawStreamV3)
47 //_____________________________________________________________________________
48 AliCaloRawStreamV3::AliCaloRawStreamV3(AliRawReader* rawReader, TString calo, AliAltroMapping **mapping) :
49 AliAltroRawStreamV3(rawReader),
58 fExternalMapping(kFALSE)
60 // create an object to read PHOS/EMCAL raw digits
63 // PHOS and EMCAL have different number of RCU per module
64 //For PHOS (different mappings for different modules)
70 //For EMCAL (the same mapping for all modules)
71 if(fCalo == "EMCAL") {
76 TString sides[]={"A","C"};
78 if (mapping == NULL) {
79 // Read mapping files from $ALICE_ROOT/CALO/mapping/*.data
80 TString path = gSystem->Getenv("ALICE_ROOT");
81 path += "/"+fCalo+"/mapping/";
83 for(Int_t m = 0; m < fNModules; m++) {
85 if (fCalo == "EMCAL") {
88 else if(fCalo == "PHOS" ) {
93 for(Int_t j = 0; j < fNSides; j++){
94 for(Int_t i = 0; i < fNRCU; i++) {
97 if(fCalo == "EMCAL") path2 += sides[j];
99 AliDebug(2,Form("Mapping file: %s",path2.Data()));
100 fMapping[m*fNSides*fNRCU + j*fNRCU + i] = new AliCaloAltroMapping(path2.Data());
106 // Mapping is supplied by reconstruction
107 fExternalMapping = kTRUE;
108 for(Int_t i = 0; i < fNModules*fNRCU*fNSides; i++)
109 fMapping[i] = mapping[i];
113 //_____________________________________________________________________________
114 AliCaloRawStreamV3::AliCaloRawStreamV3(const AliCaloRawStreamV3& stream) :
115 AliAltroRawStreamV3(stream),
124 fExternalMapping(kFALSE)
126 // Dummy copy constructor
127 Fatal("AliCaloRawStreamV3", "copy constructor not implemented");
130 //_____________________________________________________________________________
131 AliCaloRawStreamV3& AliCaloRawStreamV3::operator = (const AliCaloRawStreamV3&
134 // Dummy assignment operator
135 Fatal("operator =", "assignment operator not implemented");
139 //_____________________________________________________________________________
140 AliCaloRawStreamV3::~AliCaloRawStreamV3()
144 if (!fExternalMapping)
145 for(Int_t i = 0; i < fNModules*fNRCU*fNSides; i++)
149 //_____________________________________________________________________________
150 void AliCaloRawStreamV3::Reset()
152 // reset PHOS/EMCAL raw stream params
153 AliAltroRawStreamV3::Reset();
154 fModule = fRow = fColumn = -1;
159 //_____________________________________________________________________________
160 Bool_t AliCaloRawStreamV3::NextChannel()
162 // Read next PHOS/EMCAL signal
163 // Apply the PHOS/EMCAL altro mapping to get
164 // the module,row and column indeces
166 if (AliAltroRawStreamV3::NextChannel()) {
174 //_____________________________________________________________________________
175 void AliCaloRawStreamV3::ApplyAltroMapping()
177 // Take the DDL index, load
178 // the corresponding altro mapping
179 // object and fill the sector,row and pad indeces
181 Int_t ddlNumber = GetDDLNumber();
182 fModule = ddlNumber / fNRCU;
184 Int_t rcuIndex = ddlNumber % fNRCU;
186 if( fNModules > 1) rcuIndex += fModule*fNRCU*fNSides;
187 if( fNRCU == 2 ){ // EMCAL may need to increase RCU index for the maps
188 if (fModule%2 == 1) { rcuIndex += 2; } // other='C' side maps
191 Short_t hwAddress = GetHWAddress();
192 fRow = fMapping[rcuIndex]->GetPadRow(hwAddress);
193 fColumn = fMapping[rcuIndex]->GetPad(hwAddress);
194 fCaloFlag = fMapping[rcuIndex]->GetSector(hwAddress);