1 /**************************************************************************
\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
\r
4 * Author: The ALICE Off-line Project. *
\r
5 * Contributors are mentioned in the code where appropriate. *
\r
7 * Permission to use, copy, modify and distribute this software and its *
\r
8 * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * without fee, provided that the above copyright notice appears in all *
\r
10 * copies and that both the copyright notice and this permission notice *
\r
11 * appear in the supporting documentation. The authors make no claims *
\r
12 * about the suitability of this software for any purpose. It is *
\r
13 * provided "as is" without express or implied warranty. *
\r
14 **************************************************************************/
\r
16 /* $Id: AliTPCclustererKr.cxx,v 1.7 2008/02/06 17:24:53 matyja Exp $ */
\r
18 //-----------------------------------------------------------------
\r
19 // Implementation of the TPC Kr cluster class
\r
21 // Origin: Adam Matyja, INP PAN, adam.matyja@ifj.edu.pl
\r
22 //-----------------------------------------------------------------
\r
25 Instruction - how to use that:
\r
26 There are two macros prepared. One is for preparing clusters from MC
\r
27 samples: FindKrClusters.C. The output is kept in TPC.RecPoints.root.
\r
28 The other macro is prepared for data analysis: FindKrClustersRaw.C.
\r
29 The output is created for each processed file in root file named adc.root.
\r
30 For each data subsample the same named file is created. So be careful
\r
31 do not overwrite them.
\r
33 Additional selection criteria to select the GOLD cluster
\r
35 // open file with clusters
\r
36 TFile f("Krypton.root");
\r
37 TTree * tree = (TTree*)f.Get("Kr")
\r
38 TCut cutR0("cutR0","fADCcluster/fSize<100"); // adjust it according v seetings -
\r
39 TCut cutR1("cutR1","fADCcluster/fSize>7"); // cosmic tracks and noise removal
\r
40 TCut cutR2("cutR2","fMax.fAdc/fADCcluster<0.2"); // digital noise removal
\r
41 TCut cutR3("cutR3","fMax.fAdc/fADCcluster>0.01"); // noise removal
\r
42 TCut cutS1("cutS1","fSize<200"); // adjust it according v seetings - cosmic tracks
\r
43 TCut cutAll = cutR0+cutR1+cutR2+cutR3+cutS1;
\r
44 This values are typical values to be applied in selectors
\r
51 To run clusterizaton for MC type:
\r
54 If you don't want to use the standard selection criteria then you
\r
55 have to do following:
\r
57 // load the standard setup
\r
58 AliRunLoader* rl = AliRunLoader::Open("galice.root");
\r
59 AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
\r
62 gAlice=rl->GetAliRun();
\r
63 TDirectory *cwd = gDirectory;
\r
64 AliTPCv4 *tpc = (AliTPCv4*)gAlice->GetDetector("TPC");
\r
65 Int_t ver = tpc->IsVersion();
\r
67 AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
\r
68 AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
\r
69 digarr->Setup(param);
\r
73 Int_t nevmax=rl->GetNumberOfEvents();
\r
74 for(Int_t nev=0;nev<nevmax ;nev++){
\r
76 TTree* input_tree= tpcl->TreeD();//load tree with digits
\r
77 digarr->ConnectTree(input_tree);
\r
78 TTree *output_tree =tpcl->TreeR();//load output tree
\r
80 AliTPCclustererKr *clusters = new AliTPCclustererKr();
\r
81 clusters->SetParam(param);
\r
82 clusters->SetInput(input_tree);
\r
83 clusters->SetOutput(output_tree);
\r
84 clusters->SetDigArr(digarr);
\r
86 //If you want to change the cluster finder parameters for MC there are
\r
89 //1. signal threshold (everything below the given number is treated as 0)
\r
90 clusters->SetMinAdc(3);
\r
92 //2. number of neighbouring timebins to be considered
\r
93 clusters->SetMinTimeBins(2);
\r
95 //3. distance of the cluster center to the center of a pad in pad-padrow plane
\r
96 //(in cm). Remenber that this is still quantified by pad size.
\r
97 clusters->SetMaxPadRangeCm(2.5);
\r
99 //4. distance of the cluster center to the center of a padrow in pad-padrow
\r
100 //plane (in cm). Remenber that this is still quantified by pad size.
\r
101 clusters->SetMaxRowRangeCm(3.5);
\r
103 //5. distance of the cluster center to the max time bin on a pad (in tackts)
\r
104 //ie. fabs(centerT - time)<7
\r
105 clusters->SetMaxTimeRange(7);
\r
107 //6. cut reduce peak at 0. There are noises which appear mostly as two
\r
108 //timebins on one pad.
\r
109 clusters->SetValueToSize(3.5);
\r
112 clusters->finderIO();
\r
113 tpcl->WriteRecPoints("OVERWRITE");
\r
115 delete rl;//cleans everything
\r
118 ********* DATA *********
\r
121 To run clusterizaton for DATA for file named raw_data.root type:
\r
122 .x FindKrClustersRaw.C("raw_data.root")
\r
124 If you want to change some criteria do the following:
\r
127 // remove Altro warnings
\r
129 AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
\r
130 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
\r
131 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
\r
132 AliLog::SetModuleDebugLevel("RAW",-5);
\r
135 // Get database with noises
\r
137 // char *ocdbpath = gSystem->Getenv("OCDB_PATH");
\r
138 char *ocdbpath ="local:///afs/cern.ch/alice/tpctest/OCDB";
\r
140 ocdbpath="alien://folder=/alice/data/2007/LHC07w/OCDB/";
\r
142 AliCDBManager * man = AliCDBManager::Instance();
\r
143 man->SetDefaultStorage(ocdbpath);
\r
145 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
\r
146 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
\r
149 TFile *hfile=new TFile("adc.root","RECREATE","ADC file");
\r
150 // Create a ROOT Tree
\r
151 TTree *mytree = new TTree("Kr","Krypton cluster tree");
\r
153 //define infput file
\r
154 const char *fileName="data.root";
\r
155 AliRawReader *reader = new AliRawReaderRoot(fileName);
\r
156 //AliRawReader *reader = new AliRawReaderDate(fileName);
\r
158 AliAltroRawStreamFast* stream = new AliAltroRawStreamFast(reader);
\r
159 stream->SelectRawData("TPC");
\r
161 //one general output
\r
162 AliTPCclustererKr *clusters = new AliTPCclustererKr();
\r
163 clusters->SetOutput(mytree);
\r
164 clusters->SetRecoParam(0);//standard reco parameters
\r
165 AliTPCParamSR *param=new AliTPCParamSR();
\r
166 clusters->SetParam(param);//TPC parameters(sectors, timebins, etc.)
\r
168 //set cluster finder parameters (from data):
\r
169 //1. zero suppression parameter
\r
170 clusters->SetZeroSup(param->GetZeroSup());
\r
173 clusters->SetFirstBin(60);
\r
176 clusters->SetLastBin(950);
\r
179 clusters->SetMaxNoiseAbs(2);
\r
181 //5. maximal amount of sigma of noise
\r
182 clusters->SetMaxNoiseSigma(3);
\r
184 //The remaining parameters are the same paramters as for MC (see MC section
\r
186 clusters->SetMinAdc(3);
\r
187 clusters->SetMinTimeBins(2);
\r
188 clusters->SetMaxPadRangeCm(2.5);
\r
189 clusters->SetMaxRowRangeCm(3.5);
\r
190 clusters->SetMaxTimeRange(7);
\r
191 clusters->SetValueToSize(3.5);
\r
193 while (reader->NextEvent()) {
\r
194 clusters->FinderIO(reader);
\r
204 #include "AliTPCclustererKr.h"
\r
205 #include "AliTPCclusterKr.h"
\r
206 //#include <vector>
\r
208 #include "TObject.h"
\r
209 #include "AliPadMax.h"
\r
210 #include "AliSimDigits.h"
\r
211 #include "AliTPCv4.h"
\r
212 #include "AliTPCParam.h"
\r
213 #include "AliTPCDigitsArray.h"
\r
214 #include "AliTPCvtpr.h"
\r
215 #include "AliTPCClustersRow.h"
\r
219 #include "TTreeStream.h"
\r
221 #include "AliTPCTransform.h"
\r
223 //used in raw data finder
\r
224 #include "AliTPCROC.h"
\r
225 #include "AliTPCCalPad.h"
\r
226 #include "AliTPCAltroMapping.h"
\r
227 #include "AliTPCcalibDB.h"
\r
228 #include "AliTPCRawStream.h"
\r
229 #include "AliTPCRecoParam.h"
\r
230 #include "AliTPCReconstructor.h"
\r
231 #include "AliRawReader.h"
\r
232 #include "AliTPCCalROC.h"
\r
234 ClassImp(AliTPCclustererKr)
\r
237 AliTPCclustererKr::AliTPCclustererKr()
\r
252 // fMaxPadRange(4),
\r
253 // fMaxRowRange(3),
\r
256 fMaxPadRangeCm(2.5),
\r
257 fMaxRowRangeCm(3.5),
\r
266 // default constructor
\r
270 AliTPCclustererKr::AliTPCclustererKr(const AliTPCclustererKr ¶m)
\r
285 // fMaxPadRange(4),
\r
286 // fMaxRowRange(3),
\r
289 fMaxPadRangeCm(2.5),
\r
290 fMaxRowRangeCm(3.5),
\r
299 // copy constructor
\r
301 fParam = param.fParam;
\r
302 fRecoParam = param.fRecoParam;
\r
303 fRawData = param.fRawData;
\r
304 fInput = param.fInput ;
\r
305 fOutput = param.fOutput;
\r
306 fDigarr = param.fDigarr;
\r
307 fZeroSup = param.fZeroSup ;
\r
308 fFirstBin = param.fFirstBin ;
\r
309 fLastBin = param.fLastBin ;
\r
310 fMaxNoiseAbs = param.fMaxNoiseAbs ;
\r
311 fMaxNoiseSigma = param.fMaxNoiseSigma ;
\r
312 fMinAdc = param.fMinAdc;
\r
313 fMinTimeBins = param.fMinTimeBins;
\r
314 // fMaxPadRange = param.fMaxPadRange ;
\r
315 // fMaxRowRange = param.fMaxRowRange ;
\r
316 fMaxTimeRange = param.fMaxTimeRange;
\r
317 fValueToSize = param.fValueToSize;
\r
318 fMaxPadRangeCm = param.fMaxPadRangeCm;
\r
319 fMaxRowRangeCm = param.fMaxRowRangeCm;
\r
320 fIsolCut = param.fIsolCut;
\r
321 fDebugLevel = param.fDebugLevel;
\r
322 fHistoRow = param.fHistoRow ;
\r
323 fHistoPad = param.fHistoPad ;
\r
324 fHistoTime = param.fHistoTime;
\r
325 fHistoRowPad = param.fHistoRowPad;
\r
330 AliTPCclustererKr & AliTPCclustererKr::operator = (const AliTPCclustererKr & param)
\r
333 // assignment operator
\r
335 fParam = param.fParam;
\r
336 fRecoParam = param.fRecoParam;
\r
337 fRawData = param.fRawData;
\r
338 fInput = param.fInput ;
\r
339 fOutput = param.fOutput;
\r
340 fDigarr = param.fDigarr;
\r
341 fZeroSup = param.fZeroSup ;
\r
342 fFirstBin = param.fFirstBin ;
\r
343 fLastBin = param.fLastBin ;
\r
344 fMaxNoiseAbs = param.fMaxNoiseAbs ;
\r
345 fMaxNoiseSigma = param.fMaxNoiseSigma ;
\r
346 fMinAdc = param.fMinAdc;
\r
347 fMinTimeBins = param.fMinTimeBins;
\r
348 // fMaxPadRange = param.fMaxPadRange ;
\r
349 // fMaxRowRange = param.fMaxRowRange ;
\r
350 fMaxTimeRange = param.fMaxTimeRange;
\r
351 fValueToSize = param.fValueToSize;
\r
352 fMaxPadRangeCm = param.fMaxPadRangeCm;
\r
353 fMaxRowRangeCm = param.fMaxRowRangeCm;
\r
354 fIsolCut = param.fIsolCut;
\r
355 fDebugLevel = param.fDebugLevel;
\r
356 fHistoRow = param.fHistoRow ;
\r
357 fHistoPad = param.fHistoPad ;
\r
358 fHistoTime = param.fHistoTime;
\r
359 fHistoRowPad = param.fHistoRowPad;
\r
363 AliTPCclustererKr::~AliTPCclustererKr()
\r
371 void AliTPCclustererKr::SetRecoParam(AliTPCRecoParam *recoParam)
\r
374 // set reconstruction parameters
\r
377 fRecoParam = recoParam;
\r
379 //set default parameters if not specified
\r
380 fRecoParam = AliTPCReconstructor::GetRecoParam();
\r
381 if (!fRecoParam) fRecoParam = AliTPCRecoParam::GetLowFluxParam();
\r
387 ////____________________________________________________________________________
\r
389 void AliTPCclustererKr::SetInput(TTree * tree)
\r
392 // set input tree with digits
\r
395 if (!fInput->GetBranch("Segment")){
\r
396 cerr<<"AliTPCclusterKr::FindClusterKr(): no proper input tree !\n";
\r
402 void AliTPCclustererKr::SetOutput(TTree * /*tree*/)
\r
407 fOutput = new TTreeSRedirector("Krypton.root");
\r
410 ////____________________________________________________________________________
\r
412 Int_t AliTPCclustererKr::FinderIO()
\r
414 // Krypton cluster finder for simulated events from MC
\r
417 Error("Digits2Clusters", "input tree not initialised");
\r
422 Error("Digits2Clusters", "output tree not initialised");
\r
430 Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
\r
432 // Krypton cluster finder for the TPC raw data
\r
434 // fParam must be defined before
\r
436 if(rawReader)fRawData=kTRUE; //set flag to data
\r
439 Error("Digits2Clusters", "output tree not initialised");
\r
443 fParam->SetMaxTBin(fRecoParam->GetLastBin());//set number of timebins from reco -> param
\r
444 // used later for memory allocation
\r
446 Bool_t isAltro=kFALSE;
\r
448 AliTPCROC * roc = AliTPCROC::Instance();
\r
449 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
\r
450 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
\r
452 AliTPCRawStream input(rawReader,(AliAltroMapping**)mapping);
\r
454 const Int_t kNIS = fParam->GetNInnerSector();//number of inner sectors
\r
455 const Int_t kNOS = fParam->GetNOuterSector();//number of outer sectors
\r
456 const Int_t kNS = kNIS + kNOS;//all sectors
\r
460 AliTPCDigitsArray *digarr=new AliTPCDigitsArray(kFALSE);//data not sim
\r
461 digarr->Setup(fParam);//as usually parameters
\r
464 // Loop over sectors
\r
466 for(Int_t iSec = 0; iSec < kNS; iSec++) {
\r
467 AliTPCCalROC * noiseROC;
\r
469 noiseROC =new AliTPCCalROC(iSec);//noise=0
\r
472 noiseROC = noiseTPC->GetCalROC(iSec); // noise per given sector
\r
474 Int_t nRows = 0; //number of rows in sector
\r
475 Int_t nDDLs = 0; //number of DDLs
\r
476 Int_t indexDDL = 0; //DDL index
\r
478 nRows = fParam->GetNRowLow();
\r
480 indexDDL = iSec * 2;
\r
482 nRows = fParam->GetNRowUp();
\r
484 indexDDL = (iSec-kNIS) * 4 + kNIS * 2;
\r
488 // Load the raw data for corresponding DDLs
\r
490 rawReader->Reset();
\r
491 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
\r
495 // Allocate memory for rows in sector (pads(depends on row) x timebins)
\r
496 for(Int_t iRow = 0; iRow < nRows; iRow++) {
\r
497 digarr->CreateRow(iSec,iRow);
\r
498 }//end loop over rows
\r
500 rawReader->Reset();
\r
501 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
\r
504 // Begin loop over altro data
\r
506 while (input.Next()) {
\r
508 //check sector consistency
\r
509 if (input.GetSector() != iSec)
\r
510 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",iSec,input.GetSector()));
\r
512 Int_t iRow = input.GetRow();
\r
513 Int_t iPad = input.GetPad();
\r
514 Int_t iTimeBin = input.GetTime();
\r
517 if(fDebugLevel==72){
\r
518 fHistoRow->Fill(iRow);
\r
519 fHistoPad->Fill(iPad);
\r
520 fHistoTime->Fill(iTimeBin);
\r
521 fHistoRowPad->Fill(iPad,iRow);
\r
522 }else if(fDebugLevel>=0&&fDebugLevel<72){
\r
523 if(iSec==fDebugLevel){
\r
524 fHistoRow->Fill(iRow);
\r
525 fHistoPad->Fill(iPad);
\r
526 fHistoTime->Fill(iTimeBin);
\r
527 fHistoRowPad->Fill(iPad,iRow);
\r
529 }else if(fDebugLevel==73){
\r
531 fHistoRow->Fill(iRow);
\r
532 fHistoPad->Fill(iPad);
\r
533 fHistoTime->Fill(iTimeBin);
\r
534 fHistoRowPad->Fill(iPad,iRow);
\r
536 }else if(fDebugLevel==74){
\r
538 fHistoRow->Fill(iRow);
\r
539 fHistoPad->Fill(iPad);
\r
540 fHistoTime->Fill(iTimeBin);
\r
541 fHistoRowPad->Fill(iPad,iRow);
\r
545 //check row consistency
\r
546 if (iRow < 0 ) continue;
\r
547 if (iRow < 0 || iRow >= nRows){
\r
548 AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
\r
549 iRow, 0, nRows -1));
\r
553 //check pad consistency
\r
554 if (iPad < 0 || iPad >= (Int_t)(roc->GetNPads(iSec,iRow))) {
\r
555 AliError(Form("Pad index (%d) outside the range (%d -> %d) !",
\r
556 iPad, 0, roc->GetNPads(iSec,iRow) ));
\r
560 //check time consistency
\r
561 if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){
\r
562 //cout<<iTimeBin<<endl;
\r
564 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
\r
565 iTimeBin, 0, fRecoParam->GetLastBin() -1));
\r
569 Int_t signal = input.GetSignal();
\r
570 if (signal <= fZeroSup ||
\r
571 iTimeBin < fFirstBin ||
\r
572 iTimeBin > fLastBin
\r
574 digarr->GetRow(iSec,iRow)->SetDigitFast(0,iTimeBin,iPad);
\r
577 if (!noiseROC) continue;
\r
578 Double_t noiseOnPad = noiseROC->GetValue(iRow,iPad);//noise on given pad and row in sector
\r
579 if (noiseOnPad > fMaxNoiseAbs){
\r
580 digarr->GetRow(iSec,iRow)->SetDigitFast(0,iTimeBin,iPad);
\r
581 continue; // consider noisy pad as dead
\r
583 if(signal <= fMaxNoiseSigma * noiseOnPad){
\r
584 digarr->GetRow(iSec,iRow)->SetDigitFast(0,iTimeBin,iPad);
\r
587 digarr->GetRow(iSec,iRow)->SetDigitFast(signal,iTimeBin,iPad);
\r
588 }//end of loop over altro data
\r
589 }//end of loop over sectors
\r
592 if(isAltro) FindClusterKrIO();
\r
598 void AliTPCclustererKr::CleanSector(Int_t sector){
\r
600 // clean isolated digits
\r
602 const Int_t kNRows=fParam->GetNRow(sector);//number of rows in sector
\r
603 for(Int_t iRow=0; iRow<kNRows; ++iRow){
\r
604 AliSimDigits *digrow;
\r
606 digrow = (AliSimDigits*)fDigarr->GetRow(sector,iRow);//real data
\r
608 digrow = (AliSimDigits*)fDigarr->LoadRow(sector,iRow);//MC
\r
610 if(!digrow) continue;
\r
611 digrow->ExpandBuffer(); //decrunch
\r
612 const Int_t kNPads = digrow->GetNCols(); // number of pads
\r
613 const Int_t kNTime = digrow->GetNRows(); // number of timebins
\r
614 for(Int_t iPad=1;iPad<kNPads-1;iPad++){
\r
615 Short_t* val = digrow->GetDigitsColumn(iPad);
\r
617 for(Int_t iTimeBin=1;iTimeBin<kNTime-1;iTimeBin++){
\r
618 if (val[iTimeBin]<=0) continue;
\r
619 if (val[iTimeBin-1]+val[iTimeBin+1]<fIsolCut) {val[iTimeBin]=0; continue;}
\r
620 if (val[iTimeBin-kNTime]+val[iTimeBin+kNTime]<fIsolCut) {val[iTimeBin]=0; continue;}
\r
622 if (val[iTimeBin-1-kNTime]+val[iTimeBin+1+kNTime]<fIsolCut) {val[iTimeBin]=0; continue;}
\r
623 if (val[iTimeBin+1-kNTime]+val[iTimeBin-1+kNTime]<fIsolCut) {val[iTimeBin]=0; continue;}
\r
631 ////____________________________________________________________________________
\r
632 Int_t AliTPCclustererKr::FindClusterKrIO()
\r
636 //fParam and fDigarr must be set to run this method
\r
639 Int_t clusterCounter=0;
\r
640 const Int_t nTotalSector=fParam->GetNSector();//number of sectors
\r
641 for(Int_t iSec=0; iSec<nTotalSector; ++iSec){
\r
644 //vector of maxima for each sector
\r
645 //std::vector<AliPadMax*> maximaInSector;
\r
646 TObjArray *maximaInSector=new TObjArray();//to store AliPadMax*
\r
649 // looking for the maxima on the pad
\r
652 const Int_t kNRows=fParam->GetNRow(iSec);//number of rows in sector
\r
653 for(Int_t iRow=0; iRow<kNRows; ++iRow){
\r
654 AliSimDigits *digrow;
\r
656 digrow = (AliSimDigits*)fDigarr->GetRow(iSec,iRow);//real data
\r
658 digrow = (AliSimDigits*)fDigarr->LoadRow(iSec,iRow);//MC
\r
660 if(digrow){//if pointer exist
\r
661 digrow->ExpandBuffer(); //decrunch
\r
662 const Int_t kNPads = digrow->GetNCols(); // number of pads
\r
663 const Int_t kNTime = digrow->GetNRows(); // number of timebins
\r
664 for(Int_t iPad=0;iPad<kNPads;iPad++){
\r
666 Int_t timeBinMax=-1;//timebin of maximum
\r
667 Int_t valueMaximum=-1;//value of maximum in adc
\r
668 Int_t increaseBegin=-1;//timebin when increase starts
\r
669 Int_t sumAdc=0;//sum of adc on the pad in maximum surrounding
\r
670 bool ifIncreaseBegin=true;//flag - check if increasing started
\r
671 bool ifMaximum=false;//flag - check if it could be maximum
\r
672 Short_t* val = digrow->GetDigitsColumn(iPad);
\r
673 for(Int_t iTimeBin=1;iTimeBin<kNTime-1;iTimeBin++){
\r
675 if (val[iTimeBin]==-1) break; // 0 until the end
\r
676 for( ; iTimeBin<kNTime-2&&val[iTimeBin]<fMinAdc ;iTimeBin++) {}
\r
679 Short_t adc = val[iTimeBin];
\r
681 if(adc<fMinAdc){//standard was 3 for fMinAdc
\r
683 if(iTimeBin-increaseBegin<fMinTimeBins){//at least 2 time bins
\r
688 ifIncreaseBegin=true;
\r
692 //insert maximum, default values and set flags
\r
693 //Double_t xCord,yCord;
\r
694 //GetXY(iSec,iRow,iPad,xCord,yCord);
\r
695 Double_t x[]={iRow,iPad,iTimeBin};
\r
697 AliTPCTransform trafo;
\r
698 trafo.Transform(x,i,0,1);
\r
700 AliPadMax *oneMaximum = new AliPadMax(AliTPCvtpr(valueMaximum,
\r
706 x[2]/*timeBinMax*/),
\r
710 maximaInSector->AddLast(oneMaximum);
\r
716 ifIncreaseBegin=true;
\r
727 if(ifIncreaseBegin){
\r
728 ifIncreaseBegin=false;
\r
729 increaseBegin=iTimeBin;
\r
732 if(adc>valueMaximum){
\r
733 timeBinMax=iTimeBin;
\r
738 if(iTimeBin==kNTime-1 && ifMaximum && kNTime-increaseBegin>fMinTimeBins){//on the edge
\r
739 //at least 3 timebins
\r
740 //insert maximum, default values and set flags
\r
741 //Double_t xCord,yCord;
\r
742 //GetXY(iSec,iRow,iPad,xCord,yCord);
\r
743 Double_t x[]={iRow,iPad,iTimeBin};
\r
745 AliTPCTransform trafo;
\r
746 trafo.Transform(x,i,0,1);
\r
747 AliPadMax *oneMaximum = new AliPadMax(AliTPCvtpr(valueMaximum,
\r
753 x[2]/*timeBinMax*/),
\r
757 maximaInSector->AddLast(oneMaximum);
\r
763 ifIncreaseBegin=true;
\r
768 }//end loop over timebins
\r
769 }//end loop over pads
\r
771 // cout<<"Pointer does not exist!!"<<endl;
\r
772 }//end if poiner exists
\r
773 }//end loop over rows
\r
775 MakeClusters(maximaInSector,iSec,clusterCounter);
\r
777 maximaInSector->SetOwner(kTRUE);
\r
778 maximaInSector->Delete();
\r
779 delete maximaInSector;
\r
781 cout<<"Number of clusters in event: "<<clusterCounter<<endl;
\r
785 void AliTPCclustererKr::MakeClusters(TObjArray * maximaInSector, Int_t iSec, Int_t &clusterCounter){
\r
792 Int_t maxTimeBin=0;
\r
798 Int_t entriesArr = maximaInSector->GetEntriesFast();
\r
799 for(Int_t it1 = 0; it1 < entriesArr; ++it1 ) {
\r
801 AliPadMax *mp1=(AliPadMax *)maximaInSector->UncheckedAt(it1);
\r
802 if (!mp1) continue;
\r
803 AliTPCclusterKr clusterKr;
\r
806 Int_t clusterValue=0;
\r
807 clusterValue+=(mp1)->GetSum();
\r
808 list<Int_t> nUsedRows;
\r
809 nUsedRows.push_back((mp1)->GetRow());
\r
811 maxDig =(mp1)->GetAdc() ;
\r
812 maxSumAdc =(mp1)->GetSum() ;
\r
813 maxTimeBin =(mp1)->GetTime();
\r
814 maxPad =(mp1)->GetPad() ;
\r
815 maxRow =(mp1)->GetRow() ;
\r
816 maxX =(mp1)->GetX();
\r
817 maxY =(mp1)->GetY();
\r
818 maxT =(mp1)->GetT();
\r
820 AliSimDigits *digrowTmp;
\r
822 digrowTmp = (AliSimDigits*)fDigarr->GetRow(iSec,(mp1)->GetRow());
\r
824 digrowTmp = (AliSimDigits*)fDigarr->LoadRow(iSec,(mp1)->GetRow());
\r
827 digrowTmp->ExpandBuffer(); //decrunch
\r
829 for(Int_t itb=(mp1)->GetBegin(); itb<((mp1)->GetEnd())+1; itb++){
\r
830 Int_t adcTmp = digrowTmp->GetDigitUnchecked(itb,(mp1)->GetPad());
\r
831 AliTPCvtpr *vtpr=new AliTPCvtpr(adcTmp,itb,(mp1)->GetPad(),(mp1)->GetRow(),(mp1)->GetX(),(mp1)->GetY(),(mp1)->GetT());
\r
832 clusterKr.AddDigitToCluster(vtpr);
\r
834 clusterKr.SetCenter();//set centr of the cluster
\r
836 for(Int_t it2 = it1+1; it2 < entriesArr; ++it2 ) {
\r
837 AliPadMax *mp2=(AliPadMax *)maximaInSector->UncheckedAt(it2);
\r
838 if (!mp2) continue;
\r
839 if (TMath::Abs(clusterKr.GetCenterX() - (mp2)->GetX()) > fMaxPadRangeCm) continue;
\r
840 if (TMath::Abs(clusterKr.GetCenterY() - (mp2)->GetY()) > fMaxRowRangeCm) continue;
\r
841 if (TMath::Abs(clusterKr.GetCenterT() - (mp2)->GetT()) > fMaxTimeRange) continue;
\r
844 clusterValue+=(mp2)->GetSum();
\r
847 nUsedRows.push_back((mp2)->GetRow());
\r
849 AliSimDigits *digrowTmp1;
\r
851 digrowTmp1 = (AliSimDigits*)fDigarr->GetRow(iSec,(mp2)->GetRow());
\r
853 digrowTmp1 = (AliSimDigits*)fDigarr->LoadRow(iSec,(mp2)->GetRow());
\r
855 digrowTmp1->ExpandBuffer(); //decrunch
\r
857 for(Int_t itb=(mp2)->GetBegin(); itb<(mp2)->GetEnd()+1; itb++){
\r
858 Int_t adcTmp = digrowTmp1->GetDigitUnchecked(itb,(mp2)->GetPad());
\r
859 AliTPCvtpr *vtpr=new AliTPCvtpr(adcTmp,itb,(mp2)->GetPad(),(mp2)->GetRow(),(mp2)->GetX(),(mp2)->GetY(),(mp2)->GetT());
\r
860 clusterKr.AddDigitToCluster(vtpr);
\r
863 clusterKr.SetCenter();//set center of the cluster
\r
865 //which one is bigger
\r
866 if( (mp2)->GetAdc() > maxDig ){
\r
867 maxDig =(mp2)->GetAdc() ;
\r
868 maxSumAdc =(mp2)->GetSum() ;
\r
869 maxTimeBin =(mp2)->GetTime();
\r
870 maxPad =(mp2)->GetPad() ;
\r
871 maxRow =(mp2)->GetRow() ;
\r
872 maxX =(mp2)->GetX() ;
\r
873 maxY =(mp2)->GetY() ;
\r
874 maxT =(mp2)->GetT() ;
\r
875 } else if ( (mp2)->GetAdc() == maxDig ){
\r
876 if( (mp2)->GetSum() > maxSumAdc){
\r
877 maxDig =(mp2)->GetAdc() ;
\r
878 maxSumAdc =(mp2)->GetSum() ;
\r
879 maxTimeBin =(mp2)->GetTime();
\r
880 maxPad =(mp2)->GetPad() ;
\r
881 maxRow =(mp2)->GetRow() ;
\r
882 maxX =(mp2)->GetX() ;
\r
883 maxY =(mp2)->GetY() ;
\r
884 maxT =(mp2)->GetT() ;
\r
887 delete maximaInSector->RemoveAt(it2);
\r
890 delete maximaInSector->RemoveAt(it1);
\r
891 clusterKr.SetSize();
\r
892 //through out clusters on the edge and noise
\r
893 //if(clusterValue/clusterKr.fCluster.size()<fValueToSize)continue;
\r
894 if(clusterValue/(clusterKr.GetSize())<fValueToSize)continue;
\r
896 clusterKr.SetADCcluster(clusterValue);
\r
897 clusterKr.SetNPads(nUsedPads);
\r
898 clusterKr.SetMax(AliTPCvtpr(maxDig,maxTimeBin,maxPad,maxRow,maxX,maxY,maxT));
\r
899 clusterKr.SetSec(iSec);
\r
900 clusterKr.SetSize();
\r
903 nUsedRows.unique();
\r
904 clusterKr.SetNRows(nUsedRows.size());
\r
905 clusterKr.SetCenter();
\r
907 clusterKr.SetRMS();//Set pad,row,timebin RMS
\r
908 clusterKr.Set1D();//Set size in pads and timebins
\r
913 //save each cluster into file
\r
916 "Cl.="<<&clusterKr<<
\r
919 //end of save each cluster into file adc.root
\r
925 ////____________________________________________________________________________
\r
928 void AliTPCclustererKr::GetXY(Int_t sec,Int_t row,Int_t pad,Double_t& xGlob,Double_t& yGlob){
\r
930 //gives global XY coordinate of the pad
\r
933 Double_t yLocal = fParam->GetPadRowRadii(sec,row);//radius of row in sector in cm
\r
935 Int_t padmax = fParam->GetNPads(sec,row);//number of pads in a given row
\r
937 if(sec<fParam->GetNInnerSector())padXSize=0.4;
\r
939 Double_t xLocal=(pad+0.5-padmax/2.)*padXSize;//x-value of the center of pad
\r
942 fParam->AdjustCosSin((Int_t)sec,cos,sin);//return sinus and cosinus of the sector
\r
944 Double_t xGlob1 = xLocal * cos + yLocal * sin;
\r
945 Double_t yGlob1 = -xLocal * sin + yLocal * cos;
\r
949 rot=TMath::Pi()/2.;
\r
951 xGlob = xGlob1 * TMath::Cos(rot) + yGlob1 * TMath::Sin(rot);
\r
952 yGlob = -xGlob1 * TMath::Sin(rot) + yGlob1 * TMath::Cos(rot);
\r
955 if(sec<18||(sec>=36&&sec<54)) xGlob =-1*xGlob;
\r