]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPC.cxx
Updated flags for low flux case (A. Dainese)
[u/mrichter/AliRoot.git] / TPC / AliTPC.cxx
index 48cfe97f8f4e10df3e0d07cddfc4f3f48fa23c7d..1b2ae45453061d36a6b8beb464d1181bc6441955 100644 (file)
@@ -83,6 +83,7 @@
 #include "AliTPCExB.h"
 #include "AliRawReader.h"
 #include "AliTPCRawStream.h"
+#include "TTreeStream.h"
 
 ClassImp(AliTPC) 
 //_____________________________________________________________________________
@@ -101,8 +102,8 @@ ClassImp(AliTPC)
                   fNoiseTable(0),
                   fCurrentNoise(0),
                   fActiveSectors(0),
-                   fGainFactor(1.)
-                   
+                   fGainFactor(1.),
+    fDebugStreamer(0)
 
 {
   //
@@ -135,7 +136,8 @@ AliTPC::AliTPC(const char *name, const char *title)
                   fNoiseTable(0),
                   fCurrentNoise(0),
                    fActiveSectors(0),
-                   fGainFactor(1.)
+    fGainFactor(1.),
+     fDebugStreamer(0)
                   
 {
   //
@@ -178,11 +180,13 @@ AliTPC::AliTPC(const char *name, const char *title)
 
 
   if (!strcmp(title,"Default")) {       
-    fTPCParam = new AliTPCParamSR;
+    //fTPCParam = new AliTPCParamSR;
+    fTPCParam = AliTPCcalibDB::Instance()->GetParameters();
   } else {
     AliWarning("In Config.C you must set non-default parameters.");
     fTPCParam=0;
   }
+
 }
 
 //_____________________________________________________________________________
@@ -195,14 +199,14 @@ AliTPC::~AliTPC()
   fIshunt   = 0;
   delete fHits;
   delete fDigits;
-  delete fTPCParam;
+  //delete fTPCParam;
   delete fTrackHits; //MI 15.09.2000
   //  delete fTrackHitsOld; //MI 10.12.2001
   
   fDigitsArray = 0x0;
   delete [] fNoiseTable;
   delete [] fActiveSectors;
-
+  if (fDebugStreamer) delete fDebugStreamer;
 }
 
 //_____________________________________________________________________________
@@ -1206,14 +1210,21 @@ void AliTPC::SetDefaults(){
   AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName());
   rl->CdGAFile();
   AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60");
-  if(param){
-    AliInfo("You are using 2 pad-length geom hits with 3 pad-lenght geom digits...");
-    delete param;
-    param = new AliTPCParamSR();
-  }
-  else {
-    param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60_150x60");
-  }
+  // if(param){
+//     AliInfo("You are using 2 pad-length geom hits with 3 pad-lenght geom digits...");
+//     delete param;
+//     param = new AliTPCParamSR();
+//   }
+//   else {
+//     param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60_150x60");
+//   }
+  param = (AliTPCParamSR*)AliTPCcalibDB::Instance()->GetParameters();
+  if (!param->IsGeoRead()){
+      //
+      // read transformation matrices for gGeoManager
+      //
+      param->ReadGeoMatrices();
+    }
   if(!param){
     AliFatal("No TPC parameters found");
   }
