er  dev
ERQTelescopeGeoComponentSingleSi.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 "ERQTelescopeGeoComponentSingleSi.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 using namespace std;
23 
24 //--------------------------------------------------------------------------------------------------
25 void ERQTelescopeGeoComponentSingleSi::ConstructGeometryVolume(void) {
26  ParseXmlParameters();
27  auto* media = CreateMaterial(fMedia);
28  media->GetMaterial()->Print();
29  // ---------------- SingleSi-------------------------------------------------
30  TGeoVolume* singleSiStrip;
31  fVolume = gGeoManager->MakeBox(this->GetVolumeName(), media, fSizeX / 2., fSizeY / 2., fSizeZ / 2.);
32  //------------------ Single Si strip --------------------------------------
33  Double_t singleSiStripX = fSensX / fStripCount;
34  Double_t singleSiStripY = fSensY;
35  Double_t singleSiStripZ = fSensZ - fDeadLayerThicknessFrontSide - fDeadLayerThicknessBackSide;
36  singleSiStrip = gGeoManager->MakeBox("SensitiveSingleSiStrip", media, singleSiStripX / 2.,
37  singleSiStripY / 2., singleSiStripZ / 2.);
38  //------------------ STRUCTURE ---------------------------------------------
39  //----------------------- Single Si structure -------------------------------
40  //------------------ Add fibers to station along x -----------------------
41  for (Int_t iStrip = 0; iStrip < fStripCount; iStrip++) {
42  Double_t transX = (-1) * fSensX / 2
43  + singleSiStripX/2. + iStrip*singleSiStripX;
44  Double_t transZ = (fDeadLayerThicknessFrontSide
45  - fDeadLayerThicknessBackSide)/2.;
46  fVolume->AddNode(singleSiStrip, iStrip, new TGeoCombiTrans(transX, 0., transZ, new TGeoRotation()));
47  }
48  if (fOrientAroundZ == OrientationAroundZ::Y) {
49  fRotation.RotateZ(90.);
50  }
51 }
52 //--------------------------------------------------------------------------------------------------
53 void ERQTelescopeGeoComponentSingleSi::ParseXmlParameters() {
54  TString xmlFile = ERTelescopeSetup::Instance()->GetXMLParametersFile();
55  TDOMParser *domParser;
56  domParser = new TDOMParser;
57  domParser->SetValidate(false); // do not validate with DTD
58  Int_t parsecode = domParser->ParseFile(xmlFile);
59  if (parsecode < 0) {
60  LOG(FATAL) << domParser->GetParseCodeMessage(parsecode) << FairLogger::FairLogger::endl;
61  return ;
62  }
63  TXMLNode *rootNode = domParser->GetXMLDocument()->GetRootNode();
64  TXMLNode *detPartNode = rootNode->GetChildren();
65  TXMLNode *SiTypeNodes;
66  for ( ; detPartNode; detPartNode = detPartNode->GetNextNode()) { // detector's part
67  if (!strcasecmp(detPartNode->GetNodeName(), "SiTypes")) {
68  SiTypeNodes = detPartNode->GetChildren();
69  for ( ; SiTypeNodes; SiTypeNodes = SiTypeNodes->GetNextNode()) {
70  if (!strcasecmp(SiTypeNodes->GetNodeName(), "singleSiTypes")) {
71  TXMLNode* curNode = SiTypeNodes->GetChildren()->GetNextNode();
72  for(; curNode; curNode = curNode->GetNextNode()) {
73  TList *attrList;
74  TXMLAttr *attr = 0;
75  if (curNode->HasAttributes()){
76  attrList = curNode->GetAttributes();
77  TIter next(attrList);
78  while ((attr=(TXMLAttr*)next())) {
79  if (!strcasecmp("id", attr->GetName())) {
80  break;
81  }
82  }
83  }
84  else {
85  continue;
86  }
87  if(!strcasecmp(fComponentId, attr->GetValue())) {
88  FillTwoSidedChannelAttribute(curNode->GetAttributes());
89  TXMLNode* curNode2 = curNode->GetChildren();
90  for(; curNode2; curNode2 = curNode2->GetNextNode()) {
91  if(!strcasecmp(curNode2->GetNodeName(), "singleSiSize")) {
92  attrList = curNode2->GetAttributes();
93  attr = 0;
94  TIter nextSizeAttr(attrList);
95  while ((attr=(TXMLAttr*)nextSizeAttr())) {
96  if (!strcasecmp("singleSiX", attr->GetName())) {
97  fSizeX = atof(attr->GetValue());
98  }
99  if (!strcasecmp("singleSiY", attr->GetName())) {
100  fSizeY = atof(attr->GetValue());
101  }
102  if (!strcasecmp("singleSiZ", attr->GetName())) {
103  fSizeZ = atof(attr->GetValue());
104  }
105  }
106  }
107  if(!strcasecmp(curNode2->GetNodeName(), "singleSiSensAreaSize")) {
108  attrList = curNode2->GetAttributes();
109  attr = 0;
110  TIter nextSensSizeAttr(attrList);
111  while ((attr=(TXMLAttr*)nextSensSizeAttr())) {
112  if (!strcasecmp("singleSiSensX", attr->GetName())) {
113  fSensX = atof(attr->GetValue());
114  }
115  if (!strcasecmp("singleSiSensY", attr->GetName())) {
116  fSensY = atof(attr->GetValue());
117  }
118  if (!strcasecmp("singleSiSensZ", attr->GetName())) {
119  fSensZ = atof(attr->GetValue());
120  }
121  }
122  }
123  if(!strcasecmp(curNode2->GetNodeName(), "deadLayerThicknessFrontSide")) {
124  fDeadLayerThicknessFrontSide = atof(curNode2->GetText());
125  }
126  if(!strcasecmp(curNode2->GetNodeName(), "deadLayerThicknessBackSide")) {
127  fDeadLayerThicknessBackSide = atof(curNode2->GetText());
128  }
129  if(!strcasecmp(curNode2->GetNodeName(), "stripCount")) {
130  fStripCount = atof(curNode2->GetText());
131  }
132  if(!strcasecmp(curNode2->GetNodeName(), "singleSiMedia")) {
133  fMedia = curNode2->GetText();
134  }
135  }
136  }
137  }
138  }
139  }
140  }
141  }
142 }
143 //--------------------------------------------------------------------------------------------------
145