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 **************************************************************************/
16 /** @file AliFMDInput.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:42:40 2006
19 @brief FMD utility classes for reading FMD data
21 //___________________________________________________________________
23 // The classes defined here, are utility classes for reading in data
24 // for the FMD. They are put in a seperate library to not polute the
25 // normal libraries. The classes are intended to be used as base
26 // classes for customized class that do some sort of analysis on the
27 // various types of data produced by the FMD.
29 // Latest changes by Christian Holm Christensen
31 #include "AliFMDInput.h" // ALIFMDHIT_H
32 #include "AliFMDDebug.h" // ALIFMDDEBUG_H ALILOG_H
33 #include "AliLoader.h" // ALILOADER_H
34 #include "AliRunLoader.h" // ALIRUNLOADER_H
35 #include "AliRun.h" // ALIRUN_H
36 #include "AliStack.h" // ALISTACK_H
37 #include "AliRawReaderFile.h" // ALIRAWREADERFILE_H
38 #include "AliRawReaderRoot.h" // ALIRAWREADERROOT_H
39 #include "AliRawReaderDate.h" // ALIRAWREADERDATE_H
40 #include "AliRawEventHeaderBase.h"
41 #include "AliFMD.h" // ALIFMD_H
42 #include "AliFMDHit.h" // ALIFMDHIT_H
43 #include "AliFMDDigit.h" // ALIFMDDigit_H
44 #include "AliFMDSDigit.h" // ALIFMDDigit_H
45 #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H
46 #include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
47 #include "AliFMDGeometry.h"
49 #include <AliESDFMD.h>
50 #include <AliESDEvent.h>
51 #include <AliCDBManager.h>
52 #include <AliCDBEntry.h>
53 #include <AliAlignObjParams.h>
54 #include <AliTrackReference.h>
55 #include <TTree.h> // ROOT_TTree
56 #include <TChain.h> // ROOT_TChain
57 #include <TParticle.h> // ROOT_TParticle
58 #include <TString.h> // ROOT_TString
59 #include <TDatabasePDG.h> // ROOT_TDatabasePDG
60 #include <TMath.h> // ROOT_TMath
61 #include <TGeoManager.h> // ROOT_TGeoManager
62 #include <TSystemDirectory.h> // ROOT_TSystemDirectory
63 #include <Riostream.h> // ROOT_Riostream
64 #include <TFile.h> // ROOT_TFile
65 #include <TStreamerInfo.h>
68 //____________________________________________________________________
71 ; // This is here to keep Emacs for indenting the next line
74 //____________________________________________________________________
75 const AliFMDInput::ETrees AliFMDInput::fgkAllLoads[] = { kHits,
88 //____________________________________________________________________
89 AliFMDInput::AliFMDInput()
90 : TNamed("AliFMDInput", "Input handler for various FMD data"),
126 // Constructor of an FMD input object. Specify what data to read in
127 // using the AddLoad member function. Sub-classes should at a
128 // minimum overload the member function Event. A full job can be
129 // executed using the member function Run.
134 //____________________________________________________________________
135 AliFMDInput::AliFMDInput(const char* gAliceFile)
136 : TNamed("AliFMDInput", "Input handler for various FMD data"),
137 fGAliceFile(gAliceFile),
172 // Constructor of an FMD input object. Specify what data to read in
173 // using the AddLoad member function. Sub-classes should at a
174 // minimum overload the member function Event. A full job can be
175 // executed using the member function Run.
178 //____________________________________________________________________
180 AliFMDInput::SetLoads(UInt_t mask)
182 for (UInt_t i = 0; i < sizeof(mask); i++) {
183 if (!(mask & (1 << i))) continue;
184 const ETrees *ptype = fgkAllLoads;
186 ETrees type = *ptype;
187 if (i != UInt_t(type)) continue;
190 } while (*ptype++ != kUser);
194 //____________________________________________________________________
196 AliFMDInput::SetLoads(const char* what)
199 TObjArray* ll = l.Tokenize(", ");
202 while ((os = next())) {
203 ETrees type = ParseLoad(os->GetName());
210 //____________________________________________________________________
212 AliFMDInput::ParseLoad(const char* what)
216 const ETrees* ptype = fgkAllLoads;
218 ETrees type = *ptype;
219 if (opt.Contains(TreeName(type,true), TString::kIgnoreCase))
221 } while (*ptype++ != kUser);
224 //____________________________________________________________________
226 AliFMDInput::LoadedString(Bool_t dataOnly) const
229 if (!ret.IsNull()) return ret.Data();
231 const ETrees* ptype = fgkAllLoads;
233 ETrees type = *ptype;
235 (type == kKinematics ||
238 type == kTrackRefs)) continue;
239 if (!IsLoaded(*ptype)) continue;
241 if (!ret.IsNull()) ret.Append(",");
242 ret.Append(TreeName(type));
243 } while (*ptype++ != kUser);
247 //____________________________________________________________________
249 AliFMDInput::TreeName(ETrees tree, Bool_t shortest)
253 case kHits: return "hit";
254 case kKinematics: return "kin";
255 case kDigits: return "dig";
256 case kSDigits: return "sdig";
257 case kHeader: return "hea";
258 case kRecPoints: return "recp";
259 case kESD: return "esd";
260 case kRaw: return "raw";
261 case kGeometry: return "geo";
262 case kTrackRefs: return "trackr";
263 case kRawCalib: return "rawc";
264 case kUser: return "user";
269 case kHits: return "Hits";
270 case kKinematics: return "Kinematics";
271 case kDigits: return "Digits";
272 case kSDigits: return "SDigits";
273 case kHeader: return "Header";
274 case kRecPoints: return "RecPoints";
275 case kESD: return "ESD";
276 case kRaw: return "Raw";
277 case kGeometry: return "Geometry";
278 case kTrackRefs: return "TrackRefs";
279 case kRawCalib: return "RawCalib";
280 case kUser: return "User";
285 //____________________________________________________________________
287 AliFMDInput::NEvents() const
289 // Get number of events
290 if (IsLoaded(kRaw) ||
291 IsLoaded(kRawCalib)) return fReader->GetNumberOfEvents();
292 if (fChainE) return fChainE->GetEntriesFast();
293 if (fTreeE) return fTreeE->GetEntries();
297 //____________________________________________________________________
301 // Initialize the object. Get the needed loaders, and such.
303 // Check if we have been initialized
305 AliWarning("Already initialized");
309 const ETrees* ptype = fgkAllLoads;
311 ETrees type = *ptype;
312 what.Append(Form("\n\t%-20s: %s", TreeName(type),
313 IsLoaded(type) ? "yes" : "no"));
314 } while (*ptype++ != kUser);
316 Info("Init","Initialising w/mask 0x%04x%s", fTreeMask, what.Data());
318 if (IsLoaded(kDigits) ||
319 IsLoaded(kSDigits) ||
320 IsLoaded(kKinematics) ||
321 IsLoaded(kTrackRefs) ||
323 if (!gSystem->FindFile(".:/", fGAliceFile)) {
324 AliWarning(Form("Cannot find file %s in .:/", fGAliceFile.Data()));
327 fLoader = AliRunLoader::Open(fGAliceFile.Data(), "Alice", "read");
329 AliError(Form("Coulnd't read the file %s", fGAliceFile.Data()));
332 AliInfo(Form("Opened GAlice file %s", fGAliceFile.Data()));
334 if (fLoader->LoadgAlice()) return kFALSE;
336 fRun = fLoader->GetAliRun();
339 fFMD = static_cast<AliFMD*>(fRun->GetDetector("FMD"));
341 AliError("Failed to get detector FMD from loader");
345 // Get the FMD loader
346 fFMDLoader = fLoader->GetLoader("FMDLoader");
348 AliError("Failed to get detector FMD loader from loader");
351 if (fLoader->LoadHeader()) {
352 AliError("Failed to get event header information from loader");
355 fTreeE = fLoader->TreeE();
359 // Optionally, get the ESD files
360 if (IsLoaded(kESD)) {
361 fChainE = MakeChain("ESD", fInputDir, true);
362 fESDEvent = new AliESDEvent();
363 fESDEvent->ReadFromTree(fChainE);
364 // fChainE->SetBranchAddress("ESD", &fMainESD);
368 if (IsLoaded(kRaw) ||
369 IsLoaded(kRawCalib)) {
370 AliInfo("Getting FMD raw data digits");
371 fArrayA = new TClonesArray("AliFMDDigit");
373 if (!fRawFile.IsNull() && fRawFile.EndsWith(".root"))
374 fReader = new AliRawReaderRoot(fRawFile.Data());
375 else if (!fRawFile.IsNull() && fRawFile.EndsWith(".raw"))
376 fReader = new AliRawReaderDate(fRawFile.Data());
378 fReader = new AliRawReaderFile(-1);
380 if(!fRawFile.IsNull())
381 fReader = AliRawReader::Create(fRawFile.Data());
383 fReader = new AliRawReaderFile(-1);
385 fFMDReader = new AliFMDRawReader(fReader, 0);
388 // Optionally, get the geometry
389 if (IsLoaded(kGeometry)) {
392 fname = gSystem->DirName(fGAliceFile);
393 fname.Append("/geometry.root");
395 if (!gSystem->AccessPathName(fname.Data()))
397 AliCDBManager* cdb = AliCDBManager::Instance();
398 if (!cdb->IsDefaultStorageSet()) {
399 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
403 AliGeomManager::LoadGeometry(fname.IsNull() ? 0 : fname.Data());
405 AliCDBEntry* align = cdb->Get("FMD/Align/Data");
407 AliInfo("Got alignment data from CDB");
408 TClonesArray* array = dynamic_cast<TClonesArray*>(align->GetObject());
410 AliWarning("Invalid align data from CDB");
413 Int_t nAlign = array->GetEntries();
414 for (Int_t i = 0; i < nAlign; i++) {
415 AliAlignObjParams* a = static_cast<AliAlignObjParams*>(array->At(i));
416 if (!a->ApplyToGeometry()) {
417 AliWarning(Form("Failed to apply alignment to %s",
423 AliFMDGeometry* geom = AliFMDGeometry::Instance();
425 geom->InitTransformations();
433 //____________________________________________________________________
435 AliFMDInput::Begin(Int_t event)
437 // Called at the begining of each event. Per default, it gets the
438 // data trees and gets pointers to the output arrays. Users can
439 // overload this, but should call this member function in the
440 // overloaded member function of the derived class.
442 // Check if we have been initialized
444 AliError("Not initialized");
449 if (fLoader && fLoader->GetEvent(event)) return kFALSE;
451 // Possibly load global kinematics information
452 if (IsLoaded(kKinematics)) {
453 // AliInfo("Getting kinematics");
454 if (fLoader->LoadKinematics("READ")) return kFALSE;
455 fStack = fLoader->Stack();
458 // Possibly load FMD Hit information
459 if (IsLoaded(kHits)) {
460 // AliInfo("Getting FMD hits");
461 if (!fFMDLoader || fFMDLoader->LoadHits("READ")) return kFALSE;
462 fTreeH = fFMDLoader->TreeH();
463 if (!fArrayH) fArrayH = fFMD->Hits();
466 // Possibly load FMD TrackReference information
467 if (IsLoaded(kTrackRefs)) {
468 // AliInfo("Getting FMD hits");
469 if (!fLoader || fLoader->LoadTrackRefs("READ")) return kFALSE;
470 fTreeTR = fLoader->TreeTR();
471 if (!fArrayTR) fArrayTR = new TClonesArray("AliTrackReference");
472 fTreeTR->SetBranchAddress("TrackReferences", &fArrayTR);
475 // Possibly load heaedr information
476 if (IsLoaded(kHeader)) {
477 // AliInfo("Getting FMD hits");
478 if (!fLoader /* || fLoader->LoadHeader()*/) return kFALSE;
479 fHeader = fLoader->GetHeader();
482 // Possibly load FMD Digit information
483 if (IsLoaded(kDigits)) {
484 // AliInfo("Getting FMD digits");
485 if (!fFMDLoader || fFMDLoader->LoadDigits("READ")) return kFALSE;
486 fTreeD = fFMDLoader->TreeD();
488 if (!fArrayD) fArrayD = fFMD->Digits();
492 AliWarning(Form("Failed to load FMD Digits"));
496 // Possibly load FMD Sdigit information
497 if (IsLoaded(kSDigits)) {
498 // AliInfo("Getting FMD summable digits");
499 if (!fFMDLoader || fFMDLoader->LoadSDigits("READ")) {
500 AliWarning("Failed to load SDigits!");
503 fTreeS = fFMDLoader->TreeS();
504 if (!fArrayS) fArrayS = fFMD->SDigits();
507 // Possibly load FMD RecPoints information
508 if (IsLoaded(kRecPoints)) {
509 // AliInfo("Getting FMD reconstructed points");
510 if (!fFMDLoader || fFMDLoader->LoadRecPoints("READ")) return kFALSE;
511 fTreeR = fFMDLoader->TreeR();
512 if (!fArrayR) fArrayR = new TClonesArray("AliFMDRecPoint");
513 fTreeR->SetBranchAddress("FMD", &fArrayR);
516 // Possibly load FMD ESD information
517 if (IsLoaded(kESD)) {
518 // AliInfo("Getting FMD event summary data");
519 Int_t read = fChainE->GetEntry(event);
520 if (read <= 0) return kFALSE;
521 fESD = fESDEvent->GetFMDData();
522 if (!fESD) return kFALSE;
525 // Possibly load FMD Digit information
526 if (IsLoaded(kRaw) || IsLoaded(kRawCalib)) {
527 Bool_t mon = fRawFile.Contains("mem://");
528 // AliInfo("Getting FMD raw data digits");
529 if (mon) std::cout << "Waiting for event ..." << std::flush;
531 if (!fReader->NextEvent()) {
538 UInt_t eventType = fReader->GetType();
539 if(eventType == AliRawEventHeaderBase::kPhysicsEvent ||
540 eventType == AliRawEventHeaderBase::kCalibrationEvent)
543 if (mon) std::cout << "got it" << std::endl;
544 // AliFMDRawReader r(fReader, 0);
546 fFMDReader->ReadAdcs(fArrayA);
547 AliFMDDebug(1, ("Got a total of %d digits", fArrayA->GetEntriesFast()));
554 //____________________________________________________________________
558 // Process one event. The default implementation one or more of
560 // - ProcessHits if the hits are loaded.
561 // - ProcessDigits if the digits are loaded.
562 // - ProcessSDigits if the sumbable digits are loaded.
563 // - ProcessRecPoints if the reconstructed points are loaded.
564 // - ProcessESD if the event summary data is loaded
566 if (IsLoaded(kHits)) if (!ProcessHits()) return kFALSE;
567 if (IsLoaded(kTrackRefs))if (!ProcessTrackRefs()) return kFALSE;
568 if (IsLoaded(kKinematics) &&
569 IsLoaded(kHits)) if (!ProcessTracks()) return kFALSE;
570 if (IsLoaded(kKinematics))if (!ProcessStack()) return kFALSE;
571 if (IsLoaded(kSDigits)) if (!ProcessSDigits()) return kFALSE;
572 if (IsLoaded(kDigits)) if (!ProcessDigits()) return kFALSE;
573 if (IsLoaded(kRaw)) if (!ProcessRawDigits()) return kFALSE;
574 if (IsLoaded(kRawCalib)) if (!ProcessRawCalibDigits())return kFALSE;
575 if (IsLoaded(kRecPoints))if (!ProcessRecPoints()) return kFALSE;
576 if (IsLoaded(kESD)) if (!ProcessESDs()) return kFALSE;
577 if (IsLoaded(kUser)) if (!ProcessUsers()) return kFALSE;
582 //____________________________________________________________________
584 AliFMDInput::ProcessHits()
586 // Read the hit tree, and pass each hit to the member function
589 AliError("No hit tree defined");
593 AliError("No hit array defined");
597 Int_t nTracks = fTreeH->GetEntries();
598 for (Int_t i = 0; i < nTracks; i++) {
599 Int_t hitRead = fTreeH->GetEntry(i);
600 if (hitRead <= 0) continue;
602 Int_t nHit = fArrayH->GetEntries();
603 if (nHit <= 0) continue;
605 for (Int_t j = 0; j < nHit; j++) {
606 AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j));
609 TParticle* track = 0;
610 if (IsLoaded(kKinematics) && fStack) {
611 Int_t trackno = hit->Track();
612 track = fStack->Particle(trackno);
614 if (!ProcessHit(hit, track)) return kFALSE;
619 //____________________________________________________________________
621 AliFMDInput::ProcessTrackRefs()
623 // Read the reconstrcted points tree, and pass each reconstruction
624 // object (AliFMDRecPoint) to either ProcessRecPoint.
626 AliError("No track reference tree defined");
630 AliError("No track reference array defined");
634 Int_t nEv = fTreeTR->GetEntries();
635 for (Int_t i = 0; i < nEv; i++) {
636 Int_t trRead = fTreeTR->GetEntry(i);
637 if (trRead <= 0) continue;
638 Int_t nTrackRefs = fArrayTR->GetEntries();
639 for (Int_t j = 0; j < nTrackRefs; j++) {
640 AliTrackReference* trackRef =
641 static_cast<AliTrackReference*>(fArrayTR->At(j));
642 if (!trackRef) continue;
643 // if (trackRef->DetectorId() != AliTrackReference::kFMD) continue;
644 TParticle* track = 0;
645 if (IsLoaded(kKinematics) && fStack) {
646 Int_t trackno = trackRef->GetTrack();
647 track = fStack->Particle(trackno);
649 if (!ProcessTrackRef(trackRef,track)) return kFALSE;
654 //____________________________________________________________________
656 AliFMDInput::ProcessTracks()
658 // Read the hit tree, and pass each hit to the member function
661 AliError("No track tree defined");
665 AliError("No hit tree defined");
669 AliError("No hit array defined");
673 // Int_t nTracks = fStack->GetNtrack();
674 Int_t nTracks = fTreeH->GetEntries();
675 for (Int_t i = 0; i < nTracks; i++) {
676 Int_t trackno = nTracks - i - 1;
677 TParticle* track = fStack->Particle(trackno);
678 if (!track) continue;
680 // Get the hits for this track.
681 Int_t hitRead = fTreeH->GetEntry(i);
682 Int_t nHit = fArrayH->GetEntries();
683 if (nHit == 0 || hitRead <= 0) {
684 // Let user code see the track, even if there's no hits.
685 if (!ProcessTrack(trackno, track, 0)) return kFALSE;
689 // Loop over the hits corresponding to this track.
690 for (Int_t j = 0; j < nHit; j++) {
691 AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j));
692 if (!ProcessTrack(trackno, track, hit)) return kFALSE;
697 //____________________________________________________________________
699 AliFMDInput::ProcessStack()
701 // Read the hit tree, and pass each hit to the member function
704 AliError("No track tree defined");
707 Int_t nTracks = fStack->GetNtrack();
708 for (Int_t i = 0; i < nTracks; i++) {
709 Int_t trackno = nTracks - i - 1;
710 TParticle* track = fStack->Particle(trackno);
711 if (!track) continue;
713 if (!ProcessParticle(trackno, track)) return kFALSE;
717 //____________________________________________________________________
719 AliFMDInput::ProcessDigits()
721 // Read the digit tree, and pass each digit to the member function
724 AliError("No digit tree defined");
728 AliError("No digit array defined");
732 Int_t nEv = fTreeD->GetEntries();
733 for (Int_t i = 0; i < nEv; i++) {
734 Int_t digitRead = fTreeD->GetEntry(i);
735 if (digitRead <= 0) continue;
736 Int_t nDigit = fArrayD->GetEntries();
737 AliFMDDebug(0, ("Got %5d digits for this event", nDigit));
738 if (nDigit <= 0) continue;
739 for (Int_t j = 0; j < nDigit; j++) {
740 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayD->At(j));
741 if (!digit) continue;
742 if (!ProcessDigit(digit)) return kFALSE;
748 //____________________________________________________________________
750 AliFMDInput::ProcessSDigits()
752 // Read the summable digit tree, and pass each sumable digit to the
753 // member function ProcessSdigit.
755 AliWarning("No sdigit tree defined");
756 return kTRUE; // Empty SDigits is fine
759 AliWarning("No sdigit array defined");
760 return kTRUE; // Empty SDigits is fine
763 Int_t nEv = fTreeS->GetEntries();
764 for (Int_t i = 0; i < nEv; i++) {
765 Int_t sdigitRead = fTreeS->GetEntry(i);
766 if (sdigitRead <= 0) {
767 AliInfo(Form("Read nothing from tree"));
770 Int_t nSdigit = fArrayS->GetEntriesFast();
771 AliFMDDebug(0, ("Got %5d digits for this event", nSdigit));
772 AliInfo(Form("Got %5d digits for this event", nSdigit));
773 if (nSdigit <= 0) continue;
774 for (Int_t j = 0; j < nSdigit; j++) {
775 AliFMDSDigit* sdigit = static_cast<AliFMDSDigit*>(fArrayS->At(j));
776 if (!sdigit) continue;
777 if (!ProcessSDigit(sdigit)) return kFALSE;
783 //____________________________________________________________________
785 AliFMDInput::ProcessRawDigits()
787 // Read the digit tree, and pass each digit to the member function
790 AliError("No raw digit array defined");
794 Int_t nDigit = fArrayA->GetEntries();
795 if (nDigit <= 0) return kTRUE;
796 for (Int_t j = 0; j < nDigit; j++) {
797 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j));
798 if (!digit) continue;
799 if (AliLog::GetDebugLevel("FMD","") >= 40 && j < 30)
801 if (!ProcessRawDigit(digit)) return kFALSE;
806 //____________________________________________________________________
808 AliFMDInput::ProcessRawCalibDigits()
810 // Read the digit tree, and pass each digit to the member function
813 AliError("No raw digit array defined");
817 Int_t nDigit = fArrayA->GetEntries();
818 if (nDigit <= 0) return kTRUE;
819 for (Int_t j = 0; j < nDigit; j++) {
820 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j));
821 if (!digit) continue;
822 if (AliLog::GetDebugLevel("FMD","") >= 40 && j < 30)
824 if (!ProcessRawCalibDigit(digit)) return kFALSE;
829 //____________________________________________________________________
831 AliFMDInput::ProcessRecPoints()
833 // Read the reconstrcted points tree, and pass each reconstruction
834 // object (AliFMDRecPoint) to either ProcessRecPoint.
836 AliError("No recpoint tree defined");
840 AliError("No recpoints array defined");
844 Int_t nEv = fTreeR->GetEntries();
845 for (Int_t i = 0; i < nEv; i++) {
846 Int_t recRead = fTreeR->GetEntry(i);
847 if (recRead <= 0) continue;
848 Int_t nRecPoint = fArrayR->GetEntries();
849 for (Int_t j = 0; j < nRecPoint; j++) {
850 AliFMDRecPoint* recPoint = static_cast<AliFMDRecPoint*>(fArrayR->At(j));
851 if (!recPoint) continue;
852 if (!ProcessRecPoint(recPoint)) return kFALSE;
858 //____________________________________________________________________
860 AliFMDInput::ProcessESDs()
862 // Process event summary data
863 if (!fESD) return kFALSE;
864 for (UShort_t det = 1; det <= 3; det++) {
865 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
866 for (Char_t* rng = rings; *rng != '\0'; rng++) {
867 UShort_t nsec = (*rng == 'I' ? 20 : 40);
868 UShort_t nstr = (*rng == 'I' ? 512 : 256);
869 for (UShort_t sec = 0; sec < nsec; sec++) {
870 for (UShort_t str = 0; str < nstr; str++) {
871 Float_t eta = fESD->Eta(det,*rng,sec,str);
872 Float_t mult = fESD->Multiplicity(det,*rng,sec,str);
873 if (!fESD->IsAngleCorrected())
874 mult *= TMath::Abs(TMath::Cos(2.*TMath::ATan(TMath::Exp(-eta))));
875 if (!ProcessESD(det, *rng, sec, str, eta, mult)) continue;
883 //____________________________________________________________________
885 AliFMDInput::ProcessUsers()
887 // Process event summary data
888 for (UShort_t det = 1; det <= 3; det++) {
889 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
890 for (Char_t* rng = rings; *rng != '\0'; rng++) {
891 UShort_t nsec = (*rng == 'I' ? 20 : 40);
892 UShort_t nstr = (*rng == 'I' ? 512 : 256);
893 for (UShort_t sec = 0; sec < nsec; sec++) {
894 for (UShort_t str = 0; str < nstr; str++) {
895 Float_t v = GetSignal(det,*rng,sec,str);
896 if (!ProcessUser(det, *rng, sec, str, v)) continue;
904 //____________________________________________________________________
908 // Called at the end of each event. Per default, it unloads the
909 // data trees and resets the pointers to the output arrays. Users
910 // can overload this, but should call this member function in the
911 // overloaded member function of the derived class.
913 // Check if we have been initialized
915 AliError("Not initialized");
918 // Possibly unload global kinematics information
919 if (IsLoaded(kKinematics)) {
920 fLoader->UnloadKinematics();
924 // Possibly unload FMD Hit information
925 if (IsLoaded(kHits)) {
926 fFMDLoader->UnloadHits();
929 // Possibly unload FMD Digit information
930 if (IsLoaded(kDigits)) {
931 fFMDLoader->UnloadDigits();
934 // Possibly unload FMD Sdigit information
935 if (IsLoaded(kSDigits)) {
936 fFMDLoader->UnloadSDigits();
939 // Possibly unload FMD RecPoints information
940 if (IsLoaded(kRecPoints)) {
941 fFMDLoader->UnloadRecPoints();
944 // AliInfo("Now out event");
948 //____________________________________________________________________
950 AliFMDInput::Run(UInt_t maxEvents)
952 // Run over all events and files references in galice.root
955 if (!(retval = Init())) return retval;
957 fNEvents = NEvents();
958 if (fNEvents < 0) fNEvents = maxEvents;
959 else if (maxEvents > 0) fNEvents = TMath::Min(fNEvents,Int_t(maxEvents));
962 for (; fNEvents < 0 || event < fNEvents; event++) {
963 printf("\rEvent %8d/%8d ...", event, fNEvents);
964 if (!(retval = Begin(event))) break;
965 if (!(retval = Event())) break;
966 if (!(retval = End())) break;
968 printf("Looped over %8d events\n", event+1);
969 if (!retval) return retval;
974 //__________________________________________________________________
976 AliFMDInput::MakeLogScale(Int_t n, Double_t min, Double_t max)
978 // Service function to define a logarithmic axis.
981 // min Minimum of axis
982 // max Maximum of axis
986 for (Int_t i = 1; i < n+1; i++) bins[i] = bins[i-1] + (max-min)/n;
989 Float_t dp = n / TMath::Log10(max / min);
990 Float_t pmin = TMath::Log10(min);
991 for (Int_t i = 1; i < n+1; i++) {
992 Float_t p = pmin + i / dp;
993 bins[i] = TMath::Power(10, p);
998 //____________________________________________________________________
1000 AliFMDInput::ScanDirectory(TSystemDirectory* dir,
1001 const TString& olddir,
1003 const char* pattern, bool recursive)
1005 // Get list of files, and go back to old working directory
1006 TString oldDir(gSystem->WorkingDirectory());
1007 TList* files = dir->GetListOfFiles();
1008 gSystem->ChangeDirectory(oldDir);
1010 // Sort list of files and check if we should add it
1014 TSystemFile* file = 0;
1015 while ((file = static_cast<TSystemFile*>(next()))) {
1016 TString name(file->GetName());
1018 // Ignore special links
1019 if (name == "." || name == "..") continue;
1021 // Check if this is a directory
1022 if (file->IsDirectory()) {
1024 ScanDirectory(static_cast<TSystemDirectory*>(file),
1030 // If this is not a root file, ignore
1031 if (!name.EndsWith(".root")) continue;
1033 // If this file does not contain the pattern, ignore
1034 if (!name.Contains(pattern)) continue;
1035 if (name.Contains("friends")) continue;
1038 TString data(Form("%s/%s", file->GetTitle(), name.Data()));
1040 TFile* test = TFile::Open(data.Data(), "READ");
1041 if (!test || test->IsZombie()) {
1042 ::Warning("ScanDirectory", "Failed to open file %s", data.Data());
1050 //____________________________________________________________________
1052 AliFMDInput::MakeChain(const char* what, const char* datadir, bool recursive)
1056 const char* treeName = 0;
1057 const char* pattern = 0;
1058 if (w.Contains("ESD")) { treeName = "esdTree"; pattern = "AliESD"; }
1059 else if (w.Contains("MC")) { treeName = "TE"; pattern = "galice"; }
1061 ::Error("MakeChain", "Unknown mode '%s' (not one of ESD, or MC)", what);
1065 // --- Our data chain ----------------------------------------------
1066 TChain* chain = new TChain(treeName);
1068 // --- Get list of ESDs --------------------------------------------
1069 // Open source directory, and make sure we go back to were we were
1070 TString oldDir(gSystem->WorkingDirectory());
1071 TSystemDirectory d(datadir, datadir);
1072 ScanDirectory(&d, oldDir, chain, pattern, recursive);
1078 //____________________________________________________________________