ALIROOT-5347 Change StreamLevel for the tracker debugging
[u/mrichter/AliRoot.git] / TPC / Rec / AliTPCtracker.cxx
index bcd6341..f20a07a 100644 (file)
@@ -302,6 +302,15 @@ Int_t AliTPCtracker::UpdateTrack(AliTPCseed * track, Int_t accept){
     //  new(larr[ihelix]) AliHelix(*track) ;    
     //}
   }
+  if (AliTPCReconstructor::StreamLevel()>5) {
+    Int_t event = (fEvent==NULL)? 0: fEvent->GetEventNumberInFile();
+    AliExternalTrackParam param(*track);
+    TTreeSRedirector &cstream = *fDebugStreamer;
+    cstream<<"Update"<<
+      "cl.="<<c<<
+      "track.="<<&param<<
+      "\n";
+  }
   track->SetNoCluster(0);
   return track->Update(c,chi2,i);
 }
@@ -347,6 +356,7 @@ Int_t AliTPCtracker::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster)
     
     if (AliTPCReconstructor::StreamLevel()>2) {
     (*fDebugStreamer)<<"ErrParam"<<
+      "iter="<<fIteration<<
       "Cl.="<<cluster<<
       "T.="<<&param<<
       "dy="<<dy<<
@@ -532,7 +542,10 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
   //
   //
   //fill esds using updated tracks
+
   if (!fEvent) return;
+
+  AliESDtrack iotrack;
   
     // write tracks to the event
     // store index of the track
@@ -554,7 +567,8 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
       }
  
       if (( pt->GetPoints()[2]- pt->GetPoints()[0])>5 && pt->GetPoints()[3]>0.8){
-       AliESDtrack iotrack;
+       iotrack.~AliESDtrack();
+       new(&iotrack) AliESDtrack;
        iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
        iotrack.SetTPCPoints(pt->GetPoints());
        iotrack.SetKinkIndexes(pt->GetKinkIndexes());
@@ -567,7 +581,8 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
       }
        
       if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.55) {
-       AliESDtrack iotrack;
+       iotrack.~AliESDtrack();
+       new(&iotrack) AliESDtrack;
        iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
        iotrack.SetTPCPoints(pt->GetPoints());
        //iotrack.SetTPCindex(i);
@@ -585,7 +600,8 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
        Int_t found,foundable,shared;
        pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
        if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2)){
-         AliESDtrack iotrack;
+         iotrack.~AliESDtrack();
+         new(&iotrack) AliESDtrack;
          iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);    
          //iotrack.SetTPCindex(i);
          iotrack.SetTPCPoints(pt->GetPoints());
@@ -604,7 +620,8 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
        if (found<20) continue;
        if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
        //
-       AliESDtrack iotrack;
+       iotrack.~AliESDtrack();
+       new(&iotrack) AliESDtrack;
        iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);      
        iotrack.SetTPCPoints(pt->GetPoints());
        iotrack.SetKinkIndexes(pt->GetKinkIndexes());
@@ -621,7 +638,8 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
        Int_t found,foundable,shared;
        pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
        if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
-         AliESDtrack iotrack;
+         iotrack.~AliESDtrack();
+         new(&iotrack) AliESDtrack;
          iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);    
          iotrack.SetTPCPoints(pt->GetPoints());
          iotrack.SetKinkIndexes(pt->GetKinkIndexes());
@@ -642,7 +660,8 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
        if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
        if (float(found)/float(foundable)<0.8) continue;
        //
-       AliESDtrack iotrack;
+       iotrack.~AliESDtrack();
+       new(&iotrack) AliESDtrack;
        iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);      
        iotrack.SetTPCPoints(pt->GetPoints());
        iotrack.SetKinkIndexes(pt->GetKinkIndexes());
@@ -670,6 +689,7 @@ void AliTPCtracker::FillESD(const TObjArray* arr)
        kink->SetIndex(it, knkId<0 ? 0:1); // update track index of the kink: mother at 0, daughter at 1
       }
     }
