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());
209 //____________________________________________________________________
211 AliFMDInput::ParseLoad(const char* what)
215 const ETrees* ptype = fgkAllLoads;
217 ETrees type = *ptype;
218 if (opt.Contains(TreeName(type,true), TString::kIgnoreCase))
220 } while (*ptype++ != kUser);
223 //____________________________________________________________________
225 AliFMDInput::LoadedString(Bool_t dataOnly) const
228 if (!ret.IsNull()) return ret.Data();
230 const ETrees* ptype = fgkAllLoads;
232 ETrees type = *ptype;
234 (type == kKinematics ||
237 type == kTrackRefs)) continue;
238 if (!IsLoaded(*ptype)) continue;
240 if (!ret.IsNull()) ret.Append(",");
241 ret.Append(TreeName(type));
242 } while (*ptype++ != kUser);
246 //____________________________________________________________________
248 AliFMDInput::TreeName(ETrees tree, Bool_t shortest)
252 case kHits: return "hit";
253 case kKinematics: return "kin";
254 case kDigits: return "dig";
255 case kSDigits: return "sdig";
256 case kHeader: return "hea";
257 case kRecPoints: return "recp";
258 case kESD: return "esd";
259 case kRaw: return "raw";
260 case kGeometry: return "geo";
261 case kTrackRefs: return "trackr";
262 case kRawCalib: return "rawc";
263 case kUser: return "user";
268 case kHits: return "Hits";
269 case kKinematics: return "Kinematics";
270 case kDigits: return "Digits";
271 case kSDigits: return "SDigits";
272 case kHeader: return "Header";
273 case kRecPoints: return "RecPoints";
274 case kESD: return "ESD";
275 case kRaw: return "Raw";
276 case kGeometry: return "Geometry";
277 case kTrackRefs: return "TrackRefs";
278 case kRawCalib: return "RawCalib";
279 case kUser: return "User";
284 //____________________________________________________________________
286 AliFMDInput::NEvents() const
288 // Get number of events
289 if (IsLoaded(kRaw) ||
290 IsLoaded(kRawCalib)) return fReader->GetNumberOfEvents();
291 if (fChainE) return fChainE->GetEntriesFast();
292 if (fTreeE) return fTreeE->GetEntries();
296 //____________________________________________________________________
300 // Initialize the object. Get the needed loaders, and such.
302 // Check if we have been initialized
304 AliWarning("Already initialized");
308 const ETrees* ptype = fgkAllLoads;
310 ETrees type = *ptype;
311 what.Append(Form("\n\t%-20s: %s", TreeName(type),
312 IsLoaded(type) ? "yes" : "no"));
313 } while (*ptype++ != kUser);
315 Info("Init","Initialising w/mask 0x%04x%s", fTreeMask, what.Data());
317 if (IsLoaded(kDigits) ||
318 IsLoaded(kSDigits) ||
319 IsLoaded(kKinematics) ||
320 IsLoaded(kTrackRefs) ||
322 if (!gSystem->FindFile(".:/", fGAliceFile)) {
323 AliWarning(Form("Cannot find file %s in .:/", fGAliceFile.Data()));
326 fLoader = AliRunLoader::Open(fGAliceFile.Data(), "Alice", "read");
328 AliError(Form("Coulnd't read the file %s", fGAliceFile.Data()));
331 AliInfo(Form("Opened GAlice file %s", fGAliceFile.Data()));
333 if (fLoader->LoadgAlice()) return kFALSE;
335 fRun = fLoader->GetAliRun();
338 fFMD = static_cast<AliFMD*>(fRun->GetDetector("FMD"));
340 AliError("Failed to get detector FMD from loader");
344 // Get the FMD loader
345 fFMDLoader = fLoader->GetLoader("FMDLoader");
347 AliError("Failed to get detector FMD loader from loader");
350 if (fLoader->LoadHeader()) {
351 AliError("Failed to get event header information from loader");
354 fTreeE = fLoader->TreeE();
358 // Optionally, get the ESD files
359 if (IsLoaded(kESD)) {
360 fChainE = MakeChain("ESD", fInputDir, true);
361 fESDEvent = new AliESDEvent();
362 fESDEvent->ReadFromTree(fChainE);
363 // fChainE->SetBranchAddress("ESD", &fMainESD);
367 if (IsLoaded(kRaw) ||
368 IsLoaded(kRawCalib)) {
369 AliInfo("Getting FMD raw data digits");
370 fArrayA = new TClonesArray("AliFMDDigit");
372 if (!fRawFile.IsNull() && fRawFile.EndsWith(".root"))
373 fReader = new AliRawReaderRoot(fRawFile.Data());
374 else if (!fRawFile.IsNull() && fRawFile.EndsWith(".raw"))
375 fReader = new AliRawReaderDate(fRawFile.Data());
377 fReader = new AliRawReaderFile(-1);
379 if(!fRawFile.IsNull())
380 fReader = AliRawReader::Create(fRawFile.Data());
382 fReader = new AliRawReaderFile(-1);
384 fFMDReader = new AliFMDRawReader(fReader, 0);
387 // Optionally, get the geometry
388 if (IsLoaded(kGeometry)) {
391 fname = gSystem->DirName(fGAliceFile);
392 fname.Append("/geometry.root");
394 if (!gSystem->AccessPathName(fname.Data()))
396 AliCDBManager* cdb = AliCDBManager::Instance();
397 if (!cdb->IsDefaultStorageSet()) {
398 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
402 AliGeomManager::LoadGeometry(fname.IsNull() ? 0 : fname.Data());
404 AliCDBEntry* align = cdb->Get("FMD/Align/Data");
406 AliInfo("Got alignment data from CDB");
407 TClonesArray* array = dynamic_cast<TClonesArray*>(align->GetObject());
409 AliWarning("Invalid align data from CDB");
412 Int_t nAlign = array->GetEntries();
413 for (Int_t i = 0; i < nAlign; i++) {
414 AliAlignObjParams* a = static_cast<AliAlignObjParams*>(array->At(i));
415 if (!a->ApplyToGeometry()) {
416 AliWarning(Form("Failed to apply alignment to %s",
422 AliFMDGeometry* geom = AliFMDGeometry::Instance();
424 geom->InitTransformations();
432 //____________________________________________________________________
434 AliFMDInput::Begin(Int_t event)
436 // Called at the begining of each event. Per default, it gets the
437 // data trees and gets pointers to the output arrays. Users can
438 // overload this, but should call this member function in the
439 // overloaded member function of the derived class.
441 // Check if we have been initialized
443 AliError("Not initialized");
448 if (fLoader && fLoader->GetEvent(event)) return kFALSE;
450 // Possibly load global kinematics information
451 if (IsLoaded(kKinematics)) {
452 // AliInfo("Getting kinematics");
453 if (fLoader->LoadKinematics("READ")) return kFALSE;
454 fStack = fLoader->Stack();
457 // Possibly load FMD Hit information
458 if (IsLoaded(kHits)) {
459 // AliInfo("Getting FMD hits");
460 if (!fFMDLoader || fFMDLoader->LoadHits("READ")) return kFALSE;
461 fTreeH = fFMDLoader->TreeH();
462 if (!fArrayH) fArrayH = fFMD->Hits();
465 // Possibly load FMD TrackReference information
466 if (IsLoaded(kTrackRefs)) {
467 // AliInfo("Getting FMD hits");
468 if (!fLoader || fLoader->LoadTrackRefs("READ")) return kFALSE;
469 fTreeTR = fLoader->TreeTR();
470 if (!fArrayTR) fArrayTR = new TClonesArray("AliTrackReference");
471 fTreeTR->SetBranchAddress("TrackReferences", &fArrayTR);
474 // Possibly load heaedr information
475 if (IsLoaded(kHeader)) {
476 // AliInfo("Getting FMD hits");
477 if (!fLoader /* || fLoader->LoadHeader()*/) return kFALSE;
478 fHeader = fLoader->GetHeader();
481 // Possibly load FMD Digit information
482 if (IsLoaded(kDigits)) {
483 // AliInfo("Getting FMD digits");
484 if (!fFMDLoader || fFMDLoader->LoadDigits("READ")) return kFALSE;
485 fTreeD = fFMDLoader->TreeD();
487 if (!fArrayD) fArrayD = fFMD->Digits();
491 AliWarning(Form("Failed to load FMD Digits"));
495 // Possibly load FMD Sdigit information
496 if (IsLoaded(kSDigits)) {
497 // AliInfo("Getting FMD summable digits");
498 if (!fFMDLoader || fFMDLoader->LoadSDigits("READ")) {
499 AliWarning("Failed to load SDigits!");
502 fTreeS = fFMDLoader->TreeS();
503 if (!fArrayS) fArrayS = fFMD->SDigits();
506 // Possibly load FMD RecPoints information
507 if (IsLoaded(kRecPoints)) {
508 // AliInfo("Getting FMD reconstructed points");
509 if (!fFMDLoader || fFMDLoader->LoadRecPoints("READ")) return kFALSE;
510 fTreeR = fFMDLoader->TreeR();
511 if (!fArrayR) fArrayR = new TClonesArray("AliFMDRecPoint");
512 fTreeR->SetBranchAddress("FMD", &fArrayR);
515 // Possibly load FMD ESD information
516 if (IsLoaded(kESD)) {
517 // AliInfo("Getting FMD event summary data");
518 Int_t read = fChainE->GetEntry(event);
519 if (read <= 0) return kFALSE;
520 fESD = fESDEvent->GetFMDData();
521 if (!fESD) return kFALSE;
524 // Possibly load FMD Digit information
525 if (IsLoaded(kRaw) || IsLoaded(kRawCalib)) {
526 Bool_t mon = fRawFile.Contains("mem://");
527 // AliInfo("Getting FMD raw data digits");
528 if (mon) std::cout << "Waiting for event ..." << std::flush;
530 if (!fReader->NextEvent()) {
537 UInt_t eventType = fReader->GetType();
538 if(eventType == AliRawEventHeaderBase::kPhysicsEvent ||
539 eventType == AliRawEventHeaderBase::kCalibrationEvent)
542 if (mon) std::cout << "got it" << std::endl;
543 // AliFMDRawReader r(fReader, 0);
545 fFMDReader->ReadAdcs(fArrayA);
546 AliFMDDebug(1, ("Got a total of %d digits", fArrayA->GetEntriesFast()));
553 //____________________________________________________________________
557 // Process one event. The default implementation one or more of
559 // - ProcessHits if the hits are loaded.
560 // - ProcessDigits if the digits are loaded.
561 // - ProcessSDigits if the sumbable digits are loaded.
562 // - ProcessRecPoints if the reconstructed points are loaded.
563 // - ProcessESD if the event summary data is loaded
565 if (IsLoaded(kHits)) if (!ProcessHits()) return kFALSE;
566 if (IsLoaded(kTrackRefs))if (!ProcessTrackRefs()) return kFALSE;
567 if (IsLoaded(kKinematics) &&
568 IsLoaded(kHits)) if (!ProcessTracks()) return kFALSE;
569 if (IsLoaded(kKinematics))if (!ProcessStack()) return kFALSE;
570 if (IsLoaded(kSDigits)) if (!ProcessSDigits()) return kFALSE;
571 if (IsLoaded(kDigits)) if (!ProcessDigits()) return kFALSE;
572 if (IsLoaded(kRaw)) if (!ProcessRawDigits()) return kFALSE;
573 if (IsLoaded(kRawCalib)) if (!ProcessRawCalibDigits())return kFALSE;
574 if (IsLoaded(kRecPoints))if (!ProcessRecPoints()) return kFALSE;
575 if (IsLoaded(kESD)) if (!ProcessESDs()) return kFALSE;
576 if (IsLoaded(kUser)) if (!ProcessUsers()) return kFALSE;
581 //____________________________________________________________________
583 AliFMDInput::ProcessHits()
585 // Read the hit tree, and pass each hit to the member function
588 AliError("No hit tree defined");
592 AliError("No hit array defined");
596 Int_t nTracks = fTreeH->GetEntries();
597 for (Int_t i = 0; i < nTracks; i++) {
598 Int_t hitRead = fTreeH->GetEntry(i);
599 if (hitRead <= 0) continue;
601 Int_t nHit = fArrayH->GetEntries();
602 if (nHit <= 0) continue;
604 for (Int_t j = 0; j < nHit; j++) {
605 AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j));
608 TParticle* track = 0;
609 if (IsLoaded(kKinematics) && fStack) {
610 Int_t trackno = hit->Track();
611 track = fStack->Particle(trackno);
613 if (!ProcessHit(hit, track)) return kFALSE;
618 //____________________________________________________________________
620 AliFMDInput::ProcessTrackRefs()
622 // Read the reconstrcted points tree, and pass each reconstruction
623 // object (AliFMDRecPoint) to either ProcessRecPoint.
625 AliError("No track reference tree defined");
629 AliError("No track reference array defined");
633 Int_t nEv = fTreeTR->GetEntries();
634 for (Int_t i = 0; i < nEv; i++) {
635 Int_t trRead = fTreeTR->GetEntry(i);
636 if (trRead <= 0) continue;
637 Int_t nTrackRefs = fArrayTR->GetEntries();
638 for (Int_t j = 0; j < nTrackRefs; j++) {
639 AliTrackReference* trackRef =
640 static_cast<AliTrackReference*>(fArrayTR->At(j));
641 if (!trackRef) continue;
642 // if (trackRef->DetectorId() != AliTrackReference::kFMD) continue;
643 TParticle* track = 0;
644 if (IsLoaded(kKinematics) && fStack) {
645 Int_t trackno = trackRef->GetTrack();
646 track = fStack->Particle(trackno);
648 if (!ProcessTrackRef(trackRef,track)) return kFALSE;
653 //____________________________________________________________________
655 AliFMDInput::ProcessTracks()
657 // Read the hit tree, and pass each hit to the member function
660 AliError("No track tree defined");
664 AliError("No hit tree defined");
668 AliError("No hit array defined");
672 // Int_t nTracks = fStack->GetNtrack();
673 Int_t nTracks = fTreeH->GetEntries();
674 for (Int_t i = 0; i < nTracks; i++) {
675 Int_t trackno = nTracks - i - 1;
676 TParticle* track = fStack->Particle(trackno);
677 if (!track) continue;
679 // Get the hits for this track.
680 Int_t hitRead = fTreeH->GetEntry(i);
681 Int_t nHit = fArrayH->GetEntries();
682 if (nHit == 0 || hitRead <= 0) {
683 // Let user code see the track, even if there's no hits.
684 if (!ProcessTrack(trackno, track, 0)) return kFALSE;
688 // Loop over the hits corresponding to this track.
689 for (Int_t j = 0; j < nHit; j++) {
690 AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j));
691 if (!ProcessTrack(trackno, track, hit)) return kFALSE;
696 //____________________________________________________________________
698 AliFMDInput::ProcessStack()
700 // Read the hit tree, and pass each hit to the member function
703 AliError("No track tree defined");
706 Int_t nTracks = fStack->GetNtrack();
707 for (Int_t i = 0; i < nTracks; i++) {
708 Int_t trackno = nTracks - i - 1;
709 TParticle* track = fStack->Particle(trackno);
710 if (!track) continue;
712 if (!ProcessParticle(trackno, track)) return kFALSE;
716 //____________________________________________________________________
718 AliFMDInput::ProcessDigits()
720 // Read the digit tree, and pass each digit to the member function
723 AliError("No digit tree defined");
727 AliError("No digit array defined");
731 Int_t nEv = fTreeD->GetEntries();
732 for (Int_t i = 0; i < nEv; i++) {
733 Int_t digitRead = fTreeD->GetEntry(i);
734 if (digitRead <= 0) continue;
735 Int_t nDigit = fArrayD->GetEntries();
736 AliFMDDebug(0, ("Got %5d digits for this event", nDigit));
737 if (nDigit <= 0) continue;
738 for (Int_t j = 0; j < nDigit; j++) {
739 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayD->At(j));
740 if (!digit) continue;
741 if (!ProcessDigit(digit)) return kFALSE;
747 //____________________________________________________________________
749 AliFMDInput::ProcessSDigits()
751 // Read the summable digit tree, and pass each sumable digit to the
752 // member function ProcessSdigit.
754 AliWarning("No sdigit tree defined");
755 return kTRUE; // Empty SDigits is fine
758 AliWarning("No sdigit array defined");
759 return kTRUE; // Empty SDigits is fine
762 Int_t nEv = fTreeS->GetEntries();
763 for (Int_t i = 0; i < nEv; i++) {
764 Int_t sdigitRead = fTreeS->GetEntry(i);
765 if (sdigitRead <= 0) {
766 AliInfo(Form("Read nothing from tree"));
769 Int_t nSdigit = fArrayS->GetEntriesFast();
770 AliFMDDebug(0, ("Got %5d digits for this event", nSdigit));
771 AliInfo(Form("Got %5d digits for this event", nSdigit));
772 if (nSdigit <= 0) continue;
773 for (Int_t j = 0; j < nSdigit; j++) {
774 AliFMDSDigit* sdigit = static_cast<AliFMDSDigit*>(fArrayS->At(j));
775 if (!sdigit) continue;
776 if (!ProcessSDigit(sdigit)) return kFALSE;
782 //____________________________________________________________________
784 AliFMDInput::ProcessRawDigits()
786 // Read the digit tree, and pass each digit to the member function
789 AliError("No raw digit array defined");
793 Int_t nDigit = fArrayA->GetEntries();
794 if (nDigit <= 0) return kTRUE;
795 for (Int_t j = 0; j < nDigit; j++) {
796 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j));
797 if (!digit) continue;
798 if (AliLog::GetDebugLevel("FMD","") >= 40 && j < 30)
800 if (!ProcessRawDigit(digit)) return kFALSE;
805 //____________________________________________________________________
807 AliFMDInput::ProcessRawCalibDigits()
809 // Read the digit tree, and pass each digit to the member function
812 AliError("No raw digit array defined");
816 Int_t nDigit = fArrayA->GetEntries();
817 if (nDigit <= 0) return kTRUE;
818 for (Int_t j = 0; j < nDigit; j++) {
819 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j));
820 if (!digit) continue;
821 if (AliLog::GetDebugLevel("FMD","") >= 40 && j < 30)
823 if (!ProcessRawCalibDigit(digit)) return kFALSE;
828 //____________________________________________________________________
830 AliFMDInput::ProcessRecPoints()
832 // Read the reconstrcted points tree, and pass each reconstruction
833 // object (AliFMDRecPoint) to either ProcessRecPoint.
835 AliError("No recpoint tree defined");
839 AliError("No recpoints array defined");
843 Int_t nEv = fTreeR->GetEntries();
844 for (Int_t i = 0; i < nEv; i++) {
845 Int_t recRead = fTreeR->GetEntry(i);
846 if (recRead <= 0) continue;
847 Int_t nRecPoint = fArrayR->GetEntries();
848 for (Int_t j = 0; j < nRecPoint; j++) {
849 AliFMDRecPoint* recPoint = static_cast<AliFMDRecPoint*>(fArrayR->At(j));
850 if (!recPoint) continue;
851 if (!ProcessRecPoint(recPoint)) return kFALSE;
857 //____________________________________________________________________
859 AliFMDInput::ProcessESDs()
861 // Process event summary data
862 if (!fESD) return kFALSE;
863 for (UShort_t det = 1; det <= 3; det++) {
864 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
865 for (Char_t* rng = rings; *rng != '\0'; rng++) {
866 UShort_t nsec = (*rng == 'I' ? 20 : 40);
867 UShort_t nstr = (*rng == 'I' ? 512 : 256);
868 for (UShort_t sec = 0; sec < nsec; sec++) {
869 for (UShort_t str = 0; str < nstr; str++) {
870 Float_t eta = fESD->Eta(det,*rng,sec,str);
871 Float_t mult = fESD->Multiplicity(det,*rng,sec,str);
872 if (!fESD->IsAngleCorrected())
873 mult *= TMath::Abs(TMath::Cos(2.*TMath::ATan(TMath::Exp(-eta))));
874 if (!ProcessESD(det, *rng, sec, str, eta, mult)) continue;
882 //____________________________________________________________________
884 AliFMDInput::ProcessUsers()
886 // Process event summary data
887 for (UShort_t det = 1; det <= 3; det++) {
888 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
889 for (Char_t* rng = rings; *rng != '\0'; rng++) {
890 UShort_t nsec = (*rng == 'I' ? 20 : 40);
891 UShort_t nstr = (*rng == 'I' ? 512 : 256);
892 for (UShort_t sec = 0; sec < nsec; sec++) {
893 for (UShort_t str = 0; str < nstr; str++) {
894 Float_t v = GetSignal(det,*rng,sec,str);
895 if (!ProcessUser(det, *rng, sec, str, v)) continue;
903 //____________________________________________________________________
907 // Called at the end of each event. Per default, it unloads the
908 // data trees and resets the pointers to the output arrays. Users
909 // can overload this, but should call this member function in the
910 // overloaded member function of the derived class.
912 // Check if we have been initialized
914 AliError("Not initialized");
917 // Possibly unload global kinematics information
918 if (IsLoaded(kKinematics)) {
919 fLoader->UnloadKinematics();
923 // Possibly unload FMD Hit information
924 if (IsLoaded(kHits)) {
925 fFMDLoader->UnloadHits();
928 // Possibly unload FMD Digit information
929 if (IsLoaded(kDigits)) {
930 fFMDLoader->UnloadDigits();
933 // Possibly unload FMD Sdigit information
934 if (IsLoaded(kSDigits)) {
935 fFMDLoader->UnloadSDigits();
938 // Possibly unload FMD RecPoints information
939 if (IsLoaded(kRecPoints)) {
940 fFMDLoader->UnloadRecPoints();
943 // AliInfo("Now out event");
947 //____________________________________________________________________
949 AliFMDInput::Run(UInt_t maxEvents)
951 // Run over all events and files references in galice.root
954 if (!(retval = Init())) return retval;
956 fNEvents = NEvents();
957 if (fNEvents < 0) fNEvents = maxEvents;
958 else if (maxEvents > 0) fNEvents = TMath::Min(fNEvents,Int_t(maxEvents));
961 for (; fNEvents < 0 || event < fNEvents; event++) {
962 printf("\rEvent %8d/%8d ...", event, fNEvents);
963 if (!(retval = Begin(event))) break;
964 if (!(retval = Event())) break;
965 if (!(retval = End())) break;
967 printf("Looped over %8d events\n", event+1);
968 if (!retval) return retval;
973 //__________________________________________________________________
975 AliFMDInput::MakeLogScale(Int_t n, Double_t min, Double_t max)
977 // Service function to define a logarithmic axis.
980 // min Minimum of axis
981 // max Maximum of axis
985 for (Int_t i = 1; i < n+1; i++) bins[i] = bins[i-1] + (max-min)/n;
988 Float_t dp = n / TMath::Log10(max / min);
989 Float_t pmin = TMath::Log10(min);
990 for (Int_t i = 1; i < n+1; i++) {
991 Float_t p = pmin + i / dp;
992 bins[i] = TMath::Power(10, p);
997 //____________________________________________________________________
999 AliFMDInput::ScanDirectory(TSystemDirectory* dir,
1000 const TString& olddir,
1002 const char* pattern, bool recursive)
1004 // Get list of files, and go back to old working directory
1005 TString oldDir(gSystem->WorkingDirectory());
1006 TList* files = dir->GetListOfFiles();
1007 gSystem->ChangeDirectory(oldDir);
1009 // Sort list of files and check if we should add it
1013 TSystemFile* file = 0;
1014 while ((file = static_cast<TSystemFile*>(next()))) {
1015 TString name(file->GetName());
1017 // Ignore special links
1018 if (name == "." || name == "..") continue;
1020 // Check if this is a directory
1021 if (file->IsDirectory()) {
1023 ScanDirectory(static_cast<TSystemDirectory*>(file),
1029 // If this is not a root file, ignore
1030 if (!name.EndsWith(".root")) continue;
1032 // If this file does not contain the pattern, ignore
1033 if (!name.Contains(pattern)) continue;
1034 if (name.Contains("friends")) continue;
1037 TString data(Form("%s/%s", file->GetTitle(), name.Data()));
1039 TFile* test = TFile::Open(data.Data(), "READ");
1040 if (!test || test->IsZombie()) {
1041 ::Warning("ScanDirectory", "Failed to open file %s", data.Data());
1049 //____________________________________________________________________
1051 AliFMDInput::MakeChain(const char* what, const char* datadir, bool recursive)
1055 const char* treeName = 0;
1056 const char* pattern = 0;
1057 if (w.Contains("ESD")) { treeName = "esdTree"; pattern = "AliESD"; }
1058 else if (w.Contains("MC")) { treeName = "TE"; pattern = "galice"; }
1060 ::Error("MakeChain", "Unknown mode '%s' (not one of ESD, or MC)", what);
1064 // --- Our data chain ----------------------------------------------
1065 TChain* chain = new TChain(treeName);
1067 // --- Get list of ESDs --------------------------------------------
1068 // Open source directory, and make sure we go back to were we were
1069 TString oldDir(gSystem->WorkingDirectory());
1070 TSystemDirectory d(datadir, datadir);
1071 ScanDirectory(&d, oldDir, chain, pattern, recursive);
1077 //____________________________________________________________________