CbmRoot
Loading...
Searching...
No Matches
CbmMuchSegmentAuto.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Mikhail Ryzhinskiy [committer], Florian Uhlig */
4
13#include "CbmMuchSegmentAuto.h"
14
15#include "CbmGeoMuchPar.h" // for CbmGeoMuchPar
16#include "CbmMuchAddress.h" // for CbmMuchAddress
17#include "CbmMuchLayer.h" // for CbmMuchLayer
18#include "CbmMuchLayerSide.h" // for CbmMuchLayerSide
19#include "CbmMuchModule.h" // for CbmMuchModule
20#include "CbmMuchModuleGem.h" // for CbmMuchModuleGem
21#include "CbmMuchPoint.h" // for CbmMuchPoint
22#include "CbmMuchSectorRectangular.h" // for CbmMuchSectorRectangular
23#include "CbmMuchStation.h" // for CbmMuchStation
24
25#include <FairRootManager.h> // for FairRootManager
26#include <FairRuntimeDb.h> // for FairRuntimeDb
27#include <FairTask.h> // for FairTask, InitStatus, kSUCCESS
28
29#include <TArc.h> // for TArc
30#include <TAxis.h> // for TAxis
31#include <TCanvas.h> // for TCanvas
32#include <TClonesArray.h> // for TClonesArray
33#include <TF1.h> // for TF1
34#include <TFile.h> // for TFile, gFile
35#include <TH1.h> // for TH1D
36#include <TMath.h> // for Sqrt, Log2, Pi
37#include <TMathBase.h> // for Abs
38#include <TObjArray.h> // for TObjArray
39#include <TStyle.h> // for TStyle, gStyle
40#include <TSystem.h> // for TSystem, gSystem
41#include <TVector3.h> // for TVector3
42
43#include <cassert> // for assert
44#include <cmath> // for exp
45#include <cstdio> // for printf, fprintf, fclose
46#include <iosfwd> // for string
47#include <limits> // for numeric_limits
48
49using std::string;
50
51// ----- Default constructor -------------------------------------------
53 : FairTask()
54 , fEvents(0)
55 , fPoints(nullptr)
57 , fNStations(0)
58 , fStations(nullptr)
60 , fGeoPar(nullptr)
61 , fExp0()
62 , fExp1()
63 , fSigmaXmin()
64 , fSigmaYmin()
65 , fSigmaXmax()
66 , fSigmaYmax()
68{
69}
70// -------------------------------------------------------------------------
71
72// ----- Standard constructor ------------------------------------------
74 : FairTask()
75 , fEvents(0)
76 , fPoints(nullptr)
78 , fNStations(0)
79 , fStations(nullptr)
80 , fDigiFileName(digiFileName)
81 , fGeoPar(nullptr)
82 , fExp0()
83 , fExp1()
84 , fSigmaXmin()
85 , fSigmaYmin()
86 , fSigmaXmax()
87 , fSigmaYmax()
89{
90}
91// -------------------------------------------------------------------------
92
93// ----- Destructor ----------------------------------------------------
95// -------------------------------------------------------------------------
96
98{
99 fNStations = nStations;
100 fSigmaXmin.resize(fNStations);
101 fSigmaYmin.resize(fNStations);
102 fSigmaXmax.resize(fNStations);
103 fSigmaYmax.resize(fNStations);
105}
106
107void CbmMuchSegmentAuto::SetSigmaMin(Double_t* sigmaXmin, Double_t* sigmaYmin)
108{
109 for (Int_t iStation = 0; iStation < fNStations; ++iStation) {
110 fSigmaXmin.at(iStation) = sigmaXmin[iStation];
111 fSigmaYmin.at(iStation) = sigmaYmin[iStation];
112 }
113}
114void CbmMuchSegmentAuto::SetSigmaMax(Double_t* sigmaXmax, Double_t* sigmaYmax)
115{
116 for (Int_t iStation = 0; iStation < fNStations; ++iStation) {
117 fSigmaXmax.at(iStation) = sigmaXmax[iStation];
118 fSigmaYmax.at(iStation) = sigmaYmax[iStation];
119 }
120}
121
122void CbmMuchSegmentAuto::SetOccupancyMax(Double_t* occupancyMax)
123{
124 for (Int_t iStation = 0; iStation < fNStations; ++iStation) {
125 fOccupancyMax.at(iStation) = occupancyMax[iStation];
126 }
127}
128
129// ----- Private method SetParContainers --------------------------------
131{
132 // Get runtime database
133 FairRuntimeDb* db = FairRuntimeDb::instance();
134 if (!db) Fatal("SetParContainers", "No runtime database");
135 // Get MUCH geometry param
136 fGeoPar = (CbmGeoMuchPar*) db->getContainer("CbmGeoMuchPar");
137}
138// -------------------------------------------------------------------------
139
140
141// ----- Private method Init --------------------------------------------
143{
144 FairRootManager* fManager = FairRootManager::Instance();
145 fPoints = (TClonesArray*) fManager->GetObject("MuchPoint");
146 fEvents = 0;
147
148 fStations = fGeoPar->GetStations();
149 if (!fStations) Fatal("Init", "No input array of MUCH stations.");
150 if (fNStations != fStations->GetEntriesFast()) Fatal("Init", "Incorrect number of stations set.");
151 //fNStations = fStations->GetEntriesFast();
152 fHistHitDensity = new TH1D*[fNStations];
153
154 for (Int_t i = 0; i < fNStations; i++) {
155 // CbmMuchStation* station = (CbmMuchStation*) fStations->At(i);
156 fHistHitDensity[i] = new TH1D(Form("hStation%i", i + 1), Form("Station %i", i + 1), 110, 0, 220);
157 fHistHitDensity[i]->GetXaxis()->SetTitle("r, cm");
158 fHistHitDensity[i]->GetYaxis()->SetTitle("hits/(event#timescm^{2})");
159 fHistHitDensity[i]->SetLineColor(4);
160 fHistHitDensity[i]->SetLineWidth(2);
161 fHistHitDensity[i]->GetYaxis()->SetTitleOffset(1.27);
162 }
163 return kSUCCESS;
164}
165// -------------------------------------------------------------------------
166
167// -------------------------------------------------------------------------
169{
170 fEvents++;
171 printf("Event: %i\n", fEvents);
172
173 gStyle->SetOptStat(0);
174 for (Int_t iPoint = 0; iPoint < fPoints->GetEntriesFast(); iPoint++) {
175 CbmMuchPoint* point = (CbmMuchPoint*) fPoints->At(iPoint);
176 if (!point) continue;
177 Int_t iStation = CbmMuchAddress::GetStationIndex(point->GetDetectorID());
178 // CbmMuchStation* station = (CbmMuchStation*) fStations->At(iStation);
179 // if (station->GetDetectorType()==2) continue;
180
181 Int_t iLayer = CbmMuchAddress::GetLayerIndex(point->GetDetectorID());
182 // printf("iStation = %i\n", iStation);
183 // printf("detId = %qd\n", point->GetDetectorID());
184 // printf("iPoint = %i\n", iPoint);
185 assert(iStation >= 0 && iStation < fNStations);
186 if (iLayer) continue;
187 TVector3 pos;
188 point->Position(pos);
189 ((TH1D*) fHistHitDensity[iStation])->Fill(pos.Pt());
190 }
191}
192// -------------------------------------------------------------------------
193
194// -------------------------------------------------------------------------
196{
197 // Create normalization histo
198 TH1D* hNorm = new TH1D("hNorm", "", 110, 0, 220);
199 Double_t binSize = 2.;
200 for (Int_t l = 0; l < 100; l++) {
201 Double_t R1 = l * binSize;
202 Double_t R2 = (l + 1) * binSize;
203 Double_t s = TMath::Pi() * (R2 * R2 - R1 * R1);
204 hNorm->SetBinContent(l + 1, s * fEvents);
205 }
206
207 for (Int_t i = 0; i < fNStations; i++) {
208 CbmMuchStation* station = (CbmMuchStation*) fStations->At(i);
209 TH1D* h = fHistHitDensity[i];
210 h->Divide(hNorm);
211 TCanvas* c1 = new TCanvas(Form("cStation%i", i + 1), Form("Station %i", i + 1), 10, 10, 500, 500);
212 c1->SetLogy();
213 c1->SetLeftMargin(0.12);
214 c1->SetRightMargin(0.08);
215 TF1* f1 = new TF1("f1", "exp([0] + [1]*x)");
216 f1->SetParameter(0, 0.5);
217 f1->SetParameter(1, -0.1);
218 h->Fit("f1", "QLL", "", station->GetRmin(), station->GetRmax());
219 Double_t exp0 = h->GetFunction("f1")->GetParameter(0);
220 Double_t exp1 = h->GetFunction("f1")->GetParameter(1);
221 fExp0.push_back(exp0);
222 fExp1.push_back(exp1);
223
224 h->Draw();
225 c1->Print(Form("%s/hd_station%i.eps", gSystem->DirName(fDigiFileName), i + 1));
226 c1->Print(Form("%s/hd_station%i.png", gSystem->DirName(fDigiFileName), i + 1));
227 }
228
229 for (Int_t i = 0; i < fNStations; i++) {
230 CbmMuchStation* station = (CbmMuchStation*) fStations->At(i);
231 //if (station->GetDetectorType()==2) continue;
232
233 Int_t nLayers = station->GetNLayers();
234 for (Int_t iLayer = 0; iLayer < nLayers; iLayer++) {
235 CbmMuchLayer* layer = station->GetLayer(iLayer);
236 if (!layer) Fatal("Init", "Incomplete layers array.");
237 // Get layer sides
238 InitLayerSide(layer->GetSideF());
239 InitLayerSide(layer->GetSideB());
240 }
241 printf("Station%i segmented\n", i + 1);
242 }
243
245 TFile* oldFile = gFile;
246 TDirectory* oldDir = gDirectory;
247
248 // Save parameters
249 TFile* f = new TFile(fDigiFileName, "RECREATE");
250 fStations->Write("stations", 1);
251
252 f->Close();
254 gFile = oldFile;
255 gDirectory = oldDir;
256
258
259 Print();
260}
261// -------------------------------------------------------------------------
262
263
264// ----- Private method InitLayerSide -----------------------------------
266{
267 if (!layerSide) Fatal("Init", "Incomplete layer sides array.");
268 Int_t nModules = layerSide->GetNModules();
269 for (Int_t iModule = 0; iModule < nModules; iModule++) {
270 CbmMuchModule* mod = layerSide->GetModule(iModule);
271 if (mod->GetDetectorType() != 1) continue;
272 CbmMuchModuleGem* module = (CbmMuchModuleGem*) mod;
273 SegmentModule(module);
274 }
275}
276// -------------------------------------------------------------------------
277
278
279// ----- Private method SegmentModule -----------------------------------
281{
282 TVector3 modSize = module->GetSize();
283 Double_t modLx = modSize.X();
284 Double_t modLy = modSize.Y();
285 Double_t modLz = modSize.Z();
286 TVector3 modPosition = module->GetPosition();
287 Double_t modX = modPosition.X();
288 Double_t modY = modPosition.Y();
289 Double_t modZ = modPosition.Z();
290
291 Bool_t result = modLx > modLy;
292 Int_t iRatio = (result) ? (Int_t)((modLx + 1e-3) / modLy) : (Int_t)((modLy + 1e-3) / modLx);
293 Int_t detectorId = module->GetDetectorId();
294 Double_t secLx = (result) ? modLx / iRatio : modLx;
295 Double_t secLy = (result) ? modLy : modLy / iRatio;
296 for (Int_t i = 0; i < iRatio; i++) {
297 Double_t secX = (result) ? modX - modLx / 2. + (i + 0.5) * secLx : modX;
298 Double_t secY = (result) ? modY : modY - modLy / 2. + (i + 0.5) * secLy;
299 Int_t iSector = module->GetNSectors();
300
301 TVector3 sectorPosition(secX, secY, modZ);
302 TVector3 sectorSize(secLx, secLy, modLz);
304 new CbmMuchSectorRectangular(detectorId, iSector, sectorPosition, sectorSize, 8, 16);
305 SegmentSector(module, sector);
306 }
307}
308// -------------------------------------------------------------------------
309
310// ----- Private method SegmentSector ------------------------------------
312{
313 TVector3 secSize = sector->GetSize();
314 TVector3 secPosition = sector->GetPosition();
315 Int_t detectorId = module->GetDetectorId();
316 Int_t iStation = CbmMuchAddress::GetStationIndex(detectorId);
317 Int_t iLayer = CbmMuchAddress::GetLayerIndex(detectorId);
318 Int_t iSide = CbmMuchAddress::GetLayerSideIndex(detectorId);
319 Int_t iModule = CbmMuchAddress::GetModuleIndex(detectorId);
320 Double_t secLx = secSize.X();
321 Double_t secLy = secSize.Y();
322 Double_t secLz = secSize.Z();
323 Double_t secX = secPosition.X();
324 Double_t secY = secPosition.Y();
325 Double_t secZ = secPosition.Z();
326
327 assert(CbmMuchAddress::GetStationIndex(sector->GetAddress()) == iStation);
328 assert(CbmMuchAddress::GetLayerIndex(sector->GetAddress()) == iLayer);
329 assert(CbmMuchAddress::GetLayerSideIndex(sector->GetAddress()) == iSide);
330 assert(CbmMuchAddress::GetModuleIndex(sector->GetAddress()) == iModule);
331
332 Bool_t result1 = ShouldSegmentByX(sector);
333 Bool_t result2 = ShouldSegmentByY(sector);
334
335 if (result1 || result2) { delete sector; }
336 else {
337 CbmMuchStation* station = (CbmMuchStation*) fStations->At(iStation);
338 Double_t rMax = station->GetRmax();
339 if ((IntersectsRad(sector, module->GetCutRadius()) == 2) || !IntersectsRad(sector, rMax)) {
340 delete sector;
341 return;
342 }
343 module->AddSector(sector);
344 return;
345 }
346
347 Int_t iSector;
348 Double_t newSecX, newSecY, newSecLx, newSecLy;
349 Bool_t equal = TMath::Abs(secLx - secLy) < 1e-5;
350 Bool_t res = secLx > secLy;
351 TVector3 position, size;
352 if (result1 && result2) {
353 if (equal) { res = kTRUE; }
354 for (Int_t i = 0; i < 2; ++i) {
355 iSector = module->GetNSectors(); //CbmMuchGeoScheme::GetDetIdFromModule(moduleId, module->GetNSectors());
356 newSecLx = res ? secLx / 2. : secLx;
357 newSecLy = res ? secLy : secLy / 2.;
358 newSecX = res ? secX + (i - 0.5) * newSecLx : secX;
359 newSecY = res ? secY : secY + (i - 0.5) * newSecLy;
360 position.SetXYZ(newSecX, newSecY, secZ);
361 size.SetXYZ(newSecLx, newSecLy, secLz);
362 SegmentSector(module, new CbmMuchSectorRectangular(detectorId, iSector, position, size, 8, 16));
363 }
364 }
365 else if (result1 || result2) {
366 for (Int_t i = 0; i < 2; i++) {
367 iSector = module->GetNSectors(); //CbmMuchGeoScheme::GetDetIdFromModule(moduleId, module->GetNSectors());
368 newSecLx = result1 ? secLx / 2. : secLx;
369 newSecLy = result1 ? secLy : secLy / 2;
370 newSecX = result1 ? secX + (i - 0.5) * newSecLx : secX;
371 newSecY = result1 ? secY : secY + (i - 0.5) * newSecLy;
372 position.SetXYZ(newSecX, newSecY, secZ);
373 size.SetXYZ(newSecLx, newSecLy, secLz);
374 SegmentSector(module, new CbmMuchSectorRectangular(detectorId, iSector, position, size, 8, 16));
375 }
376 }
377}
378// -------------------------------------------------------------------------
379
380// ----- Private method ShouldSegmentByX ---------------------------------
382{
383 Double_t secLx = sector->GetSize()[0];
384 Double_t secLy = sector->GetSize()[1];
385 Double_t secX = sector->GetPosition()[0];
386 Double_t secY = sector->GetPosition()[1];
387
388 Double_t ulR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
389 Double_t urR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
390 Double_t blR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
391 Double_t brR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
392
393 Double_t uR = (ulR < urR) ? ulR : urR;
394 Double_t bR = (blR < brR) ? blR : brR;
395 Double_t R = (uR < bR) ? uR : bR;
396
398 //CbmMuchStationGem* station = (CbmMuchStationGem*)fStations->At(iStation);
399 // Check minimum and maximum allowed resolution
400 Double_t sigmaMax = fSigmaXmax.at(iStation); //station->GetSigmaXmax(); //[cm]
401 Double_t sigmaMin = fSigmaXmin.at(iStation); //station->GetSigmaXmin(); //[cm]
402 Double_t sigma = sector->GetSigmaX();
403 if (sigma > sigmaMin && sigma / 2. < sigmaMin) return false;
404 if (sigma > sigmaMax) return true;
405 // Check for occupancy
406 Double_t hitDensity = exp(fExp0.at(iStation) + fExp1.at(iStation) * R);
407 Double_t occupancyMax = fOccupancyMax.at(iStation); //station->GetOccupancyMax();
408 Double_t sPad = secLx * secLy / 128.;
409 Double_t nPads = (1.354 - 0.304 * TMath::Log2(sPad)); // number of pads fired by one track in average
410 //printf("nPads:%f\n",nPads);
411 Double_t occupancy = hitDensity * sPad * nPads;
412 if (occupancy > occupancyMax) return true;
413 return false;
414}
415// -------------------------------------------------------------------------
416
417// ----- Private method ShouldSegmentByY ---------------------------------
419{
420 Double_t secLx = sector->GetSize()[0];
421 Double_t secLy = sector->GetSize()[1];
422 Double_t secX = sector->GetPosition()[0];
423 Double_t secY = sector->GetPosition()[1];
424
425 Double_t ulR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
426 Double_t urR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
427 Double_t blR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
428 Double_t brR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
429
430 Double_t uR = (ulR < urR) ? ulR : urR;
431 Double_t bR = (blR < brR) ? blR : brR;
432 Double_t R = (uR < bR) ? uR : bR;
433
435 //CbmMuchStationGem* station = (CbmMuchStationGem*)fStations->At(iStation);
436 // Check minimum and maximum allowed resolution
437 Double_t sigmaMax = fSigmaYmax.at(iStation); //station->GetSigmaYmax(); //[cm]
438 Double_t sigmaMin = fSigmaYmin.at(iStation); //station->GetSigmaYmin(); //[cm]
439 Double_t sigma = sector->GetSigmaY();
440 if (sigma > sigmaMin && sigma / 2. < sigmaMin) return false;
441 if (sigma > sigmaMax) return true;
442 // Check for occupancy
443 Double_t hitDensity = exp(fExp0.at(iStation) + fExp1.at(iStation) * R);
444 Double_t occupancyMax = fOccupancyMax.at(iStation); //station->GetOccupancyMax();
445 Double_t sPad = secLx * secLy / 128.;
446 Double_t nPads = (1.354 - 0.304 * TMath::Log2(sPad)); // number of pads fired by one track in average
447 Double_t occupancy = hitDensity * sPad * nPads;
448 if (occupancy > occupancyMax) return true;
449 return false;
450}
451// -------------------------------------------------------------------------
452
453
454// ----- Private method IntersectsHole -----------------------------------
456{
457 if (radius < 0) return 0;
458
459 Int_t intersects = 0;
460
461 Double_t secLx = sector->GetSize()[0];
462 Double_t secLy = sector->GetSize()[1];
463 Double_t secX = sector->GetPosition()[0];
464 Double_t secY = sector->GetPosition()[1];
465
466 Double_t ulR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
467 Double_t urR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
468 Double_t blR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
469 Double_t brR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
470
471 if (ulR < radius) intersects++;
472 if (urR < radius) intersects++;
473 if (blR < radius) intersects++;
474 if (brR < radius) intersects++;
475
476 if (intersects == 4) return 2;
477 if (intersects) return 1;
478 else
479 return 0;
480}
481// -------------------------------------------------------------------------
482
483void CbmMuchSegmentAuto::Print(Option_t*) const
484{
485 printf("Segmentation written to file %s\n", fDigiFileName.Data());
486 Int_t nTotSectors = 0;
487 Int_t nTotChannels = 0;
488 Int_t nTotGems = 0;
489 Int_t nTotStraws = 0;
490 printf("====================================================================="
491 "============================\n");
492 for (Int_t iStation = 0; iStation < fStations->GetEntriesFast(); ++iStation) {
493 CbmMuchStation* station = (CbmMuchStation*) fStations->At(iStation);
494 Int_t nGems = 0;
495 Int_t nStraws = 0;
496 Int_t nSectors = 0;
497 Int_t nChannels = 0;
498 Double_t padMaxLx = std::numeric_limits<Double_t>::min();
499 Double_t padMinLx = std::numeric_limits<Double_t>::max();
500 Double_t padMaxLy = std::numeric_limits<Double_t>::min();
501 Double_t padMinLy = std::numeric_limits<Double_t>::max();
502 if (!station) continue;
503 for (Int_t iLayer = 0; iLayer < station->GetNLayers(); ++iLayer) {
504 CbmMuchLayer* layer = station->GetLayer(iLayer);
505 if (!layer) continue;
506 for (Int_t iSide = 0; iSide < 2; ++iSide) {
507 CbmMuchLayerSide* side = layer->GetSide(iSide);
508 if (!side) continue;
509 for (Int_t iModule = 0; iModule < side->GetNModules(); ++iModule) {
510 CbmMuchModule* mod = side->GetModule(iModule);
511 if (!mod) continue;
512 switch (mod->GetDetectorType()) {
513 case 1: { // GEMs
514 CbmMuchModuleGem* module = (CbmMuchModuleGem*) mod;
515 if (!module) continue;
516 nGems++;
517 nSectors += module->GetNSectors();
518 for (Int_t iSector = 0; iSector < module->GetNSectors(); ++iSector) {
519 CbmMuchSectorRectangular* sector = (CbmMuchSectorRectangular*) module->GetSector(iSector);
520 if (!sector) continue;
521 Double_t padLx = sector->GetPadDx();
522 Double_t padLy = sector->GetPadDy();
523 if (padLx > padMaxLx) padMaxLx = padLx;
524 if (padLx < padMinLx) padMinLx = padLx;
525 if (padLy > padMaxLy) padMaxLy = padLy;
526 if (padLy < padMinLy) padMinLy = padLy;
527 nChannels += sector->GetNChannels();
528 }
529 break;
530 }
531 case 2: // Straw tubes
532 nStraws++;
533 break;
534 }
535 }
536 }
537 }
538 printf("Station %i:\n", iStation + 1);
539 printf(" GEM modules: %i\n", nGems);
540 if (nGems)
541 printf(" Sectors: %i, Pads: %i, Min.Pad size:%3.2fx%3.2f, Max.Pad "
542 "size:%3.2fx%3.2f\n",
543 nSectors, nChannels, padMinLx, padMinLy, padMaxLx, padMaxLy);
544 printf(" Straw modules: %i\n", nStraws);
545 nTotSectors += nSectors;
546 nTotChannels += nChannels;
547 nTotGems += nGems;
548 nTotStraws += nStraws;
549 }
550 printf("---------------------------------------------------------------------"
551 "----------------------------\n");
552 printf(" Summary: \n GEM modules: %i\n Sectors: %i, Pads: %i\n "
553 "Straw modules: %i\n",
554 nTotGems, nTotSectors, nTotChannels, nTotStraws);
555 printf("====================================================================="
556 "============================\n");
557}
558
560{
561 string digifile(fDigiFileName.Data());
562 Int_t startIndex = digifile.size() - 4;
563 string txtfile = digifile.erase(startIndex, 4);
564 txtfile.append("txt");
565 FILE* outfile;
566 outfile = fopen(txtfile.c_str(), "w");
567
568 // Int_t colors[] = {kGreen, kBlue, kViolet, kRed, kYellow, kOrange, kMagenta, kCyan, kSpring, kPink, kAzure, kTeal,
569 // kGreen+10, kBlue+10, kViolet+10, kRed+10, kYellow+10, kOrange+10, kMagenta+10, kCyan+10, kSpring+10, kPink+10, kAzure+10, kTeal+10};
570
571 Double_t secMinLx = std::numeric_limits<Double_t>::max();
572 Double_t secMinLy = std::numeric_limits<Double_t>::max();
573 for (Int_t iStation = 0; iStation < fNStations; ++iStation) {
574 CbmMuchStation* station = (CbmMuchStation*) fStations->At(iStation);
575 CbmMuchLayer* layer = station->GetLayer(0);
576 for (Int_t iSide = 1; iSide >= 0; iSide--) {
577 CbmMuchLayerSide* side = layer->GetSide(iSide);
578 for (Int_t iModule = 0; iModule < side->GetNModules(); ++iModule) {
579 CbmMuchModule* mod = side->GetModule(iModule);
580 if (mod->GetDetectorType() != 1) continue;
581 CbmMuchModuleGem* module = (CbmMuchModuleGem*) mod;
582 for (Int_t iSector = 0; iSector < module->GetNSectors(); ++iSector) {
583 CbmMuchSectorRectangular* sector = (CbmMuchSectorRectangular*) module->GetSector(iSector);
584 if (sector->GetSize()[0] < secMinLx) secMinLx = sector->GetSize()[0];
585 if (sector->GetSize()[1] < secMinLy) secMinLy = sector->GetSize()[1];
586 }
587 } // modules
588 } // sides
589 }
590
591 for (Int_t iStation = 0; iStation < fStations->GetEntriesFast(); ++iStation) {
592 fprintf(outfile, "=================================================================="
593 "==========\n");
594 fprintf(outfile, "Station %i\n", iStation + 1);
595 fprintf(outfile, "Sector size, cm Sector position, cm Number of pads Side "
596 "Pad size, cm\n");
597 fprintf(outfile, "------------------------------------------------------------------"
598 "----------\n");
599 TCanvas* c1 = new TCanvas(Form("station%i", iStation + 1), Form("station%i", iStation + 1), 800, 800);
600 c1->SetFillColor(0);
601 c1->Range(-250, -250, 250, 250);
602 CbmMuchStation* station = (CbmMuchStation*) fStations->At(iStation);
603 CbmMuchLayer* layer = station->GetLayer(0);
604 for (Int_t iSide = 1; iSide >= 0; iSide--) {
605 CbmMuchLayerSide* layerSide = layer->GetSide(iSide);
606 for (Int_t iModule = 0; iModule < layerSide->GetNModules(); ++iModule) {
607 CbmMuchModule* mod = layerSide->GetModule(iModule);
608 mod->SetFillStyle(0);
609 mod->Draw();
610 if (mod->GetDetectorType() != 1) continue;
611 CbmMuchModuleGem* module = (CbmMuchModuleGem*) mod;
612 for (Int_t iSector = 0; iSector < module->GetNSectors(); ++iSector) {
613 CbmMuchSectorRectangular* sector = (CbmMuchSectorRectangular*) module->GetSector(iSector);
614
615 // Int_t i = Int_t((sector->GetSize()[0]+1e-3)/secMinLx) - 1;
616 // Int_t j = Int_t((sector->GetSize()[1]+1e-3)/secMinLy) - 1;
617 // TODO
618 // sector->SetFillColor(iSide ? TColor::GetColorDark(colors[i+j]) : colors[i+j]);
619 // sector->Draw("f");
620 // sector->Draw();
621 const char* side = iSide ? "Back" : "Front";
622 fprintf(outfile, "%-4.2fx%-10.2f %-6.2fx%-12.2f %-14i %-5s ", sector->GetSize()[0],
623 sector->GetSize()[1], sector->GetPosition()[0], sector->GetPosition()[1], sector->GetNChannels(),
624 side);
625 //TODO fprintf(outfile, "%-4.2fx%-4.2f\n", sector->GetDx(), sector->GetDy());
626 } // sectors
627 } // modules
628 } // sides
629
630 // Draw a hole
631 TArc* arc = new TArc(0., 0., station->GetRmin());
632 arc->Draw();
633
634 c1->Print(Form("%s/station%i.eps", gSystem->DirName(fDigiFileName), iStation + 1));
635 c1->Print(Form("%s/station%i.png", gSystem->DirName(fDigiFileName), iStation + 1));
636 } //stations
637 fclose(outfile);
638}
639
ClassImp(CbmConverterManager)
friend fvec exp(const fvec &a)
static constexpr size_t size()
Definition KfSimdPseudo.h:2
int Int_t
bool Bool_t
static int32_t GetModuleIndex(int32_t address)
static int32_t GetLayerIndex(int32_t address)
static int32_t GetLayerSideIndex(int32_t address)
static int32_t GetStationIndex(int32_t address)
Int_t GetNModules() const
CbmMuchModule * GetModule(Int_t iModule) const
CbmMuchLayerSide * GetSide(Bool_t side)
CbmMuchLayerSide * GetSideF()
CbmMuchLayerSide * GetSideB()
Int_t GetNSectors() const
CbmMuchSector * GetSector(Int_t address)
Double_t GetCutRadius() const
Int_t GetDetectorType() const
UInt_t GetAddress() const
Int_t GetNChannels() const
virtual void Exec(Option_t *option)
std::vector< Double_t > fSigmaXmax
Bool_t ShouldSegmentByY(CbmMuchSectorRectangular *sector)
void SetOccupancyMax(Double_t *occupancyMax)
std::vector< Double_t > fSigmaYmax
virtual void SetParContainers()
void SegmentSector(CbmMuchModuleGem *module, CbmMuchSectorRectangular *sector)
Int_t IntersectsRad(CbmMuchSectorRectangular *sector, Double_t radius)
std::vector< Double_t > fExp0
std::vector< Double_t > fExp1
CbmGeoMuchPar * fGeoPar
void SetNStations(Int_t nStations)
std::vector< Double_t > fSigmaYmin
void SegmentModule(CbmMuchModuleGem *module)
Bool_t ShouldSegmentByX(CbmMuchSectorRectangular *sector)
void InitLayerSide(CbmMuchLayerSide *layerSide)
std::vector< Double_t > fOccupancyMax
void Print(Option_t *="") const
void SetSigmaMin(Double_t *sigmaXmin, Double_t *sigmaYmin)
virtual InitStatus Init()
void SetSigmaMax(Double_t *sigmaXmax, Double_t *sigmaYmax)
std::vector< Double_t > fSigmaXmin
Double_t GetRmin() const
CbmMuchLayer * GetLayer(Int_t iLayer) const
Double_t GetRmax() const
Int_t GetNLayers() const
Data class with information on a STS local track.