X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSHits2Digits.C;h=e44595cddcad7fb741d962fc8826c10b5a1d9a66;hb=0f6198f24b064d9dbdcfc400eb8cc06000ea615b;hp=ccb6b675a9e4006b3217455df2cf3df67f038523;hpb=c1bfc82cdd9c828252e05894ed8bd93f17ba9760;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSHits2Digits.C b/ITS/AliITSHits2Digits.C index ccb6b675a9e..e44595cddca 100644 --- a/ITS/AliITSHits2Digits.C +++ b/ITS/AliITSHits2Digits.C @@ -1,122 +1,102 @@ -Int_t AliITSHits2Digits(const char *inFile = "galice.root"){ +#if !defined(__CINT__) || defined(__MAKECINT__) - // Dynamically link some shared libs - if (gClassTable->GetID("AliRun") < 0) { - gROOT->LoadMacro("loadlibs.C"); - loadlibs(); - } // end if +#include "Riostream.h" +#include "TDatime.h" +#include "TClassTable.h" +#include "AliRun.h" +#include "AliRunDigitizer.h" +#include "AliITSDigitizer.h" +#include "AliITS.h" +#include "AliITSDetType.h" +#include "AliITSLoader.h" +#include "AliITSresponseSDD.h" +#include "TStopwatch.h" - // Connect the Root Galice file containing Geometry, Kine and Hits - - TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile); - if (file) {file->Close(); delete file;} - cout << "AliITSHits2Digits" << endl; - file = new TFile(inFile,"UPDATE"); - if (!file->IsOpen()) { - cerr<<"Can't open "<ls(); +#endif - // Get AliRun object from file or return if not on file - if (gAlice) delete gAlice; - gAlice = (AliRun*)file->Get("gAlice"); - if (!gAlice) { - cerr << "AliITSITSHits2Digits.C : AliRun object not found on file" - << endl; - return 2; - } // end if !gAlice +//#define DEBUG +Int_t AliITSHits2Digits(TString inFile = "galice.root"){ + // Standard ITS Hits to Digits, excluding creation of SDigits. + // Dynamically link some shared libs + if (gClassTable->GetID("AliRun") < 0) { + gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C"); + }else if (gAlice){ + delete gAlice->GetRunLoader(); + delete gAlice; + gAlice=0; + } + + AliRunLoader* rl = AliRunLoader::Open(inFile.Data()); + if (rl == 0x0) + { + cerr<<"AliITSHits2Digits.C : Can not open session RL=NULL" + << endl; + return 3; + } + + Int_t retval = rl->LoadgAlice(); + if (retval) + { + cerr<<"AliITSHits2Digits.C : LoadgAlice returned error" + << endl; + return 3; + } + gAlice=rl->GetAliRun(); + AliITSLoader* gime = (AliITSLoader*)rl->GetLoader("ITSLoader"); + if (gime == 0x0) + { + cerr<<"AliITSHits2Digits.C : can not get ITS loader" + << endl; + } AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); if (!ITS) { - cerr<<"AliITSHits2Digits.C : AliITS object not found on file" + cerr<<"AliITSHits2Digit.C : AliITS object not found on file" << endl; return 3; } // end if !ITS - // Set the simulation models for the three detector types - AliITSgeom *geom = ITS->GetITSgeom(); - - // SPD - cout << "Changing from Default SPD simulation, and responce." << endl; - AliITSDetType *iDetType=ITS->DetType(0); - AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType-> - GetSegmentationModel(); - AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel(); - AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0); - ITS->SetSimulationModel(0,sim0); - // test - cout << "SPD dimensions " << seg0->Dx() << " " << seg0->Dz() << endl; - cout << "SPD npixels " << seg0->Npz() << " " << seg0->Npx() << endl; - cout << "SPD pitches " << seg0->Dpz(0) << " " << seg0->Dpx(0) << endl; - // end test - - // SDD - cout << "Changing from Default SDD simulation, and responce." << endl; - //Set response functions - Float_t baseline = 10.; - Float_t noise = 1.75; - // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, - // 2 fTolerance - AliITSDetType *iDetType=ITS->DetType(1); - AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel(); - if (!res1) { - res1=new AliITSresponseSDD(); - ITS->SetResponseModel(1,res1); - } // end if !res1 - Float_t fCutAmp = baseline + 2.*noise; - Int_t cp[8]={0,0,fCutAmp,fCutAmp,0,0,0,0}; //1D - - //res1->SetZeroSupp("2D"); - res1->SetZeroSupp("1D"); - res1->SetNoiseParam(noise,baseline); - res1->SetDo10to8(kTRUE); - res1->SetCompressParam(cp); - res1->SetMinVal(4); - res1->SetDiffCoeff(3.6,40.); - AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType-> - GetSegmentationModel(); - if (!seg1) { - seg1 = new AliITSsegmentationSDD(geom,res1); - ITS->SetSegmentationModel(1,seg1); - } // end if !seg1 - AliITSsimulationSDD *sim1 = new AliITSsimulationSDD(seg1,res1); - sim1->SetDoFFT(1); - sim1->SetCheckNoise(kFALSE); - ITS->SetSimulationModel(1,sim1); - - // SSD - cout << "Changing from Default SSD simulation, and responce." << endl; - AliITSDetType *iDetType = ITS->DetType(2); - AliITSsegmentationSSD *seg2 = (AliITSsegmentationSSD*)iDetType-> - GetSegmentationModel(); - AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel(); - res2->SetSigmaSpread(3.,2.); - AliITSsimulationSSD *sim2 = new AliITSsimulationSSD(seg2,res2); - ITS->SetSimulationModel(2,sim2); + if(!(ITS->GetITSgeom())){ + cerr << " AliITSgeom not found. Can't digitize without it." << endl; + return 4; + } // end if - if(!gAlice->TreeD()){ - cout << "Having to create the Digits Tree." << endl; - gAlice->MakeTree("D"); - } // end if !gAlice->TreeD() - //make branch - ITS->MakeBranch("D"); - ITS->SetTreeAddress(); - gAlice->GetEvent(0); - cout << "Digitizing ITS..." << endl; + TStopwatch timer; - Long_t size0 = file->GetSize(); + Int_t evNumber1 = 0; + Int_t evNumber2 = gAlice->GetEventsPerRun(); timer.Start(); - ITS->Hits2Digits(); - timer.Stop(); timer.Print(); + retval = gime->LoadHits(); + if (retval) + { + cerr<<"AliITSHits2Digits.C : ITSLoader::LoadHits returned error" + << endl; + return 3; + } - delete gAlice; gAlice=0; - file->Close(); - Long_t size1 = file->GetSize(); - cout << "File size before = " << size0 << " file size after = " << size1; - cout << "Increase in file size is " << size1-size0 << " Bytes" << endl; - delete file; - return 0; -}; + retval = gime->LoadDigits("recreate"); + if (retval) + { + cerr<<"AliITSHits2Digits.C : ITSLoader::LoadDigits returned error" + << endl; + return 3; + } + for(Int_t nevent = evNumber1; nevent < evNumber2; nevent++){ + // cout<<"Producing Digits for event n."<GetEvent(nevent); + if(!gime->TreeD()){ + cout << "Having to create the Digits Tree." << endl; + gime->MakeTree("D"); + } // end if creating digits tree + ITS->MakeBranch("D"); + ITS->SetTreeAddress(); + ITS->Hits2Digits(); + } // end for nevent + timer.Stop(); + timer.Print(); + delete rl; + return 0; +}