#include "AliHMPIDReconstructor.h"
#include "AliHMPID.h"
#include "AliHMPIDCluster.h"
#include "AliHMPIDPid.h"
#include "AliHMPIDParam.h"
#include <AliCDBEntry.h>
#include <AliCDBManager.h>
#include <AliESDEvent.h>
#include <AliRawReader.h>
#include <AliLog.h>
#include "AliHMPIDRawStream.h"
#include "AliHMPIDRecoParamV1.h"
#include <TVirtualFitter.h>
ClassImp(AliHMPIDReconstructor)
Int_t AliHMPIDReconstructor::fgStreamLevel = 0;
AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fDaqSig(0),fDig(0),fClu(0)
{
AliHMPIDParam::Instance();
fClu=new TObjArray(AliHMPIDParam::kMaxCh+1); fClu->SetOwner(kTRUE);
fDig=new TObjArray(AliHMPIDParam::kMaxCh+1); fDig->SetOwner(kTRUE);
for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){
fDig->AddAt(new TClonesArray("AliHMPIDDigit",24000),i);
TClonesArray *pClus = new TClonesArray("AliHMPIDCluster",24000);
pClus->SetUniqueID(i);
fClu->AddAt(pClus,i);
}
AliCDBEntry *pDaqSigEnt =AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");
if(!pDaqSigEnt) AliFatal("No pedestals from DAQ!");
fDaqSig = (TObjArray*)pDaqSigEnt->GetObject();
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
AliDebug(1,Form("DaqSigCut successfully loaded for chamber %i -> %i ",iCh,(Int_t)fDaqSig->At(iCh)->GetUniqueID()));
}
}
void AliHMPIDReconstructor::Dig2Clu(TObjArray *pDigAll,TObjArray *pCluAll,Int_t *pUserCut,Bool_t isTryUnfold)
{
TMatrixF padMap(AliHMPIDParam::kMinPx,AliHMPIDParam::kMaxPcx,AliHMPIDParam::kMinPy,AliHMPIDParam::kMaxPcy);
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
TClonesArray *pDigCur=(TClonesArray*)pDigAll->At(iCh);
if(pDigCur->GetEntriesFast()==0) continue;
padMap=(Float_t)-1;
TClonesArray *pCluCur=(TClonesArray*)pCluAll->At(iCh);
for(Int_t iDig=0;iDig<pDigCur->GetEntriesFast();iDig++){
AliHMPIDDigit *pDig= (AliHMPIDDigit*)pDigCur->At(iDig);
padMap( pDig->PadChX(), pDig->PadChY() )=iDig;
}
AliHMPIDCluster clu;
for(Int_t iDig=0;iDig<pDigCur->GetEntriesFast();iDig++){
AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCur->At(iDig);
if(!(pDig=UseDig(pDig->PadChX(),pDig->PadChY(),pDigCur,&padMap))) continue;
FormClu(&clu,pDig,pDigCur,&padMap);
clu.Solve(pCluCur,pUserCut,isTryUnfold);
clu.Reset();
}
}
}
void AliHMPIDReconstructor::FormClu(AliHMPIDCluster *pClu,AliHMPIDDigit *pDig,TClonesArray *pDigLst,TMatrixF *pDigMap)
{
pClu->DigAdd(pDig);
Int_t cnt=0,cx[4],cy[4];
if(pDig->PadPcX() != AliHMPIDParam::kMinPx){cx[cnt]=pDig->PadChX()-1; cy[cnt]=pDig->PadChY() ;cnt++;}
if(pDig->PadPcX() != AliHMPIDParam::kMaxPx){cx[cnt]=pDig->PadChX()+1; cy[cnt]=pDig->PadChY() ;cnt++;}
if(pDig->PadPcY() != AliHMPIDParam::kMinPy){cx[cnt]=pDig->PadChX() ; cy[cnt]=pDig->PadChY()-1;cnt++;}
if(pDig->PadPcY() != AliHMPIDParam::kMaxPy){cx[cnt]=pDig->PadChX() ; cy[cnt]=pDig->PadChY()+1;cnt++;}
for (Int_t i=0;i<cnt;i++){
if((pDig=UseDig(cx[i],cy[i],pDigLst,pDigMap))) FormClu(pClu,pDig,pDigLst,pDigMap);
}
}
void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const
{
AliDebug(1,"Start.");
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
pCluTree->Branch(Form("HMPID%d",iCh),&((*fClu)[iCh]),7);
pDigTree->SetBranchAddress(Form("HMPID%d",iCh),&((*fDig)[iCh]));
}
Int_t pUserCut[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;
AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh]));
AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!"));
}
}
TVirtualFitter* fitter = TVirtualFitter::GetFitter();
delete fitter;
fitter = TVirtualFitter::Fitter(0,3*6);
pDigTree->GetEntry(0);
Dig2Clu(fDig,fClu,pUserCut);
pCluTree->Fill();
delete fitter;
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
fDig->At(iCh)->Clear();
fClu->At(iCh)->Clear();
}
AliDebug(1,"Stop.");
}
void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)const
{
AliDebug(1,"Start.");
Int_t iDigCnt[7]={0,0,0,0,0,0,0};
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]));
}
Int_t pUserCut[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;
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())
{
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(pUserCut,&dig)) continue;
new((*((TClonesArray*)fDig->At(ch)))[iDigCnt[ch]++]) AliHMPIDDigit(dig);
}
}
pDigTree->Fill();
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear();
AliDebug(1,"Stop.");
}
AliHMPIDReconstructor.cxx:1 AliHMPIDReconstructor.cxx:2 AliHMPIDReconstructor.cxx:3 AliHMPIDReconstructor.cxx:4 AliHMPIDReconstructor.cxx:5 AliHMPIDReconstructor.cxx:6 AliHMPIDReconstructor.cxx:7 AliHMPIDReconstructor.cxx:8 AliHMPIDReconstructor.cxx:9 AliHMPIDReconstructor.cxx:10 AliHMPIDReconstructor.cxx:11 AliHMPIDReconstructor.cxx:12 AliHMPIDReconstructor.cxx:13 AliHMPIDReconstructor.cxx:14 AliHMPIDReconstructor.cxx:15 AliHMPIDReconstructor.cxx:16 AliHMPIDReconstructor.cxx:17 AliHMPIDReconstructor.cxx:18 AliHMPIDReconstructor.cxx:19 AliHMPIDReconstructor.cxx:20 AliHMPIDReconstructor.cxx:21 AliHMPIDReconstructor.cxx:22 AliHMPIDReconstructor.cxx:23 AliHMPIDReconstructor.cxx:24 AliHMPIDReconstructor.cxx:25 AliHMPIDReconstructor.cxx:26 AliHMPIDReconstructor.cxx:27 AliHMPIDReconstructor.cxx:28 AliHMPIDReconstructor.cxx:29 AliHMPIDReconstructor.cxx:30 AliHMPIDReconstructor.cxx:31 AliHMPIDReconstructor.cxx:32 AliHMPIDReconstructor.cxx:33 AliHMPIDReconstructor.cxx:34 AliHMPIDReconstructor.cxx:35 AliHMPIDReconstructor.cxx:36 AliHMPIDReconstructor.cxx:37 AliHMPIDReconstructor.cxx:38 AliHMPIDReconstructor.cxx:39 AliHMPIDReconstructor.cxx:40 AliHMPIDReconstructor.cxx:41 AliHMPIDReconstructor.cxx:42 AliHMPIDReconstructor.cxx:43 AliHMPIDReconstructor.cxx:44 AliHMPIDReconstructor.cxx:45 AliHMPIDReconstructor.cxx:46 AliHMPIDReconstructor.cxx:47 AliHMPIDReconstructor.cxx:48 AliHMPIDReconstructor.cxx:49 AliHMPIDReconstructor.cxx:50 AliHMPIDReconstructor.cxx:51 AliHMPIDReconstructor.cxx:52 AliHMPIDReconstructor.cxx:53 AliHMPIDReconstructor.cxx:54 AliHMPIDReconstructor.cxx:55 AliHMPIDReconstructor.cxx:56 AliHMPIDReconstructor.cxx:57 AliHMPIDReconstructor.cxx:58 AliHMPIDReconstructor.cxx:59 AliHMPIDReconstructor.cxx:60 AliHMPIDReconstructor.cxx:61 AliHMPIDReconstructor.cxx:62 AliHMPIDReconstructor.cxx:63 AliHMPIDReconstructor.cxx:64 AliHMPIDReconstructor.cxx:65 AliHMPIDReconstructor.cxx:66 AliHMPIDReconstructor.cxx:67 AliHMPIDReconstructor.cxx:68 AliHMPIDReconstructor.cxx:69 AliHMPIDReconstructor.cxx:70 AliHMPIDReconstructor.cxx:71 AliHMPIDReconstructor.cxx:72 AliHMPIDReconstructor.cxx:73 AliHMPIDReconstructor.cxx:74 AliHMPIDReconstructor.cxx:75 AliHMPIDReconstructor.cxx:76 AliHMPIDReconstructor.cxx:77 AliHMPIDReconstructor.cxx:78 AliHMPIDReconstructor.cxx:79 AliHMPIDReconstructor.cxx:80 AliHMPIDReconstructor.cxx:81 AliHMPIDReconstructor.cxx:82 AliHMPIDReconstructor.cxx:83 AliHMPIDReconstructor.cxx:84 AliHMPIDReconstructor.cxx:85 AliHMPIDReconstructor.cxx:86 AliHMPIDReconstructor.cxx:87 AliHMPIDReconstructor.cxx:88 AliHMPIDReconstructor.cxx:89 AliHMPIDReconstructor.cxx:90 AliHMPIDReconstructor.cxx:91 AliHMPIDReconstructor.cxx:92 AliHMPIDReconstructor.cxx:93 AliHMPIDReconstructor.cxx:94 AliHMPIDReconstructor.cxx:95 AliHMPIDReconstructor.cxx:96 AliHMPIDReconstructor.cxx:97 AliHMPIDReconstructor.cxx:98 AliHMPIDReconstructor.cxx:99 AliHMPIDReconstructor.cxx:100 AliHMPIDReconstructor.cxx:101 AliHMPIDReconstructor.cxx:102 AliHMPIDReconstructor.cxx:103 AliHMPIDReconstructor.cxx:104 AliHMPIDReconstructor.cxx:105 AliHMPIDReconstructor.cxx:106 AliHMPIDReconstructor.cxx:107 AliHMPIDReconstructor.cxx:108 AliHMPIDReconstructor.cxx:109 AliHMPIDReconstructor.cxx:110 AliHMPIDReconstructor.cxx:111 AliHMPIDReconstructor.cxx:112 AliHMPIDReconstructor.cxx:113 AliHMPIDReconstructor.cxx:114 AliHMPIDReconstructor.cxx:115 AliHMPIDReconstructor.cxx:116 AliHMPIDReconstructor.cxx:117 AliHMPIDReconstructor.cxx:118 AliHMPIDReconstructor.cxx:119 AliHMPIDReconstructor.cxx:120 AliHMPIDReconstructor.cxx:121 AliHMPIDReconstructor.cxx:122 AliHMPIDReconstructor.cxx:123 AliHMPIDReconstructor.cxx:124 AliHMPIDReconstructor.cxx:125 AliHMPIDReconstructor.cxx:126 AliHMPIDReconstructor.cxx:127 AliHMPIDReconstructor.cxx:128 AliHMPIDReconstructor.cxx:129 AliHMPIDReconstructor.cxx:130 AliHMPIDReconstructor.cxx:131 AliHMPIDReconstructor.cxx:132 AliHMPIDReconstructor.cxx:133 AliHMPIDReconstructor.cxx:134 AliHMPIDReconstructor.cxx:135 AliHMPIDReconstructor.cxx:136 AliHMPIDReconstructor.cxx:137 AliHMPIDReconstructor.cxx:138 AliHMPIDReconstructor.cxx:139 AliHMPIDReconstructor.cxx:140 AliHMPIDReconstructor.cxx:141 AliHMPIDReconstructor.cxx:142 AliHMPIDReconstructor.cxx:143 AliHMPIDReconstructor.cxx:144 AliHMPIDReconstructor.cxx:145 AliHMPIDReconstructor.cxx:146 AliHMPIDReconstructor.cxx:147 AliHMPIDReconstructor.cxx:148 AliHMPIDReconstructor.cxx:149 AliHMPIDReconstructor.cxx:150 AliHMPIDReconstructor.cxx:151 AliHMPIDReconstructor.cxx:152 AliHMPIDReconstructor.cxx:153 AliHMPIDReconstructor.cxx:154 AliHMPIDReconstructor.cxx:155 AliHMPIDReconstructor.cxx:156 AliHMPIDReconstructor.cxx:157 AliHMPIDReconstructor.cxx:158 AliHMPIDReconstructor.cxx:159 AliHMPIDReconstructor.cxx:160 AliHMPIDReconstructor.cxx:161 AliHMPIDReconstructor.cxx:162 AliHMPIDReconstructor.cxx:163 AliHMPIDReconstructor.cxx:164 AliHMPIDReconstructor.cxx:165 AliHMPIDReconstructor.cxx:166 AliHMPIDReconstructor.cxx:167 AliHMPIDReconstructor.cxx:168 AliHMPIDReconstructor.cxx:169 AliHMPIDReconstructor.cxx:170 AliHMPIDReconstructor.cxx:171 AliHMPIDReconstructor.cxx:172 AliHMPIDReconstructor.cxx:173 AliHMPIDReconstructor.cxx:174 AliHMPIDReconstructor.cxx:175 AliHMPIDReconstructor.cxx:176 AliHMPIDReconstructor.cxx:177 AliHMPIDReconstructor.cxx:178 AliHMPIDReconstructor.cxx:179 AliHMPIDReconstructor.cxx:180 AliHMPIDReconstructor.cxx:181 AliHMPIDReconstructor.cxx:182 AliHMPIDReconstructor.cxx:183 AliHMPIDReconstructor.cxx:184 AliHMPIDReconstructor.cxx:185 AliHMPIDReconstructor.cxx:186 AliHMPIDReconstructor.cxx:187 AliHMPIDReconstructor.cxx:188 AliHMPIDReconstructor.cxx:189 AliHMPIDReconstructor.cxx:190 AliHMPIDReconstructor.cxx:191 AliHMPIDReconstructor.cxx:192 AliHMPIDReconstructor.cxx:193 AliHMPIDReconstructor.cxx:194 AliHMPIDReconstructor.cxx:195 AliHMPIDReconstructor.cxx:196 AliHMPIDReconstructor.cxx:197 AliHMPIDReconstructor.cxx:198 AliHMPIDReconstructor.cxx:199 AliHMPIDReconstructor.cxx:200 AliHMPIDReconstructor.cxx:201 AliHMPIDReconstructor.cxx:202 AliHMPIDReconstructor.cxx:203 AliHMPIDReconstructor.cxx:204 AliHMPIDReconstructor.cxx:205 AliHMPIDReconstructor.cxx:206 AliHMPIDReconstructor.cxx:207 AliHMPIDReconstructor.cxx:208 AliHMPIDReconstructor.cxx:209