/* Generated by Together */ #include "FairMCApplication.h" #include "HadesRich.h" #include "FairVolume.h" #include "TGeoMCGeometry.h" #include "TGeoManager.h" #include "TGeoVolume.h" #include "TGeoMedium.h" #include "FairGeoInterface.h" #include "FairGeoBuilder.h" #include "FairGeoSet.h" #include "FairGeoNode.h" #include "TList.h" #include "HadesRichPoint.h" #include "TLorentzVector.h" #include "TVirtualMC.h" #include "TVirtualMC.h" #include "FairGeoLoader.h" #include "FairGeoRootBuilder.h" //#include "FairGeoG3Builder.h" #include "hgeorich.h" #include "iostream.h" #include "FairRootManager.h" ClassImp(HadesRich) void HadesRich::ConstructGeometry() { FairGeoLoader* geoLoad = FairGeoLoader::Instance(); FairGeoInterface* geoFace = geoLoad->getGeoInterface(); cout <<" -I Constructing Hades Rich " << endl; FairGeoSet* gset=NULL; gset = new HGeoRich(); geoFace->addGeoModule(gset); gset->setGeomFile(GetGeometryFileName()); Bool_t rc = geoFace->readSet(gset); if (rc) gset->create(geoLoad->getGeoBuilder()); TList* volList = gset->getListOfVolumes(); ProcessNodes ( volList ); } HadesRich::HadesRich(){ } HadesRich::~HadesRich() { } HadesRich::HadesRich(const char * name, Bool_t Active ) : FairDetector(name , Active), fRichCollection(0) { fRichCollection = new TClonesArray("HadesRichPoint"); } void HadesRich::Initialize() { // FairDetector::Initialize(); //Register(); Int_t NoOfEntries=svList->GetEntries(); TString cutName; TString realName; PDet=0; // TString copysign="#"; for (Int_t i = 0 ; i < NoOfEntries ; i++ ) { FairVolume* aVol = (FairVolume*) svList->At(i); cutName = aVol->getName(); cutName=cutName(0,4); if (cutName=="RDET")PDet=gMC->VolId(cutName.Data()); else { // realName=CbmG3MapedNames::getVolRealName(cutName); realName= aVol->getRealName(); if (realName=="RDET")PDet=gMC->VolId(cutName.Data()); } // Ssiz_t pos = cutName.Index (copysign, 1); // cout << " Ssiz_t= cutName " << cutName << "PDet "<1) cutName.Resize(pos); if ( aVol->getModId() == GetModId() ) { aVol->setMCid(gMC->VolId(cutName.Data())); } } } Bool_t HadesRich::ProcessHits(FairVolume *v) { Int_t iVol = v->getMCid(); if(iVol!=PDet) return kFALSE; Double_t fEdep = 0.0; HadesRichPoint *richPoint=NULL; Int_t pdgCode = gMC->TrackPid(); if (pdgCode != 50000050 )return kFALSE; //cout << "HadesRich::ProcessHits Vol id :" << iVol <<" Copy No : "<< v->getCopyNo()<< endl; // if (pdgCode == 50000050 && gMC->IsTrackExiting()){ if (gMC->IsTrackEntering() ){ // first test if E deposit is not null ! fEdep=0 ; } fEdep+=gMC->Edep(); // if (fEdep == 0.0 ) return kFALSE; if (gMC->IsTrackExiting()){ richPoint = AddHit(); richPoint->SetDetectorID(v->getMCid()); richPoint->SetELoss(fEdep); richPoint->SetEtot(gMC->Etot()); richPoint->SetTime(gMC->TrackTime()); richPoint->SetLength(gMC->TrackLength()); richPoint->SetTrackID(gMC->GetStack()->GetCurrentTrackNumber()); TLorentzVector pos; gMC->TrackPosition(pos); richPoint->SetPos (TVector3(pos.X(), pos.Y(), pos.Z())); TLorentzVector mom; gMC->TrackMomentum(mom); richPoint->SetMom (TVector3(mom.X(), mom.Y(), mom.Z())); // gMC->StopTrack(); // cout <<" -I- HadesRich " << iVol << " " << v->GetName() << endl; } return kTRUE; } HadesRichPoint* HadesRich::AddHit() { // Creates a new hit in the TClonesArray. // --- TClonesArray& ref = *fRichCollection; Int_t size = ref.GetEntriesFast(); return new(ref[size]) HadesRichPoint(); } void HadesRich::EndOfEvent() { Reset(); } void HadesRich::Register() { FairRootManager::Instance()->Register("RichPoint","RICH", fRichCollection, kTRUE); } void HadesRich::Reset() { fRichCollection->Clear(); }