X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=RICH%2FAliRICHDigitizer.cxx;h=031fb1874ff574fdface146f161c17bb71589176;hb=11d31ad9ccd99a826913350e3bdd34b4ce24ffe1;hp=fdd86a1bc27ea54a2a020a5aeab5958687bae671;hpb=cc23c5c6d6cba6eade3645fa14ece9e975ccba33;p=u%2Fmrichter%2FAliRoot.git diff --git a/RICH/AliRICHDigitizer.cxx b/RICH/AliRICHDigitizer.cxx index fdd86a1bc27..031fb1874ff 100644 --- a/RICH/AliRICHDigitizer.cxx +++ b/RICH/AliRICHDigitizer.cxx @@ -13,372 +13,92 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* $Id$ */ - -//Piotr.Skowronski@cern.ch : -//Corrections applied in order to compile (only) with new I/O and folder structure -//To be implemented correctly by responsible - -#include - -#include -#include -#include -#include -#include - -#include "AliRunLoader.h" -#include "AliLoader.h" - #include "AliRICHDigitizer.h" -#include "AliRICHChamber.h" -#include "AliHitMap.h" -#include "AliRICHHitMapA1.h" #include "AliRICH.h" -#include "AliRICHSDigit.h" #include "AliRICHDigit.h" -#include "AliRICHTransientDigit.h" -#include "AliRun.h" -#include "AliPDG.h" +#include +#include #include "AliRunDigitizer.h" +#include +#include -ClassImp(AliRICHDigitizer) - -//___________________________________________ - AliRICHDigitizer::AliRICHDigitizer() -{ -// Default constructor - don't use it - fHits = 0; - fSDigits = 0; - fHitMap = 0; - fTDList = 0; -} -//////////////////////////////////////////////////////////////////////// -AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer* manager) - :AliDigitizer(manager) -{ -// ctor which should be used - fHits = 0; - fSDigits = 0; - fHitMap = 0; - fTDList = 0; - fDebug = 0; - if (GetDebug()>2) - cerr<<"AliRICHDigitizer::AliRICHDigitizer" - <<"(AliRunDigitizer* manager) was processed"<Delete(); - delete fHits; +// 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())); +//First we read all sdigits from all inputs + AliRunLoader *pInRunLoader=0;//in and out Run loaders + AliLoader *pInRichLoader=0;//in and out RICH loaders + TClonesArray sdigs("AliRICHDigit");//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 + pInRichLoader = pInRunLoader->GetLoader("RICHLoader"); if(pInRichLoader==0) continue; //no RICH in this input, check the next input + if (!pInRunLoader->GetAliRun()) pInRunLoader->LoadgAlice(); + AliRICH* pInRich=(AliRICH*)pInRunLoader->GetAliRun()->GetDetector("RICH"); //take RICH from current input + pInRichLoader->LoadSDigits(); pInRichLoader->TreeS()->GetEntry(0); //take list of RICH sdigits from current input + 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 + AliRICHDigit *pSDig=(AliRICHDigit*)pInRich->SdiLst()->At(i); + pSDig->AddTidOffset(fManager->GetMask(inFileN)); //apply TID shift since all inputs count tracks independently starting from 0 + new(sdigs[total++]) AliRICHDigit(*pSDig); } - if (fSDigits) { - fSDigits->Delete(); - delete fSDigits; - } - for (Int_t i=0; iDelete(); - delete fTDList; - } -} - -//------------------------------------------------------------------------ -Bool_t AliRICHDigitizer::Exists(const AliRICHSDigit *padhit) -{ - return (fHitMap[fNch]->TestHit(padhit->PadX(),padhit->PadY())); -} - -//------------------------------------------------------------------------ -void AliRICHDigitizer::Update(AliRICHSDigit *padhit) -{ - AliRICHTransientDigit *pdigit = - static_cast( - fHitMap[fNch]->GetHit(padhit->PadX(),padhit->PadY())); + pInRichLoader->UnloadSDigits(); pInRich->SdiReset(); //close current input and reset + }//files loop - // update charge - // - Int_t iqpad = Int_t(padhit->QPad()); // charge per pad - pdigit->AddSignal(iqpad); - pdigit->AddPhysicsSignal(iqpad); - - // update list of tracks - // - Int_t track, charge; - track = fTrack+fMask; - if (fSignal) { - charge = iqpad; - } else { - charge = kBgTag; - } - pdigit->UpdateTrackList(track,charge); -} - -//------------------------------------------------------------------------ -void AliRICHDigitizer::CreateNew(AliRICHSDigit *padhit) -{ - fTDList->AddAtAndExpand( - new AliRICHTransientDigit(fNch,fDigits),fCounter); - fHitMap[fNch]->SetHit(padhit->PadX(),padhit->PadY(),fCounter); - - AliRICHTransientDigit* pdigit = - static_cast(fTDList->Last()); - // list of tracks - Int_t track, charge; - if (fSignal) { - track = fTrack; - charge = padhit->QPad(); - } else { - track = kBgTag; - charge = kBgTag; - } - pdigit->AddToTrackList(track,charge); - fCounter++; -} - - -//////////////////////////////////////////////////////////////////////// -Bool_t AliRICHDigitizer::Init() -{ -// Initialisation - fHits = new TClonesArray("AliRICHhit",1000); - fSDigits = new TClonesArray("AliRICHSDigit",1000); - return kTRUE; -} - -//////////////////////////////////////////////////////////////////////// -//void AliRICHDigitizer::Digitise(Int_t nev, Int_t flag) -void AliRICHDigitizer::Exec(Option_t* option) -{ - TString optionString = option; - if (optionString.Data() == "deb") { - cout<<"AliMUONDigitizer::Exec: called with option deb "<GetOutputFolderName()); - outgime = outRL->GetLoader("RICHLoader"); + if(sdigs.GetEntries()==0) return; //no sdigits collected, nothing to convert + + AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); //open output stream (only 1 possible) + AliLoader *pOutRichLoader = pOutRunLoader->GetLoader("RICHLoader"); //take output RICH loader + AliRICH *pOutRich = (AliRICH*)pOutRunLoader->GetAliRun()->GetDetector("RICH"); //take output RICH + pOutRichLoader->MakeTree("D"); pOutRich->MakeBranch("D"); //create TreeD in output stream - fTDList = new TObjArray; + Sdi2Dig(&sdigs,pOutRich->DigLst()); - - AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH"); + pOutRichLoader->TreeD()->Fill(); //fill the output tree with the list of digits + pOutRichLoader->WriteDigits("OVERWRITE"); //serialize them to file - if (outgime->TreeD() == 0x0) outgime->MakeTree("D"); + sdigs.Clear(); //remove all tmp sdigits + pOutRichLoader->UnloadDigits(); pOutRich->DigReset(); +}//Exec() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +void AliRICHDigitizer::Sdi2Dig(TClonesArray *pSdiLst,TObjArray *pDigLst) +{ +// Converts list of sdigits to 7 lists of digits, one per each chamber +// Arguments: pSDigLst - list of all sdigits +// pDigLst - list of 7 lists of digits +// Returns: none - pRICH->MakeBranchInTreeD(outgime->TreeD()); - fHitMap= new AliHitMap* [kNCH]; - - for (Int_t i =0; iChamber(i)); - segmentation=iChamber->GetSegmentationModel(); - fHitMap[i] = new AliRICHHitMapA1(segmentation, fTDList); + TClonesArray *pLst[7]; Int_t iCnt[7]; + + for(Int_t i=0;i<7;i++){ + pLst[i]=(TClonesArray*)(*pDigLst)[i]; + iCnt[i]=pLst[i]->GetEntries(); //in principle those lists should be empty } - -// Loop over files to digitize - fSignal = kTRUE; - fCounter = 0; - for (Int_t inputFile=0; inputFileGetNinputs(); inputFile++) - { - inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); - ingime = inRL->GetLoader("RICHLoader"); - -// Connect RICH branches - - if (inputFile > 0 ) fSignal = kFALSE; - TBranch *branchHits = 0; - TBranch *branchSDigits = 0; - - ingime->LoadHits("READ"); - TTree *treeH = ingime->TreeH(); - if (GetDebug()>2) { - cerr<<" inputFile "<GetBranch("RICH"); - if (branchHits) - { - fHits->Clear(); - branchHits->SetAddress(&fHits); - } - else - Error("Exec","branch RICH was not found"); - } - if (GetDebug()>2) cerr<<" branchHits = "<GetBranch("RICHSDigits"); - if (branchSDigits) - branchSDigits->SetAddress(&fSDigits); - else - Error("exec","branch RICHSDigits was not found"); - } - if (GetDebug()>2) cerr<<" branchSDigits = "<GetEntries(); - for (fTrack=0; fTrackClear(); - fSDigits->Clear(); - branchHits->GetEntry(fTrack); - branchSDigits->GetEntry(fTrack); - - - // - // Loop over hits - for(Int_t i = 0; i < fHits->GetEntriesFast(); ++i) { - AliRICHhit* mHit = static_cast(fHits->At(i)); - fNch = mHit->Chamber()-1; // chamber number - if (fNch >= kNCH) { - cerr<<"AliRICHDigitizer: chamber nr. fNch out of range: "<Chamber(fNch)); - - // - // Loop over pad hits - for (AliRICHSDigit* mPad= - (AliRICHSDigit*)pRICH->FirstPad(mHit,fSDigits); - mPad; - mPad=(AliRICHSDigit*)pRICH->NextPad(fSDigits)) - { - Int_t iqpad = mPad->QPad(); // charge per pad - fDigits[0]=mPad->PadX(); - fDigits[1]=mPad->PadY(); - fDigits[2]=iqpad; - fDigits[3]=iqpad; - fDigits[4]=mPad->HitNumber(); - - - - // build the list of fired pads and update the info - if (Exists(mPad)) { - Update(mPad); - } else { - CreateNew(mPad); - } - } //end loop over clusters - } // hit loop - } // track loop - } // end file loop - if (GetDebug()>2) cerr<<"END OF FILE LOOP"<GetEntriesFast(); - - for (Int_t nent=0;nentAt(nent); - if (transDigit==0) continue; - Int_t ich=transDigit->GetChamber(); - Int_t q=transDigit->Signal(); - iChamber=&(pRICH->Chamber(ich)); - AliRICHResponse * response=iChamber->GetResponseModel(); - Int_t adcmax= (Int_t) response->MaxAdc(); - - - // add white noise and do zero-suppression and signal truncation (new electronics,old electronics gaus 1.2,0.2) - //printf("Treshold: %d\n",iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY())); - -// tmp change -// Int_t pedestal = iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY()); - Int_t pedestal = 0; - - - //printf("Pedestal:%d\n",pedestal); - //Int_t pedestal=0; - Float_t treshold = (pedestal + 4*2.2); - - Float_t meanNoise = gRandom->Gaus(2.2, 0.3); - Float_t noise = gRandom->Gaus(0, meanNoise); - q+=(Int_t)(noise + pedestal); - //q+=(Int_t)(noise); - // magic number to be parametrised !!! - if ( q <= treshold) - { - q = q - pedestal; + + 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) + AliRICHDigit *pSdig=(AliRICHDigit*)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; } - q = q - pedestal; - if ( q >= adcmax) q=adcmax; - fDigits[0]=transDigit->PadX(); - fDigits[1]=transDigit->PadY(); - fDigits[2]=q; - fDigits[3]=transDigit->Physics(); - fDigits[4]=transDigit->Hit(); - - Int_t nptracks = transDigit->GetNTracks(); - - // this was changed to accomodate the real number of tracks - if (nptracks > kMAXTRACKSPERRICHDIGIT) { - printf("Attention - tracks > 10 %d\n",nptracks); - nptracks=kMAXTRACKSPERRICHDIGIT; - } - if (nptracks > 2) { - printf("Attention - tracks > 2 %d \n",nptracks); - } - for (Int_t tr=0;trGetTrack(tr); - charges[tr]=transDigit->GetCharge(tr); - //printf("%f \n",charges[tr]); - } //end loop over list of tracks for one pad - if (nptracks < kMAXTRACKSPERRICHDIGIT ) { - for (Int_t t=nptracks; tAddDigits(ich,tracks,charges,fDigits); - } - outgime->TreeD()->Fill(); - - //pRICH->ResetDigits(); - fTDList->Delete(); // or fTDList->Clear(); ??? - for(Int_t ii=0;iiDigitsAddress(k); - Int_t ndigit=richDigits->GetEntriesFast(); - printf ("Chamber %d digits %d \n",k,ndigit); - } - pRICH->ResetDigits(); /// ??? should it be here??? + if(i!=0 && AliRICHDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliRICHDigit(iPad,(Int_t)q,aTids); //do not create digit for the very first sdigit + iPad=pSdig->Pad(); iCh=AliRICHDigit::A2C(iPad); //new sdigit comes, reset collectors + iNdigPad=1; + aTids[0]=pSdig->GetTrack(0);aTids[1]=aTids[2]=-1; + q=pSdig->Q(); + }//sdigits loop (sorted) - outgime->WriteDigits("OVERWRITE"); - - delete [] fHitMap; - delete fTDList; - - if (fHits) fHits->Delete(); - if (fSDigits) fSDigits->Delete(); - -} + if(AliRICHDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliRICHDigit(iPad,(Int_t)q,aTids); //add the last one, in case of empty sdigits list q=-1 + //so digit is not created +}//Sdi2Dig() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++