]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/AliMCInfo.cxx
Dixed a crash when no proper files/data to display (Mikolaj)
[u/mrichter/AliRoot.git] / PWG1 / AliMCInfo.cxx
index d54d4c6b95a2b1df5c40baf0484517ad9852356d..986305bd3ec1f8a2e1bc00e0dd9f092f82828771 100644 (file)
 Origin: marian.ivanov@cern.ch
 Container classes with MC infomation
 
+The AliMCInfo contains the information about the particles properties 
+during transportation throuch ALICE Detector
+
+The base Information :
+TParticle - fParticle             -  properties of the particle at creation point
+AliTrackReference - fXXXRefernces -  TClonesArray of refernces in differnt detectors
+fNXXXRef                          -  number of the track refernces in differnt detectors
+AliTPCdigitRow    - fTPCRow       -  the map of the hitted rows - (will be repalced by TBits)
+fRowsWith*                        - number of rows hitted by particle
+fMCtracks         -               - number of turn over of the track inside of the TPC
+
+++++
+some additional information usable for tree draw - TO SPEED UP tree queries
+IMPORTANT FOR PROOF FAST PROTOTYPING ANALYSIS 
+                                      
+
+
+
 */
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 #include <stdio.h>
-#include <string.h>
 //ROOT includes
-#include "TROOT.h"
 #include "Rtypes.h"
-#include "TFile.h"
-#include "TTree.h"
-#include "TChain.h"
-#include "TCut.h"
-#include "TString.h"
-#include "TStopwatch.h"
-#include "TParticle.h"
-#include "TSystem.h"
-#include "TCanvas.h"
-#include "TGeometry.h"
-#include "TPolyLine3D.h"
-
+#include "TClonesArray.h"
 //ALIROOT includes
-#include "AliRun.h"
-#include "AliStack.h"
-#include "AliSimDigits.h"
-#include "AliTPCParam.h"
-#include "AliTPC.h"
-#include "AliTPCLoader.h"
-#include "AliDetector.h"
 #include "AliTrackReference.h"
-#include "AliTPCParamSR.h"
-#include "AliTracker.h"
-#include "AliMagF.h"
-#include "AliHelix.h"
-#include "AliTrackPointArray.h"
-
-#endif
 #include "AliMCInfo.h" 
+#endif
+
 //
 // 
 
@@ -82,6 +75,7 @@ AliMCInfo::AliMCInfo():
   fRowsWithDigitsInn(0),
   fRowsWithDigits(0),
   fRowsTrackLength(0),
+  fTPCtrackLength(-1),
   fPrim(0),
   fTPCRow(), 
   fNTPCRef(0),                    // tpc references counter
