er  dev
ERQTelescopeGeoComponentDoubleSi.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 "ERQTelescopeGeoComponentDoubleSi.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 //--------------------------------------------------------------------------------------------------
23 void ERQTelescopeGeoComponentDoubleSi::ConstructGeometryVolume(void) {
24  ParseXmlParameters();
25  auto* media = CreateMaterial(fMedia);
26  // ----------------- DoubleSi -----------------------------------------------
27  TGeoVolume* shell;
28  TGeoVolume* strip;
29  TGeoVolume* box;
30  fVolume = gGeoManager->MakeBox(this->GetVolumeName(), media, fSizeX / 2, fSizeY / 2, fSizeZ / 2);
31  //------------------ Silicon strip ---------------------------------------
32  Double_t stripX = fSensX / fStripCountX;
33  Double_t stripY = fSensY;
34  Double_t stripZ = fSensZ - fDeadLayerThicknessFrontSide - fDeadLayerThicknessBackSide;
35  strip = gGeoManager->MakeBox("doubleSiStrip" + fOrientAroundZ, media, stripX / 2,
36  stripY / 2,
37  stripZ / 2);
38  //------------------ Silicon box -----------------------------------------
39  Double_t boxX = stripX;
40  Double_t boxY = stripY / fStripCountY;
41  Double_t boxZ = stripZ;
42  box = gGeoManager->MakeBox("SensitiveDoubleSiBox"+fOrientAroundZ, media, boxX / 2,
43  boxY / 2,
44  boxZ / 2);
45  //------------------ STRUCTURE ---------------------------------------------
46  //----------------------- Double Si structure -------------------------------
47  //------------------ Add fibers to station along x -----------------------
48  TGeoRotation *fZeroRotation = new TGeoRotation();
49  fZeroRotation->RotateX(0.);
50  fZeroRotation->RotateY(0.);
51  fZeroRotation->RotateZ(0.);
52  for (Int_t iBox = 0; iBox < fStripCountY ; ++iBox ) {
53  Double_t translateY = (fSensY / 2) - boxY / 2 - boxY * iBox ;
54  strip->AddNode(box, iBox, new TGeoCombiTrans(0, translateY, 0, fZeroRotation));
55  }
56 
57  for (Int_t iStripX = 0; iStripX < fStripCountX; iStripX++) {
58  Double_t translateX = fSensX / 2 - stripX *(iStripX)-(stripX / 2);
59  Double_t translateZ = (fDeadLayerThicknessFrontSide - fDeadLayerThicknessBackSide)/2. ;
60  fVolume->AddNode(strip, iStripX, new TGeoCombiTrans(translateX, 0, translateZ, fZeroRotation));
61  }
62  // TGeoRotation *rotation = new TGeoRotation();
63  // rotation->RotateX(fRotation->X());
64  // rotation->RotateY(fRotation->Y());
65  // rotation->RotateZ(fRotation->Z() + deltaRotAroundZ);
66  // fVolume->AddNode(shell, fConstructedObjCount++,
67  // new TGeoCombiTrans(fPosition->X(), fPosition->Y(), fPosition->Z(), fRotation));
68 }
69 //--------------------------------------------------------------------------------------------------
70 void ERQTelescopeGeoComponentDoubleSi::ParseXmlParameters() {
71  TString xmlFile = ERTelescopeSetup::Instance()->GetXMLParametersFile();
72  TDOMParser *domParser;//
73  //gROOT->ProcessLine(".O 0");
74  domParser = new TDOMParser;
75  domParser->SetValidate(false); // do not validate with DTD
76 
77  Int_t parsecode = domParser->ParseFile(xmlFile);
78  if (parsecode < 0) {
79  LOG(FATAL) << domParser->GetParseCodeMessage(parsecode) << FairLogger::FairLogger::endl;
80  return ;
81  }
82  TXMLNode *rootNode = domParser->GetXMLDocument()->GetRootNode();
83  TXMLNode *detPartNode = rootNode->GetChildren();
84  TXMLNode *SiTypeNodes;
85  for ( ; detPartNode; detPartNode = detPartNode->GetNextNode()) { // detector's part
86  if (!strcasecmp(detPartNode->GetNodeName(), "SiTypes")) {
87  SiTypeNodes = detPartNode->GetChildren();
88  for ( ; SiTypeNodes; SiTypeNodes = SiTypeNodes->GetNextNode()) {
89  if (!strcasecmp(SiTypeNodes->GetNodeName(), "doubleSiTypes")) {
90  TXMLNode* curNode = SiTypeNodes->GetChildren()->GetNextNode();
91  for(; curNode; curNode = curNode->GetNextNode()) {
92  TList *attrList;
93  TXMLAttr *attr = 0;
94  if (curNode->HasAttributes()){
95  attrList = curNode->GetAttributes();
96  TIter next(attrList);
97  while ((attr=(TXMLAttr*)next())) {
98  if (!strcasecmp("id", attr->GetName())) {
99  break;
100  }
101  }
102  }
103  else {
104  continue;
105  }
106  if(!strcasecmp(fComponentId, attr->GetValue())) {
107  FillTwoSidedChannelAttribute(curNode->GetAttributes());
108  TXMLNode* curNode2 = curNode->GetChildren();
109  for(; curNode2; curNode2 = curNode2->GetNextNode()) {
110  if(!strcasecmp(curNode2->GetNodeName(), "doubleSiSize")) {
111  attrList = curNode2->GetAttributes();
112  attr = 0;
113  TIter nextSizeAttr(attrList);
114  while ((attr=(TXMLAttr*)nextSizeAttr())) {
115  if (!strcasecmp("doubleSiX", attr->GetName())) {
116  fSizeX = atof(attr->GetValue());
117  }
118  if (!strcasecmp("doubleSiY", attr->GetName())) {
119  fSizeY = atof(attr->GetValue());
120  }
121  if (!strcasecmp("doubleSiZ", attr->GetName())) {
122  fSizeZ = atof(attr->GetValue());
123  }
124  }
125  }
126  if(!strcasecmp(curNode2->GetNodeName(), "doubleSiSensAreaSize")) {
127  attrList = curNode2->GetAttributes();
128  attr = 0;
129  TIter nextSensSizeAttr(attrList);
130  while ((attr=(TXMLAttr*)nextSensSizeAttr())) {
131  if (!strcasecmp("doubleSiSensX", attr->GetName())) {
132  fSensX = atof(attr->GetValue());
133  }
134  if (!strcasecmp("doubleSiSensY", attr->GetName())) {
135  fSensY = atof(attr->GetValue());
136  }
137  if (!strcasecmp("doubleSiSensZ", attr->GetName())) {
138  fSensZ = atof(attr->GetValue());
139  }
140  }
141  }
142  if(!strcasecmp(curNode2->GetNodeName(), "deadLayerThicknessFrontSide")) {
143  fDeadLayerThicknessFrontSide = atof(curNode2->GetText());
144  }
145  if(!strcasecmp(curNode2->GetNodeName(), "deadLayerThicknessBackSide")) {
146  fDeadLayerThicknessBackSide = atof(curNode2->GetText());
147  }
148  if(!strcasecmp(curNode2->GetNodeName(), "stripCountX")) {
149  fStripCountX = atof(curNode2->GetText());
150  }
151  if(!strcasecmp(curNode2->GetNodeName(), "stripCountY")) {
152  fStripCountY = atof(curNode2->GetText());
153  }
154  if(!strcasecmp(curNode2->GetNodeName(), "doubleSiMedia")) {
155  fMedia = curNode2->GetText();
156  }
157  }
158  }
159  }
160  }
161  }
162  }
163  }
164 }
166