er  dev
ERQTelescopeGeoComponentCsI.cxx
1 /********************************************************************************
2  * Copyright (C) Joint Institute for Nuclear Research *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #include "ERQTelescopeGeoComponentCsI.h"
10 
11 #include "TGeoManager.h"
12 #include "TGeoMatrix.h"
13 #include <TDOMParser.h>
14 #include <TXMLAttr.h>
15 #include <TXMLNode.h>
16 #include <TList.h>
17 
18 #include "FairLogger.h"
19 
20 #include "ERTelescopeSetup.h"
21 //--------------------------------------------------------------------------------------------------
22 void ERQTelescopeGeoComponentCsI::ConstructGeometryVolume(void) {
23  ParseXmlParameters();
24  auto* media = CreateMaterial(fMedia);
25  Float_t fullX = fSizeX*fCubesCountX + fSplitSize*fCubesCountX;
26  Float_t fullY = fSizeY*fCubesCountY + fSplitSize*fCubesCountY;
27 
28  fVolume = gGeoManager->MakeBox(this->GetVolumeName(),
29  media,
30  fullX/2.,
31  fullY/2.,
32  fSizeZ/2.);
33 
34 
35  TGeoVolume* shellCsI = gGeoManager->MakeBox("CsIBoxShell", media, fSizeX / 2,
36  fSizeY / 2,
37  fSizeZ / 2);
38 
39  TGeoVolume* boxCsISensitive = gGeoManager->MakeBox("SensitiveCsIBox", media, fSizeX / 2 - fDeadLayer,
40  fSizeY / 2 - fDeadLayer,
41  fSizeZ / 2 - fDeadLayer);
42  shellCsI->AddNode(boxCsISensitive, 1, new TGeoCombiTrans(0, 0, 0, new TGeoRotation()));
43 
44  //------------------ STRUCTURE ---------------------------------------------
45  Int_t iBox = 0;
46  for (Int_t iCsIX = 0; iCsIX < fCubesCountX; iCsIX++) {
47  Double_t transX = -fullX/2 + fSizeX / 2. + fSplitSize / 2 + iCsIX *(fSizeX +fSplitSize);
48  for (Int_t iCsIY = 0; iCsIY < fCubesCountY; iCsIY++) {
49  Double_t transY = -fullY/2 + fSizeY / 2. + fSplitSize / 2 + iCsIY*(fSizeY + fSplitSize);
50  fVolume->AddNode(shellCsI, iBox++, new TGeoCombiTrans(transX,
51  transY,
52  0.,
53  new TGeoRotation()));
54  }
55  }
56 }
57 //--------------------------------------------------------------------------------------------------
58 void ERQTelescopeGeoComponentCsI::ParseXmlParameters() {
59  TString xmlFile = ERTelescopeSetup::Instance()->GetXMLParametersFile();
60  TDOMParser *domParser;//
61  //gROOT->ProcessLine(".O 0");
62  domParser = new TDOMParser;
63  domParser->SetValidate(false); // do not validate with DTD
64 
65  Int_t parsecode = domParser->ParseFile(xmlFile);
66  if (parsecode < 0) {
67  LOG(FATAL) << domParser->GetParseCodeMessage(parsecode) << FairLogger::FairLogger::endl;
68  return ;
69  }
70  TXMLNode *rootNode = domParser->GetXMLDocument()->GetRootNode();
71  TXMLNode *detPartNode = rootNode->GetChildren();
72  for ( ; detPartNode; detPartNode = detPartNode->GetNextNode()) { // detector's part
73  if (!strcasecmp(detPartNode->GetNodeName(), "CsITypes")) {
74  TXMLNode* curNode = detPartNode->GetChildren()->GetNextNode();
75  for (; curNode; curNode = curNode->GetNextNode()) {
76  TList *attrList;
77  TXMLAttr *attr = 0;
78  if (curNode->HasAttributes()) {
79  attrList = curNode->GetAttributes();
80  TIter next(attrList);
81  while ((attr=(TXMLAttr*)next())) {
82  if (!strcasecmp("id", attr->GetName())) {
83  break;
84  }
85  }
86  }
87  else {
88  continue;
89  }
90  if (!strcasecmp(fComponentId, attr->GetValue())) {
91  TXMLNode* curNode2 = curNode->GetChildren();
92  for (; curNode2; curNode2 = curNode2->GetNextNode()) {
93  if (!strcasecmp(curNode2->GetNodeName(), "CsISize")) {
94  attrList = curNode2->GetAttributes();
95  attr = 0;
96  TIter nextPlasticAttr(attrList);
97  while ((attr=(TXMLAttr*)nextPlasticAttr())) {
98  if (!strcasecmp("CsIX", attr->GetName())) {
99  fSizeX = atof(attr->GetValue());
100  }
101  if (!strcasecmp("CsIY", attr->GetName())) {
102  fSizeY = atof(attr->GetValue());
103  }
104  if (!strcasecmp("CsIZ", attr->GetName())) {
105  fSizeZ = atof(attr->GetValue());
106  }
107  }
108  }
109  if (!strcasecmp(curNode2->GetNodeName(), "cubesCountX")) {
110  fCubesCountX = atof(curNode2->GetText());
111  }
112  if (!strcasecmp(curNode2->GetNodeName(), "cubesCountY")) {
113  fCubesCountY = atof(curNode2->GetText());
114  }
115  if (!strcasecmp(curNode2->GetNodeName(), "splitSize")) {
116  fSplitSize = atof(curNode2->GetText());
117  }
118  if (!strcasecmp(curNode2->GetNodeName(), "deadLayer")) {
119  fDeadLayer = atof(curNode2->GetText());
120  }
121  if (!strcasecmp(curNode2->GetNodeName(), "CsIMedia")) {
122  fMedia = curNode2->GetText();
123  }
124  }
125  }
126  }
127  }
128  }
129 }
130 //--------------------------------------------------------------------------------------------------
131 TString ERQTelescopeGeoComponentCsI::GetBranchName(
132  ERDataObjectType objectType, OrientationAroundZ orientationAroundZ /*= OrientationAroundZ::Default*/,
133  ChannelSide side /*= ChannelSide::None*/) const {
134  return GetBranchNamePrefix(SensetiveType::CsI, objectType);
135 }
136 //--------------------------------------------------------------------------------------------------
137 std::list<OrientationAroundZ> ERQTelescopeGeoComponentCsI::GetOrientationsAroundZ() const {
138  return {OrientationAroundZ::X};
139 }
140 //--------------------------------------------------------------------------------------------------
141 std::list<ChannelSide> ERQTelescopeGeoComponentCsI::GetChannelSides() const {
142  return {ChannelSide::None};
143 }
144 //--------------------------------------------------------------------------------------------------
145 Int_t ERQTelescopeGeoComponentCsI::GetChannelFromSensetiveNodePath(
146  const TString& path, OrientationAroundZ orientation /*= OrientationAroundZ::Default*/) const {
147  TString pathWithChannelPostfix = path;
148  pathWithChannelPostfix.Remove(pathWithChannelPostfix.Last('/'), pathWithChannelPostfix.Length());
149  const TString channelStr(pathWithChannelPostfix(pathWithChannelPostfix.Last('_') + 1,
150  pathWithChannelPostfix.Length()));
151  return channelStr.Atoi();
152 }
153 //--------------------------------------------------------------------------------------------------
154 ClassImp(ERGeoComponent)
155