X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HMPID%2FAliHMPIDDigitizer.cxx;h=15b9fe02a70bbf10f24ec5dd31ad1d0e805ae098;hb=d1c0ae8f1124c7df31c5f73d06deadcadfc35561;hp=e159151994b90fbc29eff7024cf71770878b03d3;hpb=273116933d4655b9fc24b95e7996dd8f1d0a3e6c;p=u%2Fmrichter%2FAliRoot.git diff --git a/HMPID/AliHMPIDDigitizer.cxx b/HMPID/AliHMPIDDigitizer.cxx index e159151994b..15b9fe02a70 100644 --- a/HMPID/AliHMPIDDigitizer.cxx +++ b/HMPID/AliHMPIDDigitizer.cxx @@ -12,32 +12,44 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ - -#include "AliHMPIDDigitizer.h" -#include "AliHMPID.h" +//. +//. +//. +//. +//. #include #include -#include "AliRunDigitizer.h" +#include "AliDigitizationInput.h" #include -#include - +#include "AliLog.h" +#include +#include +#include "AliHMPIDDigitizer.h" +#include "AliHMPIDReconstructor.h" +#include "AliHMPIDDigit.h" +#include "AliHMPID.h" +#include "AliHMPIDParam.h" +#include +#include +#include +#include ClassImp(AliHMPIDDigitizer) -Bool_t AliHMPIDDigitizer::fDoNoise=kFALSE; +Bool_t AliHMPIDDigitizer::fgDoNoise=kTRUE; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -void AliHMPIDDigitizer::Exec(Option_t*) +void AliHMPIDDigitizer::Digitize(Option_t*) { // This methode is responsible for merging sdigits to a list of digits //Disintegration leeds to the fact that one hit affects several neighbouring pads, which means that the same pad might be affected by few hits. - AliDebug(1,Form("Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr())); + AliDebug(1,Form("Start with %i input(s) for event %i",fDigInput->GetNinputs(),fDigInput->GetOutputEventNr())); //First we read all sdigits from all inputs AliRunLoader *pInRunLoader=0;//in and out Run loaders AliLoader *pInRichLoader=0;//in and out HMPID loaders - TClonesArray sdigs("AliHMPIDDigit");//tmp storage for sdigits sum up from all input files + static TClonesArray sdigs("AliHMPIDDigit");//tmp storage for sdigits sum up from all input files Int_t total=0; - for(Int_t inFileN=0;inFileNGetNinputs();inFileN++){//files loop - pInRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN)); //get run loader from current input + for(Int_t inFileN=0;inFileNGetNinputs();inFileN++){//files loop + pInRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inFileN)); //get run loader from current input pInRichLoader = pInRunLoader->GetLoader("HMPIDLoader"); if(pInRichLoader==0) continue; //no HMPID in this input, check the next input if (!pInRunLoader->GetAliRun()) pInRunLoader->LoadgAlice(); AliHMPID* pInRich=(AliHMPID*)pInRunLoader->GetAliRun()->GetDetector("HMPID"); //take HMPID from current input @@ -45,7 +57,7 @@ void AliHMPIDDigitizer::Exec(Option_t*) AliDebug(1,Form("input %i has %i sdigits",inFileN,pInRich->SdiLst()->GetEntries())); for(Int_t i=0;iSdiLst()->GetEntries();i++){ //collect sdigits from current input AliHMPIDDigit *pSDig=(AliHMPIDDigit*)pInRich->SdiLst()->At(i); - pSDig->AddTidOffset(fManager->GetMask(inFileN)); //apply TID shift since all inputs count tracks independently starting from 0 + pSDig->AddTidOffset(fDigInput->GetMask(inFileN)); //apply TID shift since all inputs count tracks independently starting from 0 new(sdigs[total++]) AliHMPIDDigit(*pSDig); } pInRichLoader->UnloadSDigits(); pInRich->SdiReset(); //close current input and reset @@ -53,9 +65,10 @@ void AliHMPIDDigitizer::Exec(Option_t*) //PH if(sdigs.GetEntries()==0) return; //no sdigits collected, nothing to convert - AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); //open output stream (only 1 possible) + AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName()); //open output stream (only 1 possible) AliLoader *pOutRichLoader = pOutRunLoader->GetLoader("HMPIDLoader"); //take output HMPID loader - AliHMPID *pOutRich = (AliHMPID*)pOutRunLoader->GetAliRun()->GetDetector("HMPID"); //take output HMPID + AliRun *pArun = pOutRunLoader->GetAliRun(); + AliHMPID *pOutRich = (AliHMPID*)pArun->GetDetector("HMPID"); //take output HMPID pOutRichLoader->MakeTree("D"); pOutRich->MakeBranch("D"); //create TreeD in output stream Sdi2Dig(&sdigs,pOutRich->DigLst()); @@ -75,51 +88,87 @@ void AliHMPIDDigitizer::Sdi2Dig(TClonesArray *pSdiLst,TObjArray *pDigLst) // Returns: none TClonesArray *pLst[7]; Int_t iCnt[7]; - + for(Int_t i=0;i<7;i++){ pLst[i]=(TClonesArray*)(*pDigLst)[i]; iCnt[i]=0; if(pLst[i]->GetEntries()!=0) AliErrorClass("Some of digits lists is not empty"); //in principle those lists should be empty } - + // make noise array - Float_t arrNoise[7][6][80][48]; - if(fDoNoise) { - for (Int_t iCh=AliHMPIDDigit::kMinCh;iCh<=AliHMPIDDigit::kMaxCh;iCh++) - for (Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++) - for(Int_t iPx=AliHMPIDDigit::kMinPx;iPx<=AliHMPIDDigit::kMaxPx;iPx++) - for(Int_t iPy=AliHMPIDDigit::kMinPy;iPy<=AliHMPIDDigit::kMaxPy;iPy++) arrNoise[iCh][iPc][iPx][iPy] = gRandom->Gaus(0,1); + Float_t arrNoise[7][6][80][48], arrSigmaPed[7][6][80][48]; + if(fgDoNoise) { + for (Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) + for (Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++) + for(Int_t iPx=AliHMPIDParam::kMinPx;iPx<=AliHMPIDParam::kMaxPx;iPx++) + for(Int_t iPy=AliHMPIDParam::kMinPy;iPy<=AliHMPIDParam::kMaxPy;iPy++){ + arrNoise[iCh][iPc][iPx][iPy] = gRandom->Gaus(0,1.); + arrSigmaPed[iCh][iPc][iPx][iPy] = 1.; + } + + AliCDBEntry *pDaqSigEnt = AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig"); //contains TObjArray of TObjArray 14 TMatrixF sigmas values for pads + + if(pDaqSigEnt){ + TObjArray *pDaqSig = (TObjArray*)pDaqSigEnt->GetObject(); + for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){ //chambers loop + TMatrixF *pM = (TMatrixF*)pDaqSig->At(iCh); + for (Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++) + for(Int_t iPx=AliHMPIDParam::kMinPx;iPx<=AliHMPIDParam::kMaxPx;iPx++) + for(Int_t iPy=AliHMPIDParam::kMinPy;iPy<=AliHMPIDParam::kMaxPy;iPy++){ + Int_t padX = (iPc%2)*AliHMPIDParam::kPadPcX+iPx; + Int_t padY = (iPc/2)*AliHMPIDParam::kPadPcY+iPy; + if((*pM)(padX,padY)>0.){ + arrNoise[iCh][iPc][iPx][iPy] = gRandom->Gaus(0,(*pM)(padX,padY)); + arrSigmaPed[iCh][iPc][iPx][iPy] = (*pM)(padX,padY);} + else{ + arrNoise[iCh][iPc][iPx][iPy] = gRandom->Gaus(0,1.); + arrSigmaPed[iCh][iPc][iPx][iPy] = 1.;} + } + } + } } pSdiLst->Sort(); Int_t iPad=-1,iCh=-1,iNdigPad=-1,aTids[3]={-1,-1,-1}; Float_t q=-1; for(Int_t i=0;iGetEntries();i++){ //sdigits loop (sorted) - AliHMPIDDigit *pSdig=(AliHMPIDDigit*)pSdiLst->At(i); //take current sdigit + AliHMPIDDigit *pSdig=(AliHMPIDDigit*)pSdiLst->At(i); //take current sdigit if(pSdig->Pad()==iPad){ //if the same pad q+=pSdig->Q(); //sum up charge iNdigPad++; if(iNdigPad<=3) aTids[iNdigPad-1]=pSdig->GetTrack(0); //collect TID continue; } - if(i!=0 && AliHMPIDDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliHMPIDDigit(iPad,(Int_t)q,aTids); //do not create digit for the very first sdigit - iPad=pSdig->Pad(); iCh=AliHMPIDDigit::A2C(iPad); //new sdigit comes, reset collectors + if(i!=0 && iCh>=AliHMPIDParam::kMinCh && iCh<=AliHMPIDParam::kMaxCh){ + AliHMPIDParam::Instance()->SetThreshold((TMath::Nint(arrSigmaPed[iCh][pSdig->Pc()][pSdig->PadPcX()][pSdig->PadPcY()])*AliHMPIDParam::Nsig())); + if(AliHMPIDParam::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliHMPIDDigit(iPad,(Int_t)q,aTids);} //do not create digit for the very first sdigit + + iPad=pSdig->Pad(); iCh=AliHMPIDParam::A2C(iPad); //new sdigit comes, reset collectors iNdigPad=1; aTids[0]=pSdig->GetTrack(0);aTids[1]=aTids[2]=-1; q=pSdig->Q(); - if(fDoNoise) q+=arrNoise[iCh][pSdig->Pc()][pSdig->PadPcX()][pSdig->PadPcY()]; + if(fgDoNoise) q+=arrNoise[iCh][pSdig->Pc()][pSdig->PadPcX()][pSdig->PadPcY()]; arrNoise[iCh][pSdig->Pc()][pSdig->PadPcX()][pSdig->PadPcY()]=0; }//sdigits loop (sorted) - if(AliHMPIDDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliHMPIDDigit(iPad,(Int_t)q,aTids); //add the last one, in case of empty sdigits list q=-1 + if(iCh>=AliHMPIDParam::kMinCh && iCh<=AliHMPIDParam::kMaxCh){ + Int_t pc = AliHMPIDParam::A2P(iPad); + Int_t px = AliHMPIDParam::A2X(iPad); + Int_t py = AliHMPIDParam::A2Y(iPad); + AliHMPIDParam::Instance()->SetThreshold((TMath::Nint(arrSigmaPed[iCh][pc][px][py])*AliHMPIDParam::Nsig())); + if(AliHMPIDParam::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliHMPIDDigit(iPad,(Int_t)q,aTids); + } //add the last one, in case of empty sdigits list q=-1 + // add noise pad above threshold with no signal merged...if any - if(!fDoNoise) return; + if(!fgDoNoise) return; + aTids[0]=aTids[1]=aTids[2]=-1; - for (Int_t iCh=AliHMPIDDigit::kMinCh;iCh<=AliHMPIDDigit::kMaxCh;iCh++) - for (Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++) - for(Int_t iPx=AliHMPIDDigit::kMinPx;iPx<=AliHMPIDDigit::kMaxPx;iPx++) - for(Int_t iPy=AliHMPIDDigit::kMinPy;iPy<=AliHMPIDDigit::kMaxPy;iPy++) { - Float_t q = arrNoise[iCh][iPc][iPx][iPy]; - if(AliHMPIDDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliHMPIDDigit(AliHMPIDDigit::Abs(iCh,iPc,iPx,iPy),(Int_t)q,aTids); + for (Int_t iChCurr=AliHMPIDParam::kMinCh;iChCurr<=AliHMPIDParam::kMaxCh;iChCurr++){ + for (Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++) + for(Int_t iPx=AliHMPIDParam::kMinPx;iPx<=AliHMPIDParam::kMaxPx;iPx++) + for(Int_t iPy=AliHMPIDParam::kMinPy;iPy<=AliHMPIDParam::kMaxPy;iPy++) { + Float_t qNoise = arrNoise[iChCurr][iPc][iPx][iPy]; + AliHMPIDParam::Instance()->SetThreshold((TMath::Nint(arrSigmaPed[iChCurr][iPc][iPx][iPy])*AliHMPIDParam::Nsig())); + if(AliHMPIDParam::IsOverTh(qNoise)) new((*pLst[iChCurr])[iCnt[iChCurr]++]) AliHMPIDDigit(AliHMPIDParam::Abs(iChCurr,iPc,iPx,iPy),(Int_t)qNoise,aTids); } - + } }//Sdi2Dig() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++