| 1 |
pamelats |
1.1 |
#ifndef PAMVMC_DETECTOR_SD_H |
| 2 |
|
|
#define PAMVMC_DETECTOR_SD_H |
| 3 |
|
|
#include <iostream> |
| 4 |
|
|
#include <TClonesArray.h> |
| 5 |
|
|
#include <TObject.h> |
| 6 |
|
|
#include <TString.h> |
| 7 |
|
|
#include <TObjString.h> |
| 8 |
|
|
#include <TMap.h> |
| 9 |
|
|
#include <TROOT.h> |
| 10 |
|
|
#include "PamVMCDetectorHit.h" |
| 11 |
|
|
#include "PamVMCDigMgr.h" |
| 12 |
|
|
#include "PamVMCGeoIDMgr.h" |
| 13 |
|
|
#include "PamRootManager.h" |
| 14 |
|
|
#include "PamVMCStack.h" |
| 15 |
|
|
#include <TParticle.h> |
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
|
|
enum fin{INSIDE,ENTERING,EXITING}; |
| 19 |
|
|
|
| 20 |
|
|
class PamVMCDetectorSD : public TObject { |
| 21 |
|
|
|
| 22 |
|
|
|
| 23 |
|
|
protected: |
| 24 |
|
|
|
| 25 |
|
|
TString fcname; |
| 26 |
|
|
TString fdname; |
| 27 |
|
|
Int_t fnohit; |
| 28 |
|
|
fin ffi; |
| 29 |
|
|
TClonesArray *fHitColl; |
| 30 |
|
|
TMap fdmap; |
| 31 |
|
|
PamVMCGeoID *fdetID; |
| 32 |
|
|
PamVMCDetectorHit * fhit; |
| 33 |
|
|
PamVMCDigitizer * fdig; |
| 34 |
|
|
|
| 35 |
|
|
public: |
| 36 |
|
|
|
| 37 |
|
|
|
| 38 |
|
|
PamVMCDetectorSD( |
| 39 |
|
|
const char *cname="PamVMCDetectorHit", |
| 40 |
|
|
char *dname="", |
| 41 |
|
|
Int_t is=0): |
| 42 |
|
|
fcname(cname), fdname(dname), fnohit(0), fdetID(0) |
| 43 |
|
|
{ |
| 44 |
|
|
if(is) { |
| 45 |
|
|
fHitColl=new TClonesArray(fcname.Data(),is); |
| 46 |
|
|
} else { |
| 47 |
|
|
fHitColl=new TClonesArray(fcname.Data()); |
| 48 |
|
|
} |
| 49 |
|
|
fhit = new PamVMCDetectorHit(); |
| 50 |
|
|
|
| 51 |
|
|
fdig = (PamVMCDigitizer*)PamVMCDigMgr::Instance()->GetDIG(dname); |
| 52 |
|
|
|
| 53 |
|
|
AddGeoID(dname); |
| 54 |
|
|
} |
| 55 |
|
|
|
| 56 |
|
|
|
| 57 |
|
|
virtual ~PamVMCDetectorSD() { delete fhit; delete fHitColl; delete fdetID;} |
| 58 |
|
|
|
| 59 |
|
|
virtual void PamVMCDetectorSD::Register(){ |
| 60 |
|
|
|
| 61 |
|
|
PamRootManager::Instance()-> |
| 62 |
|
|
Register(fdname.Data(),"TClonesArray", &fHitColl); |
| 63 |
|
|
|
| 64 |
|
|
if (fdig) fdig->RegisterCollections(fdname.Data(),fHitColl); |
| 65 |
|
|
|
| 66 |
|
|
TString a=fHitColl?"exist":"not exist"; |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
|
|
void AddGeoID(const char * dname){ |
| 70 |
|
|
TString temp=dname; |
| 71 |
|
|
fdetID=new PamVMCGeoID(dname); |
| 72 |
|
|
fdmap.Add(new TObjString(temp), fdetID); |
| 73 |
|
|
cout <<" Inside AddGeoID "<<fdname.Data() << endl; |
| 74 |
|
|
fdmap.Print(); |
| 75 |
|
|
} |
| 76 |
|
|
|
| 77 |
|
|
|
| 78 |
|
|
virtual void CleanHit(){ fhit->CleanHit();} |
| 79 |
|
|
|
| 80 |
|
|
virtual void InitHit() { |
| 81 |
|
|
if(fdetID) { |
| 82 |
|
|
fhit->SetPOS( fdetID->GetID( )) ; |
| 83 |
|
|
} else { fhit->SetPOS(-1); } |
| 84 |
|
|
} |
| 85 |
|
|
|
| 86 |
|
|
virtual void UpdateHit(TVirtualMC *g){ fhit->FillHit(g); } |
| 87 |
|
|
|
| 88 |
|
|
virtual void SaveHit(){ |
| 89 |
|
|
PamVMCDetectorHit * k=CreateHit(); |
| 90 |
|
|
k=fhit; |
| 91 |
|
|
} |
| 92 |
|
|
|
| 93 |
|
|
virtual void SaveHit(Int_t f){ |
| 94 |
|
|
PamVMCDetectorHit * k=CreateHit(f); |
| 95 |
|
|
*k+=*fhit; |
| 96 |
|
|
} |
| 97 |
|
|
|
| 98 |
|
|
virtual void SaveHit(const char * dname){ |
| 99 |
|
|
PamVMCDetectorHit * k=CreateHit(dname); |
| 100 |
|
|
*k=*fhit; |
| 101 |
|
|
} |
| 102 |
|
|
|
| 103 |
|
|
virtual PamVMCDetectorHit * CreateHit() |
| 104 |
|
|
{ |
| 105 |
|
|
PamVMCDetectorHit *hit= (PamVMCDetectorHit *) fHitColl->New(fnohit++); |
| 106 |
|
|
InitHit(); |
| 107 |
|
|
return hit; |
| 108 |
|
|
} |
| 109 |
|
|
|
| 110 |
|
|
virtual void FillVolID(){ |
| 111 |
|
|
fdetID->FillVolID(); |
| 112 |
|
|
fhit->SetPOS( fdetID->GetID( )) ; |
| 113 |
|
|
} |
| 114 |
|
|
|
| 115 |
|
|
virtual PamVMCDetectorHit * CreateHit(const char * dname) |
| 116 |
|
|
{ |
| 117 |
|
|
fdetID=(PamVMCGeoID*)fdmap(dname); |
| 118 |
|
|
return CreateHit(); |
| 119 |
|
|
} |
| 120 |
|
|
|
| 121 |
|
|
virtual PamVMCDetectorHit * CreateHit(Int_t flag) { |
| 122 |
|
|
if(!fHitColl->At(flag)) { |
| 123 |
|
|
PamVMCDetectorHit *hit= (PamVMCDetectorHit *) fHitColl->New(flag); |
| 124 |
|
|
InitHit(); |
| 125 |
|
|
return hit; |
| 126 |
|
|
} |
| 127 |
|
|
return (PamVMCDetectorHit*)fHitColl->At(flag); |
| 128 |
|
|
} |
| 129 |
|
|
|
| 130 |
|
|
virtual void PreEvent(){/* this method was created |
| 131 |
|
|
for zeroing digits in common area. |
| 132 |
|
|
calls from application before each event*/}; |
| 133 |
|
|
|
| 134 |
|
|
virtual void Compress(){ (*fHitColl).Compress(); }; |
| 135 |
|
|
|
| 136 |
|
|
virtual void Digitize(){/*this method do pre-digitize action, |
| 137 |
|
|
ex. calculate strips energy release |
| 138 |
|
|
(create something to be digitized (if any). |
| 139 |
|
|
calls from application*/ } |
| 140 |
|
|
|
| 141 |
|
|
|
| 142 |
|
|
virtual void ClearHitColl(){ |
| 143 |
|
|
fnohit=0; |
| 144 |
|
|
(*fHitColl).Clear("C"); |
| 145 |
|
|
} |
| 146 |
|
|
|
| 147 |
|
|
virtual void FillHit(fin f,TVirtualMC *g){ |
| 148 |
|
|
ffi=f; |
| 149 |
|
|
switch(f) { |
| 150 |
|
|
case ENTERING: |
| 151 |
|
|
CleanHit(); |
| 152 |
|
|
FillVolID(); |
| 153 |
|
|
InitHit(); |
| 154 |
|
|
default: |
| 155 |
|
|
UpdateHit(g); |
| 156 |
|
|
break; |
| 157 |
|
|
} |
| 158 |
|
|
|
| 159 |
|
|
switch(f){ |
| 160 |
|
|
case EXITING: |
| 161 |
|
|
// Save hit if energy release is greater than zero |
| 162 |
|
|
if(fhit->GetEREL()){ |
| 163 |
|
|
SaveHit(fdname.Data()); |
| 164 |
|
|
} |
| 165 |
|
|
break; |
| 166 |
|
|
default: |
| 167 |
|
|
break; |
| 168 |
|
|
} |
| 169 |
|
|
} |
| 170 |
|
|
|
| 171 |
|
|
|
| 172 |
|
|
virtual void Print(const Option_t* ="") const { |
| 173 |
|
|
|
| 174 |
|
|
// Print more information like the name |
| 175 |
|
|
std::cout<<"DETECTOR "<<fdname<<" HIT COLLECTION"<<std::endl; |
| 176 |
|
|
fHitColl->Print(); |
| 177 |
|
|
} |
| 178 |
|
|
|
| 179 |
|
|
ClassDef(PamVMCDetectorSD,1) |
| 180 |
|
|
}; |
| 181 |
|
|
|
| 182 |
|
|
|
| 183 |
|
|
#endif //PAMVMC_DETECTOR_SD_H |