/*
$Log$
+Revision 1.3 2002/03/25 10:48:55 nilsen
+New ITS SDigit merging with region of interest cut. Update for changes in
+AliDigitizer. Additional optimization should be done.
+
Revision 1.2 2002/03/15 17:26:40 nilsen
New SDigit version of ITS Digitizer.
#include <AliRunDigitizer.h>
#include "AliITSDigitizer.h"
-#include "AliITShit.h"
+#include "AliITSpList.h"
#include "AliITSmodule.h"
#include "AliITSsimulation.h"
#include "AliITSDetType.h"
// Return:
// A blank AliITSDigitizer class.
- fITS = 0;
- fActive = 0;
- fRoif = -1;
+ fITS = 0;
+ fActive = 0;
+ fRoif = -1;
fRoiifile = 0;
+ fInit = kFALSE;
}
//______________________________________________________________________
AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
// Return:
// An AliItSDigitizer class.
- if(!gAlice) {
- fITS = 0;
- fActive = 0;
- fRoif = -1;
- fRoiifile = 0;
- return;
- } // end if
- fITS = (AliITS *)(gAlice->GetDetector("ITS"));
- if(!fITS){
- fActive = 0;
- fRoif = -1;
- fRoiifile = 0;
- return;
- } else if(fITS->GetITSgeom()){
- fActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
- fRoif = -1;
- fRoiifile = 0;
- } else{
- fActive = 0;
- fRoif = -1;
- fRoiifile = 0;
- return;
- } // end if
- // fActive needs to be set to a default all kTRUE value
- for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fActive[i] = kTRUE;
+ fITS = 0;
+ fActive = 0;
+ fRoif = -1;
+ fRoiifile = 0;
+ fInit = kFALSE;
}
//______________________________________________________________________
AliITSDigitizer::~AliITSDigitizer(){
if(fActive) delete[] fActive;
}
//______________________________________________________________________
-Bool_t AliITSDigitizer::Init(const char *filename){
- // Initialization
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
-
-// TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
-// if (file) {file->Close(); delete file;}
- TFile *file = new TFile(filename);
- if (!file->IsOpen()) {
- Error("Init","Can't open %s!",filename);
- return kFALSE;
- } // end if !file
- if (gAlice) delete gAlice;
- gAlice = (AliRun*)file->Get("gAlice");
- if (!gAlice) {
- Error("Init","AliRun object not found on file");
- return kFALSE;
- } // end if !gAlice
-
- this->Init();
- delete gAlice;
- gAlice=0;
- return kTRUE;
-}
-//______________________________________________________________________
Bool_t AliITSDigitizer::Init(){
- // Initialization
+ // Initialization. Set up region of interest, if switched on, and
+ // loads ITS and ITSgeom.
// Inputs:
// none.
// Outputs:
// none.
// Return:
-
// none.
-// TTree *ts;
+ fInit = kTRUE; // Assume for now init will work.
if(!gAlice) {
fITS = 0;
fActive = 0;
fRoif = -1;
fRoiifile = 0;
-// cout << "init !gAlice"<<endl;
- return kFALSE;
+ fInit = kFALSE;
+ Warning("Init","gAlice not found");
+ return fInit;
} // end if
fITS = (AliITS *)(gAlice->GetDetector("ITS"));
if(!fITS){
fActive = 0;
fRoif = -1;
fRoiifile = 0;
-// cout << "init !fITS"<<endl;
- return kFALSE;
+ fInit = kFALSE;
+ Warning("Init","ITS not found");
+ return fInit;
} else if(fITS->GetITSgeom()){
+ //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
fActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
} else{
- fActive = 0;
- fRoif = -1;
+ fActive = 0;
+ fRoif = -1;
fRoiifile = 0;
-// cout << "init !fITS-GetITSgeom()"<<endl;
- return kFALSE;
+ fInit = kFALSE;
+ Warning("Init","ITS geometry not found");
+ return fInit;
} // end if
// fActive needs to be set to a default all kTRUE value
for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fActive[i] = kTRUE;
-/*
+/* This will not work from Init. ts is aways returned as zero.
+ TTree *ts;
if(fRoif>=0 && fRoiifile>=0 && fRoiifile<GetManager()->GetNinputs()){
ts = GetManager()->GetInputTreeS(fRoiifile);
- cout << "calling SetByReionOfInterest"<<endl;
+ if(!ts){
+ if(!gAlice) ts = gAlice->TreeS();
+ if(!ts){
+ cout <<"The TTree TreeS needed to set by region not found."
+ " No region of interest cut will be applied."<< endl;
+ return fInit;
+ } // end if
+ } // end if
+ cout << "calling SetByReionOfInterest ts="<< ts <<endl;
SetByRegionOfInterest(ts);
} // end if
*/
- return kTRUE;
+ return fInit;
}
//______________________________________________________________________
void AliITSDigitizer::Exec(Option_t* opt){
AliITSDetType *iDetType = 0;
static Bool_t setDef = kTRUE;
- if(!fITS) fITS = (AliITS*)(gAlice->GetDetector("ITS"));
- if(!fITS){
- Error("Exec","The ITS not found. aborting.");
+ if(!fInit){
+ Error("Exec","Init not succesfull, aborting.");
return;
} // end if
- if( !(fITS->GetITSgeom()) ) {
- Warning( "Exec", "Need ITS geometry to be properly defined first." );
- return; // need transformations to do digitization.
- } // end if !GetITSgeom()
if( setDef ) fITS->SetDefaultSimulation();
setDef = kFALSE;
- sprintf( name, "%s", fITS->GetName() );
+ sprintf(name,"%s",fITS->GetName());
Int_t nfiles = GetManager()->GetNinputs();
Int_t event = GetManager()->GetOutputEventNr();
Int_t size = fITS->GetITSgeom()->GetIndexMax();
+ Int_t module,id,ifiles,mask;
+ Bool_t lmod;
+ Int_t *fl = new Int_t[nfiles];
+ fl[0] = fRoiifile;
+ mask = 1;
+ for(id=0;id<nfiles;id++) if(id!=fRoiifile){
+ // just in case fRoiifile!=0.
+ fl[mask] = id;
+ mask++;
+ } // end for,if
TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
- // Digitize
- fITS->MakeBranchInTreeD( GetManager()->GetTreeD() );
- if(fRoif!=-1)SetByRegionOfInterest(GetManager()->GetInputTreeS(fRoiifile));
+ // Digitize
+ fITS->MakeBranchInTreeD(GetManager()->GetTreeD());
- for( Int_t module=0; module<size; module++ ){
- if(fActive && fRoif!=-1) if(!fActive[module]) continue;
- Int_t id = fITS->GetITSgeom()->GetModuleType( module );
- if( !all && !det[id] ) continue;
+ for(module=0; module<size; module++ ){
+ if(fActive && fRoif!=0) if(!fActive[module]) continue;
+ id = fITS->GetITSgeom()->GetModuleType(module);
+ if(!all && !det[id]) continue;
iDetType = fITS->DetType( id );
sim = (AliITSsimulation*)iDetType->GetSimulationModel();
if(!sim) {
} // end if !sim
// Fill the module with the sum of SDigits
- sim->InitSimulationModule( module, event );
-// cout << "Module=" << module;
- for( Int_t ifiles=0; ifiles<nfiles; ifiles++ ){
-// cout <<" ifiles=" << ifiles;
- TTree *treeS = GetManager()->GetInputTreeS(ifiles);
+ sim->InitSimulationModule(module, event);
+ //cout << "Module=" << module;
+ for(ifiles=0; ifiles<nfiles; ifiles++ ){
+ if(fActive && fRoif!=0) if(!fActive[module]) continue;
+ //cout <<" fl[ifiles=" << ifiles << "]=" << fl[ifiles];
+ TTree *treeS = GetManager()->GetInputTreeS(fl[ifiles]);
if( !(treeS && fITS->GetSDigits()) ) continue;
TBranch *brchSDigits = treeS->GetBranch( name );
if( brchSDigits ) {
} else {
Error( "Exec", "branch ITS not found in TreeS, input file %d ",
ifiles );
+ return;
} // end if brchSDigits
sdig->Clear();
- Int_t mask = GetManager()->GetMask( ifiles );
-
+ mask = GetManager()->GetMask(ifiles);
// add summable digits to module
brchSDigits->GetEvent( module );
- sim->AddSDigitsToModule( sdig, mask );
+ lmod = sim->AddSDigitsToModule(sdig,mask);
+ if(ifiles==0){
+ fActive[module] = lmod;
+ } // end if
+ //cout << " fActive["<<module<<"]=";
+ //if(fActive[module]) cout << "kTRUE";
+ //else cout << "kFALSE";
} // end for ifiles
-// cout << " end ifiles loop" << endl;
+ //cout << " end ifiles loop" << endl;
// Digitize current module sum(SDigits)->Digits
sim->FinishSDigitiseModule();
GetManager()->GetTreeD()->Fill();
fITS->ResetDigits();
} // end for module
-// cout << "end modules loop"<<endl;
-
- GetManager()->GetTreeD()->GetEntries();
- GetManager()->GetTreeD()->Write( 0, TObject::kOverwrite );
- // reset tree
- GetManager()->GetTreeD()->Reset();
-
+ //cout << "end modules loop"<<endl;
+
+ GetManager()->GetTreeD()->AutoSave();
+
+ delete[] fl;
sdig->Clear();
delete sdig;
+ for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fActive[i] = kTRUE;
+ return;
}
//______________________________________________________________________
void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
// none.
// Return:
// none.
- Int_t m,nm;
- if(gAlice==0 && ts==0) return;
- if(ts==0) ts = gAlice->TreeS();
+ Int_t m,nm,i;
+
+ if(fRoif==0) return;
+ if(ts==0) return;
TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
-// cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
+ //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
if( brchSDigits ) {
- brchSDigits->SetAddress( &sdig );
+ brchSDigits->SetAddress( &sdig );
} else {
Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
return;
nm = fITS->GetITSgeom()->GetIndexMax();
for(m=0;m<nm;m++){
-// cout << " fActive["<<m<<"]=";
+ //cout << " fActive["<<m<<"]=";
fActive[m] = kFALSE; // Not active by default
sdig->Clear();
brchSDigits->GetEvent(m);
- if(sdig->GetLast()>=0){ // activate the necessary modules
- if(fRoif>=0){
+ if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
+ // activate the necessary modules
+ if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
fActive[m] = kTRUE;
-// cout << "kTRUE";
+ break;
} // end if
- } // end if.
-// cout << endl;
+ } // end if. end for i.
+ //cout << fActive[m];
+ //cout << endl;
} // end for m
sdig->Clear();
delete sdig;
+ return;
}
*/
class TObjArray;
+class TTree;
#include <TClonesArray.h> // function of this class used in inline functions.
#include "AliDigitizer.h" // Base class from which this one is derived
#include "AliITS.h" // ITS class functions used in inline functions.
-class AliITShit;
class AliITSmodule;
class AliITSDigitizer : public AliDigitizer{
virtual ~AliITSDigitizer();
// Standard routines.
virtual Bool_t Init();
- virtual Bool_t Init(const char *filename);
+ // Perform SDigits to Digits, with or without merging, depending on the
+ // number of files.
virtual void Exec(Option_t* opt=0);
// Sets a particular module active
virtual void SetModuleActive(Int_t i){if(fActive) fActive[i] = kTRUE;}
// Sets a particular module inactive
virtual void SetModuleInActive(Int_t i){if(fActive) fActive[i] = kFALSE;}
- virtual void SetByRegionOfInterest(Int_t i=0){fRoif = i;};
- virtual void SetByRegionOfFileNumber(Int_t i=0){fRoiifile = i;};
- virtual void ClearByRegionOfInterest(){fRoif = -1;};
+ // Sets Region of Interst Flag. if fRiof=0 then no Region of Interest
+ // cut applyed
+ virtual void SetByRegionOfInterestFlag(Int_t i=0){fRoif = i;};
+ // Sets the SDigits file number to be used to define the region of
+ // interest. Default is file=-1, assumed that a region of interest
+ // cut will be applied. A value of 0 means no cut to be applyed. Other
+ // values have yet to be defined.
+ virtual void SetByRegionOfFileNumber(Int_t i=-1){fRoiifile = i;};
+ // Clears the region of interest flag. Calling this implies that a
+ // Region of interest cut will not be made.
+ virtual void ClearByRegionOfInterestFlag(){fRoif = 0;};
private:
// Routines used internaly
- TClonesArray* GetHits(){return fITS->Hits();}
- AliITShit* GetHit(Int_t h){return (AliITShit*)(GetHits()->UncheckedAt(h));}
+ // Returns a pointer to the TObjecArray of Modules.
TObjArray* GetModules(){return fITS->GetModules();}
+ // Returns a pointer to a specific module.
AliITSmodule* GetModule(Int_t i){return fITS->GetModule(i);}
+ // Returns a pointer to the manager
AliRunDigitizer* GetManager(){return fManager;}
+ // Sets the region of Interest based on which module have SDigits
+ // Defined (non-noise SDigits).
virtual void SetByRegionOfInterest(TTree *ts);
private:
- AliITS *fITS; //! local pointer to ITS
- Bool_t *fActive; //! flag to indicate which module to digitize.
- Int_t fRoif; //! Region of interest flag.
+ AliITS *fITS; //! local pointer to ITS
+ Bool_t *fActive; //! flag to indicate which module to digitize.
+ Bool_t fInit; //! flag to indecate Initilization when well.
+ Int_t fRoif; //! Region of interest flag.
Int_t fRoiifile; //! The file number with which to determing the region
// of interest from.
--- /dev/null
+////////////////////////////////////////////////////////////////////////
+//
+// name: MergeV1
+// date: 11.4.2002
+// last update: 11.4.2002
+// author: Jiri Chudoba
+// version: 1.0
+//
+// description:
+// creates digits from sdigits for several detectors
+// stores sdigits in separate file (or in the source file
+// with sdigits). Stores gAlice object and copies TE to the
+// file with digits
+// ITS region of Interest is set
+// test
+//
+// input:
+// TString fileNameSDigits ... input file with sdigits
+// TString fileNameDigits ... output file with digits
+// Int_t nEvents ... how many events to process
+// Int_t ITS, TPC, ... many flags for diff. detectors
+//
+// History:
+//
+// 04.04.02 - first version
+//
+////////////////////////////////////////////////////////////////////////
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "iostream.h"
+#include "TDatetime.h"
+#include "STEER/AliRun.h"
+#include "STEER/AliRunDigitizer.h"
+#include "ITS/AliITSDigitizer.h"
+#include "ITS/AliITS.h"
+#include "ITS/AliITSDetType.h"
+#include "ITS/AliITSresponseSDD.h"
+#include "TPC/AliTPCDigitizer.h"
+#include "TRD/AliTRDdigitizer.h"
+#include "PHOS/AliPHOSDigitizer.h"
+#include "MUON/AliMUONDigitizer.h"
+#include "RICH/AliRICHDigitizer.h"
+#include "TStopwatch.h"
+#endif
+
+// #include "AliHits2SDigits.C"
+
+// void AliCopyN(TString inputFile, TString outputFile);
+
+Int_t MergeV1(TString fileNameDigits="digits.root",
+ TString fileNameSDigitsSig="sig.sdigits.root",
+ TString fileNameSDigitsBgr="bgr.sdigits.root",
+ Int_t nEvents = 1, Int_t iITS = 2, Int_t iTPC = 0,
+ Int_t iTRD = 0, Int_t iPHOS = 0, Int_t iMUON = 0,
+ Int_t iRICH = 0, Int_t iCopy = 1)
+{
+// delete the current gAlice object, the one from input file
+// will be used
+
+ if(gAlice){
+ delete gAlice;
+ gAlice = 0;
+ } // end if gAlice
+
+ // Connect the Root Galice file containing Geometry, Kine and Hits
+ TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fileNameSDigitsSig.Data());
+ if(!file) file = new TFile(fileNameSDigitsSig.Data());
+ TDatime *ct0 = new TDatime(2002,04,26,00,00,00), ct = file->GetCreationDate();
+
+
+ // Get AliRun object from file or create it if not on file
+ if(!gAlice) {
+ gAlice = (AliRun*)file->Get("gAlice");
+ if(gAlice) printf("AliRun object found on file\n");
+ if(!gAlice) gAlice = new AliRun("gAlice","Alice test program");
+ } // end if !gAlice
+
+ AliRunDigitizer * manager = new AliRunDigitizer(2,1);
+ manager->SetInputStream(0,fileNameSDigitsSig.Data());
+ manager->SetInputStream(1,fileNameSDigitsBgr.Data());
+ if (fileNameDigits != "") {
+// if (iCopy) {
+// AliCopyN(fileNameSDigitsSig,fileNameDigits);
+// }
+ manager->SetOutputFile(fileNameDigits);
+ }
+ manager->SetNrOfEventsToWrite(nEvents);
+
+ if (iITS) {
+ AliITSDigitizer *dITS = new AliITSDigitizer(manager);
+ if (iITS == 2) dITS->SetByRegionOfInterestFlag(1);
+ if(ct0->GetDate()>ct.GetDate()){
+ // For old files, must change SDD noise.
+ AliITS *ITS = (AliITS*) gAlice->GetDetector("ITS");
+ AliITSresponseSDD *resp1 = ITS->DetType(1)->GetResponseModel();
+ resp1->SetNoiseParam();
+ resp1->SetNoiseAfterElectronics();
+ Float_t n,b;
+ Int_t cPar[8];
+ resp1->GetNoiseParam(n,b);
+ n = resp1->GetNoiseAfterElectronics();
+ cPar[0]=0;
+ cPar[1]=0;
+ cPar[2]=(Int_t)(b + 2.*n + 0.5);
+ cPar[3]=(Int_t)(b + 2.*n + 0.5);
+ cPar[4]=0;
+ cPar[5]=0;
+ cPar[6]=0;
+ cPar[7]=0;
+ resp1->SetCompressParam(cPar);
+ } // end if
+ }
+ if (iTPC) AliTPCDigitizer *dTPC = new AliTPCDigitizer(manager);
+ if (iTRD) AliTRDdigitizer *dTRD = new AliTRDdigitizer(manager);
+ if (iPHOS) AliPHOSDigitizer *dPHOS = new AliPHOSDigitizer(manager);
+ if (iMUON) AliMUONDigitizer *dMUON = new AliMUONDigitizer(manager);
+ if (iRICH) AliRICHDigitizer *dRICH = new AliRICHDigitizer(manager);
+ TStopwatch timer;
+ timer.Start();
+ manager->Exec("deb all");
+ timer.Stop();
+ timer.Print();
+// delete gAlice;
+// gAlice = 0;
+ delete manager;
+}
+
+
+/*
+////////////////////////////////////////////////////////////////////////
+void AliCopyN(TString inputFileName, TString outputFileName) {
+// copy some objects
+
+ TFile *inputFile = OpenFile(inputFileName);
+ if (!inputFile) return;
+
+ TFile *outputFile = TFile::Open(outputFileName.Data(),"update");
+ if (!outputFile->IsOpen()) {
+ cerr<<"Can't open "<<outputFileName.Data()<<" !\n";
+ return;
+ }
+ if (!ImportgAlice(inputFile)) return;
+ AliCopy(inputFile, outputFile);
+ delete gAlice;
+ gAlice=0;
+ inputFile->Close();
+ delete inputFile;
+ outputFile->Close();
+ delete outputFile;
+}
+////////////////////////////////////////////////////////////////////////
+*/