+
+*/
+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::StepManager(){
+ // Called for every step in the ITS, then calles the AliITShit class
+ // creator with the information to be recoreded about that hit.
+ // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
+ // printing of information to a file which can be used to create a .det
+ // file read in by the routine CreateGeometry(). If set to 0 or any other
+ // value except 1, the default behavior, then no such file is created nor
+ // it the extra variables and the like used in the printing allocated.
+ // Inputs:
+ // none.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ if(!(this->IsActive())) return;
+ if(!(gMC->TrackCharge())) return;
+
+ Int_t copy, id,kk;
+ Bool_t sensvol = kFALSE;
+
+ id = gMC->CurrentVolID(copy);
+ for(kk=0;kk<fIdN;kk++)if(id == fIdSens[kk]){
+ sensvol=kTRUE;
+ break;
+ } // end for if
+
+ if(!sensvol) return; // not an ITS tracking volume;
+
+ if(gMC->IsTrackExiting()){
+ AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
+ } // if Outer ITS mother Volume
+
+ static TLorentzVector position, momentum; // Saves on calls to construtors
+ static AliITShit hit;// Saves on calls to construtors
+ Int_t cpn0,cpn1,cpn2,status,mod;
+ //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
+ TClonesArray &lhits = *(Hits());
+ //
+ // Track status
+ status = 0;
+ if(gMC->IsTrackInside()) status += 1;
+ if(gMC->IsTrackEntering()) status += 2;
+ if(gMC->IsTrackExiting()) status += 4;
+ if(gMC->IsTrackOut()) status += 8;
+ if(gMC->IsTrackDisappeared()) status += 16;
+ if(gMC->IsTrackStop()) status += 32;
+ if(gMC->IsTrackAlive()) status += 64;
+ //
+ switch (kk){
+ case 0:case 1: // SPD
+ gMC->CurrentVolOffID(2,cpn2);
+ gMC->CurrentVolOffID(4,cpn1);
+ gMC->CurrentVolOffID(5,cpn0);
+ break;
+ case 2:case 3: // SDD
+ cpn2 = 1;
+ gMC->CurrentVolOffID(1,cpn1);
+ gMC->CurrentVolOffID(2,cpn0);
+ break;
+ case 4:case 5: // SSD
+ cpn2 = 1;
+ gMC->CurrentVolOffID(1,cpn1);
+ gMC->CurrentVolOffID(2,cpn0);
+ break;
+ default:
+ AliError(Form("Invalid value: kk= %d . Not an ITS sensitive volume",kk));
+ return; // not an ITS sensitive volume.
+ } //
+ fIgm.DecodeDetector(mod,kk+1,cpn0,cpn1,cpn2);
+ //Info("StepManager","lay=%d mod=%d cpn0=%d cpn1=%d cpn2=%d",kk+1,mod,cpn0,cpn1,cpn2);
+ Int_t lay,lad,det,cpy0,cpy1,cpy2;
+ fIgm.DecodeDetectorLayers(mod,lay,lad,det);
+ fIgm.RecodeDetector(mod,cpy0,cpy1,cpy2);
+// printf("gMC: kk=%d cpn0=%d cpn1=%d cpn2=%d -> mod=%d -> "
+// "lay=%d lad=%d det=%d -> cpn0=%d cpn1=%d cpn2=%d\n",
+// kk,cpn0,cpn1,cpn2,mod,lay,lad,det,cpy0,cpy1,cpy2);
+ //
+ // Fill hit structure.
+ //
+ hit.SetModule(mod);
+ hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
+ gMC->TrackPosition(position);
+ gMC->TrackMomentum(momentum);
+ hit.SetPosition(position);
+ hit.SetTime(gMC->TrackTime());
+ hit.SetMomentum(momentum);
+ hit.SetStatus(status);
+ hit.SetEdep(gMC->Edep());
+ hit.SetShunt(GetIshunt());
+ if(gMC->IsTrackEntering()){
+ hit.SetStartPosition(position);
+ hit.SetStartTime(gMC->TrackTime());
+ hit.SetStartStatus(status);
+ return; // don't save entering hit.
+ } // end if IsEntering
+ // Fill hit structure with this new hit.
+ //Info("StepManager","Calling Copy Constructor");
+ new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
+ // Save old position... for next hit.
+ hit.SetStartPosition(position);
+ hit.SetStartTime(gMC->TrackTime());
+ hit.SetStartStatus(status);
+ //
+ /*
+ Int_t idettype,ix,iz;
+ Float_t lx,lz;
+ Double_t g0[4],l0[4],g1[4];
+ position.GetXYZT(g0);
+ gMC->Gmtod(g0,l0,1); // flag=1 convert coordiantes
+ gMC->Gdtom(l0,g1,1); // flag=1 convert coordinates
+ switch(idettype=(Int_t)GetITSgeom()->GetModuleType(mod)){
+ case kSPD:
+ AliITSsegmentationSPD *segspd = (AliITSsegmentationSPD *)GetSegmentationModelByModule(mod);
+ segspd->LocalToDet((Float_t)l0[0],(Float_t)l0[2],ix,iz);
+ segspd->DetToLocal(ix,iz,lx,lz);
+ break;
+ case kSDD:
+ AliITSsegmentationSDD *segsdd = (AliITSsegmentationSDD *)GetSegmentationModelByModule(mod);
+ segsdd->LocalToDet((Float_t)l0[0],(Float_t)l0[2],ix,iz);
+ segsdd->DetToLocal(ix,iz,lx,lz);
+ break;
+ case kSSD:
+ AliITSsegmentationSSD *segssd = (AliITSsegmentationSSD *)GetSegmentationModelByModule(mod);
+ segssd->LocalToDet((Float_t)l0[0],(Float_t)l0[2],ix,iz);
+ segssd->DetToLocal(ix,iz,lx,lz);
+ break;
+ default:
+ ix = iz = -1;
+ lx = lz = 0.0;
+ Warning("StepManager","Unknown module type id=%d mod=%d",
+ (Int_t)(GetITSgeom()->GetModuleType(mod)),mod);
+ } // end if
+ printf(" gMC: mod=%d g=%g %g %g %g -> "
+ "l=%g %g %g %g -> "
+ "g=%g %g %g %g -> "
+ "ix=%d iz=%d -> lx=%g lz=%g\n",
+ mod,g0[0],g0[1],g0[2],g0[3],
+ l0[0],l0[1],l0[2],l0[3],
+ g1[0],g1[1],g1[2],g1[3],ix,iz,lx,lz);
+ GetITSgeom()->GtoL(mod,g0,l0);
+ GetITSgeom()->LtoG(mod,l0,g1);
+ printf("ITSgeom: mod=%d g=%g %g %g %g -> "
+ "l=%g %g %g %g -> "
+ "g=%g %g %g %g -> "
+ "ix=%d iz=%d -> lx=%g lz=%g\n",
+ mod,g0[0],g0[1],g0[2],g0[3],
+ l0[0],l0[1],l0[2],l0[3],
+ g1[0],g1[1],g1[2],g1[3],ix,iz,lx,lz);
+ TGeoNode *cur = gGeoManager->GetCurrentNode();
+ cur->MasterToLocal(g0,l0);
+ cur->LocalToMaster(l0,g1);
+ printf(" TGeo: mod=%d g=%g %g %g %g -> "
+ "l=%g %g %g %g -> "
+ "g=%g %g %g %g\n",
+ mod,g0[0],g0[1],g0[2],g0[3],
+ l0[0],l0[1],l0[2],l0[3],
+ g1[0],g1[1],g1[2],g1[3]);
+ printf("=====================\n");
+ //
+ */
+ return;
+}
+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::PrintAscii(ostream *os)const{
+ // Print out class data values in Ascii Form to output stream
+ // Inputs:
+ // ostream *os Output stream where Ascii data is to be writen
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+#if defined __GNUC__
+#if __GNUC__ > 2
+ ios::fmtflags fmt;
+#else
+ Int_t fmt;
+#endif
+#else
+#if defined __ICC || defined __ECC || defined __xlC__
+ ios::fmtflags fmt;
+#else
+ Int_t fmt;
+#endif
+#endif
+
+ *os << fByThick << " ";
+ *os << fMajorVersion << " " << fMinorVersion << " ";
+ fmt = os->setf(ios::scientific); // set scientific floating point output
+ *os << fDet1 << " " << fDet2 << " " << fChip1 << " " << fChip2 << " ";
+ *os << fRails << " " << fFluid << " " << fIDMother;
+ os->flags(fmt); // reset back to old Formating.
+ return;
+}
+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::ReadAscii(istream *is){
+ // Read in class data values in Ascii Form to output stream
+ // Inputs:
+ // istream *is Input stream where Ascii data is to be read in from
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ *is >> fByThick;
+ *is >> fMajorVersion >> fMinorVersion;
+ *is >> fDet1 >> fDet2 >> fChip1 >> fChip2;
+ *is >> fRails >> fFluid >> fIDMother;
+ fIgm.SetVersion((AliITSVersion_t)fMajorVersion,fMinorVersion);
+ fIgm.SetGeometryName("ITS PPR aymmetric services with course"
+ " cables on cones");
+}
+
+//______________________________________________________________________
+ostream &operator<<(ostream &os,const AliITSvPPRasymmFMD &s){
+ // Standard output streaming function
+ // Inputs:
+ // ostream &os output steam
+ // AliITSvPPRasymmFMD &s class to be streamed.
+ // Output:
+ // none.
+ // Return:
+ // ostream &os The stream pointer
+
+ s.PrintAscii(&os);
+ return os;
+}
+
+//______________________________________________________________________
+istream &operator>>(istream &is,AliITSvPPRasymmFMD &s){
+ // Standard inputput streaming function
+ // Inputs:
+ // istream &is input steam
+ // AliITSvPPRasymmFMD &s class to be streamed.
+ // Output:
+ // none.
+ // Return:
+ // ostream &os The stream pointer
+
+ s.ReadAscii(&is);
+ return is;
+}