@@ -1222,11 +1233,24 @@ void AliTPC::SetDefaults(){
   AliTPCPRF2D    * prfinner   = new AliTPCPRF2D;
   AliTPCPRF2D    * prfouter1   = new AliTPCPRF2D;
   AliTPCPRF2D    * prfouter2   = new AliTPCPRF2D;  
-  AliTPCRF1D     * rf    = new AliTPCRF1D(kTRUE);
-  rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
-  rf->SetOffset(3*param->GetZSigma());
-  rf->Update();
+
   
+  //AliTPCRF1D     * rf    = new AliTPCRF1D(kTRUE);
+  //rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
+  //rf->SetOffset(3*param->GetZSigma());
+  //rf->Update();
+  //
+  // Use gamma 4
+  //
+  char  strgamma4[1000];
+  sprintf(strgamma4,"AliTPCRF1D::Gamma4((x-0.135+%f)*%f,55,160)",3*param->GetZSigma(), 1000000000*param->GetTSample()/param->GetZWidth());
+  
+  TF1 * fgamma4 = new TF1("fgamma4",strgamma4, -1,1);
+  AliTPCRF1D     * rf    = new AliTPCRF1D(kTRUE,1000);
+  rf->SetParam(fgamma4,param->GetZWidth(), 1,0.2);
+  rf->SetOffset(3*param->GetZSigma()); 
+  rf->Update();
+
   TDirectory *savedir=gDirectory;
   TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
   if (!f->IsOpen()) 
@@ -1421,6 +1445,7 @@ void AliTPC::Hits2SDigits()
   //-----------------------------------------------------------
   //   summable digits - 16 bit "ADC", no noise, no saturation
   //-----------------------------------------------------------
+  if (0) fDebugStreamer = new TTreeSRedirector("TPCSimdebug.root");
 
   if (!fTPCParam->IsGeoRead()){
     //
@@ -1442,6 +1467,10 @@ void AliTPC::Hits2SDigits()
 
   fLoader->UnloadHits();
   fLoader->UnloadSDigits();
+  if (fDebugStreamer) {
+    delete fDebugStreamer;
+    fDebugStreamer=0;
+  }    
 }
 //_____________________________________________________________________________
 
@@ -1849,6 +1878,12 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
   // Origin: Marian Ivanov,  marian.ivanov@cern.ch
   //-----------------------------------------------------------------
   AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
+  if (gAlice){ // Set correctly the magnetic field in the ExB calculation
+    AliMagF * field = gAlice->Field();
+    if (field) {
+      calib->SetExBField(field->SolenoidField());
+    }
+  }
 
   Float_t gasgain = fTPCParam->GetGasGain();
   gasgain = gasgain/fGainFactor;
@@ -1997,7 +2032,7 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
          
        TransportElectron(xyz,index);    
        Int_t rowNumber;
-       fTPCParam->GetPadRow(xyz,index); 
+       Int_t padrow = fTPCParam->GetPadRow(xyz,index); 
        //
        // Add Time0 correction due unisochronity
        // xyz[0] - pad row coordinate 
@@ -2005,20 +2040,43 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
        // xyz[2] - is in now time bin coordinate system
        Float_t correction =0;
        if (calib->GetPadTime0()){
-         if (!calib->GetPadTime0()->GetCalROC(isec)) continue;
-         correction = calib->GetPadTime0()->GetCalROC(isec)->GetValue(TMath::Nint(xyz[0]),TMath::Nint(xyz[1]));
+         if (!calib->GetPadTime0()->GetCalROC(isec)) continue;   
+         Int_t npads = fTPCParam->GetNPads(isec,padrow);
+         //      Int_t pad  = TMath::Nint(xyz[1]+fTPCParam->GetNPads(isec,TMath::Nint(xyz[0]))*0.5);
+         // pad numbering from -npads/2 .. npads/2-1
+         Int_t pad  = TMath::Nint(xyz[1]+npads/2);
+         if (pad<0) pad=0;
+         if (pad>=npads) pad=npads-1;
+         correction = calib->GetPadTime0()->GetCalROC(isec)->GetValue(padrow,pad);
+         //      printf("%d\t%d\t%d\t%f\n",isec,padrow,pad,correction);
+         if (fDebugStreamer){
+           (*fDebugStreamer)<<"Time0"<<
+             "isec="<<isec<<
+             "padrow="<<padrow<<
+             "pad="<<pad<<
+             "x0="<<xyz[0]<<
+             "x1="<<xyz[1]<<
+             "x2="<<xyz[2]<<
+             "hit.="<<tpcHit<<
+             "cor="<<correction<<
+             "\n";
+         }
        }
        xyz[2]+=correction;
+       xyz[2]+=fTPCParam->GetNTBinsL1();    // adding Level 1 time bin offset
        //
        // Electron track time (for pileup simulation)
-       xyz[4] = tpcHit->Time()/fTPCParam->GetTSample();
+       xyz[2]+=tpcHit->Time()/fTPCParam->GetTSample(); // adding time of flight
+       xyz[4] =0;
+
+       //
        // row 0 - cross talk from the innermost row
        // row fNRow+1 cross talk from the outermost row
        rowNumber = index[2]+1; 
        //transform position to local digit coordinates
        //relative to nearest pad row 
        if ((rowNumber<0)||rowNumber>fTPCParam->GetNRow(isec)+1) continue;
-       Float_t x1,y1;
+       /*      Float_t x1,y1;
        if (isec <fTPCParam->GetNInnerSector()) {
          x1 = xyz[1]*fTPCParam->GetInnerPadPitchWidth();
          y1 = fTPCParam->GetYInner(rowNumber);
@@ -2030,7 +2088,7 @@ void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
        // gain inefficiency at the wires edges - linear
        x1=TMath::Abs(x1);
        y1-=1.;
-       if(x1>y1) xyz[3]*=TMath::Max(1.e-6,(y1-x1+1.)); 
+       if(x1>y1) xyz[3]*=TMath::Max(1.e-6,(y1-x1+1.)); */
        
        nofElectrons[rowNumber]++;        
        //----------------------------------
@@ -2088,32 +2146,6 @@ void AliTPC::Init()
   AliDebug(1,"*********************************************");
 }
 
-//_____________________________________________________________________________
-void AliTPC::MakeBranch(Option_t* option)
-{
-  //
-  // Create Tree branches for the TPC.
-  //
-  AliDebug(1,"");
-  Int_t buffersize = 4000;
-  char branchname[10];
-  sprintf(branchname,"%s",GetName());
-  
-  const char *h = strstr(option,"H");
-  
-  if ( h && (fHitType<=1) && (fHits == 0x0)) fHits = new TClonesArray("AliTPChit", 176);//skowron 20.06.03
-  
-  AliDetector::MakeBranch(option);
-  
-  const char *d = strstr(option,"D");
-  
-  if (fDigits   && fLoader->TreeD() && d) {
-    MakeBranchInTree(gAlice->TreeD(), branchname, &fDigits, buffersize, 0);
-  }    
-
-  if (fHitType>1) MakeBranch2(option,0); // MI change 14.09.2000
-}
 //_____________________________________________________________________________
 void AliTPC::ResetDigits()
 {
@@ -2163,7 +2195,7 @@ void AliTPC::TransportElectron(Float_t *xyz, Int_t *index)
   // xyz and index must be already transformed to system 1
   //
 
-  fTPCParam->Transform1to2(xyz,index);
+  fTPCParam->Transform1to2(xyz,index);  // mis-alignment applied in this step
   
   //add diffusion
   Float_t driftl=xyz[2];
@@ -2659,7 +2691,15 @@ AliTPCParam* AliTPC::LoadTPCParam(TFile *file) {
     AliDebugClass(1,Form("TPC parameters %s found.",paramName));
   } else {
     AliWarningClass("TPC parameters not found. Create new (they may be incorrect)");
-    paramTPC = new AliTPCParamSR;
+    //paramTPC = new AliTPCParamSR;
+    paramTPC = AliTPCcalibDB::Instance()->GetParameters();
+    if (!paramTPC->IsGeoRead()){
+      //
+      // read transformation matrices for gGeoManager
+      //
+      paramTPC->ReadGeoMatrices();
+    }
+  
   }
   return paramTPC;