- fField = new AliMagFCM("Map2-3",filename,type,scale,maxField);
- fField->ReadField();
- } else if(version==3) {
- fField = new AliMagFDM("Map4",filename,type,scale,maxField);
- fField->ReadField();
- } else {
- Warning("SetField","Invalid map %d\n",version);
- }
-}
-
-//_____________________________________________________________________________
-void AliRun::PreTrack()
-{
- TObjArray &dets = *fModules;
- AliModule *module;
-
- for(Int_t i=0; i<=fNdets; i++)
- if((module = (AliModule*)dets[i]))
- module->PreTrack();
-
- fMCQA->PreTrack();
-}
-
-//_____________________________________________________________________________
-void AliRun::PostTrack()
-{
- TObjArray &dets = *fModules;
- AliModule *module;
-
- for(Int_t i=0; i<=fNdets; i++)
- if((module = (AliModule*)dets[i]))
- module->PostTrack();
-}
-
-//_____________________________________________________________________________
-void AliRun::FinishPrimary()
-{
- //
- // Called at the end of each primary track
- //
-
- // static Int_t count=0;
- // const Int_t times=10;
- // This primary is finished, purify stack
- PurifyKine();
-
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- detector->FinishPrimary();
- }
-
- // Write out hits if any
- if (gAlice->TreeH()) {
- gAlice->TreeH()->Fill();
- }
-
- // Reset Hits info
- gAlice->ResetHits();
-
- //
- // if(++count%times==1) gObjectTable->Print();
-}
-
-//_____________________________________________________________________________
-void AliRun::FinishEvent()
-{
- //
- // Called at the end of the event.
- //
-
- //
- if(fLego) fLego->FinishEvent();
-
- //Update the energy deposit tables
- Int_t i;
- for(i=0;i<fEventEnergy.GetSize();i++) {
- fSummEnergy[i]+=fEventEnergy[i];
- fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
- }
- fEventEnergy.Reset();
-
- // Clean detector information
- CleanDetectors();
-
- // Write out the kinematics
- if (fTreeK) {
- CleanParents();
- if(fTreeK->GetEntries() ==0) {
- // set the fParticleFileMap size for the first time
- if (fHgwmk+1 > fParticleFileMap.GetSize())
- fParticleFileMap.Set(fHgwmk+1);
- }
- // fTreeK->Fill();
- Bool_t allFilled = kFALSE;
- TObject *part;
- for(i=0; i<fHgwmk+1; ++i) if((part=fParticleMap->At(i))) {
- fParticleBuffer = (TParticle*) part;
- fParticleFileMap[i]= (Int_t) fTreeK->GetEntries();
- fTreeK->Fill();
- (*fParticleMap)[i]=0;
-
- // When all primaries were filled no particle!=0
- // should be left => to be removed later.
- if (allFilled) printf("Why != 0 part # %d?\n",i);
- }
- else {
- // // printf("Why = 0 part # %d?\n",i); => We know.
- // break;
- // we don't break now in order to be sure there is no
- // particle !=0 left.
- // To be removed later and replaced with break.
- if(!allFilled) allFilled = kTRUE;
- }
- }
-
- // Set number of tracks to event header
- fHeader.SetNtrack(fNtrack);
-
- // Write out the digits
- if (fTreeD) {
- fTreeD->Fill();
- ResetDigits();
- }
-
- if (fTreeS) {
- fTreeS->Fill();
- ResetSDigits();
- }
-
- // Write out reconstructed clusters
- if (fTreeR) {
- fTreeR->Fill();
- }
-
- // Write out the event Header information
- if (fTreeE) fTreeE->Fill();
-
- // Reset stack info
- ResetStack();
-
- // Write Tree headers
- if (fTreeK) fTreeK->Write(0,TObject::kOverwrite);
- if (fTreeH) fTreeH->Write(0,TObject::kOverwrite);
- if (fTreeD) fTreeD->Write(0,TObject::kOverwrite);
- if (fTreeR) fTreeR->Write(0,TObject::kOverwrite);
- if (fTreeS) fTreeS->Write(0,TObject::kOverwrite);
-
- ++fEvent;
-}
-
-//_____________________________________________________________________________
-void AliRun::FinishRun()
-{
- //
- // Called at the end of the run.
- //
-
- //
- if(fLego) fLego->FinishRun();
-
- if(fGenerator) fGenerator->FinishRun();
-
- // Clean detector information
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- detector->FinishRun();
- }
-
- //Output energy summary tables
- EnergySummary();
-
- TFile *file = fTreeE->GetCurrentFile();
-
- file->cd();
-
- fTreeE->Write(0,TObject::kOverwrite);
-
- // Write AliRun info and all detectors parameters
- Write(0,TObject::kOverwrite);
-
- // Clean tree information
- if (fTreeK) {
- delete fTreeK; fTreeK = 0;
- }
- if (fTreeH) {
- delete fTreeH; fTreeH = 0;
- }
- if (fTreeD) {
- delete fTreeD; fTreeD = 0;
- }
- if (fTreeR) {
- delete fTreeR; fTreeR = 0;
- }
- if (fTreeE) {
- delete fTreeE; fTreeE = 0;
- }
-
- // Close output file
- file->Write();
-}
-
-//_____________________________________________________________________________
-void AliRun::FlagTrack(Int_t track)
-{
- //
- // Flags a track and all its family tree to be kept
- //
- int curr;
- TParticle *particle;
-
- curr=track;
- while(1) {
- particle=(TParticle*)fParticleMap->At(curr);
-
- // If the particle is flagged the three from here upward is saved already
- if(particle->TestBit(kKeepBit)) return;
-
- // Save this particle
- particle->SetBit(kKeepBit);
-
- // Move to father if any
- if((curr=particle->GetFirstMother())==-1) return;
- }
-}
-
-//_____________________________________________________________________________
-void AliRun::EnergySummary()
-{
- //
- // Print summary of deposited energy
- //
-
- Int_t ndep=0;
- Float_t edtot=0;
- Float_t ed, ed2;
- Int_t kn, i, left, j, id;
- const Float_t kzero=0;
- Int_t ievent=fHeader.GetEvent()+1;
- //
- // Energy loss information
- if(ievent) {
- printf("***************** Energy Loss Information per event (GEV) *****************\n");
- for(kn=1;kn<fEventEnergy.GetSize();kn++) {
- ed=fSummEnergy[kn];
- if(ed>0) {
- fEventEnergy[ndep]=kn;
- if(ievent>1) {
- ed=ed/ievent;
- ed2=fSum2Energy[kn];
- ed2=ed2/ievent;
- ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
- } else
- ed2=99;
- fSummEnergy[ndep]=ed;
- fSum2Energy[ndep]=TMath::Min((Float_t) 99.,TMath::Max(ed2,kzero));
- edtot+=ed;
- ndep++;
- }
- }
- for(kn=0;kn<(ndep-1)/3+1;kn++) {
- left=ndep-kn*3;
- for(i=0;i<(3<left?3:left);i++) {
- j=kn*3+i;
- id=Int_t (fEventEnergy[j]+0.1);
- printf(" %s %10.3f +- %10.3f%%;",gMC->VolName(id),fSummEnergy[j],fSum2Energy[j]);
- }
- printf("\n");
- }
- //
- // Relative energy loss in different detectors
- printf("******************** Relative Energy Loss per event ********************\n");
- printf("Total energy loss per event %10.3f GeV\n",edtot);
- for(kn=0;kn<(ndep-1)/5+1;kn++) {
- left=ndep-kn*5;
- for(i=0;i<(5<left?5:left);i++) {
- j=kn*5+i;
- id=Int_t (fEventEnergy[j]+0.1);
- printf(" %s %10.3f%%;",gMC->VolName(id),100*fSummEnergy[j]/edtot);
- }
- printf("\n");
- }
- for(kn=0;kn<75;kn++) printf("*");
- printf("\n");
- }
- //
- // Reset the TArray's
- // fEventEnergy.Set(0);
- // fSummEnergy.Set(0);
- // fSum2Energy.Set(0);
-}
-
-//_____________________________________________________________________________
-AliModule *AliRun::GetModule(const char *name) const
-{
- //
- // Return pointer to detector from name
- //
- return (AliModule*)fModules->FindObject(name);
-}
-
-//_____________________________________________________________________________
-AliDetector *AliRun::GetDetector(const char *name) const
-{
- //
- // Return pointer to detector from name
- //
- return (AliDetector*)fModules->FindObject(name);
-}
-
-//_____________________________________________________________________________
-Int_t AliRun::GetModuleID(const char *name) const
-{
- //
- // Return galice internal detector identifier from name
- //
- Int_t i=-1;
- TObject *mod=fModules->FindObject(name);
- if(mod) i=fModules->IndexOf(mod);
- return i;
-}
-
-//_____________________________________________________________________________
-Int_t AliRun::GetEvent(Int_t event)
-{
- //
- // Connect the Trees Kinematics and Hits for event # event
- // Set branch addresses
- //
-
- // Reset existing structures
- // ResetStack();
- ResetHits();
- ResetDigits();
- ResetSDigits();
-
- // Delete Trees already connected
- if (fTreeK) delete fTreeK;
- if (fTreeH) delete fTreeH;
- if (fTreeD) delete fTreeD;
- if (fTreeR) delete fTreeR;
- if (fTreeS) delete fTreeS;
-
- // Get header from file
- if(fTreeE) fTreeE->GetEntry(event);
- else Error("GetEvent","Cannot file Header Tree\n");
- TFile *file = fTreeE->GetCurrentFile();
-
- file->cd();
-
- // Get Kine Tree from file
- char treeName[20];
- sprintf(treeName,"TreeK%d",event);
- fTreeK = (TTree*)gDirectory->Get(treeName);
- if (fTreeK) fTreeK->SetBranchAddress("Particles", &fParticleBuffer);
- else Error("GetEvent","cannot find Kine Tree for event:%d\n",event);
- // Create the particle stack
-
- if(fParticles)
- fParticles->Clear();
- else
- fParticles = new TClonesArray("TParticle",1000);
-
- // Build the pointer list
- if(fParticleMap) {
- fParticleMap->Clear();
- fParticleMap->Expand(fTreeK->GetEntries());
- } else
- fParticleMap = new TObjArray(fTreeK->GetEntries());
-
- file->cd();
-
- // Get Hits Tree header from file
- sprintf(treeName,"TreeH%d",event);
- fTreeH = (TTree*)gDirectory->Get(treeName);
- if (!fTreeH) {
- Error("GetEvent","cannot find Hits Tree for event:%d\n",event);
- }
-
- file->cd();
-
- // Get Digits Tree header from file
- sprintf(treeName,"TreeD%d",event);
- fTreeD = (TTree*)gDirectory->Get(treeName);
- if (!fTreeD) {
- // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event);
- }
-
- file->cd();
-
- // Get SDigits Tree header from file
- sprintf(treeName,"TreeS%d",event);
- fTreeS = (TTree*)gDirectory->Get(treeName);
- if (!fTreeS) {
- // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event);
- }
-
- file->cd();
-
- // Get Reconstruct Tree header from file
- sprintf(treeName,"TreeR%d",event);
- fTreeR = (TTree*)gDirectory->Get(treeName);
- if (!fTreeR) {
- // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event);
- }
-
- file->cd();
-
- // Set Trees branch addresses
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- detector->SetTreeAddress();
- }
-
- fNtrack = Int_t (fTreeK->GetEntries());
- return fNtrack;
-}
-
-//_____________________________________________________________________________
-TGeometry *AliRun::GetGeometry()
-{
- //
- // Import Alice geometry from current file
- // Return pointer to geometry object
- //
- if (!fGeometry) fGeometry = (TGeometry*)gDirectory->Get("AliceGeom");
- //
- // Unlink and relink nodes in detectors
- // This is bad and there must be a better way...
- //
-
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- TList *dnodes=detector->Nodes();
- Int_t j;
- TNode *node, *node1;
- for ( j=0; j<dnodes->GetSize(); j++) {
- node = (TNode*) dnodes->At(j);
- node1 = fGeometry->GetNode(node->GetName());
- dnodes->Remove(node);
- dnodes->AddAt(node1,j);
- }
- }
- return fGeometry;
-}
-
-//_____________________________________________________________________________
-void AliRun::GetNextTrack(Int_t &mtrack, Int_t &ipart, Float_t *pmom,
- Float_t &e, Float_t *vpos, Float_t *polar,
- Float_t &tof)
-{
- //
- // Return next track from stack of particles
- //
- TVector3 pol;
- fCurrent=-1;
- TParticle *track;
- for(Int_t i=fNtrack-1; i>=0; i--) {
- track=(TParticle*) fParticleMap->At(i);
- if(track) if(!track->TestBit(kDoneBit)) {
- //
- // The track exists and has not yet been processed
- fCurrent=i;
- ipart=track->GetPdgCode();
- pmom[0]=track->Px();
- pmom[1]=track->Py();
- pmom[2]=track->Pz();
- e =track->Energy();
- vpos[0]=track->Vx();
- vpos[1]=track->Vy();
- vpos[2]=track->Vz();
- track->GetPolarisation(pol);
- polar[0]=pol.X();
- polar[1]=pol.Y();
- polar[2]=pol.Z();
- tof=track->T();
- track->SetBit(kDoneBit);
- break;
- }
- }
- mtrack=fCurrent;
- //
- // stop and start timer when we start a primary track
- Int_t nprimaries = fHeader.GetNprimary();
- if (fCurrent >= nprimaries) return;
- if (fCurrent < nprimaries-1) {
- fTimer.Stop();
- track=(TParticle*) fParticleMap->At(fCurrent+1);
- // track->SetProcessTime(fTimer.CpuTime());
- }
- fTimer.Start();
-}
-
-//_____________________________________________________________________________
-Int_t AliRun::GetPrimary(Int_t track)
-{
- //
- // return number of primary that has generated track
- //
- int current, parent;
- TParticle *part;
- //
- parent=track;
- while (1) {
- current=parent;
- part = (TParticle *)fParticleMap->At(current);
- if(!part) part = Particle(current);
- parent=part->GetFirstMother();
- if(parent<0) return current;
- }
-}
-
-//_____________________________________________________________________________
-void AliRun::InitMC(const char *setup)
-{
- //
- // Initialize the Alice setup
- //
-
- if(fInitDone) {
- Warning("Init","Cannot initialise AliRun twice!\n");
- return;
- }
-
- gROOT->LoadMacro(setup);
- gInterpreter->ProcessLine(fConfigFunction.Data());
-
-
- gMC->DefineParticles(); //Create standard MC particles
-
- TObject *objfirst, *objlast;
-
- fNdets = fModules->GetLast()+1;
-
- //
- //=================Create Materials and geometry
- gMC->Init();
-
- // Added also after in case of interactive initialisation of modules
- fNdets = fModules->GetLast()+1;
-
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- detector->SetTreeAddress();
- objlast = gDirectory->GetList()->Last();
-
- // Add Detector histograms in Detector list of histograms
- if (objlast) objfirst = gDirectory->GetList()->After(objlast);
- else objfirst = gDirectory->GetList()->First();
- while (objfirst) {
- detector->Histograms()->Add(objfirst);
- objfirst = gDirectory->GetList()->After(objfirst);
- }
- }
- ReadTransPar(); //Read the cuts for all materials
-
- MediaTable(); //Build the special IMEDIA table
-
- //Initialise geometry deposition table
- fEventEnergy.Set(gMC->NofVolumes()+1);
- fSummEnergy.Set(gMC->NofVolumes()+1);
- fSum2Energy.Set(gMC->NofVolumes()+1);
-
- //Compute cross-sections
- gMC->BuildPhysics();
-
- //Write Geometry object to current file.
- fGeometry->Write();
-
- fInitDone = kTRUE;
-
- fMCQA = new AliMCQA(fNdets);
-
- //
- // Save stuff at the beginning of the file to avoid file corruption
- Write();
-}
-
-//_____________________________________________________________________________
-void AliRun::MediaTable()
-{
- //
- // Built media table to get from the media number to
- // the detector id
- //
- Int_t kz, nz, idt, lz, i, k, ind;
- // Int_t ibeg;
- TObjArray &dets = *gAlice->Detectors();
- AliModule *det;
- //
- // For all detectors
- for (kz=0;kz<fNdets;kz++) {
- // If detector is defined
- if((det=(AliModule*) dets[kz])) {
- TArrayI &idtmed = *(det->GetIdtmed());
- for(nz=0;nz<100;nz++) {
- // Find max and min material number
- if((idt=idtmed[nz])) {
- det->LoMedium() = det->LoMedium() < idt ? det->LoMedium() : idt;
- det->HiMedium() = det->HiMedium() > idt ? det->HiMedium() : idt;
- }
- }
- if(det->LoMedium() > det->HiMedium()) {
- det->LoMedium() = 0;
- det->HiMedium() = 0;
- } else {
- if(det->HiMedium() > fImedia->GetSize()) {
- Error("MediaTable","Increase fImedia from %d to %d",
- fImedia->GetSize(),det->HiMedium());
- return;
- }
- // Tag all materials in rage as belonging to detector kz
- for(lz=det->LoMedium(); lz<= det->HiMedium(); lz++) {
- (*fImedia)[lz]=kz;
- }
- }
- }
- }
- //
- // Print summary table
- printf(" Traking media ranges:\n");
- for(i=0;i<(fNdets-1)/6+1;i++) {
- for(k=0;k< (6<fNdets-i*6?6:fNdets-i*6);k++) {
- ind=i*6+k;
- det=(AliModule*)dets[ind];
- if(det)
- printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(),
- det->HiMedium());
- else
- printf(" %6s: %3d -> %3d;","NULL",0,0);
- }
- printf("\n");
- }
-}
-
-//____________________________________________________________________________
-void AliRun::SetGenerator(AliGenerator *generator)
-{
- //
- // Load the event generator
- //
- if(!fGenerator) fGenerator = generator;
-}
-
-//____________________________________________________________________________
-void AliRun::ResetGenerator(AliGenerator *generator)
-{
- //
- // Load the event generator
- //
- if(fGenerator)
- if(generator)
- Warning("ResetGenerator","Replacing generator %s with %s\n",
- fGenerator->GetName(),generator->GetName());
- else
- Warning("ResetGenerator","Replacing generator %s with NULL\n",
- fGenerator->GetName());
- fGenerator = generator;
-}
-
-//____________________________________________________________________________
-void AliRun::SetTransPar(char *filename)
-{
- fTransParName = filename;
-}
-
-//____________________________________________________________________________
-void AliRun::SetBaseFile(char *filename)
-{
- fBaseFileName = filename;
-}
-
-//____________________________________________________________________________
-void AliRun::ReadTransPar()
-{
- //
- // Read filename to set the transport parameters
- //
-
-
- const Int_t kncuts=10;
- const Int_t knflags=11;
- const Int_t knpars=kncuts+knflags;
- const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
- "BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
- "BREM","COMP","DCAY","DRAY","HADR","LOSS",
- "MULS","PAIR","PHOT","RAYL"};
- char line[256];
- char detName[7];
- char* filtmp;
- Float_t cut[kncuts];
- Int_t flag[knflags];
- Int_t i, itmed, iret, ktmed, kz;
- FILE *lun;
- //
- // See whether the file is there
- filtmp=gSystem->ExpandPathName(fTransParName.Data());
- lun=fopen(filtmp,"r");
- delete [] filtmp;
- if(!lun) {
- Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
- return;
- }
- //
- printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
- printf(" *%59s\n","*");
- printf(" * Please check carefully what you are doing!%10s\n","*");
- printf(" *%59s\n","*");
- //
- while(1) {
- // Initialise cuts and flags
- for(i=0;i<kncuts;i++) cut[i]=-99;
- for(i=0;i<knflags;i++) flag[i]=-99;
- itmed=0;
- for(i=0;i<256;i++) line[i]='\0';
- // Read up to the end of line excluded
- iret=fscanf(lun,"%[^\n]",line);
- if(iret<0) {
- //End of file
- fclose(lun);
- printf(" *%59s\n","*");
- printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
- return;
- }
- // Read the end of line
- fscanf(lun,"%*c");
- if(!iret) continue;
- if(line[0]=='*') continue;
- // Read the numbers
- 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",
- detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
- &cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
- &flag[8],&flag[9],&flag[10]);
- if(!iret) continue;
- if(iret<0) {
- //reading error
- Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
- continue;
- }
- // Check that the module exist
- AliModule *mod = GetModule(detName);
- if(mod) {
- // Get the array of media numbers
- TArrayI &idtmed = *mod->GetIdtmed();
- // Check that the tracking medium code is valid
- if(0<=itmed && itmed < 100) {
- ktmed=idtmed[itmed];
- if(!ktmed) {
- Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
- continue;
- }
- // Set energy thresholds
- for(kz=0;kz<kncuts;kz++) {
- if(cut[kz]>=0) {
- printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
- kpars[kz],cut[kz],itmed,mod->GetName());
- gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
- }
- }
- // Set transport mechanisms
- for(kz=0;kz<knflags;kz++) {
- if(flag[kz]>=0) {
- printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
- kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
- gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
- }
- }
- } else {
- Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
- continue;
- }
- } else {
- Warning("ReadTransPar","Module %s not present\n",detName);
- continue;
- }
- }
-}
-
-//_____________________________________________________________________________
-TBranch* AliRun::MakeBranchInTree(TTree *tree, const char* name, void* address, Int_t size, char *file)
-{
- //
- // Makes branch in given tree and diverts them to a separate file
- //
- if (GetDebug()>1)
- printf("* MakeBranch * Making Branch %s \n",name);
-
- TBranch *branch = tree->Branch(name,address,size);
-
- if (file) {
- char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
- sprintf(outFile,"%s/%s",gAlice->GetBaseFile(),file);
- TDirectory *cwd = gDirectory;
- branch->SetFile(outFile);
- TIter next( branch->GetListOfBranches());
- while ((branch=(TBranch*)next())) {
- branch->SetFile(outFile);
- }
- if (GetDebug()>1)
- printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
- cwd->cd();
- delete outFile;
- }
-
- return branch;
-}
-
-//_____________________________________________________________________________
-TBranch* AliRun::MakeBranchInTree(TTree *tree, const char* name, const char *classname, void* address, Int_t size, Int_t splitlevel, char *file)
-{
- //
- // Makes branch in given tree and diverts them to a separate file
- //
- TDirectory *cwd = gDirectory;
- TBranch *branch = tree->Branch(name,classname,address,size,splitlevel);
-
- if (GetDebug()>1)
- printf("* MakeBranch * Making Branch %s \n",name);
- if (file) {
- char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
- sprintf(outFile,"%s/%s",gAlice->GetBaseFile(),file);
- branch->SetFile(outFile);
- TIter next( branch->GetListOfBranches());
- while ((branch=(TBranch*)next())) {
- branch->SetFile(outFile);
- }
- if (GetDebug()>1)
- printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
- cwd->cd();
- delete outFile;
- }
- return branch;
-}
-//_____________________________________________________________________________
-void AliRun::MakeTree(Option_t *option, char *file)
-{
- //
- // Create the ROOT trees
- // Loop on all detectors to create the Root branch (if any)
- //
-
- char hname[30];
- //
- // Analyse options
- const char *oK = strstr(option,"K");
- const char *oH = strstr(option,"H");
- const char *oE = strstr(option,"E");
- const char *oD = strstr(option,"D");
- const char *oR = strstr(option,"R");
- const char *oS = strstr(option,"S");
- //
-
- if (oK && !fTreeK) {
- sprintf(hname,"TreeK%d",fEvent);
- fTreeK = new TTree(hname,"Kinematics");
- // Create a branch for particles
- MakeBranchInTree(fTreeK,
- "Particles", "TParticle", &fParticleBuffer, 4000, 1, file) ;
- fTreeK->Write();
- }
- if (oH && !fTreeH) {
- sprintf(hname,"TreeH%d",fEvent);
- fTreeH = new TTree(hname,"Hits");
- fTreeH->SetAutoSave(1000000000); //no autosave
- fTreeH->Write();
- }
- if (oD && !fTreeD) {
- sprintf(hname,"TreeD%d",fEvent);
- fTreeD = new TTree(hname,"Digits");
- fTreeD->Write();
- }
- if (oS && !fTreeS) {
- sprintf(hname,"TreeS%d",fEvent);
- fTreeS = new TTree(hname,"SDigits");
- fTreeS->Write();
- }
- if (oR && !fTreeR) {
- sprintf(hname,"TreeR%d",fEvent);
- fTreeR = new TTree(hname,"Reconstruction");
- fTreeR->Write();
- }
- if (oE && !fTreeE) {
- fTreeE = new TTree("TE","Header");
- TBranch* branch
- = MakeBranchInTree(fTreeE,
- "Header", "AliHeader", &gAliHeader, 4000, 0, file) ;
- branch->SetAutoDelete(kFALSE);
- fTreeE->Write();
- }
-
- //
- // Create a branch for hits/digits for each detector
- // Each branch is a TClonesArray. Each data member of the Hits classes
- // will be in turn a subbranch of the detector master branch
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- if (oH) detector->MakeBranch(option,file);