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 if(fgkNModules != AliITSgeomTGeo::GetNModules())AliError(Form("The total number of modules is not %d, but %d",fgkNModules,AliITSgeomTGeo::GetNModules()));
39 for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
40 fSPDNModules=modperlay[0]+modperlay[1];
41 fSDDNModules=modperlay[2]+modperlay[3];
42 fSSDNModules=modperlay[4]+modperlay[5];
43 // AliInfo(Form("Total modules: %d \n SPD modules=%d , SDD modules=%d, SSD modules=%d ",fgkNModules,fSPDNModules,fSDDNModules,fSSDNModules));
45 // kLimits[0:5] --> low fluw; kLimits[6,11] --> High flux
46 const Int_t kLimits[12]={25,25,20,20,10,10,300,300,200,200,100,100};
49 AliWarning("AliITSRecoParam is missing. Using defaults");
52 if(krp->GetEventSpecie() == AliRecoParam::kHighMult)offset=6;
56 for(Int_t i=0;i<6;i++){
57 maxval[i]=kLimits[i+offset];
60 if(i>0)modperlay[i]+=modperlay[i-1];
62 AliInfo(Form("Container created with sizes/layer: %s",values.Data()));
64 for(Int_t i=0;i<fgkNModules;i++){
65 if(i>=modperlay[layer])++layer;
66 fArray[i]=new TClonesArray("AliITSRecPoint",maxval[layer]);
71 //______________________________________________________________________
72 AliITSRecPointContainer::~AliITSRecPointContainer(){
74 for(Int_t i=0;i<fgkNModules;i++){
82 //______________________________________________________________________
83 void AliITSRecPointContainer::CookEntries(){
84 // From the number of entries in TTree R, the number of ITS subdetectors
85 // active for the present run is inferred
86 if(fActualSize == fgkNModules)fDet="ALL SPD SDD SSD ";
87 if(fActualSize == fSPDNModules) fDet = "SPD ";
88 if(fActualSize == fSDDNModules) fDet = "SDD ";
89 if(fActualSize == fSSDNModules)fDet = "SSD ";
90 if(fActualSize == (fSPDNModules+fSDDNModules)) fDet = "SPD SDD ";
91 if(fActualSize == (fSPDNModules+fSSDNModules))fDet = "SPD SSD ";
92 if(fActualSize == (fSDDNModules+fSSDNModules))fDet = "SDD SSD ";
93 if((!fDet.Contains("SPD")) && (!fDet.Contains("SDD")) &&
94 (!fDet.Contains("SSD"))){
95 AliError(Form("The number of active modules %d does not correspond to any standard configuration of the detector",fActualSize));
99 //______________________________________________________________________
100 TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR){
101 // retrieves Recpoints for module mod (offline mode: the event number is
102 // retrieved via the AliRunLoader object)
103 // The actual access to the RP TTree is done as follows:
104 // If the AliRunLoader object exists, the event number is taken from it
105 // If not, the data member fNextEvent is used.
106 // To set fNextEvent it is necessary to call PrepareToRead in advance.
107 // if this is never done, fNextEvent will have its default negative value
108 // and an error message will be delivered.
109 AliRunLoader* rl = AliRunLoader::Instance();
112 cureve = rl->GetEventNumber();
114 else if(fNextEvent>=0){
118 AliError("The RunLoader is not defined, PrepareToRead was not invoked. Revise calling sequence. Nothing done");
121 return FetchClusters(mod,tR,cureve);
123 //______________________________________________________________________
124 TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR,Int_t cureve){
125 // retrieves Recpoints for module mod
126 // cureve is the current event number. If it is different w.r.t.
127 // the event number stored in fCurrentEve, the recpoints are read from
128 // the TTree. Otherwise, the RP stored in memory are used.
129 if(cureve != fCurrentEve){
130 fCurrentEve = cureve;
132 TBranch *branch = NULL;
133 branch = tR->GetBranch("ITSRecPoints");
135 AliError("Branch ITSRecPoints not found on ITS recpoints TTree");
140 fActualSize = branch->GetEntries();
142 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
147 for(Int_t i=0;i<fSPDNModules;i++){
148 branch->SetAddress(&fArray[i]);
154 if(IsSPDActive())start+=fSPDNModules;
155 Int_t counter = fSPDNModules;
156 for(Int_t i=start;i<start+fSDDNModules;i++){
157 branch->SetAddress(&fArray[counter]);
164 if(IsSPDActive())start+=fSPDNModules;
165 if(IsSDDActive())start+=fSDDNModules;
166 Int_t counter = fSPDNModules+fSDDNModules;
167 for(Int_t i=start;i<start+fSSDNModules;i++){
168 branch->SetAddress(&fArray[counter]);
175 if(CheckBoundaries(mod)){
179 AliError(Form("Module %d is out of boundaries",mod));
185 //______________________________________________________________________
186 AliITSRecPointContainer* AliITSRecPointContainer::Instance(const AliITSRecoParam* kptr){
187 // returns AliITSRecPointContainer instance (singleton)
190 fgInstance = new AliITSRecPointContainer(AliITSReconstructor::GetRecoParam());
193 fgInstance = new AliITSRecPointContainer(kptr);
199 //______________________________________________________________________
200 void AliITSRecPointContainer::Reset(){
201 // Resets the status of the object
202 for(Int_t i=0;i<fgkNModules;i++){
203 (fArray[i])->Clear();