15 #include "FairGeoInterface.h"
16 #include "FairGeoLoader.h"
17 #include "FairGeoRootBuilder.h"
18 #include "FairRootManager.h"
19 #include "FairVolume.h"
20 #include "FairGeoMedia.h"
22 #include "FairRuntimeDb.h"
25 #include "TObjArray.h"
26 #include "TClonesArray.h"
27 #include "TGeoMCGeometry.h"
28 #include "TGeoManager.h"
29 #include "TLorentzVector.h"
30 #include "TParticle.h"
31 #include "TVirtualMC.h"
33 #include "TGeoMatrix.h"
35 #include "FairGeoMedia.h"
36 #include "FairGeoMedium.h"
49 fTrackID(0),fVolumeID(0),fEventID(-1),fPos(0,0,0,0),fMom(0,0,0,0),fTime(0),fLength(0),fELoss(0),fPosIndex(0),fApdCollection(new TClonesArray(
"PndEmcApdPoint"))
57 FairDetector(name, active),
58 fTrackID(0),fVolumeID(0),fEventID(-1),fPos(0,0,0,0),fMom(0,0,0,0),fTime(0),fLength(0),fELoss(0),fPosIndex(0),fApdCollection(new TClonesArray(
"PndEmcApdPoint"))
106 Int_t nMod = -1, nRow = -1, nCrys = -1;
109 if ( gMC->IsTrackEntering() ) {
112 if ( gMC->IsTrackExiting() ||
113 gMC->IsTrackStop() ||
114 gMC->IsTrackDisappeared() ) {
118 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
122 fTime = gMC->TrackTime();
123 gMC->TrackPosition(
fPos);
124 gMC->TrackMomentum(
fMom);
126 sscanf(nam,
"apd%dr%dc%d", &nMod, &nRow, &nCrys);
127 gMC->CurrentVolOffID(2,copyNo);
129 fVolumeID = nMod*100000000 + nRow*1000000 + copyNo*10000 + nCrys;
146 if (fVerboseLevel)
Print();
153 FairRootManager::Instance()->Register(
"EmcApdPoint",
"Emc",
fApdCollection, kTRUE);
190 Int_t nEntries = cl1->GetEntriesFast();
192 TClonesArray& clref = *cl2;
194 for (Int_t
i=0;
i<nEntries;
i++) {
196 Int_t index = oldpoint->GetTrackID() +
offset;
197 oldpoint->SetTrackID(index);
211 TString fileName=GetGeometryFileName();
213 if (fileName.EndsWith(
".dat")) {
214 std::cout<<
" " <<std::endl;
215 std::cout<<
" ====== EMCAPD::ConstructASCIIGeometry()====== " <<std::endl;
216 std::cout<<
" ============================================= " <<std::endl;
221 std::cout<<
"Geometry format not supported " <<std::endl;
228 FairGeoLoader*
geoLoad = FairGeoLoader::Instance();
229 FairGeoInterface *
geoFace = geoLoad->getGeoInterface();
230 FairGeoMedia *
Media = geoFace->getMedia();
231 FairGeoBuilder *
geobuild=geoLoad->getGeoBuilder();
233 FairGeoMedium *CbmMediumSi = Media->getMedium(
"silicon");
234 geobuild->createMedium(CbmMediumSi);
236 TGeoVolume *flayer1 =
new TGeoVolumeAssembly(
"ApdLayer1");
237 TGeoVolume *flayer2 =
new TGeoVolumeAssembly(
"ApdLayer2");
238 TGeoVolume *flayer6 =
new TGeoVolumeAssembly(
"ApdLayer6");
240 Bool_t bIsModuleOn[6] = {kFALSE, kFALSE, kFALSE, kFALSE, kFALSE,kFALSE};
245 cout <<
"Emc APD module = " << module;
246 cout << endl <<
"******** " << endl;
252 sprintf(buffer,
"apd0%dr%dc%d",module,
row, crystal);
255 if (data.
module==-1)
continue;
258 TGeoTrap *trap =
new TGeoTrap(data.
pDz/10., data.
pTheta, data.
pPhi,
262 volume =
new TGeoVolume(buffer, trap,
gGeoManager->GetMedium(
"silicon"));
264 volume->SetLineColor(5);
266 rot.RotateZ(data.
tau);
267 rot.RotateY(data.
theta);
268 rot.RotateZ(data.
phi);
270 if(module ==1) flayer1->AddNode(volume,0,
new TGeoCombiTrans(data.
posX/10., data.
posY/10., data.
posZ/10.+3.7,
new TGeoRotation (rot)));
271 if(module ==2) flayer2->AddNode(volume,0,
new TGeoCombiTrans(data.
posX/10., data.
posY/10., data.
posZ/10.+3.7,
new TGeoRotation (rot)));
272 if(module ==6) flayer6->AddNode(volume,0,
new TGeoCombiTrans(data.
posX/10., data.
posY/10., data.
posZ/10.,
new TGeoRotation (rot)));
273 bIsModuleOn[module-1] = kTRUE;
274 AddSensitiveVolume(volume);
280 TGeoVolume *flayer12 =
new TGeoVolumeAssembly(
"EmcApd12");
281 if (bIsModuleOn[0]) flayer12->AddNode(flayer1,0,
new TGeoCombiTrans(0., 0., 0.,
new TGeoRotation(0)));
282 if (bIsModuleOn[1]) flayer12->AddNode(flayer2,0,
new TGeoCombiTrans(0., 0., 0.,
new TGeoRotation(0)));
284 vname = vname.Strip();
285 TGeoVolume* vcave =
gGeoManager->FindVolumeFast(vname.Data());
286 if (bIsModuleOn[0] || bIsModuleOn[1]) vcave->AddNode(flayer12, 1);
287 if (bIsModuleOn[5]) vcave->AddNode(flayer6, 1);
290 if (bIsModuleOn[0] || bIsModuleOn[1])
291 for (Int_t
n=1;
n<=15;
n++){
293 rot1.RotateZ(22.5*
n);
294 vcave->AddNode(flayer12,
n+1,
new TGeoCombiTrans(0., 0., 0.,
new TGeoRotation (rot1)) );
299 PndEmcApdPoint*
PndEmcApd::AddHit(Int_t trackID, Int_t detID, Int_t evtID, TVector3
pos, TVector3
mom,
Double_t time,
Double_t length,
Double_t eLoss, Short_t mod, Short_t
row, Short_t crys, Short_t copy, Short_t flag) {
301 Int_t size = clref.GetEntriesFast();
303 cout <<
"-I- PndEmcApd: Adding Point at IN (" << pos.X() <<
", " << pos.Y()
304 <<
", " << pos.Z() <<
") cm, detector " << detID <<
", evt " << evtID <<
", track "
305 << trackID <<
", energy loss " << eLoss*1e06 <<
" keV, module " << mod <<
" row " << row <<
" crystal " << crys <<
" copy " << copy << endl;
307 return new(clref[size])
PndEmcApdPoint(trackID, detID, evtID, pos, mom, time, length, eLoss,
308 mod, row, crys, copy, flag);
315 fPos.SetXYZT(0., 0., 0., 0.);
316 fMom.SetXYZT(0., 0., 0., 0.) ;
virtual void ConstructGeometry()
int GetMinRows(int module)
int GetMaxCrystals(int module, int row)
TLorentzVector fPos
event id
Int_t fPosIndex
energy loss
TGeoManager * gGeoManager
TClonesArray * fApdCollection
DataG4 GetData(int module, int row, int crystal)
virtual void EndOfEvent()
FairGeoBuilder * geobuild
int GetMinCrystals(int module, int row)
int GetMaxRows(int module)
Int_t fVolumeID
track index
PndEmcApdPoint * AddHit(Int_t trackID, Int_t detID, Int_t evtID, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss, Short_t mod, Short_t row, Short_t crys, Short_t copy, Short_t flag)
virtual Bool_t ProcessHits(FairVolume *vol=0)
virtual void Initialize()
void ResetParameters()
Hit collection.
void ConstructASCIIGeometry()
virtual void Print() const
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
virtual TClonesArray * GetCollection(Int_t iColl) const
FairGeoInterface * geoFace
TLorentzVector fMom
position
virtual void BeginEvent()