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