]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDReconstructor.cxx
Coverity fixed
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDReconstructor.cxx
index e38cd056d5a76f86e3b944a0785f320f1148deb1..9573203d3fa71f88f76eca73994dd22d86d890a1 100644 (file)
 #include <AliCDBManager.h>         //ctor
 #include <AliESDEvent.h>           //FillEsd()
 #include <AliRawReader.h>          //Reconstruct() for raw digits
+#include <AliLog.h>                //
 #include "AliHMPIDRawStream.h"     //ConvertDigits()
-#include "AliHMPIDRecoParam.h"     //ctor
+#include "AliHMPIDRecoParamV1.h"   //ctor
+
 ClassImp(AliHMPIDReconstructor)
 
-AliHMPIDRecoParam* AliHMPIDReconstructor::fgkRecoParam =0;  // 
+Int_t AliHMPIDReconstructor::fgStreamLevel = 0;        // stream (debug) level
+
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fUserCut(0),fDaqSig(0),fDig(0),fClu(0)
+AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fDaqSig(0),fDig(0),fClu(0)
 {
 //
 //ctor
 //
   AliHMPIDParam::Instance();                                                        //geometry loaded for reconstruction
-  fUserCut = new Int_t[7];
+
   fClu=new TObjArray(AliHMPIDParam::kMaxCh+1); fClu->SetOwner(kTRUE);
   fDig=new TObjArray(AliHMPIDParam::kMaxCh+1); fDig->SetOwner(kTRUE);
   
@@ -48,40 +51,7 @@ AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fUserCut(0),fD
     pClus->SetUniqueID(i);
     fClu->AddAt(pClus,i);
   }
-
-   if(fgkRecoParam!=0x0 && fgkRecoParam->GetUserCutMode()==kFALSE)
-  {
-      for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
-      fUserCut[iCh] = fgkRecoParam->GetUserCut(iCh);
-      AliDebug(1,Form("UserCut successfully loaded (from RecoParam) for chamber %i -> %i ",iCh,fUserCut[iCh]));
-   }
-  }  
-  else {
-  AliCDBEntry *pUserCutEnt =AliCDBManager::Instance()->Get("HMPID/Calib/UserCut");    //contains TObjArray of 14 TObject with n. of sigmas to cut charge 
-  if(pUserCutEnt) {
-    TObjArray *pUserCut = (TObjArray*)pUserCutEnt->GetObject(); 
-    for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){                  //chambers loop 
-      fUserCut[iCh] = pUserCut->At(iCh)->GetUniqueID();
-      AliDebug(1,Form("UserCut successfully loaded (from OCDB) for chamber %i -> %i ",iCh,fUserCut[iCh]));
-    }
-   }
-   else {for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) fUserCut[iCh] = 3;}
-  }
-
-  AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre"); //contains TObjArray of 7 TF1
-  if(!pQthreEnt) AliFatal("No Qthre available");
-  TObjArray *pQthre = (TObjArray*)pQthreEnt->GetObject();
-  for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
-    for(Int_t isec=0;isec<=5;isec++) {
-     TF1 *pfQthre = (TF1*)pQthre->At(6*iCh+isec); 
-     Double_t tMin,tMax;
-     pfQthre->GetRange(tMin,tMax);
-     Double_t qthre=pfQthre->Eval(tMin);
-     AliDebug(1,Form("Qthre successfully loaded for chamber %i  sector %i -> %f ",iCh,isec,qthre));
-    }
-  }
-
-     
   AliCDBEntry *pDaqSigEnt =AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");  //contains TObjArray of TObjArray 14 TMatrixF sigmas values for pads 
   if(!pDaqSigEnt) AliFatal("No pedestals from DAQ!");
   fDaqSig = (TObjArray*)pDaqSigEnt->GetObject();
@@ -153,8 +123,25 @@ void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const
     pCluTree->Branch(Form("HMPID%d",iCh),&((*fClu)[iCh]),7);
     pDigTree->SetBranchAddress(Form("HMPID%d",iCh),&((*fDig)[iCh]));
   }   
+  
+  Int_t *pUserCut = new Int_t[7];
+  
+   if(AliHMPIDReconstructor::GetRecoParam()) {
+    for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
+      pUserCut[iCh] = AliHMPIDReconstructor::GetRecoParam()->GetHmpUserCut(iCh);
+      AliDebug(1,Form("UserCut successfully loaded (from AliHMPIDRecoParamV1) for chamber %i -> %i ",iCh,pUserCut[iCh]));
+    }
+  }
+  else {
+    for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
+      pUserCut[iCh] = 4;                                                                             // minimal requirement for sigma cut
+      AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh]));
+      AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!"));
+      }
+    }  
+  
   pDigTree->GetEntry(0);
-  Dig2Clu(fDig,fClu,fUserCut);     //cluster finder 
+  Dig2Clu(fDig,fClu,pUserCut);     //cluster finder 
   pCluTree->Fill();                //fill tree for current event
   
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
@@ -162,6 +149,8 @@ void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const
     fClu->At(iCh)->Clear();
   }
   
+  delete [] pUserCut;
+  
   AliDebug(1,"Stop.");      
 }//Reconstruct(for simulated digits)
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -180,6 +169,22 @@ void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)cons
     pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]));
   }
     
+  Int_t *pUserCut = new Int_t[7];
+  
+   if(AliHMPIDReconstructor::GetRecoParam()) {
+    for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
+      pUserCut[iCh] = AliHMPIDReconstructor::GetRecoParam()->GetHmpUserCut(iCh);
+      AliDebug(1,Form("UserCut successfully loaded (from AliHMPIDRecoParamV1) for chamber %i -> %i ",iCh,pUserCut[iCh]));
+    }
+  }
+  else {
+    for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
+      pUserCut[iCh] = 4;                                                                             // minimal requirement for sigma cut
+      AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh]));
+      AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!"));
+      }
+    }  
+      
   AliHMPIDRawStream stream(pRR);    
   
   while(stream.Next())
@@ -187,7 +192,7 @@ void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)cons
     Int_t ch = AliHMPIDParam::DDL2C(stream.GetDDLNumber());
     for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
       AliHMPIDDigit dig(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);
-      if(!IsDigSurvive(&dig)) continue; 
+      if(!IsDigSurvive(pUserCut,&dig)) continue; 
       new((*((TClonesArray*)fDig->At(ch)))[iDigCnt[ch]++]) AliHMPIDDigit(dig); //add this digit to the tmp list 
     }
   }
@@ -196,6 +201,8 @@ void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)cons
   
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear();
   
+  delete [] pUserCut;
+  
   AliDebug(1,"Stop.");
 }//Reconstruct digits from raw digits
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -212,5 +219,4 @@ void AliHMPIDReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree
     pID.FindPid(pTrk,AliPID::kSPECIES,prob);
     pTrk->SetHMPIDpid(prob);
   }//ESD tracks loop
-  
 }//FillESD()