]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDTracker.cxx
Restoring previous fixes that were lost during one of the last commits in this class...
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDTracker.cxx
index 2d2e3805b64fb54db0f1d592bb5b58af4d080ea7..837164c91e310cfffe080795949c5e3851274f9b 100644 (file)
@@ -4,9 +4,10 @@
 #include "AliHMPIDParam.h"       //GetTrackPoint(),PropagateBack()
 #include "AliHMPIDPid.h"         //Recon(),reconHTA()
 #include "AliHMPIDRecon.h"       //Recon()
-#include "AliHMPIDRecoParam.h"   //Recon()
+#include "AliHMPIDRecoParamV1.h"   //Recon()
 #include "AliHMPIDReconstructor.h"//Recon()
 #include "AliHMPIDReconHTA.h"    //ReconHTA()
+#include <AliLog.h>              //Recon()  
 #include <AliESDEvent.h>         //PropagateBack(),Recon()  
 #include <AliESDtrack.h>         //Intersect() 
 #include <AliTracker.h> 
@@ -15,7 +16,6 @@
 #include <AliAlignObj.h>         //GetTrackPoint()
 #include <AliCDBManager.h>       //PropageteBack()
 #include <AliCDBEntry.h>         //PropageteBack()
-#include "AliHMPIDRecoParam.h"   //Recon()
 //.
 // HMPID base class fo tracking
 //.
@@ -130,8 +130,18 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
 //  Double_t d3d=0;
   Double_t qthre = 0;   Double_t nmean=0; Int_t hvsec=0;
   Int_t nClusCh[AliHMPIDParam::kMaxCh+1];
+
+  Bool_t tsRight = kTRUE;
   
+  UInt_t tsmin = (UInt_t)((TF1*)pQthre->At(0))->GetXmin();                                        //
+  UInt_t tsmax = (UInt_t)((TF1*)pQthre->At(0))->GetXmax();                                        //
+  UInt_t ts = pEsd->GetTimeStamp();
+  
+  if(ts<tsmin || ts>tsmax) {
+    AliWarning(Form(" in HMPID time stamp out of range!!! Please check!!! ts = %i",ts));
+    tsRight = kFALSE;
+  }
+   
   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){                                        //loop on the ESD tracks in the event
            
 //    Double_t bestChi2=99999;chi2=99999;                                                          //init. track matching params
@@ -157,7 +167,7 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
     pTrk->SetHMPIDsignal(AliHMPIDRecon::kNotPerformed);                                        //ring reconstruction not yet performed
     
     Int_t ipCh=IntTrkCha(pTrk,xPc,yPc,xRa,yRa,theta,phi);                                        //find the intersected chamber for this track 
-    if(ipCh<0) continue;                                                                         //no intersection at all, go after next track
+    if(ipCh<0) {delete hmpTrk;hmpTrk=0x0;continue;}                                                                         //no intersection at all, go after next track
 
     pTrk->SetHMPIDtrk(xPc,yPc,theta,phi);                                                        //store initial infos
     pTrk->SetHMPIDcluIdx(ipCh,9999);                                                             //set chamber, index of cluster + cluster size
@@ -168,7 +178,7 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
     nMipClusTot = pMipCluLst->GetEntries();                                                     //total number of clusters in the given chamber
     nClusCh[ipCh] = nMipClusTot;
     
-    if(nMipClusTot==0) continue;                                                                         
+    if(nMipClusTot==0) {delete hmpTrk;hmpTrk=0x0;continue;}                                                                         
     
     Int_t index=-1;                                                                             //index of the "best" matching cluster
     
@@ -176,14 +186,16 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
       
       AliHMPIDCluster *pClu=(AliHMPIDCluster*)pMipCluLst->UncheckedAt(iClu);                    //get the cluster
 // evaluate qThre
-      if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {                                             // just for backward compatibility
-        qthre=((TF1*)pQthre->At(pClu->Ch()))->Eval(pEsd->GetTimeStamp());                          //
-      } else {                                                                                     // in the past just 1 qthre
-        hvsec = pParam->InHVSector(pClu->Y());                                              //  per chamber
-        if(hvsec>=0)
-         qthre=((TF1*)pQthre->At(6*ipCh+hvsec))->Eval(pEsd->GetTimeStamp());                      //
-      }                                                                                            //
-//
+      if(tsRight){
+       if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {
+         qthre=((TF1*)pQthre->At(pClu->Ch()))->Eval(ts);                                         //
+       } else {                                                                                  // in the past just 1 qthre
+         hvsec = pParam->InHVSector(pClu->Y());                                                  //  per chamber
+         if(hvsec>=0) qthre=((TF1*)pQthre->At(6*ipCh+hvsec))->Eval(ts);                                     //
+        } 
+      } else qthre = pParam->QCut();
+            
+//      
       if(pClu->Q()<qthre) continue;                                                                      //charge compartible with MIP clusters      
       isOkQcut = kTRUE;
 //
@@ -195,18 +207,18 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
         index=iClu;
         bestHmpCluster=pClu;
       }
-    }
+    } // clusters loop
 
     if(!isOkQcut) {
       pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
-      continue;                                                                     
+      delete hmpTrk;hmpTrk=0x0; continue;                                                                     
     }
 
     Double_t radius = (pParam->Lors2Mars(ipCh,pParam->SizeAllX()/2,pParam->SizeAllY()/2)).Mag(); 
     
-    if(!AliTracker::PropagateTrackToBxByBz(hmpTrk,radius,pTrk->GetMass(),1,kFALSE)) continue;
+    if(!AliTracker::PropagateTrackToBxByBz(hmpTrk,radius,pTrk->GetMass(),1,kFALSE)) {delete hmpTrk;hmpTrk=0x0;continue;}
               
-    if(!hmpTrk->PropagateTo(bestHmpCluster)) continue;
+    if(!hmpTrk->PropagateTo(bestHmpCluster)) {delete hmpTrk;hmpTrk=0x0;continue;}
 
     Int_t cluSiz = bestHmpCluster->Size();
     pTrk->SetHMPIDmip(bestHmpCluster->X(),bestHmpCluster->Y(),(Int_t)bestHmpCluster->Q(),0);  //store mip info in any case 
@@ -214,7 +226,6 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
 
     if(AliHMPIDReconstructor::GetRecoParam())                                                 //retrieve distance cut
     {
-      AliHMPIDReconstructor::GetRecoParam()->PrintParameters();
       if(AliHMPIDReconstructor::GetRecoParam()->IsFixedDistCut()==kTRUE)                      //distance cut is fixed number
       { 
         distCut=AliHMPIDReconstructor::GetRecoParam()->GetHmpTrackMatchingDist();
@@ -229,9 +240,7 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
       
     if(dmin < distCut) {
       isOkDcut = kTRUE;
-    }
-
-    
+    }   
     
     if(!isOkDcut) {
       pTrk->SetHMPIDsignal(pParam->kMipDistCut);                                                //closest cluster with enough charge is still too far from intersection
@@ -239,45 +248,49 @@ Int_t AliHMPIDTracker::Recon(AliESDEvent *pEsd,TObjArray *pClus,TObjArray *pNmea
     
     if(isOkQcut*isOkDcut) isMatched = kTRUE;                                                    // MIP-Track matched !!    
     
-    if(!isMatched) continue;                                                                    // If matched continue...
+    if(!isMatched) {delete hmpTrk;hmpTrk=0x0;continue;}                                           // If matched continue...
 
     Bool_t isOk = hmpTrk->Update(bestHmpCluster,0.1,0);
-    if(!isOk) continue;
+    if(!isOk) {delete hmpTrk;hmpTrk=0x0;continue;}
     pTrk->SetOuterHmpParam(hmpTrk,AliESDtrack::kHMPIDout);                 
 
     FillResiduals(hmpTrk,bestHmpCluster,kFALSE);
  
+    Int_t iRad     = pParam->Radiator(yRa);                                                      //evaluate the radiator involved
     
     //evaluate nMean
-    if(pNmean->GetEntries()==21) {                                                              //for backward compatibility
-      nmean=((TF1*)pNmean->At(3*ipCh))->Eval(pEsd->GetTimeStamp());                             //C6F14 Nmean for this chamber
-    } else {
-      Int_t iRad     = pParam->Radiator(yRa);                                                   //evaluate the radiator involved
-      if(iRad < 0) {
+    if(tsRight){
+     if(pNmean->GetEntries()==21) {                                                              //for backward compatibility
+       nmean=((TF1*)pNmean->At(3*ipCh))->Eval(ts);                                               //C6F14 Nmean for this chamber
+     } else {
+       if(iRad < 0) {
        nmean = -1;
-      } else {
-      Double_t tLow  = ((TF1*)pNmean->At(6*ipCh+2*iRad  ))->Eval(pEsd->GetTimeStamp());         //C6F14 low  temp for this chamber
-      Double_t tHigh = ((TF1*)pNmean->At(6*ipCh+2*iRad+1))->Eval(pEsd->GetTimeStamp());         //C6F14 high temp for this chamber
-      Double_t tExp  = pParam->FindTemp(tLow,tHigh,yRa);                                        //estimated temp for that chamber at that y
-      nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp);                  //mean ref idx @ a given temp
-      }
-      if(nmean < 0){                                                                            //track didn' t pass through the radiator
+       } else {
+       Double_t tLow  = ((TF1*)pNmean->At(6*ipCh+2*iRad  ))->Eval(ts);                           //C6F14 low  temp for this chamber
+       Double_t tHigh = ((TF1*)pNmean->At(6*ipCh+2*iRad+1))->Eval(ts);                           //C6F14 high temp for this chamber
+       Double_t tExp  = pParam->FindTemp(tLow,tHigh,yRa);                                        //estimated temp for that chamber at that y
+       nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp);                  //mean ref idx @ a given temp
+       }
+       if(nmean < 0){                                                                            //track didn' t pass through the radiator
          pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad);                                           //set the appropriate flag
          pTrk->SetHMPIDcluIdx(ipCh,index+1000*cluSiz);                                          //set index of cluster
+         delete hmpTrk;hmpTrk=0x0; 
          continue;
+        }
       }
-    }
+    } else nmean = pParam->MeanIdxRad();
+    
     //
     recon.SetImpPC(xPc,yPc);                                                                     //store track impact to PC
     recon.CkovAngle(pTrk,(TClonesArray *)pClus->At(ipCh),index,nmean,xRa,yRa);                   //search for Cerenkov angle of this track
-    
-    
+
+    if(pTrk->GetHMPIDsignal()<0) {delete hmpTrk;hmpTrk=0x0;continue;}
+        
     AliHMPIDPid pID;
     Double_t prob[5];
     pID.FindPid(pTrk,5,prob);
     pTrk->SetHMPIDpid(prob);
 //      Printf(" Prob e- %6.2f mu %6.2f pi %6.2f k %6.2f p %6.2f",prob[0]*100,prob[1]*100,prob[2]*100,prob[3]*100,prob[4]*100);
-
     delete hmpTrk;hmpTrk=0x0;
   }//iTrk
 
