-//_______________________________________________________________________
-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;
- }
- //
- if(fDebug) {
- 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);
- if(fDebug){
- 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) {
- if(fDebug) 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) {
- if(fDebug) 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 {
- if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
- continue;
- }
- }
-}
-
-
-//_______________________________________________________________________
-void AliRun::MakeTree(Option_t *option, const 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 *oTR = strstr(option,"T");
- const char *oE = strstr(option,"E");
- const char *oD = strstr(option,"D");
- const char *oR = strstr(option,"R");
- const char *oS = strstr(option,"S");
- //
-
- TDirectory *cwd = gDirectory;
-
- TBranch *branch = 0;
-
- if (oK) fStack->MakeTree(fEvent, file);
-
- if (oE && !fTreeE) {
- fTreeE = new TTree("TE","Header");
- // branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0);
- branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0);
- branch->SetAutoDelete(kFALSE);
- TFolder *folder = dynamic_cast<TFolder *>(gROOT->FindObjectAny("/Folders/RunMC/Event/Header"));
- if (folder) folder->Add(fHeader);
-// branch = fTreeE->Branch("Stack","AliStack", &fStack, 4000, 0);
-// branch->SetAutoDelete(kFALSE);
-// if (folder) folder->Add(fStack);
- fTreeE->Write(0,TObject::kOverwrite);
- }
-
- if (file && branch) {
- char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
- sprintf(outFile,"%s/%s",GetBaseFile(),file);
- branch->SetFile(outFile);
- TIter next( branch->GetListOfBranches());
- while ((branch=dynamic_cast<TBranch*>(next()))) {
- branch->SetFile(outFile);
- }
- if (GetDebug()>1)
- printf("* MakeBranch * Diverting Branch %s to file %s\n", branch->GetName(),file);
- cwd->cd();
- delete outFile;
- }
-
- if (oH && !fTreeH) {
- sprintf(hname,"TreeH%d",fEvent);
- fTreeH = new TTree(hname,"Hits");
- fTreeH->SetAutoSave(1000000000); //no autosave
- fTreeH->Write(0,TObject::kOverwrite);
- }
-
- if (oTR && !fTreeTR) {
- sprintf(hname,"TreeTR%d",fEvent);
- fTreeTR = new TTree(hname,"TrackReferences");
- fTreeTR->SetAutoSave(1000000000); //no autosave
- fTreeTR->Write(0,TObject::kOverwrite);
- }
-
- if (oD && !fTreeD) {
- sprintf(hname,"TreeD%d",fEvent);
- fTreeD = new TTree(hname,"Digits");
- fTreeD->Write(0,TObject::kOverwrite);
- }
- if (oS && !fTreeS) {
- sprintf(hname,"TreeS%d",fEvent);
- fTreeS = new TTree(hname,"SDigits");
- fTreeS->Write(0,TObject::kOverwrite);
- }
- if (oR && !fTreeR) {
- sprintf(hname,"TreeR%d",fEvent);
- fTreeR = new TTree(hname,"Reconstruction");
- fTreeR->Write(0,TObject::kOverwrite);
- }
-
- //
- // 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 = dynamic_cast<AliModule*>(next()))) {
- if (oH) detector->MakeBranch(option,file);
- if (oTR) detector->MakeBranchTR(option,file);
- }
-}
-
-//_______________________________________________________________________
-TParticle* AliRun::Particle(Int_t i)
-{
- return fStack->Particle(i);
-}
-