]>
Commit | Line | Data |
---|---|---|
d3da6dc4 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
1b10372c | 15 | //. |
16 | //. | |
17 | //. | |
18 | //. | |
19 | //. | |
20 | #include <AliRun.h> | |
d3da6dc4 | 21 | #include <AliRunLoader.h> |
22 | #include "AliRunDigitizer.h" | |
23 | #include <AliLoader.h> | |
24 | #include <AliLog.h> | |
1b10372c | 25 | #include "AliHMPIDDigitizer.h" |
26 | #include "AliHMPIDDigit.h" | |
27 | #include "AliHMPID.h" | |
ae5a42aa | 28 | #include "AliHMPIDParam.h" |
1b10372c | 29 | #include <TRandom.h> |
d3da6dc4 | 30 | |
73badab2 | 31 | extern TRandom *gRandom; |
32 | ||
d3da6dc4 | 33 | ClassImp(AliHMPIDDigitizer) |
34 | ||
94b1fbfa | 35 | Bool_t AliHMPIDDigitizer::fgDoNoise=kFALSE; |
d3da6dc4 | 36 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
37 | void AliHMPIDDigitizer::Exec(Option_t*) | |
38 | { | |
39 | // This methode is responsible for merging sdigits to a list of digits | |
40 | //Disintegration leeds to the fact that one hit affects several neighbouring pads, which means that the same pad might be affected by few hits. | |
41 | AliDebug(1,Form("Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr())); | |
42 | //First we read all sdigits from all inputs | |
43 | AliRunLoader *pInRunLoader=0;//in and out Run loaders | |
44 | AliLoader *pInRichLoader=0;//in and out HMPID loaders | |
d6183365 | 45 | static TClonesArray sdigs("AliHMPIDDigit");//tmp storage for sdigits sum up from all input files |
d3da6dc4 | 46 | Int_t total=0; |
47 | for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop | |
48 | pInRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN)); //get run loader from current input | |
49 | pInRichLoader = pInRunLoader->GetLoader("HMPIDLoader"); if(pInRichLoader==0) continue; //no HMPID in this input, check the next input | |
50 | if (!pInRunLoader->GetAliRun()) pInRunLoader->LoadgAlice(); | |
51 | AliHMPID* pInRich=(AliHMPID*)pInRunLoader->GetAliRun()->GetDetector("HMPID"); //take HMPID from current input | |
52 | pInRichLoader->LoadSDigits(); pInRichLoader->TreeS()->GetEntry(0); //take list of HMPID sdigits from current input | |
53 | AliDebug(1,Form("input %i has %i sdigits",inFileN,pInRich->SdiLst()->GetEntries())); | |
54 | for(Int_t i=0;i<pInRich->SdiLst()->GetEntries();i++){ //collect sdigits from current input | |
55 | AliHMPIDDigit *pSDig=(AliHMPIDDigit*)pInRich->SdiLst()->At(i); | |
56 | pSDig->AddTidOffset(fManager->GetMask(inFileN)); //apply TID shift since all inputs count tracks independently starting from 0 | |
57 | new(sdigs[total++]) AliHMPIDDigit(*pSDig); | |
58 | } | |
59 | pInRichLoader->UnloadSDigits(); pInRich->SdiReset(); //close current input and reset | |
60 | }//files loop | |
61 | ||
62 | //PH if(sdigs.GetEntries()==0) return; //no sdigits collected, nothing to convert | |
63 | ||
64 | AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); //open output stream (only 1 possible) | |
65 | AliLoader *pOutRichLoader = pOutRunLoader->GetLoader("HMPIDLoader"); //take output HMPID loader | |
1b10372c | 66 | AliRun *pArun = pOutRunLoader->GetAliRun(); |
67 | AliHMPID *pOutRich = (AliHMPID*)pArun->GetDetector("HMPID"); //take output HMPID | |
d3da6dc4 | 68 | pOutRichLoader->MakeTree("D"); pOutRich->MakeBranch("D"); //create TreeD in output stream |
69 | ||
70 | Sdi2Dig(&sdigs,pOutRich->DigLst()); | |
71 | ||
72 | pOutRichLoader->TreeD()->Fill(); //fill the output tree with the list of digits | |
73 | pOutRichLoader->WriteDigits("OVERWRITE"); //serialize them to file | |
74 | ||
75 | sdigs.Clear(); //remove all tmp sdigits | |
76 | pOutRichLoader->UnloadDigits(); pOutRich->DigReset(); | |
77 | }//Exec() | |
78 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
79 | void AliHMPIDDigitizer::Sdi2Dig(TClonesArray *pSdiLst,TObjArray *pDigLst) | |
80 | { | |
81 | // Converts list of sdigits to 7 lists of digits, one per each chamber | |
82 | // Arguments: pSDigLst - list of all sdigits | |
83 | // pDigLst - list of 7 lists of digits | |
84 | // Returns: none | |
85 | ||
86 | TClonesArray *pLst[7]; Int_t iCnt[7]; | |
1b10372c | 87 | |
d3da6dc4 | 88 | for(Int_t i=0;i<7;i++){ |
89 | pLst[i]=(TClonesArray*)(*pDigLst)[i]; | |
3c6274c1 | 90 | iCnt[i]=0; if(pLst[i]->GetEntries()!=0) AliErrorClass("Some of digits lists is not empty"); //in principle those lists should be empty |
d3da6dc4 | 91 | } |
c5c19d6a | 92 | |
93 | // make noise array | |
94 | Float_t arrNoise[7][6][80][48]; | |
94b1fbfa | 95 | if(fgDoNoise) { |
ae5a42aa | 96 | for (Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) |
97 | for (Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++) | |
98 | for(Int_t iPx=AliHMPIDParam::kMinPx;iPx<=AliHMPIDParam::kMaxPx;iPx++) | |
73badab2 | 99 | for(Int_t iPy=AliHMPIDParam::kMinPy;iPy<=AliHMPIDParam::kMaxPy;iPy++) arrNoise[iCh][iPc][iPx][iPy] = gRandom->Gaus(0,1.1); |
c5c19d6a | 100 | } |
d3da6dc4 | 101 | |
102 | pSdiLst->Sort(); | |
103 | ||
104 | Int_t iPad=-1,iCh=-1,iNdigPad=-1,aTids[3]={-1,-1,-1}; Float_t q=-1; | |
105 | for(Int_t i=0;i<pSdiLst->GetEntries();i++){ //sdigits loop (sorted) | |
106 | AliHMPIDDigit *pSdig=(AliHMPIDDigit*)pSdiLst->At(i); //take current sdigit | |
107 | if(pSdig->Pad()==iPad){ //if the same pad | |
108 | q+=pSdig->Q(); //sum up charge | |
109 | iNdigPad++; if(iNdigPad<=3) aTids[iNdigPad-1]=pSdig->GetTrack(0); //collect TID | |
110 | continue; | |
111 | } | |
ae5a42aa | 112 | if(i!=0 && AliHMPIDParam::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliHMPIDDigit(iPad,(Int_t)q,aTids); //do not create digit for the very first sdigit |
113 | iPad=pSdig->Pad(); iCh=AliHMPIDParam::A2C(iPad); //new sdigit comes, reset collectors | |
d3da6dc4 | 114 | iNdigPad=1; |
115 | aTids[0]=pSdig->GetTrack(0);aTids[1]=aTids[2]=-1; | |
c5c19d6a | 116 | q=pSdig->Q(); |
94b1fbfa | 117 | if(fgDoNoise) q+=arrNoise[iCh][pSdig->Pc()][pSdig->PadPcX()][pSdig->PadPcY()]; |
c5c19d6a | 118 | arrNoise[iCh][pSdig->Pc()][pSdig->PadPcX()][pSdig->PadPcY()]=0; |
d3da6dc4 | 119 | }//sdigits loop (sorted) |
120 | ||
ae5a42aa | 121 | 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 |
c5c19d6a | 122 | // add noise pad above threshold with no signal merged...if any |
94b1fbfa | 123 | if(!fgDoNoise) return; |
c5c19d6a | 124 | aTids[0]=aTids[1]=aTids[2]=-1; |
ec575c20 | 125 | for (Int_t iChCurr=AliHMPIDParam::kMinCh;iChCurr<=AliHMPIDParam::kMaxCh;iChCurr++) |
ae5a42aa | 126 | for (Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++) |
127 | for(Int_t iPx=AliHMPIDParam::kMinPx;iPx<=AliHMPIDParam::kMaxPx;iPx++) | |
128 | for(Int_t iPy=AliHMPIDParam::kMinPy;iPy<=AliHMPIDParam::kMaxPy;iPy++) { | |
ec575c20 | 129 | Float_t qNoise = arrNoise[iChCurr][iPc][iPx][iPy]; |
130 | if(AliHMPIDParam::IsOverTh(qNoise)) new((*pLst[iChCurr])[iCnt[iChCurr]++]) AliHMPIDDigit(AliHMPIDParam::Abs(iChCurr,iPc,iPx,iPy),(Int_t)qNoise,aTids); | |
c5c19d6a | 131 | } |
132 | ||
d3da6dc4 | 133 | }//Sdi2Dig() |
134 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |