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