1 /**************************************************************************
2 * Copyright(c) 2004, 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 //___________________________________________________________________
20 // The classes defined here, are utility classes for reading in data
21 // for the FMD. They are put in a seperate library to not polute the
22 // normal libraries. The classes are intended to be used as base
23 // classes for customized class that do some sort of analysis on the
24 // various types of data produced by the FMD.
26 // Latest changes by Christian Holm Christensen
28 #include "AliFMDInput.h" // ALIFMDHIT_H
29 #include "AliLog.h" // ALILOG_H
30 #include "Riostream.h" // ROOT_Riostream
31 #include <TDatabasePDG.h>
34 #include <TParticle.h>
35 #include "AliFMDHit.h" // ALIFMDHIT_H
36 #include "AliFMDDigit.h" // ALIFMDDigit_H
37 #include "AliFMDMultStrip.h" // ALIFMDMultStrip_H
38 #include "AliFMDMultRegion.h" // ALIFMDMultRegion_H
40 //____________________________________________________________________
43 ; // This is here to keep Emacs for indenting the next line
47 //____________________________________________________________________
48 AliFMDInput::AliFMDInput()
69 // Constructor of an FMD input object. Specify what data to read in
70 // using the AddLoad member function. Sub-classes should at a
71 // minimum overload the member function Event. A full job can be
72 // executed using the member function Run.
77 //____________________________________________________________________
78 AliFMDInput::AliFMDInput(const char* gAliceFile)
79 : fGAliceFile(gAliceFile),
99 // Constructor of an FMD input object. Specify what data to read in
100 // using the AddLoad member function. Sub-classes should at a
101 // minimum overload the member function Event. A full job can be
102 // executed using the member function Run.
105 //____________________________________________________________________
107 AliFMDInput::NEvents() const
109 // Get number of events
110 if (fTreeE) return fTreeE->GetEntries();
114 //____________________________________________________________________
118 // Initialize the object. Get the needed loaders, and such.
120 // Check if we have been initialized
122 AliWarning("Already initialized");
125 if (fGAliceFile.IsNull()) fGAliceFile = "galice.root";
127 fLoader = AliRunLoader::Open(fGAliceFile.Data(), "Alice", "read");
129 AliError(Form("Coulnd't read the file %s", fGAliceFile.Data()));
134 if (fLoader->LoadgAlice()) return kFALSE;
135 fRun = fLoader->GetAliRun();
138 fFMD = static_cast<AliFMD*>(fRun->GetDetector("FMD"));
140 AliError("Failed to get detector FMD from loader");
144 // Get the FMD loader
145 fFMDLoader = fLoader->GetLoader("FMDLoader");
147 AliError("Failed to get detector FMD loader from loader");
150 if (fLoader->LoadHeader()) {
151 AliError("Failed to get event header information from loader");
154 fTreeE = fLoader->TreeE();
160 //____________________________________________________________________
162 AliFMDInput::Begin(Int_t event)
164 // Called at the begining of each event. Per default, it gets the
165 // data trees and gets pointers to the output arrays. Users can
166 // overload this, but should call this member function in the
167 // overloaded member function of the derived class.
169 // Check if we have been initialized
171 AliError("Not initialized");
175 if (fLoader->GetEvent(event)) return kFALSE;
176 AliInfo(Form("Now in event %d/%d", event, NEvents()));
178 // Possibly load global kinematics information
179 if (TESTBIT(fTreeMask, kKinematics)) {
180 AliInfo("Getting kinematics");
181 if (fLoader->LoadKinematics()) return kFALSE;
182 fStack = fLoader->Stack();
184 // Possibly load FMD Hit information
185 if (TESTBIT(fTreeMask, kHits)) {
186 AliInfo("Getting FMD hits");
187 if (fFMDLoader->LoadHits()) return kFALSE;
188 fTreeH = fFMDLoader->TreeH();
189 if (!fArrayH) fArrayH = fFMD->Hits();
191 // Possibly load FMD Digit information
192 if (TESTBIT(fTreeMask, kDigits)) {
193 AliInfo("Getting FMD digits");
194 if (fFMDLoader->LoadDigits()) return kFALSE;
195 fTreeD = fFMDLoader->TreeD();
196 if (!fArrayD) fArrayD = fFMD->Digits();
198 // Possibly load FMD Sdigit information
199 if (TESTBIT(fTreeMask, kSDigits)) {
200 AliInfo("Getting FMD summable digits");
201 if (fFMDLoader->LoadSDigits()) return kFALSE;
202 fTreeS = fFMDLoader->TreeS();
203 if (!fArrayS) fArrayS = fFMD->SDigits();
205 // Possibly load FMD RecPoints information
206 if (TESTBIT(fTreeMask, kRecPoints)) {
207 AliInfo("Getting FMD reconstructed points");
208 if (fFMDLoader->LoadRecPoints()) return kFALSE;
209 fTreeR = fFMDLoader->TreeR();
210 if (!fArrayN) fArrayN = new TClonesArray("AliFMDMultStrip");
211 if (!fArrayP) fArrayP = new TClonesArray("AliFMDMultRegion");
212 fTreeR->SetBranchAddress("FMDNaiive", &fArrayN);
213 fTreeR->SetBranchAddress("FMDPoisson", &fArrayP);
218 //____________________________________________________________________
222 // Called at the end of each event. Per default, it unloads the
223 // data trees and resets the pointers to the output arrays. Users
224 // can overload this, but should call this member function in the
225 // overloaded member function of the derived class.
227 // Check if we have been initialized
229 AliError("Not initialized");
232 // Possibly unload global kinematics information
233 if (TESTBIT(fTreeMask, kKinematics)) {
234 fLoader->UnloadKinematics();
238 // Possibly unload FMD Hit information
239 if (TESTBIT(fTreeMask, kHits)) {
240 fFMDLoader->UnloadHits();
243 // Possibly unload FMD Digit information
244 if (TESTBIT(fTreeMask, kDigits)) {
245 fFMDLoader->UnloadDigits();
248 // Possibly unload FMD Sdigit information
249 if (TESTBIT(fTreeMask, kSDigits)) {
250 fFMDLoader->UnloadSDigits();
253 // Possibly unload FMD RecPoints information
254 if (TESTBIT(fTreeMask, kRecPoints)) {
255 fFMDLoader->UnloadRecPoints();
258 AliInfo("Now out event");
262 //____________________________________________________________________
266 // Run over all events and files references in galice.root
269 if (!(retval = Init())) return retval;
271 Int_t nEvents = NEvents();
272 for (Int_t event = 0; event < nEvents; event++) {
273 if (!(retval = Begin(event))) break;
274 if (!(retval = Event())) break;
275 if (!(retval = End())) break;
277 if (!retval) return retval;
282 //====================================================================
283 ClassImp(AliFMDInputHits)
289 AliFMDInputHits::Event()
291 // Read the hit tree, and pass each hit to the member function
292 // ProcessHit. Optionally, if the user said `AddLoad(kKinematics)'
293 // the track corresponding to the hit will also be passed to the
294 // ProcessHit member function of the derived class.
296 AliError("No hit tree defined");
299 Int_t nTracks = fTreeH->GetEntries();
300 for (Int_t i = 0; i < nTracks; i++) {
301 Int_t hitRead = fTreeH->GetEntry(i);
302 if (hitRead <= 0) continue;
304 AliError("No hit array defined");
307 Int_t nHit = fArrayH->GetEntries();
308 if (nHit <= 0) continue;
309 for (Int_t j = 0; j < nHit; j++) {
310 AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j));
312 TParticle* track = 0;
313 if (TESTBIT(fTreeMask, kKinematics) && fStack) {
314 Int_t trackno = hit->Track();
315 track = fStack->Particle(trackno);
317 if (!ProcessHit(hit, track)) return kFALSE;
323 //====================================================================
324 ClassImp(AliFMDInputDigits)
330 AliFMDInputDigits::Event()
332 // Read the digit tree, and pass each digit to the member function
334 Int_t nEv = fTreeD->GetEntries();
335 for (Int_t i = 0; i < nEv; i++) {
336 Int_t digitRead = fTreeD->GetEntry(i);
337 if (digitRead <= 0) continue;
338 Int_t nDigit = fArrayD->GetEntries();
339 if (nDigit <= 0) continue;
340 for (Int_t j = 0; j < nDigit; j++) {
341 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayD->At(j));
342 if (!digit) continue;
343 if (!ProcessDigit(digit)) return kFALSE;
349 //====================================================================
350 ClassImp(AliFMDInputSDigits)
356 AliFMDInputSDigits::Event()
358 // Read the summable digit tree, and pass each sumable digit to the
359 // member function ProcessSdigit.
360 Int_t nEv = fTreeD->GetEntries();
361 for (Int_t i = 0; i < nEv; i++) {
362 Int_t sdigitRead = fTreeS->GetEntry(i);
363 if (sdigitRead <= 0) continue;
364 Int_t nSdigit = fArrayS->GetEntries();
365 if (nSdigit <= 0) continue;
366 for (Int_t j = 0; j < nSdigit; j++) {
367 AliFMDSDigit* sdigit = static_cast<AliFMDSDigit*>(fArrayS->At(j));
368 if (!sdigit) continue;
369 if (!ProcessSDigit(sdigit)) return kFALSE;
375 //====================================================================
376 ClassImp(AliFMDInputRecPoints)
382 AliFMDInputRecPoints::Event()
384 // Read the reconstrcted points tree, and pass each reconstruction
385 // object to either ProcessStrip (for AliFMDMultStrip objects), or
386 // ProcessRegion (for AliFMDMultRegion objects).
387 Int_t nEv = fTreeR->GetEntries();
388 for (Int_t i = 0; i < nEv; i++) {
389 Int_t recRead = fTreeR->GetEntry(i);
390 if (recRead <= 0) continue;
391 Int_t nRecStrip = fArrayN->GetEntries();
392 for (Int_t j = 0; j < nRecStrip; j++) {
393 AliFMDMultStrip* strip = static_cast<AliFMDMultStrip*>(fArrayN->At(j));
394 if (!strip) continue;
395 if (!ProcessStrip(strip)) return kFALSE;
397 Int_t nRecRegion = fArrayP->GetEntries();
398 for (Int_t j = 0; j < nRecRegion; j++) {
399 AliFMDMultRegion* region =static_cast<AliFMDMultRegion*>(fArrayP->At(j));
400 if (!region) continue;
401 if (!ProcessRegion(region)) return kFALSE;
409 //____________________________________________________________________