1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 // Control class for Alice C++ //
21 // Only one single instance of this class exists. //
22 // The object is created in main program aliroot //
23 // and is pointed by the global gAlice. //
25 // -Supports the list of all Alice Detectors (fModules). //
26 // -Supports the list of particles (fParticles). //
27 // -Supports the Trees. //
28 // -Supports the geometry. //
29 // -Supports the event display. //
32 <img src="picts/AliRunClass.gif">
37 <img src="picts/alirun.gif">
41 ///////////////////////////////////////////////////////////////////////////////
47 #include "Riostream.h"
53 #include "TGeometry.h"
56 #include "TObjectTable.h"
57 #include "TParticle.h"
63 #include "AliConfig.h"
64 #include "AliDetector.h"
65 #include "AliDisplay.h"
66 #include "AliGenEventHeader.h"
67 #include "AliGenerator.h"
68 #include "AliHeader.h"
71 #include "AliLegoGenerator.h"
74 #include "AliMagFCM.h"
75 #include "AliMagFDM.h"
84 //_______________________________________________________________________
111 fPDGDB(0), //Particle factory object
116 fConfigFunction("\0"),
130 // Default constructor for AliRun
134 //_______________________________________________________________________
135 AliRun::AliRun(const AliRun& arun):
136 TVirtualMCApplication(arun),
162 fPDGDB(0), //Particle factory object
167 fConfigFunction("\0"),
181 // Copy constructor for AliRun
186 //_____________________________________________________________________________
187 AliRun::AliRun(const char *name, const char *title):
188 TVirtualMCApplication(name,title),
194 fHeader(new AliHeader()),
201 fModules(new TObjArray(77)), // Support list for the Detectors
207 fImedia(new TArrayI(1000)),
214 fPDGDB(TDatabasePDG::Instance()), //Particle factory object!
215 fHitLists(new TList()), // Create HitLists list
219 fConfigFunction("Config();"),
220 fRandom(new TRandom3()),
224 fStack(new AliStack(10000)), //Particle stack
233 // Constructor for the main processor.
234 // Creates the geometry
235 // Creates the list of Detectors.
236 // Creates the list of particles.
241 // Set random number generator
244 if (gSystem->Getenv("CONFIG_SEED")) {
245 gRandom->SetSeed(static_cast<UInt_t>(atoi(gSystem->Getenv("CONFIG_SEED"))));
248 // Add to list of browsable
249 gROOT->GetListOfBrowsables()->Add(this,name);
251 // Create the TNode geometry for the event display
252 BuildSimpleGeometry();
254 // Create default mag field
257 // Prepare the tracking medium lists
258 for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99;
260 // Add particle list to configuration
261 AliConfig::Instance()->Add(fPDGDB);
263 // Set transport parameters
268 //_______________________________________________________________________
272 // Default AliRun destructor
275 if(fTreeE)curfil=fTreeE->GetCurrentFile();
298 // avoid to delete TFile objects not owned by this object
299 // avoid multiple deletions
300 if(curfil == fTreeDFile) fTreeDFile=0;
301 if(curfil == fTreeSFile) fTreeSFile=0;
302 if(curfil == fTreeRFile) fTreeRFile=0;
303 if(fTreeSFile == fTreeDFile) fTreeSFile=0;
304 if(fTreeRFile == fTreeDFile) fTreeRFile=0;
305 if(fTreeRFile == fTreeSFile) fTreeRFile=0;
307 if(fTreeDFile->IsOpen())fTreeDFile->Close();
311 if(fTreeSFile->IsOpen())fTreeSFile->Close();
315 if(fTreeRFile->IsOpen())fTreeRFile->Close();
318 if (gROOT->GetListOfBrowsables())
319 gROOT->GetListOfBrowsables()->Remove(this);
324 //_______________________________________________________________________
325 void AliRun::Copy(AliRun &) const
327 Fatal("Copy","Not implemented!\n");
330 //_______________________________________________________________________
331 void AliRun::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const
334 // Add a hit to detector id
336 TObjArray &dets = *fModules;
337 if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
340 //_______________________________________________________________________
341 void AliRun::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const
344 // Add digit to detector id
346 TObjArray &dets = *fModules;
347 if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
350 //_______________________________________________________________________
351 void AliRun::Browse(TBrowser *b)
354 // Called when the item "Run" is clicked on the left pane
355 // of the Root browser.
356 // It displays the Root Trees and all detectors.
358 if(!fStack) fStack=fHeader->Stack();
359 TTree* pTreeK = fStack->TreeK();
361 if (pTreeK) b->Add(pTreeK,pTreeK->GetName());
362 if (fTreeH) b->Add(fTreeH,fTreeH->GetName());
363 if (fTreeTR) b->Add(fTreeTR,fTreeH->GetName());
364 if (fTreeD) b->Add(fTreeD,fTreeD->GetName());
365 if (fTreeE) b->Add(fTreeE,fTreeE->GetName());
366 if (fTreeR) b->Add(fTreeR,fTreeR->GetName());
367 if (fTreeS) b->Add(fTreeS,fTreeS->GetName());
369 TIter next(fModules);
371 while((detector = dynamic_cast<AliModule*>(next()))) {
372 b->Add(detector,detector->GetName());
374 b->Add(fMCQA,"AliMCQA");
377 //_______________________________________________________________________
381 // Initialize Alice geometry
386 //_______________________________________________________________________
387 void AliRun::BuildSimpleGeometry()
390 // Create a simple TNode geometry used by Root display engine
392 // Initialise geometry
394 fGeometry = new TGeometry("AliceGeom","Galice Geometry for Hits");
395 new TMaterial("void","Vacuum",0,0,0); //Everything is void
396 TBRIK *brik = new TBRIK("S_alice","alice volume","void",2000,2000,3000);
397 brik->SetVisibility(0);
398 new TNode("alice","alice","S_alice");
401 //_______________________________________________________________________
402 void AliRun::CleanDetectors()
405 // Clean Detectors at the end of event
407 TIter next(fModules);
409 while((detector = dynamic_cast<AliModule*>(next()))) {
410 detector->FinishEvent();
414 //_______________________________________________________________________
415 Int_t AliRun::DistancetoPrimitive(Int_t, Int_t)
418 // Return the distance from the mouse to the AliRun object
424 //_______________________________________________________________________
425 void AliRun::DumpPart (Int_t i) const
428 // Dumps particle i in the stack
433 //_______________________________________________________________________
434 void AliRun::DumpPStack () const
437 // Dumps the particle stack
439 fStack->DumpPStack();
442 //_______________________________________________________________________
443 void AliRun::SetField(AliMagF* magField)
445 // Set Magnetic Field Map
450 //_______________________________________________________________________
451 void AliRun::SetField(Int_t type, Int_t version, Float_t scale,
452 Float_t maxField, char* filename)
455 // Set magnetic field parameters
456 // type Magnetic field transport flag 0=no field, 2=helix, 3=Runge Kutta
457 // version Magnetic field map version (only 1 active now)
458 // scale Scale factor for the magnetic field
459 // maxField Maximum value for the magnetic field
462 // --- Sanity check on mag field flags
463 if(fField) delete fField;
465 fField = new AliMagFC("Map1"," ",type,scale,maxField);
466 } else if(version<=2) {
467 fField = new AliMagFCM("Map2-3",filename,type,scale,maxField);
469 } else if(version==3) {
470 fField = new AliMagFDM("Map4",filename,type,scale,maxField);
473 Warning("SetField","Invalid map %d\n",version);
477 //_______________________________________________________________________
478 void AliRun::FinishRun()
481 // Called at the end of the run.
485 if(fLego) fLego->FinishRun();
487 // Clean detector information
488 TIter next(fModules);
490 while((detector = dynamic_cast<AliModule*>(next()))) {
491 detector->FinishRun();
494 //Output energy summary tables
497 TFile *file = fTreeE->GetCurrentFile();
501 fTreeE->Write(0,TObject::kOverwrite);
503 // Write AliRun info and all detectors parameters
504 Write(0,TObject::kOverwrite);
506 // Clean tree information
511 delete fTreeH; fTreeH = 0;
514 delete fTreeTR; fTreeTR = 0;
517 delete fTreeD; fTreeD = 0;
520 delete fTreeR; fTreeR = 0;
523 // delete fTreeE; fTreeE = 0;
526 delete fTreeS; fTreeS = 0;
528 fGenerator->FinishRun();
534 //_______________________________________________________________________
535 void AliRun::FlagTrack(Int_t track)
539 fStack->FlagTrack(track);
542 //_______________________________________________________________________
543 void AliRun::EnergySummary()
546 // Print summary of deposited energy
552 Int_t kn, i, left, j, id;
553 const Float_t kzero=0;
554 Int_t ievent=fHeader->GetEvent()+1;
556 // Energy loss information
558 printf("***************** Energy Loss Information per event (GEV) *****************\n");
559 for(kn=1;kn<fEventEnergy.GetSize();kn++) {
562 fEventEnergy[ndep]=kn;
567 ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
570 fSummEnergy[ndep]=ed;
571 fSum2Energy[ndep]=TMath::Min(static_cast<Float_t>(99.),TMath::Max(ed2,kzero));
576 for(kn=0;kn<(ndep-1)/3+1;kn++) {
578 for(i=0;i<(3<left?3:left);i++) {
580 id=Int_t (fEventEnergy[j]+0.1);
581 printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
586 // Relative energy loss in different detectors
587 printf("******************** Relative Energy Loss per event ********************\n");
588 printf("Total energy loss per event %10.3f GeV\n",edtot);
589 for(kn=0;kn<(ndep-1)/5+1;kn++) {
591 for(i=0;i<(5<left?5:left);i++) {
593 id=Int_t (fEventEnergy[j]+0.1);
594 printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
598 for(kn=0;kn<75;kn++) printf("*");
602 // Reset the TArray's
603 // fEventEnergy.Set(0);
604 // fSummEnergy.Set(0);
605 // fSum2Energy.Set(0);
608 //_______________________________________________________________________
609 AliModule *AliRun::GetModule(const char *name) const
612 // Return pointer to detector from name
614 return dynamic_cast<AliModule*>(fModules->FindObject(name));
617 //_______________________________________________________________________
618 AliDetector *AliRun::GetDetector(const char *name) const
621 // Return pointer to detector from name
623 return dynamic_cast<AliDetector*>(fModules->FindObject(name));
626 //_______________________________________________________________________
627 Int_t AliRun::GetModuleID(const char *name) const
630 // Return galice internal detector identifier from name
633 TObject *mod=fModules->FindObject(name);
634 if(mod) i=fModules->IndexOf(mod);
638 //_______________________________________________________________________
639 Int_t AliRun::GetEvent(Int_t event)
642 // Connect the Trees Kinematics and Hits for event # event
643 // Set branch addresses
646 // Reset existing structures
648 ResetTrackReferences();
652 // Delete Trees already connected
653 if (fTreeH) { delete fTreeH; fTreeH = 0;}
654 if (fTreeTR) { delete fTreeTR; fTreeTR = 0;}
655 if (fTreeD) { delete fTreeD; fTreeD = 0;}
656 if (fTreeR) { delete fTreeR; fTreeR = 0;}
657 if (fTreeS) { delete fTreeS; fTreeS = 0;}
659 // Create the particle stack
660 if (fHeader) delete fHeader;
663 // Get header from file
665 fTreeE->SetBranchAddress("Header", &fHeader);
667 if (!fTreeE->GetEntry(event)) {
668 Error("GetEvent","Cannot find event:%d\n",event);
673 Error("GetEvent","Cannot find Header Tree (TE)\n");
677 // Get the stack from the header, set fStack to 0 if it
678 // fails to get event
680 TFile *file = fTreeE->GetCurrentFile();
685 if (fStack) delete fStack;
686 fStack = fHeader->Stack();
688 if (!fStack->GetEvent(event)) fStack = 0;
691 // Get Hits Tree header from file
692 sprintf(treeName,"TreeH%d",event);
693 fTreeH = dynamic_cast<TTree*>(gDirectory->Get(treeName));
695 Warning("GetEvent","cannot find Hits Tree for event:%d\n",event);
698 // Get TracReferences Tree header from file
699 sprintf(treeName,"TreeTR%d",event);
700 fTreeTR = dynamic_cast<TTree*>(gDirectory->Get(treeName));
702 Warning("GetEvent","cannot find TrackReferences Tree for event:%d\n",event);
705 // get current file name and compare with names containing trees S,D,R
706 TString curfilname=static_cast<TString>(fTreeE->GetCurrentFile()->GetName());
707 if(fTreeDFileName==curfilname)fTreeDFileName="";
708 if(fTreeSFileName==curfilname)fTreeSFileName="";
709 if(fTreeRFileName==curfilname)fTreeRFileName="";
711 // Get Digits Tree header from file
712 sprintf(treeName,"TreeD%d",event);
714 if (!fTreeDFile && fTreeDFileName != "") {
715 InitTreeFile("D",fTreeDFileName);
718 fTreeD = dynamic_cast<TTree*>(fTreeDFile->Get(treeName));
720 fTreeD = dynamic_cast<TTree*>(file->Get(treeName));
723 // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event);
725 if(fTreeDFileName != ""){
726 if(fTreeDFileName==fTreeSFileName) {
728 fTreeSFile = fTreeDFile;
730 if(fTreeDFileName==fTreeRFileName) {
732 fTreeRFile = fTreeDFile;
738 // Get SDigits Tree header from file
739 sprintf(treeName,"TreeS%d",event);
740 if (!fTreeSFile && fTreeSFileName != "") {
741 InitTreeFile("S",fTreeSFileName);
744 fTreeS = dynamic_cast<TTree*>(fTreeSFile->Get(treeName));
746 fTreeS = dynamic_cast<TTree*>(gDirectory->Get(treeName));
749 // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event);
752 if(fTreeSFileName != ""){
753 if(fTreeSFileName==fTreeRFileName){
755 fTreeRFile = fTreeSFile;
761 // Get Reconstruct Tree header from file
762 sprintf(treeName,"TreeR%d",event);
763 if (!fTreeRFile && fTreeRFileName != "") {
764 InitTreeFile("R",fTreeRFileName);
767 fTreeR = dynamic_cast<TTree*>(fTreeRFile->Get(treeName));
769 fTreeR = dynamic_cast<TTree*>(gDirectory->Get(treeName));
772 // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event);
777 // Set Trees branch addresses
778 TIter next(fModules);
780 while((detector = dynamic_cast<AliModule*>(next()))) {
781 detector->SetTreeAddress();
784 fEvent=event; //MI change
786 return fHeader->GetNtrack();
789 //_______________________________________________________________________
790 TGeometry *AliRun::GetGeometry()
793 // Import Alice geometry from current file
794 // Return pointer to geometry object
796 if (!fGeometry) fGeometry = dynamic_cast<TGeometry*>(gDirectory->Get("AliceGeom"));
798 // Unlink and relink nodes in detectors
799 // This is bad and there must be a better way...
802 TIter next(fModules);
804 while((detector = dynamic_cast<AliModule*>(next()))) {
805 TList *dnodes=detector->Nodes();
808 for ( j=0; j<dnodes->GetSize(); j++) {
809 node = dynamic_cast<TNode*>(dnodes->At(j));
810 node1 = fGeometry->GetNode(node->GetName());
811 dnodes->Remove(node);
812 dnodes->AddAt(node1,j);
818 //_______________________________________________________________________
819 Int_t AliRun::GetPrimary(Int_t track) const
822 // return number of primary that has generated track
824 return fStack->GetPrimary(track);
827 //_______________________________________________________________________
828 void AliRun::MediaTable()
831 // Built media table to get from the media number to
834 Int_t kz, nz, idt, lz, i, k, ind;
836 TObjArray &dets = *gAlice->Detectors();
840 for (kz=0;kz<fNdets;kz++) {
841 // If detector is defined
842 if((det=dynamic_cast<AliModule*>(dets[kz]))) {
843 TArrayI &idtmed = *(det->GetIdtmed());
844 for(nz=0;nz<100;nz++) {
845 // Find max and min material number
846 if((idt=idtmed[nz])) {
847 det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
848 det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
851 if(det->LoMedium() > det->HiMedium()) {
855 if(det->HiMedium() > fImedia->GetSize()) {
856 Error("MediaTable","Increase fImedia from %d to %d",
857 fImedia->GetSize(),det->HiMedium());
860 // Tag all materials in rage as belonging to detector kz
861 for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
868 // Print summary table
869 printf(" Traking media ranges:\n");
870 for(i=0;i<(fNdets-1)/6+1;i++) {
871 for(k=0;k< (6<fNdets-i*6?6:fNdets-i*6);k++) {
873 det=dynamic_cast<AliModule*>(dets[ind]);
875 printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
878 printf(" %6s: %3d -> %3d;","NULL",0,0);
884 //_______________________________________________________________________
885 void AliRun::SetGenerator(AliGenerator *generator)
888 // Load the event generator
890 if(!fGenerator) fGenerator = generator;
893 //_______________________________________________________________________
894 void AliRun::ResetGenerator(AliGenerator *generator)
897 // Load the event generator
901 Warning("ResetGenerator","Replacing generator %s with %s\n",
902 fGenerator->GetName(),generator->GetName());
904 Warning("ResetGenerator","Replacing generator %s with NULL\n",
905 fGenerator->GetName());
906 fGenerator = generator;
909 //_______________________________________________________________________
910 void AliRun::SetTransPar(const char *filename)
912 fTransParName = filename;
915 //_______________________________________________________________________
916 void AliRun::SetBaseFile(const char *filename)
918 fBaseFileName = filename;
921 //_______________________________________________________________________
922 void AliRun::ReadTransPar()
925 // Read filename to set the transport parameters
929 const Int_t kncuts=10;
930 const Int_t knflags=11;
931 const Int_t knpars=kncuts+knflags;
932 const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
933 "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
934 "BREM","COMP","DCAY","DRAY","HADR","LOSS",
935 "MULS","PAIR","PHOT","RAYL"};
941 Int_t i, itmed, iret, ktmed, kz;
944 // See whether the file is there
945 filtmp=gSystem->ExpandPathName(fTransParName.Data());
946 lun=fopen(filtmp,"r");
949 Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
954 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
955 printf(" *%59s\n","*");
956 printf(" * Please check carefully what you are doing!%10s\n","*");
957 printf(" *%59s\n","*");
961 // Initialise cuts and flags
962 for(i=0;i<kncuts;i++) cut[i]=-99;
963 for(i=0;i<knflags;i++) flag[i]=-99;
965 for(i=0;i<256;i++) line[i]='\0';
966 // Read up to the end of line excluded
967 iret=fscanf(lun,"%[^\n]",line);
972 printf(" *%59s\n","*");
973 printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
977 // Read the end of line
980 if(line[0]=='*') continue;
982 iret=sscanf(line,"%s %d %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d %d %d %d %d %d %d",
983 detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
984 &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
985 &flag[8],&flag[9],&flag[10]);
989 Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
992 // Check that the module exist
993 AliModule *mod = GetModule(detName);
995 // Get the array of media numbers
996 TArrayI &idtmed = *mod->GetIdtmed();
997 // Check that the tracking medium code is valid
998 if(0<=itmed && itmed < 100) {
1001 Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
1004 // Set energy thresholds
1005 for(kz=0;kz<kncuts;kz++) {
1007 if(fDebug) printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
1008 kpars[kz],cut[kz],itmed,mod->GetName());
1009 gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
1012 // Set transport mechanisms
1013 for(kz=0;kz<knflags;kz++) {
1015 if(fDebug) printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
1016 kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
1017 gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
1021 Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
1025 if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
1032 //_______________________________________________________________________
1033 void AliRun::MakeTree(Option_t *option, const char *file)
1036 // Create the ROOT trees
1037 // Loop on all detectors to create the Root branch (if any)
1043 const char *oK = strstr(option,"K");
1044 const char *oH = strstr(option,"H");
1045 const char *oTR = strstr(option,"T");
1046 const char *oE = strstr(option,"E");
1047 const char *oD = strstr(option,"D");
1048 const char *oR = strstr(option,"R");
1049 const char *oS = strstr(option,"S");
1052 TDirectory *cwd = gDirectory;
1054 TBranch *branch = 0;
1056 if (oK) fStack->MakeTree(fEvent, file);
1058 if (oE && !fTreeE) {
1059 fTreeE = new TTree("TE","Header");
1060 // branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0);
1061 branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0);
1062 branch->SetAutoDelete(kFALSE);
1063 TFolder *folder = dynamic_cast<TFolder *>(gROOT->FindObjectAny("/Folders/RunMC/Event/Header"));
1064 if (folder) folder->Add(fHeader);
1065 // branch = fTreeE->Branch("Stack","AliStack", &fStack, 4000, 0);
1066 // branch->SetAutoDelete(kFALSE);
1067 // if (folder) folder->Add(fStack);
1068 fTreeE->Write(0,TObject::kOverwrite);
1071 if (file && branch) {
1072 char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
1073 sprintf(outFile,"%s/%s",GetBaseFile(),file);
1074 branch->SetFile(outFile);
1075 TIter next( branch->GetListOfBranches());
1076 while ((branch=dynamic_cast<TBranch*>(next()))) {
1077 branch->SetFile(outFile);
1080 printf("* MakeBranch * Diverting Branch %s to file %s\n", branch->GetName(),file);
1085 if (oH && !fTreeH) {
1086 sprintf(hname,"TreeH%d",fEvent);
1087 fTreeH = new TTree(hname,"Hits");
1088 fTreeH->SetAutoSave(1000000000); //no autosave
1089 fTreeH->Write(0,TObject::kOverwrite);
1092 if (oTR && !fTreeTR) {
1093 sprintf(hname,"TreeTR%d",fEvent);
1094 fTreeTR = new TTree(hname,"TrackReferences");
1095 fTreeTR->SetAutoSave(1000000000); //no autosave
1096 fTreeTR->Write(0,TObject::kOverwrite);
1099 if (oD && !fTreeD) {
1100 sprintf(hname,"TreeD%d",fEvent);
1101 fTreeD = new TTree(hname,"Digits");
1102 fTreeD->Write(0,TObject::kOverwrite);
1104 if (oS && !fTreeS) {
1105 sprintf(hname,"TreeS%d",fEvent);
1106 fTreeS = new TTree(hname,"SDigits");
1107 fTreeS->Write(0,TObject::kOverwrite);
1109 if (oR && !fTreeR) {
1110 sprintf(hname,"TreeR%d",fEvent);
1111 fTreeR = new TTree(hname,"Reconstruction");
1112 fTreeR->Write(0,TObject::kOverwrite);
1116 // Create a branch for hits/digits for each detector
1117 // Each branch is a TClonesArray. Each data member of the Hits classes
1118 // will be in turn a subbranch of the detector master branch
1119 TIter next(fModules);
1120 AliModule *detector;
1121 while((detector = dynamic_cast<AliModule*>(next()))) {
1122 if (oH) detector->MakeBranch(option,file);
1123 if (oTR) detector->MakeBranchTR(option,file);
1127 //_______________________________________________________________________
1128 TParticle* AliRun::Particle(Int_t i)
1130 return fStack->Particle(i);
1133 //_______________________________________________________________________
1134 void AliRun::ResetDigits()
1137 // Reset all Detectors digits
1139 TIter next(fModules);
1140 AliModule *detector;
1141 while((detector = dynamic_cast<AliModule*>(next()))) {
1142 detector->ResetDigits();
1146 //_______________________________________________________________________
1147 void AliRun::ResetSDigits()
1150 // Reset all Detectors digits
1152 TIter next(fModules);
1153 AliModule *detector;
1154 while((detector = dynamic_cast<AliModule*>(next()))) {
1155 detector->ResetSDigits();
1159 //_______________________________________________________________________
1160 void AliRun::ResetHits()
1163 // Reset all Detectors hits
1165 TIter next(fModules);
1166 AliModule *detector;
1167 while((detector = dynamic_cast<AliModule*>(next()))) {
1168 detector->ResetHits();
1172 //_______________________________________________________________________
1173 void AliRun::ResetTrackReferences()
1176 // Reset all Detectors hits
1178 TIter next(fModules);
1179 AliModule *detector;
1180 while((detector = dynamic_cast<AliModule*>(next()))) {
1181 detector->ResetTrackReferences();
1185 //_______________________________________________________________________
1186 void AliRun::ResetPoints()
1189 // Reset all Detectors points
1191 TIter next(fModules);
1192 AliModule *detector;
1193 while((detector = dynamic_cast<AliModule*>(next()))) {
1194 detector->ResetPoints();
1198 //_______________________________________________________________________
1199 void AliRun::InitMC(const char *setup)
1202 // Initialize the Alice setup
1206 Warning("Init","Cannot initialise AliRun twice!\n");
1210 gROOT->LoadMacro(setup);
1211 gInterpreter->ProcessLine(fConfigFunction.Data());
1213 // Register MC in configuration
1214 AliConfig::Instance()->Add(gMC);
1215 gMC->SetStack(fStack);
1217 gMC->DefineParticles(); //Create standard MC particles
1218 AliPDG::AddParticlesToPdgDataBase();
1220 TObject *objfirst, *objlast;
1222 fNdets = fModules->GetLast()+1;
1225 //=================Create Materials and geometry
1228 // Added also after in case of interactive initialisation of modules
1229 fNdets = fModules->GetLast()+1;
1231 TIter next(fModules);
1232 AliModule *detector;
1233 while((detector = dynamic_cast<AliModule*>(next()))) {
1234 detector->SetTreeAddress();
1235 objlast = gDirectory->GetList()->Last();
1237 // Add Detector histograms in Detector list of histograms
1238 if (objlast) objfirst = gDirectory->GetList()->After(objlast);
1239 else objfirst = gDirectory->GetList()->First();
1241 detector->Histograms()->Add(objfirst);
1242 objfirst = gDirectory->GetList()->After(objfirst);
1245 ReadTransPar(); //Read the cuts for all materials
1247 MediaTable(); //Build the special IMEDIA table
1249 //Initialise geometry deposition table
1250 fEventEnergy.Set(gMC->NofVolumes()+1);
1251 fSummEnergy.Set(gMC->NofVolumes()+1);
1252 fSum2Energy.Set(gMC->NofVolumes()+1);
1254 //Compute cross-sections
1255 gMC->BuildPhysics();
1257 //Write Geometry object to current file.
1262 fMCQA = new AliMCQA(fNdets);
1264 AliConfig::Instance();
1266 // Save stuff at the beginning of the file to avoid file corruption
1270 //_______________________________________________________________________
1271 void AliRun::RunMC(Int_t nevent, const char *setup)
1274 // Main function to be called to process a galice run
1276 // Root > gAlice.Run();
1277 // a positive number of events will cause the finish routine
1280 fEventsPerRun = nevent;
1281 // check if initialisation has been done
1282 if (!fInitDone) InitMC(setup);
1284 // Create the Root Tree with one branch per detector
1288 if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
1289 MakeTree("K","Kine.root");
1290 MakeTree("H","Hits.root");
1295 gMC->ProcessRun(nevent);
1297 // End of this run, close files
1298 if(nevent>0) FinishRun();
1301 //_______________________________________________________________________
1302 void AliRun::RunReco(const char *selected, Int_t first, Int_t last)
1305 // Main function to be called to reconstruct Alice event
1307 cout << "Found "<< gAlice->TreeE()->GetEntries() << "events" << endl;
1308 Int_t nFirst = first;
1309 Int_t nLast = (last < 0)? static_cast<Int_t>(gAlice->TreeE()->GetEntries()) : last;
1311 for (Int_t nevent = nFirst; nevent <= nLast; nevent++) {
1312 cout << "Processing event "<< nevent << endl;
1315 Digits2Reco(selected);
1319 //_______________________________________________________________________
1321 void AliRun::Hits2Digits(const char *selected)
1324 // Convert Hits to sumable digits
1326 for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
1329 Hits2SDigits(selected);
1330 SDigits2Digits(selected);
1335 //_______________________________________________________________________
1337 void AliRun::Tree2Tree(Option_t *option, const char *selected)
1340 // Function to transform the content of
1342 // - TreeH to TreeS (option "S")
1343 // - TreeS to TreeD (option "D")
1344 // - TreeD to TreeR (option "R")
1346 // If multiple options are specified ("SDR"), transformation will be done in sequence for
1347 // selected detector and for all detectors if none is selected (detector string
1348 // can contain blank separated list of detector names).
1351 const char *oS = strstr(option,"S");
1352 const char *oD = strstr(option,"D");
1353 const char *oR = strstr(option,"R");
1355 TObjArray *detectors = Detectors();
1357 TIter next(detectors);
1359 AliDetector *detector = 0;
1361 TDirectory *cwd = gDirectory;
1367 while((obj = next())) {
1368 if (!dynamic_cast<AliModule*>(obj))
1369 Fatal("Tree2Tree","Wrong type in fModules array\n");
1370 if (!(detector = dynamic_cast<AliDetector*>(obj))) continue;
1372 if (strcmp(detector->GetName(),selected)) continue;
1373 if (!detector->IsActive()) continue;
1374 if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
1376 sprintf(outFile,"SDigits.%s.root",detector->GetName());
1377 detector->MakeBranch("S",outFile);
1380 sprintf(outFile,"Digits.%s.root",detector->GetName());
1381 detector->MakeBranch("D",outFile);
1384 sprintf(outFile,"Reco.%s.root",detector->GetName());
1385 detector->MakeBranch("R",outFile);
1388 detector->MakeBranch(option);
1394 cout << "Hits2SDigits: Processing " << detector->GetName() << "..." << endl;
1395 detector->Hits2SDigits();
1398 cout << "SDigits2Digits: Processing " << detector->GetName() << "..." << endl;
1399 detector->SDigits2Digits();
1402 cout << "Digits2Reco: Processing " << detector->GetName() << "..." << endl;
1403 detector->Digits2Reco();
1410 //_______________________________________________________________________
1411 void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
1412 Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max,
1413 Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener)
1416 // Generates lego plots of:
1417 // - radiation length map phi vs theta
1418 // - radiation length map phi vs eta
1419 // - interaction length map
1420 // - g/cm2 length map
1422 // ntheta bins in theta, eta
1423 // themin minimum angle in theta (degrees)
1424 // themax maximum angle in theta (degrees)
1426 // phimin minimum angle in phi (degrees)
1427 // phimax maximum angle in phi (degrees)
1428 // rmin minimum radius
1429 // rmax maximum radius
1432 // The number of events generated = ntheta*nphi
1433 // run input parameters in macro setup (default="Config.C")
1435 // Use macro "lego.C" to visualize the 3 lego plots in spherical coordinates
1438 <img src="picts/AliRunLego1.gif">
1443 <img src="picts/AliRunLego2.gif">
1448 <img src="picts/AliRunLego3.gif">
1453 // check if initialisation has been done
1454 if (!fInitDone) InitMC(setup);
1455 //Save current generator
1456 AliGenerator *gen=Generator();
1458 // Set new generator
1459 if (!gener) gener = new AliLegoGenerator();
1460 ResetGenerator(gener);
1462 // Configure Generator
1463 gener->SetRadiusRange(rmin, rmax);
1464 gener->SetZMax(zmax);
1465 gener->SetCoor1Range(nc1, c1min, c1max);
1466 gener->SetCoor2Range(nc2, c2min, c2max);
1469 //Create Lego object
1470 fLego = new AliLego("lego",gener);
1472 //Prepare MC for Lego Run
1477 //gMC->ProcessRun(nc1*nc2+1);
1478 gMC->ProcessRun(nc1*nc2);
1480 // Create only the Root event Tree
1483 // End of this run, close files
1485 // Restore current generator
1486 ResetGenerator(gen);
1487 // Delete Lego Object
1488 delete fLego; fLego=0;
1491 //_______________________________________________________________________
1492 void AliRun::SetConfigFunction(const char * config)
1495 // Set the signature of the function contained in Config.C to configure
1498 fConfigFunction=config;
1501 //_______________________________________________________________________
1502 void AliRun::SetCurrentTrack(Int_t track)
1505 // Set current track number
1507 fStack->SetCurrentTrack(track);
1510 //_______________________________________________________________________
1511 void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
1512 Float_t *vpos, Float_t *polar, Float_t tof,
1513 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
1515 // Delegate to stack
1518 fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
1519 mech, ntr, weight, is);
1522 //_______________________________________________________________________
1523 void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg,
1524 Double_t px, Double_t py, Double_t pz, Double_t e,
1525 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
1526 Double_t polx, Double_t poly, Double_t polz,
1527 TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
1529 // Delegate to stack
1531 fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
1532 polx, poly, polz, mech, ntr, weight, is);
1536 //_______________________________________________________________________
1537 void AliRun::SetHighWaterMark(const Int_t nt)
1540 // Set high water mark for last track in event
1541 fStack->SetHighWaterMark(nt);
1544 //_______________________________________________________________________
1545 void AliRun::KeepTrack(const Int_t track)
1548 // Delegate to stack
1550 fStack->KeepTrack(track);
1557 //_______________________________________________________________________
1558 void AliRun::ConstructGeometry()
1561 // Create modules, materials, geometry
1565 TIter next(fModules);
1566 AliModule *detector;
1567 printf("Geometry creation:\n");
1568 while((detector = dynamic_cast<AliModule*>(next()))) {
1570 // Initialise detector materials and geometry
1571 detector->CreateMaterials();
1572 detector->CreateGeometry();
1573 printf("%10s R:%.2fs C:%.2fs\n",
1574 detector->GetName(),stw.RealTime(),stw.CpuTime());
1578 //_______________________________________________________________________
1579 void AliRun::InitGeometry()
1582 // Initialize detectors and display geometry
1585 printf("Initialisation:\n");
1587 TIter next(fModules);
1588 AliModule *detector;
1589 while((detector = dynamic_cast<AliModule*>(next()))) {
1591 // Initialise detector and display geometry
1593 detector->BuildGeometry();
1594 printf("%10s R:%.2fs C:%.2fs\n",
1595 detector->GetName(),stw.RealTime(),stw.CpuTime());
1600 //_______________________________________________________________________
1601 void AliRun::GeneratePrimaries()
1604 // Generate primary particles and fill them in the stack.
1607 Generator()->Generate();
1610 //_______________________________________________________________________
1611 void AliRun::BeginEvent()
1613 // Clean-up previous event
1615 fEventEnergy.Reset();
1616 // Clean detector information
1623 // Reset all Detectors & kinematics & trees
1627 // Initialise event header
1628 fHeader->Reset(fRun,fEvent,fEventNrInRun);
1630 fStack->BeginEvent(fEvent);
1634 fLego->BeginEvent();
1641 ResetTrackReferences();
1648 sprintf(hname,"TreeH%d",fEvent);
1649 fTreeH->SetName(hname);
1654 sprintf(hname,"TreeTR%d",fEvent);
1655 fTreeTR->SetName(hname);
1660 sprintf(hname,"TreeD%d",fEvent);
1661 fTreeD->SetName(hname);
1662 fTreeD->Write(0,TObject::kOverwrite);
1666 sprintf(hname,"TreeS%d",fEvent);
1667 fTreeS->SetName(hname);
1668 fTreeS->Write(0,TObject::kOverwrite);
1672 sprintf(hname,"TreeR%d",fEvent);
1673 fTreeR->SetName(hname);
1674 fTreeR->Write(0,TObject::kOverwrite);
1678 //_______________________________________________________________________
1679 void AliRun::BeginPrimary()
1682 // Called at the beginning of each primary track
1686 gAlice->ResetHits();
1687 gAlice->ResetTrackReferences();
1691 //_______________________________________________________________________
1692 void AliRun::PreTrack()
1694 TObjArray &dets = *fModules;
1697 for(Int_t i=0; i<=fNdets; i++)
1698 if((module = dynamic_cast<AliModule*>(dets[i])))
1704 //_______________________________________________________________________
1705 void AliRun::Stepping()
1708 // Called at every step during transport
1711 Int_t id = DetFromMate(gMC->GetMedium());
1715 // --- If lego option, do it and leave
1717 fLego->StepManager();
1720 //Update energy deposition tables
1721 AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep());
1723 //Call the appropriate stepping routine;
1724 AliModule *det = dynamic_cast<AliModule*>(fModules->At(id));
1725 if(det && det->StepManagerIsEnabled()) {
1726 fMCQA->StepManager(id);
1732 //_______________________________________________________________________
1733 void AliRun::PostTrack()
1735 TObjArray &dets = *fModules;
1738 for(Int_t i=0; i<=fNdets; i++)
1739 if((module = dynamic_cast<AliModule*>(dets[i])))
1740 module->PostTrack();
1743 //_______________________________________________________________________
1744 void AliRun::FinishPrimary()
1747 // Called at the end of each primary track
1750 // static Int_t count=0;
1751 // const Int_t times=10;
1752 // This primary is finished, purify stack
1753 fStack->PurifyKine();
1755 TIter next(fModules);
1756 AliModule *detector;
1757 while((detector = dynamic_cast<AliModule*>(next()))) {
1758 detector->FinishPrimary();
1761 // Write out hits if any
1762 if (gAlice->TreeH()) {
1763 gAlice->TreeH()->Fill();
1766 // Write out hits if any
1767 if (gAlice->TreeTR()) {
1768 gAlice->TreeTR()->Fill();
1772 // if(++count%times==1) gObjectTable->Print();
1775 //_______________________________________________________________________
1776 void AliRun::FinishEvent()
1779 // Called at the end of the event.
1783 if(fLego) fLego->FinishEvent();
1785 //Update the energy deposit tables
1787 for(i=0;i<fEventEnergy.GetSize();i++) {
1788 fSummEnergy[i]+=fEventEnergy[i];
1789 fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
1794 // Update Header information
1796 fHeader->SetNprimary(fStack->GetNprimary());
1797 fHeader->SetNtrack(fStack->GetNtrack());
1800 // Write out the kinematics
1801 fStack->FinishEvent();
1803 // Write out the event Header information
1805 fHeader->SetStack(fStack);
1810 // Write Tree headers
1811 TTree* pTreeK = fStack->TreeK();
1812 if (pTreeK) pTreeK->Write(0,TObject::kOverwrite);
1813 if (fTreeH) fTreeH->Write(0,TObject::kOverwrite);
1814 if (fTreeTR) fTreeTR->Write(0,TObject::kOverwrite);
1820 //_______________________________________________________________________
1821 void AliRun::Field(const Double_t* x, Double_t *b) const
1824 for (Int_t i=0; i<3; i++) xfloat[i] = x[i];
1828 Field()->Field(xfloat,bfloat);
1829 for (Int_t j=0; j<3; j++) b[j] = bfloat[j];
1832 printf("No mag field defined!\n");
1839 // End of MC Application
1842 //_______________________________________________________________________
1843 void AliRun::Streamer(TBuffer &R__b)
1845 // Stream an object of class AliRun.
1847 if (R__b.IsReading()) {
1848 if (!gAlice) gAlice = this;
1850 AliRun::Class()->ReadBuffer(R__b, this);
1852 gROOT->GetListOfBrowsables()->Add(this,"Run");
1854 fTreeE = dynamic_cast<TTree*>(gDirectory->Get("TE"));
1856 fTreeE->SetBranchAddress("Header", &fHeader);
1858 else Error("Streamer","cannot find Header Tree\n");
1860 fTreeE->GetEntry(0);
1863 AliRun::Class()->WriteBuffer(R__b, this);
1868 //_______________________________________________________________________
1869 Int_t AliRun::CurrentTrack() const {
1871 // Returns current track
1873 return fStack->CurrentTrack();
1876 //_______________________________________________________________________
1877 Int_t AliRun::GetNtrack() const {
1879 // Returns number of tracks in stack
1881 return fStack->GetNtrack();
1884 //_______________________________________________________________________
1885 TObjArray* AliRun::Particles() {
1887 // Returns pointer to Particles array
1889 return fStack->Particles();
1892 //_______________________________________________________________________
1893 TTree* AliRun::TreeK() {
1895 // Returns pointer to the TreeK array
1897 return fStack->TreeK();
1901 //_______________________________________________________________________
1902 void AliRun::SetGenEventHeader(AliGenEventHeader* header)
1904 fHeader->SetGenEventHeader(header);
1907 //_______________________________________________________________________
1908 TFile* AliRun::InitFile(TString fileName)
1911 // create the file where the whole tree will be saved
1913 TDirectory *wd = gDirectory;
1914 TFile* file = TFile::Open(fileName,"update");
1916 if (!file->IsOpen()) {
1917 Error("Cannot open file, %s\n",fileName);
1923 //_______________________________________________________________________
1924 TFile* AliRun::InitTreeFile(Option_t *option, TString fileName)
1927 // create the file where one of the following trees will be saved
1929 // WARNING: by default these trees are saved on the file on which
1930 // hits are stored. If you divert one of these trees, you cannot restore
1931 // it to the original file (usually galice.root) in the same aliroot session
1932 Bool_t oS = (strstr(option,"S")!=0);
1933 Bool_t oR = (strstr(option,"R")!=0);
1934 Bool_t oD = (strstr(option,"D")!=0);
1936 for (Int_t i=0; i<3; i++) choice[i] = 0;
1937 if(oS)choice[0] = 1;
1938 if(oD)choice[1] = 1;
1939 if(oR)choice[2] = 1;
1943 if(!(oS || oR || oD))return ptr;
1946 for (Int_t i=0; i<3; i++) active[i] = 0;
1947 if(fTreeSFileName != "") active[0] = 1;
1948 if(fTreeDFileName != "") active[1] = 1;
1949 if(fTreeDFileName != "") active[2] = 1;
1951 Bool_t alreadyopen1 = kFALSE;
1952 Bool_t alreadyopen2 = kFALSE;
1955 // if already active and same name with non-null ptr
1956 if(active[0]==1 && fileName == fTreeSFileName && fTreeSFile){
1957 Warning("InitTreeFile","File %s already opened",fTreeSFileName.Data());
1961 // if already active with different name with non-null ptr
1962 if(active[0]==1 && fileName != fTreeSFileName && fTreeSFile){
1963 // close the active files and also the other possible files in option
1964 CloseTreeFile(option);
1966 fTreeSFileName = fileName;
1968 (active[1] == 1 && fTreeDFileName == fTreeSFileName && fTreeDFile);
1970 (active[2] == 1 && fTreeRFileName == fTreeSFileName && fTreeRFile);
1971 if(!(alreadyopen1 || alreadyopen2)){
1972 ptr = InitFile(fileName);
1976 if(alreadyopen1){fTreeSFile = fTreeDFile; ptr = fTreeSFile;}
1977 if(alreadyopen2){fTreeSFile = fTreeRFile; ptr = fTreeSFile;}
1979 if(choice[1] == 1) { fTreeDFileName = fileName; fTreeDFile = ptr;}
1980 if(choice[2] == 1) { fTreeRFileName = fileName; fTreeRFile = ptr;}
1986 // if already active and same name with non-null ptr
1987 if(active[1]==1 && fileName == fTreeDFileName && fTreeDFile){
1988 Warning("InitTreeFile","File %s already opened",fTreeDFileName.Data());
1992 // if already active with different name with non-null ptr
1993 if(active[1]==1 && fileName != fTreeDFileName && fTreeDFile){
1994 // close the active files and also the other possible files in option
1995 CloseTreeFile(option);
1997 fTreeDFileName = fileName;
1999 (active[0] == 1 && fTreeSFileName == fTreeDFileName && fTreeSFile);
2001 (active[2] == 1 && fTreeRFileName == fTreeDFileName && fTreeRFile);
2002 if(!(alreadyopen1 || alreadyopen2)){
2003 ptr = InitFile(fileName);
2007 if(alreadyopen1){fTreeDFile = fTreeSFile; ptr = fTreeDFile;}
2008 if(alreadyopen2){fTreeDFile = fTreeRFile; ptr = fTreeDFile;}
2010 if(choice[2] == 1) { fTreeRFileName = fileName; fTreeRFile = ptr;}
2016 // if already active and same name with non-null ptr
2017 if(active[2]==1 && fileName == fTreeRFileName && fTreeRFile){
2018 Warning("InitTreeFile","File %s already opened",fTreeRFileName.Data());
2022 // if already active with different name with non-null ptr
2023 if(active[2]==1 && fileName != fTreeRFileName && fTreeRFile){
2024 // close the active files and also the other possible files in option
2025 CloseTreeFile(option);
2027 fTreeRFileName = fileName;
2029 (active[1] == 1 && fTreeDFileName == fTreeRFileName && fTreeDFile);
2031 (active[0]== 1 && fTreeSFileName == fTreeRFileName && fTreeSFile);
2032 if(!(alreadyopen1 || alreadyopen2)){
2033 ptr = InitFile(fileName);
2037 if(alreadyopen1){fTreeRFile = fTreeDFile; ptr = fTreeRFile;}
2038 if(alreadyopen2){fTreeRFile = fTreeSFile; ptr = fTreeRFile;}
2046 //_______________________________________________________________________
2047 void AliRun::PrintTreeFile()
2050 // prints the file names and pointer associated to S,D,R trees
2052 cout<<"===================================================\n";
2053 TFile *file = fTreeE->GetCurrentFile();
2054 TString curfilname="";
2055 if(file)curfilname=static_cast<TString>(file->GetName());
2056 cout<<" Current tree file name: "<<curfilname<<endl;
2057 cout<<"Pointer: "<<file<<endl;
2058 cout<<" Tree S File name: "<<fTreeSFileName<<endl;
2059 cout<<"Pointer: "<<fTreeSFile<<endl<<endl;
2060 cout<<" Tree D File name: "<<fTreeDFileName<<endl;
2061 cout<<"Pointer: "<<fTreeDFile<<endl<<endl;
2062 cout<<" Tree R File name: "<<fTreeRFileName<<endl;
2063 cout<<"Pointer: "<<fTreeRFile<<endl<<endl;
2064 cout<<"===================================================\n";
2066 //_______________________________________________________________________
2067 void AliRun::CloseTreeFile(Option_t *option)
2070 // closes the file containing the tree specified in option
2073 Bool_t oS = (strstr(option,"S")!=0);
2074 Bool_t oR = (strstr(option,"R")!=0);
2075 Bool_t oD = (strstr(option,"D")!=0);
2076 Bool_t none = !(oS || oR || oD);
2079 fTreeSFileName = "";
2081 if(!((fTreeSFile == fTreeDFile) || (fTreeSFile == fTreeRFile)) &&
2082 fTreeSFile->IsOpen()){
2083 fTreeSFile->Close();
2090 fTreeDFileName = "";
2092 if(!((fTreeDFile == fTreeRFile) || (fTreeDFile == fTreeSFile)) &&
2093 fTreeDFile->IsOpen()){
2094 fTreeDFile->Close();
2101 fTreeRFileName = "";
2103 if(!((fTreeRFile == fTreeSFile) || (fTreeRFile == fTreeDFile)) &&
2104 fTreeRFile->IsOpen()){
2105 fTreeRFile->Close();
2113 //_______________________________________________________________________
2114 void AliRun::MakeTree(Option_t *option, TFile *file)
2117 // Create some trees in the separate file
2119 const char *oD = strstr(option,"D");
2120 const char *oR = strstr(option,"R");
2121 const char *oS = strstr(option,"S");
2123 TDirectory *cwd = gDirectory;
2128 sprintf(hname,"TreeD%d",fEvent);
2130 fTreeD = static_cast<TTree*>(file->Get("hname"));
2132 fTreeD = new TTree(hname,"Digits");
2133 fTreeD->Write(0,TObject::kOverwrite);
2139 sprintf(hname,"TreeS%d",fEvent);
2141 fTreeS = static_cast<TTree*>(file->Get("hname"));
2143 fTreeS = new TTree(hname,"SDigits");
2144 fTreeS->Write(0,TObject::kOverwrite);
2151 sprintf(hname,"TreeR%d",fEvent);
2153 fTreeR = static_cast<TTree*>(file->Get("hname"));
2155 fTreeR = new TTree(hname,"RecPoint");
2156 fTreeR->Write(0,TObject::kOverwrite);