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>
60 // --- Standard library ---
63 // --- AliRoot header files ---
64 #include "AliRunLoader.h"
67 #include "AliEMCALLoader.h"
68 #include "AliEMCALClusterizerv1.h"
69 #include "AliEMCALRecPoint.h"
70 #include "AliEMCALDigit.h"
71 #include "AliEMCALDigitizer.h"
73 #include "AliEMCALGeometry.h"
74 #include "AliEMCALHistoUtilities.h"
75 #include "AliCDBManager.h"
78 #include "AliCDBEntry.h"
80 ClassImp(AliEMCALClusterizerv1)
82 //____________________________________________________________________________
83 AliEMCALClusterizerv1::AliEMCALClusterizerv1() : AliEMCALClusterizer()
85 // default ctor (to be used mainly by Streamer)
88 fDefaultInit = kTRUE ;
89 fGeom = AliEMCALGeometry::GetInstance();
90 fGeom->GetTransformationForSM(); // Global <-> Local
93 //____________________________________________________________________________
94 AliEMCALClusterizerv1::AliEMCALClusterizerv1(const TString alirunFileName, const TString eventFolderName)
95 :AliEMCALClusterizer(alirunFileName, eventFolderName)
97 // ctor with the indication of the file where header Tree and digits Tree are stored
101 fDefaultInit = kFALSE ;
104 //____________________________________________________________________________
105 AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
110 //____________________________________________________________________________
111 const TString AliEMCALClusterizerv1::BranchName() const
116 //____________________________________________________________________________
117 Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t AbsId)
120 // Convert digitized amplitude into energy.
121 // Calibration parameters are taken from calibration data base for raw data,
122 // or from digitizer parameters for simulated data.
127 //We now get geometry at a higher level
130 // AliRunLoader *rl = AliRunLoader::GetRunLoader();
132 // Load EMCAL Geomtry
134 //AliRun * gAlice = rl->GetAliRun();
135 //AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
136 //AliEMCALGeometry * geom = emcal->GetGeometry();
139 AliFatal("Did not get geometry from EMCALLoader") ;
148 Bool_t bCell = fGeom->GetCellIndex(AbsId, iSupMod, nTower, nIphi, nIeta) ;
150 Error("DigitizeEnergy","Wrong cell id number") ;
151 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
153 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
154 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
155 return -fADCpedestalECA + amp * fADCchannelECA ;
158 else //Return energy with default parameters if calibration is not available
159 return -fADCpedestalECA + amp * fADCchannelECA ;
163 //____________________________________________________________________________
164 void AliEMCALClusterizerv1::Exec(Option_t * option)
166 // Steering method to perform clusterization for events
167 // in the range from fFirstEvent to fLastEvent.
168 // This range is optionally set by SetEventRange().
169 // if fLastEvent=-1 (by default), then process events until the end.
171 if(strstr(option,"tim"))
172 gBenchmark->Start("EMCALClusterizer");
174 if(strstr(option,"print"))
177 AliRunLoader *rl = AliRunLoader::GetRunLoader();
178 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
180 //Get calibration parameters from file or digitizer default values.
181 GetCalibrationParameters() ;
183 if (fLastEvent == -1)
184 fLastEvent = rl->GetNumberOfEvents() - 1;
185 Int_t nEvents = fLastEvent - fFirstEvent + 1;
188 rl->LoadDigits("EMCAL");
189 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
190 rl->GetEvent(ievent);
192 fNumberOfECAClusters = 0;
194 if(strstr(option,"pseudo"))
195 MakeClusters("pseudo") ; //both types
197 MakeClusters("") ; //only the real clusters
204 if(strstr(option,"deb"))
205 PrintRecPoints(option) ;
207 //increment the total number of recpoints per run
208 fRecPointsInRun += emcalLoader->RecPoints()->GetEntriesFast() ;
213 if(strstr(option,"tim")){
214 gBenchmark->Stop("EMCALClusterizer");
215 printf("Exec took %f seconds for Clusterizing %f seconds per event",
216 gBenchmark->GetCpuTime("EMCALClusterizer"), gBenchmark->GetCpuTime("EMCALClusterizer")/nEvents );
221 //____________________________________________________________________________
222 Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
223 Int_t nPar, Float_t * fitparameters) const
225 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
226 // The initial values for fitting procedure are set equal to the positions of local maxima.
227 // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
229 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
230 TClonesArray *digits = emcalLoader->Digits();
232 gMinuit->mncler(); // Reset Minuit's list of paramters
233 gMinuit->SetPrintLevel(-1) ; // No Printout
234 gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
235 // To set the address of the minimization function
236 TList * toMinuit = new TList();
237 toMinuit->AddAt(emcRP,0) ;
238 toMinuit->AddAt(digits,1) ;
240 gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
242 // filling initial values for fit parameters
243 AliEMCALDigit * digit ;
247 Int_t nDigits = (Int_t) nPar / 3 ;
251 for(iDigit = 0; iDigit < nDigits; iDigit++){
252 digit = maxAt[iDigit];
256 // have to be tune for TRD1; May 31,06
258 // fGeom->AbsToRelNumbering(digit->GetId(), relid) ; // obsolete method
259 // fGeom->PosInAlice(relid, x, z) ; // obsolete method
261 Float_t energy = maxAtEnergy[iDigit] ;
263 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
266 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
269 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
272 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
275 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
278 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
283 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
288 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
289 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
290 gMinuit->SetMaxIterations(5);
291 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
293 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
295 if(ierflg == 4){ // Minimum not found
296 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
299 for(index = 0; index < nPar; index++){
302 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
303 fitparameters[index] = val ;
311 //____________________________________________________________________________
312 void AliEMCALClusterizerv1::GetCalibrationParameters()
314 // Set calibration parameters:
315 // if calibration database exists, they are read from database,
316 // otherwise, they are taken from digitizer.
318 // It is a user responsilibity to open CDB before reconstruction,
320 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
322 //Check if calibration is stored in data base
323 if(AliCDBManager::Instance()->IsDefaultStorageSet()){
324 AliCDBEntry *entry = (AliCDBEntry*)
325 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
326 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
330 //If calibration is not available use default parameters
332 AliEMCALLoader *emcalLoader =
333 dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
334 if ( !emcalLoader->Digitizer() )
335 emcalLoader->LoadDigitizer();
336 AliEMCALDigitizer * dig = dynamic_cast<AliEMCALDigitizer*>(emcalLoader->Digitizer());
338 fADCchannelECA = dig->GetECAchannel() ;
339 fADCpedestalECA = dig->GetECApedestal();
343 //____________________________________________________________________________
344 void AliEMCALClusterizerv1::Init()
346 // Make all memory allocations which can not be done in default constructor.
347 // Attach the Clusterizer task to the list of EMCAL tasks
349 AliRunLoader *rl = AliRunLoader::GetRunLoader();
350 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
351 fGeom->GetTransformationForSM(); // Global <-> Local
352 AliInfo(Form("geom 0x%x",fGeom));
355 gMinuit = new TMinuit(100) ;
357 fHists = BookHists();
360 //____________________________________________________________________________
361 void AliEMCALClusterizerv1::InitParameters()
363 // Initializes the parameters for the Clusterizer
364 fNumberOfECAClusters = 0;
366 fNTowerInGroup = 36; //Produces maximum of 80 pseudoclusters per event
368 fECAClusteringThreshold = 0.5; // value obtained from Alexei
369 fECALocMaxCut = 0.03; // ??
374 fRecPointsInRun = 0 ;
375 fMinECut = 0.01; // have to be tune
380 //____________________________________________________________________________
381 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
383 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
385 // = 2 is in different SM, quit from searching
386 // neighbours are defined as digits having at least a common vertex
387 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
388 // which is compared to a digit (d2) not yet in a cluster
391 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
392 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
393 static Int_t rowdiff, coldiff;
396 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
397 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
398 if(nSupMod1 != nSupMod2) return 2; // different SM
400 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, iphi1,ieta1);
401 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nTower2,nIphi2,nIeta2, iphi2,ieta2);
403 rowdiff = TMath::Abs(iphi1 - iphi2);
404 coldiff = TMath::Abs(ieta1 - ieta2) ;
406 if (( coldiff <= 1 ) && ( rowdiff <= 1 )) rv = 1; // neighbours with at least commom vertex
408 if (gDebug == 2 && rv==1)
409 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
410 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
415 //____________________________________________________________________________
416 Int_t AliEMCALClusterizerv1::AreInGroup(AliEMCALDigit * d1, AliEMCALDigit * d2) const
418 // Tells whether two digits fall within the same supermodule and
419 // tower grouping. The number of towers in a group is controlled by
420 // the parameter nTowersInGroup
421 // = 0 are not in same group but continue searching
423 // = 2 is in different SM, quit from searching
424 // = 3 different tower group, quit from searching
426 // The order of d1 and d2 is important: first (d1) should be a digit
427 // already in a cluster which is compared to a digit (d2) not yet in a cluster
429 //JLK Question: does the quit from searching assume that the digits
430 //are ordered, so that once you are in a different SM, you'll not
431 //find another in the list that will match? How about my TowerGroup search?
434 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
435 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
436 static Int_t towerGroup1 = -1, towerGroup2 = -1;
439 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
440 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
441 if(nSupMod1 != nSupMod2) return 2; // different SM
443 static Int_t nTowerInSM = fGeom->GetNCellsInSupMod()/fGeom->GetNCellsInTower();
445 //figure out which tower grouping each digit belongs to
446 for(int it = 0; it < nTowerInSM/fNTowerInGroup; it++) {
447 if(nTower1 <= nTowerInSM - it*fNTowerInGroup) towerGroup1 = it;
448 if(nTower2 <= nTowerInSM - it*fNTowerInGroup) towerGroup2 = it;
450 if(towerGroup1 != towerGroup2) return 3; //different Towergroup
452 //same SM, same towergroup, we're happy
453 if(towerGroup1 == towerGroup2 && towerGroup2 >= 0)
456 if (gDebug == 2 && rv==1)
457 printf("AreInGroup: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
458 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
463 //____________________________________________________________________________
464 void AliEMCALClusterizerv1::Unload()
466 // Unloads the Digits and RecPoints
467 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
469 emcalLoader->UnloadDigits() ;
470 emcalLoader->UnloadRecPoints() ;
473 //____________________________________________________________________________
474 void AliEMCALClusterizerv1::WriteRecPoints()
477 // Creates new branches with given title
478 // fills and writes into TreeR.
480 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
482 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
484 TClonesArray * digits = emcalLoader->Digits() ;
485 TTree * treeR = emcalLoader->TreeR();
487 emcalLoader->MakeRecPointsContainer();
488 treeR = emcalLoader->TreeR();
492 //Evaluate position, dispersion and other RecPoint properties for EC section
493 for(index = 0; index < aECARecPoints->GetEntries(); index++)
494 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->EvalAll(fECAW0,digits) ;
496 aECARecPoints->Sort() ;
498 for(index = 0; index < aECARecPoints->GetEntries(); index++) {
499 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->SetIndexInList(index) ;
500 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->Print();
503 Int_t bufferSize = 32000 ;
504 Int_t splitlevel = 0 ;
508 TBranch * branchECA = 0;
509 if ((branchECA = treeR->GetBranch("EMCALECARP")))
510 branchECA->SetAddress(&aECARecPoints);
512 treeR->Branch("EMCALECARP","TObjArray",&aECARecPoints,bufferSize,splitlevel);
515 emcalLoader->WriteRecPoints("OVERWRITE");
519 //____________________________________________________________________________
520 void AliEMCALClusterizerv1::MakeClusters(char* option)
522 // Steering method to construct the clusters stored in a list of Reconstructed Points
523 // A cluster is defined as a list of neighbour digits
525 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
527 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
530 AliFatal("Did not get geometry from EMCALLoader");
532 aECARecPoints->Clear();
534 //Start with pseudoclusters, if option
535 if(strstr(option,"pseudo")) {
536 TClonesArray * digits = emcalLoader->Digits() ;
537 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
539 TIter nextdigit(digitsC) ;
540 AliEMCALDigit * digit;
542 AliEMCALRecPoint * recPoint = 0 ;
546 // PseudoClusterization starts
547 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
549 TArrayI clusterECAdigitslist(1000); // what is this
551 if(fGeom->CheckAbsCellId(digit->GetId()) ) { //Is this an EMCAL digit? Just maing sure...
552 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
553 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
554 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
555 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
556 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
557 fNumberOfECAClusters++ ;
559 recPoint->SetClusterType(AliESDCaloCluster::kPseudoCluster);
561 recPoint->AddDigit(*digit, digit->GetAmp()) ;
562 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
563 iDigitInECACluster++ ;
564 digitsC->Remove(digit) ;
565 AliDebug(1,Form("MakePseudoClusters: OK id = %d, adc = %f \n", digit->GetId(), digit->GetAmp()));
566 nextdigit.Reset(); // will start from beggining
568 AliEMCALDigit * digitN = 0; // digi neighbor
571 // Find the neighbours
572 while (index < iDigitInECACluster){ // scan over digits already in cluster
573 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
575 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
576 ineb = AreInGroup(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
578 case 0 : // not a neighbour
580 case 1 : // are neighbours
581 recPoint->AddDigit(*digitN, digitN->GetAmp() ) ;
582 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
583 iDigitInECACluster++ ;
584 digitsC->Remove(digitN) ;
586 case 2 : // different SM
588 case 3 : // different Tower group
591 } // scan over the reduced list of digits
592 } // scan over digits already in cluster
593 nextdigit.Reset() ; // will start from beggining
597 AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
598 //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
602 //Now do real clusters
603 TClonesArray * digits = emcalLoader->Digits() ;
604 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
606 TIter nextdigit(digitsC) ;
607 AliEMCALDigit * digit;
609 AliEMCALRecPoint * recPoint = 0 ;
613 double e=0.0, ehs = 0.0;
614 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // clean up digits
615 e = Calibrate(digit->GetAmp(), digit->GetId());
616 AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
617 AliEMCALHistoUtilities::FillH1(fHists, 11, e);
618 if(e < fMinECut ) digitsC->Remove(digit);
621 AliDebug(1,Form("MakeClusters: Number of digits %d -> (e %f), ehs %d\n",
622 digits->GetEntries(),fMinECut,ehs));
623 //cout << " Number of digits " << digits->GetEntries() << " -> (e>" <<fMinECut <<")";
624 //cout << digitsC->GetEntries()<< " ehs "<<ehs<<endl;
626 // Clusterization starts
627 // cout << "Outer Loop" << endl;
631 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
633 TArrayI clusterECAdigitslist(1000); // what is this
635 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
636 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
637 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
638 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
639 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
640 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
641 fNumberOfECAClusters++ ;
643 recPoint->SetClusterType(AliESDCaloCluster::kClusterv1);
645 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
646 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
647 iDigitInECACluster++ ;
648 digitsC->Remove(digit) ;
649 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , thre = %f \n", digit->GetId(),
650 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
651 nextdigit.Reset(); // will start from beggining
653 AliEMCALDigit * digitN = 0; // digi neighbor
656 // Find the neighbours
657 while (index < iDigitInECACluster){ // scan over digits already in cluster
658 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
660 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
661 ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
663 case 0 : // not a neighbour
665 case 1 : // are neighbours
666 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
667 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
668 iDigitInECACluster++ ;
669 digitsC->Remove(digitN) ;
671 case 2 : // different SM
674 } // scan over the reduced list of digits
675 } // scan over digits already in cluster
676 nextdigit.Reset() ; // will start from beggining
680 AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
681 //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
684 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,digits->GetEntriesFast()));
687 //____________________________________________________________________________
688 void AliEMCALClusterizerv1::MakeUnfolding() const
690 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
694 //____________________________________________________________________________
695 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
697 // Shape of the shower (see EMCAL TDR)
698 // If you change this function, change also the gradient evaluation in ChiSquare()
700 Double_t r4 = r*r*r*r ;
701 Double_t r295 = TMath::Power(r, 2.95) ;
702 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
706 //____________________________________________________________________________
707 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * /*iniTower*/,
709 AliEMCALDigit ** /*maxAt*/,
710 Float_t * /*maxAtEnergy*/) const
712 // Performs the unfolding of a cluster with nMax overlapping showers
714 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
718 //_____________________________________________________________________________
719 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
721 Double_t * /*x*/, Int_t /*iflag*/)
723 // Calculates the Chi square for the cluster unfolding minimization
724 // Number of parameters, Gradient, Chi squared, parameters, what to do
726 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
728 //____________________________________________________________________________
729 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
731 // Print clusterizer parameters
733 TString message("\n") ;
735 if( strcmp(GetName(), "") !=0 ){
739 TString taskName(GetName()) ;
740 taskName.ReplaceAll(Version(), "") ;
742 printf("--------------- ");
743 printf(taskName.Data()) ;
746 printf("-----------\n");
747 printf("Clusterizing digits from the file: ");
748 printf(taskName.Data());
749 printf("\n Branch: ");
751 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
752 printf("\n ECA Logarithmic weight = %f", fECAW0);
754 printf("\nUnfolding on\n");
756 printf("\nUnfolding off\n");
758 printf("------------------------------------------------------------------");
761 printf("AliEMCALClusterizerv1 not initialized ") ;
764 //____________________________________________________________________________
765 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
767 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
768 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
769 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
771 printf("PrintRecPoints: Clusterization result:") ;
773 printf("event # %d\n", emcalLoader->GetRunLoader()->GetEventNumber() ) ;
774 printf(" Found %d ECA Rec Points\n ",
775 aECARecPoints->GetEntriesFast()) ;
777 fRecPointsInRun += aECARecPoints->GetEntriesFast() ;
779 if(strstr(option,"all")) {
781 printf("\n-----------------------------------------------------------------------\n") ;
782 printf("Clusters in ECAL section\n") ;
783 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
789 for (index = 0 ; index < aECARecPoints->GetEntries() ; index++) {
790 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(aECARecPoints->At(index)) ;
792 //rp->GetGlobalPosition(globalpos);
794 rp->GetLocalPosition(localpos);
796 rp->GetElipsAxis(lambda);
799 primaries = rp->GetPrimaries(nprimaries);
800 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
801 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
802 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
803 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
805 if(rp->GetEnergy()>maxE){
806 maxE=rp->GetEnergy();
809 maxDis=rp->GetDispersion();
811 fPointE->Fill(rp->GetEnergy());
812 fPointL1->Fill(lambda[0]);
813 fPointL2->Fill(lambda[1]);
814 fPointDis->Fill(rp->GetDispersion());
815 fPointMult->Fill(rp->GetMultiplicity());
817 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
818 printf("%d ", primaries[iprimary] ) ;
825 fMaxDis->Fill(maxDis);
828 printf("\n-----------------------------------------------------------------------\n");
831 TList* AliEMCALClusterizerv1::BookHists()
833 //set up histograms for monitoring clusterizer performance
837 fPointE = new TH1F("pointE","point energy", 2000, 0.0, 150.);
838 fPointL1 = new TH1F("pointL1","point L1", 1000, 0.0, 3.);
839 fPointL2 = new TH1F("pointL2","point L2", 1000, 0.0, 3.);
840 fPointDis = new TH1F("pointDis","point Dis", 1000, 0.0, 3.);
841 fPointMult = new TH1F("pointMult","point Mult", 100, 0.0, 100.);
842 fDigitAmp = new TH1F("digitAmp","Digit Amplitude", 2000, 0.0, 5000.);
843 fMaxE = new TH1F("maxE","Max point energy", 2000, 0.0, 150.);
844 fMaxL1 = new TH1F("maxL1","Max point L1", 1000, 0.0, 3.);
845 fMaxL2 = new TH1F("maxL2","Max point L2", 1000, 0.0, 3.);
846 fMaxDis = new TH1F("maxDis","Max point Dis", 1000, 0.0, 3.); // 9
848 new TH1F("adcOfDigits","adc of digits(threshold control)", 1001, -0.5, 1000.5); // 10
849 new TH1F("energyOfDigits","energy of digits(threshold control)", 1000, 0.0, 1.); // 11
851 return AliEMCALHistoUtilities::MoveHistsToList("EmcalClusterizerv1ControlHists", kFALSE);
854 void AliEMCALClusterizerv1::SaveHists(const char *fn)
856 AliEMCALHistoUtilities::SaveListOfHists(fHists, fn, kTRUE);
859 void AliEMCALClusterizerv1::Browse(TBrowser* b)
861 if(fHists) b->Add(fHists);