1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////
20 Origin: marian.ivanov@cern.ch
21 Container classes with MC infomation
23 The AliMCInfo contains the information about the particles properties
24 during transportation throuch ALICE Detector
26 The base Information :
27 TParticle - fParticle - properties of the particle at creation point
28 AliTrackReference - fXXXRefernces - TClonesArray of refernces in differnt detectors
29 fNXXXRef - number of the track refernces in differnt detectors
30 AliTPCdigitRow - fTPCRow - the map of the hitted rows - (will be repalced by TBits)
31 fRowsWith* - number of rows hitted by particle
32 fMCtracks - - number of turn over of the track inside of the TPC
35 some additional information usable for tree draw - TO SPEED UP tree queries
36 IMPORTANT FOR PROOF FAST PROTOTYPING ANALYSIS
43 #if !defined(__CINT__) || defined(__MAKECINT__)
47 #include "TClonesArray.h"
49 #include "AliTrackReference.h"
50 #include "AliMCInfo.h"
56 ClassImp(AliTPCdigitRow)
61 ////////////////////////////////////////////////////////////////////////
62 AliMCInfo::AliMCInfo():
75 fRowsWithDigitsInn(0),
81 fNTPCRef(0), // tpc references counter
82 fNITSRef(0), // ITS references counter
83 fNTRDRef(0), // TRD references counter
84 fNTOFRef(0), // TOF references counter
91 // Default constructor
93 fTPCReferences = new TClonesArray("AliTrackReference",10);
94 fITSReferences = new TClonesArray("AliTrackReference",10);
95 fTRDReferences = new TClonesArray("AliTrackReference",10);
96 fTOFReferences = new TClonesArray("AliTrackReference",10);
97 fTRdecay.SetTrack(-1);
101 AliMCInfo::AliMCInfo(const AliMCInfo& info):
103 fTrackRef(info.fTrackRef),
104 fTrackRefOut(info.fTrackRefOut),
105 fTRdecay(info.GetTRdecay()),
106 fPrimPart(info.fPrimPart),
107 fParticle(info.fParticle),
108 fMass(info.GetMass()),
109 fCharge(info.fCharge),
111 fEventNr(info.fEventNr),
112 fMCtracks(info.fMCtracks),
114 fTPCdecay(info.fTPCdecay),
115 fRowsWithDigitsInn(info.fRowsWithDigitsInn),
116 fRowsWithDigits(info.fRowsWithDigits),
117 fRowsTrackLength(info.fRowsTrackLength),
118 fTPCtrackLength(info.fTPCtrackLength),
120 fTPCRow(info.fTPCRow),
121 fNTPCRef(info.fNTPCRef), // tpc references counter
122 fNITSRef(info.fNITSRef), // ITS references counter
123 fNTRDRef(info.fNTRDRef), // TRD references counter
124 fNTOFRef(info.fNTOFRef), // TOF references counter
133 fTPCReferences = (TClonesArray*)info.fTPCReferences->Clone();
134 fITSReferences = (TClonesArray*)info.fITSReferences->Clone();
135 fTRDReferences = (TClonesArray*)info.fTRDReferences->Clone();
136 fTOFReferences = (TClonesArray*)info.fTOFReferences->Clone();
140 AliMCInfo& AliMCInfo::operator=(const AliMCInfo& info) {
142 // Assignment operator
145 new (this) AliMCInfo(info);
150 AliMCInfo::~AliMCInfo()
153 // Destructor of the class
155 if (fTPCReferences) {
156 delete fTPCReferences;
159 delete fITSReferences;
162 delete fTRDReferences;
165 delete fTOFReferences;
172 void AliMCInfo::Update()
176 // Calculates some derived variables
183 if (fTRdecay.GetTrack()>0){
184 fDecayCoord[0] = fTRdecay.X();
185 fDecayCoord[1] = fTRdecay.Y();
186 fDecayCoord[2] = fTRdecay.Z();
187 if ( (fTRdecay.R()<250)&&(fTRdecay.R()>85) && (TMath::Abs(fTRdecay.Z())<250) ){
198 //digits information update
199 fRowsWithDigits = fTPCRow.RowsOn();
200 fRowsWithDigitsInn = fTPCRow.RowsOn(63); // 63 = number of inner rows
201 fRowsTrackLength = fTPCRow.Last() - fTPCRow.First();
204 // calculate primary ionization per cm
205 if (fParticle.GetPDG()){
206 fMass = fParticle.GetMass();
207 fCharge = fParticle.GetPDG()->Charge();
208 if (fTPCReferences->GetEntriesFast()>0){
209 fTrackRef = *((AliTrackReference*)fTPCReferences->At(0));
212 Float_t p = TMath::Sqrt(fTrackRef.Px()*fTrackRef.Px()+
213 fTrackRef.Py()*fTrackRef.Py()+
214 fTrackRef.Pz()*fTrackRef.Pz());
216 Float_t betagama = p /fMass;
217 fPrim = TPCBetheBloch(betagama);
229 ////////////////////////////////////////////////////////////////////////
230 AliTPCdigitRow::AliTPCdigitRow()
234 ////////////////////////////////////////////////////////////////////////
235 AliTPCdigitRow & AliTPCdigitRow::operator=(const AliTPCdigitRow &digOld)
237 for (Int_t i = 0; i<32; i++) fDig[i] = digOld.fDig[i];
240 ////////////////////////////////////////////////////////////////////////
241 void AliTPCdigitRow::SetRow(Int_t row)
244 // set bit mask for given row
247 // cerr<<"AliTPCdigitRow::SetRow: index "<<row<<" out of bounds."<<endl;
255 ////////////////////////////////////////////////////////////////////////
256 Bool_t AliTPCdigitRow::TestRow(Int_t row) const
259 // return kTRUE if row is on
263 return TESTBIT(fDig[iC],iB);
265 ////////////////////////////////////////////////////////////////////////
266 Int_t AliTPCdigitRow::RowsOn(Int_t upto) const
269 // returns number of rows with a digit
270 // count only rows less equal row number upto
273 for (Int_t i = 0; i<32; i++) {
274 for (Int_t j = 0; j < 8; j++) {
275 if (i*8+j > upto) return total;
276 if (TESTBIT(fDig[i],j)) total++;
281 ////////////////////////////////////////////////////////////////////////
282 void AliTPCdigitRow::Reset()
285 // resets all rows to zero
287 for (Int_t i = 0; i<32; i++) {
291 ////////////////////////////////////////////////////////////////////////
292 Int_t AliTPCdigitRow::Last() const
295 // returns the last row number with a digit
296 // returns -1 if now digits
298 for (Int_t i = 32-1; i>=0; i--) {
299 for (Int_t j = 7; j >= 0; j--) {
300 if TESTBIT(fDig[i],j) return i*8+j;
305 ////////////////////////////////////////////////////////////////////////
306 Int_t AliTPCdigitRow::First() const
309 // returns the first row number with a digit
310 // returns -1 if now digits
312 for (Int_t i = 0; i<32; i++) {
313 for (Int_t j = 0; j < 8; j++) {
314 if (TESTBIT(fDig[i],j)) return i*8+j;
321 //_____________________________________________________________________________
322 Float_t AliMCInfo::TPCBetheBloch(Float_t bg)
325 // Bethe-Bloch energy loss formula
327 const Double_t kp1=0.76176e-1;
328 const Double_t kp2=10.632;
329 const Double_t kp3=0.13279e-4;
330 const Double_t kp4=1.8631;
331 const Double_t kp5=1.9479;
333 Double_t dbg = (Double_t) bg;
335 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
337 Double_t aa = TMath::Power(beta,kp4);
338 Double_t bb = TMath::Power(1./dbg,kp5);
340 bb=TMath::Log(kp3+bb);
342 return ((Float_t)((kp2-aa-bb)*kp1/aa));
346 void AliMCInfo::CalcTPCrows(TClonesArray * runArrayTR){
348 // Calculates the numebr of the track references for detectors
349 // In case of changing direction - curling tracks - the counter is not increasing
352 // of the first and last point in the TPC
358 Float_t tpcminRadius=250;
359 Float_t tpcmaxRadius=80;
363 for (Int_t iTrackRef = 0; iTrackRef < runArrayTR->GetEntriesFast(); iTrackRef++) {
365 AliTrackReference *ref = (AliTrackReference*)runArrayTR->At(iTrackRef);
366 Float_t newdirection = (ref->X()*ref->Px()+ref->Y()*ref->Py()>0)? 1.:-1.; //inside or outside
367 if (dir*newdirection<0.5) {
372 if (ref->DetectorId()== AliTrackReference::kTRD){
376 if (ref->DetectorId()== AliTrackReference::kITS){
380 if (ref->DetectorId()== AliTrackReference::kITS){
385 if (ref->DetectorId()== AliTrackReference::kTPC){
387 if (ref->R()>tpcmaxRadius) tpcmaxRadius = ref->R();
388 if (ref->R()<tpcminRadius) tpcminRadius = ref->R();
390 if (ref->DetectorId()== AliTrackReference::kDisappeared){
391 if (TMath::Abs(ref->Z())<250 && TMath::Abs(ref->R()<250))
392 tpcmaxRadius = ref->R();
395 fTPCtrackLength = tpcmaxRadius-tpcminRadius;