26#include "FairGeoInterface.h"
27#include "FairGeoLoader.h"
28#include "FairGeoMedia.h"
29#include "FairGeoMedium.h"
30#include "FairGeoNode.h"
31#include "FairGeoRootBuilder.h"
32#include "FairRootManager.h"
34#include "FairRuntimeDb.h"
35#include "FairVolume.h"
37#include "TClonesArray.h"
40#include "TGeoBoolNode.h"
41#include "TGeoCompositeShape.h"
43#include "TGeoMCGeometry.h"
44#include "TGeoManager.h"
45#include "TGeoMatrix.h"
47#include "TGeoVolume.h"
51#include "TVirtualMC.h"
77 , fMuchCollection(new TClonesArray(
"CbmMuchPoint"))
79 , flGeoPar(new TList())
85 flGeoPar->SetName(GetName());
93 : FairDetector(name, active)
105 , fMuchCollection(new TClonesArray(
"CbmMuchPoint"))
107 , flGeoPar(new TList())
137 if (gMC->IsTrackEntering()) {
139 fTime = gMC->TrackTime() * 1.0e09;
141 gMC->TrackPosition(
fPosIn);
142 gMC->TrackMomentum(
fMomIn);
149 if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
150 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
154 if (fVerboseLevel > 2) {
176 if (
fELoss == 0.)
return kFALSE;
197 TString name = vol->GetName();
198 Char_t cStationNr[3] = {name[11], name[12],
' '};
199 Int_t iStation = atoi(cStationNr) - 1;
200 Int_t iLayer = TString(name[18]).Atoi() - 1;
201 Int_t iSide = (name[19] ==
'b') ? 1 : 0;
202 Char_t cModuleNr[4] = {name[26], name[27], name[28],
' '};
203 Int_t iModule = atoi(cModuleNr) - 1;
204 if (iSide != 1 && iSide != 0) printf(
"side = %i", iSide);
210 assert(detectorId > 0);
222 if (fVerboseLevel)
Print(
"");
244 LOG(info) << fName <<
": " << nHits <<
" points registered in this event.";
257 Int_t nEntries = cl1->GetEntriesFast();
258 LOG(info) << fName <<
": " << nEntries <<
" entries to add.";
259 TClonesArray& clref = *cl2;
261 for (Int_t i = 0; i < nEntries; i++) {
263 Int_t index = oldpoint->GetTrackID() + offset;
264 oldpoint->SetTrackID(index);
268 LOG(info) << fName <<
": " << cl2->GetEntriesFast() <<
" merged entries.";
275 TVector3 momOut, Double_t time, Double_t length, Double_t eLoss)
279 Int_t
size = clref.GetEntriesFast();
280 if (fVerboseLevel > 1)
281 LOG(info) << fName <<
": Adding Point at (" << posIn.X() <<
", " << posIn.Y() <<
", " << posIn.Z()
282 <<
") cm, detector " << detID <<
", track " << trackID <<
", energy loss " << eLoss * 1e06 <<
" keV";
284 return new (clref[
size])
CbmMuchPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss);
291 TString fileName = GetGeometryFileName();
294 if (!fileName.EndsWith(
".root")) {
295 LOG(fatal) << GetName() <<
": Geometry format of file " << fileName.Data() <<
" not supported.";
298 if (fileName.Contains(
"mcbm")) {
301 LOG(info) <<
"mcbm geometry found ";
310 FairRun* fRun = FairRun::Instance();
312 Fatal(
"CreateGeometry",
"No FairRun found");
315 FairRuntimeDb* rtdb = FairRuntimeDb::instance();
325 TGeoMatrix* tempMatrix {
nullptr};
327 LOG(info) <<
"Importing MUCH geometry from ROOT file " << fgeoName.Data();
331 LOG(info) <<
"Constructing MUCH geometry from ROOT file " << fgeoName.Data();
332 FairModule::ConstructRootGeometry();
338 TGeoNode* ncave = gGeoManager->GetTopNode();
343 TGeoNode* nmuch = (TGeoNode*) ncave->GetNodes()->FindObject(objName);
344 fPassNodes->Add(nmuch);
347 TObjArray* nodes = nmuch->GetNodes();
349 for (Int_t i = 0; i < nodes->GetEntriesFast(); i++) {
350 TGeoNode* node = (TGeoNode*) nodes->At(i);
351 TString nodeName = node->GetName();
354 TObjArray* nodes1 = node->GetNodes();
356 for (Int_t j = 0; j < nodes1->GetEntriesFast(); j++) {
357 TGeoNode* node1 = (TGeoNode*) nodes1->At(j);
358 TString node1Name = node1->GetName();
360 if (node1Name.Contains(
"absblock")) fPassNodes->Add(node);
361 if (node1Name.Contains(
"muchstation")) {
363 TObjArray* layers = node1->GetNodes();
364 for (Int_t l = 0; l < layers->GetEntriesFast(); l++) {
365 TGeoNode* layer = (TGeoNode*) layers->At(l);
367 if (!TString(layer->GetName()).Contains(
"layer"))
continue;
368 TObjArray* layerNodes = layer->GetNodes();
369 for (Int_t m = 0; m < layerNodes->GetEntriesFast(); m++) {
370 TGeoNode* layerNode = (TGeoNode*) layerNodes->At(m);
371 TString layerNodeName = layerNode->GetName();
373 if (layerNodeName.Contains(
"active")) fSensNodes->Add(layerNode);
375 if (layerNodeName.Contains(
"support")) fPassNodes->Add(layerNode);
377 if (layerNodeName.Contains(
"cool")) fPassNodes->Add(layerNode);
385 fPar->setInputVersion(fRun->GetRunId(), 1);
392 TString tsname = name;
395 if (tsname.Contains(
"active")) {
396 LOG(debug1) <<
"CbmMuch::CheckIfSensitive: Register active volume: " << tsname;
@ kMuch
Muon detection system.
ClassImp(CbmMuch) CbmMuch
static constexpr size_t size()
TObjArray * GetGeoPassiveNodes()
TObjArray * GetStations()
TObjArray * GetGeoSensitiveNodes()
static int32_t GetModuleIndex(int32_t address)
static int32_t GetLayerIndex(int32_t address)
static int32_t GetLayerSideIndex(int32_t address)
static int32_t GetSystemIndex(int32_t address)
static uint32_t GetAddress(int32_t station=0, int32_t layer=0, int32_t side=0, int32_t module=0, int32_t sector=0, int32_t channel=0)
static int32_t GetStationIndex(int32_t address)
static CbmMuchGeoScheme * Instance()
void Init(TObjArray *stations, Int_t flag)
TString fVolumeName
parameter container
Int_t fVolumeID
track index
virtual void ConstructRootGeometry(TGeoMatrix *shift=NULL)
virtual Bool_t IsSensitive(const std::string &name)
Int_t fPosIndex
energy loss
CbmMuchPoint * AddHit(Int_t trackID, Int_t detID, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss)
virtual void BeginEvent()
Int_t GetDetId(FairVolume *vol)
TLorentzVector fMomIn
position
TClonesArray * fMuchCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
virtual void Print(Option_t *) const
virtual void EndOfEvent()
Bool_t CheckIfSensitive(std::string name)
virtual void ConstructGeometry()
virtual Bool_t ProcessHits(FairVolume *vol=0)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
void AddPoint(ECbmModuleId iDet)
Bool_t IsNewGeometryFile(TString &filename)
void ImportRootGeometry(TString &filename, FairModule *mod, TGeoMatrix *mat)