From: nilsen Date: Wed, 24 Apr 2002 22:08:12 +0000 (+0000) Subject: New ITS Digitizer/merger with two macros. One to make SDigits (old way) and X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=fd04285ae10e33db0095ebbd8200b98444d18e63;hp=d4a640990ffbc2b2056a1be0dad94a86465f089c New ITS Digitizer/merger with two macros. One to make SDigits (old way) and one to run the merger (modified for Jiri). --- diff --git a/ITS/AliITSDigitizer.cxx b/ITS/AliITSDigitizer.cxx index 1733fd43dca..257a297a43a 100644 --- a/ITS/AliITSDigitizer.cxx +++ b/ITS/AliITSDigitizer.cxx @@ -15,6 +15,10 @@ /* $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. @@ -42,7 +46,7 @@ The SDigits are reading as TClonesArray of AliITSpListItem #include #include "AliITSDigitizer.h" -#include "AliITShit.h" +#include "AliITSpList.h" #include "AliITSmodule.h" #include "AliITSsimulation.h" #include "AliITSDetType.h" @@ -61,10 +65,11 @@ AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){ // 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){ @@ -77,31 +82,11 @@ 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;iGetITSgeom()->GetIndexMax();i++) fActive[i] = kTRUE; + fITS = 0; + fActive = 0; + fRoif = -1; + fRoiifile = 0; + fInit = kFALSE; } //______________________________________________________________________ AliITSDigitizer::~AliITSDigitizer(){ @@ -117,80 +102,64 @@ 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"<GetDetector("ITS")); if(!fITS){ fActive = 0; fRoif = -1; fRoiifile = 0; -// cout << "init !fITS"<GetITSgeom()){ + //cout << "fRoif,fRoiifile="<GetITSgeom()->GetIndexMax()]; } else{ - fActive = 0; - fRoif = -1; + fActive = 0; + fRoif = -1; fRoiifile = 0; -// cout << "init !fITS-GetITSgeom()"<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 && fRoiifileGetNinputs()){ ts = GetManager()->GetInputTreeS(fRoiifile); - cout << "calling SetByReionOfInterest"<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 <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;idMakeBranchInTreeD( GetManager()->GetTreeD() ); - if(fRoif!=-1)SetByRegionOfInterest(GetManager()->GetInputTreeS(fRoiifile)); + // Digitize + fITS->MakeBranchInTreeD(GetManager()->GetTreeD()); - for( Int_t module=0; moduleGetITSgeom()->GetModuleType( module ); - if( !all && !det[id] ) continue; + for(module=0; moduleGetITSgeom()->GetModuleType(module); + if(!all && !det[id]) continue; iDetType = fITS->DetType( id ); sim = (AliITSsimulation*)iDetType->GetSimulationModel(); if(!sim) { @@ -247,11 +220,12 @@ void AliITSDigitizer::Exec(Option_t* opt){ } // end if !sim // Fill the module with the sum of SDigits - sim->InitSimulationModule( module, event ); -// cout << "Module=" << module; - for( Int_t ifiles=0; ifilesClear(); - 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["<Digits sim->FinishSDigitiseModule(); @@ -275,15 +255,15 @@ void AliITSDigitizer::Exec(Option_t* opt){ GetManager()->GetTreeD()->Fill(); fITS->ResetDigits(); } // end for module -// cout << "end modules loop"<GetTreeD()->GetEntries(); - GetManager()->GetTreeD()->Write( 0, TObject::kOverwrite ); - // reset tree - GetManager()->GetTreeD()->Reset(); - + //cout << "end modules loop"<GetTreeD()->AutoSave(); + + delete[] fl; sdig->Clear(); delete sdig; + for(Int_t i=0;iGetITSgeom()->GetIndexMax();i++) fActive[i] = kTRUE; + return; } //______________________________________________________________________ void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){ @@ -301,15 +281,16 @@ 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="<GetITSgeom()->GetIndexMax(); for(m=0;mClear(); delete sdig; + return; } diff --git a/ITS/AliITSDigitizer.h b/ITS/AliITSDigitizer.h index 466f485bc9c..03ecfba9c3b 100644 --- a/ITS/AliITSDigitizer.h +++ b/ITS/AliITSDigitizer.h @@ -8,6 +8,7 @@ */ class TObjArray; +class TTree; #include // function of this class used in inline functions. @@ -15,7 +16,6 @@ class AliRunDigitizer; #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{ @@ -25,27 +25,40 @@ 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. diff --git a/ITS/MergeV1.C b/ITS/MergeV1.C new file mode 100644 index 00000000000..6c1f80e4eeb --- /dev/null +++ b/ITS/MergeV1.C @@ -0,0 +1,152 @@ +//////////////////////////////////////////////////////////////////////// +// +// 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 "<Close(); + delete inputFile; + outputFile->Close(); + delete outputFile; +} +//////////////////////////////////////////////////////////////////////// +*/