///////////////////////////////////////////////////////////// // DchDetector // // Class for DchDetector // ///////////////////////////////////////////////////////////// #include "iostream.h" #include "TClonesArray.h" #include "TGeoMCGeometry.h" #include "TGeoManager.h" #include "TLorentzVector.h" #include "TParticle.h" #include "TVirtualMC.h" #include "CbmGeoInterface.h" #include "CbmGeoLoader.h" #include "CbmGeoNode.h" #include "CbmGeoRootBuilder.h" #include "CbmStack.h" #include "CbmRootManager.h" #include "CbmVolume.h" #include "DchGeo.h" #include "DchDetector.h" #include "DchPoint.h" #include "CbmGeoG3Builder.h" #include "CbmRuntimeDb.h" #include "DchGeoPar.h" #include "TObjArray.h" #include "CbmRun.h" // ----- Default constructor ------------------------------------------- DchDetector::DchDetector() { fDchPointCollection = new TClonesArray("DchPoint"); fPosIndex = 0; volDetector = 0; } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ DchDetector::DchDetector(const char* name, Bool_t active) : CbmDetector(name, active) { fDchPointCollection = new TClonesArray("DchPoint"); fPosIndex = 0; volDetector = 0; fevent=-1; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- DchDetector::~DchDetector() { if (fDchPointCollection) { fDchPointCollection->Delete(); delete fDchPointCollection; } } // ------------------------------------------------------------------------- // ----- Public method ProcessHits -------------------------------------- Bool_t DchDetector::ProcessHits(CbmVolume* vol) { fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); // trk ID Int_t copyNo; gMC->CurrentVolID(copyNo); TString nam = gMC->CurrentVolName(); //string with the correct name TString curnam = nam; curnam.Remove(0,curnam.Length()-2); fModuleID = curnam.Atoi(); std::cout<<"III DchDetector::ProcessHits() : copyNo = "<IsTrackEntering() ) { fELoss = 0.; fTime = gMC->TrackTime() * 1.0e09; // time fLength = gMC->TrackLength(); gMC->TrackPosition(fPosIn); // cm gMC->TrackMomentum(fMomIn); // GeV } // Sum energy loss for all steps in the active volume fELoss += gMC->Edep(); // Set additional parameters at exit of active volume. Create DchPoint. if ( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) { gMC->TrackPosition(fPosOut); // cm gMC->TrackMomentum(fMomOut); // GeV // if (fELoss == 0. ) return kFALSE; } AddHit(fTrackID, fVolumeID, fModuleID, TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()), TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, fLength, fELoss, nam,fevent); // TO BE SET AS DEBUG // cout << "PARAMETERS ----------" << endl; // cout << "trk " << fTrackID << " vol " << fVolumeID << fModuleID <Register("DchPoint","Dch", fDchPointCollection, kTRUE); } // ---------------------------------------------------------------------------- // ----- Public method GetCollection -------------------------------------- TClonesArray* DchDetector::GetCollection(Int_t iColl) const { if (iColl == 0) return fDchPointCollection; return NULL; } // ---------------------------------------------------------------------------- // ----- Public method Print ---------------------------------------------- void DchDetector::Print() const { Int_t nHits = fDchPointCollection->GetEntriesFast(); cout << "-I- DchDetector: " << nHits << " points registered in this event." << endl; if (fVerboseLevel>1) for (Int_t i=0; iPrint(); } // ---------------------------------------------------------------------------- // ----- Public method Reset ---------------------------------------------- void DchDetector::Reset() { fDchPointCollection->Clear(); fPosIndex = 0; } // ---------------------------------------------------------------------------- // ----- Public method CopyClones ----------------------------------------- // void DchDetector::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset ) { // Int_t nEntries = cl1->GetEntriesFast(); // cout << "-I- DchDetector: " << nEntries << " entries to add." << endl; // TClonesArray& clref = *cl2; // DchPoint* oldpoint = NULL; // for (Int_t i=0; iAt(i); // Int_t index = oldpoint->GetTrackID() + offset; // oldpoint->SetTrackID(index); // new (clref[fPosIndex]) DchPoint(*oldpoint); // fPosIndex++; // } // cout << " -I- DchDetector: " << cl2->GetEntriesFast() << " merged entries." // << endl; // } // ---------------------------------------------------------------------------- // ----- Public method ConstructGeometry ---------------------------------- void DchDetector::ConstructGeometry() { std::cout<<" --- Building DCH Geometry ---"<getGeoInterface(); DchGeo* dchGeo = new DchGeo(); dchGeo->setGeomFile(GetGeometryFileName()); std::cout<<"Geometry filename = "<addGeoModule(dchGeo); Bool_t rc = geoIFace->readSet(dchGeo); if (rc) dchGeo->create(geoLoad->getGeoBuilder()); else std::cerr<<"DchDetector:: geometry could not be read!"<getListOfVolumes(); std::cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<GetEntries()<<" volumes"<GetRuntimeDb(); DchGeoPar* par=(DchGeoPar*)(rtdb->getContainer("DchGeoPar")); TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); TObjArray *fPassNodes = par->GetGeoPassiveNodes(); TListIter iter(volList); CbmGeoNode* node = NULL; CbmGeoVolume *aVol=NULL; while( (node = (CbmGeoNode*)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<<"koniec"<1) cout << "-I- DchDetector: Adding Point at IN (" << posIn.X() << ", " << posIn.Y() << ", " << posIn.Z() << ") cm, OUT ("<< posOut.X()<< ", " << posOut.Y() <<" "<