@@ -293,7 +306,18 @@ Int_t AliHMPIDTracker::ReconHiddenTrk(AliESDEvent *pEsd,TObjArray *pClus,TObjArr
   AliHMPIDReconHTA reconHTA;                                                                     //instance of reconstruction class, nothing important in ctor
   
   AliHMPIDParam *pParam = AliHMPIDParam::Instance();                                             //Instance of AliHMPIDParam
-  
+  Bool_t tsRight = kTRUE;
+  UInt_t tsmin = (UInt_t)((TF1*)pQthre->At(0))->GetXmin();                                        //
+  UInt_t tsmax = (UInt_t)((TF1*)pQthre->At(0))->GetXmax();                                        //
+  UInt_t ts = pEsd->GetTimeStamp();
+
+  if(ts<tsmin || ts>tsmax) {
+    AliWarning(Form(" in HMPID time stamp out of range!!! Please check!!! ts = %i",ts));
+    tsRight = kFALSE;
+  }
+   
   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){                                        //loop on the ESD tracks in the event
     
     AliESDtrack *pTrk = pEsd->GetTrack(iTrk);                                                     //here it is simulated or just empty track
@@ -329,16 +353,19 @@ Int_t AliHMPIDTracker::ReconHiddenTrk(AliESDEvent *pEsd,TObjArray *pClus,TObjArr
     
     Int_t hvsec;
     Double_t qthre=0;
+    
 // evaluate qThre
+    if(tsRight){
     if(pQthre->GetEntriesFast()==pParam->kMaxCh+1) {                                              // just for backward compatibility
-      qthre=((TF1*)pQthre->At(chMip))->Eval(pEsd->GetTimeStamp());                                //
+      qthre=((TF1*)pQthre->At(chMip))->Eval(ts);                                                  //
     } else {                                                                                      // in the past just 1 qthre
       hvsec = pParam->InHVSector(yMip);                                                           //  per chamber
-      if(hvsec>=0) qthre=((TF1*)pQthre->At(6*chMip+hvsec))->Eval(pEsd->GetTimeStamp());           //
-    }
+      if(hvsec>=0) qthre=((TF1*)pQthre->At(6*chMip+hvsec))->Eval(ts);                             //
+    } 
+   } else qthre = pParam->QCut();
 //
     if(qMip<qthre) {
-      pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0);                                                        //store mip info in any case 
+      pTrk->SetHMPIDmip(xMip,yMip,(Int_t)qMip,0);                                                 //store mip info in any case 
       pTrk->SetHMPIDcluIdx(chMip,indMip+1000*cluMipSiz);                                                          
       pTrk->SetHMPIDsignal(pParam->kMipQdcCut);
       return 1;                                                                                   //charge compatible with MIP clusters      
@@ -349,24 +376,28 @@ Int_t AliHMPIDTracker::ReconHiddenTrk(AliESDEvent *pEsd,TObjArray *pClus,TObjArr
 
     Double_t yRa = yMip;                                                                        //just an approx...
     Double_t nmean;
+
+    Int_t iRad     = pParam->Radiator(yRa);                                                   //evaluate the radiator involved
+    
     //evaluate nMean
+    if(tsRight){
     if(pNmean->GetEntries()==21) {                                                              //for backward compatibility
-      nmean=((TF1*)pNmean->At(3*chMip))->Eval(pEsd->GetTimeStamp());                            //C6F14 Nmean for this chamber
+      nmean=((TF1*)pNmean->At(3*chMip))->Eval(ts);                                              //C6F14 Nmean for this chamber
     } else {
-      Int_t iRad     = pParam->Radiator(yRa);                                                   //evaluate the radiator involved
       if(iRad < 0) {
        nmean = -1;
       } else {
-      Double_t tLow  = ((TF1*)pNmean->At(6*chMip+2*iRad  ))->Eval(pEsd->GetTimeStamp());        //C6F14 low  temp for this chamber
-      Double_t tHigh = ((TF1*)pNmean->At(6*chMip+2*iRad+1))->Eval(pEsd->GetTimeStamp());        //C6F14 high temp for this chamber
+      Double_t tLow  = ((TF1*)pNmean->At(6*chMip+2*iRad  ))->Eval(ts);                          //C6F14 low  temp for this chamber
+      Double_t tHigh = ((TF1*)pNmean->At(6*chMip+2*iRad+1))->Eval(ts);                          //C6F14 high temp for this chamber
       Double_t tExp  = pParam->FindTemp(tLow,tHigh,yRa);                                        //estimated temp for that chamber at that y
       nmean = pParam->NIdxRad(AliHMPIDParam::Instance()->GetEPhotMean(),tExp);                  //mean ref idx @ a given temp
       }
       if(nmean < 0){                                                                            //track didn' t pass through the radiator
          pTrk->SetHMPIDsignal(AliHMPIDRecon::kNoRad);                                           //set the appropriate flag
          return 1;
-      }
-    }
+        }
+      } 
+    } else nmean = pParam->MeanIdxRad();
     //
     if(!reconHTA.CkovHiddenTrk(pTrk,(TClonesArray *)pClus->At(ipCh),indMip,nmean)) {                 //search for track parameters and Cerenkov angle of this track
       AliHMPIDPid pID;