]>
Commit | Line | Data |
---|---|---|
1d9af2d5 | 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 | **************************************************************************/ | |
15 | //. | |
16 | ||
17 | /* $Id$ */ | |
18 | ||
19 | #include <AliRun.h> | |
20 | #include <AliRunLoader.h> | |
21 | #include "AliRunDigitizer.h" | |
22 | #include <AliLoader.h> | |
23 | #include <AliLog.h> | |
24 | #include "AliITSupgradeDigitizer.h" | |
25 | #include "AliITSDigitUpgrade.h" | |
26 | #include "AliITSupgrade.h" | |
27 | #include <TObjArray.h> | |
28 | #include <TClonesArray.h> | |
29 | ||
30 | extern TRandom *gRandom; | |
31 | ||
32 | ClassImp(AliITSupgradeDigitizer) | |
33 | ||
34 | void AliITSupgradeDigitizer::SetConfiguration(TArrayD xcell, TArrayD zcell) | |
35 | { | |
36 | ||
37 | if(xcell.GetSize()!=zcell.GetSize()) AliError(" !! The # of X cells and Z cells differ !!"); | |
38 | ||
39 | fNlayers = xcell.GetSize(); | |
40 | ||
41 | if(fNlayers > 9) { | |
42 | AliError("* Only 9 layers can be be filled ...Exiting!!! *"); | |
43 | return; | |
44 | } | |
45 | ||
46 | fNxCells.Set(fNlayers); | |
47 | fNzCells.Set(fNlayers); | |
48 | for(Int_t i=0; i<fNlayers; i++){ | |
49 | fNxCells.AddAt(xcell.At(i),i); | |
50 | fNzCells.AddAt(zcell.At(i),i); | |
51 | } | |
52 | } | |
53 | //______________________________________________________________________________ | |
54 | void AliITSupgradeDigitizer::Exec(Option_t*) | |
55 | { | |
56 | // This method is responsible for merging sdigits to a list of digits | |
57 | // Disintegration leeds to the fact that one hit affects several neighbouring pads, | |
58 | // which means that the same pad might be affected by few hits. | |
59 | ||
60 | AliDebug(1,Form("Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr())); | |
61 | ||
62 | ||
63 | AliITSsegmentationUpgrade *s = new AliITSsegmentationUpgrade(); | |
64 | SetConfiguration(s->GetFullCellSizeX(),s->GetFullCellSizeZ()); | |
65 | delete s; | |
66 | //First we read all sdigits from all inputs | |
67 | AliRunLoader *pInRunLoader=0;//in and out Run loaders | |
68 | AliLoader *pITSLoader=0;//in and out ITS loaders | |
69 | ||
70 | TClonesArray sdigits[10]; | |
71 | for(Int_t i=0; i<fNlayers; i++) sdigits[i].SetClass("AliITSDigitUpgrade");//tmp storage for sdigits sum up from all input files | |
72 | ||
73 | ||
74 | Int_t total[10]={0,0,0,0,0,0,0,0,0,0}; | |
75 | for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop | |
76 | ||
77 | pInRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN)); //get run loader from current input | |
78 | pITSLoader = pInRunLoader->GetLoader("ITSLoader"); | |
79 | if(pITSLoader==0) { | |
80 | continue; //no ITS in this input, check the next input | |
81 | AliDebug(1,"no ITS lodader, checking in the other input \n"); | |
82 | } | |
83 | ||
84 | if (!pInRunLoader->GetAliRun()) pInRunLoader->LoadgAlice(); | |
85 | AliITSupgrade* pITS=(AliITSupgrade*)pInRunLoader->GetAliRun()->GetDetector("ITS"); | |
86 | ||
87 | pITSLoader->LoadSDigits(); | |
88 | ||
89 | pITSLoader->TreeS()->GetEntry(0); //take list of ITS sdigits from current input | |
90 | ||
91 | for(Int_t is=0;is<pITS->SDigitsList()->GetEntries();is++){ | |
92 | ||
93 | //collect sdigits from current input | |
94 | for(Int_t ientr =0; ientr < ((TClonesArray*)pITS->SDigitsList()->At(is))->GetEntries(); ientr++){ | |
95 | AliITSDigitUpgrade *pSDig=(AliITSDigitUpgrade*)((TClonesArray*)pITS->SDigitsList()->At(is))->At(ientr); | |
96 | pSDig->AddTidOffset(fManager->GetMask(inFileN)); // -> To be introduced for merging (apply TID shift since all inputs count tracks independently starting from 0) | |
97 | new((sdigits[is])[total[is]++]) AliITSDigitUpgrade(*pSDig); | |
98 | } | |
99 | } | |
100 | ||
101 | pITSLoader->UnloadSDigits(); | |
102 | pITS->SDigitsReset(); //close current input and reset | |
103 | }//files loop | |
104 | ||
105 | AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); //open output stream (only 1 possible) | |
106 | AliLoader *pOutITSLoader = pOutRunLoader->GetLoader("ITSLoader"); | |
107 | AliRun *pArun = pOutRunLoader->GetAliRun(); | |
108 | AliITSupgrade *pOutITS = (AliITSupgrade*)pArun->GetDetector("ITS"); | |
109 | pOutITSLoader->MakeTree("D"); pOutITS->MakeBranch("D"); //create TreeD in output stream | |
110 | pOutITS->SetTreeAddress(); | |
111 | ||
112 | Sdigits2Digits(sdigits,pOutITS->DigitsList()); | |
113 | ||
114 | pOutITSLoader->TreeD()->Fill(); //fill the output tree with the list of digits | |
115 | pOutITSLoader->WriteDigits("OVERWRITE"); //serialize them to file | |
116 | ||
117 | for(Int_t i=0; i< fNlayers; i++) sdigits[i].Clear(); //remove all tmp sdigits | |
118 | pOutITSLoader->UnloadDigits(); | |
119 | pOutITS->DigitsReset(); | |
120 | }//Exec() | |
121 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
122 | void AliITSupgradeDigitizer::Sdigits2Digits(TClonesArray *pSDigitList,TObjArray *pDigitList) | |
123 | { | |
124 | TClonesArray *pLst[100]; Int_t iCnt[100]; | |
125 | ||
126 | for(Int_t i=0;i<fNlayers;i++){ | |
127 | pLst[i]=(TClonesArray*)(*pDigitList)[i]; | |
128 | iCnt[i]=0; if(pLst[i]->GetEntries()!=0) AliErrorClass("Some of digits lists is not empty"); //in principle those lists should be empty | |
129 | } | |
130 | ||
6ea6235b | 131 | //AliInfo("starting loop over gli sdigits to create the digits"); |
1d9af2d5 | 132 | Double_t eloss =0.; |
133 | Double_t nele = 0.; | |
134 | ULong_t pixid = 999; | |
135 | Int_t tids[3]={-1,-1,-1}; | |
136 | ||
137 | Float_t elossID[3]={-1.,-1.,-1.}; | |
6ea6235b | 138 | //AliInfo("starting layers"); |
1d9af2d5 | 139 | AliDebug(1,"starting loop over layers"); |
140 | ||
141 | for(Int_t ilay=0;ilay<fNlayers;ilay++){ | |
142 | ||
143 | AliITSDigitUpgrade *tmpdig=0x0; | |
144 | pSDigitList[ilay].Sort(); | |
0ac80088 | 145 | Int_t module=999; |
1d9af2d5 | 146 | Int_t iNdigPart=0; |
147 | AliDebug(1,"starting loop over sdigits to create digits"); | |
148 | for(Int_t isdigentr=0; isdigentr<pSDigitList[ilay].GetEntries(); isdigentr++){ | |
149 | tmpdig = (AliITSDigitUpgrade*)(pSDigitList[ilay].At(isdigentr) ) ; | |
0ac80088 | 150 | if(tmpdig->GetPixId()==pixid && tmpdig->GetModule()==module) { |
1d9af2d5 | 151 | iNdigPart++; |
152 | if(iNdigPart<=3) { | |
2204e928 | 153 | tids[iNdigPart-1] = tmpdig->GetTrack(0); |
154 | elossID[iNdigPart-1] = tmpdig->GetSignal(); | |
1d9af2d5 | 155 | } |
156 | eloss+=tmpdig->GetSignal(); | |
157 | nele+=tmpdig->GetNelectrons(); | |
158 | continue; | |
159 | } | |
160 | AliITSDigitUpgrade digit(pixid,eloss); | |
0ac80088 | 161 | |
1d9af2d5 | 162 | digit.SetNelectrons(nele); |
163 | digit.SetLayer(ilay); | |
0ac80088 | 164 | digit.SetModule(module); |
1d9af2d5 | 165 | digit.SetTids(tids); |
166 | digit.SetSignalID(elossID); | |
167 | if(isdigentr!=0) new((*pLst[ilay])[iCnt[ilay]++]) AliITSDigitUpgrade(digit); | |
168 | eloss = tmpdig->GetSignal(); | |
169 | nele = tmpdig->GetNelectrons(); | |
170 | pixid=tmpdig->GetPixId(); | |
171 | tids[0]=tmpdig->GetTrack(0); | |
172 | tids[1]=tids[2]=-1; | |
173 | elossID[0]=tmpdig->GetSignal(); | |
0ac80088 | 174 | elossID[1]=elossID[2]=-1; |
175 | module=tmpdig->GetModule(); | |
1d9af2d5 | 176 | } |
177 | ||
178 | if(!tmpdig) AliDebug(1,"\n \n---------> tmpdig is null...break is expected ! \n"); | |
179 | else AliDebug(1," tmpdig exists \n"); | |
180 | ||
181 | if(tmpdig){ | |
182 | tmpdig->SetSignal(eloss); | |
183 | tmpdig->SetPixId(pixid); | |
184 | tmpdig->SetTids(tids); | |
185 | tmpdig->SetSignalID(elossID); | |
186 | tmpdig->SetNelectrons(nele); | |
187 | tmpdig->SetLayer(ilay); | |
0ac80088 | 188 | tmpdig->SetModule(module); |
1d9af2d5 | 189 | //cout<<" tmpdigit : pixid "<< pixid<< " tids "<< tids << " nele " << nele << " ilay "<<ilay<<endl; |
190 | new((*pLst[ilay])[iCnt[ilay]++]) AliITSDigitUpgrade(*tmpdig); | |
191 | } | |
192 | AliDebug(1,"ending loop over sdigits to create digits"); | |
193 | ||
194 | } | |
195 | AliDebug(1,"ending loop over layers"); | |
196 | ||
197 | } | |
198 |