]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDRecon.cxx
AddTimeStamp was always increasing track length but accounting
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDRecon.cxx
index 45ad64e3c1745cb3a73180d88c4ad076785869fd..6f05d3fc7e073c357638e9497d7edc916e8bc783 100644 (file)
@@ -31,7 +31,7 @@
 
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 AliHMPIDRecon::AliHMPIDRecon():
-  TTask("RichRec","RichPat"),
+  TNamed("RichRec","RichPat"),
   fPhotCnt(-1),
   fPhotFlag(0x0),
   fPhotClusIndex(0x0),    
@@ -93,8 +93,6 @@ void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Int_t inde
   const Int_t nMinPhotAcc = 3;                      // Minimum number of photons required to perform the pattern recognition
   
   Int_t nClusTot = pCluLst->GetEntries();
-  if(nClusTot>fParam->MultCut()) fIsWEIGHT = kTRUE; // offset to take into account bkg in reconstruction
-  else                           fIsWEIGHT = kFALSE;
 
   InitVars(nClusTot);
   
@@ -109,8 +107,11 @@ void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Int_t inde
   
   fPhotCnt=0;
   
+  Int_t nPads = 0;
+  
   for (Int_t iClu=0; iClu<pCluLst->GetEntriesFast();iClu++){//clusters loop
-    AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu);                       //get pointer to current cluster    
+    AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu);                       //get pointer to current cluster
+    nPads+=pClu->Size();    
     if(iClu == index) {                                                                       // this is the MIP! not a photon candidate: just store mip info
       mipX = pClu->X();
       mipY = pClu->Y();
@@ -140,7 +141,9 @@ void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Int_t inde
   fMipPos.Set(mipX,mipY);
     
 //PATTERN RECOGNITION STARTED: 
-  
+  if(fPhotCnt>fParam->MultCut()) fIsWEIGHT = kTRUE; // offset to take into account bkg in reconstruction
+  else                           fIsWEIGHT = kFALSE;
+    
   Int_t iNrec=FlagPhot(HoughResponse(),pCluLst,pTrk);                                                      //flag photons according to individual theta ckov with respect to most probable
   
   pTrk->SetHMPIDmip(mipX,mipY,mipQ,iNrec);                                                    //store mip info 
@@ -150,10 +153,12 @@ void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Int_t inde
     return;
   }
   
+  Int_t occupancy = (Int_t)(1000*(nPads/(6.*80.*48.))); 
+  
   Double_t thetaC = FindRingCkov(pCluLst->GetEntries());                                    //find the best reconstructed theta Cherenkov
 //    FindRingGeom(thetaC,2);
-  pTrk->SetHMPIDsignal(thetaC);                                                             //store theta Cherenkov
-  pTrk->SetHMPIDchi2(fCkovSigma2);                                                          //store errors squared
+  pTrk->SetHMPIDsignal(thetaC+occupancy);                                                             //store theta Cherenkov
+  pTrk->SetHMPIDchi2(fCkovSigma2);                                                              //store errors squared
   
   DeleteVars();
 }//CkovAngle()
@@ -367,7 +372,6 @@ Int_t AliHMPIDRecon::FlagPhot(Double_t ckov,TClonesArray *pCluLst, AliESDtrack *
 // Photon Flag:  Flag = 0 initial set; 
 //               Flag = 1 good candidate (charge compatible with photon); 
 //               Flag = 2 photon used for the ring;
-  Int_t *PhotIndex = new Int_t[fPhotCnt];
   
   Int_t steps = (Int_t)((ckov )/ fDTheta); //how many times we need to have fDTheta to fill the distance between 0  and thetaCkovHough
 
@@ -380,29 +384,27 @@ Int_t AliHMPIDRecon::FlagPhot(Double_t ckov,TClonesArray *pCluLst, AliESDtrack *
   Int_t iInsideCnt = 0; //count photons which Theta ckov inside the window
   for(Int_t i=0;i<fPhotCnt;i++){//photon candidates loop
     fPhotFlag[i] = 0;
-    if(fPhotCkov[i] >= tmin && fPhotCkov[i] <= tmax)   
-      fPhotFlag[i]=2;    
-      PhotIndex[iInsideCnt]=fPhotClusIndex[i];
+    if(fPhotCkov[i] >= tmin && fPhotCkov[i] <= tmax) { 
+      fPhotFlag[i]=2;
+      AddObjectToFriends(pCluLst,i,pTrk);
       iInsideCnt++;
     }
   }
       
-  for (Int_t iClu=0; iClu<pCluLst->GetEntriesFast();iClu++){//clusters loop
-    AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu);                       //get pointer to current cluster
-    for(Int_t j=0; j<iInsideCnt; j++){
-      if(iClu==PhotIndex[j]) {
-      AliHMPIDCluster *pClus = new AliHMPIDCluster(*pClu);  
-      pTrk->AddCalibObject(pClus); 
-     } 
-    }
-  } 
-                                                                                      
-  delete [] PhotIndex;
-  
   return iInsideCnt;
   
 }//FlagPhot()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void  AliHMPIDRecon::AddObjectToFriends(TClonesArray *pCluLst, Int_t photonIndex, AliESDtrack *pTrk)
+{
+// Add AliHMPIDcluster object to ESD friends
+    
+  AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(fPhotClusIndex[photonIndex]);     
+  AliHMPIDCluster *pClus = new AliHMPIDCluster(*pClu);
+  pClus->SetChi2(fPhotCkov[photonIndex]);  
+  pTrk->AddCalibObject(pClus);   
+}    
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 TVector2 AliHMPIDRecon::TracePhot(Double_t ckovThe,Double_t ckovPhi)const
 {
 // Trace a single Ckov photon from emission point somewhere in radiator up to photocathode taking into account ref indexes of materials it travereses
@@ -517,6 +519,7 @@ Double_t AliHMPIDRecon::HoughResponse()
       fParam->Lors2Pad(pos.X(),pos.Y(),ipc,ipadx,ipady);
       ipadx+=(ipc%2)*fParam->kPadPcX;
       ipady+=(ipc/2)*fParam->kPadPcY;
+      if(ipadx<0 || ipady>160 || ipady<0 || ipady>144 || ch<0 || ch>6) continue;
       if(fParam->IsDeadPad(ipadx,ipady,ch)) continue;
       nPhi++;
     }//point loop