HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hemcdetector.cc
Go to the documentation of this file.
1 //*-- AUTHOR : Kirill Lapidus
2 //*-- Created :
3 //*-- modified : 20/02/2017 by Vladimir Pechenov
4 
5 //_HADES_CLASS_DESCRIPTION
6 /////////////////////////////////////////////////////////////
7 //
8 // HEmcDetector
9 //
10 // The Emc detector class
11 //
12 /////////////////////////////////////////////////////////////
13 
14 using namespace std;
15 #include "hemcdetector.h"
16 #include "emcdef.h"
17 #include "hcategory.h"
18 #include "hlinearcategory.h"
19 #include "hmatrixcategory.h"
20 #include "hgeantmaxtrk.h"
21 #include "hades.h"
22 #include "hevent.h"
23 #include "hpario.h"
24 #include "hparrootfileio.h"
25 #include "hparasciifileio.h"
26 #include "hdetpario.h"
27 #include "hemcparrootfileio.h"
28 #include "hemcparasciifileio.h"
29 #include "TClass.h"
30 #include <iostream>
31 #include <iomanip>
32 
33 ClassImp(HEmcDetector) // Emc detector class
34 
35 const Int_t HEmcDetector::cellMap[163] = { // 17 x 15
36  6, 7, 8, 9, 10,
37  23, 24, 25, 26, 27,
38  39, 40, 41, 42, 43, 44, 45,
39  56, 57, 58, 59, 60, 61, 62,
40  72, 73, 74, 75, 76, 77, 78, 79, 80,
41  89, 90, 91, 92, 93, 94, 95, 96, 97,
42  106, 107, 108, 109, 110, 111, 112, 113, 114,
43  122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
44  139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
45  155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
46  172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
47  188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
48  205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
49  221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
50  238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254
51 };
52 
53 Int_t HEmcDetector::posMap[255] = {0}; // need to initialize it for sake of the linker JAM
54 
55 HEmcDetector::HEmcDetector(void) : HDetector("Emc","The Emc detector") {
56  // constructor
57  fName="Emc";
58  maxSectors=6;
59  maxModules=1;
60  maxComponents=emcMaxRows*emcMaxColumns; // including spares (needed for parameter containers)
61  numCells=163;
62  modules = new TArrayI(getMaxSectors());
63 
64  for (Int_t i = 0; i < 255; ++i)
65  posMap[i] = -1;
66  for (Int_t i = 0; i < 163; ++i)
67  posMap[cellMap[i]] = i;
68 }
69 
71  delete modules;
72  modules = 0;
73 }
74 
75 HCategory* HEmcDetector::buildLinearCategory(const Text_t *classname, Float_t fillRate) {
76  HLinearCategory* category=new HLinearCategory(classname,(Int_t)(numCells*fillRate));
77  return category;
78 }
79 
80 HCategory *HEmcDetector::buildMatrixCategory(const Text_t* classname, Float_t fillRate) {
81  //making the categories for different types of data levels
82  HMatrixCategory* category = NULL;
83  Int_t* sizes2 = new Int_t[2];
84 
85  if (strcmp(classname,"HGeantEmc")==0) {
86  sizes2[0]= getMaxSectors();
87  sizes2[1]= MAXTRKEMC;
88  category = new HMatrixCategory(classname,2,sizes2,fillRate);
89  } else if (strcmp(classname,"HEmcRaw")==0) {
90  sizes2[0]=getMaxSectors();
91  sizes2[1]=emcMaxRows*emcMaxColumns;
92  category = new HMatrixCategory(classname,2,sizes2,fillRate);
93  } else if (strcmp(classname,"HEmcCal")==0 || strcmp(classname,"HEmcCalSim")==0) {
94  sizes2[0]=getMaxSectors();
95  sizes2[1]=emcMaxRows*emcMaxColumns;
96  category = new HMatrixCategory(classname,2,sizes2,fillRate);
97  } else if (strcmp(classname,"HEmcCluster")==0 || strcmp(classname,"HEmcClusterSim")==0) {
98  sizes2[0]=getMaxSectors();
99  sizes2[1]=emcMaxRows*emcMaxColumns;
100  category = new HMatrixCategory(classname,2,sizes2,fillRate);
101  } else {
102  sizes2[0]=getMaxSectors();
103  sizes2[1]=maxComponents;
104  category = new HMatrixCategory(classname,2,sizes2,fillRate);
105  }
106  delete [] sizes2;
107  return category;
108 }
109 
111  // builds the categories for the Emc
112  // gets the category if existing
113  // builts and adds if not existing
114  // returns the pointer to the category or zero
115  HCategory *pcat = gHades->getCurrentEvent()->getCategory(cat);
116  if (pcat) return (pcat); // already existing
117  switch (cat) {
118  case catEmcRaw :
119  pcat = buildMatrixCategory("HEmcRaw",0.5);
120  break;
121  case catEmcCal :
122  pcat = buildMatrixCategory("HEmcCal",0.5);
123  break;
124  case catEmcCalQA :
125  pcat = buildMatrixCategory("HEmcCalQA",0.5);
126  break;
127  case catEmcCluster :
128 // pcat = buildLinearCategory("HEmcCluster",0.5);
129  pcat = buildMatrixCategory("HEmcCluster",0.5);
130  break;
131  default :
132  pcat = NULL;
133  }
134  if (pcat) gHades->getCurrentEvent()->addCategory(cat, pcat, "Emc");
135  return (pcat);
136 }
137 
139  // activates the input/output class for the Emc parameters
140  if (strcmp(io->IsA()->GetName(),"HParOraIo")==0) {
141  io->setDetParIo("HEmcParIo");
142  return;
143  }
144  if (strcmp(io->IsA()->GetName(),"HParRootFileIo")==0) {
145  HEmcParRootFileIo* p=new HEmcParRootFileIo(((HParRootFileIo*)io)->getParRootFile());
146  io->setDetParIo(p);
147  }
148  if (strcmp(io->IsA()->GetName(),"HParAsciiFileIo")==0) {
149  HEmcParAsciiFileIo* p=new HEmcParAsciiFileIo(((HParAsciiFileIo*)io)->getFile());
150  io->setDetParIo(p);
151  }
152 }
153 
155  // writes the Emc setup to output
156  HDetParIo* out=output->getDetParIo("HEmcParIo");
157  if (out) return out->write(this);
158  return kFALSE;
159 }
160 
161 Int_t HEmcDetector::getCell(const Char_t row, const Char_t col) {
162  // returns the cell index
163  if (row<0 || row>=emcMaxRows || col<0 || col>=emcMaxColumns) return -1;
164  else return row*emcMaxColumns + col;
165 }
166 
167 void HEmcDetector::getRowCol(const Int_t cell, Char_t& row, Char_t& col) {
168  // returns the row and column indexes
169  if (cell>=0 && cell<emcMaxComponents) {
170  row=(Char_t)(cell/emcMaxColumns);
171  col=(Char_t)(cell%emcMaxColumns);
172  } else row=col=-1;
173 }
174 
176  // returns the maximum number of modules in the actual setup
177  Int_t maxSec = -1;
178  for (Int_t i = 0; i < maxSectors; i++) {
179  if (modules->At(i)) maxSec = (i > maxSec) ? i : maxSec;
180  }
181  maxSec++;
182  return maxSec;
183 }
184 
186 {
187  if (pos >= 0 && pos < 163)
188  return cellMap[pos];
189  return -1;
190 }
191 
193 {
194  if (cell >= 0 && cell < 255)
195  return posMap[cell];
196  return -1;
197 }
virtual Bool_t addCategory(Cat_t aCat, HCategory *cat, Option_t opt[])=0
static Int_t getPositionFromCell(Int_t cell)
Bool_t write(HParIo *io)
HCategory * buildLinearCategory(const Text_t *, Float_t)
Definition: hemcdetector.cc:75
static const Int_t cellMap[163]
Definition: hemcdetector.h:10
HCategory * buildCategory(Cat_t cat)
Short_t Cat_t
Definition: haddef.h:8
Int_t maxComponents
Definition: hdetector.h:17
virtual ~HEmcDetector(void)
Definition: hemcdetector.cc:70
HEvent *& getCurrentEvent(void)
Definition: hades.cc:422
virtual void setDetParIo(HDetParIo *)
Definition: hpario.cc:34
void activateParIo(HParIo *io)
Int_t getMaxSectors(void)
Definition: hdetector.h:23
Int_t maxSectors
Definition: hdetector.h:15
static Int_t getCellFromPosition(Int_t pos)
virtual HDetParIo * getDetParIo(const Text_t *)
Definition: hpario.cc:50
Definition: hpario.h:11
const Cat_t catEmcCluster
Definition: emcdef.h:10
Int_t getMaxSecInSetup(void)
Int_t maxModules
Definition: hdetector.h:16
Hades * gHades
Definition: hades.cc:1213
const Int_t emcMaxColumns
Definition: emcdef.h:13
const Cat_t catEmcCalQA
Definition: emcdef.h:9
return output
ClassImp(HEmcDetector) const Int_t HEmcDetector
Definition: hemcdetector.cc:33
HEmcDetector(void)
Definition: hemcdetector.cc:55
const Cat_t catEmcRaw
Definition: emcdef.h:7
HCategory * buildMatrixCategory(const Text_t *, Float_t)
Definition: hemcdetector.cc:80
const Int_t emcMaxComponents
Definition: emcdef.h:15
const Cat_t catEmcCal
Definition: emcdef.h:8
virtual HCategory * getCategory(Cat_t aCat)=0
virtual Int_t write(HParSet *)
Definition: hdetpario.h:30
#define MAXTRKEMC
Definition: hgeantmaxtrk.h:10
static Int_t posMap[255]
Definition: hemcdetector.h:11
static Int_t getCell(const Char_t row, const Char_t col)
TArrayI * modules
Definition: hdetector.h:18
const Int_t emcMaxRows
Definition: emcdef.h:12
Int_t numCells
Definition: hemcdetector.h:9
static void getRowCol(const Int_t cell, Char_t &row, Char_t &col)