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*) AliCDBManager::Instance()
321 ->GetDefaultStorage()
322 ->Get("EMCAL/GainFactors_and_Pedestals/Calibration",
323 gAlice->GetRunNumber());
324 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
328 //If calibration is not available use default parameters
330 AliEMCALLoader *emcalLoader =
331 dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
332 if ( !emcalLoader->Digitizer() )
333 emcalLoader->LoadDigitizer();
334 AliEMCALDigitizer * dig = dynamic_cast<AliEMCALDigitizer*>(emcalLoader->Digitizer());
336 fADCchannelECA = dig->GetECAchannel() ;
337 fADCpedestalECA = dig->GetECApedestal();
341 //____________________________________________________________________________
342 void AliEMCALClusterizerv1::Init()
344 // Make all memory allocations which can not be done in default constructor.
345 // Attach the Clusterizer task to the list of EMCAL tasks
347 AliRunLoader *rl = AliRunLoader::GetRunLoader();
348 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
349 fGeom->GetTransformationForSM(); // Global <-> Local
350 AliInfo(Form("geom 0x%x",fGeom));
353 gMinuit = new TMinuit(100) ;
355 fHists = BookHists();
358 //____________________________________________________________________________
359 void AliEMCALClusterizerv1::InitParameters()
361 // Initializes the parameters for the Clusterizer
362 fNumberOfECAClusters = 0;
364 fNTowerInGroup = 36; //Produces maximum of 80 pseudoclusters per event
366 fECAClusteringThreshold = 0.5; // value obtained from Alexei
367 fECALocMaxCut = 0.03; // ??
372 fRecPointsInRun = 0 ;
373 fMinECut = 0.01; // have to be tune
378 //____________________________________________________________________________
379 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
381 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
383 // = 2 is in different SM, quit from searching
384 // neighbours are defined as digits having at least a common vertex
385 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
386 // which is compared to a digit (d2) not yet in a cluster
389 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
390 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
391 static Int_t rowdiff, coldiff;
394 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
395 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
396 if(nSupMod1 != nSupMod2) return 2; // different SM
398 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, iphi1,ieta1);
399 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nTower2,nIphi2,nIeta2, iphi2,ieta2);
401 rowdiff = TMath::Abs(iphi1 - iphi2);
402 coldiff = TMath::Abs(ieta1 - ieta2) ;
404 if (( coldiff <= 1 ) && ( rowdiff <= 1 )) rv = 1; // neighbours with at least commom vertex
406 if (gDebug == 2 && rv==1)
407 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
408 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
413 //____________________________________________________________________________
414 Int_t AliEMCALClusterizerv1::AreInGroup(AliEMCALDigit * d1, AliEMCALDigit * d2) const
416 // Tells whether two digits fall within the same supermodule and
417 // tower grouping. The number of towers in a group is controlled by
418 // the parameter nTowersInGroup
419 // = 0 are not in same group but continue searching
421 // = 2 is in different SM, quit from searching
422 // = 3 different tower group, quit from searching
424 // The order of d1 and d2 is important: first (d1) should be a digit
425 // already in a cluster which is compared to a digit (d2) not yet in a cluster
427 //JLK Question: does the quit from searching assume that the digits
428 //are ordered, so that once you are in a different SM, you'll not
429 //find another in the list that will match? How about my TowerGroup search?
432 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
433 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
434 static Int_t towerGroup1 = -1, towerGroup2 = -1;
437 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
438 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
439 if(nSupMod1 != nSupMod2) return 2; // different SM
441 static Int_t nTowerInSM = fGeom->GetNCellsInSupMod()/fGeom->GetNCellsInTower();
443 //figure out which tower grouping each digit belongs to
444 for(int it = 0; it < nTowerInSM/fNTowerInGroup; it++) {
445 if(nTower1 <= nTowerInSM - it*fNTowerInGroup) towerGroup1 = it;
446 if(nTower2 <= nTowerInSM - it*fNTowerInGroup) towerGroup2 = it;
448 if(towerGroup1 != towerGroup2) return 3; //different Towergroup
450 //same SM, same towergroup, we're happy
451 if(towerGroup1 == towerGroup2 && towerGroup2 >= 0)
454 if (gDebug == 2 && rv==1)
455 printf("AreInGroup: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
456 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
461 //____________________________________________________________________________
462 void AliEMCALClusterizerv1::Unload()
464 // Unloads the Digits and RecPoints
465 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
467 emcalLoader->UnloadDigits() ;
468 emcalLoader->UnloadRecPoints() ;
471 //____________________________________________________________________________
472 void AliEMCALClusterizerv1::WriteRecPoints()
475 // Creates new branches with given title
476 // fills and writes into TreeR.
478 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
480 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
482 TClonesArray * digits = emcalLoader->Digits() ;
483 TTree * treeR = emcalLoader->TreeR();
485 emcalLoader->MakeRecPointsContainer();
486 treeR = emcalLoader->TreeR();
490 //Evaluate position, dispersion and other RecPoint properties for EC section
491 for(index = 0; index < aECARecPoints->GetEntries(); index++)
492 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->EvalAll(fECAW0,digits) ;
494 aECARecPoints->Sort() ;
496 for(index = 0; index < aECARecPoints->GetEntries(); index++) {
497 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->SetIndexInList(index) ;
498 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->Print();
501 Int_t bufferSize = 32000 ;
502 Int_t splitlevel = 0 ;
506 TBranch * branchECA = 0;
507 if ((branchECA = treeR->GetBranch("EMCALECARP")))
508 branchECA->SetAddress(&aECARecPoints);
510 treeR->Branch("EMCALECARP","TObjArray",&aECARecPoints,bufferSize,splitlevel);
513 emcalLoader->WriteRecPoints("OVERWRITE");
517 //____________________________________________________________________________
518 void AliEMCALClusterizerv1::MakeClusters(char* option)
520 // Steering method to construct the clusters stored in a list of Reconstructed Points
521 // A cluster is defined as a list of neighbour digits
523 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
525 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
528 AliFatal("Did not get geometry from EMCALLoader");
530 aECARecPoints->Clear();
532 //Start with pseudoclusters, if option
533 if(strstr(option,"pseudo")) {
534 TClonesArray * digits = emcalLoader->Digits() ;
535 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
537 TIter nextdigit(digitsC) ;
538 AliEMCALDigit * digit;
540 AliEMCALRecPoint * recPoint = 0 ;
544 // PseudoClusterization starts
545 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
547 TArrayI clusterECAdigitslist(1000); // what is this
549 if(fGeom->CheckAbsCellId(digit->GetId()) ) { //Is this an EMCAL digit? Just maing sure...
550 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
551 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
552 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
553 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
554 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
555 fNumberOfECAClusters++ ;
557 recPoint->SetClusterType(AliEMCALRecPoint::kPseudoCluster);
559 recPoint->AddDigit(*digit, digit->GetAmp()) ;
560 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
561 iDigitInECACluster++ ;
562 digitsC->Remove(digit) ;
563 AliDebug(1,Form("MakePseudoClusters: OK id = %d, adc = %f \n", digit->GetId(), digit->GetAmp()));
564 nextdigit.Reset(); // will start from beggining
566 AliEMCALDigit * digitN = 0; // digi neighbor
569 // Find the neighbours
570 while (index < iDigitInECACluster){ // scan over digits already in cluster
571 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
573 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
574 ineb = AreInGroup(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
576 case 0 : // not a neighbour
578 case 1 : // are neighbours
579 recPoint->AddDigit(*digitN, digitN->GetAmp() ) ;
580 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
581 iDigitInECACluster++ ;
582 digitsC->Remove(digitN) ;
584 case 2 : // different SM
586 case 3 : // different Tower group
589 } // scan over the reduced list of digits
590 } // scan over digits already in cluster
591 nextdigit.Reset() ; // will start from beggining
594 if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
598 //Now do real clusters
599 TClonesArray * digits = emcalLoader->Digits() ;
600 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
602 TIter nextdigit(digitsC) ;
603 AliEMCALDigit * digit;
605 AliEMCALRecPoint * recPoint = 0 ;
609 double e=0.0, ehs = 0.0;
610 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // clean up digits
611 e = Calibrate(digit->GetAmp(), digit->GetId());
612 AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
613 AliEMCALHistoUtilities::FillH1(fHists, 11, e);
614 if(e < fMinECut ) digitsC->Remove(digit);
617 cout << " Number of digits " << digits->GetEntries() << " -> (e>" <<fMinECut <<")";
618 cout << digitsC->GetEntries()<< " ehs "<<ehs<<endl;
620 // Clusterization starts
621 // cout << "Outer Loop" << endl;
625 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
627 TArrayI clusterECAdigitslist(1000); // what is this
629 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
630 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
631 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
632 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
633 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
634 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
635 fNumberOfECAClusters++ ;
637 recPoint->SetClusterType(AliEMCALRecPoint::kClusterv1);
639 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
640 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
641 iDigitInECACluster++ ;
642 digitsC->Remove(digit) ;
643 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , thre = %f \n", digit->GetId(),
644 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
645 nextdigit.Reset(); // will start from beggining
647 AliEMCALDigit * digitN = 0; // digi neighbor
650 // Find the neighbours
651 while (index < iDigitInECACluster){ // scan over digits already in cluster
652 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
654 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
655 ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
657 case 0 : // not a neighbour
659 case 1 : // are neighbours
660 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
661 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
662 iDigitInECACluster++ ;
663 digitsC->Remove(digitN) ;
665 case 2 : // different SM
668 } // scan over the reduced list of digits
669 } // scan over digits already in cluster
670 nextdigit.Reset() ; // will start from beggining
673 if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
676 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,digits->GetEntriesFast()));
679 //____________________________________________________________________________
680 void AliEMCALClusterizerv1::MakeUnfolding() const
682 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
686 //____________________________________________________________________________
687 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
689 // Shape of the shower (see EMCAL TDR)
690 // If you change this function, change also the gradient evaluation in ChiSquare()
692 Double_t r4 = r*r*r*r ;
693 Double_t r295 = TMath::Power(r, 2.95) ;
694 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
698 //____________________________________________________________________________
699 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * /*iniTower*/,
701 AliEMCALDigit ** /*maxAt*/,
702 Float_t * /*maxAtEnergy*/) const
704 // Performs the unfolding of a cluster with nMax overlapping showers
706 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
710 //_____________________________________________________________________________
711 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
713 Double_t * /*x*/, Int_t /*iflag*/)
715 // Calculates the Chi square for the cluster unfolding minimization
716 // Number of parameters, Gradient, Chi squared, parameters, what to do
718 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
720 //____________________________________________________________________________
721 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
723 // Print clusterizer parameters
725 TString message("\n") ;
727 if( strcmp(GetName(), "") !=0 ){
731 TString taskName(GetName()) ;
732 taskName.ReplaceAll(Version(), "") ;
734 printf("--------------- ");
735 printf(taskName.Data()) ;
738 printf("-----------\n");
739 printf("Clusterizing digits from the file: ");
740 printf(taskName.Data());
741 printf("\n Branch: ");
743 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
744 printf("\n ECA Logarithmic weight = %f", fECAW0);
746 printf("\nUnfolding on\n");
748 printf("\nUnfolding off\n");
750 printf("------------------------------------------------------------------");
753 printf("AliEMCALClusterizerv1 not initialized ") ;
756 //____________________________________________________________________________
757 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
759 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
760 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
761 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
763 printf("PrintRecPoints: Clusterization result:") ;
765 printf("event # %d\n", emcalLoader->GetRunLoader()->GetEventNumber() ) ;
766 printf(" Found %d ECA Rec Points\n ",
767 aECARecPoints->GetEntriesFast()) ;
769 fRecPointsInRun += aECARecPoints->GetEntriesFast() ;
771 if(strstr(option,"all")) {
773 printf("\n-----------------------------------------------------------------------\n") ;
774 printf("Clusters in ECAL section\n") ;
775 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
781 for (index = 0 ; index < aECARecPoints->GetEntries() ; index++) {
782 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(aECARecPoints->At(index)) ;
784 //rp->GetGlobalPosition(globalpos);
786 rp->GetLocalPosition(localpos);
788 rp->GetElipsAxis(lambda);
791 primaries = rp->GetPrimaries(nprimaries);
792 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
793 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
794 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
795 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
797 if(rp->GetEnergy()>maxE){
798 maxE=rp->GetEnergy();
801 maxDis=rp->GetDispersion();
803 fPointE->Fill(rp->GetEnergy());
804 fPointL1->Fill(lambda[0]);
805 fPointL2->Fill(lambda[1]);
806 fPointDis->Fill(rp->GetDispersion());
807 fPointMult->Fill(rp->GetMultiplicity());
809 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
810 printf("%d ", primaries[iprimary] ) ;
817 fMaxDis->Fill(maxDis);
820 printf("\n-----------------------------------------------------------------------\n");
823 TList* AliEMCALClusterizerv1::BookHists()
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);