Track time measurement (S.Radomski)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Feb 2003 09:04:12 +0000 (09:04 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Feb 2003 09:04:12 +0000 (09:04 +0000)
TRD/AliTRDtrack.cxx
TRD/AliTRDtracker.cxx
macros/CompareTime.C [new file with mode: 0644]
macros/CompareTimeHypothesis.C [new file with mode: 0644]

index 1cb894dbfc5e2b6263f933c72c127da70059c53b..24e9c32e331f39b4c9d416f3c952cb8c0d5ab165 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.16  2003/02/10 14:06:10  cblume
+Add tracking without tilted pads as option
+
 Revision 1.15  2003/01/27 16:34:49  cblume
 Update of tracking by Sergei and Chuncheng
 
@@ -105,7 +108,12 @@ AliTRDtrack::AliTRDtrack(const AliTRDcluster *c, UInt_t index,
   if(s*s < 1) q *= TMath::Sqrt((1-s*s)/(1+t*t));
 
   fdQdl[0] = q;
-
+  
+  // initialisation [SR, GSI 18.02.2003] (i startd for 1)
+  for(Int_t i=1; i<kMAX_CLUSTERS_PER_TRACK; i++) {
+    fdQdl[i] = 0;
+    fIndex[i] = 0;
+  }
 }                              
            
 //_____________________________________________________________________________
@@ -140,6 +148,11 @@ AliTRDtrack::AliTRDtrack(const AliTRDtrack& t) : AliKalmanTrack(t) {
     fdQdl[i]=t.fdQdl[i];
   }
 
+  // initialisation (i starts from n) [SR, GSI, 18.02.2003]
+  for(Int_t i=n; i<kMAX_CLUSTERS_PER_TRACK; i++) {
+    fdQdl[i] = 0;
+    fIndex[i] = 0;
+  }
 }                                
 
 //_____________________________________________________________________________
@@ -189,6 +202,11 @@ AliTRDtrack::AliTRDtrack(const AliKalmanTrack& t, Double_t alpha)
   fCty=c[6 ];   fCtz=c[7 ];   fCte=c32;   fCtt=c[9 ];
   fCcy=c[10];   fCcz=c[11];   fCce=c42;   fCct=c[13]; fCcc=c[14];  
 
+  // Initialization [SR, GSI, 18.02.2003]
+  for(Int_t i=0; i<kMAX_CLUSTERS_PER_TRACK; i++) {
+    fdQdl[i] = 0;
+    fIndex[i] = 0;
+  }
 }              
 
 //____________________________________________________________________________
@@ -299,6 +317,9 @@ Int_t AliTRDtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
     return 0;
   }
 
+  // track Length measurement [SR, GSI, 17.02.2003]
+  Double_t oldX = fX, oldY = fY, oldZ = fZ;  
+
   Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fY, z1=fZ;
   Double_t c1=fC*x1 - fE;
   if((c1*c1) > 1) return 0;
@@ -367,6 +388,12 @@ Int_t AliTRDtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
   fC*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
   fE+=fX*(fC-cc);    
 
+  // track time measurement [SR, GSI 17.02.2002]
+  if (IsStartedTimeIntegral()) {
+    Double_t l2 = (fX-oldX)*(fX-oldX) + (fY-oldY)*(fY-oldY) + (fZ-oldZ)*(fZ-oldZ);
+    AddTimeStep(TMath::Sqrt(l2));
+  }
+
   return 1;            
 }     
 
