]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDReconstructor.cxx
First revision of 'detailed' or 'detector' pid information.
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDReconstructor.cxx
index a7ac61c83a6e0cd0d932f0c9d0f6d43123576a91..2265284322c5ec171afa5ab68d2f26832d04a14d 100644 (file)
 #include "AliHMPIDParam.h"         //FillEsd() 
 #include <AliCDBEntry.h>           //ctor
 #include <AliCDBManager.h>         //ctor
-#include <AliESD.h>                //FillEsd()
+#include <AliESDEvent.h>           //FillEsd()
 #include <AliRawReader.h>          //Reconstruct() for raw digits
+#include "AliHMPIDRawStream.h"     //ConvertDigits()
+#include "AliHMPIDRecoParam.h"     //ctor
 ClassImp(AliHMPIDReconstructor)
 
+AliHMPIDRecoParam* AliHMPIDReconstructor::fgkRecoParam =0;  // 
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fUserCut(0),fDaqSig(0),fDig(0),fClu(0)
 {
@@ -44,17 +47,25 @@ 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);
+      Printf("HMPID: 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();
-      Printf("HMPID: UserCut successfully loaded for chamber %i -> %i ",iCh,fUserCut[iCh]);
+      Printf("HMPID: UserCut successfully loaded (from OCDB) for chamber %i -> %i ",iCh,fUserCut[iCh]);
     }
+   }
   }
-
-  
+   
   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();
@@ -139,46 +150,6 @@ void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const
   AliDebug(1,"Stop.");      
 }//Reconstruct(for simulated digits)
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDReconstructor::Reconstruct(AliRunLoader *pAL,AliRawReader* pRR)const
-{
-//Invoked  by AliReconstruction to convert raw digits from DDL files to clusters
-//Arguments: pAL - ALICE run loader pointer
-//           pRR - ALICE raw reader pointer
-//  Returns: none
-  AliLoader *pRL=pAL->GetDetectorLoader("HMPID");  AliHMPID *pRich=(AliHMPID*)pAL->GetAliRun()->GetDetector("HMPID");//get pointers for HMPID and HMPID loader
-
-  AliHMPIDDigit dig; //tmp digit, raw digit will be converted to it
-
-  TObjArray digLst; Int_t iDigCnt[7]; for(Int_t i=0;i<7;i++){digLst.AddAt(new TClonesArray("AliHMPIDDigit"),i); iDigCnt[i]=0;} //tmp list of digits for allchambers
-
-  Int_t iEvtN=0;
-  while(pRR->NextEvent()){//events loop
-    pAL->GetEvent(iEvtN++);
-    pRL->MakeTree("R");  pRich->MakeBranch("R");
-
-    for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
-      pRR->Select("HMPID",2*iCh,2*iCh+1);//select only DDL files for the current chamber
-      UInt_t w32=0;
-      while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
-        UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
-        dig.Raw(w32,ddl,pRR);
-        AliDebug(1,Form("Ch=%i DDL=%i raw=0x%x digit=(%3i,%3i,%3i,%3i) Q=%5.2f",iCh,ddl,w32,dig.Ch(),dig.Pc(),dig.PadPcX(),dig.PadPcY(),dig.Q()));
-        if(!IsDigSurvive(&dig)) continue;                                             //sigma cut test
-        new((*((TClonesArray*)digLst.At(iCh)))[iDigCnt[iCh]++]) AliHMPIDDigit(dig); //add this digit to the tmp list
-      }//raw records loop
-      pRR->Reset();
-    }//chambers loop
-
-    Dig2Clu(&digLst,pRich->CluLst());//cluster finder for all chambers
-    for(Int_t i=0;i<7;i++){digLst.At(i)->Delete(); iDigCnt[i]=0;}                    //clean up list of digits for all chambers
-
-    pRL->TreeR()->Fill();            //fill tree for current event
-    pRL->WriteRecPoints("OVERWRITE");//write out clusters for current event
-    pRich->CluReset();
-  }//events loop
-  pRL->UnloadRecPoints();
-}//Reconstruct raw data
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)const
 {
 //Invoked  by AliReconstruction to convert raw digits from DDL files to digits
@@ -186,27 +157,41 @@ void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)cons
 //           pDigTree - pointer to Digit tree
 //  Returns: none    
   AliDebug(1,"Start.");
-  AliHMPIDDigit dig; //tmp digit, raw digit will be converted to it
+//  Int_t digcnt=0;
+  
+
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
-    pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]),4000,0);
-    pRR->Select("HMPID",2*iCh,2*iCh+1);//select only DDL files for the current chamber      
+    pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]),4000,0); 
+    
     Int_t iDigCnt=0;
-    UInt_t w32=0;
-                while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
-      UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
-      if(!dig.Raw(w32,ddl,pRR)) continue;  
-      AliDebug(1,Form("Ch=%i DDL=%i raw=0x%x digit=(%3i,%3i,%3i,%3i) Q=%5.2f",iCh,ddl,w32,dig.Ch(),dig.Pc(),dig.PadPcX(),dig.PadPcY(),dig.Q()));
-      if(!IsDigSurvive(&dig)) continue;                                       //sigma cut test
-      new((*((TClonesArray*)fDig->At(iCh)))[iDigCnt++]) AliHMPIDDigit(dig); //add this digit to the tmp list
-    }//raw records loop
-    pRR->Reset();        
-  }//chambers loop
+    AliHMPIDRawStream stream(pRR);    
+    while(stream.Next())
+    {
+      
+      UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
+      if((UInt_t)(2*iCh)==ddl || (UInt_t)(2*iCh+1)==ddl) {
+       for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){
+        for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
+          for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
+            if(stream.GetCharge(ddl,row,dil,pad) < 1) continue; 
+              AliHMPIDDigit dig(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
+              if(!IsDigSurvive(&dig)) continue; 
+              new((*((TClonesArray*)fDig->At(iCh)))[iDigCnt++]) AliHMPIDDigit(dig); //add this digit to the tmp list 
+            }//pad
+          }//dil
+        }//row
+      }//while
+    }
+    stream.Delete();
+  }
   pDigTree->Fill();
+  
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear();
+  
   AliDebug(1,"Stop.");
 }//Reconstruct digits from raw digits
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDReconstructor::FillESD(AliRunLoader *, AliESD *pESD) const
+void AliHMPIDReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree*/, AliESDEvent *pESD) const
 {
 // Calculates probability to be a electron-muon-pion-kaon-proton
 // from the given Cerenkov angle and momentum assuming no initial particle composition
@@ -244,4 +229,3 @@ void AliHMPIDReconstructor::FillESD(AliRunLoader *, AliESD *pESD) const
     pTrk->SetHMPIDpid(pid);
   }//ESD tracks loop
 }//FillESD()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++