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"
63 ClassImp(AliTPCDigitizer)
65 //___________________________________________
66 AliTPCDigitizer::AliTPCDigitizer() :AliDigitizer(),fDebug(0), fDebugStreamer(0)
69 // Default ctor - don't use it
74 //___________________________________________
75 AliTPCDigitizer::AliTPCDigitizer(AliDigitizationInput* digInput)
76 :AliDigitizer(digInput),fDebug(0), fDebugStreamer(0)
79 // ctor which should be used
81 AliDebug(2,"(AliDigitizationInput* digInput) was processed");
82 if (AliTPCReconstructor::StreamLevel()>0) fDebugStreamer = new TTreeSRedirector("TPCDigitDebug.root");
86 //------------------------------------------------------------------------
87 AliTPCDigitizer::~AliTPCDigitizer()
90 if (fDebugStreamer) delete fDebugStreamer;
95 //------------------------------------------------------------------------
96 Bool_t AliTPCDigitizer::Init()
104 //------------------------------------------------------------------------
105 void AliTPCDigitizer::Digitize(Option_t* option)
107 DigitizeFast(option);
109 //------------------------------------------------------------------------
110 void AliTPCDigitizer::DigitizeFast(Option_t* option)
113 // merge input tree's with summable digits
114 //output stored in TreeTPCD
117 TString optionString = option;
118 if (!strcmp(optionString.Data(),"deb")) {
119 cout<<"AliTPCDigitizer:::DigitizeFast called with option deb "<<endl;
122 //get detector and geometry
125 AliRunLoader *rl, *orl;
126 AliLoader *gime, *ogime;
130 Warning("DigitizeFast","gAlice is NULL. Loading from input 0");
131 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
134 Error("DigitizeFast","Can not find Run Loader for input 0. Can not proceed.");
140 AliTPC *pTPC = (AliTPC *) gAlice->GetModule("TPC");
141 AliTPCParam * param = pTPC->GetParam();
143 //sprintf(s,param->GetTitle());
144 snprintf(s,100,"%s",param->GetTitle());
145 //sprintf(ss,"75x40_100x60");
146 snprintf(ss,100,"75x40_100x60");
148 printf("2 pad-length geom hits with 3 pad-lenght geom digits...\n");
150 param=new AliTPCParamSR();
153 //sprintf(ss,"75x40_100x60_150x60");
154 snprintf(ss,100,"75x40_100x60_150x60");
155 if(strcmp(s,ss)!=0) {
156 printf("No TPC parameters found...\n");
161 pTPC->GenerNoise(500000); //create table with noise
163 Int_t nInputs = fDigInput->GetNinputs();
164 Int_t * masks = new Int_t[nInputs];
165 for (Int_t i=0; i<nInputs;i++)
166 masks[i]= fDigInput->GetMask(i);
167 Short_t **pdig= new Short_t*[nInputs]; //pointers to the expanded digits array
168 Int_t **ptr= new Int_t*[nInputs]; //pointers to the expanded tracks array
169 Bool_t *active= new Bool_t[nInputs]; //flag for active input segments
172 //create digits array for given sectors
175 //create branch's in TPC treeD
176 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
177 ogime = orl->GetLoader("TPCLoader");
178 TTree * tree = ogime->TreeD();
179 AliSimDigits * digrow = new AliSimDigits;
183 ogime->MakeTree("D");
184 tree = ogime->TreeD();
186 tree->Branch("Segment","AliSimDigits",&digrow);
188 AliSimDigits ** digarr = new AliSimDigits*[nInputs];
189 for (Int_t i1=0;i1<nInputs; i1++)
193 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1));
194 gime = rl->GetLoader("TPCLoader");
195 gime->LoadSDigits("read");
196 TTree * treear = gime->TreeS();
200 cerr<<"AliTPCDigitizer: Input tree with SDigits not found in"
201 <<" input "<< i1<<endl;
202 for (Int_t i2=0;i2<i1+1; i2++){
204 if(digarr[i2]) delete digarr[i2];
214 //sprintf(phname,"lhcphase%d",i1);
215 snprintf(phname,100,"lhcphase%d",i1);
216 TParameter<float> *ph = (TParameter<float>*)treear->GetUserInfo()
217 ->FindObject("lhcphase0");
219 cerr<<"AliTPCDigitizer: LHC phase not found in"
220 <<" input "<< i1<<endl;
221 for (Int_t i2=0;i2<i1+1; i2++){
222 if(digarr[i2]) delete digarr[i2];
231 tree->GetUserInfo()->Add(new TParameter<float>(phname,ph->GetVal()));
233 if (treear->GetIndex()==0)
234 treear->BuildIndex("fSegmentID","fSegmentID");
235 treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
243 param->SetZeroSup(2);
245 Int_t zerosup = param->GetZeroSup();
246 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
247 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
249 //Loop over segments of the TPC
251 for (Int_t segmentID=0; segmentID<param->GetNRowsTotal(); segmentID++)
253 Int_t sector, padRow;
254 if (!param->AdjustSectorRow(segmentID,sector,padRow))
256 cerr<<"AliTPC warning: invalid segment ID ! "<<segmentID<<endl;
259 AliTPCCalROC * gainROC = gainTPC->GetCalROC(sector); // pad gains per given sector
260 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sector); // noise per given sector
261 digrow->SetID(segmentID);
266 Bool_t digitize = kFALSE;
267 for (Int_t i=0;i<nInputs; i++)
270 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
271 gime = rl->GetLoader("TPCLoader");
273 if (gime->TreeS()->GetEntryWithIndex(segmentID,segmentID) >= 0) {
274 digarr[i]->ExpandBuffer();
275 digarr[i]->ExpandTrackBuffer();
276 nTimeBins = digarr[i]->GetNRows();
277 nPads = digarr[i]->GetNCols();
279 if (!GetRegionOfInterest() || (i == 0)) digitize = kTRUE;
283 if (GetRegionOfInterest() && !digitize) break;
285 if (!digitize) continue;
287 digrow->Allocate(nTimeBins,nPads);
288 digrow->AllocateTrack(3);
291 Int_t label[1000]; //stack for 300 events
294 Int_t nElems = nTimeBins*nPads;
296 for (Int_t i=0;i<nInputs; i++)
298 pdig[i] = digarr[i]->GetDigits();
299 ptr[i] = digarr[i]->GetTracks();
302 Short_t *pdig1= digrow->GetDigits();
303 Int_t *ptr1= digrow->GetTracks() ;
307 for (Int_t elem=0;elem<nElems; elem++)
313 for (Int_t i=0;i<nInputs; i++) if (active[i])
315 // q += digarr[i]->GetDigitFast(rows,col);
318 for (Int_t tr=0;tr<3;tr++)
320 // Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr);
321 Int_t lab = ptr[i][tr*nElems];
322 if ( (lab > 1) && *(pdig[i])>zerosup)
324 label[labptr]=lab+masks[i];
331 q/=16.; //conversion factor
332 Float_t gain = gainROC->GetValue(padRow,elem/nTimeBins); // get gain for given - pad-row pad
334 //printf("problem\n");
337 Float_t noisePad = noiseROC->GetValue(padRow,elem/nTimeBins);
338 // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac());
339 Float_t noise = pTPC->GetNoise();
344 if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1);
345 //digrow->SetDigitFast((Short_t)q,rows,col);
347 for (Int_t tr=0;tr<3;tr++)
350 ptr1[tr*nElems] = label[tr];
359 digrow->GlitchFilter();
361 digrow->CompresBuffer(1,zerosup);
362 digrow->CompresTrackBuffer(1);
364 if (fDebug>0) cerr<<sector<<"\t"<<padRow<<"\n";
365 } //for (Int_t n=0; n<param->GetNRowsTotal(); n++)
368 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
369 ogime = orl->GetLoader("TPCLoader");
370 ogime->WriteDigits("OVERWRITE");
372 //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite);
375 for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];
385 //------------------------------------------------------------------------
386 void AliTPCDigitizer::DigitizeSave(Option_t* option)
389 // Merge input tree's with summable digits
390 // Output digits stored in TreeTPCD
392 // Not active for long time.
393 // Before adding modification (for ion tail calucation and for the crorsstalk) it should be
394 // checked one by one with currenlty used AliTPCDigitizer::DigitizeFast
396 TString optionString = option;
397 if (!strcmp(optionString.Data(),"deb")) {
398 cout<<"AliTPCDigitizer::Digitize: called with option deb "<<endl;
401 //get detector and geometry
402 AliRunLoader *rl, *orl;
403 AliLoader *gime, *ogime;
406 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
407 ogime = orl->GetLoader("TPCLoader");
409 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
410 //gime = rl->GetLoader("TPCLoader");
411 rl->GetLoader("TPCLoader");
413 AliRun* alirun = rl->GetAliRun();
415 AliTPC *pTPC = (AliTPC *) alirun->GetModule("TPC");
416 AliTPCParam * param = pTPC->GetParam();
417 pTPC->GenerNoise(500000); //create teble with noise
418 printf("noise %f \n", param->GetNoise()*param->GetNoiseNormFac());
420 Int_t nInputs = fDigInput->GetNinputs();
421 // stupid protection...
422 if (nInputs <= 0) return;
424 Int_t * masks = new Int_t[nInputs];
425 for (Int_t i=0; i<nInputs;i++)
426 masks[i]= fDigInput->GetMask(i);
428 AliSimDigits ** digarr = new AliSimDigits*[nInputs];
429 for(Int_t ii=0;ii<nInputs;ii++) digarr[ii]=0;
431 for (Int_t i1=0;i1<nInputs; i1++)
435 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1));
436 gime = rl->GetLoader("TPCLoader");
438 TTree * treear = gime->TreeS();
441 cerr<<" TPC - not existing input = \n"<<i1<<" ";
443 for(Int_t i=0; i<nInputs; i++) delete digarr[i];
448 TBranch * br = treear->GetBranch("fSegmentID");
449 if (br) br->GetFile()->cd();
450 treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
453 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
454 gime = rl->GetLoader("TPCLoader");
455 Stat_t nentries = gime->TreeS()->GetEntries();
458 //create branch's in TPC treeD
459 AliSimDigits * digrow = new AliSimDigits;
460 TTree * tree = ogime->TreeD();
462 tree->Branch("Segment","AliSimDigits",&digrow);
463 param->SetZeroSup(2);
465 Int_t zerosup = param->GetZeroSup();
466 //Loop over segments of the TPC
468 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
469 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
470 for (Int_t n=0; n<nentries; n++) {
471 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
472 gime = rl->GetLoader("TPCLoader");
473 gime->TreeS()->GetEvent(n);
475 digarr[0]->ExpandBuffer();
476 digarr[0]->ExpandTrackBuffer();
479 for (Int_t i=1;i<nInputs; i++){
480 // fDigInput->GetInputTreeTPCS(i)->GetEntryWithIndex(digarr[0]->GetID(),digarr[0]->GetID());
481 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
482 gime = rl->GetLoader("TPCLoader");
483 gime->TreeS()->GetEntryWithIndex(digarr[0]->GetID(),digarr[0]->GetID());
484 digarr[i]->ExpandBuffer();
485 digarr[i]->ExpandTrackBuffer();
486 if ((digarr[0]->GetID()-digarr[i]->GetID())>0)
491 Int_t sector, padRow;
492 if (!param->AdjustSectorRow(digarr[0]->GetID(),sector,padRow)) {
493 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr[0]->GetID()<<endl;
497 AliTPCCalROC * gainROC = gainTPC->GetCalROC(sector); // pad gains per given sector
498 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sector); // noise per given sector
499 digrow->SetID(digarr[0]->GetID());
501 Int_t nTimeBins = digarr[0]->GetNRows();
502 Int_t nPads = digarr[0]->GetNCols();
503 digrow->Allocate(nTimeBins,nPads);
504 digrow->AllocateTrack(3);
507 Int_t label[1000]; //stack for 300 events
512 for (Int_t iTimeBin=0;iTimeBin<nTimeBins; iTimeBin++){ // iTimeBin
513 for (Int_t iPad=0;iPad<nPads; iPad++){ // pad
518 for (Int_t i=0;i<nInputs; i++){
519 q += digarr[i]->GetDigitFast(iTimeBin,iPad);
522 for (Int_t tr=0;tr<3;tr++) {
523 Int_t lab = digarr[i]->GetTrackIDFast(iTimeBin,iPad,tr);
524 //Int_t lab = ptr[i][tr*nElems];
526 label[labptr]=lab+masks[i];
534 q/=16.; //conversion factor
535 // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac());
536 Float_t gain = gainROC->GetValue(padRow,iPad);
538 Float_t noisePad = noiseROC->GetValue(padRow, iPad);
540 Float_t noise = pTPC->GetNoise();
543 // here we can get digits from past and add signal
546 //for (Int_t jTimeBin=0; jTimeBin<iTimeBin; jTimeBin++)
553 if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1);
554 digrow->SetDigitFast((Short_t)q,iTimeBin,iPad);
555 // *pdig1 =Short_t(q);
556 for (Int_t tr=0;tr<3;tr++){
558 ((AliSimDigits*)digrow)->SetTrackIDFast(label[tr],iTimeBin,iPad,tr);
559 //ptr1[tr*nElems] = label[tr];
561 // ((AliSimDigits*)digrow)->SetTrackIDFast(-1,iTimeBin,iPad,tr);
562 // ptr1[tr*nElems] = 1;
570 digrow->CompresBuffer(1,zerosup);
571 digrow->CompresTrackBuffer(1);
573 if (fDebug>0) cerr<<sector<<"\t"<<padRow<<"\n";
575 // printf("end TPC merging - end -Tree %s\t%p\n",fDigInput->GetInputTreeH(0)->GetName(),fDigInput->GetInputTreeH(0)->GetListOfBranches()->At(3));
576 //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite);
577 ogime->WriteDigits("OVERWRITE");
579 for (Int_t i=1;i<nInputs; i++)
581 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
582 gime = rl->GetLoader("TPCLoader");
583 gime->UnloadSDigits();
585 ogime->UnloadDigits();
588 for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];
595 //------------------------------------------------------------------------
596 void AliTPCDigitizer::DigitizeWithTailAndCrossTalk(Option_t* option)
598 // Modified version of the digitization function
599 // Modification: adding the ion tail and crosstalk:
601 // pcstream used in order to visually inspect data
604 // Crosstalk simulation:
605 // 1.) Calculate per time bin mean charge (per pad) within anode wire segment
606 // 2.) Subsract for the clusters at given time bin fraction of (mean charge) normalized by add hoc constant
607 // AliTPCRecoParam::GetCrosstalkCorrection() (0 if not crosstalk, 1 if ideal crosstalk)
608 // for simplicity we are assuming that wire segents are related to pad-rows
609 // Wire segmentationn is obtatined from the
610 // AliTPCParam::GetWireSegment(Int_t sector, Int_t row); // to be implemented
611 // AliTPCParam::GetNPadsPerSegment(Int_t segmentID); // to be implemented
613 // Ion tail simulation:
614 // 1.) Needs signal from pad+-1, taking signal from history
615 // merge input tree's with summable digits
616 // output stored in TreeTPCD
620 TString optionString = option;
621 if (!strcmp(optionString.Data(),"deb")) {
622 cout<<"AliTPCDigitizer:::DigitizeFast called with option deb "<<endl;
625 //get detector and geometry
628 AliRunLoader *rl, *orl;
629 AliLoader *gime, *ogime;
633 Warning("DigitizeFast","gAlice is NULL. Loading from input 0");
634 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
637 Error("DigitizeFast","Can not find Run Loader for input 0. Can not proceed.");
643 AliTPC *pTPC = (AliTPC *) gAlice->GetModule("TPC");
644 AliTPCParam * param = pTPC->GetParam();
646 //sprintf(s,param->GetTitle());
647 snprintf(s,100,"%s",param->GetTitle());
648 //sprintf(ss,"75x40_100x60");
649 snprintf(ss,100,"75x40_100x60");
651 printf("2 pad-length geom hits with 3 pad-lenght geom digits...\n");
653 param=new AliTPCParamSR();
656 //sprintf(ss,"75x40_100x60_150x60");
657 snprintf(ss,100,"75x40_100x60_150x60");
658 if(strcmp(s,ss)!=0) {
659 printf("No TPC parameters found...\n");
664 pTPC->GenerNoise(500000); //create table with noise
666 Int_t nInputs = fDigInput->GetNinputs();
667 Int_t * masks = new Int_t[nInputs];
668 for (Int_t i=0; i<nInputs;i++)
669 masks[i]= fDigInput->GetMask(i);
670 Short_t **pdig= new Short_t*[nInputs]; //pointers to the expanded digits array
671 Int_t **ptr= new Int_t*[nInputs]; //pointers to the expanded tracks array
672 Bool_t *active= new Bool_t[nInputs]; //flag for active input segments
675 //create digits array for given sectors
678 //create branch's in TPC treeD
679 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
680 ogime = orl->GetLoader("TPCLoader");
681 TTree * tree = ogime->TreeD();
682 AliSimDigits * digrow = new AliSimDigits;
686 ogime->MakeTree("D");
687 tree = ogime->TreeD();
689 tree->Branch("Segment","AliSimDigits",&digrow);
691 AliSimDigits ** digarr = new AliSimDigits*[nInputs];
692 for (Int_t i1=0;i1<nInputs; i1++)
696 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i1));
697 gime = rl->GetLoader("TPCLoader");
698 gime->LoadSDigits("read");
699 TTree * treear = gime->TreeS();
703 cerr<<"AliTPCDigitizer: Input tree with SDigits not found in"
704 <<" input "<< i1<<endl;
705 for (Int_t i2=0;i2<i1+1; i2++){
707 if(digarr[i2]) delete digarr[i2];
717 //sprintf(phname,"lhcphase%d",i1);
718 snprintf(phname,100,"lhcphase%d",i1);
719 TParameter<float> *ph = (TParameter<float>*)treear->GetUserInfo()
720 ->FindObject("lhcphase0");
722 cerr<<"AliTPCDigitizer: LHC phase not found in"
723 <<" input "<< i1<<endl;
724 for (Int_t i2=0;i2<i1+1; i2++){
725 if(digarr[i2]) delete digarr[i2];
734 tree->GetUserInfo()->Add(new TParameter<float>(phname,ph->GetVal()));
736 if (treear->GetIndex()==0)
737 treear->BuildIndex("fSegmentID","fSegmentID");
738 treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
746 param->SetZeroSup(2);
747 Int_t zerosup = param->GetZeroSup();
748 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
749 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
751 // 1.) Make first loop to calculate mean amplitude per pad per segment
753 // TObjArray * crossTalkSignalArray(nsectors);
754 // TMatrixD crossTalkSignal(nWireSegments, timeBin); // structure with mean signal per pad to be filled in first loop
757 //2.) Loop over segments (padrows) of the TPC
759 for (Int_t segmentID=0; segmentID<param->GetNRowsTotal(); segmentID++)
761 Int_t sector, padRow;
762 if (!param->AdjustSectorRow(segmentID,sector,padRow))
764 cerr<<"AliTPC warning: invalid segment ID ! "<<segmentID<<endl;
767 AliTPCCalROC * gainROC = gainTPC->GetCalROC(sector); // pad gains per given sector
768 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(sector); // noise per given sector
769 digrow->SetID(segmentID);
774 Bool_t digitize = kFALSE;
775 for (Int_t i=0;i<nInputs; i++)
778 rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(i));
779 gime = rl->GetLoader("TPCLoader");
781 if (gime->TreeS()->GetEntryWithIndex(segmentID,segmentID) >= 0) {
782 digarr[i]->ExpandBuffer();
783 digarr[i]->ExpandTrackBuffer();
784 nTimeBins = digarr[i]->GetNRows();
785 nPads = digarr[i]->GetNCols();
787 if (!GetRegionOfInterest() || (i == 0)) digitize = kTRUE;
791 if (GetRegionOfInterest() && !digitize) break;
793 if (!digitize) continue;
795 digrow->Allocate(nTimeBins,nPads);
796 digrow->AllocateTrack(3);
799 Int_t label[1000]; //stack for 300 events
802 Int_t nElems = nTimeBins*nPads;
804 for (Int_t i=0;i<nInputs; i++)
806 pdig[i] = digarr[i]->GetDigits();
807 ptr[i] = digarr[i]->GetTracks();
810 Short_t *pdig1= digrow->GetDigits();
811 Int_t *ptr1= digrow->GetTracks() ;
815 for (Int_t elem=0;elem<nElems; elem++)
817 // padNumber=elem/nTimeBins
818 // timeBin=elem%nTimeBins
822 for (Int_t i=0;i<nInputs; i++) if (active[i])
824 // q += digarr[i]->GetDigitFast(rows,col);
827 for (Int_t tr=0;tr<3;tr++)
829 // Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr);
830 Int_t lab = ptr[i][tr*nElems];
831 if ( (lab > 1) && *(pdig[i])>zerosup)
833 label[labptr]=lab+masks[i];
840 Int_t padNumber=elem/nTimeBins;
842 q/=16.; //conversion factor
843 Float_t gain = gainROC->GetValue(padRow,padNumber); // get gain for given - pad-row pad
845 //printf("problem\n");
848 // Crosstalk correction:
849 // Double_t qCrossTalk=crossTalkSignal(wireSegment,timeBin); // signal matrix from per sector array
852 // Ion tail correction:
853 // padNumber=elem/nTimeBins
854 // timeBin=elem%nTimeBins
855 // elem=padNumber*nTimeBins+timeBin;
856 // lowerElem=elem-nIonTailBins;
857 // if (lowerElem<0) lowerElem=0;
858 // if (lowerElem in previospad) lowerElem = padNumber*nTimeBins;
860 // for (Int_t celem=elem-1; celem>lowerElem; celem--){
861 // Int_t deltaT=elem-celem
865 Float_t noisePad = noiseROC->GetValue(padRow,padNumber);
866 // Float_t noise = gRandom->Gaus(0,param->GetNoise()*param->GetNoiseNormFac());
867 Float_t noise = pTPC->GetNoise();
869 q=TMath::Nint(q); // round to the nearest integer
871 fill infor to check consistency of the data
875 if(q >= param->GetADCSat()) q = (Short_t)(param->GetADCSat() - 1);
876 //digrow->SetDigitFast((Short_t)q,rows,col);
878 for (Int_t tr=0;tr<3;tr++)
881 ptr1[tr*nElems] = label[tr];
890 digrow->GlitchFilter();
892 digrow->CompresBuffer(1,zerosup);
893 digrow->CompresTrackBuffer(1);
895 if (fDebug>0) cerr<<sector<<"\t"<<padRow<<"\n";
896 } //for (Int_t n=0; n<param->GetNRowsTotal(); n++)
899 orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
900 ogime = orl->GetLoader("TPCLoader");
901 ogime->WriteDigits("OVERWRITE");
903 //fDigInput->GetTreeDTPC()->Write(0,TObject::kOverwrite);
906 for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];