/*
$Log$
+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.
+
+Revision 1.65 2001/11/27 16:27:28 nilsen
+Adding AliITSDigitizer class to do merging and digitization . Based on the
+TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
+file. The following files required minor changes. AliITS, added functions
+SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
+AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
+the original Root Directory in function Compress1D. Now it uses gDirectory.
+
+Revision 1.64 2001/11/19 16:17:02 nilsen
+Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
+bugs found by Rene require more work to fix. Will be fixed soon.
+
Revision 1.63 2001/10/24 21:16:34 nilsen
Removed some dead code and improved comments/documntation.
#include <TString.h>
#include "AliMC.h"
-#include "AliRun.h"
#include "AliHeader.h"
#include "AliITS.h"
fEuclidOut = 0;
fITSgeom = 0;
fITSmodules = 0;
- SetDetectors(); // default to fOpt="All". This variable not written out.
+ fOpt = "All";
+// SetDetectors(); // default to fOpt="All". This variable not written out.
fIdN = 0;
fIdName = 0;
// SDD
iDetType=DetType(1);
if (!iDetType->GetResponseModel()) {
- SetResponseModel(1,new AliITSresponseSDD());
+ SetResponseModel(1,new AliITSresponseSDD("simulated"));
} // end if
AliITSresponse *resp1=iDetType->GetResponseModel();
if (!iDetType->GetSegmentationModel()) {
SetSegmentationModel(2,seg2);
} // end if
if (!iDetType->GetResponseModel()) {
- SetResponseModel(2,new AliITSresponseSSD());
+ SetResponseModel(2,new AliITSresponseSSD("simulated"));
} // end if
const char *kData2=(iDetType->GetResponseModel())->DataType();
if (strstr(kData2,"real")) {
// 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(){
if (branch) branch->SetAddress(&fSDigits);
}
//______________________________________________________________________
-void AliITS::MakeBranchD(const char *file){
+void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
// Creates Tree branches for the ITS.
// Inputs:
+ // TTree *treeD Pointer to the Digits Tree.
// cont char *file File name where Digits branch is to be written
// to. If blank it write the SDigits to the same
// file in which the Hits were found.
for (i=0; i<kNTYPES ;i++) {
if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
else sprintf(branchname,"%sDigits%d",GetName(),i+1);
- if (fDtype && gAlice->TreeD()) {
- MakeBranchInTree(gAlice->TreeD(),
+ if (fDtype && treeD) {
+ MakeBranchInTree(treeD,
branchname, &((*fDtype)[i]),buffersize,file);
} // end if
} // end for i
// Outputs:
// none.
- return; // Using Hits in place of the larger sDigits.
+// return; // Using Hits in place of the larger sDigits.
AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
// Do the Hits to Digits operation. Use Standard input values.
// Event number from file, no background hit merging , use size from
HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
}
//______________________________________________________________________
-void AliITS::SDigits2Digits(){
+void AliITS::SDigitsToDigits(Option_t *opt){
// Standard Summable digits to Digits function.
// Inputs:
// none.
// Outputs:
// none.
+ char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+
+ if(!GetITSgeom()) return; // need transformations to do digitization.
+ AliITSgeom *geom = GetITSgeom();
+
+ const char *all = strstr(opt,"All");
+ const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
+ strstr(opt,"SSD")};
+ if( !det[0] && !det[1] && !det[2] ) all = "All";
+ else all = 0;
+ static Bool_t setDef=kTRUE;
+ if (setDef) SetDefaultSimulation();
+ setDef=kFALSE;
+
+ AliITSsimulation *sim = 0;
+ AliITSDetType *iDetType = 0;
+ TTree *trees = gAlice->TreeS();
+ if( !(trees && this->GetSDigits()) ){
+ Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
+ return;
+ } // end if
+ sprintf( name, "%s", this->GetName() );
+ TBranch *brchSDigits = trees->GetBranch( name );
+
+ Int_t id,module;
+ for(module=0;module<geom->GetIndexMax();module++){
+ id = geom->GetModuleType(module);
+ if (!all && !det[id]) continue;
+ iDetType = DetType(id);
+ sim = (AliITSsimulation*)iDetType->GetSimulationModel();
+ if (!sim) {
+ Error("SDigit2Digits",
+ "The simulation class was not instanciated!");
+ exit(1);
+ } // end if !sim
+ sim->InitSimulationModule(module,gAlice->GetEvNumber());
+//
+ // add summable digits to module
+ this->GetSDigits()->Clear();
+ brchSDigits->GetEvent(module);
+ sim->AddSDigitsToModule(GetSDigits(),0);
+//
+ // Digitise current module sum(SDigits)->Digits
+ sim->FinishSDigitiseModule();
+
+ // fills all branches - wasted disk space
+ gAlice->TreeD()->Fill();
+ this->ResetDigits();
+ } // end for module
+
+ gAlice->TreeD()->GetEntries();
- Hits2Digits();
+ gAlice->TreeD()->AutoSave();
+ // reset tree
+ gAlice->TreeD()->Reset();
+
}
//______________________________________________________________________
void AliITS::Hits2Digits(){
// none.
// Return:
// none.
- return; // using Hits instead of the larger sdigits.
+// return; // using Hits instead of the larger sdigits.
+
+ HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
}
//______________________________________________________________________
void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
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();
}
// 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");
else return;
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();
}
//______________________________________________________________________