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(const AliEMCALClusterizerv1& clus):AliEMCALClusterizer(clus)
108 fHists = clus.fHists;
109 fPointE = clus.fPointE;
110 fPointL1 = clus.fPointL1;
111 fPointL2 = clus.fPointL2;
112 fPointDis = clus.fPointDis;
113 fPointMult = clus.fPointMult;
114 fDigitAmp = clus.fDigitAmp;
116 fMaxL1 = clus.fMaxL1;
117 fMaxL2 = clus.fMaxL2;
118 fMaxDis = clus.fMaxDis;
121 fDefaultInit = clus.fDefaultInit;
122 fToUnfold = clus.fToUnfold;
123 fNumberOfECAClusters = clus.fNumberOfECAClusters;
124 fNTowerInGroup = clus.fNTowerInGroup;
125 fCalibData = clus.fCalibData;
126 fADCchannelECA = clus.fADCchannelECA;
127 fADCpedestalECA = clus.fADCpedestalECA;
128 fECAClusteringThreshold = clus.fECAClusteringThreshold;
129 fECALocMaxCut = clus.fECALocMaxCut;
130 fECAW0 = clus.fECAW0;
131 fRecPointsInRun = clus.fRecPointsInRun;
132 fTimeGate = clus.fTimeGate;
133 fMinECut = clus.fMinECut;
137 //____________________________________________________________________________
138 AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
143 //____________________________________________________________________________
144 const TString AliEMCALClusterizerv1::BranchName() const
149 //____________________________________________________________________________
150 Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t AbsId)
153 // Convert digitized amplitude into energy.
154 // Calibration parameters are taken from calibration data base for raw data,
155 // or from digitizer parameters for simulated data.
160 //We now get geometry at a higher level
163 // AliRunLoader *rl = AliRunLoader::GetRunLoader();
165 // Load EMCAL Geomtry
167 //AliRun * gAlice = rl->GetAliRun();
168 //AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
169 //AliEMCALGeometry * geom = emcal->GetGeometry();
172 AliFatal("Did not get geometry from EMCALLoader") ;
181 Bool_t bCell = fGeom->GetCellIndex(AbsId, iSupMod, nTower, nIphi, nIeta) ;
183 Error("DigitizeEnergy","Wrong cell id number") ;
184 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
186 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
187 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
188 return -fADCpedestalECA + amp * fADCchannelECA ;
191 else //Return energy with default parameters if calibration is not available
192 return -fADCpedestalECA + amp * fADCchannelECA ;
196 //____________________________________________________________________________
197 void AliEMCALClusterizerv1::Exec(Option_t * option)
199 // Steering method to perform clusterization for events
200 // in the range from fFirstEvent to fLastEvent.
201 // This range is optionally set by SetEventRange().
202 // if fLastEvent=-1 (by default), then process events until the end.
204 if(strstr(option,"tim"))
205 gBenchmark->Start("EMCALClusterizer");
207 if(strstr(option,"print"))
210 AliRunLoader *rl = AliRunLoader::GetRunLoader();
211 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
213 //Get calibration parameters from file or digitizer default values.
214 GetCalibrationParameters() ;
216 if (fLastEvent == -1)
217 fLastEvent = rl->GetNumberOfEvents() - 1;
218 Int_t nEvents = fLastEvent - fFirstEvent + 1;
221 rl->LoadDigits("EMCAL");
222 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
223 rl->GetEvent(ievent);
225 fNumberOfECAClusters = 0;
227 if(strstr(option,"pseudo"))
228 MakeClusters("pseudo") ; //both types
230 MakeClusters("") ; //only the real clusters
237 if(strstr(option,"deb"))
238 PrintRecPoints(option) ;
240 //increment the total number of recpoints per run
241 fRecPointsInRun += emcalLoader->RecPoints()->GetEntriesFast() ;
246 if(strstr(option,"tim")){
247 gBenchmark->Stop("EMCALClusterizer");
248 printf("Exec took %f seconds for Clusterizing %f seconds per event",
249 gBenchmark->GetCpuTime("EMCALClusterizer"), gBenchmark->GetCpuTime("EMCALClusterizer")/nEvents );
254 //____________________________________________________________________________
255 Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
256 Int_t nPar, Float_t * fitparameters) const
258 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
259 // The initial values for fitting procedure are set equal to the positions of local maxima.
260 // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
262 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
263 TClonesArray *digits = emcalLoader->Digits();
265 gMinuit->mncler(); // Reset Minuit's list of paramters
266 gMinuit->SetPrintLevel(-1) ; // No Printout
267 gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
268 // To set the address of the minimization function
269 TList * toMinuit = new TList();
270 toMinuit->AddAt(emcRP,0) ;
271 toMinuit->AddAt(digits,1) ;
273 gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
275 // filling initial values for fit parameters
276 AliEMCALDigit * digit ;
280 Int_t nDigits = (Int_t) nPar / 3 ;
284 for(iDigit = 0; iDigit < nDigits; iDigit++){
285 digit = maxAt[iDigit];
289 // have to be tune for TRD1; May 31,06
291 // fGeom->AbsToRelNumbering(digit->GetId(), relid) ; // obsolete method
292 // fGeom->PosInAlice(relid, x, z) ; // obsolete method
294 Float_t energy = maxAtEnergy[iDigit] ;
296 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
299 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
302 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
305 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
308 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
311 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
316 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
321 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
322 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
323 gMinuit->SetMaxIterations(5);
324 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
326 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
328 if(ierflg == 4){ // Minimum not found
329 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
332 for(index = 0; index < nPar; index++){
335 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
336 fitparameters[index] = val ;
344 //____________________________________________________________________________
345 void AliEMCALClusterizerv1::GetCalibrationParameters()
347 // Set calibration parameters:
348 // if calibration database exists, they are read from database,
349 // otherwise, they are taken from digitizer.
351 // It is a user responsilibity to open CDB before reconstruction,
353 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
355 //Check if calibration is stored in data base
356 if(AliCDBManager::Instance()->IsDefaultStorageSet()){
357 AliCDBEntry *entry = (AliCDBEntry*)
358 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
359 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
363 //If calibration is not available use default parameters
365 AliEMCALLoader *emcalLoader =
366 dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
367 if ( !emcalLoader->Digitizer() )
368 emcalLoader->LoadDigitizer();
369 AliEMCALDigitizer * dig = dynamic_cast<AliEMCALDigitizer*>(emcalLoader->Digitizer());
371 fADCchannelECA = dig->GetECAchannel() ;
372 fADCpedestalECA = dig->GetECApedestal();
376 //____________________________________________________________________________
377 void AliEMCALClusterizerv1::Init()
379 // Make all memory allocations which can not be done in default constructor.
380 // Attach the Clusterizer task to the list of EMCAL tasks
382 AliRunLoader *rl = AliRunLoader::GetRunLoader();
383 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
384 fGeom->GetTransformationForSM(); // Global <-> Local
385 AliInfo(Form("geom 0x%x",fGeom));
388 gMinuit = new TMinuit(100) ;
390 fHists = BookHists();
393 //____________________________________________________________________________
394 void AliEMCALClusterizerv1::InitParameters()
396 // Initializes the parameters for the Clusterizer
397 fNumberOfECAClusters = 0;
399 fNTowerInGroup = 36; //Produces maximum of 80 pseudoclusters per event
401 fECAClusteringThreshold = 0.5; // value obtained from Alexei
402 fECALocMaxCut = 0.03; // ??
407 fRecPointsInRun = 0 ;
408 fMinECut = 0.01; // have to be tune
413 //____________________________________________________________________________
414 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
416 // Gives the neighbourness of two digits = 0 are not neighbour but continue searching
418 // = 2 is in different SM, quit from searching
419 // neighbours are defined as digits having at least a common vertex
420 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
421 // which is compared to a digit (d2) not yet in a cluster
424 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
425 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
426 static Int_t rowdiff, coldiff;
429 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
430 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
431 if(nSupMod1 != nSupMod2) return 2; // different SM
433 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, iphi1,ieta1);
434 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nTower2,nIphi2,nIeta2, iphi2,ieta2);
436 rowdiff = TMath::Abs(iphi1 - iphi2);
437 coldiff = TMath::Abs(ieta1 - ieta2) ;
439 if (( coldiff <= 1 ) && ( rowdiff <= 1 )) rv = 1; // neighbours with at least commom vertex
441 if (gDebug == 2 && rv==1)
442 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
443 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
448 //____________________________________________________________________________
449 Int_t AliEMCALClusterizerv1::AreInGroup(AliEMCALDigit * d1, AliEMCALDigit * d2) const
451 // Tells whether two digits fall within the same supermodule and
452 // tower grouping. The number of towers in a group is controlled by
453 // the parameter nTowersInGroup
454 // = 0 are not in same group but continue searching
456 // = 2 is in different SM, quit from searching
457 // = 3 different tower group, quit from searching
459 // The order of d1 and d2 is important: first (d1) should be a digit
460 // already in a cluster which is compared to a digit (d2) not yet in a cluster
462 //JLK Question: does the quit from searching assume that the digits
463 //are ordered, so that once you are in a different SM, you'll not
464 //find another in the list that will match? How about my TowerGroup search?
467 static Int_t nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
468 static Int_t nSupMod2=0, nTower2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
469 static Int_t towerGroup1 = -1, towerGroup2 = -1;
472 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
473 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nTower2,nIphi2,nIeta2);
474 if(nSupMod1 != nSupMod2) return 2; // different SM
476 static Int_t nTowerInSM = fGeom->GetNCellsInSupMod()/fGeom->GetNCellsInTower();
478 //figure out which tower grouping each digit belongs to
479 for(int it = 0; it < nTowerInSM/fNTowerInGroup; it++) {
480 if(nTower1 <= nTowerInSM - it*fNTowerInGroup) towerGroup1 = it;
481 if(nTower2 <= nTowerInSM - it*fNTowerInGroup) towerGroup2 = it;
483 if(towerGroup1 != towerGroup2) return 3; //different Towergroup
485 //same SM, same towergroup, we're happy
486 if(towerGroup1 == towerGroup2 && towerGroup2 >= 0)
489 if (gDebug == 2 && rv==1)
490 printf("AreInGroup: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
491 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
496 //____________________________________________________________________________
497 void AliEMCALClusterizerv1::Unload()
499 // Unloads the Digits and RecPoints
500 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
502 emcalLoader->UnloadDigits() ;
503 emcalLoader->UnloadRecPoints() ;
506 //____________________________________________________________________________
507 void AliEMCALClusterizerv1::WriteRecPoints()
510 // Creates new branches with given title
511 // fills and writes into TreeR.
513 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
515 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
517 TClonesArray * digits = emcalLoader->Digits() ;
518 TTree * treeR = emcalLoader->TreeR();
520 emcalLoader->MakeRecPointsContainer();
521 treeR = emcalLoader->TreeR();
525 //Evaluate position, dispersion and other RecPoint properties for EC section
526 for(index = 0; index < aECARecPoints->GetEntries(); index++)
527 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->EvalAll(fECAW0,digits) ;
529 aECARecPoints->Sort() ;
531 for(index = 0; index < aECARecPoints->GetEntries(); index++) {
532 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->SetIndexInList(index) ;
533 (dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(index)))->Print();
536 Int_t bufferSize = 32000 ;
537 Int_t splitlevel = 0 ;
541 TBranch * branchECA = 0;
542 if ((branchECA = treeR->GetBranch("EMCALECARP")))
543 branchECA->SetAddress(&aECARecPoints);
545 treeR->Branch("EMCALECARP","TObjArray",&aECARecPoints,bufferSize,splitlevel);
548 emcalLoader->WriteRecPoints("OVERWRITE");
552 //____________________________________________________________________________
553 void AliEMCALClusterizerv1::MakeClusters(char* option)
555 // Steering method to construct the clusters stored in a list of Reconstructed Points
556 // A cluster is defined as a list of neighbour digits
558 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
560 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
563 AliFatal("Did not get geometry from EMCALLoader");
565 aECARecPoints->Clear();
567 //Start with pseudoclusters, if option
568 if(strstr(option,"pseudo")) {
569 TClonesArray * digits = emcalLoader->Digits() ;
570 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
572 TIter nextdigit(digitsC) ;
573 AliEMCALDigit * digit;
575 AliEMCALRecPoint * recPoint = 0 ;
579 // PseudoClusterization starts
580 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
582 TArrayI clusterECAdigitslist(1000); // what is this
584 if(fGeom->CheckAbsCellId(digit->GetId()) ) { //Is this an EMCAL digit? Just maing sure...
585 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
586 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
587 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
588 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
589 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
590 fNumberOfECAClusters++ ;
592 recPoint->SetClusterType(AliESDCaloCluster::kPseudoCluster);
594 recPoint->AddDigit(*digit, digit->GetAmp()) ;
595 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
596 iDigitInECACluster++ ;
597 digitsC->Remove(digit) ;
598 AliDebug(1,Form("MakePseudoClusters: OK id = %d, adc = %f \n", digit->GetId(), digit->GetAmp()));
599 nextdigit.Reset(); // will start from beggining
601 AliEMCALDigit * digitN = 0; // digi neighbor
604 // Find the neighbours
605 while (index < iDigitInECACluster){ // scan over digits already in cluster
606 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
608 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
609 ineb = AreInGroup(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
611 case 0 : // not a neighbour
613 case 1 : // are neighbours
614 recPoint->AddDigit(*digitN, digitN->GetAmp() ) ;
615 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
616 iDigitInECACluster++ ;
617 digitsC->Remove(digitN) ;
619 case 2 : // different SM
621 case 3 : // different Tower group
624 } // scan over the reduced list of digits
625 } // scan over digits already in cluster
626 nextdigit.Reset() ; // will start from beggining
630 AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
631 //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
635 //Now do real clusters
636 TClonesArray * digits = emcalLoader->Digits() ;
637 TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
639 TIter nextdigit(digitsC) ;
640 AliEMCALDigit * digit;
642 AliEMCALRecPoint * recPoint = 0 ;
646 double e=0.0, ehs = 0.0;
647 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // clean up digits
648 e = Calibrate(digit->GetAmp(), digit->GetId());
649 AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
650 AliEMCALHistoUtilities::FillH1(fHists, 11, e);
651 if(e < fMinECut ) digitsC->Remove(digit);
654 AliDebug(1,Form("MakeClusters: Number of digits %d -> (e %f), ehs %d\n",
655 digits->GetEntries(),fMinECut,ehs));
656 //cout << " Number of digits " << digits->GetEntries() << " -> (e>" <<fMinECut <<")";
657 //cout << digitsC->GetEntries()<< " ehs "<<ehs<<endl;
659 // Clusterization starts
660 // cout << "Outer Loop" << endl;
664 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
666 TArrayI clusterECAdigitslist(1000); // what is this
668 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
669 Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
670 if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
671 AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
672 aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
673 recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
674 fNumberOfECAClusters++ ;
676 recPoint->SetClusterType(AliESDCaloCluster::kClusterv1);
678 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
679 clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
680 iDigitInECACluster++ ;
681 digitsC->Remove(digit) ;
682 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , thre = %f \n", digit->GetId(),
683 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
684 nextdigit.Reset(); // will start from beggining
686 AliEMCALDigit * digitN = 0; // digi neighbor
689 // Find the neighbours
690 while (index < iDigitInECACluster){ // scan over digits already in cluster
691 digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
693 while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
694 ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
696 case 0 : // not a neighbour
698 case 1 : // are neighbours
699 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
700 clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
701 iDigitInECACluster++ ;
702 digitsC->Remove(digitN) ;
704 case 2 : // different SM
707 } // scan over the reduced list of digits
708 } // scan over digits already in cluster
709 nextdigit.Reset() ; // will start from beggining
713 AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
714 //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
717 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,digits->GetEntriesFast()));
720 //____________________________________________________________________________
721 void AliEMCALClusterizerv1::MakeUnfolding() const
723 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
727 //____________________________________________________________________________
728 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
730 // Shape of the shower (see EMCAL TDR)
731 // If you change this function, change also the gradient evaluation in ChiSquare()
733 Double_t r4 = r*r*r*r ;
734 Double_t r295 = TMath::Power(r, 2.95) ;
735 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
739 //____________________________________________________________________________
740 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * /*iniTower*/,
742 AliEMCALDigit ** /*maxAt*/,
743 Float_t * /*maxAtEnergy*/) const
745 // Performs the unfolding of a cluster with nMax overlapping showers
747 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
751 //_____________________________________________________________________________
752 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
754 Double_t * /*x*/, Int_t /*iflag*/)
756 // Calculates the Chi square for the cluster unfolding minimization
757 // Number of parameters, Gradient, Chi squared, parameters, what to do
759 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
761 //____________________________________________________________________________
762 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
764 // Print clusterizer parameters
766 TString message("\n") ;
768 if( strcmp(GetName(), "") !=0 ){
772 TString taskName(GetName()) ;
773 taskName.ReplaceAll(Version(), "") ;
775 printf("--------------- ");
776 printf(taskName.Data()) ;
779 printf("-----------\n");
780 printf("Clusterizing digits from the file: ");
781 printf(taskName.Data());
782 printf("\n Branch: ");
784 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
785 printf("\n ECA Logarithmic weight = %f", fECAW0);
787 printf("\nUnfolding on\n");
789 printf("\nUnfolding off\n");
791 printf("------------------------------------------------------------------");
794 printf("AliEMCALClusterizerv1 not initialized ") ;
797 //____________________________________________________________________________
798 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
800 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
801 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
802 TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
804 printf("PrintRecPoints: Clusterization result:") ;
806 printf("event # %d\n", emcalLoader->GetRunLoader()->GetEventNumber() ) ;
807 printf(" Found %d ECA Rec Points\n ",
808 aECARecPoints->GetEntriesFast()) ;
810 fRecPointsInRun += aECARecPoints->GetEntriesFast() ;
812 if(strstr(option,"all")) {
814 printf("\n-----------------------------------------------------------------------\n") ;
815 printf("Clusters in ECAL section\n") ;
816 printf("Index Ene(GeV) Multi Module phi r theta X Y Z Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
822 for (index = 0 ; index < aECARecPoints->GetEntries() ; index++) {
823 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(aECARecPoints->At(index)) ;
825 //rp->GetGlobalPosition(globalpos);
827 rp->GetLocalPosition(localpos);
829 rp->GetElipsAxis(lambda);
832 primaries = rp->GetPrimaries(nprimaries);
833 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
834 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
835 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
836 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
838 if(rp->GetEnergy()>maxE){
839 maxE=rp->GetEnergy();
842 maxDis=rp->GetDispersion();
844 fPointE->Fill(rp->GetEnergy());
845 fPointL1->Fill(lambda[0]);
846 fPointL2->Fill(lambda[1]);
847 fPointDis->Fill(rp->GetDispersion());
848 fPointMult->Fill(rp->GetMultiplicity());
850 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
851 printf("%d ", primaries[iprimary] ) ;
858 fMaxDis->Fill(maxDis);
861 printf("\n-----------------------------------------------------------------------\n");
864 TList* AliEMCALClusterizerv1::BookHists()
866 //set up histograms for monitoring clusterizer performance
870 fPointE = new TH1F("pointE","point energy", 2000, 0.0, 150.);
871 fPointL1 = new TH1F("pointL1","point L1", 1000, 0.0, 3.);
872 fPointL2 = new TH1F("pointL2","point L2", 1000, 0.0, 3.);
873 fPointDis = new TH1F("pointDis","point Dis", 1000, 0.0, 3.);
874 fPointMult = new TH1F("pointMult","point Mult", 100, 0.0, 100.);
875 fDigitAmp = new TH1F("digitAmp","Digit Amplitude", 2000, 0.0, 5000.);
876 fMaxE = new TH1F("maxE","Max point energy", 2000, 0.0, 150.);
877 fMaxL1 = new TH1F("maxL1","Max point L1", 1000, 0.0, 3.);
878 fMaxL2 = new TH1F("maxL2","Max point L2", 1000, 0.0, 3.);
879 fMaxDis = new TH1F("maxDis","Max point Dis", 1000, 0.0, 3.); // 9
881 new TH1F("adcOfDigits","adc of digits(threshold control)", 1001, -0.5, 1000.5); // 10
882 new TH1F("energyOfDigits","energy of digits(threshold control)", 1000, 0.0, 1.); // 11
884 return AliEMCALHistoUtilities::MoveHistsToList("EmcalClusterizerv1ControlHists", kFALSE);
887 void AliEMCALClusterizerv1::SaveHists(const char *fn)
889 AliEMCALHistoUtilities::SaveListOfHists(fHists, fn, kTRUE);
892 void AliEMCALClusterizerv1::Browse(TBrowser* b)
894 if(fHists) b->Add(fHists);