1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
18 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
19 // August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
20 // of new IO (à la PHOS)
21 //////////////////////////////////////////////////////////////////////////////
22 // Clusterization class. Performs clusterization (collects neighbouring active cells) and
23 // unfolds the clusters having several local maxima.
24 // Results are stored in TreeR#, branches EMCALTowerRP (EMC recPoints),
25 // EMCALPreShoRP (CPV RecPoints) and AliEMCALClusterizer (Clusterizer with all
26 // parameters including input digits branch title, thresholds etc.)
27 // This TTask is normally called from Reconstructioner, but can as well be used in
30 // root [0] AliEMCALClusterizerv1 * cl = new AliEMCALClusterizerv1("galice.root")
31 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
32 // //reads gAlice from header file "..."
33 // root [1] cl->ExecuteTask()
34 // //finds RecPoints in all events stored in galice.root
35 // root [2] cl->SetDigitsBranch("digits2")
36 // //sets another title for Digitis (input) branch
37 // root [3] cl->SetRecPointsBranch("recp2")
38 // //sets another title four output branches
39 // root [4] cl->SetTowerLocalMaxCut(0.03)
40 // //set clusterization parameters
41 // root [5] cl->ExecuteTask("deb all time")
42 // //once more finds RecPoints options are
43 // // deb - print number of found rec points
44 // // deb all - print number of found RecPoints and some their characteristics
45 // // time - print benchmarking results
47 // --- ROOT system ---
56 #include "TBenchmark.h"
58 // --- Standard library ---
61 // --- AliRoot header files ---
62 #include "AliEMCALGetter.h"
63 #include "AliEMCALClusterizerv1.h"
64 #include "AliEMCALTowerRecPoint.h"
65 #include "AliEMCALDigit.h"
66 #include "AliEMCALDigitizer.h"
68 #include "AliEMCALGeometry.h"
70 ClassImp(AliEMCALClusterizerv1)
72 //____________________________________________________________________________
73 AliEMCALClusterizerv1::AliEMCALClusterizerv1() : AliEMCALClusterizer()
75 // default ctor (to be used mainly by Streamer)
78 fDefaultInit = kTRUE ;
81 //____________________________________________________________________________
82 AliEMCALClusterizerv1::AliEMCALClusterizerv1(const TString alirunFileName, const TString eventFolderName)
83 :AliEMCALClusterizer(alirunFileName, eventFolderName)
85 // ctor with the indication of the file where header Tree and digits Tree are stored
89 fDefaultInit = kFALSE ;
93 //____________________________________________________________________________
94 AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
100 //____________________________________________________________________________
101 const TString AliEMCALClusterizerv1::BranchName() const
107 //____________________________________________________________________________
108 Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t where) const
110 //To be replased later by the method, reading individual parameters from the database
111 // where = 0 == PRE ; where = 1 == ECAL ; where = 2 == HCAL
112 if ( where == 0 ) // calibrate as PRE section
113 return -fADCpedestalPRE + amp * fADCchannelPRE ;
114 else if (where == 1) //calibrate as ECA section
115 return -fADCpedestalECA + amp * fADCchannelECA ;
116 else if (where == 2) //calibrate as HCA section
117 return -fADCpedestalHCA + amp * fADCchannelHCA ;
119 Fatal("Calibrate", "Something went wrong!") ;
123 //____________________________________________________________________________
124 void AliEMCALClusterizerv1::Exec(Option_t * option)
128 if(strstr(option,"tim"))
129 gBenchmark->Start("EMCALClusterizer");
131 if(strstr(option,"print"))
134 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
136 Int_t nevents = gime->MaxEvent() ;
139 for(ievent = 0; ievent < nevents; ievent++){
141 gime->Event(ievent,"D") ;
143 GetCalibrationParameters() ;
145 fNumberOfPREClusters = fNumberOfECAClusters = fNumberOfHCAClusters = 0 ;
154 if(strstr(option,"deb"))
155 PrintRecPoints(option) ;
157 //increment the total number of recpoints per run
158 fRecPointsInRun += gime->PRERecPoints()->GetEntriesFast() ;
159 fRecPointsInRun += gime->ECARecPoints()->GetEntriesFast() ;
160 fRecPointsInRun += gime->HCARecPoints()->GetEntriesFast() ;
165 if(strstr(option,"tim")){
166 gBenchmark->Stop("EMCALClusterizer");
167 Info("Exec", "took %f seconds for Clusterizing %f seconds per event",
168 gBenchmark->GetCpuTime("EMCALClusterizer"), gBenchmark->GetCpuTime("EMCALClusterizer")/nevents ) ;
172 //____________________________________________________________________________
173 Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALTowerRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
174 Int_t nPar, Float_t * fitparameters) const
176 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
177 // The initial values for fitting procedure are set equal to the positions of local maxima.
178 // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
180 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
181 TClonesArray * digits = gime->Digits() ;
184 gMinuit->mncler(); // Reset Minuit's list of paramters
185 gMinuit->SetPrintLevel(-1) ; // No Printout
186 gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
187 // To set the address of the minimization function
188 TList * toMinuit = new TList();
189 toMinuit->AddAt(emcRP,0) ;
190 toMinuit->AddAt(digits,1) ;
192 gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
194 // filling initial values for fit parameters
195 AliEMCALDigit * digit ;
199 Int_t nDigits = (Int_t) nPar / 3 ;
203 AliEMCALGeometry * geom = gime->EMCALGeometry() ;
205 for(iDigit = 0; iDigit < nDigits; iDigit++){
206 digit = maxAt[iDigit];
211 geom->AbsToRelNumbering(digit->GetId(), relid) ;
212 geom->PosInAlice(relid, x, z) ;
214 Float_t energy = maxAtEnergy[iDigit] ;
216 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
219 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
222 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
225 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
228 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
231 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
236 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
241 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
242 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
243 gMinuit->SetMaxIterations(5);
244 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
246 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
248 if(ierflg == 4){ // Minimum not found
249 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
252 for(index = 0; index < nPar; index++){
255 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
256 fitparameters[index] = val ;
264 //____________________________________________________________________________
265 void AliEMCALClusterizerv1::GetCalibrationParameters()
267 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
269 if ( !gime->Digitizer() )
270 gime->LoadDigitizer();
271 AliEMCALDigitizer * dig = gime->Digitizer();
273 fADCchannelPRE = dig->GetPREchannel() ;
274 fADCpedestalPRE = dig->GetPREpedestal() ;
276 fADCchannelECA = dig->GetECAchannel() ;
277 fADCpedestalECA = dig->GetECApedestal();
279 fADCchannelHCA = dig->GetHCAchannel() ;
280 fADCpedestalHCA = dig->GetHCApedestal();
283 //____________________________________________________________________________
284 void AliEMCALClusterizerv1::Init()
286 // Make all memory allocations which can not be done in default constructor.
287 // Attach the Clusterizer task to the list of EMCAL tasks
289 AliEMCALGetter * gime = AliEMCALGetter::Instance(GetTitle(), fEventFolderName.Data());
291 AliEMCALGeometry * geom = gime->EMCALGeometry() ;
293 fNTowers = geom->GetNZ() * geom->GetNPhi() ;
295 gMinuit = new TMinuit(100) ;
297 if ( !gime->Clusterizer() )
298 gime->PostClusterizer(this);
301 //____________________________________________________________________________
302 void AliEMCALClusterizerv1::InitParameters()
304 fNumberOfPREClusters = fNumberOfECAClusters = fNumberOfHCAClusters = 0 ;
305 fPREClusteringThreshold = 0.0001; // must be adjusted according to the noise leve set by digitizer
306 fECAClusteringThreshold = 0.0045; // must be adjusted according to the noise leve set by digitizer
307 fHCAClusteringThreshold = 0.001; // must be adjusted according to the noise leve set by digitizer
308 fPRELocMaxCut = 0.03 ;
309 fECALocMaxCut = 0.03 ;
310 fHCALocMaxCut = 0.03 ;
320 fRecPointsInRun = 0 ;
324 //____________________________________________________________________________
325 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2)const
327 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
329 // = 2 are not neighbour but do not continue searching
330 // neighbours are defined as digits having at least a common vertex
331 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
332 // which is compared to a digit (d2) not yet in a cluster
334 AliEMCALGeometry * geom = AliEMCALGetter::Instance()->EMCALGeometry() ;
339 geom->AbsToRelNumbering(d1->GetId(), relid1) ;
342 geom->AbsToRelNumbering(d2->GetId(), relid2) ;
344 if ( (relid1[0] == relid2[0]) && // inside the same EMCAL Arm
345 (relid1[1]==relid2[1]) ) { // and same tower section
346 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
347 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
349 if (( coldiff <= 1 ) && ( rowdiff <= 1 )){
350 if((relid1[1] != 0) || (TMath::Abs(d1->GetTime() - d2->GetTime() ) < fTimeGate))
354 if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
355 rv = 2; // Difference in row numbers is too large to look further
361 if( (relid1[0] < relid2[0]) || (relid1[1] != relid2[1]) )
366 Info("AreNeighbours", "neighbours=%d, id1=%d, relid1=%d,%d,%d,%d \n id2=%d, relid2=%d,%d,%d,%d",
367 rv, d1->GetId(), relid1[0], relid1[1], relid1[2], relid1[3],
368 d2->GetId(), relid2[0], relid2[1], relid2[2], relid2[3]) ;
373 //____________________________________________________________________________
374 void AliEMCALClusterizerv1::Unload()
376 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
377 gime->EmcalLoader()->UnloadDigits() ;
378 gime->EmcalLoader()->UnloadRecPoints() ;
381 //____________________________________________________________________________
382 void AliEMCALClusterizerv1::WriteRecPoints()
385 // Creates new branches with given title
386 // fills and writes into TreeR.
388 AliEMCALGetter *gime = AliEMCALGetter::Instance() ;
390 TObjArray * aPRERecPoints = gime->PRERecPoints() ;
391 TObjArray * aECARecPoints = gime->ECARecPoints() ;
392 TObjArray * aHCARecPoints = gime->HCARecPoints() ;
394 TClonesArray * digits = gime->Digits() ;
395 TTree * treeR = gime->TreeR(); ;
399 //Evaluate position, dispersion and other RecPoint properties for PRE section
400 for(index = 0; index < aPRERecPoints->GetEntries(); index++)
401 (dynamic_cast<AliEMCALRecPoint *>(aPRERecPoints->At(index)))->EvalAll(fPREW0,digits) ;
402 aPRERecPoints->Sort() ;
404 for(index = 0; index < aPRERecPoints->GetEntries(); index++)
405 (dynamic_cast<AliEMCALRecPoint *>(aPRERecPoints->At(index)))->SetIndexInList(index) ;
407 aPRERecPoints->Expand(aPRERecPoints->GetEntriesFast()) ;
409 //Evaluate position, dispersion and other RecPoint properties for EC section
410 for(index = 0; index < aECARecPoints->GetEntries(); index++)
411 (dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(index)))->EvalAll(fECAW0,digits) ;
413 aECARecPoints->Sort() ;
415 for(index = 0; index < aECARecPoints->GetEntries(); index++)
416 (dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(index)))->SetIndexInList(index) ;
418 aECARecPoints->Expand(aECARecPoints->GetEntriesFast()) ;
420 //Evaluate position, dispersion and other RecPoint properties for HCA section
421 for(index = 0; index < aHCARecPoints->GetEntries(); index++)
422 (dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(index)))->EvalAll(fHCAW0,digits) ;
424 aHCARecPoints->Sort() ;
426 for(index = 0; index < aHCARecPoints->GetEntries(); index++)
427 (dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(index)))->SetIndexInList(index) ;
429 aHCARecPoints->Expand(aHCARecPoints->GetEntriesFast()) ;
431 Int_t bufferSize = 32000 ;
432 Int_t splitlevel = 0 ;
435 TBranch * branchPRE = treeR->Branch("EMCALPRERP","TObjArray",&aPRERecPoints,bufferSize,splitlevel);
436 branchPRE->SetTitle(BranchName());
439 TBranch * branchECA = treeR->Branch("EMCALECARP","TObjArray",&aECARecPoints,bufferSize,splitlevel);
440 branchECA->SetTitle(BranchName());
443 TBranch * branchHCA = treeR->Branch("EMCALHCARP","TObjArray",&aHCARecPoints,bufferSize,splitlevel);
444 branchHCA->SetTitle(BranchName());
450 gime->WriteRecPoints("OVERWRITE");
451 gime->WriteClusterizer("OVERWRITE");
454 //____________________________________________________________________________
455 void AliEMCALClusterizerv1::MakeClusters()
457 // Steering method to construct the clusters stored in a list of Reconstructed Points
458 // A cluster is defined as a list of neighbour digits
460 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
462 AliEMCALGeometry * geom = gime->EMCALGeometry() ;
465 TObjArray * aPRERecPoints = gime->PRERecPoints() ;
466 TObjArray * aECARecPoints = gime->ECARecPoints() ;
467 TObjArray * aHCARecPoints = gime->HCARecPoints() ;
469 aPRERecPoints->Delete() ;
470 aECARecPoints->Delete() ;
471 aHCARecPoints->Delete() ;
473 TClonesArray * digits = gime->Digits() ;
476 AliEMCALDigit * digit ;
477 Int_t ndigECA=0, ndigPRE=0, ndigHCA=0 ;
479 // count the number of digits in ECA section
480 while ( (digit = dynamic_cast<AliEMCALDigit *>(next())) ) { // scan over the list of digits
481 if (geom->IsInECA(digit->GetId()))
483 else if (geom->IsInPRE(digit->GetId()))
485 else if (geom->IsInHCA(digit->GetId()))
488 Error("MakeClusters", "id = %d is a wrong ID!", digit->GetId()) ;
493 // add amplitude of PRE and ECA sections
495 for (digECA = 0 ; digECA < ndigECA ; digECA++) {
496 digit = dynamic_cast<AliEMCALDigit *>(digits->At(digECA)) ;
498 for (digPRE = ndigECA ; digPRE < ndigECA+ndigPRE ; digPRE++) {
499 AliEMCALDigit * digitPRE = dynamic_cast<AliEMCALDigit *>(digits->At(digPRE)) ;
500 if ( geom->AreInSameTower(digit->GetId(), digitPRE->GetId()) ){
501 Float_t amp = static_cast<Float_t>(digit->GetAmp()) + geom->GetSummationFraction() * static_cast<Float_t>(digitPRE->GetAmp()) + 0.5 ;
502 digit->SetAmp(static_cast<Int_t>(amp)) ;
507 Info("MakeClusters","id = %d amp = %d", digit->GetId(), digit->GetAmp()) ;
510 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone()) ;
513 // Clusterization starts
515 TIter nextdigit(digitsC) ;
516 Bool_t notremovedECA = kTRUE, notremovedPRE = kTRUE ;
518 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
519 AliEMCALRecPoint * clu = 0 ;
521 TArrayI clusterPREdigitslist(50), clusterECAdigitslist(50), clusterHCAdigitslist(50);
523 Bool_t inPRE = kFALSE, inECA = kFALSE, inHCA = kFALSE ;
524 if( geom->IsInPRE(digit->GetId()) ) {
527 else if( geom->IsInECA(digit->GetId()) ) {
530 else if( geom->IsInHCA(digit->GetId()) ) {
536 Info("MakeClusters","id = %d, ene = %f , thre = %f ",
537 digit->GetId(),Calibrate(digit->GetAmp(), 0), fPREClusteringThreshold) ;
539 Info("MakeClusters","id = %d, ene = %f , thre = %f",
540 digit->GetId(),Calibrate(digit->GetAmp(), 1), fECAClusteringThreshold) ;
542 Info("MakeClusters","id = %d, ene = %f , thre = %f",
543 digit->GetId(),Calibrate(digit->GetAmp(), 2), fHCAClusteringThreshold ) ;
546 if ( (inPRE && (Calibrate(digit->GetAmp(), 0) > fPREClusteringThreshold )) ||
547 (inECA && (Calibrate(digit->GetAmp(), 1) > fECAClusteringThreshold )) ||
548 (inHCA && (Calibrate(digit->GetAmp(), 2) > fHCAClusteringThreshold )) ) {
550 Int_t iDigitInPRECluster = 0, iDigitInECACluster = 0, iDigitInHCACluster = 0;
551 Int_t where ; // PRE = 0, ECAl = 1, HCAL = 2
553 // Find the seed in each of the section ECAL/PRE/HCAL
555 if( geom->IsInECA(digit->GetId()) ) {
556 where = 1 ; // to tell we are in ECAL
557 // start a new Tower RecPoint
558 if(fNumberOfECAClusters >= aECARecPoints->GetSize())
559 aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
560 AliEMCALTowerRecPoint * rp = new AliEMCALTowerRecPoint("") ;
562 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
563 clu = dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
564 fNumberOfECAClusters++ ;
565 clu->AddDigit(*digit, Calibrate(digit->GetAmp(), where)) ;
566 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
567 iDigitInECACluster++ ;
568 digitsC->Remove(digit) ;
570 Info("MakeClusters","OK id = %d, ene = %f , thre = %f ", digit->GetId(),Calibrate(digit->GetAmp(), 1), fECAClusteringThreshold) ;
573 else if( geom->IsInPRE(digit->GetId()) ) {
574 where = 0 ; // to tell we are in PRE
575 // start a new Pre Shower cluster
576 if(fNumberOfPREClusters >= aPRERecPoints->GetSize())
577 aPRERecPoints->Expand(2*fNumberOfPREClusters+1);
578 AliEMCALTowerRecPoint * rp = new AliEMCALTowerRecPoint("") ;
580 aPRERecPoints->AddAt(rp, fNumberOfPREClusters) ;
581 clu = dynamic_cast<AliEMCALTowerRecPoint *>(aPRERecPoints->At(fNumberOfPREClusters)) ;
582 fNumberOfPREClusters++ ;
583 clu->AddDigit(*digit, Calibrate(digit->GetAmp(), where));
584 clusterPREdigitslist[iDigitInPRECluster] = digit->GetIndexInList() ;
585 iDigitInPRECluster++ ;
586 digitsC->Remove(digit) ;
588 Info("MakeClusters","OK id = %d, ene = %f , thre = %f ", digit->GetId(),Calibrate(digit->GetAmp(), 0), fPREClusteringThreshold) ;
592 // Here we remove remaining ECA digits, which cannot make a cluster
594 if( notremovedECA ) {
595 while( ( digit = dynamic_cast<AliEMCALDigit *>(nextdigit()) ) ) {
596 if( geom->IsInECA(digit->GetId()) )
597 digitsC->Remove(digit) ;
601 notremovedECA = kFALSE ;
605 else if( geom->IsInHCA(digit->GetId()) ) {
606 where = 2 ; // to tell we are in HCAL
607 // start a new HCAL cluster
608 if(fNumberOfHCAClusters >= aHCARecPoints->GetSize())
609 aHCARecPoints->Expand(2*fNumberOfHCAClusters+1);
610 AliEMCALTowerRecPoint * rp = new AliEMCALTowerRecPoint("") ;
612 aHCARecPoints->AddAt(rp, fNumberOfHCAClusters) ;
613 clu = dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(fNumberOfHCAClusters)) ;
614 fNumberOfHCAClusters++ ;
615 clu->AddDigit(*digit, Calibrate(digit->GetAmp(), where));
616 clusterHCAdigitslist[iDigitInHCACluster] = digit->GetIndexInList() ;
617 iDigitInHCACluster++ ;
618 digitsC->Remove(digit) ;
620 Info("MakeClusters","OK id = %d, ene = %f , thre = %f ", digit->GetId(),Calibrate(digit->GetAmp(), 2), fHCAClusteringThreshold) ;
624 // Here we remove remaining PRE digits, which cannot make a cluster
626 if( notremovedPRE ) {
627 while( ( digit = dynamic_cast<AliEMCALDigit *>(nextdigit()) ) ) {
628 if( geom->IsInPRE(digit->GetId()) )
629 digitsC->Remove(digit) ;
633 notremovedPRE = kFALSE ;
639 AliEMCALDigit * digitN ;
642 // Do the Clustering in each of the three section ECAL/PRE/HCAL
644 while (index < iDigitInECACluster){ // scan over digits already in cluster
645 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]) ;
647 while ( (digitN = (AliEMCALDigit *)nextdigit()) ) { // scan over the reduced list of digits
648 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
649 // Info("MakeClusters","id1 = %d, id2 = %d , neighbours = %d", digit->GetId(), digitN->GetId(), ineb) ;
651 case 0 : // not a neighbour
653 case 1 : // are neighbours
654 clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), 1) ) ;
655 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
656 iDigitInECACluster++ ;
657 digitsC->Remove(digitN) ;
659 case 2 : // too far from each other
667 } // loop over ECA cluster
670 while (index < iDigitInPRECluster){ // scan over digits already in cluster
671 digit = (AliEMCALDigit*)digits->At(clusterPREdigitslist[index]) ;
673 while ( (digitN = (AliEMCALDigit *)nextdigit()) ) { // scan over the reduced list of digits
674 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
675 // Info("MakeClusters","id1 = %d, id2 = %d , neighbours = %d", digit->GetId(), digitN->GetId(), ineb) ;
677 case 0 : // not a neighbour
679 case 1 : // are neighbours
680 clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), 0) ) ;
681 clusterPREdigitslist[iDigitInPRECluster] = digitN->GetIndexInList() ;
682 iDigitInPRECluster++ ;
683 digitsC->Remove(digitN) ;
685 case 2 : // too far from each other
693 } // loop over PRE cluster
696 while (index < iDigitInHCACluster){ // scan over digits already in cluster
697 digit = (AliEMCALDigit*)digits->At(clusterHCAdigitslist[index]) ;
699 while ( (digitN = (AliEMCALDigit *)nextdigit()) ) { // scan over the reduced list of digits
700 Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
701 //Info("MakeClusters","id1 = %d, id2 = %d , neighbours = %d", digit->GetId(), digitN->GetId(), ineb) ;
703 case 0 : // not a neighbour
705 case 1 : // are neighbours
706 clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), 2) ) ;
707 clusterHCAdigitslist[iDigitInHCACluster] = digitN->GetIndexInList() ;
708 iDigitInHCACluster++ ;
709 digitsC->Remove(digitN) ;
711 case 2 : // too far from each other
718 } // loop over HCA cluster
725 //____________________________________________________________________________
726 void AliEMCALClusterizerv1::MakeUnfolding()
728 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
732 //____________________________________________________________________________
733 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
735 // Shape of the shower (see EMCAL TDR)
736 // If you change this function, change also the gradient evaluation in ChiSquare()
738 Double_t r4 = r*r*r*r ;
739 Double_t r295 = TMath::Power(r, 2.95) ;
740 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
744 //____________________________________________________________________________
745 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALTowerRecPoint * /*iniTower*/,
747 AliEMCALDigit ** /*maxAt*/,
748 Float_t * /*maxAtEnergy*/)
750 // Performs the unfolding of a cluster with nMax overlapping showers
752 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
756 //_____________________________________________________________________________
757 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
759 Double_t * /*x*/, Int_t /*iflag*/)
761 // Calculates the Chi square for the cluster unfolding minimization
762 // Number of parameters, Gradient, Chi squared, parameters, what to do
764 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
766 //____________________________________________________________________________
767 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
769 // Print clusterizer parameters
771 TString message("\n") ;
773 if( strcmp(GetName(), "") !=0 ){
777 TString taskName(GetName()) ;
778 taskName.ReplaceAll(Version(), "") ;
780 message += "--------------- " ;
781 message += taskName.Data() ;
783 message += GetTitle() ;
784 message += "-----------\n" ;
785 message += "Clusterizing digits from the file: " ;
786 message += taskName.Data() ;
787 message += "\n Branch: " ;
788 message += GetName() ;
789 message += "\n Pre Shower Clustering threshold = " ;
790 message += fPREClusteringThreshold ;
791 message += "\n Pre Shower Local Maximum cut = " ;
792 message += fPRELocMaxCut ;
793 message += "\n Pre Shower Logarothmic weight = " ;
795 message += "\n ECA Clustering threshold = " ;
796 message += fECAClusteringThreshold ;
797 message += "\n ECA Local Maximum cut = " ;
798 message += fECALocMaxCut ;
799 message += "\n ECA Logarothmic weight = " ;
801 message += "\n Pre Shower Clustering threshold = " ;
802 message += fHCAClusteringThreshold ;
803 message += "\n HCA Local Maximum cut = " ;
804 message += fHCALocMaxCut ;
805 message += "\n HCA Logarothmic weight = " ;
808 message +="\nUnfolding on\n" ;
810 message += "\nUnfolding off\n";
812 message += "------------------------------------------------------------------" ;
815 message += "AliEMCALClusterizerv1 not initialized " ;
817 Info("Print", message.Data() ) ;
820 //____________________________________________________________________________
821 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
823 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
825 TObjArray * aPRERecPoints = AliEMCALGetter::Instance()->PRERecPoints() ;
826 TObjArray * aECARecPoints = AliEMCALGetter::Instance()->ECARecPoints() ;
827 TObjArray * aHCARecPoints = AliEMCALGetter::Instance()->HCARecPoints() ;
829 Info("PrintRecPoints", "Clusterization result:") ;
831 printf("event # %d\n", gAlice->GetEvNumber() ) ;
832 printf(" Found %d PRE SHOWER RecPoints, %d ECA Rec Points and %d HCA Rec Points\n ",
833 aPRERecPoints->GetEntriesFast(), aECARecPoints->GetEntriesFast(), aHCARecPoints->GetEntriesFast() ) ;
835 fRecPointsInRun += aPRERecPoints->GetEntriesFast() ;
836 fRecPointsInRun += aECARecPoints->GetEntriesFast() ;
837 fRecPointsInRun += aHCARecPoints->GetEntriesFast() ;
839 if(strstr(option,"all")) {
841 //Pre shower recPoints
843 printf("-----------------------------------------------------------------------\n") ;
844 printf("Clusters in PRE section\n") ;
845 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
849 for (index = 0 ; index < aPRERecPoints->GetEntries() ; index++) {
850 AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint *>(aPRERecPoints->At(index)) ;
852 rp->GetGlobalPosition(globalpos);
854 rp->GetLocalPosition(localpos);
856 rp->GetElipsAxis(lambda);
859 primaries = rp->GetPrimaries(nprimaries);
860 printf("\n%6d %8.4f %3d %2d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
861 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(), rp->GetEMCALArm(),
862 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
863 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
864 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
865 printf("%d ", primaries[iprimary] ) ;
869 printf("\n-----------------------------------------------------------------------\n") ;
870 printf("Clusters in ECAL section\n") ;
871 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
873 for (index = 0 ; index < aECARecPoints->GetEntries() ; index++) {
874 AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint * >(aECARecPoints->At(index)) ;
876 rp->GetGlobalPosition(globalpos);
878 rp->GetLocalPosition(localpos);
880 rp->GetElipsAxis(lambda);
883 primaries = rp->GetPrimaries(nprimaries);
884 printf("\n%6d %8.4f %3d %2d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
885 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(), rp->GetEMCALArm(),
886 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
887 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
888 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
889 printf("%d ", primaries[iprimary] ) ;
893 printf("\n-----------------------------------------------------------------------\n") ;
894 printf("Clusters in HCAL section\n") ;
895 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
897 for (index = 0 ; index < aHCARecPoints->GetEntries() ; index++) {
898 AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint * >(aHCARecPoints->At(index)) ;
900 rp->GetGlobalPosition(globalpos);
902 rp->GetLocalPosition(localpos);
904 rp->GetElipsAxis(lambda);
907 primaries = rp->GetPrimaries(nprimaries);
908 printf("\n%6d %8.4f %3d %2d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
909 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(), rp->GetEMCALArm(),
910 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
911 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
912 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
913 printf("%d ", primaries[iprimary] ) ;
917 printf("\n-----------------------------------------------------------------------\n");