- // Accumulates hits as long as the track stays in a single
- // crystal or PPSD gas Cell
- Int_t id[2]; // (layer, phi, Eta) indices
- Int_t absid;
- // position wrt MRS and energy deposited
- Float_t xyze[4]={0.,0.,0.,0.};
- TLorentzVector pos; // Lorentz vector of the track current position.
- TLorentzVector mom; // Lorentz vector of the track current momentum.
- Int_t tracknumber = gAlice->CurrentTrack();
- static Int_t primary;
-
- gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
- gMC->CurrentVolID(id[1]); // get the phi number inside the layer
- primary = gAlice->GetPrimary(tracknumber);
- if(gMC->IsTrackEntering()&&id[0]==1) primary = tracknumber;
-// tracknumber = primary;
- gMC->TrackPosition(pos);
- gMC->TrackMomentum(mom);
- xyze[0] = pos[0];
- xyze[1] = pos[1];
- xyze[2] = pos[2];
- xyze[3] = gMC->Edep();
-
- if(xyze[3] > 0.){// Track is inside the crystal and deposits some energy
- absid = (id[0]-1)*(fGeom->GetNPhi()) + id[1];
- AddHit(fIshunt, primary,tracknumber, absid, xyze, &mom);
+ // Accumulates hits as long as the track stays in a tower
+
+ Int_t id[2]={0,0}; // (phi, Eta) indices
+ // position wrt MRS and energy deposited
+ Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
+ Float_t pmom[4]={0.,0.,0.,0.};
+ TLorentzVector pos; // Lorentz vector of the track current position.
+ TLorentzVector mom; // Lorentz vector of the track current momentum.
+ Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
+ static Float_t ienergy = 0;
+ Int_t copy = 0;
+
+ AliEMCALGeometry * geom = GetGeometry() ;
+
+ TParticle *part=0;
+ Int_t parent=-1;
+
+ static Int_t idXPHI = gMC->VolId("XPHI");
+ if(gMC->CurrentVolID(copy) == idXPHI ) { // We are in a Scintillator Layer
+ Float_t depositedEnergy ;
+
+ if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
+ if (fCurPrimary==-1)
+ fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
+
+ if (fCurParent==-1 || tracknumber != fCurTrack) {
+ // Check parentage
+ //Int_t parent=tracknumber;
+ parent=tracknumber;
+ if (fCurParent != -1) {
+ while (parent != fCurParent && parent != -1) {
+ //TParticle *part=gAlice->GetMCApp()->Particle(parent);
+ part=gAlice->GetMCApp()->Particle(parent);
+ parent=part->GetFirstMother();
+ }
+ }
+ if (fCurParent==-1 || parent==-1) {
+ //Int_t parent=tracknumber;
+ //TParticle *part=gAlice->GetMCApp()->Particle(parent);
+ parent=tracknumber;
+ part=gAlice->GetMCApp()->Particle(parent);
+ while (parent != -1 && geom->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
+ parent=part->GetFirstMother();
+ if (parent!=-1)
+ part=gAlice->GetMCApp()->Particle(parent);
+ }
+ fCurParent=parent;
+ if (fCurParent==-1)
+ Error("StepManager","Cannot find parent");
+ else {
+ //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
+ part=gAlice->GetMCApp()->Particle(fCurParent);
+ ienergy = part->Energy();
+ }
+ while (parent != -1) {
+ part=gAlice->GetMCApp()->Particle(parent);
+ part->SetBit(kKeepBit);
+ parent=part->GetFirstMother();
+ }
+ }
+ fCurTrack=tracknumber;
+ }
+ gMC->TrackPosition(pos);
+ xyzte[0] = pos[0];
+ xyzte[1] = pos[1];
+ xyzte[2] = pos[2];
+ xyzte[3] = gMC->TrackTime() ;
+
+ gMC->TrackMomentum(mom);
+ pmom[0] = mom[0];
+ pmom[1] = mom[1];
+ pmom[2] = mom[2];
+ pmom[3] = mom[3];
+
+ gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
+ gMC->CurrentVolID(id[1]); // get the phi number inside the layer
+
+ Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ;
+ Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ;
+ Int_t absid = tower;
+ Int_t nlayers = geom->GetNECLayers();
+ if ((layer > nlayers)||(layer<1))
+ Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ;
+
+ Float_t lightYield = depositedEnergy ;
+ // Apply Birk's law (copied from G3BIRK)
+
+ if (gMC->TrackCharge()!=0) { // Check
+ Float_t birkC1Mod = 0;
+ if (fBirkC0==1){ // Apply correction for higher charge states
+ if (TMath::Abs(gMC->TrackCharge())>=2)
+ birkC1Mod=fBirkC1*7.2/12.6;
+ else
+ birkC1Mod=fBirkC1;
+ }
+ Float_t dedxcm=0.;
+ if (gMC->TrackStep()>0)
+ dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
+ else
+ dedxcm=0;
+ lightYield=lightYield/(1.+birkC1Mod*dedxcm+fBirkC2*dedxcm*dedxcm);
+ }
+
+ // use sampling fraction to get original energy --HG
+ xyzte[4] = lightYield * geom->GetSampling();
+
+ if (gDebug == 2)
+ printf("StepManager: id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ;
+
+ AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom);