/* Generated by Together */ #include "FairMCApplication.h" #include "HadesMdc.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 "HadesMdcPoint.h" #include "TLorentzVector.h" #include "TVirtualMC.h" #include "FairGeoLoader.h" #include "FairGeoRootBuilder.h" #include "hgeomdc.h" #include "iostream.h" #include "FairRootManager.h" ClassImp(HadesMdc) void HadesMdc::ConstructGeometry() { Bool_t rc = kTRUE; cout <<" -I Constructing Hades Mdc " << endl; FairGeoSet* gset=NULL; FairGeoLoader *loader=FairGeoLoader::Instance(); FairGeoInterface *interface =loader->getGeoInterface(); if (interface ) { gset = new HGeoMdc(); interface->addGeoModule(gset); gset->setGeomFile(GetGeometryFileName()); // full MDC set up is used if (gset) { Int_t mdcMods[6][4]= { {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1} }; for(Int_t i=0;i<6;i++) gset->setModules(i,mdcMods[i]); } rc = interface->readSet( gset ); if ( rc ) gset->create(loader->getGeoBuilder()); else Fatal("CbmHadMdc","can not create volume" ); } else Fatal("CbmHadMdc"," no HGeoInterface defined "); TList* alist = gset->getListOfVolumes(); ProcessNodes ( alist ); /* FairGeoNode* volu; TListIter iter(alist); FairVolume *aVol=NULL; while((volu=(FairGeoNode*)iter.Next())){ // Save created volume aVol = new FairVolume( volu->getName(), fNbOfVolumes++); vList->addVolume ( aVol ); //Set sensitivity if ( volu->isSensitive() && fActive==kTRUE) { aVol->setDetId(fdetId); aVol->SetModule(this); svList->Add( aVol ); fNbOfSensitiveVol++; } } */ } HadesMdc::HadesMdc(){ } HadesMdc::~HadesMdc() { } HadesMdc::HadesMdc(const char * name, Bool_t Active ) : FairDetector(name , Active), fMdcCollection1(0),fMdcCollection2(0) { fMdcCollection1 = new TClonesArray("HadesMdcPoint"); // fMdcCollection2 = new TClonesArray("HadesMdcPoint"); } void HadesMdc::Initialize() { TRefArray *SDList = FairDetector::svList; Int_t NoOfEntries=SDList->GetEntries(); TString cutName; for (Int_t i = 0 ; i < NoOfEntries ; i++ ) { FairVolume* aVol = (FairVolume*) SDList->At(i); cutName = aVol->getName(); cutName=cutName(0,4); if ( aVol->getModId() == GetModId() ) { aVol->setMCid(gMC->VolId(cutName.Data())); } } fMDC1 = gMC->VolId("D1S1"); fMDC2 = gMC->VolId("D4S6"); // cout << "HadesMdc::Initialize() MDC1 = " << fMDC1<< "MDC2 = " << fMDC2<< endl; } Bool_t HadesMdc::ProcessHits(FairVolume *v) { Int_t copyNo; HadesMdcPoint *trdPoint=NULL; Int_t pdgCode = gMC->TrackPid(); if (pdgCode!=11) return kFALSE; if ( gMC->IsTrackEntering() ) { // first test if E deposit is not null ! fEdep = 0.0; } fEdep+=gMC->Edep(); if (gMC->IsTrackExiting() && fEdep !=0 ){ // if(v->getMCid()==fMDC1) trdPoint = AddHit(); // else if (v->getMCid()==fMDC2)trdPoint = AddHit2(); // if(trdPoint){ // gMC->CurrentVolID(copyNo); trdPoint = AddHit(); trdPoint->SetDetectorID(v->getMCid()); trdPoint->SetELoss(fEdep); trdPoint->SetEtot(gMC->Etot()); trdPoint->SetTime(gMC->TrackTime()); trdPoint->SetLength(gMC->TrackLength()); trdPoint->SetTrackID(gMC->GetStack()->GetCurrentTrackNumber()); TLorentzVector pos; gMC->TrackPosition(pos); trdPoint->SetPos (TVector3(pos.X(), pos.Y(), pos.Z())); TLorentzVector mom; gMC->TrackMomentum(mom); trdPoint->SetMom (TVector3(mom.X(), mom.Y(), mom.Z())); } return kTRUE; } HadesMdcPoint* HadesMdc::AddHit() { // Creates a new hit in the TClonesArray. // --- TClonesArray& ref = *fMdcCollection1; Int_t size = ref.GetEntriesFast(); return new(ref[size]) HadesMdcPoint(); } HadesMdcPoint* HadesMdc::AddHit2() { // Creates a new hit in the TClonesArray. // --- TClonesArray& ref = *fMdcCollection2; Int_t size = ref.GetEntriesFast(); return new(ref[size]) HadesMdcPoint(); } void HadesMdc::EndOfEvent() { Reset(); } void HadesMdc::Register() { FairRootManager::Instance()->Register("MdcPoint1","MDC1", fMdcCollection1,kTRUE); //FairRootManager::Instance()->Register("MdcPoint2","MDC2", fMdcCollection2,kTRUE); } void HadesMdc::Reset() { fMdcCollection1->Clear(); //fMdcCollection2->Clear(); }