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];
257 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
258 fGeom->PosInAlice(relid, x, z) ;
260 Float_t energy = maxAtEnergy[iDigit] ;
262 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
265 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
268 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
271 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
274 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
277 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
282 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
287 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
288 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
289 gMinuit->SetMaxIterations(5);
290 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
292 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
294 if(ierflg == 4){ // Minimum not found
295 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
298 for(index = 0; index < nPar; index++){
301 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
302 fitparameters[index] = val ;
310 //____________________________________________________________________________
311 void AliEMCALClusterizerv1::GetCalibrationParameters()
313 // Set calibration parameters:
314 // if calibration database exists, they are read from database,
315 // otherwise, they are taken from digitizer.
317 // It is a user responsilibity to open CDB before reconstruction,
319 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
321 //Check if calibration is stored in data base
322 if(AliCDBManager::Instance()->IsDefaultStorageSet()){
323 AliCDBEntry *entry = (AliCDBEntry*)
324 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
325 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
329 //If calibration is not available use default parameters
331 AliEMCALLoader *emcalLoader =
332 dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
333 if ( !emcalLoader->Digitizer() )
334 emcalLoader->LoadDigitizer();
335 AliEMCALDigitizer * dig = dynamic_cast<AliEMCALDigitizer*>(emcalLoader->Digitizer());
337 fADCchannelECA = dig->GetECAchannel() ;
338 fADCpedestalECA = dig->GetECApedestal();
342 //____________________________________________________________________________
343 void AliEMCALClusterizerv1::Init()
345 // Make all memory allocations which can not be done in default constructor.
346 // Attach the Clusterizer task to the list of EMCAL tasks
348 AliRunLoader *rl = AliRunLoader::GetRunLoader();
349 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
350 fGeom->GetTransformationForSM(); // Global <-> Local
351 AliInfo(Form("geom 0x%x",fGeom));
354 gMinuit = new TMinuit(100) ;
356 fHists = BookHists();
359 //____________________________________________________________________________
360 void AliEMCALClusterizerv1::InitParameters()
362 // Initializes the parameters for the Clusterizer
363 fNumberOfECAClusters = 0;
365 fNTowerInGroup = 36; //Produces maximum of 80 pseudoclusters per event
367 fECAClusteringThreshold = 0.5; // value obtained from Alexei
368 fECALocMaxCut = 0.03; // ??
373 fRecPointsInRun = 0 ;
374 fMinECut = 0.01; // have to be tune
379 //____________________________________________________________________________
380 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
382 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
384 // = 2 is in different SM, quit from searching
385 // neighbours are defined as digits having at least a common vertex
386 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
387 // which is compared to a digit (d2) not yet in a cluster
390 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
391 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
392 static Int_t rowdiff, coldiff;
395 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
396 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
397 if(nSupMod1 != nSupMod2) return 2; // different SM
399 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, iphi1,ieta1);
400 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nTower2,nIphi2,nIeta2, iphi2,ieta2);
402 rowdiff = TMath::Abs(iphi1 - iphi2);
403 coldiff = TMath::Abs(ieta1 - ieta2) ;
405 if (( coldiff <= 1 ) && ( rowdiff <= 1 )) rv = 1; // neighbours with at least commom vertex
407 if (gDebug == 2 && rv==1)
408 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
409 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
414 //____________________________________________________________________________
415 Int_t AliEMCALClusterizerv1::AreInGroup(AliEMCALDigit * d1, AliEMCALDigit * d2) const
417 // Tells whether two digits fall within the same supermodule and
418 // tower grouping. The number of towers in a group is controlled by
419 // the parameter nTowersInGroup
420 // = 0 are not in same group but continue searching
422 // = 2 is in different SM, quit from searching
423 // = 3 different tower group, quit from searching
425 // The order of d1 and d2 is important: first (d1) should be a digit
426 // already in a cluster which is compared to a digit (d2) not yet in a cluster
428 //JLK Question: does the quit from searching assume that the digits
429 //are ordered, so that once you are in a different SM, you'll not
430 //find another in the list that will match? How about my TowerGroup search?
433 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
434 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
435 static Int_t towerGroup1 = -1, towerGroup2 = -1;
438 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
439 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
440 if(nSupMod1 != nSupMod2) return 2; // different SM
442 static Int_t nTowerInSM = fGeom->GetNCellsInSupMod()/fGeom->GetNCellsInTower();
444 //figure out which tower grouping each digit belongs to
445 for(int it = 0; it < nTowerInSM/fNTowerInGroup; it++) {
446 if(nTower1 <= nTowerInSM - it*fNTowerInGroup) towerGroup1 = it;
447 if(nTower2 <= nTowerInSM - it*fNTowerInGroup) towerGroup2 = it;
449 if(towerGroup1 != towerGroup2) return 3; //different Towergroup
451 //same SM, same towergroup, we're happy
452 if(towerGroup1 == towerGroup2 && towerGroup2 >= 0)
455 if (gDebug == 2 && rv==1)
456 printf("AreInGroup: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
457 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
462 //____________________________________________________________________________
463 void AliEMCALClusterizerv1::Unload()
465 // Unloads the Digits and RecPoints
466 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
468 emcalLoader->UnloadDigits() ;
469 emcalLoader->UnloadRecPoints() ;
472 //____________________________________________________________________________
473 void AliEMCALClusterizerv1::WriteRecPoints()
476 // Creates new branches with given title
477 // fills and writes into TreeR.
479 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
481 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
483 TClonesArray * digits = emcalLoader->Digits() ;
484 TTree * treeR = emcalLoader->TreeR();
486 emcalLoader->MakeRecPointsContainer();
487 treeR = emcalLoader->TreeR();
491 //Evaluate position, dispersion and other RecPoint properties for EC section
492 for(index = 0; index < aECARecPoints->GetEntries(); index++)
493 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->EvalAll(fECAW0,digits) ;
495 aECARecPoints->Sort() ;
497 for(index = 0; index < aECARecPoints->GetEntries(); index++) {
498 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->SetIndexInList(index) ;
499 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->Print();
502 Int_t bufferSize = 32000 ;
503 Int_t splitlevel = 0 ;
507 TBranch * branchECA = 0;
508 if ((branchECA = treeR->GetBranch("EMCALECARP")))
509 branchECA->SetAddress(&aECARecPoints);
511 treeR->Branch("EMCALECARP","TObjArray",&aECARecPoints,bufferSize,splitlevel);
514 emcalLoader->WriteRecPoints("OVERWRITE");
518 //____________________________________________________________________________
519 void AliEMCALClusterizerv1::MakeClusters(char* option)
521 // Steering method to construct the clusters stored in a list of Reconstructed Points
522 // A cluster is defined as a list of neighbour digits
524 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
526 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
529 AliFatal("Did not get geometry from EMCALLoader");
531 aECARecPoints->Clear();
533 //Start with pseudoclusters, if option
534 if(strstr(option,"pseudo")) {
535 TClonesArray * digits = emcalLoader->Digits() ;
536 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
538 TIter nextdigit(digitsC) ;
539 AliEMCALDigit * digit;
541 AliEMCALRecPoint * recPoint = 0 ;
545 // PseudoClusterization starts
546 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
548 TArrayI clusterECAdigitslist(1000); // what is this
550 if(fGeom->CheckAbsCellId(digit->GetId()) ) { //Is this an EMCAL digit? Just maing sure...
551 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
552 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
553 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
554 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
555 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
556 fNumberOfECAClusters++ ;
558 recPoint->SetClusterType(AliESDCaloCluster::kPseudoCluster);
560 recPoint->AddDigit(*digit, digit->GetAmp()) ;
561 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
562 iDigitInECACluster++ ;
563 digitsC->Remove(digit) ;
564 AliDebug(1,Form("MakePseudoClusters: OK id = %d, adc = %f \n", digit->GetId(), digit->GetAmp()));
565 nextdigit.Reset(); // will start from beggining
567 AliEMCALDigit * digitN = 0; // digi neighbor
570 // Find the neighbours
571 while (index < iDigitInECACluster){ // scan over digits already in cluster
572 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
574 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
575 ineb = AreInGroup(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
577 case 0 : // not a neighbour
579 case 1 : // are neighbours
580 recPoint->AddDigit(*digitN, digitN->GetAmp() ) ;
581 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
582 iDigitInECACluster++ ;
583 digitsC->Remove(digitN) ;
585 case 2 : // different SM
587 case 3 : // different Tower group
590 } // scan over the reduced list of digits
591 } // scan over digits already in cluster
592 nextdigit.Reset() ; // will start from beggining
596 AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
597 //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
601 //Now do real clusters
602 TClonesArray * digits = emcalLoader->Digits() ;
603 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
605 TIter nextdigit(digitsC) ;
606 AliEMCALDigit * digit;
608 AliEMCALRecPoint * recPoint = 0 ;
612 double e=0.0, ehs = 0.0;
613 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // clean up digits
614 e = Calibrate(digit->GetAmp(), digit->GetId());
615 AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
616 AliEMCALHistoUtilities::FillH1(fHists, 11, e);
617 if(e < fMinECut ) digitsC->Remove(digit);
620 AliDebug(1,Form("MakeClusters: Number of digits %d -> (e %f), ehs %d\n",
621 digits->GetEntries(),fMinECut,ehs));
622 //cout << " Number of digits " << digits->GetEntries() << " -> (e>" <<fMinECut <<")";
623 //cout << digitsC->GetEntries()<< " ehs "<<ehs<<endl;
625 // Clusterization starts
626 // cout << "Outer Loop" << endl;
630 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
632 TArrayI clusterECAdigitslist(1000); // what is this
634 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
635 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
636 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
637 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
638 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
639 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
640 fNumberOfECAClusters++ ;
642 recPoint->SetClusterType(AliESDCaloCluster::kClusterv1);
644 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
645 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
646 iDigitInECACluster++ ;
647 digitsC->Remove(digit) ;
648 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , thre = %f \n", digit->GetId(),
649 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
650 nextdigit.Reset(); // will start from beggining
652 AliEMCALDigit * digitN = 0; // digi neighbor
655 // Find the neighbours
656 while (index < iDigitInECACluster){ // scan over digits already in cluster
657 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
659 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
660 ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
662 case 0 : // not a neighbour
664 case 1 : // are neighbours
665 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
666 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
667 iDigitInECACluster++ ;
668 digitsC->Remove(digitN) ;
670 case 2 : // different SM
673 } // scan over the reduced list of digits
674 } // scan over digits already in cluster
675 nextdigit.Reset() ; // will start from beggining
679 AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
680 //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
683 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,digits->GetEntriesFast()));
686 //____________________________________________________________________________
687 void AliEMCALClusterizerv1::MakeUnfolding() const
689 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
693 //____________________________________________________________________________
694 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
696 // Shape of the shower (see EMCAL TDR)
697 // If you change this function, change also the gradient evaluation in ChiSquare()
699 Double_t r4 = r*r*r*r ;
700 Double_t r295 = TMath::Power(r, 2.95) ;
701 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
705 //____________________________________________________________________________
706 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * /*iniTower*/,
708 AliEMCALDigit ** /*maxAt*/,
709 Float_t * /*maxAtEnergy*/) const
711 // Performs the unfolding of a cluster with nMax overlapping showers
713 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
717 //_____________________________________________________________________________
718 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
720 Double_t * /*x*/, Int_t /*iflag*/)
722 // Calculates the Chi square for the cluster unfolding minimization
723 // Number of parameters, Gradient, Chi squared, parameters, what to do
725 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
727 //____________________________________________________________________________
728 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
730 // Print clusterizer parameters
732 TString message("\n") ;
734 if( strcmp(GetName(), "") !=0 ){
738 TString taskName(GetName()) ;
739 taskName.ReplaceAll(Version(), "") ;
741 printf("--------------- ");
742 printf(taskName.Data()) ;
745 printf("-----------\n");
746 printf("Clusterizing digits from the file: ");
747 printf(taskName.Data());
748 printf("\n Branch: ");
750 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
751 printf("\n ECA Logarithmic weight = %f", fECAW0);
753 printf("\nUnfolding on\n");
755 printf("\nUnfolding off\n");
757 printf("------------------------------------------------------------------");
760 printf("AliEMCALClusterizerv1 not initialized ") ;
763 //____________________________________________________________________________
764 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
766 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
767 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
768 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
770 printf("PrintRecPoints: Clusterization result:") ;
772 printf("event # %d\n", emcalLoader->GetRunLoader()->GetEventNumber() ) ;
773 printf(" Found %d ECA Rec Points\n ",
774 aECARecPoints->GetEntriesFast()) ;
776 fRecPointsInRun += aECARecPoints->GetEntriesFast() ;
778 if(strstr(option,"all")) {
780 printf("\n-----------------------------------------------------------------------\n") ;
781 printf("Clusters in ECAL section\n") ;
782 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
788 for (index = 0 ; index < aECARecPoints->GetEntries() ; index++) {
789 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(aECARecPoints->At(index)) ;
791 //rp->GetGlobalPosition(globalpos);
793 rp->GetLocalPosition(localpos);
795 rp->GetElipsAxis(lambda);
798 primaries = rp->GetPrimaries(nprimaries);
799 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
800 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
801 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
802 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
804 if(rp->GetEnergy()>maxE){
805 maxE=rp->GetEnergy();
808 maxDis=rp->GetDispersion();
810 fPointE->Fill(rp->GetEnergy());
811 fPointL1->Fill(lambda[0]);
812 fPointL2->Fill(lambda[1]);
813 fPointDis->Fill(rp->GetDispersion());
814 fPointMult->Fill(rp->GetMultiplicity());
816 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
817 printf("%d ", primaries[iprimary] ) ;
824 fMaxDis->Fill(maxDis);
827 printf("\n-----------------------------------------------------------------------\n");
830 TList* AliEMCALClusterizerv1::BookHists()
832 //set up histograms for monitoring clusterizer performance
836 fPointE = new TH1F("pointE","point energy", 2000, 0.0, 150.);
837 fPointL1 = new TH1F("pointL1","point L1", 1000, 0.0, 3.);
838 fPointL2 = new TH1F("pointL2","point L2", 1000, 0.0, 3.);
839 fPointDis = new TH1F("pointDis","point Dis", 1000, 0.0, 3.);
840 fPointMult = new TH1F("pointMult","point Mult", 100, 0.0, 100.);
841 fDigitAmp = new TH1F("digitAmp","Digit Amplitude", 2000, 0.0, 5000.);
842 fMaxE = new TH1F("maxE","Max point energy", 2000, 0.0, 150.);
843 fMaxL1 = new TH1F("maxL1","Max point L1", 1000, 0.0, 3.);
844 fMaxL2 = new TH1F("maxL2","Max point L2", 1000, 0.0, 3.);
845 fMaxDis = new TH1F("maxDis","Max point Dis", 1000, 0.0, 3.); // 9
847 new TH1F("adcOfDigits","adc of digits(threshold control)", 1001, -0.5, 1000.5); // 10
848 new TH1F("energyOfDigits","energy of digits(threshold control)", 1000, 0.0, 1.); // 11
850 return AliEMCALHistoUtilities::MoveHistsToList("EmcalClusterizerv1ControlHists", kFALSE);
853 void AliEMCALClusterizerv1::SaveHists(const char *fn)
855 AliEMCALHistoUtilities::SaveListOfHists(fHists, fn, kTRUE);
858 void AliEMCALClusterizerv1::Browse(TBrowser* b)
860 if(fHists) b->Add(fHists);