]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALClusterizerv1.cxx
Removing ^M at the end of lines
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALClusterizerv1.cxx
1 /**************************************************************************
2
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4
5  *                                                                        *
6
7  * Author: The ALICE Off-line Project.                                    *
8
9  * Contributors are mentioned in the code where appropriate.              *
10
11  *                                                                        *
12
13  * Permission to use, copy, modify and distribute this software and its   *
14
15  * documentation strictly for non-commercial purposes is hereby granted   *
16
17  * without fee, provided that the above copyright notice appears in all   *
18
19  * copies and that both the copyright notice and this permission notice   *
20
21  * appear in the supporting documentation. The authors make no claims     *
22
23  * about the suitability of this software for any purpose. It is          *
24
25  * provided "as is" without express or implied warranty.                  *
26
27  **************************************************************************/
28
29 /* $Id$ */
30
31
32
33 /* $Log:
34
35    1 October 2000. Yuri Kharlov:
36
37      AreNeighbours()
38
39      PPSD upper layer is considered if number of layers>1
40
41
42
43    18 October 2000. Yuri Kharlov:
44
45      AliEMCALClusterizerv1()
46
47      CPV clusterizing parameters added
48
49
50
51      MakeClusters()
52
53      After first PPSD digit remove EMC digits only once
54
55 */
56
57 //*-- Author: Yves Schutz (SUBATECH)  & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
58
59 //  August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
60
61 //                           of new  IO (à la PHOS)
62
63 //////////////////////////////////////////////////////////////////////////////
64
65 //  Clusterization class. Performs clusterization (collects neighbouring active cells) and 
66
67 //  unfolds the clusters having several local maxima.  
68
69 //  Results are stored in TreeR#, branches EMCALTowerRP (EMC recPoints),
70
71 //  EMCALPreShoRP (CPV RecPoints) and AliEMCALClusterizer (Clusterizer with all 
72
73 //  parameters including input digits branch title, thresholds etc.)
74
75 //  This TTask is normally called from Reconstructioner, but can as well be used in 
76
77 //  standalone mode.
78
79 // Use Case:
80
81 //  root [0] AliEMCALClusterizerv1 * cl = new AliEMCALClusterizerv1("galice.root")  
82
83 //  Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
84
85 //               //reads gAlice from header file "..."                      
86
87 //  root [1] cl->ExecuteTask()  
88
89 //               //finds RecPoints in all events stored in galice.root
90
91 //  root [2] cl->SetDigitsBranch("digits2") 
92
93 //               //sets another title for Digitis (input) branch
94
95 //  root [3] cl->SetRecPointsBranch("recp2")  
96
97 //               //sets another title four output branches
98
99 //  root [4] cl->SetTowerLocalMaxCut(0.03)  
100
101 //               //set clusterization parameters
102
103 //  root [5] cl->ExecuteTask("deb all time")  
104
105 //               //once more finds RecPoints options are 
106
107 //               // deb - print number of found rec points
108
109 //               // deb all - print number of found RecPoints and some their characteristics 
110
111 //               // time - print benchmarking results
112
113
114
115 // --- ROOT system ---
116
117
118
119 #include "TROOT.h" 
120
121 #include "TFile.h" 
122
123 #include "TFolder.h" 
124
125 #include "TMath.h" 
126
127 #include "TMinuit.h"
128
129 #include "TTree.h" 
130
131 #include "TSystem.h" 
132
133 #include "TBenchmark.h"
134
135
136
137 // --- Standard library ---
138
139
140
141 #include <iostream.h>
142
143 #include <iomanip.h>
144
145
146
147 // --- AliRoot header files ---
148
149
150
151 #include "AliEMCALClusterizerv1.h"
152
153 #include "AliEMCALDigit.h"
154
155 #include "AliEMCALDigitizer.h"
156
157 #include "AliEMCALTowerRecPoint.h"
158
159 #include "AliEMCAL.h"
160
161 #include "AliEMCALGetter.h"
162
163 #include "AliEMCALGeometry.h"
164
165 #include "AliRun.h"
166
167
168
169 ClassImp(AliEMCALClusterizerv1)
170
171   
172
173 //____________________________________________________________________________
174
175   AliEMCALClusterizerv1::AliEMCALClusterizerv1() : AliEMCALClusterizer()
176
177 {
178
179   // default ctor (to be used mainly by Streamer)
180
181   
182
183   InitParameters() ; 
184
185   fDefaultInit = kTRUE ; 
186
187 }
188
189
190
191 //____________________________________________________________________________
192
193 AliEMCALClusterizerv1::AliEMCALClusterizerv1(const char* headerFile, const char* name, const Bool_t toSplit)
194
195 :AliEMCALClusterizer(headerFile, name, toSplit)
196
197 {
198
199   // ctor with the indication of the file where header Tree and digits Tree are stored
200
201   
202
203   InitParameters() ; 
204
205   Init() ;
206
207   fDefaultInit = kFALSE ; 
208
209
210
211 }
212
213
214
215 //____________________________________________________________________________
216
217   AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
218
219 {
220
221   // dtor
222
223   fSplitFile = 0 ; 
224
225   
226
227 }
228
229
230
231 //____________________________________________________________________________
232
233 const TString AliEMCALClusterizerv1::BranchName() const 
234
235 {  
236
237   TString branchName(GetName() ) ;
238
239   branchName.Remove(branchName.Index(Version())-1) ;
240
241   return branchName ;
242
243 }
244
245
246
247 //____________________________________________________________________________
248
249 Float_t  AliEMCALClusterizerv1::Calibrate(Int_t amp, Bool_t inpresho) const
250
251 {//To be replased later by the method, reading individual parameters from the database
252
253
254
255   if ( inpresho ) // calibrate as pre shower
256
257      return -fADCpedestalPreSho + amp * fADCchannelPreSho ; 
258
259
260
261   else //calibrate as tower 
262
263     return -fADCpedestalTower + amp * fADCchannelTower ;                
264
265 }
266
267
268
269 //____________________________________________________________________________
270
271 void AliEMCALClusterizerv1::Exec(Option_t * option)
272
273 {
274
275   // Steering method
276
277
278
279   if( strcmp(GetName(), "")== 0 ) 
280
281     Init() ;
282
283
284
285   if(strstr(option,"tim"))
286
287     gBenchmark->Start("EMCALClusterizer"); 
288
289   
290
291   if(strstr(option,"print"))
292
293     Print("") ; 
294
295
296
297   AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
298
299   if(gime->BranchExists("RecPoints"))
300
301     return ;
302
303   Int_t nevents = gime->MaxEvent() ;
304
305   Int_t ievent ;
306
307
308
309   for(ievent = 0; ievent < nevents; ievent++){
310
311
312
313     gime->Event(ievent,"D") ;
314
315
316
317     if(ievent == 0)
318
319       GetCalibrationParameters() ;
320
321
322
323     fNumberOfTowerClusters = fNumberOfPreShoClusters = 0 ;
324
325            
326
327     MakeClusters() ;
328
329     
330
331     if(fToUnfold)
332
333       MakeUnfolding() ;
334
335
336
337     WriteRecPoints(ievent) ;
338
339
340
341     if(strstr(option,"deb"))  
342
343       PrintRecPoints(option) ;
344
345
346
347     //increment the total number of digits per run 
348
349     fRecPointsInRun += gime->TowerRecPoints()->GetEntriesFast() ;  
350
351     fRecPointsInRun += gime->PreShowerRecPoints()->GetEntriesFast() ;  
352
353  }
354
355   
356
357   if(strstr(option,"tim")){
358
359     gBenchmark->Stop("EMCALClusterizer");
360
361     cout << "AliEMCALClusterizer:" << endl ;
362
363     cout << "  took " << gBenchmark->GetCpuTime("EMCALClusterizer") << " seconds for Clusterizing " 
364
365          <<  gBenchmark->GetCpuTime("EMCALClusterizer")/nevents << " seconds per event " << endl ;
366
367     cout << endl ;
368
369   }
370
371   
372
373 }
374
375
376
377 //____________________________________________________________________________
378
379 Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALTowerRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
380
381                                     Int_t nPar, Float_t * fitparameters) const
382
383
384
385   // Calls TMinuit to fit the energy distribution of a cluster with several maxima 
386
387   // The initial values for fitting procedure are set equal to the positions of local maxima.
388
389   // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
390
391
392
393   AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
394
395   TClonesArray * digits = gime->Digits() ; 
396
397   
398
399
400
401   gMinuit->mncler();                     // Reset Minuit's list of paramters
402
403   gMinuit->SetPrintLevel(-1) ;           // No Printout
404
405   gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;  
406
407                                          // To set the address of the minimization function 
408
409
410
411   TList * toMinuit = new TList();
412
413   toMinuit->AddAt(emcRP,0) ;
414
415   toMinuit->AddAt(digits,1) ;
416
417   
418
419   gMinuit->SetObjectFit(toMinuit) ;         // To tranfer pointer to UnfoldingChiSquare
420
421
422
423   // filling initial values for fit parameters
424
425   AliEMCALDigit * digit ;
426
427
428
429   Int_t ierflg  = 0; 
430
431   Int_t index   = 0 ;
432
433   Int_t nDigits = (Int_t) nPar / 3 ;
434
435
436
437   Int_t iDigit ;
438
439
440
441   AliEMCALGeometry * geom = gime->EMCALGeometry() ; 
442
443
444
445   for(iDigit = 0; iDigit < nDigits; iDigit++){
446
447     digit = maxAt[iDigit]; 
448
449
450
451     Int_t relid[4] ;
452
453     Float_t x = 0.;
454
455     Float_t z = 0.;
456
457     geom->AbsToRelNumbering(digit->GetId(), relid) ;
458
459     geom->PosInAlice(relid, x, z) ;
460
461
462
463     Float_t energy = maxAtEnergy[iDigit] ;
464
465
466
467     gMinuit->mnparm(index, "x",  x, 0.1, 0, 0, ierflg) ;
468
469     index++ ;   
470
471     if(ierflg != 0){ 
472
473       cout << "EMCAL Unfolding>  Unable to set initial value for fit procedure : x = " << x << endl ;
474
475       return kFALSE;
476
477     }
478
479     gMinuit->mnparm(index, "z",  z, 0.1, 0, 0, ierflg) ;
480
481     index++ ;   
482
483     if(ierflg != 0){
484
485       cout << "EMCAL Unfolding>  Unable to set initial value for fit procedure : z = " << z << endl ;
486
487       return kFALSE;
488
489     }
490
491     gMinuit->mnparm(index, "Energy",  energy , 0.05*energy, 0., 4.*energy, ierflg) ;
492
493     index++ ;   
494
495     if(ierflg != 0){
496
497       cout << "EMCAL Unfolding>  Unable to set initial value for fit procedure : energy = " << energy << endl ;      
498
499       return kFALSE;
500
501     }
502
503   }
504
505
506
507   Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
508
509                       //  depends on it. 
510
511   Double_t p1 = 1.0 ;
512
513   Double_t p2 = 0.0 ;
514
515
516
517   gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ;   // force TMinuit to reduce function calls  
518
519   gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ;   // force TMinuit to use my gradient  
520
521   gMinuit->SetMaxIterations(5);
522
523   gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ;  // No Warnings
524
525
526
527   gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ;    // minimize 
528
529
530
531   if(ierflg == 4){  // Minimum not found   
532
533     cout << "EMCAL Unfolding>  Fit not converged, cluster abandoned "<< endl ;      
534
535     return kFALSE ;
536
537   }            
538
539   for(index = 0; index < nPar; index++){
540
541     Double_t err ;
542
543     Double_t val ;
544
545     gMinuit->GetParameter(index, val, err) ;    // Returns value and error of parameter index
546
547     fitparameters[index] = val ;
548
549    }
550
551
552
553   delete toMinuit ;
554
555   return kTRUE;
556
557
558
559 }
560
561
562
563 //____________________________________________________________________________
564
565 void AliEMCALClusterizerv1::GetCalibrationParameters() 
566
567 {
568
569   AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
570
571   const AliEMCALDigitizer * dig = gime->Digitizer(BranchName()) ;
572
573
574
575   fADCchannelTower   = dig->GetTowerchannel() ;
576
577   fADCpedestalTower  = dig->GetTowerpedestal();
578
579
580
581   fADCchannelPreSho  = dig->GetPreShochannel() ;
582
583   fADCpedestalPreSho = dig->GetPreShopedestal() ; 
584
585
586
587 }
588
589
590
591 //____________________________________________________________________________
592
593 void AliEMCALClusterizerv1::Init()
594
595 {
596
597   // Make all memory allocations which can not be done in default constructor.
598
599   // Attach the Clusterizer task to the list of EMCAL tasks
600
601   
602
603   if ( strcmp(GetTitle(), "") == 0 )
604
605     SetTitle("galice.root") ;
606
607
608
609   TString branchname = GetName() ;
610
611   branchname.Remove(branchname.Index(Version())-1) ;
612
613
614
615   AliEMCALGetter * gime = AliEMCALGetter::GetInstance(GetTitle(), branchname.Data(), fToSplit ) ; 
616
617   if ( gime == 0 ) {
618
619     cerr << "ERROR: AliEMCALClusterizerv1::Init -> Could not obtain the Getter object !" << endl ; 
620
621     return ;
622
623   } 
624
625
626
627   fSplitFile = 0 ;
628
629   if(fToSplit){
630
631     // construct the name of the file as /path/EMCAL.SDigits.root
632
633     //First - extract full path if necessary
634
635     TString fileName(GetTitle()) ;
636
637     Ssiz_t islash = fileName.Last('/') ;
638
639     if(islash<fileName.Length())
640
641       fileName.Remove(islash+1,fileName.Length()) ;
642
643     else
644
645       fileName="" ;
646
647     // Next - append the file name 
648
649     fileName+="EMCAL.RecData." ;
650
651     if((strcmp(branchname.Data(),"Default")!=0)&&(strcmp(branchname.Data(),"")!=0)){
652
653       fileName+=branchname ;
654
655       fileName+="." ;
656
657     }
658
659     fileName+="root" ;
660
661     // Finally - check if the file already opened or open the file
662
663     fSplitFile = static_cast<TFile*>(gROOT->GetFile(fileName.Data()));   
664
665     if(!fSplitFile)
666
667       fSplitFile =  TFile::Open(fileName.Data(),"update") ;
668
669   }
670
671
672
673     
674
675   const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
676
677   fNTowers = geom->GetNZ() *  geom->GetNPhi() ;
678
679
680
681   if(!gMinuit) 
682
683     gMinuit = new TMinuit(100) ;
684
685
686
687   gime->PostClusterizer(this) ;
688
689   gime->PostRecPoints(branchname ) ;
690
691  
692
693 }
694
695
696
697 //____________________________________________________________________________
698
699 void AliEMCALClusterizerv1::InitParameters()
700
701 {
702
703   fNumberOfPreShoClusters = fNumberOfTowerClusters = 0 ; 
704
705
706
707  
708
709   
710
711   fPreShoClusteringThreshold  = 0.0001;
712
713   fTowerClusteringThreshold   = 0.2;   
714
715   
716
717   fTowerLocMaxCut  = 0.03 ;
718
719   fPreShoLocMaxCut = 0.03 ;
720
721   
722
723   fW0     = 4.5 ;
724
725   fW0CPV  = 4.0 ;
726
727
728
729   fTimeGate = 1.e-8 ; 
730
731   
732
733   fToUnfold = kFALSE ;
734
735    
736
737   TString clusterizerName( GetName()) ; 
738
739   if (clusterizerName.IsNull() ) 
740
741     clusterizerName = "Default" ; 
742
743   clusterizerName.Append(":") ; 
744
745   clusterizerName.Append(Version()) ; 
746
747   SetName(clusterizerName) ;
748
749   fRecPointsInRun          = 0 ; 
750
751
752
753 }
754
755
756
757 //____________________________________________________________________________
758
759 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2)const
760
761 {
762
763   // Gives the neighbourness of two digits = 0 are not neighbour but continue searching 
764
765   //                                       = 1 are neighbour
766
767   //                                       = 2 are not neighbour but do not continue searching
768
769   // neighbours are defined as digits having at least a common vertex 
770
771   // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster 
772
773   //                                      which is compared to a digit (d2)  not yet in a cluster  
774
775
776
777    AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ;
778
779
780
781   Int_t rv = 0 ; 
782
783
784
785   Int_t relid1[4] ; 
786
787   geom->AbsToRelNumbering(d1->GetId(), relid1) ; 
788
789
790
791   Int_t relid2[4] ; 
792
793   geom->AbsToRelNumbering(d2->GetId(), relid2) ; 
794
795  
796
797   if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same EMCAL Arm 
798
799     Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;  
800
801     Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;  
802
803     
804
805     if (( coldiff <= 1 )  && ( rowdiff <= 1 )){
806
807       if((relid1[1] != 0) || (TMath::Abs(d1->GetTime() - d2->GetTime() ) < fTimeGate))
808
809       rv = 1 ; 
810
811     }
812
813     else {
814
815       if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1)) 
816
817         rv = 2; //  Difference in row numbers is too large to look further 
818
819     }
820
821
822
823   } 
824
825   else {
826
827     
828
829     if( (relid1[0] < relid2[0]) || (relid1[1] != relid2[1]) )  
830
831       rv=2 ;
832
833
834
835   }
836
837
838
839   return rv ; 
840
841 }
842
843
844
845
846
847 //____________________________________________________________________________
848
849 Bool_t AliEMCALClusterizerv1::IsInTower(AliEMCALDigit * digit) const
850
851 {
852
853   // Tells if (true) or not (false) the digit is in a EMCAL-Tower 
854
855  
856
857   Bool_t rv = kFALSE ; 
858
859   if (!digit->IsInPreShower()) 
860
861     rv = kTRUE; 
862
863   return rv ; 
864
865 }
866
867
868
869 //____________________________________________________________________________
870
871 Bool_t AliEMCALClusterizerv1::IsInPreShower(AliEMCALDigit * digit) const
872
873 {
874
875   // Tells if (true) or not (false) the digit is in a EMCAL-PreShower
876
877  
878
879   Bool_t rv = kFALSE ; 
880
881   if (digit->IsInPreShower()) 
882
883     rv = kTRUE; 
884
885   return rv ; 
886
887 }
888
889
890
891 //____________________________________________________________________________
892
893 void AliEMCALClusterizerv1::WriteRecPoints(Int_t event)
894
895 {
896
897
898
899   // Creates new branches with given title
900
901   // fills and writes into TreeR.
902
903
904
905   AliEMCALGetter *gime = AliEMCALGetter::GetInstance() ; 
906
907   TObjArray * towerRecPoints = gime->TowerRecPoints() ; 
908
909   TObjArray * preshoRecPoints = gime->PreShowerRecPoints() ; 
910
911   TClonesArray * digits = gime->Digits() ; 
912
913   TTree * treeR ; 
914
915   
916
917   if(fToSplit){
918
919     if(!fSplitFile)
920
921       return ;
922
923     fSplitFile->cd() ;
924
925     TString name("TreeR") ;
926
927     name += event ; 
928
929     treeR = dynamic_cast<TTree*>(fSplitFile->Get(name)); 
930
931   }
932
933   else{
934
935     treeR = gAlice->TreeR();
936
937   }
938
939
940
941   if(!treeR){
942
943     gAlice->MakeTree("R", fSplitFile);
944
945     treeR = gAlice->TreeR() ;
946
947   }
948
949  
950
951   Int_t index ;
952
953   //Evaluate position, dispersion and other RecPoint properties...
954
955   for(index = 0; index < towerRecPoints->GetEntries(); index++)
956
957     (dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(index)))->EvalAll(fW0,digits) ;
958
959   
960
961   towerRecPoints->Sort() ;
962
963
964
965   for(index = 0; index < towerRecPoints->GetEntries(); index++)
966
967     (dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(index)))->SetIndexInList(index) ;
968
969
970
971   towerRecPoints->Expand(towerRecPoints->GetEntriesFast()) ; 
972
973
974
975   //Now the same for pre shower
976
977   for(index = 0; index < preshoRecPoints->GetEntries(); index++)
978
979     (dynamic_cast<AliEMCALRecPoint *>(preshoRecPoints->At(index)))->EvalAll(fW0CPV,digits)  ;
980
981
982
983   preshoRecPoints->Sort() ;
984
985
986
987   for(index = 0; index < preshoRecPoints->GetEntries(); index++)
988
989     (dynamic_cast<AliEMCALRecPoint *>(preshoRecPoints->At(index)))->SetIndexInList(index) ;
990
991
992
993   preshoRecPoints->Expand(preshoRecPoints->GetEntriesFast()) ;
994
995   
996
997   Int_t bufferSize = 32000 ;    
998
999   Int_t splitlevel = 0 ;
1000
1001
1002
1003   //First Tower branch
1004
1005   TBranch * towerBranch = treeR->Branch("EMCALTowerRP","TObjArray",&towerRecPoints,bufferSize,splitlevel);
1006
1007   towerBranch->SetTitle(BranchName());
1008
1009   
1010
1011   //Now Pre Shower branch 
1012
1013   TBranch * preshoBranch = treeR->Branch("EMCALPreShoRP","TObjArray",&preshoRecPoints,bufferSize,splitlevel);
1014
1015   preshoBranch->SetTitle(BranchName());
1016
1017     
1018
1019   //And Finally  clusterizer branch
1020
1021   AliEMCALClusterizerv1 * cl = (AliEMCALClusterizerv1*)gime->Clusterizer(BranchName()) ;
1022
1023   TBranch * clusterizerBranch = treeR->Branch("AliEMCALClusterizer","AliEMCALClusterizerv1",
1024
1025                                               &cl,bufferSize,splitlevel);
1026
1027   clusterizerBranch->SetTitle(BranchName());
1028
1029
1030
1031   towerBranch        ->Fill() ;
1032
1033   preshoBranch        ->Fill() ;
1034
1035   clusterizerBranch->Fill() ;
1036
1037
1038
1039   treeR->AutoSave() ; //Write(0,kOverwrite) ;  
1040
1041   if(gAlice->TreeR()!=treeR)
1042
1043     treeR->Delete(); 
1044
1045 }
1046
1047
1048
1049 //____________________________________________________________________________
1050
1051 void AliEMCALClusterizerv1::MakeClusters()
1052
1053 {
1054
1055   // Steering method to construct the clusters stored in a list of Reconstructed Points
1056
1057   // A cluster is defined as a list of neighbour digits
1058
1059     
1060
1061   AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
1062
1063   
1064
1065   TObjArray * towerRecPoints  = gime->TowerRecPoints(BranchName()) ; 
1066
1067   TObjArray * preshoRecPoints = gime->PreShowerRecPoints(BranchName()) ; 
1068
1069   towerRecPoints->Delete() ;
1070
1071   preshoRecPoints->Delete() ;
1072
1073   
1074
1075   TClonesArray * digits = gime->Digits() ; 
1076
1077   if ( !digits ) {
1078
1079     cerr << "ERROR:  AliEMCALClusterizerv1::MakeClusters -> Digits with name " 
1080
1081          << GetName() << " not found ! " << endl ; 
1082
1083     abort() ; 
1084
1085   } 
1086
1087   TClonesArray * digitsC =  dynamic_cast<TClonesArray*>(digits->Clone()) ;
1088
1089   
1090
1091   
1092
1093   // Clusterization starts  
1094
1095   
1096
1097   TIter nextdigit(digitsC) ; 
1098
1099   AliEMCALDigit * digit ; 
1100
1101   Bool_t notremoved = kTRUE ;
1102
1103   
1104
1105   while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
1106
1107     AliEMCALRecPoint * clu = 0 ; 
1108
1109     
1110
1111     TArrayI clusterdigitslist(1500) ;   
1112
1113     Int_t index ;
1114
1115  
1116
1117     if (( IsInTower (digit)  && Calibrate(digit->GetAmp(),digit->IsInPreShower()) > fTowerClusteringThreshold  ) || 
1118
1119         ( IsInPreShower (digit) && Calibrate(digit->GetAmp(),digit->IsInPreShower()) > fPreShoClusteringThreshold  ) ) {
1120
1121       
1122
1123       Int_t iDigitInCluster = 0 ; 
1124
1125       
1126
1127       if  ( IsInTower(digit) ) {   
1128
1129         // start a new Tower RecPoint
1130
1131         if(fNumberOfTowerClusters >= towerRecPoints->GetSize()) 
1132
1133           towerRecPoints->Expand(2*fNumberOfTowerClusters+1) ;
1134
1135         
1136
1137         towerRecPoints->AddAt(new  AliEMCALTowerRecPoint(""), fNumberOfTowerClusters) ;
1138
1139         clu = dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(fNumberOfTowerClusters)) ; 
1140
1141         fNumberOfTowerClusters++ ; 
1142
1143         clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->IsInPreShower())) ; 
1144
1145         clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ;  
1146
1147         iDigitInCluster++ ; 
1148
1149         digitsC->Remove(digit) ; 
1150
1151         
1152
1153       } else { 
1154
1155         
1156
1157         // start a new Pre Shower cluster
1158
1159         if(fNumberOfPreShoClusters >= preshoRecPoints->GetSize()) 
1160
1161           preshoRecPoints->Expand(2*fNumberOfPreShoClusters+1);
1162
1163         
1164
1165         preshoRecPoints->AddAt(new AliEMCALTowerRecPoint(""), fNumberOfPreShoClusters) ;
1166
1167         
1168
1169         clu =  dynamic_cast<AliEMCALTowerRecPoint *>(preshoRecPoints->At(fNumberOfPreShoClusters))  ;  
1170
1171         fNumberOfPreShoClusters++ ; 
1172
1173         clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->IsInPreShower() ) );     
1174
1175         clusterdigitslist[iDigitInCluster] = digit->GetIndexInList()  ; 
1176
1177         iDigitInCluster++ ; 
1178
1179         digitsC->Remove(digit) ; 
1180
1181         nextdigit.Reset() ;
1182
1183         
1184
1185         // Here we remove remaining Tower digits, which cannot make a cluster
1186
1187         
1188
1189         if( notremoved ) { 
1190
1191           while( ( digit = dynamic_cast<AliEMCALDigit *>(nextdigit()) ) ) {
1192
1193             if( IsInTower(digit) )
1194
1195               digitsC->Remove(digit) ;
1196
1197             else 
1198
1199               break ; 
1200
1201           }
1202
1203           notremoved = kFALSE ;
1204
1205         }
1206
1207         
1208
1209       } // else        
1210
1211       
1212
1213       nextdigit.Reset() ;
1214
1215       
1216
1217       AliEMCALDigit * digitN ; 
1218
1219       index = 0 ;
1220
1221       while (index < iDigitInCluster){ // scan over digits already in cluster 
1222
1223         digit =  (AliEMCALDigit*)digits->At(clusterdigitslist[index])  ;      
1224
1225         index++ ; 
1226
1227         while ( (digitN = (AliEMCALDigit *)nextdigit()) ) { // scan over the reduced list of digits 
1228
1229           Int_t ineb = AreNeighbours(digit, digitN);       // call (digit,digitN) in THAT oder !!!!!
1230
1231          switch (ineb ) {
1232
1233           case 0 :   // not a neighbour
1234
1235             break ;
1236
1237           case 1 :   // are neighbours 
1238
1239             clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), digitN->IsInPreShower() ) ) ;
1240
1241             clusterdigitslist[iDigitInCluster] = digitN->GetIndexInList() ; 
1242
1243             iDigitInCluster++ ; 
1244
1245             digitsC->Remove(digitN) ;
1246
1247             break ;
1248
1249           case 2 :   // too far from each other
1250
1251             goto endofloop;   
1252
1253           } // switch
1254
1255           
1256
1257         } // while digitN
1258
1259         
1260
1261       endofloop: ;
1262
1263         nextdigit.Reset() ; 
1264
1265         
1266
1267       } // loop over cluster     
1268
1269       
1270
1271     } // energy theshold  
1272
1273     
1274
1275     
1276
1277   } // while digit
1278
1279   
1280
1281   delete digitsC ;
1282
1283   
1284
1285 }
1286
1287
1288
1289 //____________________________________________________________________________
1290
1291 void AliEMCALClusterizerv1::MakeUnfolding()
1292
1293 {
1294
1295   Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
1296
1297   
1298
1299 //   // Unfolds clusters using the shape of an ElectroMagnetic shower
1300
1301 //   // Performs unfolding of all EMC/CPV clusters
1302
1303
1304
1305 //   AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
1306
1307   
1308
1309 //   const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
1310
1311 //   TObjArray * emcRecPoints = gime->TowerRecPoints() ; 
1312
1313 //   TObjArray * cpvRecPoints = gime->PreShoRecPoints() ; 
1314
1315 //   TClonesArray * digits = gime->Digits() ; 
1316
1317   
1318
1319 //   // Unfold first EMC clusters 
1320
1321 //   if(fNumberOfTowerClusters > 0){
1322
1323
1324
1325 //     Int_t nModulesToUnfold = geom->GetNModules() ; 
1326
1327
1328
1329 //     Int_t numberofNotUnfolded = fNumberOfTowerClusters ; 
1330
1331 //     Int_t index ;   
1332
1333 //     for(index = 0 ; index < numberofNotUnfolded ; index++){
1334
1335       
1336
1337 //       AliEMCALTowerRecPoint * emcRecPoint = (AliEMCALTowerRecPoint *) emcRecPoints->At(index) ;
1338
1339 //       if(emcRecPoint->GetEMCALMod()> nModulesToUnfold)
1340
1341 //      break ;
1342
1343       
1344
1345 //       Int_t nMultipl = emcRecPoint->GetMultiplicity() ; 
1346
1347 //       Int_t * maxAt = new Int_t[nMultipl] ;
1348
1349 //       Float_t * maxAtEnergy = new Float_t[nMultipl] ;
1350
1351 //       Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fTowerLocMaxCut,digits) ;
1352
1353       
1354
1355 //       if( nMax > 1 ) {     // if cluster is very flat (no pronounced maximum) then nMax = 0       
1356
1357 //      UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ;
1358
1359 //      emcRecPoints->Remove(emcRecPoint); 
1360
1361 //      emcRecPoints->Compress() ;
1362
1363 //      index-- ;
1364
1365 //      fNumberOfTowerClusters -- ;
1366
1367 //      numberofNotUnfolded-- ;
1368
1369 //       }
1370
1371       
1372
1373 //       delete[] maxAt ; 
1374
1375 //       delete[] maxAtEnergy ; 
1376
1377 //     }
1378
1379 //   } 
1380
1381 //   // Unfolding of EMC clusters finished
1382
1383
1384
1385
1386
1387 //   // Unfold now CPV clusters
1388
1389 //   if(fNumberOfPreShoClusters > 0){
1390
1391     
1392
1393 //     Int_t nModulesToUnfold = geom->GetNModules() ;
1394
1395
1396
1397 //     Int_t numberofPreShoNotUnfolded = fNumberOfPreShoClusters ;     
1398
1399 //     Int_t index ;   
1400
1401 //     for(index = 0 ; index < numberofPreShoNotUnfolded ; index++){
1402
1403       
1404
1405 //       AliEMCALRecPoint * recPoint = (AliEMCALRecPoint *) cpvRecPoints->At(index) ;
1406
1407
1408
1409 //       if(recPoint->GetEMCALMod()> nModulesToUnfold)
1410
1411 //      break ;
1412
1413       
1414
1415 //       AliEMCALTowerRecPoint * emcRecPoint = (AliEMCALTowerRecPoint*) recPoint ; 
1416
1417       
1418
1419 //       Int_t nMultipl = emcRecPoint->GetMultiplicity() ; 
1420
1421 //       Int_t * maxAt = new Int_t[nMultipl] ;
1422
1423 //       Float_t * maxAtEnergy = new Float_t[nMultipl] ;
1424
1425 //       Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fPreShoLocMaxCut,digits) ;
1426
1427       
1428
1429 //       if( nMax > 1 ) {     // if cluster is very flat (no pronounced maximum) then nMax = 0       
1430
1431 //      UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ;
1432
1433 //      cpvRecPoints->Remove(emcRecPoint); 
1434
1435 //      cpvRecPoints->Compress() ;
1436
1437 //      index-- ;
1438
1439 //      numberofPreShoNotUnfolded-- ;
1440
1441 //      fNumberOfPreShoClusters-- ;
1442
1443 //       }
1444
1445       
1446
1447 //       delete[] maxAt ; 
1448
1449 //       delete[] maxAtEnergy ; 
1450
1451 //     } 
1452
1453 //   }
1454
1455 //   //Unfolding of PreSho clusters finished
1456
1457   
1458
1459 }
1460
1461
1462
1463 //____________________________________________________________________________
1464
1465 Double_t  AliEMCALClusterizerv1::ShowerShape(Double_t r)
1466
1467
1468
1469   // Shape of the shower (see EMCAL TDR)
1470
1471   // If you change this function, change also the gradient evaluation in ChiSquare()
1472
1473
1474
1475   Double_t r4    = r*r*r*r ;
1476
1477   Double_t r295  = TMath::Power(r, 2.95) ;
1478
1479   Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
1480
1481   return shape ;
1482
1483 }
1484
1485
1486
1487 //____________________________________________________________________________
1488
1489 void  AliEMCALClusterizerv1::UnfoldCluster(AliEMCALTowerRecPoint * iniTower, 
1490
1491                                                  Int_t nMax, 
1492
1493                                                  AliEMCALDigit ** maxAt, 
1494
1495                                                  Float_t * maxAtEnergy)
1496
1497 {
1498
1499   // Performs the unfolding of a cluster with nMax overlapping showers 
1500
1501   
1502
1503   Fatal("AliEMCALClusterizerv1::UnfoldCluster", "--> Unfolding not implemented") ;
1504
1505
1506
1507  //  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
1508
1509 //   const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
1510
1511 //   const TClonesArray * digits = gime->Digits() ; 
1512
1513 //   TObjArray * emcRecPoints = gime->TowerRecPoints() ; 
1514
1515 //   TObjArray * cpvRecPoints = gime->PreShoRecPoints() ; 
1516
1517
1518
1519 //   Int_t nPar = 3 * nMax ;
1520
1521 //   Float_t * fitparameters = new Float_t[nPar] ;
1522
1523
1524
1525 //   Bool_t rv = FindFit(iniTower, maxAt, maxAtEnergy, nPar, fitparameters) ;
1526
1527 //   if( !rv ) {
1528
1529 //     // Fit failed, return and remove cluster
1530
1531 //     delete[] fitparameters ; 
1532
1533 //     return ;
1534
1535 //   }
1536
1537
1538
1539 //   // create ufolded rec points and fill them with new energy lists
1540
1541 //   // First calculate energy deposited in each sell in accordance with fit (without fluctuations): efit[]
1542
1543 //   // and later correct this number in acordance with actual energy deposition
1544
1545
1546
1547 //   Int_t nDigits = iniTower->GetMultiplicity() ;  
1548
1549 //   Float_t * efit = new Float_t[nDigits] ;
1550
1551 //   Float_t xDigit=0.,zDigit=0.,distance=0. ;
1552
1553 //   Float_t xpar=0.,zpar=0.,epar=0.  ;
1554
1555 //   Int_t relid[4] ;
1556
1557 //   AliEMCALDigit * digit = 0 ;
1558
1559 //   Int_t * emcDigits = iniTower->GetDigitsList() ;
1560
1561
1562
1563 //   Int_t iparam ;
1564
1565 //   Int_t iDigit ;
1566
1567 //   for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
1568
1569 //     digit = (AliEMCALDigit*) digits->At(emcDigits[iDigit] ) ;   
1570
1571 //     geom->AbsToRelNumbering(digit->GetId(), relid) ;
1572
1573 //     geom->RelPosInModule(relid, xDigit, zDigit) ;
1574
1575 //     efit[iDigit] = 0;
1576
1577
1578
1579 //     iparam = 0 ;    
1580
1581 //     while(iparam < nPar ){
1582
1583 //       xpar = fitparameters[iparam] ;
1584
1585 //       zpar = fitparameters[iparam+1] ;
1586
1587 //       epar = fitparameters[iparam+2] ;
1588
1589 //       iparam += 3 ;
1590
1591 //       distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar)  ;
1592
1593 //       distance =  TMath::Sqrt(distance) ;
1594
1595 //       efit[iDigit] += epar * ShowerShape(distance) ;
1596
1597 //     }
1598
1599 //   }
1600
1601   
1602
1603
1604
1605 //   // Now create new RecPoints and fill energy lists with efit corrected to fluctuations
1606
1607 //   // so that energy deposited in each cell is distributed betwin new clusters proportionally
1608
1609 //   // to its contribution to efit
1610
1611
1612
1613 //   Float_t * emcEnergies = iniTower->GetEnergiesList() ;
1614
1615 //   Float_t ratio ;
1616
1617
1618
1619 //   iparam = 0 ;
1620
1621 //   while(iparam < nPar ){
1622
1623 //     xpar = fitparameters[iparam] ;
1624
1625 //     zpar = fitparameters[iparam+1] ;
1626
1627 //     epar = fitparameters[iparam+2] ;
1628
1629 //     iparam += 3 ;    
1630
1631     
1632
1633 //     AliEMCALTowerRecPoint * emcRP = 0 ;  
1634
1635
1636
1637 //     if(iniTower->IsTower()){ //create new entries in fTowerRecPoints...
1638
1639       
1640
1641 //       if(fNumberOfTowerClusters >= emcRecPoints->GetSize())
1642
1643 //      emcRecPoints->Expand(2*fNumberOfTowerClusters) ;
1644
1645       
1646
1647 //       (*emcRecPoints)[fNumberOfTowerClusters] = new AliEMCALTowerRecPoint("") ;
1648
1649 //       emcRP = (AliEMCALTowerRecPoint *) emcRecPoints->At(fNumberOfTowerClusters);
1650
1651 //       fNumberOfTowerClusters++ ;
1652
1653 //     }
1654
1655 //     else{//create new entries in fPreShoRecPoints
1656
1657 //       if(fNumberOfPreShoClusters >= cpvRecPoints->GetSize())
1658
1659 //      cpvRecPoints->Expand(2*fNumberOfPreShoClusters) ;
1660
1661       
1662
1663 //       (*cpvRecPoints)[fNumberOfPreShoClusters] = new AliEMCALPreShoRecPoint("") ;
1664
1665 //       emcRP = (AliEMCALTowerRecPoint *) cpvRecPoints->At(fNumberOfPreShoClusters);
1666
1667 //       fNumberOfPreShoClusters++ ;
1668
1669 //     }
1670
1671     
1672
1673 //     Float_t eDigit ;
1674
1675 //     for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
1676
1677 //       digit = (AliEMCALDigit*) digits->At( emcDigits[iDigit] ) ; 
1678
1679 //       geom->AbsToRelNumbering(digit->GetId(), relid) ;
1680
1681 //       geom->RelPosInModule(relid, xDigit, zDigit) ;
1682
1683 //       distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar)  ;
1684
1685 //       distance =  TMath::Sqrt(distance) ;
1686
1687 //       ratio = epar * ShowerShape(distance) / efit[iDigit] ; 
1688
1689 //       eDigit = emcEnergies[iDigit] * ratio ;
1690
1691 //       emcRP->AddDigit( *digit, eDigit ) ;
1692
1693 //     }        
1694
1695 //   }
1696
1697  
1698
1699 //   delete[] fitparameters ; 
1700
1701 //   delete[] efit ; 
1702
1703   
1704
1705 }
1706
1707
1708
1709 //_____________________________________________________________________________
1710
1711 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag)
1712
1713 {
1714
1715   // Calculates the Chi square for the cluster unfolding minimization
1716
1717   // Number of parameters, Gradient, Chi squared, parameters, what to do
1718
1719
1720
1721   abort() ; 
1722
1723  //  Fatal("AliEMCALClusterizerv1::UnfoldingChiSquare","-->Unfolding not implemented") ;
1724
1725
1726
1727 //   TList * toMinuit = (TList*) gMinuit->GetObjectFit() ;
1728
1729
1730
1731 //   AliEMCALTowerRecPoint * emcRP = (AliEMCALTowerRecPoint*) toMinuit->At(0)  ;
1732
1733 //   TClonesArray * digits = (TClonesArray*)toMinuit->At(1)  ;
1734
1735
1736
1737
1738
1739   
1740
1741 //   //  AliEMCALTowerRecPoint * emcRP = (AliEMCALTowerRecPoint *) gMinuit->GetObjectFit() ; // TowerRecPoint to fit
1742
1743
1744
1745 //   Int_t * emcDigits     = emcRP->GetDigitsList() ;
1746
1747
1748
1749 //   Int_t nOdigits = emcRP->GetDigitsMultiplicity() ; 
1750
1751
1752
1753 //   Float_t * emcEnergies = emcRP->GetEnergiesList() ;
1754
1755
1756
1757 //   const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ; 
1758
1759 //   fret = 0. ;     
1760
1761 //   Int_t iparam ;
1762
1763
1764
1765 //   if(iflag == 2)
1766
1767 //     for(iparam = 0 ; iparam < nPar ; iparam++)    
1768
1769 //       Grad[iparam] = 0 ; // Will evaluate gradient
1770
1771   
1772
1773 //   Double_t efit ;    
1774
1775
1776
1777 //   AliEMCALDigit * digit ;
1778
1779 //   Int_t iDigit ;
1780
1781
1782
1783 //   for( iDigit = 0 ; iDigit < nOdigits ; iDigit++) {
1784
1785
1786
1787 //     digit = (AliEMCALDigit*) digits->At( emcDigits[iDigit] ) ; 
1788
1789
1790
1791 //     Int_t relid[4] ;
1792
1793 //     Float_t xDigit ;
1794
1795 //     Float_t zDigit ;
1796
1797
1798
1799 //     geom->AbsToRelNumbering(digit->GetId(), relid) ;
1800
1801
1802
1803 //     geom->RelPosInModule(relid, xDigit, zDigit) ;
1804
1805
1806
1807 //      if(iflag == 2){  // calculate gradient
1808
1809 //        Int_t iParam = 0 ;
1810
1811 //        efit = 0 ;
1812
1813 //        while(iParam < nPar ){
1814
1815 //       Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ;
1816
1817 //       iParam++ ; 
1818
1819 //       distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ; 
1820
1821 //       distance = TMath::Sqrt( distance ) ; 
1822
1823 //       iParam++ ;      
1824
1825 //       efit += x[iParam] * ShowerShape(distance) ;
1826
1827 //       iParam++ ;
1828
1829 //        }
1830
1831 //        Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E) 
1832
1833 //        iParam = 0 ;
1834
1835 //        while(iParam < nPar ){
1836
1837 //       Double_t xpar = x[iParam] ;
1838
1839 //       Double_t zpar = x[iParam+1] ;
1840
1841 //       Double_t epar = x[iParam+2] ;
1842
1843 //       Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) );
1844
1845 //       Double_t shape = sum * ShowerShape(dr) ;
1846
1847 //       Double_t r4 = dr*dr*dr*dr ;
1848
1849 //       Double_t r295 = TMath::Power(dr,2.95) ;
1850
1851 //       Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) +
1852
1853 //                                       0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ;
1854
1855          
1856
1857 //       Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ;  // Derivative over x    
1858
1859 //       iParam++ ; 
1860
1861 //       Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ;  // Derivative over z         
1862
1863 //       iParam++ ; 
1864
1865 //       Grad[iParam] += shape ;                                  // Derivative over energy             
1866
1867 //       iParam++ ; 
1868
1869 //        }
1870
1871 //      }
1872
1873 //      efit = 0;
1874
1875 //      iparam = 0 ;
1876
1877
1878
1879 //      while(iparam < nPar ){
1880
1881 //        Double_t xpar = x[iparam] ;
1882
1883 //        Double_t zpar = x[iparam+1] ;
1884
1885 //        Double_t epar = x[iparam+2] ;
1886
1887 //        iparam += 3 ;
1888
1889 //        Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar)  ;
1890
1891 //        distance =  TMath::Sqrt(distance) ;
1892
1893 //        efit += epar * ShowerShape(distance) ;
1894
1895 //      }
1896
1897
1898
1899 //      fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ; 
1900
1901 //      // Here we assume, that sigma = sqrt(E)
1902
1903 //   }
1904
1905
1906
1907 }
1908
1909
1910
1911 //____________________________________________________________________________
1912
1913 void AliEMCALClusterizerv1::Print(Option_t * option)const
1914
1915 {
1916
1917   // Print clusterizer parameters
1918
1919
1920
1921   if( strcmp(GetName(), "") !=0 ){
1922
1923     
1924
1925     // Print parameters
1926
1927  
1928
1929     TString taskName(GetName()) ; 
1930
1931     taskName.ReplaceAll(Version(), "") ;
1932
1933
1934
1935     cout << "---------------"<< taskName.Data() << " " << GetTitle()<< "-----------" << endl 
1936
1937          << "Clusterizing digits from the file: " << taskName.Data() << endl 
1938
1939          << "                           Branch: " << GetName() << endl 
1940
1941          << endl 
1942
1943          << "                       EMC Clustering threshold = " << fTowerClusteringThreshold << endl
1944
1945          << "                       EMC Local Maximum cut    = " << fTowerLocMaxCut << endl
1946
1947          << "                       EMC Logarothmic weight   = " << fW0 << endl
1948
1949          << endl
1950
1951          << "                       CPV Clustering threshold = " << fPreShoClusteringThreshold << endl
1952
1953          << "                       CPV Local Maximum cut    = " << fPreShoLocMaxCut << endl
1954
1955        << "                       CPV Logarothmic weight   = " << fW0CPV << endl
1956
1957          << endl ;
1958
1959     if(fToUnfold)
1960
1961       cout << " Unfolding on " << endl ;
1962
1963     else
1964
1965       cout << " Unfolding off " << endl ;
1966
1967     
1968
1969     cout << "------------------------------------------------------------------" <<endl ;
1970
1971   }
1972
1973   else
1974
1975     cout << " AliEMCALClusterizerv1 not initialized " << endl ;
1976
1977 }
1978
1979 //____________________________________________________________________________
1980
1981 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
1982
1983 {
1984
1985   // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
1986
1987
1988
1989   TObjArray * towerRecPoints = AliEMCALGetter::GetInstance()->TowerRecPoints() ; 
1990
1991   TObjArray * preshoRecPoints = AliEMCALGetter::GetInstance()->PreShowerRecPoints() ; 
1992
1993
1994
1995   cout << "AliEMCALClusterizerv1: : event "<<gAlice->GetEvNumber() << endl ;
1996
1997   cout << "       Found "<< towerRecPoints->GetEntriesFast() << " TOWER Rec Points and " 
1998
1999            << preshoRecPoints->GetEntriesFast() << " PRE SHOWER RecPoints" << endl ;
2000
2001
2002
2003   fRecPointsInRun +=  towerRecPoints->GetEntriesFast() ; 
2004
2005   fRecPointsInRun +=  preshoRecPoints->GetEntriesFast() ; 
2006
2007
2008
2009   if(strstr(option,"all")) {
2010
2011
2012
2013     cout << "Tower clusters " << endl ;
2014
2015     cout << " Index  Ene(MeV)   Multi  Module     phi     r  theta    Lambda 1   Lambda 2  # of prim  Primaries list "      <<  endl;      
2016
2017     
2018
2019     Int_t index ;
2020
2021     for (index = 0 ; index < towerRecPoints->GetEntries() ; index++) {
2022
2023       AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint * >(towerRecPoints->At(index)) ; 
2024
2025       TVector3  globalpos;  
2026
2027       rp->GetGlobalPosition(globalpos);
2028
2029       Float_t lambda[2]; 
2030
2031       rp->GetElipsAxis(lambda);
2032
2033       Int_t * primaries; 
2034
2035       Int_t nprimaries;
2036
2037       primaries = rp->GetPrimaries(nprimaries);
2038
2039
2040
2041       cout << setw(4) << rp->GetIndexInList() << "   " 
2042
2043            << setw(7) << setprecision(3) << rp->GetEnergy() << "      "
2044
2045            << setw(3) << rp->GetMultiplicity() << "      " 
2046
2047            << setw(1) << rp->GetEMCALArm() << "     " 
2048
2049            << setw(5) << setprecision(4) << globalpos.X() << "  " 
2050
2051            << setw(5) << setprecision(4) << globalpos.Y() << "  " 
2052
2053            << setw(5) << setprecision(4) << globalpos.Z() << "     "
2054
2055            << setw(4) << setprecision(2) << lambda[0]  << "  "
2056
2057            << setw(4) << setprecision(2) << lambda[1]  << "  "
2058
2059            << setw(2) << nprimaries << "  " ;
2060
2061      
2062
2063       for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
2064
2065         cout << setw(4) <<   primaries[iprimary] << "  "  ;
2066
2067       cout << endl ;     
2068
2069     }
2070
2071
2072
2073     //Now plot Pre shower recPoints
2074
2075
2076
2077     cout << "-----------------------------------------------------------------------"<<endl ;
2078
2079
2080
2081     cout << "PreShower clusters " << endl ;
2082
2083     cout << " Index  Ene(MeV)   Multi  Module     phi     r  theta    Lambda 1   Lambda 2  # of prim  Primaries list "      <<  endl;      
2084
2085     
2086
2087     for (index = 0 ; index < preshoRecPoints->GetEntries() ; index++) {
2088
2089       AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint *>(preshoRecPoints->At(index)) ; 
2090
2091       TVector3  globalpos;  
2092
2093       rp->GetGlobalPosition(globalpos);
2094
2095       Float_t lambda[2]; 
2096
2097       rp->GetElipsAxis(lambda);
2098
2099       Int_t * primaries; 
2100
2101       Int_t nprimaries;
2102
2103       primaries = rp->GetPrimaries(nprimaries);
2104
2105
2106
2107       cout << setw(4) << rp->GetIndexInList() << "   " 
2108
2109            << setw(7) << setprecision(3) << rp->GetEnergy() << "      "
2110
2111            << setw(3) << rp->GetMultiplicity() << "      " 
2112
2113            << setw(1) << rp->GetEMCALArm() << "     " 
2114
2115            << setw(5) << setprecision(4) << globalpos.X() << "  " 
2116
2117            << setw(5) << setprecision(4) << globalpos.Y() << "  " 
2118
2119            << setw(5) << setprecision(4) << globalpos.Z() << "     "
2120
2121            << setw(4) << setprecision(2) << lambda[0]  << "  "
2122
2123            << setw(4) << setprecision(2) << lambda[1]  << "  "
2124
2125            << setw(2) << nprimaries << "  " ;
2126
2127      
2128
2129       for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
2130
2131         cout << setw(4) <<   primaries[iprimary] << "  "  ;
2132
2133       cout << endl ;     
2134
2135     }
2136
2137
2138
2139     cout << "-----------------------------------------------------------------------"<<endl ;
2140
2141   }
2142
2143 }
2144
2145
2146