140 std::set<MmChamber> to_ret{};
141 std::cout<<
"Read the MicroMegas geometry tree dump from "<<
inputFile<<std::endl;
144 std::cerr<<__FILE__<<
":"<<__LINE__<<
" Failed to open "<<
inputFile<<std::endl;
149 std::cerr<<__FILE__<<
":"<<__LINE__<<
" The file "<<
inputFile<<
" does not contain the 'MmGeoModelTree'"<<std::endl;
154 TTreeReaderValue<unsigned short> stationIndex{
treeReader,
"stationIndex"};
157 TTreeReaderValue<short> multilayer{
treeReader,
"multilayer"};
162 TTreeReaderValue<std::vector<float>> stripLength{
treeReader,
"stripLength"};
164 TTreeReaderValue<std::vector<bool>> isStereo{
treeReader,
"isStereo"};
165 TTreeReaderValue<std::vector<float>> locStripCenterX{
treeReader,
"locStripCenterX"};
166 TTreeReaderValue<std::vector<float>> locStripCenterY{
treeReader,
"locStripCenterY"};
168 TTreeReaderValue<std::vector<float>> stripCenterX{
treeReader,
"stripCenterX"};
169 TTreeReaderValue<std::vector<float>> stripCenterY{
treeReader,
"stripCenterY"};
170 TTreeReaderValue<std::vector<float>> stripCenterZ{
treeReader,
"stripCenterZ"};
171 TTreeReaderValue<std::vector<float>> stripLeftEdgeX{
treeReader,
"stripLeftEdgeX"};
172 TTreeReaderValue<std::vector<float>> stripLeftEdgeY{
treeReader,
"stripLeftEdgeY"};
173 TTreeReaderValue<std::vector<float>> stripLeftEdgeZ{
treeReader,
"stripLeftEdgeZ"};
174 TTreeReaderValue<std::vector<float>> stripRightEdgeX{
treeReader,
"stripRightEdgeX"};
175 TTreeReaderValue<std::vector<float>> stripRightEdgeY{
treeReader,
"stripRightEdgeY"};
176 TTreeReaderValue<std::vector<float>> stripRightEdgeZ{
treeReader,
"stripRightEdgeZ"};
179 TTreeReaderValue<float> ActiveHeightR{
treeReader,
"ActiveHeightR"};
180 TTreeReaderValue<float> ActiveWidthS{
treeReader,
"ActiveWidthS"};
181 TTreeReaderValue<float> ActiveWidthL{
treeReader,
"ActiveWidthL"};
182 TTreeReaderValue<float> stripPitch{
treeReader,
"stripPitch"};
185 TTreeReaderValue<std::vector<float>> geoModelTransformX{
treeReader,
"GeoModelTransformX"};
186 TTreeReaderValue<std::vector<float>> geoModelTransformY{
treeReader,
"GeoModelTransformY"};
187 TTreeReaderValue<std::vector<float>> geoModelTransformZ{
treeReader,
"GeoModelTransformZ"};
189 TTreeReaderValue<std::vector<float>> stripRotCol1X{
treeReader,
"stripRotLinearCol1X"};
190 TTreeReaderValue<std::vector<float>> stripRotCol1Y{
treeReader,
"stripRotLinearCol1Y"};
191 TTreeReaderValue<std::vector<float>> stripRotCol1Z{
treeReader,
"stripRotLinearCol1Z"};
193 TTreeReaderValue<std::vector<float>> stripRotCol2X{
treeReader,
"stripRotLinearCol2X"};
194 TTreeReaderValue<std::vector<float>> stripRotCol2Y{
treeReader,
"stripRotLinearCol2Y"};
195 TTreeReaderValue<std::vector<float>> stripRotCol2Z{
treeReader,
"stripRotLinearCol2Z"};
197 TTreeReaderValue<std::vector<float>> stripRotCol3X{
treeReader,
"stripRotLinearCol3X"};
198 TTreeReaderValue<std::vector<float>> stripRotCol3Y{
treeReader,
"stripRotLinearCol3Y"};
199 TTreeReaderValue<std::vector<float>> stripRotCol3Z{
treeReader,
"stripRotLinearCol3Z"};
201 TTreeReaderValue<std::vector<float>> stripRotTransX{
treeReader,
"stripRotTranslationX"};
202 TTreeReaderValue<std::vector<float>> stripRotTransY{
treeReader,
"stripRotTranslationY"};
203 TTreeReaderValue<std::vector<float>> stripRotTransZ{
treeReader,
"stripRotTranslationZ"};
205 TTreeReaderValue<std::vector<uint8_t>> stripRotGasGap{
treeReader,
"stripRotGasGap"};
207 TTreeReaderValue<std::vector<float>> firstStripPosX{
treeReader,
"firstStripPosX"};
208 TTreeReaderValue<std::vector<float>> firstStripPosY{
treeReader,
"firstStripPosY"};
210 TTreeReaderValue<std::vector<int>> readoutSide{
treeReader,
"stripReadoutSide"};
211 TTreeReaderValue<std::vector<unsigned int>> firstStripNum{
treeReader,
"stripFirstStrip"};
219 newchamber.stationEta = (*stationEta);
220 newchamber.stationPhi = (*stationPhi);
221 newchamber.multilayer = (*multilayer);
224 newchamber.ActiveHeightR = (*ActiveHeightR);
225 newchamber.ActiveWidthS = (*ActiveWidthS);
226 newchamber.ActiveWidthL = (*ActiveWidthL);
227 newchamber.stripPitch = (*stripPitch);
229 Amg::Vector3D geoTrans{(*geoModelTransformX)[0], (*geoModelTransformY)[0], (*geoModelTransformZ)[0]};
231 geoRot.col(0) =
Amg::Vector3D((*geoModelTransformX)[1], (*geoModelTransformY)[1], (*geoModelTransformZ)[1]);
232 geoRot.col(1) =
Amg::Vector3D((*geoModelTransformX)[2], (*geoModelTransformY)[2], (*geoModelTransformZ)[2]);
233 geoRot.col(2) =
Amg::Vector3D((*geoModelTransformX)[3], (*geoModelTransformY)[3], (*geoModelTransformZ)[3]);
237 for (
size_t s = 0;
s < stripCenterX->size(); ++
s){
240 newStrip.locCenter =
Amg::Vector2D{(*locStripCenterX)[
s], (*locStripCenterY)[
s]};
241 newStrip.leftEdge =
Amg::Vector3D{(*stripLeftEdgeX)[
s], (*stripLeftEdgeY)[
s], (*stripLeftEdgeZ)[
s]};
242 newStrip.rightEdge =
Amg::Vector3D{(*stripRightEdgeX)[
s], (*stripRightEdgeY)[
s], (*stripRightEdgeZ)[
s]};
244 newStrip.gasGap = (*gasGap)[
s];
245 newStrip.channel = (*channel)[
s];
246 newStrip.isStereo = (*isStereo)[
s];
247 newchamber.channels.insert(std::move(newStrip));
250 for (
size_t l = 0;
l < stripRotGasGap->size(); ++
l){
252 newLayer.
gasGap = (*stripRotGasGap)[
l];
254 stripRot.col(0) =
Amg::Vector3D((*stripRotCol1X)[
l],(*stripRotCol1Y)[
l], (*stripRotCol1Z)[
l]);
255 stripRot.col(1) =
Amg::Vector3D((*stripRotCol2X)[
l],(*stripRotCol2Y)[
l], (*stripRotCol2Z)[
l]);
256 stripRot.col(2) =
Amg::Vector3D((*stripRotCol3X)[
l],(*stripRotCol3Y)[
l], (*stripRotCol3Z)[
l]);
257 Amg::Vector3D layTrans{(*stripRotTransX)[
l], (*stripRotTransY)[
l], (*stripRotTransZ)[
l]};
259 newLayer.firstStripPos =
Amg::Vector2D{(*firstStripPosX)[
l], (*firstStripPosY)[
l]};
260 newLayer.readoutSide = (*readoutSide)[
l];
261 newLayer.firstStrip = (*firstStripNum)[
l];
262 newchamber.layers.insert(std::move(newLayer));
265 auto insert_itr = to_ret.insert(std::move(newchamber));
266 if (!insert_itr.second) {
267 std::stringstream
err{};
268 err<<__FILE__<<
":"<<__LINE__<<
" The chamber "<<(*insert_itr.first).stationIndex
269 <<
" has already been inserted. "<<std::endl;
270 throw std::runtime_error(
err.str());
273 std::cout<<
"File parsing is finished. Found in total "<<to_ret.size()<<
" readout element dumps "<<std::endl;