3 #include "AliITSRecoParam.h"
4 #include "AliITSReconstructor.h"
5 #include "AliITSRecPointContainer.h"
6 #include "AliITSRecPoint.h"
7 #include "AliRunLoader.h"
9 ClassImp(AliITSRecPointContainer)
11 //////////////////////////////////////////////////////////////////////
12 // Class to store ITS RecPoints for the duration of //
13 // one event processing //
14 // The container is cleared at each event and new RP //
15 // are loaded from TTree //
16 // Origin masera@to.infn.it Nov. 12 2009 //
17 //////////////////////////////////////////////////////////////////////
21 AliITSRecPointContainer* AliITSRecPointContainer::fgInstance = 0x0;
23 //______________________________________________________________________
24 AliITSRecPointContainer::AliITSRecPointContainer(const AliITSRecoParam* krp):TObject(),
34 // Default constructor
36 for(Int_t i=0;i<6;i++)fNClusters[i]=0;
37 if(fgkNModules != AliITSgeomTGeo::GetNModules())AliError(Form("The total number of modules is not %d, but %d",fgkNModules,AliITSgeomTGeo::GetNModules()));
40 for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
41 fSPDNModules=modperlay[0]+modperlay[1];
42 fSDDNModules=modperlay[2]+modperlay[3];
43 fSSDNModules=modperlay[4]+modperlay[5];
44 // AliInfo(Form("Total modules: %d \n SPD modules=%d , SDD modules=%d, SSD modules=%d ",fgkNModules,fSPDNModules,fSDDNModules,fSSDNModules));
46 // kLimits[0:5] --> low fluw; kLimits[6,11] --> High flux
47 const Int_t kLimits[12]={25,25,20,20,10,10,300,300,200,200,100,100};
50 AliWarning("AliITSRecoParam is missing. Using defaults");
53 if(krp->GetEventSpecie() == AliRecoParam::kHighMult)offset=6;
57 for(Int_t i=0;i<6;i++){
58 maxval[i]=kLimits[i+offset];
61 if(i>0)modperlay[i]+=modperlay[i-1];
63 AliInfo(Form("Container created with sizes/layer: %s",values.Data()));
65 for(Int_t i=0;i<fgkNModules;i++){
66 if(i>=modperlay[layer])++layer;
67 fArray[i]=new TClonesArray("AliITSRecPoint",maxval[layer]);
72 //______________________________________________________________________
73 AliITSRecPointContainer::~AliITSRecPointContainer(){
75 for(Int_t i=0;i<fgkNModules;i++){
83 //______________________________________________________________________
84 void AliITSRecPointContainer::CookEntries(){
85 // From the number of entries in TTree R, the number of ITS subdetectors
86 // active for the present run is inferred
87 if(fActualSize == fgkNModules)fDet="ALL SPD SDD SSD ";
88 if(fActualSize == fSPDNModules) fDet = "SPD ";
89 if(fActualSize == fSDDNModules) fDet = "SDD ";
90 if(fActualSize == fSSDNModules)fDet = "SSD ";
91 if(fActualSize == (fSPDNModules+fSDDNModules)) fDet = "SPD SDD ";
92 if(fActualSize == (fSPDNModules+fSSDNModules))fDet = "SPD SSD ";
93 if(fActualSize == (fSDDNModules+fSSDNModules))fDet = "SDD SSD ";
94 if((!fDet.Contains("SPD")) && (!fDet.Contains("SDD")) &&
95 (!fDet.Contains("SSD"))){
96 AliError(Form("The number of active modules %d does not correspond to any standard configuration of the detector",fActualSize));
100 //______________________________________________________________________
101 TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR){
102 // retrieves Recpoints for module mod (offline mode: the event number is
103 // retrieved via the AliRunLoader object)
104 // The actual access to the RP TTree is done as follows:
105 // If the AliRunLoader object exists, the event number is taken from it
106 // If not, the data member fNextEvent is used.
107 // To set fNextEvent it is necessary to call PrepareToRead in advance.
108 // if this is never done, fNextEvent will have its default negative value
109 // and an error message will be delivered.
110 AliRunLoader* rl = AliRunLoader::Instance();
113 cureve = rl->GetEventNumber();
115 else if(fNextEvent>=0){
119 AliError("The RunLoader is not defined, PrepareToRead was not invoked. Revise calling sequence. Nothing done");
122 return FetchClusters(mod,tR,cureve);
124 //______________________________________________________________________
125 TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR,Int_t cureve){
126 // retrieves Recpoints for module mod
127 // cureve is the current event number. If it is different w.r.t.
128 // the event number stored in fCurrentEve, the recpoints are read from
129 // the TTree. Otherwise, the RP stored in memory are used.
130 if(cureve != fCurrentEve){
131 fCurrentEve = cureve;
133 TBranch *branch = NULL;
134 branch = tR->GetBranch("ITSRecPoints");
136 AliError("Branch ITSRecPoints not found on ITS recpoints TTree");
141 fActualSize = branch->GetEntries();
143 if(fDet.IsNull())return NULL;
144 // it is assumed that the filling order of the tree is SPD, SDD, SSD
145 // even if one or two subdetector are missing
146 Int_t modL1=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1);
148 for(Int_t i=0;i<fSPDNModules;i++){
149 branch->SetAddress(&fArray[i]);
152 fNClusters[0]+=fArray[i]->GetEntries();
155 fNClusters[1]+=fArray[i]->GetEntries();
161 if(IsSPDActive())start+=fSPDNModules;
162 Int_t modL3=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3);
163 Int_t counter = fSPDNModules;
164 for(Int_t i=start;i<start+fSDDNModules;i++){
165 branch->SetAddress(&fArray[counter]);
169 fNClusters[2]+=fArray[i]->GetEntries();
172 fNClusters[3]+=fArray[i]->GetEntries();
178 if(IsSPDActive())start+=fSPDNModules;
179 if(IsSDDActive())start+=fSDDNModules;
180 Int_t modL5=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5);
181 Int_t counter = fSPDNModules+fSDDNModules;
182 for(Int_t i=start;i<start+fSSDNModules;i++){
183 branch->SetAddress(&fArray[counter]);
187 fNClusters[4]+=fArray[i]->GetEntries();
190 fNClusters[5]+=fArray[i]->GetEntries();
196 if(CheckBoundaries(mod)){
200 AliError(Form("Module %d is out of boundaries",mod));
205 //______________________________________________________________________
206 UInt_t AliITSRecPointContainer::GetNClustersInLayer(Int_t lay, TTree* tR, Int_t eventN){
207 // returns the number of clusters for laier lay
208 // layers are numbered from 1 to 6
210 AliError(Form("Layer %d is out of range",lay));
214 FetchClusters(0,tR,eventN);
219 return fNClusters[lay-1];
221 //______________________________________________________________________
222 UInt_t AliITSRecPointContainer::GetNClustersInLayerFast(Int_t lay) const {
223 // returns the number of clusters for laier lay
224 // layers are numbered from 1 to 6
225 // No checks are done on the event number: the numer of clusters
226 // for the event stored in memory is returned
228 AliError(Form("Layer %d is out of range",lay));
231 return fNClusters[lay-1];
233 //______________________________________________________________________
234 AliITSRecPointContainer* AliITSRecPointContainer::Instance(const AliITSRecoParam* kptr){
235 // returns AliITSRecPointContainer instance (singleton)
238 fgInstance = new AliITSRecPointContainer(AliITSReconstructor::GetRecoParam());
241 fgInstance = new AliITSRecPointContainer(kptr);
247 //______________________________________________________________________
248 void AliITSRecPointContainer::Destroy(){
249 // deletes the singleton
256 //______________________________________________________________________
257 void AliITSRecPointContainer::Reset(){
258 // Resets the status of the object
259 ClearClus(0,fgkNModules);
261 for(Int_t i=0;i<6;i++)fNClusters[i]=0;
263 //______________________________________________________________________
264 void AliITSRecPointContainer::ResetSPD(){
265 // Resets only the entries in fArray concerning SPD
266 // This method should be used with care only when the filling
267 // of the container is not done from the RP TTree.
268 fCurrentEve = -1000; // protection: if FetchClusters method will be used
269 // after this call, an ccess to the RP TTree will
271 ClearClus(0,fSPDNModules);
274 //______________________________________________________________________
275 void AliITSRecPointContainer::ResetSDD(){
276 // Resets only the entries in fArray concerning SDD
277 // This method should be used with care only when the filling
278 // of the container is not done from the RP TTree.
279 fCurrentEve = -1000; // protection: if FetchClusters method will be used
280 // after this call, an ccess to the RP TTree will
282 Int_t first = fSPDNModules;
283 Int_t last = first + fSDDNModules;
284 ClearClus(first,last);
287 //______________________________________________________________________
288 void AliITSRecPointContainer::ResetSSD(){
289 // Resets only the entries in fArray concerning SSD
290 // This method should be used with care only when the filling
291 // of the container is not done from the RP TTree.
292 fCurrentEve = -1000; // protection: if FetchClusters method will be used
293 // after this call, an ccess to the RP TTree will
295 Int_t first = fSPDNModules + fSDDNModules;
296 Int_t last = first + fSSDNModules;
297 ClearClus(first,last);