]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtrackerMI.cxx
fix
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackerMI.cxx
index b8ef0cb201afa8a768f3a7f5147006db0606c858..16a9d47dcb350b4194ac65904a8038bc7759282c 100644 (file)
@@ -79,7 +79,7 @@
 // The systematic errors due to the misalignment and miscalibration are added to the covariance matrix
 // of the tracks (not to the clusters as they are dependent):
 // The parameters form AliTPCRecoParam are used AliTPCRecoParam::GetSystematicError
-// The systematic errors are expressed there in RMS - position (cm), angle (rad), curvature (1/cm)
+// The systematic errors are expressed there in RMS - position (cm), angle (rad), curvature (1/GeV)
 // The default values are 0. 
 //
 // The sytematic errors are added to the covariance matrix in following places:
 #include "AliTPCTransform.h"
 #include "AliTPCClusterParam.h"
 #include "AliTPCdEdxInfo.h"
+#include "AliDCSSensorArray.h"
+#include "AliDCSSensor.h"
+#include "AliDAQ.h"
+#include "AliCosmicTracker.h"
 
 //
 
+using std::cerr;
+using std::endl;
 ClassImp(AliTPCtrackerMI)
 
 
@@ -380,9 +386,11 @@ Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluste
   }
 
   if (fUseHLTClusters == 3 || fUseHLTClusters == 4) {
-    if(!AliTPCReconstructor::GetRecoParam()->GetUseHLTOnePadCluster()) {
-      if (TMath::Abs(cluster->GetSigmaY2()) < kAlmost0)
-       return 2;
+    if (fIteration==2){
+      if(!AliTPCReconstructor::GetRecoParam()->GetUseHLTOnePadCluster()) {
+       if (TMath::Abs(cluster->GetSigmaY2()) < kAlmost0)
+         return 2;
+      }
     }
   }
 
@@ -1201,15 +1209,13 @@ Int_t  AliTPCtrackerMI::LoadClusters(const TObjArray *arr)
     }
     if (left ==0){
       tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
-      tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
       for (Int_t j=0;j<tpcrow->GetN1();++j) 
        tpcrow->SetCluster1(j, *(AliTPCclusterMI*)(clrow->GetArray()->At(j)));
     }
     if (left ==1){
       tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
-      tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
       for (Int_t j=0;j<tpcrow->GetN2();++j) 
-       tpcrow->SetCluster2(j,*(AliTPCclusterMI*)(clrow->GetArray()->At(j)));
+       tpcrow->SetCluster2(j, *(AliTPCclusterMI*)(clrow->GetArray()->At(j)));
     }
     clrow->GetArray()->Clear("C");
   }
@@ -1258,13 +1264,13 @@ Int_t  AliTPCtrackerMI::LoadClusters(const TClonesArray *arr)
       if(row == 27 || row == 76) continue;
     }
 
-    Int_t left=0;
+    //    Int_t left=0;
     if (sec<fkNIS*2){
-      left = sec/fkNIS;
+      //      left = sec/fkNIS;
       fInnerSec[sec%fkNIS].InsertCluster(clust, count[sec][row], fkParam);    
     }
     else{
-      left = (sec-fkNIS*2)/fkNOS;
+      //      left = (sec-fkNIS*2)/fkNOS;
       fOuterSec[(sec-fkNIS*2)%fkNOS].InsertCluster(clust, count[sec][row], fkParam);
     }
   }
@@ -1282,7 +1288,7 @@ Int_t  AliTPCtrackerMI::LoadClusters()
 {
   //
   // load clusters to the memory
-  AliTPCClustersRow *clrow= new AliTPCClustersRow("AliTPCclusterMI");
+  static AliTPCClustersRow *clrow= new AliTPCClustersRow("AliTPCclusterMI");
   //
   //  TTree * tree = fClustersArray.GetTree();
 
@@ -1315,19 +1321,17 @@ Int_t  AliTPCtrackerMI::LoadClusters()
     }
     if (left ==0){
       tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
-      tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
       for (Int_t k=0;k<tpcrow->GetN1();++k) 
        tpcrow->SetCluster1(k, *(AliTPCclusterMI*)(clrow->GetArray()->At(k)));
     }
     if (left ==1){
       tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
-      tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
       for (Int_t k=0;k<tpcrow->GetN2();++k) 
-       tpcrow->SetCluster2(k,*(AliTPCclusterMI*)(clrow->GetArray()->At(k)));
+       tpcrow->SetCluster2(k, *(AliTPCclusterMI*)(clrow->GetArray()->At(k)));
     }
   }
   //
