#ifndef PAMVMC_DETECTOR_SD_H #define PAMVMC_DETECTOR_SD_H #include #include #include #include #include #include #include #include "PamVMCDetectorHit.h" #include "PamVMCDigMgr.h" #include "PamVMCGeoIDMgr.h" #include "PamRootManager.h" #include "PamVMCStack.h" #include enum fin{INSIDE,ENTERING,EXITING}; class PamVMCDetectorSD : public TObject { protected: TString fcname; TString fdname; Int_t fnohit; fin ffi; TClonesArray *fHitColl; TMap fdmap; PamVMCGeoID *fdetID; PamVMCDetectorHit * fhit; PamVMCDigitizer * fdig; public: PamVMCDetectorSD( const char *cname="PamVMCDetectorHit", const char *dname="", Int_t is=0): fcname(cname), fdname(dname), fnohit(0), fdetID(0) { if(is) { fHitColl=new TClonesArray(fcname.Data(),is); } else { fHitColl=new TClonesArray(fcname.Data()); } fhit = new PamVMCDetectorHit(); fdig = (PamVMCDigitizer*)PamVMCDigMgr::Instance()->GetDIG(dname); AddGeoID(dname); } virtual ~PamVMCDetectorSD() { delete fhit; delete fHitColl; delete fdetID;} virtual void Register(){ PamRootManager::Instance()-> Register(fdname.Data(),"TClonesArray", &fHitColl); if (fdig) fdig->RegisterCollections(fdname.Data(),fHitColl); TString a=fHitColl?"exist":"not exist"; } void AddGeoID(const char * dname){ TString temp=dname; fdetID=new PamVMCGeoID(dname); fdmap.Add(new TObjString(temp), fdetID); cout <<" Inside AddGeoID "<CleanHit();} virtual void InitHit() { if(fdetID) { fhit->SetPOS( fdetID->GetID( )) ; } else { fhit->SetPOS(-1); } } virtual void UpdateHit(TVirtualMC *g, Bool_t is_prim ){ fhit->FillHit(g, is_prim); } virtual void SaveHit(){ PamVMCDetectorHit * k=CreateHit(); k=fhit; } virtual void SaveHit(Int_t f){ PamVMCDetectorHit * k=CreateHit(f); *k+=*fhit; } virtual void SaveHit(const char * dname){ PamVMCDetectorHit * k=CreateHit(dname); *k=*fhit; } virtual PamVMCDetectorHit * CreateHit() { PamVMCDetectorHit *hit= (PamVMCDetectorHit *) fHitColl->New(fnohit++); InitHit(); //cout<<"New hit in"<GetEREL()){ SaveHit(fdname.Data()); } break; default: break; } } Int_t GetNhits() const { return fnohit; } virtual void Print(const Option_t* ="") const { // Print more information like the name std::cout<<"DETECTOR "<Print(); } ClassDef(PamVMCDetectorSD,1) }; #endif //PAMVMC_DETECTOR_SD_H