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 ---
57 #include <TBenchmark.h>
59 // --- Standard library ---
62 // --- AliRoot header files ---
63 #include "AliRunLoader.h"
65 #include "AliEMCALLoader.h"
66 #include "AliEMCALClusterizerv1.h"
67 #include "AliEMCALRecPoint.h"
68 #include "AliEMCALDigit.h"
69 #include "AliEMCALDigitizer.h"
71 #include "AliEMCALGeometry.h"
72 #include "AliEMCALHistoUtilities.h"
73 #include "AliCDBManager.h"
74 #include "AliCDBStorage.h"
75 #include "AliCDBEntry.h"
77 ClassImp(AliEMCALClusterizerv1)
79 //____________________________________________________________________________
80 AliEMCALClusterizerv1::AliEMCALClusterizerv1() : AliEMCALClusterizer()
82 // default ctor (to be used mainly by Streamer)
85 fDefaultInit = kTRUE ;
86 fGeom = AliEMCALGeometry::GetInstance();
87 fGeom->GetTransformationForSM(); // Global <-> Local
90 //____________________________________________________________________________
91 AliEMCALClusterizerv1::AliEMCALClusterizerv1(const TString alirunFileName, const TString eventFolderName)
92 :AliEMCALClusterizer(alirunFileName, eventFolderName)
94 // ctor with the indication of the file where header Tree and digits Tree are stored
98 fDefaultInit = kFALSE ;
101 //____________________________________________________________________________
102 AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
107 //____________________________________________________________________________
108 const TString AliEMCALClusterizerv1::BranchName() const
113 //____________________________________________________________________________
114 Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t AbsId)
117 // Convert digitized amplitude into energy.
118 // Calibration parameters are taken from calibration data base for raw data,
119 // or from digitizer parameters for simulated data.
124 //We now get geometry at a higher level
127 // AliRunLoader *rl = AliRunLoader::GetRunLoader();
129 // Load EMCAL Geomtry
131 //AliRun * gAlice = rl->GetAliRun();
132 //AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
133 //AliEMCALGeometry * geom = emcal->GetGeometry();
136 AliFatal("Did not get geometry from EMCALLoader") ;
145 Bool_t bCell = fGeom->GetCellIndex(AbsId, iSupMod, nTower, nIphi, nIeta) ;
147 Error("DigitizeEnergy","Wrong cell id number") ;
148 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
150 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
151 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
152 return -fADCpedestalECA + amp * fADCchannelECA ;
155 else //Return energy with default parameters if calibration is not available
156 return -fADCpedestalECA + amp * fADCchannelECA ;
160 //____________________________________________________________________________
161 void AliEMCALClusterizerv1::Exec(Option_t * option)
163 // Steering method to perform clusterization for events
164 // in the range from fFirstEvent to fLastEvent.
165 // This range is optionally set by SetEventRange().
166 // if fLastEvent=-1 (by default), then process events until the end.
168 if(strstr(option,"tim"))
169 gBenchmark->Start("EMCALClusterizer");
171 if(strstr(option,"print"))
174 AliRunLoader *rl = AliRunLoader::GetRunLoader();
175 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
177 //Get calibration parameters from file or digitizer default values.
178 GetCalibrationParameters() ;
180 if (fLastEvent == -1)
181 fLastEvent = rl->GetNumberOfEvents() - 1;
182 Int_t nEvents = fLastEvent - fFirstEvent + 1;
185 rl->LoadDigits("EMCAL");
186 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
187 rl->GetEvent(ievent);
189 fNumberOfECAClusters = 0;
191 if(strstr(option,"pseudo"))
192 MakeClusters("pseudo") ; //both types
194 MakeClusters("") ; //only the real clusters
201 if(strstr(option,"deb"))
202 PrintRecPoints(option) ;
204 //increment the total number of recpoints per run
205 fRecPointsInRun += emcalLoader->RecPoints()->GetEntriesFast() ;
210 if(strstr(option,"tim")){
211 gBenchmark->Stop("EMCALClusterizer");
212 printf("Exec took %f seconds for Clusterizing %f seconds per event",
213 gBenchmark->GetCpuTime("EMCALClusterizer"), gBenchmark->GetCpuTime("EMCALClusterizer")/nEvents );
218 //____________________________________________________________________________
219 Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
220 Int_t nPar, Float_t * fitparameters) const
222 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
223 // The initial values for fitting procedure are set equal to the positions of local maxima.
224 // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
226 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
227 TClonesArray *digits = emcalLoader->Digits();
229 gMinuit->mncler(); // Reset Minuit's list of paramters
230 gMinuit->SetPrintLevel(-1) ; // No Printout
231 gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
232 // To set the address of the minimization function
233 TList * toMinuit = new TList();
234 toMinuit->AddAt(emcRP,0) ;
235 toMinuit->AddAt(digits,1) ;
237 gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
239 // filling initial values for fit parameters
240 AliEMCALDigit * digit ;
244 Int_t nDigits = (Int_t) nPar / 3 ;
248 for(iDigit = 0; iDigit < nDigits; iDigit++){
249 digit = maxAt[iDigit];
254 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
255 fGeom->PosInAlice(relid, x, z) ;
257 Float_t energy = maxAtEnergy[iDigit] ;
259 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
262 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
265 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
268 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
271 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
274 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
279 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
284 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
285 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
286 gMinuit->SetMaxIterations(5);
287 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
289 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
291 if(ierflg == 4){ // Minimum not found
292 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
295 for(index = 0; index < nPar; index++){
298 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
299 fitparameters[index] = val ;
307 //____________________________________________________________________________
308 void AliEMCALClusterizerv1::GetCalibrationParameters()
310 // Set calibration parameters:
311 // if calibration database exists, they are read from database,
312 // otherwise, they are taken from digitizer.
314 // It is a user responsilibity to open CDB before reconstruction,
316 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
318 //Check if calibration is stored in data base
319 if(AliCDBManager::Instance()->IsDefaultStorageSet()){
320 AliCDBEntry *entry = (AliCDBEntry*)
321 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
322 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
326 //If calibration is not available use default parameters
328 AliEMCALLoader *emcalLoader =
329 dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
330 if ( !emcalLoader->Digitizer() )
331 emcalLoader->LoadDigitizer();
332 AliEMCALDigitizer * dig = dynamic_cast<AliEMCALDigitizer*>(emcalLoader->Digitizer());
334 fADCchannelECA = dig->GetECAchannel() ;
335 fADCpedestalECA = dig->GetECApedestal();
339 //____________________________________________________________________________
340 void AliEMCALClusterizerv1::Init()
342 // Make all memory allocations which can not be done in default constructor.
343 // Attach the Clusterizer task to the list of EMCAL tasks
345 AliRunLoader *rl = AliRunLoader::GetRunLoader();
346 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
347 fGeom->GetTransformationForSM(); // Global <-> Local
348 AliInfo(Form("geom 0x%x",fGeom));
351 gMinuit = new TMinuit(100) ;
353 fHists = BookHists();
356 //____________________________________________________________________________
357 void AliEMCALClusterizerv1::InitParameters()
359 // Initializes the parameters for the Clusterizer
360 fNumberOfECAClusters = 0;
362 fNTowerInGroup = 36; //Produces maximum of 80 pseudoclusters per event
364 fECAClusteringThreshold = 0.5; // value obtained from Alexei
365 fECALocMaxCut = 0.03; // ??
370 fRecPointsInRun = 0 ;
371 fMinECut = 0.01; // have to be tune
376 //____________________________________________________________________________
377 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
379 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
381 // = 2 is in different SM, quit from searching
382 // neighbours are defined as digits having at least a common vertex
383 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
384 // which is compared to a digit (d2) not yet in a cluster
387 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
388 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
389 static Int_t rowdiff, coldiff;
392 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
393 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
394 if(nSupMod1 != nSupMod2) return 2; // different SM
396 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, iphi1,ieta1);
397 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nTower2,nIphi2,nIeta2, iphi2,ieta2);
399 rowdiff = TMath::Abs(iphi1 - iphi2);
400 coldiff = TMath::Abs(ieta1 - ieta2) ;
402 if (( coldiff <= 1 ) && ( rowdiff <= 1 )) rv = 1; // neighbours with at least commom vertex
404 if (gDebug == 2 && rv==1)
405 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
406 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
411 //____________________________________________________________________________
412 Int_t AliEMCALClusterizerv1::AreInGroup(AliEMCALDigit * d1, AliEMCALDigit * d2) const
414 // Tells whether two digits fall within the same supermodule and
415 // tower grouping. The number of towers in a group is controlled by
416 // the parameter nTowersInGroup
417 // = 0 are not in same group but continue searching
419 // = 2 is in different SM, quit from searching
420 // = 3 different tower group, quit from searching
422 // The order of d1 and d2 is important: first (d1) should be a digit
423 // already in a cluster which is compared to a digit (d2) not yet in a cluster
425 //JLK Question: does the quit from searching assume that the digits
426 //are ordered, so that once you are in a different SM, you'll not
427 //find another in the list that will match? How about my TowerGroup search?
430 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
431 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
432 static Int_t towerGroup1 = -1, towerGroup2 = -1;
435 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
436 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
437 if(nSupMod1 != nSupMod2) return 2; // different SM
439 static Int_t nTowerInSM = fGeom->GetNCellsInSupMod()/fGeom->GetNCellsInTower();
441 //figure out which tower grouping each digit belongs to
442 for(int it = 0; it < nTowerInSM/fNTowerInGroup; it++) {
443 if(nTower1 <= nTowerInSM - it*fNTowerInGroup) towerGroup1 = it;
444 if(nTower2 <= nTowerInSM - it*fNTowerInGroup) towerGroup2 = it;
446 if(towerGroup1 != towerGroup2) return 3; //different Towergroup
448 //same SM, same towergroup, we're happy
449 if(towerGroup1 == towerGroup2 && towerGroup2 >= 0)
452 if (gDebug == 2 && rv==1)
453 printf("AreInGroup: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
454 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
459 //____________________________________________________________________________
460 void AliEMCALClusterizerv1::Unload()
462 // Unloads the Digits and RecPoints
463 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
465 emcalLoader->UnloadDigits() ;
466 emcalLoader->UnloadRecPoints() ;
469 //____________________________________________________________________________
470 void AliEMCALClusterizerv1::WriteRecPoints()
473 // Creates new branches with given title
474 // fills and writes into TreeR.
476 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
478 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
480 TClonesArray * digits = emcalLoader->Digits() ;
481 TTree * treeR = emcalLoader->TreeR();
483 emcalLoader->MakeRecPointsContainer();
484 treeR = emcalLoader->TreeR();
488 //Evaluate position, dispersion and other RecPoint properties for EC section
489 for(index = 0; index < aECARecPoints->GetEntries(); index++)
490 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->EvalAll(fECAW0,digits) ;
492 aECARecPoints->Sort() ;
494 for(index = 0; index < aECARecPoints->GetEntries(); index++) {
495 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->SetIndexInList(index) ;
496 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->Print();
499 Int_t bufferSize = 32000 ;
500 Int_t splitlevel = 0 ;
504 TBranch * branchECA = 0;
505 if ((branchECA = treeR->GetBranch("EMCALECARP")))
506 branchECA->SetAddress(&aECARecPoints);
508 treeR->Branch("EMCALECARP","TObjArray",&aECARecPoints,bufferSize,splitlevel);
511 emcalLoader->WriteRecPoints("OVERWRITE");
515 //____________________________________________________________________________
516 void AliEMCALClusterizerv1::MakeClusters(char* option)
518 // Steering method to construct the clusters stored in a list of Reconstructed Points
519 // A cluster is defined as a list of neighbour digits
521 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
523 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
526 AliFatal("Did not get geometry from EMCALLoader");
528 aECARecPoints->Clear();
530 //Start with pseudoclusters, if option
531 if(strstr(option,"pseudo")) {
532 TClonesArray * digits = emcalLoader->Digits() ;
533 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
535 TIter nextdigit(digitsC) ;
536 AliEMCALDigit * digit;
538 AliEMCALRecPoint * recPoint = 0 ;
542 // PseudoClusterization starts
543 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
545 TArrayI clusterECAdigitslist(1000); // what is this
547 if(fGeom->CheckAbsCellId(digit->GetId()) ) { //Is this an EMCAL digit? Just maing sure...
548 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
549 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
550 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
551 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
552 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
553 fNumberOfECAClusters++ ;
555 recPoint->SetClusterType(AliEMCALRecPoint::kPseudoCluster);
557 recPoint->AddDigit(*digit, digit->GetAmp()) ;
558 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
559 iDigitInECACluster++ ;
560 digitsC->Remove(digit) ;
561 AliDebug(1,Form("MakePseudoClusters: OK id = %d, adc = %f \n", digit->GetId(), digit->GetAmp()));
562 nextdigit.Reset(); // will start from beggining
564 AliEMCALDigit * digitN = 0; // digi neighbor
567 // Find the neighbours
568 while (index < iDigitInECACluster){ // scan over digits already in cluster
569 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
571 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
572 ineb = AreInGroup(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
574 case 0 : // not a neighbour
576 case 1 : // are neighbours
577 recPoint->AddDigit(*digitN, digitN->GetAmp() ) ;
578 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
579 iDigitInECACluster++ ;
580 digitsC->Remove(digitN) ;
582 case 2 : // different SM
584 case 3 : // different Tower group
587 } // scan over the reduced list of digits
588 } // scan over digits already in cluster
589 nextdigit.Reset() ; // will start from beggining
592 if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
596 //Now do real clusters
597 TClonesArray * digits = emcalLoader->Digits() ;
598 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
600 TIter nextdigit(digitsC) ;
601 AliEMCALDigit * digit;
603 AliEMCALRecPoint * recPoint = 0 ;
607 double e=0.0, ehs = 0.0;
608 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // clean up digits
609 e = Calibrate(digit->GetAmp(), digit->GetId());
610 AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
611 AliEMCALHistoUtilities::FillH1(fHists, 11, e);
612 if(e < fMinECut ) digitsC->Remove(digit);
615 cout << " Number of digits " << digits->GetEntries() << " -> (e>" <<fMinECut <<")";
616 cout << digitsC->GetEntries()<< " ehs "<<ehs<<endl;
618 // Clusterization starts
619 // cout << "Outer Loop" << endl;
623 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
625 TArrayI clusterECAdigitslist(1000); // what is this
627 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
628 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
629 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
630 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
631 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
632 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
633 fNumberOfECAClusters++ ;
635 recPoint->SetClusterType(AliEMCALRecPoint::kClusterv1);
637 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
638 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
639 iDigitInECACluster++ ;
640 digitsC->Remove(digit) ;
641 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , thre = %f \n", digit->GetId(),
642 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
643 nextdigit.Reset(); // will start from beggining
645 AliEMCALDigit * digitN = 0; // digi neighbor
648 // Find the neighbours
649 while (index < iDigitInECACluster){ // scan over digits already in cluster
650 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
652 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
653 ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
655 case 0 : // not a neighbour
657 case 1 : // are neighbours
658 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
659 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
660 iDigitInECACluster++ ;
661 digitsC->Remove(digitN) ;
663 case 2 : // different SM
666 } // scan over the reduced list of digits
667 } // scan over digits already in cluster
668 nextdigit.Reset() ; // will start from beggining
671 if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
674 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,digits->GetEntriesFast()));
677 //____________________________________________________________________________
678 void AliEMCALClusterizerv1::MakeUnfolding() const
680 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
684 //____________________________________________________________________________
685 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
687 // Shape of the shower (see EMCAL TDR)
688 // If you change this function, change also the gradient evaluation in ChiSquare()
690 Double_t r4 = r*r*r*r ;
691 Double_t r295 = TMath::Power(r, 2.95) ;
692 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
696 //____________________________________________________________________________
697 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * /*iniTower*/,
699 AliEMCALDigit ** /*maxAt*/,
700 Float_t * /*maxAtEnergy*/) const
702 // Performs the unfolding of a cluster with nMax overlapping showers
704 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
708 //_____________________________________________________________________________
709 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
711 Double_t * /*x*/, Int_t /*iflag*/)
713 // Calculates the Chi square for the cluster unfolding minimization
714 // Number of parameters, Gradient, Chi squared, parameters, what to do
716 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
718 //____________________________________________________________________________
719 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
721 // Print clusterizer parameters
723 TString message("\n") ;
725 if( strcmp(GetName(), "") !=0 ){
729 TString taskName(GetName()) ;
730 taskName.ReplaceAll(Version(), "") ;
732 printf("--------------- ");
733 printf(taskName.Data()) ;
736 printf("-----------\n");
737 printf("Clusterizing digits from the file: ");
738 printf(taskName.Data());
739 printf("\n Branch: ");
741 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
742 printf("\n ECA Logarithmic weight = %f", fECAW0);
744 printf("\nUnfolding on\n");
746 printf("\nUnfolding off\n");
748 printf("------------------------------------------------------------------");
751 printf("AliEMCALClusterizerv1 not initialized ") ;
754 //____________________________________________________________________________
755 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
757 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
758 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
759 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
761 printf("PrintRecPoints: Clusterization result:") ;
763 printf("event # %d\n", emcalLoader->GetRunLoader()->GetEventNumber() ) ;
764 printf(" Found %d ECA Rec Points\n ",
765 aECARecPoints->GetEntriesFast()) ;
767 fRecPointsInRun += aECARecPoints->GetEntriesFast() ;
769 if(strstr(option,"all")) {
771 printf("\n-----------------------------------------------------------------------\n") ;
772 printf("Clusters in ECAL section\n") ;
773 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
779 for (index = 0 ; index < aECARecPoints->GetEntries() ; index++) {
780 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(aECARecPoints->At(index)) ;
782 //rp->GetGlobalPosition(globalpos);
784 rp->GetLocalPosition(localpos);
786 rp->GetElipsAxis(lambda);
789 primaries = rp->GetPrimaries(nprimaries);
790 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
791 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
792 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
793 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
795 if(rp->GetEnergy()>maxE){
796 maxE=rp->GetEnergy();
799 maxDis=rp->GetDispersion();
801 fPointE->Fill(rp->GetEnergy());
802 fPointL1->Fill(lambda[0]);
803 fPointL2->Fill(lambda[1]);
804 fPointDis->Fill(rp->GetDispersion());
805 fPointMult->Fill(rp->GetMultiplicity());
807 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
808 printf("%d ", primaries[iprimary] ) ;
815 fMaxDis->Fill(maxDis);
818 printf("\n-----------------------------------------------------------------------\n");
821 TList* AliEMCALClusterizerv1::BookHists()
823 //set up histograms for monitoring clusterizer performance
827 fPointE = new TH1F("pointE","point energy", 2000, 0.0, 150.);
828 fPointL1 = new TH1F("pointL1","point L1", 1000, 0.0, 3.);
829 fPointL2 = new TH1F("pointL2","point L2", 1000, 0.0, 3.);
830 fPointDis = new TH1F("pointDis","point Dis", 1000, 0.0, 3.);
831 fPointMult = new TH1F("pointMult","point Mult", 100, 0.0, 100.);
832 fDigitAmp = new TH1F("digitAmp","Digit Amplitude", 2000, 0.0, 5000.);
833 fMaxE = new TH1F("maxE","Max point energy", 2000, 0.0, 150.);
834 fMaxL1 = new TH1F("maxL1","Max point L1", 1000, 0.0, 3.);
835 fMaxL2 = new TH1F("maxL2","Max point L2", 1000, 0.0, 3.);
836 fMaxDis = new TH1F("maxDis","Max point Dis", 1000, 0.0, 3.); // 9
838 new TH1F("adcOfDigits","adc of digits(threshold control)", 1001, -0.5, 1000.5); // 10
839 new TH1F("energyOfDigits","energy of digits(threshold control)", 1000, 0.0, 1.); // 11
841 return AliEMCALHistoUtilities::MoveHistsToList("EmcalClusterizerv1ControlHists", kFALSE);
844 void AliEMCALClusterizerv1::SaveHists(const char *fn)
846 AliEMCALHistoUtilities::SaveListOfHists(fHists, fn, kTRUE);
849 void AliEMCALClusterizerv1::Browse(TBrowser* b)
851 if(fHists) b->Add(fHists);