-  delete clrow;
+  clrow->Clear("C");
   LoadOuterSectors();
   LoadInnerSectors();
   return 0;
@@ -1560,7 +1564,7 @@ AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
   Int_t ncl=(index&0x00007fff)>>00;
 
   const AliTPCtrackerRow * tpcrow=0;
-  AliTPCclusterMI * clrow =0;
+  TClonesArray * clrow =0;
 
   if (sec<0 || sec>=fkNIS*4) {
     AliWarning(Form("Wrong sector %d",sec));
@@ -1598,7 +1602,7 @@ AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
     }
   }
 
-  return &(clrow[ncl]);      
+  return (AliTPCclusterMI*)clrow->At(ncl);
   
 }
 
@@ -1639,9 +1643,15 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
       if (TMath::Abs(angle-t.GetAlpha())>0.001){
        Double_t rotation = angle-t.GetAlpha();
        t.SetRelativeSector(relativesector);
-       if (!t.Rotate(rotation)) return 0;      
+       if (!t.Rotate(rotation)) {
+          t.SetClusterIndex(nr, t.GetClusterIndex(nr) | 0x8000);
+          return 0;
+        }      
+      }
+      if (!t.PropagateTo(x)) {
+        t.SetClusterIndex(nr, t.GetClusterIndex(nr) | 0x8000);
+        return 0;
       }
-      if (!t.PropagateTo(x)) return 0;
       //
       t.SetCurrentCluster(cl); 
       t.SetRow(nr);
