]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrackingSector.cxx
Updating Run Types for TRIGGER pp.
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
index 22521eaeeddde41056c0b4602f8f2c31de288194..99789dcee3c6e1cb4c2553369451a52b6ae0cc57 100644 (file)
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-
-/*
-$Log$
-Revision 1.7  2001/11/19 08:44:08  cblume
-Fix bugs reported by Rene
-
-Revision 1.6  2001/05/28 17:07:58  hristov
-Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
-
-Revision 1.5  2000/12/08 16:07:02  cblume
-Update of the tracking by Sergei
-
-Revision 1.4  2000/10/16 01:16:53  cblume
-Changed timebin 0 to be the one closest to the readout
-
-Revision 1.3  2000/10/15 23:40:01  cblume
-Remove AliTRDconst
-
-Revision 1.2  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.1.2.2  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.1.2.1  2000/09/22 14:47:52  cblume
-Add the tracking code
-
-*/ 
-
-/////////////////////////////////////////////////////////////////////////
-//                                                                     //
-//  Tracking sector                                                    //
-//                                                                     //
-/////////////////////////////////////////////////////////////////////////                       
-                                
-#include <TObject.h>
-
-#include "AliRun.h"
-
-#include "AliTRD.h" 
-#include "AliTRDgeometry.h" 
-#include "AliTRDcluster.h" 
-#include "AliTRDtimeBin.h" 
-#include "AliTRDtrackingSector.h" 
-
-ClassImp(AliTRDtrackingSector) 
-
-//_______________________________________________________
-AliTRDtrackingSector::~AliTRDtrackingSector()
-{
-  //
-  // Destructor
-  //
-
-  delete fTimeBin;
-
-}
-
-//_______________________________________________________
-AliTRDtimeBin &AliTRDtrackingSector::operator[](Int_t i)
-{
-  //
-  // Index operator 
-  //
-
-  return *(fTimeBin+i);
-
-}
-
-//_______________________________________________________
-void AliTRDtrackingSector::SetUp()
-{ 
-  //
-  // Initialization
-  //
-
-  AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
-  fGeom = trd->GetGeometry();
-
-  fTimeBinSize = fGeom->GetTimeBinSize();
-
-  fN = AliTRDgeometry::Nplan() * (Int_t(AliTRDgeometry::DrThick()
-                                       /fTimeBinSize) + 1);
-
-  fTimeBin = new AliTRDtimeBin[fN]; 
-
-}
-
-//______________________________________________________
-Double_t AliTRDtrackingSector::GetX(Int_t tb) const
-{
-  //
-  // Get global x coordinate
-  //
-
-  if( (tb<0) || (tb>fN-1)) {
-    fprintf(stderr,"AliTRDtrackingSector::GetX: TimeBin index is out of range !\n");
-    return -99999.;
-  }
-  else { 
-    
-    Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
-    Int_t localTb = tbPerPlane - tb%tbPerPlane - 1;
-
-    Int_t plane = tb/tbPerPlane;
-    Float_t t0 = fGeom->GetTime0(plane);
-    Double_t x = t0 - (localTb + 0.5) * fTimeBinSize;
-
-    return x;
-
-  }
-
-}
-
-//______________________________________________________
-Int_t AliTRDtrackingSector::GetTimeBinNumber(Double_t x) const
-{
-  //
-  // Returns the time bin number
-  //
-
-  Float_t rOut = fGeom->GetTime0(AliTRDgeometry::Nplan()-1); 
-  Float_t rIn  = fGeom->GetTime0(0) - AliTRDgeometry::DrThick();
-
-
-  if(x >= rOut) return fN-1;
-  if(x <= rIn)  return 0;
-
-  Int_t plane;
-  for (plane = AliTRDgeometry::Nplan()-1; plane >= 0; plane--) {
-    if(x > (fGeom->GetTime0(plane) - AliTRDgeometry::DrThick())) break;
-  }  
-  Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
-  Int_t localTb = Int_t((fGeom->GetTime0(plane)-x)/fTimeBinSize);
-
-  if((localTb < 0) || (localTb >= tbPerPlane)) {
-    printf("AliTRDtrackingSector::GetTimeBinNumber: \n");
-    printf("local time bin %d is out of bounds [0..%d]: x = %f \n",
-          localTb,tbPerPlane-1,x);
-    return -1;
-  }
-      
-  Int_t timeBin = (plane + 1) * tbPerPlane - 1 - localTb;
-
-  return timeBin;
-}
-
-//______________________________________________________
-Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t localTb) const 
-{
-  //
-  // Time bin
-  //
-
-  Int_t plane = fGeom->GetPlane(det);
-
-  Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
-
-  Int_t timeBin = (plane + 1) * tbPerPlane - 1 - localTb;
-
-  return timeBin;
-
-}
-
-
-//______________________________________________________
-
-Bool_t AliTRDtrackingSector::TECframe(Int_t tb, Double_t y, Double_t z) const
-{
-  //  
-  // Returns <true> if point defined by <x(tb),y,z> is within 
-  // the TEC G10 frame, otherwise returns <false>  
-  //  
-
-  if((tb > (fN-1)) || (tb < 0)) return kFALSE; 
-
-  Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
-  Int_t plane = tb/tbPerPlane;
-  
-  Double_t x = GetX(tb);
-  y = TMath::Abs(y);
-
-  if((y > fGeom->GetChamberWidth(plane)/2.) &&
-     (y < x*TMath::Tan(0.5*AliTRDgeometry::GetAlpha()))) return kTRUE; 
-
-  Double_t zmin, zmax;
-  Float_t  fRowPadSize, fRow0;
-  Int_t    nPadRows;
-
-  for(Int_t iCha = 1; iCha < AliTRDgeometry::Ncham(); iCha++) {
-
-    fRow0 = fGeom->GetRow0(plane,iCha-1,0);
-    fRowPadSize = fGeom->GetRowPadSize(plane,iCha-1,0);
-    nPadRows = fGeom->GetRowMax(plane,iCha-1,0);
-    zmin = fRow0 - fRowPadSize/2 + fRowPadSize * nPadRows;
-
-    fRow0 = fGeom->GetRow0(plane,iCha,0);
-    fRowPadSize = fGeom->GetRowPadSize(plane,iCha,0);
-    zmax = fRow0 - fRowPadSize/2;
-
-    if((z > zmin) && (z < zmax)) return kTRUE;     
-  }
-
-  return kFALSE;
-
-}
+/**************************************************************************\r
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+*                                                                        *\r
+* Author: The ALICE Off-line Project.                                    *\r
+* Contributors are mentioned in the code where appropriate.              *\r
+*                                                                        *\r
+* Permission to use, copy, modify and distribute this software and its   *\r
+* documentation strictly for non-commercial purposes is hereby granted   *\r
+* without fee, provided that the above copyright notice appears in all   *\r
+* copies and that both the copyright notice and this permission notice   *\r
+* appear in the supporting documentation. The authors make no claims     *\r
+* about the suitability of this software for any purpose. It is          *\r
+* provided "as is" without express or implied warranty.                  *\r
+**************************************************************************/\r
+\r
+/* $Id: AliTRDtrackingSector.cxx 23810 2008-02-08 09:00:27Z hristov $ */\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+//                                                                           //\r
+//  Tracking data container for one sector                                   //\r
+//                                                                           //\r
+//  Authors:                                                                 //\r
+//    Alex Bercuci <A.Bercuci@gsi.de>                                        //\r
+//    Markus Fasel <M.Fasel@gsi.de>                                          //\r
+//                                                                           //\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "AliTRDtrackingSector.h"\r
+#include "AliTRDtrackingChamber.h"\r
+\r
+\r
+ClassImp(AliTRDtrackingSector)\r
+\r
+//_____________________________________________________________________________\r
+AliTRDtrackingSector::AliTRDtrackingSector()\r
+  :fSector(-1)\r
+  ,fN(0)\r
+  ,fGeom(NULL)\r
+{\r
+  // Default constructor\r
+  \r
+  memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
+  memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
+  memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)\r
+  :fSector(gs)\r
+  ,fN(0)\r
+  ,fGeom(geo)\r
+{\r
+  //\r
+  // AliTRDtrackingSector Constructor\r
+  //\r
+\r
+  memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
+  memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
+  memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
+}\r
+\r
+    \r
+//_____________________________________________________________________________\r
+void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec, const AliTRDCalDet *cal)\r
+{              \r
+//     Steer building of tracking chambers and build tracking sector.\r
+//     Propagate radial position information (calibration/alignment aware) from chambers to sector level\r
+//\r
+  \r
+  AliTRDchamberTimeBin *tb = NULL;\r
+  AliTRDtrackingChamber **tc = &fChamber[0];\r
+  for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){\r
+    for(Int_t itb=0; itb<AliTRDseedV1::kNtb; itb++){\r
+      if(!(tb = (*tc)->GetTB(itb))) continue;\r
+      tb->SetReconstructor(rec);\r
+    }\r
+    (*tc)->Build(fGeom, cal, rec->IsHLT());\r
+  }\r
+    \r
+  Int_t nl;\r
+  for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
+    fX0[il] = 0.; nl = 0;\r
+    for(int is=0; is<AliTRDgeometry::kNstack; is++){\r
+      Int_t idx = is*AliTRDgeometry::kNlayer + il;\r
+      if(fIndex[idx]<0) continue;\r
+      fX0[il] += GetChamber(fIndex[idx])->GetX(); \r
+      nl++; \r
+    }\r
+    if(!nl){\r
+      //printf("Could not estimate radial position  of plane %d in sector %d.\n", ip, fSector);\r
+      continue;\r
+    }\r
+    fX0[il] /= Float_t(nl);\r
+  }\r
+}\r
+\r
+\r
+\r
+//_____________________________________________________________________________\r
+void AliTRDtrackingSector::Clear(const Option_t *opt)\r
+{\r
+// Reset counters and steer chamber clear\r
+\r
+  AliTRDtrackingChamber **tc = &fChamber[0];\r
+  for(Int_t ich=0; ich<fN; ich++, tc++){ \r
+    (*tc)->Clear(opt);\r
+    delete (*tc); (*tc) = NULL;   // I would avoid\r
+  }    \r
+  memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
+  fN = 0;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t layer, Bool_t build)\r
+{\r
+// Return chamber at position (stack, plane) in current \r
+// sector or build a new one if it is not already created\r
+  \r
+  Int_t ch = stack*AliTRDgeometry::kNlayer + layer;\r
+  if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];\r
+  else if(!build) return NULL;\r
+  \r
+  // CHAMBER HAS TO BE BUILD\r
+  Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);\r
+  fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; \r
+  fN++;\r
+  \r
+  memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (AliTRDgeometry::kNdets-fIndex[ch]-1)*sizeof(void*));\r
+  for(Int_t ic = ch+1; ic<AliTRDgeometry::kNdets; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;\r
+  \r
+  AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();\r
+  chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));\r
+  return chmb;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)\r
+{\r
+// Return chamber at position (stack, plane) in current \r
+// sector or build a new one if it is not already created\r
+  \r
+  if(stack<0 || stack>=AliTRDgeometry::kNstack) return NULL;\r
+  \r
+  Int_t ich, n = 0;\r
+  for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
+    ich = stack*AliTRDgeometry::kNlayer + il;\r
+    if(fIndex[ich] < 0) fStack[il] = NULL; \r
+    else{\r
+      fStack[il] = fChamber[Int_t(fIndex[ich])];\r
+      n++;\r
+    }\r
+  }\r
+  \r
+  return n ? &fStack[0] : NULL;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTRDtrackingSector::Print(Option_t *opt) const\r
+{\r
+// Dump info about this tracking sector and the tracking chamber within\r
+// \r
+\r
+  printf("\n\tSector[%2d]\n", fSector);\r
+  for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
+    for(int is =0; is<AliTRDgeometry::kNstack; is++){\r
+      Int_t ch = is*AliTRDgeometry::kNlayer + il;\r
+      if(opt) fChamber[Int_t(fIndex[ch])]->Print(opt);\r
+      else printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);\r
+    }\r
+    if(!opt) printf("\n");\r
+  }\r
+\r
+}\r