/*
$Log$
+Revision 1.76 2002/11/21 23:05:27 alibrary
+Removing AliMC and AliMCProcess
+
+Revision 1.75 2002/10/22 14:45:25 alibrary
+Introducing Riostream.h
+
+Revision 1.74 2002/10/14 14:57:00 hristov
+Merging the VirtualMC branch to the main development branch (HEAD)
+
+Revision 1.67.4.3 2002/10/14 13:14:07 hristov
+Updating VirtualMC to v3-09-02
+
+Revision 1.73 2002/09/09 17:14:25 nilsen
+Update of documentation to reflect changes in AliITSdigitS?D classes.
+
+Revision 1.72 2002/06/10 17:28:55 nilsen
+Added new FillModules routine and cleaned up the old one.
+
+Revision 1.71 2002/05/13 14:27:56 hristov
+TreeC created once per event (M.Masera)
+
+Revision 1.70 2002/05/10 22:28:30 nilsen
+Changes by Massimo Masera to allow the TTree of clusters to be written to a
+file otherthan the one with digits in it.
+
Revision 1.69 2002/05/05 21:06:55 nilsen
Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
proper initilization when a simulation has already been defined.
// futher information.
//
///////////////////////////////////////////////////////////////////////////////
-#include <iostream.h>
-#include <iomanip.h>
-#include <fstream.h>
+#include <Riostream.h>
#include <stdlib.h>
#include <TMath.h>
#include <TRandom.h>
#include <TTree.h>
#include <TString.h>
-#include "AliMC.h"
#include "AliHeader.h"
#include "AliITS.h"
// Return:
// none.
+ if (fHits) {
+ fHits->Delete();
delete fHits;
+ fHits=0;
+ }
+ if (fSDigits) {
+ fSDigits->Delete();
delete fSDigits;
- delete fDigits;
+ fSDigits=0;
+ }
+// delete fDigits; fDigits=0;
+ if (fRecPoints) {
+ fRecPoints->Delete();
delete fRecPoints;
- if(fIdName!=0) delete[] fIdName; // Array of TStrings
- if(fIdSens!=0) delete[] fIdSens;
- if(fITSmodules!=0) {
+ fRecPoints=0;
+ }
+ delete[] fIdName; // Array of TStrings
+ delete[] fIdSens;
+ if(fITSmodules) {
this->ClearModules();
delete fITSmodules;
- }// end if fITSmodules!=0
-
- if(fDtype) {
- fDtype->Delete();
- delete fDtype;
- } // end if fDtype
- delete [] fNdtype;
- if (fCtype) {
- fCtype->Delete();
- delete fCtype;
- } // end if fCtype
- delete [] fNctype;
-
- if (fDetTypes) {
- fDetTypes->Delete();
- delete fDetTypes;
- } // end if fDetTypes
-
- if (fTreeC) delete fTreeC;
-
- if (fITSgeom) delete fITSgeom;
+ fITSmodules = 0;
+ }// end if fITSmodules!=0
+
+ if(fDtype) {
+ fDtype->Delete();
+ delete fDtype;
+ } // end if fDtype
+ delete [] fNdtype;
+ if (fCtype) {
+ fCtype->Delete();
+ delete fCtype;
+ } // end if fCtype
+ delete [] fNctype;
+
+ if (fDetTypes) {
+ fDetTypes->Delete();
+ delete fDetTypes;
+ } // end if fDetTypes
+
+ if (fTreeC) delete fTreeC;
+
+ if (fITSgeom) delete fITSgeom;
}
//______________________________________________________________________
AliITS::AliITS(AliITS &source){
// Return:
// none.
static TTree *trH1; //Tree with background hits
- static TClonesArray *fHits2; //List of hits for one track only
+// static TClonesArray *fHits2; //List of hits for one track only
static Bool_t first=kTRUE;
static TFile *file;
const char *addBgr = strstr(option,"Add");
if (addBgr ) {
if(first) {
file=new TFile(filename);
- fHits2 = new TClonesArray("AliITShit",1000 );
+// fHits2 = new TClonesArray("AliITShit",1000 );
} // end if first
first=kFALSE;
file->cd();
file->ls();
// Get Hits Tree header from file
- if(fHits2) fHits2->Clear();
+// if(fHits2) fHits2->Clear();
if(trH1) delete trH1;
trH1=0;
Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
} // end if !trH1
// Set branch addresses
+/*
TBranch *branch;
char branchname[20];
sprintf(branchname,"%s",GetName());
branch = trH1->GetBranch(branchname);
if (branch) branch->SetAddress(&fHits2);
} // end if trH1 && fHits
+*/
} // end if addBgr
+ FillModules(gAlice->TreeH(),0); // fill from this file's tree.
+/*
TClonesArray *itsHits = this->Hits();
Int_t lay,lad,det,index;
AliITShit *itsHit=0;
mod->AddHit(itsHit,t,h);
} // end loop over hits
} // end loop over tracks
-
+*/
// open the file with background
if (addBgr ) {
+ FillModules(trH1,10000000); // Default mask 10M.
+/*
Int_t track,i;
ntracks =(Int_t)trH1->GetEntries();
// Loop over tracks
mod->AddHit(itsHit,track,i);
} // end loop over hits
} // end loop over tracks
+*/
TTree *fAli=gAlice->TreeK();
TFile *fileAli=0;
if (fAli) fileAli =fAli->GetCurrentFile();
} // end if add
}
//______________________________________________________________________
+void AliITS::FillModules(TTree *treeH, Int_t mask) {
+ // fill the modules with the sorted by module hits;
+ // can be called many times to do a merging
+ // Inputs:
+ // TTree *treeH The tree containing the hits to be copied into
+ // the modules.
+ // Int_t mask The track number mask to indecate which file
+ // this hits came from.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+
+ Int_t lay,lad,det,index;
+ AliITShit *itsHit=0;
+ AliITSmodule *mod=0;
+ char branchname[20];
+ sprintf(branchname,"%s",GetName());
+ TBranch *branch = treeH->GetBranch(branchname);
+ if (!branch) {
+ Error("FillModules","%s branch in TreeH not found",branchname);
+ return;
+ } // end if !branch
+ branch->SetAddress(&fHits);
+ Int_t nTracks =(Int_t) treeH->GetEntries();
+ Int_t iPrimTrack,h;
+ for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
+ ResetHits();
+ Int_t nBytes = treeH->GetEvent(iPrimTrack);
+ if (nBytes <= 0) continue;
+ Int_t nHits = fHits->GetEntriesFast();
+ for(h=0; h<nHits; h++){
+ itsHit = (AliITShit *)fHits->UncheckedAt(h);
+ itsHit->GetDetectorID(lay,lad,det);
+ if (fITSgeom) {
+ index = fITSgeom->GetModuleIndex(lay,lad,det);
+ } else {
+ index=det-1; // This should not be used.
+ } // end if [You must have fITSgeom for this to work!]
+ mod = GetModule(index);
+ itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
+ mod->AddHit(itsHit,iPrimTrack,h);
+ } // end loop over hits
+ } // end loop over tracks
+}
+//______________________________________________________________________
void AliITS::ClearModules(){
// Clear the modules TObjArray.
// Inputs:
// Float_t phys Physics indicator. See AliITSdigits.h
// Int_t *digits Integer array containing the digits info. See
// AliITSdigit.h
- // Int_t *tracks Integer array [3] containing the track numbers that
- // contributed to this digit.
- // Int_t *hits Integer array [3] containing the hit numbers that
+ // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
+ // containing the track numbers that contributed to
+ // this digit.
+ // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
+ // containing the hit numbers, from AliITSmodule, that
// contributed to this digit.
// Float_t *charge Floating point array of the signals contributed
// to this digit by each track.
TFile *fileRecPoints = gAlice->GetTreeRFile();
if(fileRecPoints)fileRecPoints->cd();
const char *optC = strstr(option,"C");
- if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
+ char hname[30];
+ Int_t cureve = gAlice->GetEvNumber();
+ sprintf(hname,"TreeC%d",cureve);
+ if(fTreeC){
+ const char *curname = fTreeC->GetName();
+ char *exists = strstr(hname,curname);
+ if(!exists){
+ delete fTreeC;
+ fTreeC=0;
+ }
+ }
+ if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
else return;
Int_t buffersize = 4000;
char clclass[40];
// one branch for Clusters per type of detector
- Int_t i;
+ Int_t i;
for (i=0; i<kNTYPES ;i++) {
AliITSDetType *iDetType=DetType(i);
iDetType->GetClassNames(digclass,clclass);
// clusters
- fCtype->AddAt(new TClonesArray(clclass,1000),i);
+ if(!ClustersAddress(i)){
+ fCtype->AddAt(new TClonesArray(clclass,1000),i);
+ }
if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
else sprintf(branchname,"%sClusters%d",GetName(),i+1);
if (fCtype && fTreeC) {