]>
Commit | Line | Data |
---|---|---|
3c038d07 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
d37f8c34 | 17 | |
f94f8f87 | 18 | /* |
19 | Class for creating of the sumable digits and digits from MC data | |
20 | // | |
21 | The input : ideal signals (Hits->Diffusion->Attachment -Ideal signal) | |
22 | The output: raw digits | |
23 | ||
24 | Effect implemented: | |
25 | 1. Pad by pad gain map | |
26 | 2. Noise map | |
27 | 3. The dead channels identified - zerro noise for corresponding pads | |
28 | In this case the outpu equal zerro | |
29 | ||
30 | */ | |
31 | ||
32 | ||
33 | ||
34 | ||
d37f8c34 | 35 | #include <stdlib.h> |
3c038d07 | 36 | #include <TTree.h> |
37 | #include <TObjArray.h> | |
38 | #include <TFile.h> | |
39 | #include <TDirectory.h> | |
19364939 | 40 | #include <Riostream.h> |
f546a4b4 | 41 | #include <TParameter.h> |
3c038d07 | 42 | |
43 | #include "AliTPCDigitizer.h" | |
44 | ||
45 | #include "AliTPC.h" | |
46 | #include "AliTPCParam.h" | |
7a09f434 | 47 | #include "AliTPCParamSR.h" |
3c038d07 | 48 | #include "AliRun.h" |
c93255fe | 49 | #include "AliLoader.h" |
3c038d07 | 50 | #include "AliPDG.h" |
f21fc003 | 51 | #include "AliDigitizationInput.h" |
3c038d07 | 52 | #include "AliSimDigits.h" |
f77f13c8 | 53 | #include "AliLog.h" |
3c038d07 | 54 | |
13116aec | 55 | #include "AliTPCcalibDB.h" |
56 | #include "AliTPCCalPad.h" | |
57 | #include "AliTPCCalROC.h" | |
58 | ||
a11596ad | 59 | using std::cout; |
60 | using std::cerr; | |
61 | using std::endl; | |
3c038d07 | 62 | ClassImp(AliTPCDigitizer) |
63 | ||
64 | //___________________________________________ | |
179c6296 | 65 | AliTPCDigitizer::AliTPCDigitizer() :AliDigitizer(),fDebug(0) |
3c038d07 | 66 | { |
179c6296 | 67 | // |
3c038d07 | 68 | // Default ctor - don't use it |
179c6296 | 69 | // |
70 | ||
3c038d07 | 71 | } |
72 | ||
73 | //___________________________________________ | |
f21fc003 | 74 | AliTPCDigitizer::AliTPCDigitizer(AliDigitizationInput* digInput) |
75 | :AliDigitizer(digInput),fDebug(0) | |
3c038d07 | 76 | { |
179c6296 | 77 | // |
3c038d07 | 78 | // ctor which should be used |
179c6296 | 79 | // |
f21fc003 | 80 | AliDebug(2,"(AliDigitizationInput* digInput) was processed"); |
3c038d07 | 81 | } |
82 | ||
83 | //------------------------------------------------------------------------ | |
84 | AliTPCDigitizer::~AliTPCDigitizer() | |
85 | { | |
86 | // Destructor | |
87 | } | |
88 | ||
89 | ||
90 | ||
91 | //------------------------------------------------------------------------ | |
92 | Bool_t AliTPCDigitizer::Init() | |
93 | { | |
94 | // Initialization | |
95 | ||
96 | return kTRUE; | |
97 | } | |
98 | ||
99 | ||
100 | //------------------------------------------------------------------------ | |
f21fc003 | 101 | void AliTPCDigitizer::Digitize(Option_t* option) |
f648982e | 102 | { |
f21fc003 | 103 | DigitizeFast(option); |
f648982e | 104 | } |
105 | //------------------------------------------------------------------------ | |
f21fc003 | 106 | void AliTPCDigitizer::DigitizeFast(Option_t* option) |
3c038d07 | 107 | { |
108 | ||
109 | // merge input tree's with summable digits | |
110 | //output stored in TreeTPCD | |
7a09f434 | 111 | char s[100]; |
112 | char ss[100]; | |
3c038d07 | 113 | TString optionString = option; |
94bf739c | 114 | if (!strcmp(optionString.Data(),"deb")) { |
f21fc003 | 115 | cout<<"AliTPCDigitizer:::DigitizeFast called with option deb "<<endl; |
3c038d07 | 116 | fDebug = 3; |
117 | } | |
118 | //get detector and geometry | |
88cb7938 | 119 | |
120 | ||
121 | AliRunLoader *rl, *orl; | |
122 | AliLoader *gime, *ogime; | |
123 | ||
124 | if (gAlice == 0x0) | |
125 | { | |
f21fc003 | 126 | Warning("DigitizeFast","gAlice is NULL. Loading from input 0"); |
127 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0)); | |
88cb7938 | 128 | if (rl == 0x0) |
129 | { | |
f21fc003 | 130 | Error("DigitizeFast","Can not find Run Loader for input 0. Can not proceed."); |
88cb7938 | 131 | return; |
132 | } | |
133 | rl->LoadgAlice(); | |
134 | rl->GetAliRun(); | |
135 | } | |
3c038d07 | 136 | AliTPC *pTPC = (AliTPC *) gAlice->GetModule("TPC"); |
137 | AliTPCParam * param = pTPC->GetParam(); | |
7a09f434 | 138 | |
94e6c6f4 | 139 | //sprintf(s,param->GetTitle()); |
f21fc003 | 140 | snprintf(s,100,"%s",param->GetTitle()); |
94e6c6f4 | 141 | //sprintf(ss,"75x40_100x60"); |
142 | snprintf(ss,100,"75x40_100x60"); | |
7a09f434 | 143 | if(strcmp(s,ss)==0){ |
144 | printf("2 pad-length geom hits with 3 pad-lenght geom digits...\n"); | |
145 | delete param; | |
146 | param=new AliTPCParamSR(); | |
147 | } | |
148 | else{ | |
94e6c6f4 | 149 | //sprintf(ss,"75x40_100x60_150x60"); |
150 | snprintf(ss,100,"75x40_100x60_150x60"); | |
7a09f434 | 151 | if(strcmp(s,ss)!=0) { |
152 | printf("No TPC parameters found...\n"); | |
153 | exit(2); | |
154 | } | |
155 | } | |
156 | ||
f546a4b4 | 157 | pTPC->GenerNoise(500000); //create table with noise |
407ff276 | 158 | // |
f21fc003 | 159 | Int_t nInputs = fDigInput->GetNinputs(); |
407ff276 | 160 | Int_t * masks = new Int_t[nInputs]; |
161 | for (Int_t i=0; i<nInputs;i++) | |
f21fc003 | 162 | masks[i]= fDigInput->GetMask(i); |
407ff276 | 163 | Short_t **pdig= new Short_t*[nInputs]; //pointers to the expanded digits array |
f546a4b4 | 164 | Int_t **ptr= new Int_t*[nInputs]; //pointers to the expanded tracks array |
4df28b43 | 165 | Bool_t *active= new Bool_t[nInputs]; //flag for active input segments |
f546a4b4 | 166 | Char_t phname[100]; |
88cb7938 | 167 | |
3c038d07 | 168 | //create digits array for given sectors |
f648982e | 169 | // make indexes |
f546a4b4 | 170 | // |
171 | //create branch's in TPC treeD | |
f21fc003 | 172 | orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName()); |
f546a4b4 | 173 | ogime = orl->GetLoader("TPCLoader"); |
174 | TTree * tree = ogime->TreeD(); | |
175 | AliSimDigits * digrow = new AliSimDigits; | |
176 | ||
177 | if (tree == 0x0) | |
178 | { | |
179 | ogime->MakeTree("D"); | |
180 | tree = ogime->TreeD(); | |
181 | } | |
182 | tree->Branch("Segment","AliSimDigits",&digrow); | |
183 | // | |
407ff276 | 184 | AliSimDigits ** digarr = new AliSimDigits*[nInputs]; |
88cb7938 | 185 | for (Int_t i1=0;i1<nInputs; i1++) |
186 | { | |
187 | digarr[i1]=0; | |
188 | // intree[i1] | |
f21fc003 | 189 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1)); |
88cb7938 | 190 | gime = rl->GetLoader("TPCLoader"); |
191 | gime->LoadSDigits("read"); | |
192 | TTree * treear = gime->TreeS(); | |
193 | ||
194 | if (!treear) | |
195 | { | |
196 | cerr<<"AliTPCDigitizer: Input tree with SDigits not found in" | |
197 | <<" input "<< i1<<endl; | |
712976a6 | 198 | for (Int_t i2=0;i2<i1+1; i2++){ |
199 | ||
200 | if(digarr[i2]) delete digarr[i2]; | |
201 | } | |
202 | delete [] digarr; | |
203 | delete [] active; | |
204 | delete []masks; | |
205 | delete []pdig; | |
206 | delete []ptr; | |
88cb7938 | 207 | return; |
208 | } | |
f546a4b4 | 209 | |
94e6c6f4 | 210 | //sprintf(phname,"lhcphase%d",i1); |
211 | snprintf(phname,100,"lhcphase%d",i1); | |
f546a4b4 | 212 | TParameter<float> *ph = (TParameter<float>*)treear->GetUserInfo() |
213 | ->FindObject("lhcphase0"); | |
214 | if(!ph){ | |
215 | cerr<<"AliTPCDigitizer: LHC phase not found in" | |
216 | <<" input "<< i1<<endl; | |
712976a6 | 217 | for (Int_t i2=0;i2<i1+1; i2++){ |
218 | if(digarr[i2]) delete digarr[i2]; | |
219 | } | |
220 | delete [] digarr; | |
221 | delete [] active; | |
222 | delete []masks; | |
223 | delete []pdig; | |
224 | delete []ptr; | |
f546a4b4 | 225 | return; |
226 | } | |
227 | tree->GetUserInfo()->Add(new TParameter<float>(phname,ph->GetVal())); | |
228 | // | |
88cb7938 | 229 | if (treear->GetIndex()==0) |
230 | treear->BuildIndex("fSegmentID","fSegmentID"); | |
231 | treear->GetBranch("Segment")->SetAddress(&digarr[i1]); | |
12d8d654 | 232 | } |
88cb7938 | 233 | |
3c038d07 | 234 | |
88cb7938 | 235 | |
f546a4b4 | 236 | |
3c038d07 | 237 | // |
238 | ||
407ff276 | 239 | param->SetZeroSup(2); |
240 | ||
f648982e | 241 | Int_t zerosup = param->GetZeroSup(); |
5033a39a | 242 | AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor(); |
1ac191a6 | 243 | AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise(); |
f648982e | 244 | // |
3c038d07 | 245 | //Loop over segments of the TPC |
246 | ||
4df28b43 | 247 | for (Int_t segmentID=0; segmentID<param->GetNRowsTotal(); segmentID++) |
88cb7938 | 248 | { |
4df28b43 | 249 | Int_t sec, row; |
250 | if (!param->AdjustSectorRow(segmentID,sec,row)) | |
251 | { | |
252 | cerr<<"AliTPC warning: invalid segment ID ! "<<segmentID<<endl; | |
253 | continue; | |
254 | } | |
13116aec | 255 | AliTPCCalROC * gainROC = gainTPC->GetCalROC(sec); // pad gains per given sector |
1ac191a6 | 256 | AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sec); // noise per given sector |
4df28b43 | 257 | digrow->SetID(segmentID); |
258 | ||
259 | Int_t nrows = 0; | |
260 | Int_t ncols = 0; | |
261 | ||
262 | Bool_t digitize = kFALSE; | |
263 | for (Int_t i=0;i<nInputs; i++) | |
88cb7938 | 264 | { |
265 | ||
f21fc003 | 266 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i)); |
88cb7938 | 267 | gime = rl->GetLoader("TPCLoader"); |
268 | ||
4df28b43 | 269 | if (gime->TreeS()->GetEntryWithIndex(segmentID,segmentID) >= 0) { |
270 | digarr[i]->ExpandBuffer(); | |
271 | digarr[i]->ExpandTrackBuffer(); | |
272 | nrows = digarr[i]->GetNRows(); | |
273 | ncols = digarr[i]->GetNCols(); | |
274 | active[i] = kTRUE; | |
f21fc003 | 275 | if (!GetRegionOfInterest() || (i == 0)) digitize = kTRUE; |
4df28b43 | 276 | } else { |
277 | active[i] = kFALSE; | |
278 | } | |
f21fc003 | 279 | if (GetRegionOfInterest() && !digitize) break; |
88cb7938 | 280 | } |
4df28b43 | 281 | if (!digitize) continue; |
3c038d07 | 282 | |
3c038d07 | 283 | digrow->Allocate(nrows,ncols); |
284 | digrow->AllocateTrack(3); | |
285 | ||
407ff276 | 286 | Float_t q=0; |
287 | Int_t label[1000]; //stack for 300 events | |
288 | Int_t labptr = 0; | |
289 | ||
f648982e | 290 | Int_t nElems = nrows*ncols; |
291 | ||
88cb7938 | 292 | for (Int_t i=0;i<nInputs; i++) |
4df28b43 | 293 | if (active[i]) { |
88cb7938 | 294 | pdig[i] = digarr[i]->GetDigits(); |
295 | ptr[i] = digarr[i]->GetTracks(); | |
4df28b43 | 296 | } |
88cb7938 | 297 | |
407ff276 | 298 | Short_t *pdig1= digrow->GetDigits(); |
299 | Int_t *ptr1= digrow->GetTracks() ; | |
300 | ||
f648982e | 301 | |
407ff276 | 302 | |
88cb7938 | 303 | for (Int_t elem=0;elem<nElems; elem++) |
304 | { | |
305 | ||
306 | q=0; | |
307 | labptr=0; | |
308 | // looop over digits | |
4df28b43 | 309 | for (Int_t i=0;i<nInputs; i++) if (active[i]) |
88cb7938 | 310 | { |
311 | // q += digarr[i]->GetDigitFast(rows,col); | |
312 | q += *(pdig[i]); | |
313 | ||
314 | for (Int_t tr=0;tr<3;tr++) | |
315 | { | |
316 | // Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr); | |
317 | Int_t lab = ptr[i][tr*nElems]; | |
318 | if ( (lab > 1) && *(pdig[i])>zerosup) | |
319 | { | |
320 | label[labptr]=lab+masks[i]; | |
321 | labptr++; | |
322 | } | |
323 | } | |
324 | pdig[i]++; | |
325 | ptr[i]++; | |
326 | } | |
327 | q/=16.; //conversion factor | |
13116aec | 328 | Float_t gain = gainROC->GetValue(row,elem/nrows); // get gain for given - pad-row pad |
ebf9a79e | 329 | //if (gain<0.5){ |
330 | //printf("problem\n"); | |
331 | //} | |
13116aec | 332 | q*= gain; |
1ac191a6 | 333 | Float_t noisePad = noiseROC->GetValue(row,elem/nrows); |
88cb7938 | 334 | // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac()); |
335 | Float_t noise = pTPC->GetNoise(); | |
1ac191a6 | 336 | q+=noise*noisePad; |
3c038d07 | 337 | q=TMath::Nint(q); |
88cb7938 | 338 | if (q > zerosup) |
339 | { | |
e93a083a | 340 | if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1); |
88cb7938 | 341 | //digrow->SetDigitFast((Short_t)q,rows,col); |
342 | *pdig1 =Short_t(q); | |
343 | for (Int_t tr=0;tr<3;tr++) | |
344 | { | |
345 | if (tr<labptr) | |
346 | ptr1[tr*nElems] = label[tr]; | |
347 | } | |
348 | } | |
349 | pdig1++; | |
350 | ptr1++; | |
351 | } | |
58c45a5e | 352 | // |
353 | // glitch filter | |
354 | // | |
355 | digrow->GlitchFilter(); | |
356 | // | |
3c038d07 | 357 | digrow->CompresBuffer(1,zerosup); |
358 | digrow->CompresTrackBuffer(1); | |
359 | tree->Fill(); | |
360 | if (fDebug>0) cerr<<sec<<"\t"<<row<<"\n"; | |
4df28b43 | 361 | } //for (Int_t n=0; n<param->GetNRowsTotal(); n++) |
88cb7938 | 362 | |
363 | ||
f21fc003 | 364 | orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName()); |
88cb7938 | 365 | ogime = orl->GetLoader("TPCLoader"); |
366 | ogime->WriteDigits("OVERWRITE"); | |
367 | ||
f21fc003 | 368 | //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite); |
88cb7938 | 369 | |
3c038d07 | 370 | delete digrow; |
407ff276 | 371 | for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1]; |
372 | delete []masks; | |
4df28b43 | 373 | delete []pdig; |
374 | delete []ptr; | |
375 | delete []active; | |
376 | delete []digarr; | |
3c038d07 | 377 | } |
378 | ||
f648982e | 379 | |
380 | ||
381 | //------------------------------------------------------------------------ | |
f21fc003 | 382 | void AliTPCDigitizer::DigitizeSave(Option_t* option) |
f648982e | 383 | { |
384 | ||
385 | // merge input tree's with summable digits | |
386 | //output stored in TreeTPCD | |
387 | ||
388 | TString optionString = option; | |
94bf739c | 389 | if (!strcmp(optionString.Data(),"deb")) { |
f21fc003 | 390 | cout<<"AliTPCDigitizer::Digitize: called with option deb "<<endl; |
f648982e | 391 | fDebug = 3; |
392 | } | |
393 | //get detector and geometry | |
88cb7938 | 394 | AliRunLoader *rl, *orl; |
395 | AliLoader *gime, *ogime; | |
396 | ||
397 | ||
f21fc003 | 398 | orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName()); |
88cb7938 | 399 | ogime = orl->GetLoader("TPCLoader"); |
400 | ||
f21fc003 | 401 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0)); |
097d753a | 402 | //gime = rl->GetLoader("TPCLoader"); |
403 | rl->GetLoader("TPCLoader"); | |
88cb7938 | 404 | rl->LoadgAlice(); |
405 | AliRun* alirun = rl->GetAliRun(); | |
406 | ||
407 | AliTPC *pTPC = (AliTPC *) alirun->GetModule("TPC"); | |
f648982e | 408 | AliTPCParam * param = pTPC->GetParam(); |
409 | pTPC->GenerNoise(500000); //create teble with noise | |
410 | printf("noise %f \n", param->GetNoise()*param->GetNoiseNormFac()); | |
411 | // | |
f21fc003 | 412 | Int_t nInputs = fDigInput->GetNinputs(); |
097d753a | 413 | // stupid protection... |
414 | if (nInputs <= 0) return; | |
415 | // | |
f648982e | 416 | Int_t * masks = new Int_t[nInputs]; |
417 | for (Int_t i=0; i<nInputs;i++) | |
f21fc003 | 418 | masks[i]= fDigInput->GetMask(i); |
f648982e | 419 | |
606d6545 | 420 | AliSimDigits ** digarr = new AliSimDigits*[nInputs]; |
421 | for(Int_t ii=0;ii<nInputs;ii++) digarr[ii]=0; | |
422 | ||
88cb7938 | 423 | for (Int_t i1=0;i1<nInputs; i1++) |
424 | { | |
606d6545 | 425 | //digarr[i1]=0; |
f648982e | 426 | // intree[i1] |
f21fc003 | 427 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1)); |
88cb7938 | 428 | gime = rl->GetLoader("TPCLoader"); |
429 | ||
430 | TTree * treear = gime->TreeS(); | |
de0e19ab | 431 | // |
f648982e | 432 | if (!treear) { |
de0e19ab | 433 | cerr<<" TPC - not existing input = \n"<<i1<<" "; |
434 | delete [] masks; | |
435 | for(Int_t i=0; i<nInputs; i++) delete digarr[i]; | |
436 | delete [] digarr; | |
437 | return; | |
f648982e | 438 | } |
de0e19ab | 439 | // |
440 | TBranch * br = treear->GetBranch("fSegmentID"); | |
441 | if (br) br->GetFile()->cd(); | |
f648982e | 442 | treear->GetBranch("Segment")->SetAddress(&digarr[i1]); |
de0e19ab | 443 | } |
88cb7938 | 444 | |
f21fc003 | 445 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0)); |
88cb7938 | 446 | gime = rl->GetLoader("TPCLoader"); |
447 | Stat_t nentries = gime->TreeS()->GetEntries(); | |
f648982e | 448 | |
449 | ||
450 | //create branch's in TPC treeD | |
451 | AliSimDigits * digrow = new AliSimDigits; | |
88cb7938 | 452 | TTree * tree = ogime->TreeD(); |
453 | ||
f648982e | 454 | tree->Branch("Segment","AliSimDigits",&digrow); |
f648982e | 455 | param->SetZeroSup(2); |
456 | ||
457 | Int_t zerosup = param->GetZeroSup(); | |
458 | //Loop over segments of the TPC | |
459 | ||
5033a39a | 460 | AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor(); |
1ac191a6 | 461 | AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise(); |
f648982e | 462 | for (Int_t n=0; n<nentries; n++) { |
f21fc003 | 463 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0)); |
88cb7938 | 464 | gime = rl->GetLoader("TPCLoader"); |
465 | gime->TreeS()->GetEvent(n); | |
466 | ||
f648982e | 467 | digarr[0]->ExpandBuffer(); |
468 | digarr[0]->ExpandTrackBuffer(); | |
13116aec | 469 | |
470 | ||
f648982e | 471 | for (Int_t i=1;i<nInputs; i++){ |
f21fc003 | 472 | // fDigInput->GetInputTreeTPCS(i)->GetEntryWithIndex(digarr[0]->GetID(),digarr[0]->GetID()); |
473 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i)); | |
88cb7938 | 474 | gime = rl->GetLoader("TPCLoader"); |
475 | gime->TreeS()->GetEntryWithIndex(digarr[0]->GetID(),digarr[0]->GetID()); | |
f648982e | 476 | digarr[i]->ExpandBuffer(); |
477 | digarr[i]->ExpandTrackBuffer(); | |
478 | if ((digarr[0]->GetID()-digarr[i]->GetID())>0) | |
88cb7938 | 479 | printf("problem\n"); |
f648982e | 480 | |
481 | } | |
482 | ||
483 | Int_t sec, row; | |
484 | if (!param->AdjustSectorRow(digarr[0]->GetID(),sec,row)) { | |
485 | cerr<<"AliTPC warning: invalid segment ID ! "<<digarr[0]->GetID()<<endl; | |
486 | continue; | |
487 | } | |
488 | ||
13116aec | 489 | AliTPCCalROC * gainROC = gainTPC->GetCalROC(sec); // pad gains per given sector |
1ac191a6 | 490 | AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sec); // noise per given sector |
f648982e | 491 | digrow->SetID(digarr[0]->GetID()); |
492 | ||
493 | Int_t nrows = digarr[0]->GetNRows(); | |
494 | Int_t ncols = digarr[0]->GetNCols(); | |
495 | digrow->Allocate(nrows,ncols); | |
496 | digrow->AllocateTrack(3); | |
497 | ||
498 | Float_t q=0; | |
499 | Int_t label[1000]; //stack for 300 events | |
500 | Int_t labptr = 0; | |
501 | ||
502 | ||
503 | ||
504 | for (Int_t rows=0;rows<nrows; rows++){ | |
505 | for (Int_t col=0;col<ncols; col++){ | |
506 | ||
88cb7938 | 507 | q=0; |
508 | labptr=0; | |
509 | // looop over digits | |
f648982e | 510 | for (Int_t i=0;i<nInputs; i++){ |
88cb7938 | 511 | q += digarr[i]->GetDigitFast(rows,col); |
f648982e | 512 | //q += *(pdig[i]); |
88cb7938 | 513 | |
f648982e | 514 | for (Int_t tr=0;tr<3;tr++) { |
88cb7938 | 515 | Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr); |
516 | //Int_t lab = ptr[i][tr*nElems]; | |
f648982e | 517 | if ( (lab > 1) ) { |
518 | label[labptr]=lab+masks[i]; | |
519 | labptr++; | |
88cb7938 | 520 | } |
f648982e | 521 | } |
88cb7938 | 522 | // pdig[i]++; |
523 | //ptr[i]++; | |
524 | ||
f648982e | 525 | } |
88cb7938 | 526 | q/=16.; //conversion factor |
527 | // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac()); | |
13116aec | 528 | Float_t gain = gainROC->GetValue(row,col); |
529 | q*= gain; | |
1ac191a6 | 530 | Float_t noisePad = noiseROC->GetValue(row, col); |
531 | ||
88cb7938 | 532 | Float_t noise = pTPC->GetNoise(); |
1ac191a6 | 533 | q+=noise*noisePad; |
633fa37f | 534 | |
f648982e | 535 | q=TMath::Nint(q); |
536 | if (q > zerosup){ | |
88cb7938 | 537 | |
e93a083a | 538 | if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1); |
88cb7938 | 539 | digrow->SetDigitFast((Short_t)q,rows,col); |
540 | // *pdig1 =Short_t(q); | |
541 | for (Int_t tr=0;tr<3;tr++){ | |
542 | if (tr<labptr) | |
543 | ((AliSimDigits*)digrow)->SetTrackIDFast(label[tr],rows,col,tr); | |
544 | //ptr1[tr*nElems] = label[tr]; | |
545 | //else | |
546 | // ((AliSimDigits*)digrow)->SetTrackIDFast(-1,rows,col,tr); | |
547 | // ptr1[tr*nElems] = 1; | |
548 | } | |
549 | } | |
550 | //pdig1++; | |
551 | //ptr1++; | |
f648982e | 552 | } |
553 | } | |
554 | ||
555 | digrow->CompresBuffer(1,zerosup); | |
556 | digrow->CompresTrackBuffer(1); | |
557 | tree->Fill(); | |
558 | if (fDebug>0) cerr<<sec<<"\t"<<row<<"\n"; | |
559 | } | |
f21fc003 | 560 | // printf("end TPC merging - end -Tree %s\t%p\n",fDigInput->GetInputTreeH(0)->GetName(),fDigInput->GetInputTreeH(0)->GetListOfBranches()->At(3)); |
561 | //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite); | |
88cb7938 | 562 | ogime->WriteDigits("OVERWRITE"); |
563 | ||
564 | for (Int_t i=1;i<nInputs; i++) | |
565 | { | |
f21fc003 | 566 | rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i)); |
88cb7938 | 567 | gime = rl->GetLoader("TPCLoader"); |
568 | gime->UnloadSDigits(); | |
569 | } | |
570 | ogime->UnloadDigits(); | |
571 | ||
f648982e | 572 | delete digrow; |
573 | for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1]; | |
4ce766eb | 574 | delete [] masks; |
575 | delete [] digarr; | |
f648982e | 576 | } |