+
     // << account for suppressed tracks in the kink indices (RS)  
     AliInfo(Form("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks()));
   
@@ -1353,7 +1373,7 @@ Int_t  AliTPCtracker::LoadClusters()
   clrow->Clear("C");
   LoadOuterSectors();
   LoadInnerSectors();
-  if(!AliTPCReconstructor::GetRecoParam()->GetUseIonTailCorrection()) ApplyTailCancellation();
+  if (AliTPCReconstructor::GetRecoParam()->GetUseIonTailCorrection()) ApplyTailCancellation();
   return 0;
 }
 
@@ -1425,7 +1445,7 @@ void   AliTPCtracker::Transform(AliTPCclusterMI * cluster){
     return;
   }
   transform->SetCurrentRecoParam((AliTPCRecoParam*)AliTPCReconstructor::GetRecoParam());
-  Double_t x[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()};
+  Double_t x[3]={static_cast<Double_t>(cluster->GetRow()),static_cast<Double_t>(cluster->GetPad()),static_cast<Double_t>(cluster->GetTimeBin())};
   Int_t i[1]={cluster->GetDetector()};
   transform->Transform(x,i,0,1);  
   //  if (cluster->GetDetector()%36>17){
@@ -1517,7 +1537,10 @@ void  AliTPCtracker::ApplyTailCancellation(){
           indexAmpGraphs[icache] = 0;
         }
         /////////////////////////////  --> position fo sie loop
-        AliTPCcalibDB::Instance()->GetTailcancelationGraphs(sec+36*secType+18*iside,graphRes,indexAmpGraphs);
+        if (!AliTPCcalibDB::Instance()->GetTailcancelationGraphs(sec+36*secType+18*iside,graphRes,indexAmpGraphs))
+        {
+          continue;
+        }
         
         AliTPCtrackerSector &sector= (secType==0)?fInnerSec[sec]:fOuterSec[sec];  
         Int_t nrows     = sector.GetNRows();                                       // number of rows
@@ -1583,7 +1606,7 @@ void  AliTPCtracker::ApplyTailCancellation(){
               qMaxArray[icl0]+=ionTailMax;
 
               // Dump some info for debugging while clusters are being corrected
-              if (AliTPCReconstructor::StreamLevel()==1) {
+              if (AliTPCReconstructor::StreamLevel()>2) {
                 TTreeSRedirector &cstream = *fDebugStreamer;
                 if (gRandom->Rndm() > 0.999){
                   cstream<<"IonTail"<<
@@ -1602,7 +1625,7 @@ void  AliTPCtracker::ApplyTailCancellation(){
             cl0->SetMax(TMath::Nint(Float_t(cl0->GetMax())+qMaxArray[icl0]));
           
             // Dump some info for debugging after clusters are corrected 
-            if (AliTPCReconstructor::StreamLevel()==1) {
+            if (AliTPCReconstructor::StreamLevel()>2) {
               TTreeSRedirector &cstream = *fDebugStreamer;
               if (gRandom->Rndm() > 0.999){
               cstream<<"IonTailCorrected"<<
@@ -1632,7 +1655,7 @@ void  AliTPCtracker::ApplyTailCancellation(){
   }// end of side loop
 }
 //_____________________________________________________________________________
-void AliTPCtracker::GetTailValue(const Float_t ampfactor,Double_t &ionTailMax, Double_t &ionTailTotal,TGraphErrors **graphRes,Float_t *indexAmpGraphs,AliTPCclusterMI *cl0,AliTPCclusterMI *cl1){
+void AliTPCtracker::GetTailValue(Float_t ampfactor,Double_t &ionTailMax, Double_t &ionTailTotal,TGraphErrors **graphRes,Float_t *indexAmpGraphs,AliTPCclusterMI *cl0,AliTPCclusterMI *cl1){
 
   //
   // Function in order to calculate the amount of the correction to be added for a given cluster, return values are ionTailTaoltal and ionTailMax
@@ -1652,6 +1675,7 @@ void AliTPCtracker::GetTailValue(const Float_t ampfactor,Double_t &ionTailMax, D
   Double_t rmsPad1          = (cl1->GetSigmaY2()==0)?kMinPRF:(TMath::Sqrt(cl1->GetSigmaY2())/padWidth);
   Double_t rmsPad0          = (cl0->GetSigmaY2()==0)?kMinPRF:(TMath::Sqrt(cl0->GetSigmaY2())/padWidth);
  
+  
   Double_t sumAmp1=0.;
   for (Int_t idelta =-2; idelta<=2;idelta++){
     sumAmp1+=TMath::Exp(-idelta*idelta/(2*rmsPad1));
@@ -1682,6 +1706,7 @@ void AliTPCtracker::GetTailValue(const Float_t ampfactor,Double_t &ionTailMax, D
         }
     }
     if (!graphRes[ampIndex]) continue;
+    if (deltaTimebin+2 >= graphRes[ampIndex]->GetN()) continue;
     if (graphRes[ampIndex]->GetY()[deltaTimebin+2]>=0) continue;
      
     for (Int_t ipad0=padcl0-padScan; ipad0<=padcl0+padScan; ipad0++) {
@@ -2968,8 +2993,9 @@ Int_t AliTPCtracker::RefitInward(AliESDEvent *event)
   PropagateForward2(fSeeds);
   RemoveUsed2(fSeeds,0.4,0.4,20);
 
-  TObjArray arraySeed(fSeeds->GetEntries());
-  for (Int_t i=0;i<fSeeds->GetEntries();i++) {
+  Int_t entriesSeed=fSeeds->GetEntries();
+  TObjArray arraySeed(entriesSeed);
+  for (Int_t i=0;i<entriesSeed;i++) {
     arraySeed.AddAt(fSeeds->At(i),i);    
   }
   SignShared(&arraySeed);
@@ -3076,6 +3102,8 @@ Int_t AliTPCtracker::RefitInward(AliESDEvent *event)
 
   AliCosmicTracker::FindCosmic(event, kTRUE);
 
+  FillClusterOccupancyInfo();
+
   return 0;
 }
 
@@ -3239,19 +3267,7 @@ void AliTPCtracker::ReadSeeds(const AliESDEvent *const event, Int_t direction)
     //  MarkSeedFree( seed );
     //  continue;    
     //}
-    if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 )  {
-      Double_t par0[5],par1[5],alpha,x;
-      esd->GetInnerExternalParameters(alpha,x,par0);
-      esd->GetExternalParameters(x,par1);
-      Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
-      Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
-      Double_t trdchi2=0;
-      if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
-      //reset covariance if suspicious 
-      if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
-       seed->ResetCovariance(10.);
-    }
-
+    
     //
     //
     // rotate to the local coordinate system
@@ -5377,7 +5393,7 @@ void  AliTPCtracker::FindKinks(TObjArray * array, AliESDEvent *esd)
       kink->SetDaughter(paramd);
       kink->Update();
 
-      Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
+      Float_t x[3] = { static_cast<Float_t>(kink->GetPosition()[0]),static_cast<Float_t>(kink->GetPosition()[1]),static_cast<Float_t>(kink->GetPosition()[2])};
       Int_t index[4];
       fkParam->Transform0to1(x,index);
       fkParam->Transform1to2(x,index);
@@ -6099,7 +6115,7 @@ void  AliTPCtracker::FindKinks(TObjArray * array, AliESDEvent *esd)
       kink->SetDaughter(paramd);
       kink->Update();
 
-      Float_t x[3] = { kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]};
+      Float_t x[3] = { static_cast<Float_t>(kink->GetPosition()[0]),static_cast<Float_t>(kink->GetPosition()[1]),static_cast<Float_t>(kink->GetPosition()[2])};
       Int_t index[4];
       fkParam->Transform0to1(x,index);
       fkParam->Transform1to2(x,index);
@@ -8464,3 +8480,25 @@ TObjArray * AliTPCtracker::MakeSeedsHLT(const AliESDEvent *hltEvent)
   std::cout<<"\n\nHLT tracks left: "<<seeds->GetEntries()<<" out of "<<hltEvent->GetNumberOfTracks()<<endl<<endl;
   return seeds;    
 }
+
+void AliTPCtracker::FillClusterOccupancyInfo()
+{
+  //fill the cluster occupancy info into the ESD friend
+  AliESDfriend* esdFriend = static_cast<AliESDfriend*>(fEvent->FindListObject("AliESDfriend"));
+  if (!esdFriend) return;
+
+  for (Int_t isector=0; isector<18; isector++){
+    AliTPCtrackerSector &iroc = fInnerSec[isector];
+    AliTPCtrackerSector &oroc = fOuterSec[isector];
+    //all clusters
+    esdFriend->SetNclustersTPC(isector,   iroc.GetNClInSector(0));
+    esdFriend->SetNclustersTPC(isector+18,iroc.GetNClInSector(1));
+    esdFriend->SetNclustersTPC(isector+36,oroc.GetNClInSector(0));
+    esdFriend->SetNclustersTPC(isector+54,oroc.GetNClInSector(1));
+    //clusters used in tracking
+    esdFriend->SetNclustersTPCused(isector,    iroc.GetNClUsedInSector(0));
+    esdFriend->SetNclustersTPCused(isector+18, iroc.GetNClUsedInSector(1));
+    esdFriend->SetNclustersTPCused(isector+36, oroc.GetNClUsedInSector(0));
+    esdFriend->SetNclustersTPCused(isector+54, oroc.GetNClUsedInSector(1));
+  }
+}