index e71246a5e967da372e292f4b46dc56b2cde4fe99..1518560e3b7ffba61fc22fb50af5c4742e3b96a8 100644 (file)
@@ -15,6 +15,9 @@
                                                       
 /*
 $Log$
+Revision 1.23  2003/02/10 14:06:10  cblume
+Add tracking without tilted pads as option
+
 Revision 1.22  2003/01/30 15:19:58  cblume
 New set of  parameters
 
@@ -549,6 +552,9 @@ Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
        CookLabel(ps, 1-fLabelFraction);
        UseClusters(ps);
       }
+      
+      // Propagate to outer reference plane [SR, GSI, 18.02.2003]
+      ps->PropagateTo(364.8);
       otrack_trd=ps;
       trdTree.Fill();
       cout<<found++<<'\r';
diff --git a/macros/CompareTime.C b/macros/CompareTime.C
new file mode 100644 (file)
index 0000000..d7891ab
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// This macro draws time resolution for true hypothesis and fits it with gausian
+// on a given reference plane in a given momentum range.
+// The results is then printed to a PostScript file.
+// The filename is composed out of input parameters.
+//
+// Input parameters:
+// nRefPlane - indicate the reference plane.
+//   1: in TPC  
+//   2: out TPC
+//   3: out TRD
+// 
+// minP, maxP - total momentum cuts. momentum from gAlice are used for cuts
+// 
+// The macro is using SORTED reference points in a file "trackRef.root".
+// Track references can be sorted using CopyReferences.C
+// 
+// Before using check filenames and names of trees invlolved
+// 
+// ITS tracks (nRefPlane == 1) are compared at inner TPC ref Plane
+// make shure they are properly propagated to this plane
+//
+// Sylwester Radomski, e-mail: S.Radomski@gsi.de
+// Feb 14, 2002 
+// 
+
+
+CompareTime (Int_t nRefPlane, Double_t minP, Double_t maxP) 
+{
+  
+  // Check input data Consistancy  
+  if (nRefPlane < 1 || nRefPlane > 3) {
+    cout << "Wrong Reference Plane Id ( " << nRefPalne << ") [1-3] " << endl;
+    return;
+  }
+
+  if (maxP < minP) {
+    cout << "MaxP lesser than MinP" << endl;
+    return;
+  }
+
+  // Style
+
+  gROOT->SetStyle("Plain");
+  gStyle->SetOptStat(1110);
+  gStyle->SetOptFit(11);
+
+  Double_t cc = 0.299792458;
+  AliKalmanTrack::SetConvConst(100/cc/0.4);
+  
+  const char* gFileName = "galice.root";
+  const char* refFileName = "trackRef.root";
+
+  const char* trackFileName[] = {"AliTPCtracks.root", "AliTPCBackTracks.root", "AliTRDtracks.root"};
+  const char *treeName[] = {"TreeT_ITSb_0", "seedsTPCtoTRD_0", "TRDb_0"};
+  const char *refTreeName[] = {"TPC", "TPC", "TRD"};
+
+  // Histograms
+
+  const Int_t nTypes = 5; 
+  Int_t codes[] = {11, 13, 211, 321, 2212};
+  
+  //Double_t cutoff[] = {20, 20, 20, 100, 100};
+  Double_t cutoff[] = {30, 30, 30, 100, 200};
+
+  const char *names[nTypes] = {"Electrons", "Muons", "Pions", "Kaons", "Protons"};
+  
+  TH1D *hDiffSame[nTypes];;
+
+  for(Int_t i=0; i<nTypes; i++)
+    hDiffSame[i] = new TH1D(names[i], names[i], 50, -cutoff[i], cutoff[i]);
+  
+  TH1D *hLength = new TH1D("length", "Length Resolution", 100, -0.5, 0.5);
+
+  // Particles
+
+  TFile *refFile = new TFile(gFileName, "READ");
+  gAlice = (AliRun*)refFile->Get("gAlice");
+  gAlice->GetEvent(0);
+
+
+  // Reference tracks
+
+  refFile = new TFile(refFileName, "READ");
+  TTree *treeRef = (TTree*)refFile->Get("TreeTR0_Sorted"); 
+  TBranch *trkRef = treeRef->GetBranch( refTreeName[nRefPlane-1] );
+  TClonesArray *trkRefs = new TClonesArray("AliTrackReference", 100);
+  trkRef->SetAddress(&trkRefs);
+  
+  Int_t ntracks = trkRef->GetEntries();
+  cout << ntracks << endl;
+
+  // Tracks
+  
+  TFile *trackFile = new TFile(trackFileName[nRefPlane-1]);
+
+  TTree *tracks = (TTree*)trackFile->Get(treeName[nRefPlane-1]);
+  TBranch *recTracks = tracks->GetBranch("tracks");
+  AliTPCtrack *track = 0;
+  recTracks->SetAddress(&track);
+
+  for(Int_t t=0; t<tracks->GetEntries(); t++) {
+
+    cout << t << "\r";
+    
+    recTracks->GetEvent(t);
+    
+    Int_t lab = track->GetLabel();
+    if (lab < 0 || lab > 100000) continue;
+    
+    Int_t pdg = gAlice->Particle(lab)->GetPdgCode();
+    treeRef->GetEvent(lab);
+    
+    Int_t nEntrRef = trkRefs->GetEntries();
+    
+    if (gAlice->Particle(lab)->P() < minP ) continue; 
+    if (gAlice->Particle(lab)->P() > maxP ) continue;
+    if (gAlice->Particle(lab)->GetFirstMother() != -1) continue;
+    
+    if (!(nEntrRef)) continue;
+      
+    Double_t timeTrue, timeTrack;
+    Double_t trueLength;
+
+    Int_t index =  nEntrRef-1;
+    if (nRefPlane == 1) index = 0;
+
+    timeTrue = ((AliTrackReference*)(*trkRefs)[index])->GetTime() * 1e12;
+    trueLength = ((AliTrackReference*)(*trkRefs)[index])->GetLength();
+    
+    hLength->Fill(trueLength - track->GetIntegratedLength());
+    
+    for(Int_t i=0; i<nTypes; i++) {
+      timeTrack = track->GetIntegratedTime(codes[i]);
+      if (abs(pdg) == codes[i]) hDiffSame[i]->Fill(timeTrue - timeTrack);
+    }
+  }  
+  
+  TCanvas *c = new TCanvas();
+  c->SetCanvasSize(640, 800);  
+  c->SetWindowSize(650, 830);  
+  c->Divide(2,3);
+  c->cd(1);
+  hLength->Draw();
+  hLength->SetXTitle("True Length - Measured Length [cm]");
+  
+  for(Int_t i=0; i<nTypes; i++) {
+    c->cd(2+i);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    hDiffSame[i]->Draw();  
+    hDiffSame[i]->SetXTitle("time true - measured [ps]");    
+    hDiffSame[i]->Fit("gaus");
+  }
+
+  char outFileName[80];
+  const char *refPlaneNames[] = {"inTPC", "outTPC","outTRD"}; 
+  
+  c->Modified();
+  c->ForceUpdate();
+
+  sprintf(outFileName, "time_%s_%3.2f-%3.2f.ps", refPlaneNames[nRefPlane-1], minP, maxP);
+  c->Print(outFileName);
+
+  if (treeRef) delete treeRef;
+  if (tracks) delete tracks;
+  
+}
diff --git a/macros/CompareTimeHypothesis.C b/macros/CompareTimeHypothesis.C
new file mode 100644 (file)
index 0000000..6134fc5
--- /dev/null
@@ -0,0 +1,177 @@
+//
+// This macro draws time resolution for true and false particle hypothesis
+// on a given reference plane in a given momentum range.
+// True hypothesis is painted in BLUE while false in RED
+//
+// Input parameters:
+// nRefPlane - indicate the reference plane.
+//   1: in TPC  
+//   2: out TPC
+//   3: out TRD
+// 
+// minP, maxP - total momentum cuts. momentum from gAlice are used for cuts
+// 
+// The macro is using SORTED reference points in a file "trackRef.root".
+// Track references can be sorted using CopyReferences.C
+// 
+// Before using check filenames and names of trees invlolved
+// 
+// ITS tracks (nRefPlane == 1) are compared at inner TPC ref Plane
+// make shure they are properly propagated to this plane.
+//
+// Sylwester Radomski, e-mail: S.Radomski@gsi.de
+// Feb 14, 2002 
+// 
+
+CompareTimeHypothesis (Int_t nRefPlane, Double_t minP, Double_t maxP) {
+
+  // Check input data Consistancy
+  
+  if (nRefPlane < 1 || nRefPlane > 3) {
+    cout << "Wrong Reference Plane Id ( " << nRefPalne << ") [1-3] " << endl;
+    return;
+  }
+
+  if (maxP < minP) {
+    cout << "MaxP lesser than MinP" << endl;
+    return;
+  }
+
+  // Styling
+  gROOT->SetStyle("Plain");
+  gStyle->SetOptStat(1111);
+  gStyle->SetStatH(0.2);
+  gStyle->SetStatW(0.3);
+
+  // magnetic field 0.4 T
+  Double_t cc = 0.299792458;
+  AliKalmanTrack::SetConvConst(100/cc/0.4);
+
+  const char* gFileName = "galice.root";
+  const char* refFileName = "trackRef.root";
+  
+  const char* trackFileName[] = {"AliTPCtracks.root", "AliTPCBackTracks.root", "AliTRDtracks.root"};
+  const char *treeName[] = {"TreeT_ITSb_0", "seedsTPCtoTRD_0", "TRDb_0"};
+  const char *refTreeName[] = {"TPC", "TPC", "TRD"};
+  
+  // Histograms
+
+  const Int_t nTypes = 5; 
+  Int_t codes[] = {11, 13, 211, 321, 2212};
+  
+  //Double_t cutoff[] = {20, 20, 20, 100, 100};
+  Double_t cutoff[] = {30, 30, 30, 100, 200};
+
+  const char *names[3*nTypes] = {
+    "Electrons", "Muons", "Pions", "Kaons", "Protons",
+    "11s", "13s", "211s", "321s", "2212s",
+    "11o", "13o", "211o", "321o", "2212o"
+  };
+
+  THStack *stack[nTypes];
+  TH1D *hDiffSame[nTypes], *hDiffOdd[nTypes];
+
+  for(Int_t i=0; i<nTypes; i++) {
+
+    stack[i] = new THStack(names[i], names[i]);
+    hDiffSame[i] = new TH1D(names[nTypes+i], names[nTypes+i], 50, -cutoff[i], cutoff[i]);
+    hDiffOdd[i] = new TH1D(names[2*nTypes+i], names[2*nTypes+i], 50, -cutoff[i], cutoff[i]);
+    hDiffSame[i]->SetFillColor(kBlue);
+    hDiffOdd[i]->SetFillColor(kRed);
+    
+    //hDiffSame[i]->SetFillStyle(3003);
+    //hDiffOdd[i]->SetFillStyle(3008);
+
+    stack[i]->Add(hDiffOdd[i]);
+    stack[i]->Add(hDiffSame[i]);
+  }
+  
+  TH1D *hLength = new TH1D("length", "Length Resolution", 100, -0.5, 0.5);
+
+  // Particles
+
+  TFile *refFile = new TFile(gFileName, "READ");
+  gAlice = (AliRun*)refFile->Get("gAlice");
+  gAlice->GetEvent(0);
+
+
+  // Reference tracks
+
+  refFile = new TFile(refFileName, "READ");
+  TTree *treeRef = (TTree*)refFile->Get("TreeTR0_Sorted"); 
+  TBranch *trkRef = treeRef->GetBranch(refTreeName[nRefPlane-1]);
+  TClonesArray *trkRefs = new TClonesArray("AliTrackReference", 100);
+  trkRef->SetAddress(&trkRefs);
+  
+  Int_t ntracks = trkRef->GetEntries();
+  cout << ntracks << endl;
+
+
+  // Tracks
+  TFile *trackFile = new TFile(trackFileName[nRefPlane-1]);
+  TTree *tracks = (TTree*)trackFile->Get(treeName[nRefPlane-1]);
+  TBranch *trkTracks = tracks->GetBranch("tracks");
+  AliTPCtrack *track = 0;
+  trkTracks->SetAddress(&track);
+
+  for(Int_t t=0; t<tracks->GetEntries(); t++) {
+
+    cout << t << "\r";
+    
+    trkTracks->GetEvent(t);
+    
+    Int_t lab = track->GetLabel();
+    if (lab < 0 || lab > 100000) continue;
+    
+    Int_t pdg = gAlice->Particle(lab)->GetPdgCode();
+    treeRef->GetEvent(lab);
+    
+    Int_t nEntrTRK = trkRefs->GetEntries();
+    
+    // Primaries within momentum range
+    if (gAlice->Particle(lab)->P() < minP ) continue; 
+    if (gAlice->Particle(lab)->P() > maxP ) continue;
+    if (gAlice->Particle(lab)->GetFirstMother() != -1) continue;    
+    if (!(nEntrTRK)) continue;
+      
+    Double_t timeTrue, timeTrack;
+    Double_t trueLength;
+    
+    Int_t index =  nEntrTRK-1;
+    if (nRefPlane == 1) index = 0;
+
+    timeTrue = ((AliTrackReference*)(*trkRefs)[index])->GetTime() * 1e12;
+
+    //timeTrue = gRandom->Gaus(timeTrue, 10);
+
+    trueLength = ((AliTrackReference*)(*trkRefs)[index])->GetLength();
+    hLength->Fill(trueLength - track->GetIntegratedLength());
+
+    for(Int_t i=0; i<nTypes; i++) {
+
+      timeTrack = track->GetIntegratedTime(codes[i]);
+      if (abs(pdg) == codes[i]) hDiffSame[i]->Fill(timeTrue - timeTrack);
+      else hDiffOdd[i]->Fill(timeTrue - timeTrack);      
+    }
+  }  
+  
+  TCanvas *c = new TCanvas();
+  c->SetWindowSize(640, 800);
+  c->Divide(2,3);
+
+  c->cd(1);
+  hLength->Draw();
+  hLength->SetXTitle("True Length - Measured Length [cm]");
+
+  for(Int_t i=0; i<nTypes; i++) {
+    c->cd(2+i);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    stack[i]->Draw();  
+    stack[i]->GetXaxis()->SetTitle("time true - measured [ps]");    
+  }
+
+  if (treeRef) delete treeRef;
+  if (tracks) delete tracks;
+}