EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LqstGeoParData.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LqstGeoParData.cxx
1 //
2 // RMP (rpetti@bnl.gov), 09-10-2014
3 //
4 // Low Q^2 tagging detector specific data definitions
5 //
6 
7 #include <iostream>
8 
9 #include "TGeoBBox.h"
10 #include "EicGeoMap.h"
11 #include "TMath.h"
12 
13 #include <LqstGeoParData.h>
14 
15 //#include <CalorimeterGeoParData.h>
16 
17 using namespace std;
18 
19 TGeoVolume *LqstCell::createCell(LqstGeoParData *detector, TString name)
20 {
21  //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22  // create each individual detector element
23  /*
24  TGeoTrd1 *element = new TGeoTrd1("detectorElement",
25  0.1*LqstGeoParData::cellFaceSize/2.,
26  0.1*LqstGeoParData::cellFaceSize/8.,
27  0.1*LqstGeoParData::cellFaceSize/2.,
28  0.1*LqstGeoParData::cellLength/2.);
29 
30  */
31 
32  TGeoBBox *element = new TGeoBBox(name,
33  detector->get_cellFaceSize()/2.,
34  detector->get_cellFaceSize()/2.,
35  detector->get_cellFaceLength()/2.);
36 
37  TGeoVolume *velement = new TGeoVolume(name, element, detector->GetMedium(_DIAMOND_));
38 
39  velement->SetLineColor(kYellow);
40  velement->SetFillColor(kYellow);
41 
42  return velement;
43 
44 }
45 
46 TGeoVolume *LqstCell::createCell(LqstGeoParData *detector, TString name, double length)
47 {
48  //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
49  // create each individual detector element
50 
51  // this is meant to be used for the ecal sector
52 
53  /*
54 
55  TGeoTrd1 *element = new TGeoTrd1("detectorElement",
56  0.1*LqstGeoParData::cellFaceSize/2.,
57  0.1*LqstGeoParData::cellFaceSize/8.,
58  0.1*LqstGeoParData::cellFaceSize/2.,
59  0.1*LqstGeoParData::cellLength/2.);
60 
61  */
62 
63  Double_t alveoleThickness = 0.1*0.2; // was 0.01*0.2
64  Double_t cellEnvelopeWidth = detector->get_cellFaceSize() + 2.*alveoleThickness;
65  Double_t cellEnvelopeLength = length + 2.*alveoleThickness;
66 
67  TString nameAlveole = name;
68  nameAlveole = nameAlveole.Append("Alveole");
69 
70  TGeoBBox *alveole = new TGeoBBox(nameAlveole,
71  cellEnvelopeWidth/2.,
72  cellEnvelopeWidth/2.,
73  cellEnvelopeLength/2.);
74  TGeoVolume *valveole = new TGeoVolume(nameAlveole, alveole, detector->GetMedium("CarbonFiber"));
75 
76  // crystal volume inside alveole
77  TGeoBBox *crystal = new TGeoBBox(name,
78  detector->get_cellFaceSize()/2.,
79  detector->get_cellFaceSize()/2.,
80  length/2.);
81 
82  TGeoVolume *vcrystal = new TGeoVolume(name, crystal, detector->GetMedium(_DIAMOND_));
83 
84  vcrystal->SetLineColor(kBlue);
85  vcrystal->SetFillColor(kBlue);
86 
87  // place crystal into the alveole
88  valveole->AddNode(vcrystal, 0, new TGeoCombiTrans(0.0, 0.0, 0.0, new TGeoRotation()));
89 
90  valveole->SetLineColor(kBlue-1);
91  valveole->SetFillColor(kBlue-1);
92 
93  return valveole;
94 
95 }
96 
97 void LqstGeoParData::InitializeDetector(LqstGeoParData *det, int nlayers, int nX, int nY, double size, double length, double zoffset, double xoffset, double angle)
98 {
99  lqs = det;
100 
101  lqs->set_numCellsX(nX);
102  lqs->set_numCellsY(nY);
103 
104  lqs->set_cellFaceSize(size);
105  lqs->set_cellFaceLength(length);
106 
107  lqs->set_beamLineOffset(zoffset);
108  lqs->set_xOffset(xoffset);
109 
110  lqs->set_angle(angle);
111 
112  lqs->set_nGroups(nlayers);
113 
114 
115  mcell = new LqstCell();
116 
117  // makeMap();
118 
119 
120  /*
121  double volumeWidth = get_detectorWidth();
122  double volumeLength = get_detectorLength();
123  double volumeHeight = get_detectorHeight();
124  */
125 
126  // holder volume for entire detector...filled with air
127  // holder = new TGeoBBox("HolderVolume", 0.1*volumeLength/2., 0.1*volumeHeight/2., 0.1*volumeWidth/2.);
128 
129 
130  // individual cells
131  // createCell();
132 
133  // create map
134  //makeMap();
135 
136 }
137 
138 
140 {
141 
142  unsigned tcounter = 0;
143 
144 
145  TGeoVolume *cell = (TGeoVolume*)mcell->createCell(lqs, "trackerCell");
146 
147  EicGeoMap *gmapT = lqs->CreateNewMap();
148  gmapT->AddGeantVolumeLevel("trackerCell", lqs->get_nGroups()*lqs->get_totalNumCells());
149  gmapT->SetSingleSensorContainerVolume("trackerCell");
150 
151 
152  // for tracking layers (group 0)
153  lqs->AddLogicalVolumeGroup(nCellsX, nCellsY, lqs->get_nGroups());
154 
155  for(int ilay = 0; ilay<lqs->get_nGroups(); ilay++)
156  {
157 
158  double offset = ilay*10. + 1. + 25./2.;
159 
160  for(unsigned ix=0; ix<nCellsX; ix++)
161  {
162  // double xx = cellFaceSize*(ix-1./2.);
163 
164  double xx = cellFaceSize*(ix - (nCellsX-1)/2.);
165 
166  for(unsigned iy=0; iy<nCellsY; iy++)
167  {
168  double yy = cellFaceSize*(iy - (nCellsY-1)/2.);
169 
170  //=-=-==-=-
171  // used to create the mapping function
172  //UInt_t geant[1] = {ilay}, lgroup = 0, logical[3] = {ix, iy, ilay};
173  UInt_t geant[1] = {tcounter}, group=0, logical[3] = {ix, iy, ilay};
174 
175  if(lqs->SetMappingTableEntry(gmapT, geant, group, logical))
176  {
177  cout << "Failed to set mapping table entry!" << endl;
178  exit(0);
179  }
180 
181  //lqs->GetTopVolume()->AddNode( mcell->createCell(lqs, "trackerCell"), tcounter++, new TGeoCombiTrans( xx, yy, offset, new TGeoRotation()) );
182  lqs->GetTopVolume()->AddNode( cell, tcounter++, new TGeoCombiTrans( xx, yy, offset, new TGeoRotation()) );
183  //lqs->AddNode( mcell->createCell(lqs), tcounter++, new TGeoCombiTrans( xx, yy, offset, new TGeoRotation()) );
184  } // for (iy)
185 
186  } // for (ix)
187 
188  // tcounter = 0;
189  }
190 
191 
192 }
193 
195 {
196 
197  // for now assume the same cell size for emcal as for tracking layers
198 
199  unsigned tcounter = 0;
200 
201 
202  // for ecal layers (group 1)
203  UInt_t lgroup = lqs->AddLogicalVolumeGroup(nCellsX, nCellsY);
204 
205  TGeoVolume *cell = (TGeoVolume*)mcell->createCell(lqs, "ecalCell", ecalTowerLength);
206 
207  // create a CalorimeterGeoParData object here so that
208  // geometry parameters can be stored and retrieved
209  // as other calorimeter systems (for use in digitization step)
210  //mEcalTowerLength = lqs->GetEcalTowerLength(); // was hard set to 100
211 
212  double offset = -(30. + 1. - ecalTowerLength/2.);
213  //double offset = -mCellLength/2.;
214 
215  EicGeoMap *gmapCr = lqs->CreateNewMap();
216  //gmapE->AddGeantVolumeLevel("ecal", 1);
217  gmapCr->AddGeantVolumeLevel("ecalCell", 1);
218  gmapCr->AddGeantVolumeLevel("ecalCellAlveole", lqs->get_totalNumCells());
219  gmapCr->SetSingleSensorContainerVolume("ecalCellAlveole");
220 
221  /*
222  // Perhaps want to make alveoles GEANT sensitive volumes as well (say, to check
223  // energy losses there) -> create a separate map;
224  EicGeoMap *gmapAl = lqs->CreateNewMap();
225  // N*N alveole packs;
226  gmapAl->AddGeantVolumeLevel("ecalCellAlveole", lqs->get_totalNumCells());
227  gmapAl->SetSingleSensorContainerVolume("ecalCellAlveole");
228  */
229 
230  for(unsigned ix=0; ix<nCellsX; ix++)
231  {
232 
233  // enter the cell envelope, make room for aveole enclosure of size 0.2mm
234  double xx = (cellFaceSize + 2.*0.1*0.2)*(ix - (nCellsX-1)/2.);
235 
236  for(unsigned iy=0; iy<nCellsY; iy++)
237  {
238  double yy = (cellFaceSize + 2.*0.1*0.2)*(iy - (nCellsY-1)/2.);
239 
240  //=-=-==-=-
241  // used to create the mapping function
242  //UInt_t geant[1] = {tcounter}, lgroup = 1, logical[3] = {ix, iy};
243  UInt_t geant[2] = {0, tcounter}, logical[2] = {ix, iy};
244 
245  //if(lqs->SetMappingTableEntry(gmapCr, geant+0, lgroup, logical) ||
246  // lqs->SetMappingTableEntry(gmapAl, geant+1, lgroup, logical))
247  if(lqs->SetMappingTableEntry(gmapCr, geant+0, lgroup, logical) )
248  {
249  cout << "Failed to set mapping table entry!" << endl;
250  exit(0);
251  }
252 
253  lqs->GetTopVolume()->AddNode( cell, tcounter++, new TGeoCombiTrans( xx, yy, offset, new TGeoRotation()) );
254  //lqs->GetTopVolume()->AddNode( mcell->createCell(lqs, "ecalCell", ecalTowerLength), tcounter++, new TGeoCombiTrans( xx, yy, offset, new TGeoRotation()) );
255 
256  } // end iy loop
257  } // end ix loop
258 
259 } // end constructEcalLayers function
260 
262 {
263 
264  constructTrackerLayers();
265  constructEcalLayers();
266 
267  TGeoRotation *rotator = new TGeoRotation();
268  rotator->RotateY(totalAngle*TMath::RadToDeg());
269 
270  lqs->SetTopVolumeTransformation(new TGeoCombiTrans(xOffset, 0., beamLineOffset, rotator));
271 
272  lqs->FinalizeOutput();
273 
274 }
275