@@ -2398,23 +2408,25 @@ void AliTPCtrackerMI::DumpClusters(Int_t iter, TObjArray *trackArray)
 
   for (Int_t sec=0;sec<fkNIS;sec++){
     for (Int_t row=0;row<fInnerSec->GetNRows();row++){
-      AliTPCclusterMI *cl = fInnerSec[sec][row].GetClusters1();
+      TClonesArray *cla = fInnerSec[sec][row].GetClusters1();
       for (Int_t icl =0;icl< fInnerSec[sec][row].GetN1();icl++){    
-       Float_t gx[3];  cl[icl].GetGlobalXYZ(gx);
+       AliTPCclusterMI* cl = (AliTPCclusterMI*)cla->At(icl);
+       Float_t gx[3];  cl->GetGlobalXYZ(gx);
        (*fDebugStreamer)<<"clDump"<< 
          "iter="<<iter<<
-         "cl.="<<&cl[icl]<<      
+         "cl.="<<cl<<      
          "gx0="<<gx[0]<<
          "gx1="<<gx[1]<<
          "gx2="<<gx[2]<<
          "\n";
       }
-      cl = fInnerSec[sec][row].GetClusters2();
+      cla = fInnerSec[sec][row].GetClusters2();
       for (Int_t icl =0;icl< fInnerSec[sec][row].GetN2();icl++){
-       Float_t gx[3];  cl[icl].GetGlobalXYZ(gx);
+       AliTPCclusterMI* cl = (AliTPCclusterMI*)cla->At(icl);
+       Float_t gx[3];  cl->GetGlobalXYZ(gx);
        (*fDebugStreamer)<<"clDump"<< 
          "iter="<<iter<<
-         "cl.="<<&cl[icl]<<
+         "cl.="<<cl<<
          "gx0="<<gx[0]<<
          "gx1="<<gx[1]<<
          "gx2="<<gx[2]<<
@@ -2425,23 +2437,27 @@ void AliTPCtrackerMI::DumpClusters(Int_t iter, TObjArray *trackArray)
   
   for (Int_t sec=0;sec<fkNOS;sec++){
     for (Int_t row=0;row<fOuterSec->GetNRows();row++){
-      AliTPCclusterMI *cl = fOuterSec[sec][row].GetClusters1();
+      TClonesArray *cla = fOuterSec[sec][row].GetClusters1();
       for (Int_t icl =0;icl< fOuterSec[sec][row].GetN1();icl++){
-       Float_t gx[3];  cl[icl].GetGlobalXYZ(gx);
+       Float_t gx[3];  
+       AliTPCclusterMI* cl = (AliTPCclusterMI*) cla->At(icl);
+       cl->GetGlobalXYZ(gx);
        (*fDebugStreamer)<<"clDump"<< 
          "iter="<<iter<<
-         "cl.="<<&cl[icl]<<
+         "cl.="<<cl<<
          "gx0="<<gx[0]<<
          "gx1="<<gx[1]<<
          "gx2="<<gx[2]<<
          "\n";      
       }
-      cl = fOuterSec[sec][row].GetClusters2();
+      cla = fOuterSec[sec][row].GetClusters2();
       for (Int_t icl =0;icl< fOuterSec[sec][row].GetN2();icl++){
-       Float_t gx[3];  cl[icl].GetGlobalXYZ(gx);
+       Float_t gx[3];  
+       AliTPCclusterMI* cl = (AliTPCclusterMI*) cla->At(icl);
+       cl->GetGlobalXYZ(gx);
        (*fDebugStreamer)<<"clDump"<< 
          "iter="<<iter<<
-         "cl.="<<&cl[icl]<<
+         "cl.="<<cl<<
          "gx0="<<gx[0]<<
          "gx1="<<gx[1]<<
          "gx2="<<gx[2]<<
@@ -2459,27 +2475,27 @@ void AliTPCtrackerMI::UnsignClusters()
   
   for (Int_t sec=0;sec<fkNIS;sec++){
     for (Int_t row=0;row<fInnerSec->GetNRows();row++){
-      AliTPCclusterMI *cl = fInnerSec[sec][row].GetClusters1();
+      TClonesArray *cla = fInnerSec[sec][row].GetClusters1();
       for (Int_t icl =0;icl< fInnerSec[sec][row].GetN1();icl++)
        //      if (cl[icl].IsUsed(10))         
-       cl[icl].Use(-1);
-      cl = fInnerSec[sec][row].GetClusters2();
+       ((AliTPCclusterMI*) cla->At(icl))->Use(-1);
+      cla = fInnerSec[sec][row].GetClusters2();
       for (Int_t icl =0;icl< fInnerSec[sec][row].GetN2();icl++)
        //if (cl[icl].IsUsed(10))       
-         cl[icl].Use(-1);      
+       ((AliTPCclusterMI*) cla->At(icl))->Use(-1);
     }
   }
   
   for (Int_t sec=0;sec<fkNOS;sec++){
     for (Int_t row=0;row<fOuterSec->GetNRows();row++){
-      AliTPCclusterMI *cl = fOuterSec[sec][row].GetClusters1();
+      TClonesArray *cla = fOuterSec[sec][row].GetClusters1();
       for (Int_t icl =0;icl< fOuterSec[sec][row].GetN1();icl++)
        //if (cl[icl].IsUsed(10))       
-         cl[icl].Use(-1);
-      cl = fOuterSec[sec][row].GetClusters2();
+       ((AliTPCclusterMI*) cla->At(icl))->Use(-1);
+      cla = fOuterSec[sec][row].GetClusters2();
       for (Int_t icl =0;icl< fOuterSec[sec][row].GetN2();icl++)
        //if (cl[icl].IsUsed(10))       
-       cl[icl].Use(-1);      
+       ((AliTPCclusterMI*) cla->At(icl))->Use(-1);
     }
   }
   
@@ -2653,59 +2669,6 @@ void AliTPCtrackerMI::SignClusters(const TObjArray * arr, Float_t fnumber, Float
 }
 
 
-void  AliTPCtrackerMI::StopNotActive(const TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const
-{
-  // stop not active tracks
-  // take th1 as threshold for number of founded to number of foundable on last 10 active rows
-  // take th2 as threshold for number of founded to number of foundable on last 20 active rows 
-  Int_t nseed = arr->GetEntriesFast();  
-  //
-  for (Int_t i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) {
-      continue;
-    }
-    if (!(pt->IsActive())) continue;
-    StopNotActive(pt,row0,th0, th1,th2);
-  }
-}
-
-
-
-void  AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1,
- Float_t th2) const
-{
-  // stop not active tracks
-  // take th1 as threshold for number of founded to number of foundable on last 10 active rows
-  // take th2 as threshold for number of founded to number of foundable on last 20 active rows 
-  Int_t sumgood1  = 0;
-  Int_t sumgood2  = 0;
-  Int_t foundable = 0;
-  Int_t maxindex = seed->GetLastPoint();  //last foundable row
-  if (seed->GetNFoundable()*th0 > seed->GetNumberOfClusters()) {
-    seed->Desactivate(10) ;
-    return;
-  }
-
-  for (Int_t i=row0; i<maxindex; i++){
-    Int_t index = seed->GetClusterIndex2(i);
-    if (index!=-1) foundable++;
-    //if (!c) continue;
-    if (foundable<=30) sumgood1++;
-    if (foundable<=50) {
-      sumgood2++;
-    }
-    else{ 
-      break;
-    }        
-  }
-  if (foundable>=30.){ 
-     if (sumgood1<(th1*30.)) seed->Desactivate(10);
-  }
-  if (foundable>=50)
-    if (sumgood2<(th2*50.)) seed->Desactivate(10);
-}
-
 
 Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
 {
@@ -2842,6 +2805,9 @@ Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
   //FindKinks(fSeeds,event);
   if (AliTPCReconstructor::StreamLevel()>3)  DumpClusters(2,fSeeds);
   Info("RefitInward","Number of refitted tracks %d",ntracks);
+
+  AliCosmicTracker::FindCosmic(event, kTRUE);
+
   return 0;
 }
 
@@ -2921,7 +2887,30 @@ Int_t AliTPCtrackerMI::PropagateBack(AliESDEvent *event)
 }
 
 
-void AliTPCtrackerMI::DeleteSeeds()
+Int_t AliTPCtrackerMI::PostProcess(AliESDEvent *event)
+{
+  //
+  // Post process events 
+  //
+  if (!event) return 0;
+
+  //
+  // Set TPC event status
+  // 
+
+  // event affected by HV dip
+  // reset TPC status
+  if(IsTPCHVDipEvent(event)) { 
+    event->ResetDetectorStatus(AliDAQ::kTPC);
+  }
+  //printf("Status %d \n", event->IsDetectorOn(AliDAQ::kTPC));
+
+  return 0;
+}
+
+
+ void AliTPCtrackerMI::DeleteSeeds()
 {
   //
   fSeeds->Clear();
@@ -3231,12 +3220,12 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
        }
        
 
-       Double_t dym = 0;
-       Double_t dzm = 0;
-       if (cm){
-         dym = ym - cm->GetY();
-         dzm = zm - cm->GetZ();
-       }
+       // Double_t dym = 0;
+       // Double_t dzm = 0;
+       // if (cm){
+       //   dym = ym - cm->GetY();
+       //   dzm = zm - cm->GetZ();
+       // }
        nin2++;
 
 
@@ -7641,8 +7630,8 @@ Bool_t AliTPCtrackerMI::IsFindable(AliTPCseed & track){
 void AliTPCtrackerMI::AddCovariance(AliTPCseed * seed){
   //
   // Adding systematic error estimate to the covariance matrix
-  // !!!! the systematic error for element 4 is in 1/cm not in pt 
-  //
+  //                !!!! the systematic error for element 4 is in 1/GeV 
+  // 03.03.2012     MI changed in respect to the previous versions
   const Double_t *param = AliTPCReconstructor::GetRecoParam()->GetSystematicError();
   //
   // use only the diagonal part if not specified otherwise
@@ -7650,12 +7639,14 @@ void AliTPCtrackerMI::AddCovariance(AliTPCseed * seed){
   //
   Double_t *covarS= (Double_t*)seed->GetCovariance();
   Double_t factor[5]={1,1,1,1,1};
-  Double_t facC =  AliTracker::GetBz()*kB2C;
   factor[0]= TMath::Sqrt(TMath::Abs((covarS[0] + param[0]*param[0])/covarS[0]));
   factor[1]= TMath::Sqrt(TMath::Abs((covarS[2] + param[1]*param[1])/covarS[2]));
   factor[2]= TMath::Sqrt(TMath::Abs((covarS[5] + param[2]*param[2])/covarS[5]));
   factor[3]= TMath::Sqrt(TMath::Abs((covarS[9] + param[3]*param[3])/covarS[9]));
-  factor[4]= TMath::Sqrt(TMath::Abs((covarS[14] + facC*facC*param[4]*param[4])/covarS[14]));
+  factor[4]= TMath::Sqrt(TMath::Abs((covarS[14] +param[4]*param[4])/covarS[14]));
+  //
+  factor[0]=factor[2];
+  factor[4]=factor[2];
   // 0
   // 1    2
   // 3    4    5
@@ -7674,6 +7665,9 @@ void AliTPCtrackerMI::AddCovarianceAdd(AliTPCseed * seed){
   //
   // Adding systematic error - as additive factor without correlation
   //
+  //                !!!! the systematic error for element 4 is in 1/GeV 
+  // 03.03.2012     MI changed in respect to the previous versions
+
   const Double_t *param = AliTPCReconstructor::GetRecoParam()->GetSystematicError();
   Double_t *covarIn= (Double_t*)seed->GetCovariance();
   Double_t covar[15];
@@ -7687,8 +7681,7 @@ void AliTPCtrackerMI::AddCovarianceAdd(AliTPCseed * seed){
   covar[2] = param[1]*param[1];
   covar[5] = param[2]*param[2];
   covar[9] = param[3]*param[3];
-  Double_t facC =  AliTracker::GetBz()*kB2C;
-  covar[14]= param[4]*param[4]*facC*facC;
+  covar[14]= param[4]*param[4];
   //
   covar[1]=TMath::Sqrt((covar[0]*covar[2]))*covarIn[1]/TMath::Sqrt((covarIn[0]*covarIn[2]));
   //
@@ -7707,14 +7700,68 @@ void AliTPCtrackerMI::AddCovarianceAdd(AliTPCseed * seed){
   seed->AddCovariance(covar);
 }
 
+//_____________________________________________________________________________
+Bool_t  AliTPCtrackerMI::IsTPCHVDipEvent(AliESDEvent const *esdEvent) {
+//
+// check events affected by TPC HV dip
+//
+if(!esdEvent) return kFALSE;
+
+// Init TPC OCDB
+if(!AliTPCcalibDB::Instance()) return kFALSE;
+AliTPCcalibDB::Instance()->SetRun(esdEvent->GetRunNumber());
+
+// Get HV TPC chamber sensors and calculate the median
+AliDCSSensorArray *voltageArray= AliTPCcalibDB::Instance()->GetVoltageSensors(esdEvent->GetRunNumber());
+if(!voltageArray) return kFALSE;
+
+TString sensorName="";
+Double_t kTPCHVdip = 2.0; // allow for 2V dip as compared to median from given sensor
+
+
+  for(Int_t sector=0; sector<72; sector++)
+  {
+    Char_t sideName='A';
+    if ((sector/18)%2==1) sideName='C';
+    if (sector<36){
+      //IROC
+      sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,sector%18);
+    } else {
+      //OROC
+      sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,sector%18);
+    }
+    
+    AliDCSSensor* sensor = voltageArray->GetSensor(sensorName.Data());
+    if(!sensor) continue;
+    TGraph *graph = sensor->GetGraph();
+    if(!graph) continue;
+    Double_t median = TMath::Median(graph->GetN(), graph->GetY());
+    if(median == 0) continue;
+
+    //printf("chamber %d, sensor %s, HV %f, median %f\n", sector, sensorName.Data(), sensor->GetValue(esdEvent->GetTimeStamp()), median);
+    
+    if(TMath::Abs(sensor->GetValue(esdEvent->GetTimeStamp())-median)>kTPCHVdip) {
+      return kTRUE; 
+    }
+  } 
+  return kFALSE; 
+} 
+
 //________________________________________
 void AliTPCtrackerMI::MarkSeedFree(TObject *sd) 
 {
   // account that this seed is "deleted" 
   AliTPCseed* seed = dynamic_cast<AliTPCseed*>(sd);
-  if (!sd) {AliError(Form("Freeing of non-AliTPCseed %p from the pool is requested",sd)); return;}
+  if (!seed) {
+    AliError(Form("Freeing of non-AliTPCseed %p from the pool is requested",sd)); 
+    return;
+  }
   int id = seed->GetPoolID();
-  if (id<0) {AliError(Form("Freeing of seed %p NOT from the pool is requested",sd)); return;}
+  if (id<0) {
+    AliError(Form("Freeing of seed %p NOT from the pool is requested",sd)); 
+    return;
+  }
   //  AliInfo(Form("%d %p",id, seed));
   fSeedsPool->RemoveAt(id);
   if (fFreeSeedsID.GetSize()<=fNFreeSeeds) fFreeSeedsID.Set( 2*fNFreeSeeds + 100 );