/*
$Log$
+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.
+
+Revision 1.68 2002/05/02 18:51:53 nilsen
+AliITS.h
+ Method MakeBranchR has now a second argument, with a default value:
+ Option_t *opt=" ". Opt="Fast" is to create a separate branch
+ for fast points in TreeR
+ New method MakeBranchRF: it a separate branch in TreeR for Fast Points
+
+AliITS.cxx
+1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
+ TreeR
+2) Changes in MakeBranchR to allow the creation of a special branch
+ for fast points
+
+Revision 1.67 2002/03/15 17:22:51 nilsen
+Intoduced SDigits2Digits and SDigitsToDigits functions.
+
Revision 1.66 2001/11/28 01:35:45 nilsen
Using standard constructors instead of default constructors for Clusterfinder,
Response, and FastSimulator.
// Return:
// none.
- delete fHits;
- delete fSDigits;
- delete fDigits;
- delete fRecPoints;
+ delete fHits; fHits=0;
+ delete fSDigits; fSDigits=0;
+// delete fDigits; fDigits=0;
+ delete fRecPoints; fRecPoints=0;
if(fIdName!=0) delete[] fIdName; // Array of TStrings
if(fIdSens!=0) delete[] fIdSens;
if(fITSmodules!=0) {
// none.
AliITSDetType *iDetType;
+ AliITSsimulation *sim;
iDetType=DetType(0);
- if (!iDetType->GetSimulationModel()) {
+ sim = iDetType->GetSimulationModel();
+ if (!sim) {
AliITSsegmentation *seg0=
(AliITSsegmentation*)iDetType->GetSegmentationModel();
AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
SetSimulationModel(0,sim0);
+ }else{ // simulation exists, make sure it is set up properly.
+ ((AliITSsimulationSPD*)sim)->Init(
+ (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
+ (AliITSresponseSPD*) iDetType->GetResponseModel());
+// if(sim->GetResponseModel()==0) sim->SetResponseModel(
+// (AliITSresponse*)iDetType->GetResponseModel());
+// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+// (AliITSsegmentation*)iDetType->GetSegmentationModel());
} // end if
iDetType=DetType(1);
- if (!iDetType->GetSimulationModel()) {
+ sim = iDetType->GetSimulationModel();
+ if (!sim) {
AliITSsegmentation *seg1=
(AliITSsegmentation*)iDetType->GetSegmentationModel();
AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
SetSimulationModel(1,sim1);
+ }else{ // simulation exists, make sure it is set up properly.
+ ((AliITSsimulationSDD*)sim)->Init(
+ (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
+ (AliITSresponseSDD*) iDetType->GetResponseModel());
+// if(sim->GetResponseModel()==0) sim->SetResponseModel(
+// (AliITSresponse*)iDetType->GetResponseModel());
+// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+// (AliITSsegmentation*)iDetType->GetSegmentationModel());
} //end if
iDetType=DetType(2);
- if (!iDetType->GetSimulationModel()) {
+ sim = iDetType->GetSimulationModel();
+ if (!sim) {
AliITSsegmentation *seg2=
(AliITSsegmentation*)iDetType->GetSegmentationModel();
AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
SetSimulationModel(2,sim2);
+ }else{ // simulation exists, make sure it is set up properly.
+ ((AliITSsimulationSSD*)sim)->Init(
+ (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
+ (AliITSresponseSSD*) iDetType->GetResponseModel());
+// if(sim->GetResponseModel()==0) sim->SetResponseModel(
+// (AliITSresponse*)iDetType->GetResponseModel());
+// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+// (AliITSsegmentation*)iDetType->GetSegmentationModel());
} // end if
}
//______________________________________________________________________
// none.
// Return:
// none.
- const char *cS = strstr(option,"S");
- const char *cD = strstr(option,"D");
- const char *cR = strstr(option,"R");
+ Bool_t cS = (strstr(option,"S")!=0);
+ Bool_t cD = (strstr(option,"D")!=0);
+ Bool_t cR = (strstr(option,"R")!=0);
+ Bool_t cRF = (strstr(option,"RF")!=0);
+ if(cRF)cR = kFALSE;
AliDetector::MakeBranch(option,file);
if(cS) MakeBranchS(file);
if(cD) MakeBranchD(file);
if(cR) MakeBranchR(file);
+ if(cRF) MakeBranchRF(file);
}
//______________________________________________________________________
void AliITS::SetTreeAddress(){
// 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:
gAlice->TreeD()->GetEntries();
- char hname[30];
- sprintf(hname,"TreeD%d",gAlice->GetEvNumber());
- gAlice->TreeD()->Write(hname,TObject::kOverwrite);
+ gAlice->TreeD()->AutoSave();
// reset tree
gAlice->TreeD()->Reset();
ClearModules();
gAlice->TreeS()->GetEntries();
-
- char hname[30];
- sprintf(hname,"TreeS%d",evNumber);
- gAlice->TreeS()->Write(hname,TObject::kOverwrite);
+ gAlice->TreeS()->AutoSave();
// reset tree
gAlice->TreeS()->Reset();
}
ClearModules();
gAlice->TreeD()->GetEntries();
-
- char hname[30];
- sprintf(hname,"TreeD%d",evNumber);
- gAlice->TreeD()->Write(hname,TObject::kOverwrite);
+ gAlice->TreeD()->AutoSave();
// reset tree
gAlice->TreeD()->Reset();
}
// 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.
// none.
// Return:
// none.
-
+ TDirectory *cwd = gDirectory;
+ 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) {
TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
} // end if fCtype && fTreeC
} // end for i
+ cwd->cd();
}
//______________________________________________________________________
void AliITS::GetTreeC(Int_t event){
} // end if fTreeC
sprintf(treeName,"TreeC%d",event);
- fTreeC = (TTree*)gDirectory->Get(treeName);
+ TFile *fileRecPoints = gAlice->GetTreeRFile();
+ if(!fileRecPoints){
+ fTreeC = (TTree*)gDirectory->Get(treeName);
+ }
+ else {
+ fTreeC = (TTree*)fileRecPoints->Get(treeName);
+ }
TBranch *branch;
if (fNctype) fNctype[i]=0;
}
//______________________________________________________________________
-void AliITS::MakeBranchR(const char *file){
+void AliITS::MakeBranchR(const char *file, Option_t *opt){
// Creates Tree branches for the ITS Reconstructed points.
// Inputs:
// cont char *file File name where RecPoints branch is to be written
char branchname[30];
// only one branch for rec points for all detector types
- sprintf(branchname,"%sRecPoints",GetName());
+ Bool_t oFast= (strstr(opt,"Fast")!=0);
+ if(oFast){
+ sprintf(branchname,"%sRecPointsF",GetName());
+ } else {
+ sprintf(branchname,"%sRecPoints",GetName());
+ }
if (fRecPoints && gAlice->TreeR()) {
MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
} // end if
TBranch *branch;
sprintf(branchname,"%sRecPoints",GetName());
branch = treeR->GetBranch(branchname);
- if (branch) branch->SetAddress(&fRecPoints);
+ if (branch) {
+ branch->SetAddress(&fRecPoints);
+ }
+ else {
+ sprintf(branchname,"%sRecPointsF",GetName());
+ branch = treeR->GetBranch(branchname);
+ if (branch) {
+ branch->SetAddress(&fRecPoints);
+ }
+ }
}
//______________________________________________________________________
void AliITS::AddRecPoint(const AliITSRecPoint &r){
} // end if !sim
mod = (AliITSmodule *)fITSmodules->At(module);
sim->CreateFastRecPoints(mod,module,gRandom);
- gAlice->TreeR()->Fill();
+ // gAlice->TreeR()->Fill();
+ TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
+ br->Fill();
ResetRecPoints();
} // end for module
ClearModules();
- char hname[30];
- sprintf(hname,"TreeR%d",evNumber);
- gAlice->TreeR()->Write(hname,TObject::kOverwrite);
+ gAlice->TreeR()->AutoSave();
// reset tree
gAlice->TreeR()->Reset();
}
setRec=kFALSE;
TTree *treeC=TreeC();
-
AliITSClusterFinder *rec = 0;
AliITSDetType *iDetType = 0;
Int_t id,module,first=0;
else gAlice->TreeD()->GetEvent(lastentry+(module-first));
Int_t ndigits = itsDigits->GetEntriesFast();
if (ndigits) rec->FindRawClusters(module);
- gAlice->TreeR()->Fill();
+ gAlice->TreeR()->Fill();
ResetRecPoints();
treeC->Fill();
ResetClusters();
gAlice->TreeR()->GetEntries();
treeC->GetEntries();
-
- char hname[30];
- sprintf(hname,"TreeR%d",evNumber);
- gAlice->TreeR()->Write(hname,TObject::kOverwrite);
+ gAlice->TreeR()->AutoSave();
// reset tree
gAlice->TreeR()->Reset();
- sprintf(hname,"TreeC%d",evNumber);
- treeC->Write(hname,TObject::kOverwrite);
+ treeC->AutoSave();
treeC->Reset();
}
//______________________________________________________________________