]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALCellInfo.cxx
changing to AMANDA protocol version 2
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCellInfo.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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
16 /* $Log$ */
17
18 // Aug 1, 2007 - cells information in one place
19 #include "AliEMCALCellInfo.h"
20 #include "AliEMCALGeometry.h"
21
22 #include <TObjArray.h>
23  
24 ClassImp(cellInfo) 
25
26 cellInfo::cellInfo() : absId(-1), nSupMod(-1), nModule(-1), nIphi(-1), 
27 nIeta(-1), iPhi(-1), iEta(-1), iPhim(-1), iEtam(-1)   
28 {
29 }
30
31 ClassImp(AliEMCALCellInfo)
32 // ------------------------------------------------------------------------------
33
34 AliEMCALCellInfo::AliEMCALCellInfo() : TNamed("",""), fTable(0), fCurrentInd(0)
35 {
36 }
37
38 AliEMCALCellInfo::AliEMCALCellInfo(const char* name, const Int_t nrow) : TNamed(name,"table of cell information") , fTable(0), fCurrentInd(0)
39 {
40   fTable = new TObjArray(nrow);
41 }
42
43 void AliEMCALCellInfo::AddAt(cellInfo* r)
44 {
45   (*fTable)[fCurrentInd] = new cellInfo(*r);
46   fCurrentInd++;
47 }
48
49 AliEMCALCellInfo::~AliEMCALCellInfo()
50 {
51   if(fTable) {
52     fTable->Delete();
53     delete fTable;
54   }
55 }
56
57 cellInfo* AliEMCALCellInfo::GetTable(Int_t i) const
58 {
59   return (cellInfo*)fTable->At(i);
60 }
61
62 void AliEMCALCellInfo::PrintTable(int ind1, int ind2) const
63 {
64   printf(" %s : %s : #rows %i \n", GetName(), GetTitle(), fTable->GetSize());
65   if(ind1==-1 && ind2==-1) return;
66   printf(" absId nSupMod nModule nIphi nIeta iPhi iEta iPhim iEtam\n");
67   if(ind1 < 0) ind1 = 0;
68   if(ind2 >= fTable->GetSize()) ind2 = fTable->GetSize();
69   for(int i=ind1; i<ind2; i++) {
70     cellInfo* r = GetTable(i);
71     if(r==0) break;
72     printf(" %5.5i    %2.2i      %3.3i    %1.1i    %1.1i    %2.2i    %2.2i    %2.2i    %2.2i\n", 
73     r->absId, r->nSupMod, r->nModule, r->nIphi, r->nIeta, r->iPhi, r->iEta, r->iPhim,r->iEtam);
74   }
75 }
76
77
78 AliEMCALCellInfo *AliEMCALCellInfo::GetTableForGeometry(const char* geoName)
79 {
80   if(geoName==0) return 0;
81   AliEMCALGeometry *g=AliEMCALGeometry::GetInstance(geoName);  
82   return GetTableForGeometry(g);
83 }
84
85 AliEMCALCellInfo *AliEMCALCellInfo::GetTableForGeometry(AliEMCALGeometry *g)
86 {
87   if(g==0) return 0;
88   AliEMCALCellInfo *t = new AliEMCALCellInfo("CellInfo",g->GetNCells());
89
90   for(Int_t absid=0; absid<g->GetNCells(); absid++){
91     cellInfo r;
92     r.absId   = absid;
93
94     g->GetCellIndex(r.absId,  r.nSupMod, r.nModule, r.nIphi, r.nIeta);
95     g->GetCellPhiEtaIndexInSModule(r.nSupMod,r.nModule,r.nIphi,r.nIeta, r.iPhi,r.iEta);
96     g->GetModulePhiEtaIndexInSModule(r.nSupMod,r.nModule, r.iPhim, r.iEtam); 
97
98     t->AddAt(&r);
99   }
100   return t;
101 }