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"
51 #include "AliMathBase.h"
57 ClassImp(AliTPCdigitRow)
62 ////////////////////////////////////////////////////////////////////////
63 AliMCInfo::AliMCInfo():
76 fRowsWithDigitsInn(0),
82 fNTPCRef(0), // tpc references counter
83 fNITSRef(0), // ITS references counter
84 fNTRDRef(0), // TRD references counter
85 fNTOFRef(0), // TOF references counter
86 fNTPCRefOut(0), // tpc references counter
87 fNITSRefOut(0), // ITS references counter
88 fNTRDRefOut(0), // TRD references counter
89 fNTOFRefOut(0), // TOF references counter
96 // Default constructor
98 fTPCReferences = new TClonesArray("AliTrackReference",10);
99 fITSReferences = new TClonesArray("AliTrackReference",10);
100 fTRDReferences = new TClonesArray("AliTrackReference",10);
101 fTOFReferences = new TClonesArray("AliTrackReference",10);
102 fTRdecay.SetTrack(-1);
103 for (Int_t i=0;i<4;i++) fVDist[i]=0;
104 for (Int_t i=0;i<3;i++) fDecayCoord[i]=0;
108 AliMCInfo::AliMCInfo(const AliMCInfo& info):
110 fTrackRef(info.fTrackRef),
111 fTrackRefOut(info.fTrackRefOut),
112 fTRdecay(info.GetTRdecay()),
113 fPrimPart(info.fPrimPart),
114 fParticle(info.fParticle),
115 fMass(info.GetMass()),
116 fCharge(info.fCharge),
118 fEventNr(info.fEventNr),
119 fMCtracks(info.fMCtracks),
121 fTPCdecay(info.fTPCdecay),
122 fRowsWithDigitsInn(info.fRowsWithDigitsInn),
123 fRowsWithDigits(info.fRowsWithDigits),
124 fRowsTrackLength(info.fRowsTrackLength),
125 fTPCtrackLength(info.fTPCtrackLength),
127 fTPCRow(info.fTPCRow),
128 fNTPCRef(info.fNTPCRef), // tpc references counter
129 fNITSRef(info.fNITSRef), // ITS references counter
130 fNTRDRef(info.fNTRDRef), // TRD references counter
131 fNTOFRef(info.fNTOFRef), // TOF references counter
132 fNTPCRefOut(info.fNTPCRefOut), // tpc references counter
133 fNITSRefOut(info.fNITSRefOut), // ITS references counter
134 fNTRDRefOut(info.fNTRDRefOut), // TRD references counter
135 fNTOFRefOut(info.fNTOFRefOut), // TOF references counter
144 fTPCReferences = (TClonesArray*)info.fTPCReferences->Clone();
145 fITSReferences = (TClonesArray*)info.fITSReferences->Clone();
146 fTRDReferences = (TClonesArray*)info.fTRDReferences->Clone();
147 fTOFReferences = (TClonesArray*)info.fTOFReferences->Clone();
148 for (Int_t i=0;i<4;i++) fVDist[i]=info.fVDist[i];
149 for (Int_t i=0;i<3;i++) fDecayCoord[i]=info.fDecayCoord[i];
154 AliMCInfo& AliMCInfo::operator=(const AliMCInfo& info) {
156 // Assignment operator
159 new (this) AliMCInfo(info);
164 AliMCInfo::~AliMCInfo()
167 // Destructor of the class
169 if (fTPCReferences) {
170 delete fTPCReferences;
173 delete fITSReferences;
176 delete fTRDReferences;
179 delete fTOFReferences;
187 void AliMCInfo::Update()
191 // Calculates some derived variables
198 if (fTRdecay.GetTrack()>0){
199 fDecayCoord[0] = fTRdecay.X();
200 fDecayCoord[1] = fTRdecay.Y();
201 fDecayCoord[2] = fTRdecay.Z();
202 if ( (fTRdecay.R()<250)&&(fTRdecay.R()>85) && (TMath::Abs(fTRdecay.Z())<250) ){
213 //digits information update
214 fRowsWithDigits = fTPCRow.RowsOn();
215 fRowsWithDigitsInn = fTPCRow.RowsOn(63); // 63 = number of inner rows
216 fRowsTrackLength = fTPCRow.Last() - fTPCRow.First();
219 // calculate primary ionization per cm
220 if (fParticle.GetPDG()){
221 fMass = fParticle.GetMass();
222 fCharge = fParticle.GetPDG()->Charge();
223 if (fTPCReferences->GetEntriesFast()>0){
224 fTrackRef = *((AliTrackReference*)fTPCReferences->At(0));
227 Float_t p = TMath::Sqrt(fTrackRef.Px()*fTrackRef.Px()+
228 fTrackRef.Py()*fTrackRef.Py()+
229 fTrackRef.Pz()*fTrackRef.Pz());
231 Float_t betagama = p /fMass;
232 fPrim = AliMathBase::BetheBlochAleph(betagama);
247 ////////////////////////////////////////////////////////////////////////
248 AliTPCdigitRow::AliTPCdigitRow()
252 ////////////////////////////////////////////////////////////////////////
253 AliTPCdigitRow & AliTPCdigitRow::operator=(const AliTPCdigitRow &digOld)
255 for (Int_t i = 0; i<32; i++) fDig[i] = digOld.fDig[i];
258 ////////////////////////////////////////////////////////////////////////
259 void AliTPCdigitRow::SetRow(Int_t row)
262 // set bit mask for given row
265 // cerr<<"AliTPCdigitRow::SetRow: index "<<row<<" out of bounds."<<endl;
273 ////////////////////////////////////////////////////////////////////////
274 Bool_t AliTPCdigitRow::TestRow(Int_t row) const
277 // return kTRUE if row is on
281 return TESTBIT(fDig[iC],iB);
283 ////////////////////////////////////////////////////////////////////////
284 Int_t AliTPCdigitRow::RowsOn(Int_t upto) const
287 // returns number of rows with a digit
288 // count only rows less equal row number upto
291 for (Int_t i = 0; i<32; i++) {
292 for (Int_t j = 0; j < 8; j++) {
293 if (i*8+j > upto) return total;
294 if (TESTBIT(fDig[i],j)) total++;
299 ////////////////////////////////////////////////////////////////////////
300 void AliTPCdigitRow::Reset()
303 // resets all rows to zero
305 for (Int_t i = 0; i<32; i++) {
309 ////////////////////////////////////////////////////////////////////////
310 Int_t AliTPCdigitRow::Last() const
313 // returns the last row number with a digit
314 // returns -1 if now digits
316 for (Int_t i = 32-1; i>=0; i--) {
317 for (Int_t j = 7; j >= 0; j--) {
318 if TESTBIT(fDig[i],j) return i*8+j;
323 ////////////////////////////////////////////////////////////////////////
324 Int_t AliTPCdigitRow::First() const
327 // returns the first row number with a digit
328 // returns -1 if now digits
330 for (Int_t i = 0; i<32; i++) {
331 for (Int_t j = 0; j < 8; j++) {
332 if (TESTBIT(fDig[i],j)) return i*8+j;
339 void AliMCInfo::Clear(Option_t* ){
343 if (fTPCReferences) fTPCReferences->Clear();
344 if (fITSReferences) fITSReferences->Clear();
345 if (fTRDReferences) fTRDReferences->Clear();
346 if (fTOFReferences) fTOFReferences->Clear();
347 for (Int_t i=0;i<4;i++) fVDist[i]=0;
348 for (Int_t i=0;i<3;i++) fDecayCoord[i]=0;
349 fTRdecay.SetTrack(-1);
352 fPrimPart=-1; // index of primary particle in TreeH
353 fMass=0; // mass of the particle
354 fCharge=0; // charge of the particle
355 fLabel=0; // track label
356 fEventNr=0; // event number
357 fMCtracks=0; // indication of how many times the track is retuturned back
359 fTPCdecay=0; //indicates decay in TPC
360 fRowsWithDigitsInn=0; // number of rows with digits in the inner sectors
361 fRowsWithDigits=0; // number of rows with digits in the outer sectors
362 fRowsTrackLength=0; // last - first row with digit
363 fTPCtrackLength=0; // distance between first and last track reference
364 fPrim=0; // theoretical dedx in tpc according particle momenta and mass
365 fNTPCRef=0; // tpc references counter
366 fNITSRef=0; // ITS references counter
367 fNTRDRef=0; // TRD references counter
368 fNTOFRef=0; // TOF references counter
370 fNTPCRefOut=0; // tpc references counter - out
371 fNITSRefOut=0; // ITS references counter - out
372 fNTRDRefOut=0; // TRD references counter - out
373 fNTOFRefOut=0; // TOF references counter - out
378 void AliMCInfo::CalcTPCrows(TClonesArray * runArrayTR){
380 // Calculates the numebr of the track references for detectors
381 // In case of changing direction - curling tracks - the counter is not increasing
384 // of the first and last point in the TPC
396 Float_t tpcminRadius=TMath::Max(90., fParticle.R());
397 Float_t tpcmaxRadius=TMath::Min(250.,fParticle.R());
400 if (runArrayTR->GetEntriesFast()>0){
402 AliTrackReference *ref0 = (AliTrackReference*)runArrayTR->At(0);
403 Float_t dir = ((ref0->X()*ref0->Px()+ref0->Y()*ref0->Py())>0)? 1.:-1.; //inside or outside
406 for (Int_t iTrackRef = 0; iTrackRef < runArrayTR->GetEntriesFast(); iTrackRef++) {
408 AliTrackReference *ref = (AliTrackReference*)runArrayTR->At(iTrackRef);
409 Float_t newdirection = ((ref->X()*ref->Px()+ref->Y()*ref->Py())>0)? 1.:-1.; //inside or outside
412 if (dir*newdirection<0.0) {
417 if (ref->DetectorId()== AliTrackReference::kTRD){
424 if (ref->DetectorId()== AliTrackReference::kITS){
431 if (ref->DetectorId()== AliTrackReference::kTOF){
439 if (ref->DetectorId()== AliTrackReference::kTPC){
443 fTrackRefOut = (*ref);
444 if (ref->R()>tpcmaxRadius) tpcmaxRadius = ref->R();
445 if (ref->R()<tpcminRadius) tpcminRadius = ref->R();
448 if (ref->DetectorId()== AliTrackReference::kDisappeared){
449 if (nover==0 &&TMath::Abs(ref->Z())<250){
450 tpcmaxRadius = TMath::Min(Float_t(250.),ref->R());
454 } // if we have track refs
455 fTPCtrackLength = tpcmaxRadius-tpcminRadius;
465 void AliMCInfo::Update(TParticle * part, TClonesArray * runArrayTR, Double_t pvertex[4], Int_t label){
472 AliMCInfo *info = this;
473 fVDist[0]=part->Vx()-pvertex[0];
474 fVDist[1]=part->Vy()-pvertex[1];
475 fVDist[2]=part->Vz()-pvertex[2];
476 fVDist[3]=part->R()-pvertex[3];
480 for (Int_t iTrackRef = 0; iTrackRef < runArrayTR->GetEntriesFast(); iTrackRef++) {
481 AliTrackReference *trackRef = (AliTrackReference*)runArrayTR->At(iTrackRef);
482 Int_t label = trackRef->GetTrack();
483 if (trackRef->DetectorId()== AliTrackReference::kTPC){
484 TClonesArray & arr = *(info->fTPCReferences);
485 new (arr[arr.GetEntriesFast()]) AliTrackReference(*trackRef);
487 if (trackRef->DetectorId()== AliTrackReference::kITS){
488 TClonesArray & arr = *(info->fITSReferences);
489 new (arr[arr.GetEntriesFast()]) AliTrackReference(*trackRef);
491 if (trackRef->DetectorId()== AliTrackReference::kTRD){
492 TClonesArray & arr = *(info->fTRDReferences);
493 new (arr[arr.GetEntriesFast()]) AliTrackReference(*trackRef);
495 if (trackRef->DetectorId()== AliTrackReference::kTOF){
496 TClonesArray & arr = *(info->fTOFReferences);
497 new (arr[arr.GetEntriesFast()]) AliTrackReference(*trackRef);
502 if (trackRef->DetectorId()== AliTrackReference::kDisappeared){
503 info->fTRdecay = *trackRef;
508 CalcTPCrows(runArrayTR);