@@ -93,6 +87,9 @@ AliMCInfo::AliMCInfo():
   fTRDReferences(0),
   fTOFReferences(0)
 {
+  //
+  // Default constructor
+  //
   fTPCReferences  = new TClonesArray("AliTrackReference",10);
   fITSReferences  = new TClonesArray("AliTrackReference",10);
   fTRDReferences  = new TClonesArray("AliTrackReference",10);
@@ -118,6 +115,7 @@ AliMCInfo::AliMCInfo(const AliMCInfo& info):
   fRowsWithDigitsInn(info.fRowsWithDigitsInn),
   fRowsWithDigits(info.fRowsWithDigits),
   fRowsTrackLength(info.fRowsTrackLength),
+  fTPCtrackLength(info.fTPCtrackLength),
   fPrim(info.fPrim),
   fTPCRow(info.fTPCRow), 
   fNTPCRef(info.fNTPCRef),                    // tpc references counter
@@ -129,6 +127,9 @@ AliMCInfo::AliMCInfo(const AliMCInfo& info):
   fTRDReferences(0),
   fTOFReferences(0)
 {
+  //
+  // copy constructor
+  //
   fTPCReferences = (TClonesArray*)info.fTPCReferences->Clone();
   fITSReferences = (TClonesArray*)info.fITSReferences->Clone();
   fTRDReferences = (TClonesArray*)info.fTRDReferences->Clone();
@@ -136,8 +137,21 @@ AliMCInfo::AliMCInfo(const AliMCInfo& info):
 }
 
 
+AliMCInfo& AliMCInfo::operator=(const AliMCInfo& info) { 
+  //
+  // Assignment operator
+  //
+  this->~AliMCInfo();
+  new (this) AliMCInfo(info);
+  return *this;
+}
+
+
 AliMCInfo::~AliMCInfo()
 {
+  //
+  // Destructor of the class
+  //
   if (fTPCReferences) {
     delete fTPCReferences;
   }
@@ -157,32 +171,12 @@ AliMCInfo::~AliMCInfo()
 
 void AliMCInfo::Update()
 {
+  //
+  // Update MC info
+  // Calculates some derived variables
   //
   //
   fMCtracks =1;
-  if (!fTPCReferences) {
-    fNTPCRef =0;
-    return;
-  }
-  Float_t direction=1;
-  //Float_t rlast=0;
-  fNTPCRef = fTPCReferences->GetEntriesFast();
-  fNITSRef = fITSReferences->GetEntriesFast();
-  fNTRDRef = fTRDReferences->GetEntriesFast();
-  fNTOFRef = fTOFReferences->GetEntriesFast();
-  
-  for (Int_t iref =0;iref<fTPCReferences->GetEntriesFast();iref++){
-    AliTrackReference * ref = (AliTrackReference *) fTPCReferences->At(iref);
-    //Float_t r = (ref->X()*ref->X()+ref->Y()*ref->Y());
-    Float_t newdirection = ref->X()*ref->Px()+ref->Y()*ref->Py(); //inside or outside
-    if (iref==0) direction = newdirection;
-    if ( newdirection*direction<0){
-      //changed direction
-      direction = newdirection;
-      fMCtracks+=1;
-    }
-    //rlast=r;                     
-  }
   //
   // decay info
   fTPCdecay=kFALSE;
@@ -240,14 +234,17 @@ AliTPCdigitRow::AliTPCdigitRow()
 ////////////////////////////////////////////////////////////////////////
 AliTPCdigitRow & AliTPCdigitRow::operator=(const AliTPCdigitRow &digOld)
 {
-  for (Int_t i = 0; i<kgRowBytes; i++) fDig[i] = digOld.fDig[i];
+  for (Int_t i = 0; i<32; i++) fDig[i] = digOld.fDig[i];
   return (*this);
 }
 ////////////////////////////////////////////////////////////////////////
 void AliTPCdigitRow::SetRow(Int_t row) 
 {
-  if (row >= 8*kgRowBytes) {
-    cerr<<"AliTPCdigitRow::SetRow: index "<<row<<" out of bounds."<<endl;
+  //
+  // set bit mask for given row
+  //
+  if (row >= 8*32) {
+    //    cerr<<"AliTPCdigitRow::SetRow: index "<<row<<" out of bounds."<<endl;
     return;
   }
   Int_t iC = row/8;
@@ -273,7 +270,7 @@ Int_t AliTPCdigitRow::RowsOn(Int_t upto) const
 // count only rows less equal row number upto
 //
   Int_t total = 0;
-  for (Int_t i = 0; i<kgRowBytes; i++) {
+  for (Int_t i = 0; i<32; i++) {
     for (Int_t j = 0; j < 8; j++) {
       if (i*8+j > upto) return total;
       if (TESTBIT(fDig[i],j))  total++;
@@ -287,7 +284,7 @@ void AliTPCdigitRow::Reset()
 //
 // resets all rows to zero
 //
-  for (Int_t i = 0; i<kgRowBytes; i++) {
+  for (Int_t i = 0; i<32; i++) {
     fDig[i] <<= 8;
   }
 }
@@ -298,7 +295,7 @@ Int_t AliTPCdigitRow::Last() const
 // returns the last row number with a digit
 // returns -1 if now digits 
 //
-  for (Int_t i = kgRowBytes-1; i>=0; i--) {
+  for (Int_t i = 32-1; i>=0; i--) {
     for (Int_t j = 7; j >= 0; j--) {
       if TESTBIT(fDig[i],j) return i*8+j;
     }
@@ -312,7 +309,7 @@ Int_t AliTPCdigitRow::First() const
 // returns the first row number with a digit
 // returns -1 if now digits 
 //
-  for (Int_t i = 0; i<kgRowBytes; i++) {
+  for (Int_t i = 0; i<32; i++) {
     for (Int_t j = 0; j < 8; j++) {
       if (TESTBIT(fDig[i],j)) return i*8+j;
     }
@@ -345,3 +342,56 @@ Float_t AliMCInfo::TPCBetheBloch(Float_t bg)
   return ((Float_t)((kp2-aa-bb)*kp1/aa));
 }
 
+
+void AliMCInfo::CalcTPCrows(TClonesArray * runArrayTR){
+  //
+  // Calculates the numebr of the track references for detectors
+  // In case of changing direction - curling tracks - the counter is not increasing
+  //
+  // Rough calculation 
+  // of the first and last point in the TPC  
+  //
+  fNTPCRef = 0;
+  fNITSRef = 0;
+  fNTRDRef = 0;
+  fNTOFRef = 0;  
+  Float_t tpcminRadius=250;
+  Float_t tpcmaxRadius=80;
+  Float_t dir=0;
+  Int_t nover=0;
+  
+  for (Int_t iTrackRef = 0; iTrackRef < runArrayTR->GetEntriesFast(); iTrackRef++) {
+    //
+    AliTrackReference *ref = (AliTrackReference*)runArrayTR->At(iTrackRef);  
+    Float_t newdirection = (ref->X()*ref->Px()+ref->Y()*ref->Py()>0)? 1.:-1.; //inside or outside
+    if (dir*newdirection<0.5) {
+      nover++;
+      dir = newdirection;
+    }
+    //
+    if (ref->DetectorId()== AliTrackReference::kTRD){
+      tpcmaxRadius =250;
+      fNTRDRef++;
+    }
+    if (ref->DetectorId()== AliTrackReference::kITS){
+      fNITSRef++;
+      tpcminRadius =90;
+    }
+    if (ref->DetectorId()== AliTrackReference::kITS){
+      fNTOFRef++;
+      tpcmaxRadius =250;
+    }
+    //
+    if (ref->DetectorId()== AliTrackReference::kTPC){
+      fNTPCRef++;
+      if (ref->R()>tpcmaxRadius) tpcmaxRadius = ref->R();
+      if (ref->R()<tpcminRadius) tpcminRadius = ref->R();
+    }
+    if (ref->DetectorId()== AliTrackReference::kDisappeared){
+      if (TMath::Abs(ref->Z())<250 && TMath::Abs(ref->R()<250))
+       tpcmaxRadius = ref->R();
+    }
+  }
+  fTPCtrackLength = tpcmaxRadius-tpcminRadius;
+  fMCtracks=nover;
+}