///////////////////////////////////////////////////////////// // PndDchDetector // // Class for PndDchDetector // ///////////////////////////////////////////////////////////// #include #include using std::cout; using std::endl; #include "TClonesArray.h" #include "TGeoMCGeometry.h" #include "TGeoManager.h" #include "TLorentzVector.h" #include "TParticle.h" #include "TVirtualMC.h" #include "TObjArray.h" #include "TString.h" #include "TGeoVoxelFinder.h" #include "TGeoMatrix.h" #include "TParticlePDG.h" #include "FairGeoInterface.h" #include "FairGeoLoader.h" #include "FairGeoNode.h" #include "FairGeoRootBuilder.h" #include "PndStack.h" #include "FairRootManager.h" #include "FairVolume.h" //#include "FairGeoG3Builder.h" #include "FairRuntimeDb.h" #include "FairRun.h" #include "FairGeoMedia.h" #include "PndDchGeo.h" #include "PndDchDetector.h" #include "PndDchPoint.h" #include "PndDchGeoPar.h" #include "PndDetectorList.h" // ----- Default constructor ------------------------------------------- PndDchDetector::PndDchDetector() { fDchPointCollection = new TClonesArray("PndDchPoint"); fPosIndex = 0; ResetParameters(); } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ PndDchDetector::PndDchDetector(const char* name, Bool_t active) : FairDetector(name, active) { fDchPointCollection = new TClonesArray("PndDchPoint"); fPosIndex = 0; ResetParameters(); } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndDchDetector::~PndDchDetector() { if (fDchPointCollection) { fDchPointCollection->Delete(); delete fDchPointCollection; } } // ------------------------------------------------------------------------- // ----- Public method ProcessHits -------------------------------------- Bool_t PndDchDetector::ProcessHits(FairVolume* vol) { TParticle* particle = gMC->GetStack()->GetCurrentTrack(); fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); fEvent = gMC->CurrentEvent(); Bool_t valid = kFALSE; gMC->CurrentVolID(fPlane); TString nam = gMC->CurrentVolName(); if(!(nam.Contains("dchSplane"))) return kFALSE; nam = gMC->CurrentVolOffName(1); nam.Remove(0,nam.Length()-1); fChamber = nam.Atoi(); if(fVerboseLevel>2) std::cout<<"III PndDchDetector::ProcessHits() : plane = "<GetEntriesFast(); cout << "-I- PndDchDetector: " << nHits << " points registered in this event." << endl; if (fVerboseLevel>1) for (Int_t i=0; iPrint(); } // ---------------------------------------------------------------------------- // ----- Public method Reset ---------------------------------------------- void PndDchDetector::Reset() { fDchPointCollection->Delete(); fPosIndex = 0; } // ---------------------------------------------------------------------------- // ----- Public method CopyClones ----------------------------------------- // void PndDchDetector::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset ) { // Int_t nEntries = cl1->GetEntriesFast(); // cout << "-I- PndDchDetector: " << nEntries << " entries to add." << endl; // TClonesArray& clref = *cl2; // PndDchPoint* oldpoint = NULL; // for (Int_t i=0; iAt(i); // Int_t index = oldpoint->GetTrackID() + offset; // oldpoint->SetTrackID(index); // new (clref[fPosIndex]) PndDchPoint(*oldpoint); // fPosIndex++; // } // cout << " -I- PndDchDetector: " << cl2->GetEntriesFast() << " merged entries." // << endl; // } // ---------------------------------------------------------------------------- // ----- Public method ConstructGeometry ---------------------------------- void PndDchDetector::ConstructGeometry() { TString fileName=GetGeometryFileName(); if (fileName.EndsWith(".geo")) { ConstructASCIIGeometry(); } else if(fileName.EndsWith(".root")) { ConstructRootGeometry(); } else { std::cout<< "Geometry format not supported " <Get("top"); // TGeoVolume *Cave = gGeoManager->GetTopVolume(); // //*** // TGeoNode* n = dchTop->GetNode(0); // // TGeoVolume* v1= n->GetVolume(); // // gGeoManager->AddVolume(dchTop); // TGeoVoxelFinder *voxels = dchTop->GetVoxels(); // if (voxels) voxels->SetNeedRebuild(); // TGeoMatrix *M = n->GetMatrix(); // M->SetDefaultName(); // gGeoManager->GetListOfMatrices()->Remove(M); // TGeoHMatrix *global = gGeoManager->GetHMatrix(); // gGeoManager->GetListOfMatrices()->Remove(global); //Remove the Identity matrix // // Cave->AddNode(v1,0, M); // //***/ // ExpandNode(dchTop,Cave); // } // void PndDchDetector::ExpandNode(TGeoVolume *fVol, TGeoVolume *Cave){ // FairGeoLoader*geoLoad = FairGeoLoader::Instance(); // FairGeoInterface *geoFace = geoLoad->getGeoInterface(); // FairGeoMedia *Media = geoFace->getMedia(); // FairGeoBuilder *geobuild=geoLoad->getGeoBuilder(); // TObjArray *nodeList=fVol->GetNodes(); // if(fVerboseLevel>2) // std::cout<< "DEBUG NodeListEntries = " << nodeList->GetEntries() << std::endl; // for (Int_t nod=0; nod < nodeList->GetEntries(); nod++) { // if(fVerboseLevel>2) std::cout<< "DEBUG nod = " << nod << std::endl; // TGeoNode *fNode =(TGeoNode *)nodeList->At(nod); // TGeoVolume *v= fNode->GetVolume(); // if(fNode->GetNdaughters()>0) // ExpandNode(v, Cave); // TGeoMedium* med1=v->GetMedium(); // if(fVerboseLevel>2) std::cout<< "DEBUG NodeName = " << fNode->GetName() << std::endl; // if (med1) { // if(fVerboseLevel>2) std::cout<< "DEBUG medium = " << med1->GetName() << std::endl; // TGeoMaterial*mat1=v->GetMaterial(); // TGeoMaterial *newMat = gGeoManager->GetMaterial(mat1->GetName()); // if (newMat==0) { // std::cout<< "Material " << mat1->GetName() << " is not defined " << std::endl; // FairGeoMedium *CbmMedium=Media->getMedium(mat1->GetName()); // if (!CbmMedium) { // std::cout << "Material is not defined in ASCII file nor in Root file" << std::endl; // CbmMedium=new FairGeoMedium(mat1->GetName()); // Media->addMedium(CbmMedium); // } // std::cout << "Create Medium " << mat1->GetName() << std::endl; // Int_t nmed=geobuild->createMedium(CbmMedium); // v->SetMedium(gGeoManager->GetMedium(nmed)); // gGeoManager->SetAllIndex(); // } else { // if(fVerboseLevel>2) // std::cout<< "DEBUG material was defined MaterialName= " << mat1->GetName() << std::endl; // TGeoMedium *med2= gGeoManager->GetMedium(mat1->GetName()); // v->SetMedium(med2); // } // } // if (!gGeoManager->FindVolumeFast(v->GetName())) { // if(fVerboseLevel>2) std::cout<< "DEBUG registration form" << std::endl; // v->RegisterYourself(); // } // //only dchVolume added to the Node list of Cave // TString name = v->GetName(); // if(fVerboseLevel>2) std::cout<< "DEBUG VolumeName " <2) std::cout<< "DEBUG AddNode for volume " <AddNode(v,0, fNode->GetMatrix()); // } // if (name.Contains("Splane")) { // if (nod==0) { // if(fVerboseLevel>2) std::cout<< "DEBUG AddSensitive " <getGeoInterface(); PndDchGeo* dchGeo = new PndDchGeo(); dchGeo->setGeomFile(GetGeometryFileName()); geoIFace->addGeoModule(dchGeo); Bool_t rc = geoIFace->readSet(dchGeo); if (rc) dchGeo->create(geoLoad->getGeoBuilder()); else std::cerr<<"PndDchDetector:: geometry could not be read!"<getListOfVolumes(); std::cout<<"volList contains "<GetEntries()<<" volumes"<GetRuntimeDb(); PndDchGeoPar* par=(PndDchGeoPar*)(rtdb->getContainer("PndDchGeoPar")); TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); TObjArray *fPassNodes = par->GetGeoPassiveNodes(); TListIter iter(volList); FairGeoNode* node = NULL; FairGeoVolume *aVol=NULL; while( (node = (FairGeoNode*)iter.Next()) ) { std::cout<<"&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<< node->GetName()< ( node ); if ( node->isSensitive() ) { fSensNodes->AddLast( aVol ); }else{ fPassNodes->AddLast( aVol ); } } par->setChanged(); par->setInputVersion(fRun->GetRunId(),1); // set active/inactive ProcessNodes( volList ); std::cout<<"DCH Geometry built"<