1 /**************************************************************************
2 * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 Class for creating of the sumable digits and digits from MC data
21 The input : ideal signals (Hits->Diffusion->Attachment -Ideal signal)
22 The output: "raw digits"
25 1. Pad by pad gain map
27 3. The dead channels identified - zerro noise for corresponding pads
28 In this case the outpu equal zerro
37 #include <TObjArray.h>
39 #include <TDirectory.h>
40 #include <Riostream.h>
41 #include <TParameter.h>
43 #include "AliTPCDigitizer.h"
46 #include "AliTPCParam.h"
47 #include "AliTPCParamSR.h"
49 #include "AliLoader.h"
51 #include "AliDigitizationInput.h"
52 #include "AliSimDigits.h"
55 #include "AliTPCcalibDB.h"
56 #include "AliTPCCalPad.h"
57 #include "AliTPCCalROC.h"
58 #include "TTreeStream.h"
59 #include "AliTPCReconstructor.h"
64 ClassImp(AliTPCDigitizer)
66 //___________________________________________
67 AliTPCDigitizer::AliTPCDigitizer() :AliDigitizer(),fDebug(0), fDebugStreamer(0)
70 // Default ctor - don't use it
75 //___________________________________________
76 AliTPCDigitizer::AliTPCDigitizer(AliDigitizationInput* digInput)
77 :AliDigitizer(digInput),fDebug(0), fDebugStreamer(0)
80 // ctor which should be used
82 AliDebug(2,"(AliDigitizationInput* digInput) was processed");
83 if (AliTPCReconstructor::StreamLevel()>0) fDebugStreamer = new TTreeSRedirector("TPCDigitDebug.root");
87 //------------------------------------------------------------------------
88 AliTPCDigitizer::~AliTPCDigitizer()
91 if (fDebugStreamer) delete fDebugStreamer;
96 //------------------------------------------------------------------------
97 Bool_t AliTPCDigitizer::Init()
105 //------------------------------------------------------------------------
106 void AliTPCDigitizer::Digitize(Option_t* option)
108 DigitizeFast(option);
110 //------------------------------------------------------------------------
111 void AliTPCDigitizer::DigitizeFast(Option_t* option)
114 // merge input tree's with summable digits
115 //output stored in TreeTPCD
118 TString optionString = option;
119 if (!strcmp(optionString.Data(),"deb")) {
120 cout<<"AliTPCDigitizer:::DigitizeFast called with option deb "<<endl;
123 //get detector and geometry
126 AliRunLoader *rl, *orl;
127 AliLoader *gime, *ogime;
131 Warning("DigitizeFast","gAlice is NULL. Loading from input 0");
132 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
135 Error("DigitizeFast","Can not find Run Loader for input 0. Can not proceed.");
141 AliTPC *pTPC = (AliTPC *) gAlice->GetModule("TPC");
142 AliTPCParam * param = pTPC->GetParam();
144 //sprintf(s,param->GetTitle());
145 snprintf(s,100,"%s",param->GetTitle());
146 //sprintf(ss,"75x40_100x60");
147 snprintf(ss,100,"75x40_100x60");
149 printf("2 pad-length geom hits with 3 pad-lenght geom digits...\n");
151 param=new AliTPCParamSR();
154 //sprintf(ss,"75x40_100x60_150x60");
155 snprintf(ss,100,"75x40_100x60_150x60");
156 if(strcmp(s,ss)!=0) {
157 printf("No TPC parameters found...\n");
162 pTPC->GenerNoise(500000); //create table with noise
164 Int_t nInputs = fDigInput->GetNinputs();
165 Int_t * masks = new Int_t[nInputs];
166 for (Int_t i=0; i<nInputs;i++)
167 masks[i]= fDigInput->GetMask(i);
168 Short_t **pdig= new Short_t*[nInputs]; //pointers to the expanded digits array
169 Int_t **ptr= new Int_t*[nInputs]; //pointers to the expanded tracks array
170 Bool_t *active= new Bool_t[nInputs]; //flag for active input segments
173 //create digits array for given sectors
176 //create branch's in TPC treeD
177 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
178 ogime = orl->GetLoader("TPCLoader");
179 TTree * tree = ogime->TreeD();
180 AliSimDigits * digrow = new AliSimDigits;
184 ogime->MakeTree("D");
185 tree = ogime->TreeD();
187 tree->Branch("Segment","AliSimDigits",&digrow);
189 AliSimDigits ** digarr = new AliSimDigits*[nInputs];
190 for (Int_t i1=0;i1<nInputs; i1++)
194 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1));
195 gime = rl->GetLoader("TPCLoader");
196 gime->LoadSDigits("read");
197 TTree * treear = gime->TreeS();
201 cerr<<"AliTPCDigitizer: Input tree with SDigits not found in"
202 <<" input "<< i1<<endl;
203 for (Int_t i2=0;i2<i1+1; i2++){
205 if(digarr[i2]) delete digarr[i2];
215 //sprintf(phname,"lhcphase%d",i1);
216 snprintf(phname,100,"lhcphase%d",i1);
217 TParameter<float> *ph = (TParameter<float>*)treear->GetUserInfo()
218 ->FindObject("lhcphase0");
220 cerr<<"AliTPCDigitizer: LHC phase not found in"
221 <<" input "<< i1<<endl;
222 for (Int_t i2=0;i2<i1+1; i2++){
223 if(digarr[i2]) delete digarr[i2];
232 tree->GetUserInfo()->Add(new TParameter<float>(phname,ph->GetVal()));
234 if (treear->GetIndex()==0)
235 treear->BuildIndex("fSegmentID","fSegmentID");
236 treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
244 param->SetZeroSup(2);
246 Int_t zerosup = param->GetZeroSup();
247 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
248 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
250 //Loop over segments of the TPC
252 for (Int_t segmentID=0; segmentID<param->GetNRowsTotal(); segmentID++)
254 Int_t sector, padRow;
255 if (!param->AdjustSectorRow(segmentID,sector,padRow))
257 cerr<<"AliTPC warning: invalid segment ID ! "<<segmentID<<endl;
260 AliTPCCalROC * gainROC = gainTPC->GetCalROC(sector); // pad gains per given sector
261 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sector); // noise per given sector
262 digrow->SetID(segmentID);
267 Bool_t digitize = kFALSE;
268 for (Int_t i=0;i<nInputs; i++)
271 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
272 gime = rl->GetLoader("TPCLoader");
274 if (gime->TreeS()->GetEntryWithIndex(segmentID,segmentID) >= 0) {
275 digarr[i]->ExpandBuffer();
276 digarr[i]->ExpandTrackBuffer();
277 nTimeBins = digarr[i]->GetNRows();
278 nPads = digarr[i]->GetNCols();
280 if (!GetRegionOfInterest() || (i == 0)) digitize = kTRUE;
284 if (GetRegionOfInterest() && !digitize) break;
286 if (!digitize) continue;
288 digrow->Allocate(nTimeBins,nPads);
289 digrow->AllocateTrack(3);
292 Int_t label[1000]; //stack for 300 events
295 Int_t nElems = nTimeBins*nPads;
297 for (Int_t i=0;i<nInputs; i++)
299 pdig[i] = digarr[i]->GetDigits();
300 ptr[i] = digarr[i]->GetTracks();
303 Short_t *pdig1= digrow->GetDigits();
304 Int_t *ptr1= digrow->GetTracks() ;
308 for (Int_t elem=0;elem<nElems; elem++)
314 for (Int_t i=0;i<nInputs; i++) if (active[i])
316 // q += digarr[i]->GetDigitFast(rows,col);
319 for (Int_t tr=0;tr<3;tr++)
321 // Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr);
322 Int_t lab = ptr[i][tr*nElems];
323 if ( (lab > 1) && *(pdig[i])>zerosup)
325 label[labptr]=lab+masks[i];
332 q/=16.; //conversion factor
333 Float_t gain = gainROC->GetValue(padRow,elem/nTimeBins); // get gain for given - pad-row pad
335 //printf("problem\n");
338 Float_t noisePad = noiseROC->GetValue(padRow,elem/nTimeBins);
339 // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac());
340 Float_t noise = pTPC->GetNoise();
345 if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1);
346 //digrow->SetDigitFast((Short_t)q,rows,col);
348 for (Int_t tr=0;tr<3;tr++)
351 ptr1[tr*nElems] = label[tr];
360 digrow->GlitchFilter();
362 digrow->CompresBuffer(1,zerosup);
363 digrow->CompresTrackBuffer(1);
365 if (fDebug>0) cerr<<sector<<"\t"<<padRow<<"\n";
366 } //for (Int_t n=0; n<param->GetNRowsTotal(); n++)
369 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
370 ogime = orl->GetLoader("TPCLoader");
371 ogime->WriteDigits("OVERWRITE");
373 //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite);
376 for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];
386 //------------------------------------------------------------------------
387 void AliTPCDigitizer::DigitizeSave(Option_t* option)
390 // Merge input tree's with summable digits
391 // Output digits stored in TreeTPCD
393 // Not active for long time.
394 // Before adding modification (for ion tail calucation and for the crorsstalk) it should be
395 // checked one by one with currenlty used AliTPCDigitizer::DigitizeFast
397 TString optionString = option;
398 if (!strcmp(optionString.Data(),"deb")) {
399 cout<<"AliTPCDigitizer::Digitize: called with option deb "<<endl;
402 //get detector and geometry
403 AliRunLoader *rl, *orl;
404 AliLoader *gime, *ogime;
407 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
408 ogime = orl->GetLoader("TPCLoader");
410 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
411 //gime = rl->GetLoader("TPCLoader");
412 rl->GetLoader("TPCLoader");
414 AliRun* alirun = rl->GetAliRun();
416 AliTPC *pTPC = (AliTPC *) alirun->GetModule("TPC");
417 AliTPCParam * param = pTPC->GetParam();
418 pTPC->GenerNoise(500000); //create teble with noise
419 printf("noise %f \n", param->GetNoise()*param->GetNoiseNormFac());
421 Int_t nInputs = fDigInput->GetNinputs();
422 // stupid protection...
423 if (nInputs <= 0) return;
425 Int_t * masks = new Int_t[nInputs];
426 for (Int_t i=0; i<nInputs;i++)
427 masks[i]= fDigInput->GetMask(i);
429 AliSimDigits ** digarr = new AliSimDigits*[nInputs];
430 for(Int_t ii=0;ii<nInputs;ii++) digarr[ii]=0;
432 for (Int_t i1=0;i1<nInputs; i1++)
436 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1));
437 gime = rl->GetLoader("TPCLoader");
439 TTree * treear = gime->TreeS();
442 cerr<<" TPC - not existing input = \n"<<i1<<" ";
444 for(Int_t i=0; i<nInputs; i++) delete digarr[i];
449 TBranch * br = treear->GetBranch("fSegmentID");
450 if (br) br->GetFile()->cd();
451 treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
454 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
455 gime = rl->GetLoader("TPCLoader");
456 Stat_t nentries = gime->TreeS()->GetEntries();
459 //create branch's in TPC treeD
460 AliSimDigits * digrow = new AliSimDigits;
461 TTree * tree = ogime->TreeD();
463 tree->Branch("Segment","AliSimDigits",&digrow);
464 param->SetZeroSup(2);
466 Int_t zerosup = param->GetZeroSup();
467 //Loop over segments of the TPC
469 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
470 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
471 for (Int_t n=0; n<nentries; n++) {
472 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
473 gime = rl->GetLoader("TPCLoader");
474 gime->TreeS()->GetEvent(n);
476 digarr[0]->ExpandBuffer();
477 digarr[0]->ExpandTrackBuffer();
480 for (Int_t i=1;i<nInputs; i++){
481 // fDigInput->GetInputTreeTPCS(i)->GetEntryWithIndex(digarr[0]->GetID(),digarr[0]->GetID());
482 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
483 gime = rl->GetLoader("TPCLoader");
484 gime->TreeS()->GetEntryWithIndex(digarr[0]->GetID(),digarr[0]->GetID());
485 digarr[i]->ExpandBuffer();
486 digarr[i]->ExpandTrackBuffer();
487 if ((digarr[0]->GetID()-digarr[i]->GetID())>0)
492 Int_t sector, padRow;
493 if (!param->AdjustSectorRow(digarr[0]->GetID(),sector,padRow)) {
494 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr[0]->GetID()<<endl;
498 AliTPCCalROC * gainROC = gainTPC->GetCalROC(sector); // pad gains per given sector
499 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sector); // noise per given sector
500 digrow->SetID(digarr[0]->GetID());
502 Int_t nTimeBins = digarr[0]->GetNRows();
503 Int_t nPads = digarr[0]->GetNCols();
504 digrow->Allocate(nTimeBins,nPads);
505 digrow->AllocateTrack(3);
508 Int_t label[1000]; //stack for 300 events
513 for (Int_t iTimeBin=0;iTimeBin<nTimeBins; iTimeBin++){ // iTimeBin
514 for (Int_t iPad=0;iPad<nPads; iPad++){ // pad
519 for (Int_t i=0;i<nInputs; i++){
520 q += digarr[i]->GetDigitFast(iTimeBin,iPad);
523 for (Int_t tr=0;tr<3;tr++) {
524 Int_t lab = digarr[i]->GetTrackIDFast(iTimeBin,iPad,tr);
525 //Int_t lab = ptr[i][tr*nElems];
527 label[labptr]=lab+masks[i];
535 q/=16.; //conversion factor
536 // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac());
537 Float_t gain = gainROC->GetValue(padRow,iPad);
539 Float_t noisePad = noiseROC->GetValue(padRow, iPad);
541 Float_t noise = pTPC->GetNoise();
544 // here we can get digits from past and add signal
547 //for (Int_t jTimeBin=0; jTimeBin<iTimeBin; jTimeBin++)
554 if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1);
555 digrow->SetDigitFast((Short_t)q,iTimeBin,iPad);
556 // *pdig1 =Short_t(q);
557 for (Int_t tr=0;tr<3;tr++){
559 ((AliSimDigits*)digrow)->SetTrackIDFast(label[tr],iTimeBin,iPad,tr);
560 //ptr1[tr*nElems] = label[tr];
562 // ((AliSimDigits*)digrow)->SetTrackIDFast(-1,iTimeBin,iPad,tr);
563 // ptr1[tr*nElems] = 1;
571 digrow->CompresBuffer(1,zerosup);
572 digrow->CompresTrackBuffer(1);
574 if (fDebug>0) cerr<<sector<<"\t"<<padRow<<"\n";
576 // printf("end TPC merging - end -Tree %s\t%p\n",fDigInput->GetInputTreeH(0)->GetName(),fDigInput->GetInputTreeH(0)->GetListOfBranches()->At(3));
577 //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite);
578 ogime->WriteDigits("OVERWRITE");
580 for (Int_t i=1;i<nInputs; i++)
582 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
583 gime = rl->GetLoader("TPCLoader");
584 gime->UnloadSDigits();
586 ogime->UnloadDigits();
589 for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];
596 //------------------------------------------------------------------------
597 void AliTPCDigitizer::DigitizeWithTailAndCrossTalk(Option_t* option)
599 // Modified version of the digitization function
600 // Modification: adding the ion tail and crosstalk:
602 // pcstream used in order to visually inspect data
605 // Crosstalk simulation:
606 // 1.) Calculate per time bin mean charge (per pad) within anode wire segment
607 // 2.) Subsract for the clusters at given time bin fraction of (mean charge) normalized by add hoc constant
608 // AliTPCRecoParam::GetCrosstalkCorrection() (0 if not crosstalk, 1 if ideal crosstalk)
609 // for simplicity we are assuming that wire segents are related to pad-rows
610 // Wire segmentationn is obtatined from the
611 // AliTPCParam::GetWireSegment(Int_t sector, Int_t row); // to be implemented
612 // AliTPCParam::GetNPadsPerSegment(Int_t segmentID); // to be implemented
614 // Ion tail simulation:
615 // 1.) Needs signal from pad+-1, taking signal from history
616 // merge input tree's with summable digits
617 // output stored in TreeTPCD
621 TString optionString = option;
622 if (!strcmp(optionString.Data(),"deb")) {
623 cout<<"AliTPCDigitizer:::DigitizeFast called with option deb "<<endl;
626 //get detector and geometry
629 AliRunLoader *rl, *orl;
630 AliLoader *gime, *ogime;
634 Warning("DigitizeFast","gAlice is NULL. Loading from input 0");
635 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
638 Error("DigitizeFast","Can not find Run Loader for input 0. Can not proceed.");
644 AliTPC *pTPC = (AliTPC *) gAlice->GetModule("TPC");
645 AliTPCParam * param = pTPC->GetParam();
647 //sprintf(s,param->GetTitle());
648 snprintf(s,100,"%s",param->GetTitle());
649 //sprintf(ss,"75x40_100x60");
650 snprintf(ss,100,"75x40_100x60");
652 printf("2 pad-length geom hits with 3 pad-lenght geom digits...\n");
654 param=new AliTPCParamSR();
657 //sprintf(ss,"75x40_100x60_150x60");
658 snprintf(ss,100,"75x40_100x60_150x60");
659 if(strcmp(s,ss)!=0) {
660 printf("No TPC parameters found...\n");
665 pTPC->GenerNoise(500000); //create table with noise
667 Int_t nInputs = fDigInput->GetNinputs();
668 Int_t * masks = new Int_t[nInputs];
669 for (Int_t i=0; i<nInputs;i++)
670 masks[i]= fDigInput->GetMask(i);
671 Short_t **pdig= new Short_t*[nInputs]; //pointers to the expanded digits array
672 Int_t **ptr= new Int_t*[nInputs]; //pointers to the expanded tracks array
673 Bool_t *active= new Bool_t[nInputs]; //flag for active input segments
676 //create digits array for given sectors
679 //create branch's in TPC treeD
680 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
681 ogime = orl->GetLoader("TPCLoader");
682 TTree * tree = ogime->TreeD();
683 AliSimDigits * digrow = new AliSimDigits;
687 ogime->MakeTree("D");
688 tree = ogime->TreeD();
690 tree->Branch("Segment","AliSimDigits",&digrow);
692 AliSimDigits ** digarr = new AliSimDigits*[nInputs];
693 for (Int_t i1=0;i1<nInputs; i1++)
697 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1));
698 gime = rl->GetLoader("TPCLoader");
699 gime->LoadSDigits("read");
700 TTree * treear = gime->TreeS();
704 cerr<<"AliTPCDigitizer: Input tree with SDigits not found in"
705 <<" input "<< i1<<endl;
706 for (Int_t i2=0;i2<i1+1; i2++){
708 if(digarr[i2]) delete digarr[i2];
718 //sprintf(phname,"lhcphase%d",i1);
719 snprintf(phname,100,"lhcphase%d",i1);
720 TParameter<float> *ph = (TParameter<float>*)treear->GetUserInfo()
721 ->FindObject("lhcphase0");
723 cerr<<"AliTPCDigitizer: LHC phase not found in"
724 <<" input "<< i1<<endl;
725 for (Int_t i2=0;i2<i1+1; i2++){
726 if(digarr[i2]) delete digarr[i2];
735 tree->GetUserInfo()->Add(new TParameter<float>(phname,ph->GetVal()));
737 if (treear->GetIndex()==0)
738 treear->BuildIndex("fSegmentID","fSegmentID");
739 treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
747 param->SetZeroSup(2);
748 Int_t zerosup = param->GetZeroSup();
749 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
750 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
752 // 1.) Make first loop to calculate mean amplitude per pad per segment
754 // TObjArray * crossTalkSignalArray(nsectors);
755 // TMatrixD crossTalkSignal(nWireSegments, timeBin); // structure with mean signal per pad to be filled in first loop
758 //2.) Loop over segments (padrows) of the TPC
760 for (Int_t segmentID=0; segmentID<param->GetNRowsTotal(); segmentID++)
762 Int_t sector, padRow;
763 if (!param->AdjustSectorRow(segmentID,sector,padRow))
765 cerr<<"AliTPC warning: invalid segment ID ! "<<segmentID<<endl;
768 AliTPCCalROC * gainROC = gainTPC->GetCalROC(sector); // pad gains per given sector
769 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sector); // noise per given sector
770 digrow->SetID(segmentID);
775 Bool_t digitize = kFALSE;
776 for (Int_t i=0;i<nInputs; i++)
779 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
780 gime = rl->GetLoader("TPCLoader");
782 if (gime->TreeS()->GetEntryWithIndex(segmentID,segmentID) >= 0) {
783 digarr[i]->ExpandBuffer();
784 digarr[i]->ExpandTrackBuffer();
785 nTimeBins = digarr[i]->GetNRows();
786 nPads = digarr[i]->GetNCols();
788 if (!GetRegionOfInterest() || (i == 0)) digitize = kTRUE;
792 if (GetRegionOfInterest() && !digitize) break;
794 if (!digitize) continue;
796 digrow->Allocate(nTimeBins,nPads);
797 digrow->AllocateTrack(3);
800 Int_t label[1000]; //stack for 300 events
803 Int_t nElems = nTimeBins*nPads;
805 for (Int_t i=0;i<nInputs; i++)
807 pdig[i] = digarr[i]->GetDigits();
808 ptr[i] = digarr[i]->GetTracks();
811 Short_t *pdig1= digrow->GetDigits();
812 Int_t *ptr1= digrow->GetTracks() ;
816 for (Int_t elem=0;elem<nElems; elem++)
818 // padNumber=elem/nTimeBins
819 // timeBin=elem%nTimeBins
823 for (Int_t i=0;i<nInputs; i++) if (active[i])
825 // q += digarr[i]->GetDigitFast(rows,col);
828 for (Int_t tr=0;tr<3;tr++)
830 // Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr);
831 Int_t lab = ptr[i][tr*nElems];
832 if ( (lab > 1) && *(pdig[i])>zerosup)
834 label[labptr]=lab+masks[i];
841 Int_t padNumber=elem/nTimeBins;
843 q/=16.; //conversion factor
844 Float_t gain = gainROC->GetValue(padRow,padNumber); // get gain for given - pad-row pad
846 //printf("problem\n");
849 // Crosstalk correction:
850 // Double_t qCrossTalk=crossTalkSignal(wireSegment,timeBin); // signal matrix from per sector array
853 // Ion tail correction:
854 // padNumber=elem/nTimeBins
855 // timeBin=elem%nTimeBins
856 // elem=padNumber*nTimeBins+timeBin;
857 // lowerElem=elem-nIonTailBins;
858 // if (lowerElem<0) lowerElem=0;
859 // if (lowerElem in previospad) lowerElem = padNumber*nTimeBins;
861 // for (Int_t celem=elem-1; celem>lowerElem; celem--){
862 // Int_t deltaT=elem-celem
866 Float_t noisePad = noiseROC->GetValue(padRow,padNumber);
867 // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac());
868 Float_t noise = pTPC->GetNoise();
870 q=TMath::Nint(q); // round to the nearest integer
872 fill infor to check consistency of the data
876 if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1);
877 //digrow->SetDigitFast((Short_t)q,rows,col);
879 for (Int_t tr=0;tr<3;tr++)
882 ptr1[tr*nElems] = label[tr];
891 digrow->GlitchFilter();
893 digrow->CompresBuffer(1,zerosup);
894 digrow->CompresTrackBuffer(1);
896 if (fDebug>0) cerr<<sector<<"\t"<<padRow<<"\n";
897 } //for (Int_t n=0; n<param->GetNRowsTotal(); n++)
900 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
901 ogime = orl->GetLoader("TPCLoader");
902 ogime->WriteDigits("OVERWRITE");
904 //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite);
907 for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];