New Trigger Emulation and Trigger access from data (Rachid Guernane)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerData.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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 purpeateose. It is      *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17  
18  
19 EMCal trigger data container
20 for persistency of produced data presently stored in TTreeD
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
22 */
23
24 #include "AliEMCALTriggerData.h"
25 #include "AliEMCALTriggerPatch.h"
26
27 ClassImp(AliEMCALTriggerData)
28
29 //_____________
30 AliEMCALTriggerData::AliEMCALTriggerData() : TObject(),
31 fL0Patches( new TClonesArray("AliEMCALTriggerPatch") ),
32 fL0NPatches(),
33 fL0RegionSize(0,0),
34 fL0SubRegionSize(0,0),
35 fL0PatchSize(0,0),
36 fL0Peaks(),
37 fL1GammaPatches( new TClonesArray("AliEMCALTriggerPatch") ),
38 fL1JetPatches( new TClonesArray("AliEMCALTriggerPatch") ),
39 fL1RegionSize(0,0),
40 fL1GammaPatchSize(0,0),
41 fL1GammaSubRegionSize(0,0),
42 fL1JetPatchSize(0,0),
43 fL1JetSubRegionSize(0,0)
44 {  
45         for (Int_t i=0;i<32;i++) fL0NPatches[i] = 0;
46         for (Int_t i=0;i<48;i++) for (Int_t j=0;j<64;j++) fL1Region[i][j] = 0;
47         
48         fL1V0[0] = fL1V0[1] = 0;
49 }
50
51 //_____________
52 AliEMCALTriggerData::~AliEMCALTriggerData()
53 {
54 }
55
56 //_____________
57 void AliEMCALTriggerData::SetL0Patches(Int_t i, const TClonesArray& patches)
58 {
59         Int_t new_size = patches.GetEntriesFast();
60         Int_t old_size = fL0Patches->GetEntriesFast();
61
62         fL0NPatches[i] = new_size;
63         
64         Int_t size = 0;
65         for (Int_t j=0;j<=i;j++) size += fL0NPatches[j];
66                 
67         fL0Patches->Expand( size );
68                         
69         for (Int_t j=0;j<new_size;j++)
70         {
71                 AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>( patches.At(j) );
72                 new((*fL0Patches)[old_size+j]) AliEMCALTriggerPatch( *p );
73         }
74 }
75
76 //_____________
77 void AliEMCALTriggerData::SetL1GammaPatches(const TClonesArray& patches)
78 {
79         Int_t size = patches.GetEntriesFast();
80         fL1GammaPatches->Expand( size );
81
82         for (Int_t j=0;j<size;j++)
83         {
84                 AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>( patches.At(j) );
85                 new((*fL1GammaPatches)[j]) AliEMCALTriggerPatch( *p );
86         }
87 }
88
89 //_____________
90 void AliEMCALTriggerData::SetL1JetPatches(const TClonesArray& patches)
91 {
92         Int_t size = patches.GetEntriesFast();
93         
94         fL1JetPatches->Expand( size );
95         
96         for (Int_t j=0;j<size;j++)
97         {
98                 AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>( patches.At(j) );
99                 new((*fL1JetPatches)[j]) AliEMCALTriggerPatch( *p );
100         }
101 }
102
103 //_____________
104 void AliEMCALTriggerData::SetL1Region(Int_t**& region)
105 {
106         //
107         for (Int_t i=0;i<48;i++)
108                 for (Int_t j=0;j<64;j++)
109                 {
110                         fL1Region[i][j] = region[i][j];
111                 }
112 }
113
114 //_____________
115 void AliEMCALTriggerData::SetL1V0(const Int_t*& arr)
116 {
117         for (Int_t i=0;i<2;i++) fL1V0[i] = arr[i];
118 }
119
120 //_____________
121 void AliEMCALTriggerData::Scan() const
122 {
123         //
124         printf("L0:\n");
125         for (Int_t i=0;i<32;i++) printf("\tFound %2d patches in TRU %2d\n",fL0NPatches[i],i);
126         
127         printf("L1:\n");
128         printf("\tRegion of size.....................(%2d,%2d)\n",int(fL1RegionSize.X()),int(fL1RegionSize.Y()));
129         printf("\tGamma sub-region size..............(%2d,%2d)\n",int(fL1GammaSubRegionSize.X()),int(fL1GammaSubRegionSize.Y()));
130         printf("\tJet sub-region size................(%2d,%2d)\n",int(fL1JetSubRegionSize.X()),int(fL1JetSubRegionSize.Y()));
131         printf("\tFound %4d gamma patches of size...(%2d,%2d)\n",fL1GammaPatches->GetEntriesFast(),int(fL1GammaPatchSize.X()),int(fL1GammaPatchSize.Y()));
132         printf("\tFound %4d jet patches of size.....(%2d,%2d)\n",fL1JetPatches->GetEntriesFast(),int(fL1JetPatchSize.X()),int(fL1JetPatchSize.Y()));
133 }
134
135 //_____________
136 void AliEMCALTriggerData::Reset()
137 {
138         //
139     if (fL0Patches)           fL0Patches->Delete(); 
140         if (fL1GammaPatches) fL1GammaPatches->Delete();
141         if (fL1JetPatches)     fL1JetPatches->Delete(); 
142
143         for (Int_t i=0;i<32;i++) fL0NPatches[i] = 0;
144         for (Int_t i=0;i<48;i++) for (Int_t j=0;j<64;j++) fL1Region[i][j] = 0;
145         fL1V0[0] = fL1V0[1] = 0;
146 }
147
148
149