1 //____________________________________________________________________
5 // Script that contains a class to get the media where a certain track
6 // was created. This is used for background studies.
8 // Use the script `Compile.C' to compile this class using ACLic.
11 #include <AliFMDHit.h>
12 #include <AliFMDInput.h>
21 @brief Media description
24 struct Media : public TNamed
28 Media(const char* name, const char* title)
29 : TNamed(name, title), fMeds(0)
31 fCount = new TNtuple(GetName(), "E/I:DET:RNG:SEC:STR:X/F:Y:Z:EDEP:PDG/I");
33 Media(const char* name)
34 : TNamed(name, "Media information"), fMeds(0), fCount(0)
36 AliDetector* det = gAlice->GetDetector(name);
38 Warning("Media", "Detector %s not found in gAlice", name);
41 fMeds = det->GetIdtmed();
43 Warning("Media", "No mediums for detector %s found", name);
46 fCount = new TNtuple(GetName(), "E/I:DET:RNG:SEC:STR:X/F:Y:Z:EDEP:PDG/I");
51 //____________________________________________________________________
53 @brief Get media where a particle is produced
56 Root> Compile("GetMedia.C")
62 class GetMedia : public AliFMDInputHits
72 //__________________________________________________________________
73 GetMedia(const char* modlist="FMD:ITS:BODY:ABSO:START:PIPE",
74 const char* output="media.root")
76 fOutput = TFile::Open(output, "RECREATE");
77 fOther = new Media("other", "Unknown media"),
78 fAll = new Media("All", "All media")
82 //__________________________________________________________________
83 Media* FindMedia(Int_t med)
87 while ((media == static_cast<Media*>(next()))) {
88 if (!media->fMeds) continue;
89 TArrayI& ids = *(media->fMeds);
90 for (Int_t i = 0; i < ids.fN; i++)
91 if (med == ids[i]) return media;
95 //__________________________________________________________________
99 Error("GetMedia", "No geometry defined - make sure you have that");
103 Error("GetMedia", "gAlice not defined");
108 while ((colon = fModList.Index(":", now)) >= 0) {
109 fMedia.Add(new Media(fModList(now, colon-now)));
112 if (now < fModList.Length())
113 fMedia.Add(new Media(now, fModList.Length()-now));
114 if (fMedia.GetEntries() <= 0) return kFALSE;
115 return AliFMDInputHits::Init();
117 //__________________________________________________________________
118 /** Begining of event
119 @param ev Event number
120 @return @c false on error */
121 Bool_t Begin(Int_t ev)
124 return AliFMDInputHits::Begin(ev);
126 //__________________________________________________________________
127 Bool_t ProcessHit(AliFMDHit* hit, TParticle* track)
129 if (!hit || !track) {
130 std::cout << "No hit or track (hit: " << hit << ", track: "
131 << track << ")" << std::endl;
134 // Get production vertex
135 Double_t vx = track->Vx();
136 Double_t vy = track->Vy();
137 Double_t vz = track->Vz();
139 fAll->fCounts->Fill(fEv, hit->Detector(),Int_t(hit->Ring()),
140 hit->Sector(), hit->Strip(),
141 hit->X(), hit->Y(), hit->Z(), hit->Edep(),
144 TGeoNode* prodNode = gGeoManager->FindNode(vx,vy,vz);
145 if (!prodNode) return kTRUE;
148 TGeoVolume* prodVol = prodNode->GetVolume();
149 if (!prodVol) return kTRUE;
152 TGeoMedium* prodMed = prodVol->GetMedium();
153 if (!prodMed) return kTRUE;
155 Media* media = FindMedia(prodMed->GetUniqueID());
156 if (media) media = fOther;
158 // r = TMath::Sqrt(hit->X() * hit->X() + hit->Y() * hit->Y());
159 // if(r!=0) Float_t wgt=1./(2. * 3.1415*r);
160 media->fCounts->Fill(fEv, hit->Detector(),Int_t(hit->Ring()),
161 hit->Sector(), hit->Strip(),
162 hit->X(), hit->Y(), hit->Z(), hit->Edep(),
166 //__________________________________________________________________
175 //____________________________________________________________________