X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FAliTOFSDigitizer.cxx;h=9e662e0d924363eda81ebaca235a4a7dc3fb221c;hb=7e8c2e88595eba4245b6763891b1193deb0c8392;hp=1ffbe7f4bbfec5e97758df4322ad5baf51b71286;hpb=845fe446cb1a40a86ce2c49be4e962b5aa712a65;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/AliTOFSDigitizer.cxx b/TOF/AliTOFSDigitizer.cxx index 1ffbe7f4bbf..9e662e0d924 100644 --- a/TOF/AliTOFSDigitizer.cxx +++ b/TOF/AliTOFSDigitizer.cxx @@ -15,69 +15,188 @@ /* $Id$ */ -//_________________________________________________________________________ -// This is a TTask that constructs SDigits out of Hits -// A Summable Digits is the "sum" of all hits in a pad -// Detector response has been simulated via the method -// SimulateDetectorResponse -// -//-- Authors: F. Pierella, A. De Caro -// Use case: see AliTOFhits2sdigits.C macro in the CVS -////////////////////////////////////////////////////////////////////////////// - -#include -#include +//__________________________________________________________// +// // +// This is a TTask that constructs SDigits out of Hits // +// A Summable Digits is the "sum" of all hits in a pad // +// Detector response has been simulated via the method // +// SimulateDetectorResponse // +// // +// -- Authors: F. Pierella, A. De Caro // +// Use case: see AliTOFhits2sdigits.C macro in the CVS // +//__________________________________________________________// #include +#include #include #include -#include -#include #include -#include -#include -#include #include +#include +#include -#include "AliLog.h" -#include "AliDetector.h" #include "AliLoader.h" -#include "AliRun.h" +#include "AliLog.h" +#include "AliMC.h" #include "AliRunLoader.h" -#include "AliTOF.h" +#include "AliRun.h" + #include "AliTOFGeometry.h" #include "AliTOFHitMap.h" -#include "AliTOFSDigit.h" -#include "AliTOFSDigitizer.h" -#include "AliTOFhit.h" #include "AliTOFhitT0.h" -#include "AliMC.h" +#include "AliTOFhit.h" +#include "AliTOFSDigitizer.h" +#include "AliTOFSDigit.h" +#include "AliTOF.h" + +extern TROOT *gROOT; ClassImp(AliTOFSDigitizer) //____________________________________________________________________________ - AliTOFSDigitizer::AliTOFSDigitizer():TTask("TOFSDigitizer","") +AliTOFSDigitizer::AliTOFSDigitizer(): + TTask("TOFSDigitizer",""), + fEvent1(-1), + fEvent2(-1), + ftail(0x0), + fHeadersFile(""), + fRunLoader(0x0), + fTOFLoader(0x0), + fSelectedSector(-1), + fSelectedPlate(-1), + fTimeResolution(0), + fpadefficiency(0), + fEdgeEffect(-1), + fEdgeTails(-1), + fHparameter(0), + fH2parameter(0), + fKparameter(0), + fK2parameter(0), + fEffCenter(0), + fEffBoundary(0), + fEff2Boundary(0), + fEff3Boundary(0), + fAddTRes(0), + fResCenter(0), + fResBoundary(0), + fResSlope(0), + fTimeWalkCenter(0), + fTimeWalkBoundary(0), + fTimeWalkSlope(0), + fTimeDelayFlag(-1), + fPulseHeightSlope(0), + fTimeDelaySlope(0), + fMinimumCharge(0), + fChargeSmearing(0), + fLogChargeSmearing(0), + fTimeSmearing(0), + fAverageTimeFlag(-1), + fAdcBin(0), + fAdcMean(0), + fAdcRms(0) { // ctor +} - fRunLoader = 0; - fTOFLoader = 0; +//------------------------------------------------------------------------ +AliTOFSDigitizer::AliTOFSDigitizer(const AliTOFSDigitizer &source): + TTask(source), + fEvent1(-1), + fEvent2(-1), + ftail(0x0), + fHeadersFile(""), + fRunLoader(0x0), + fTOFLoader(0x0), + fSelectedSector(-1), + fSelectedPlate(-1), + fTimeResolution(0), + fpadefficiency(0), + fEdgeEffect(-1), + fEdgeTails(-1), + fHparameter(0), + fH2parameter(0), + fKparameter(0), + fK2parameter(0), + fEffCenter(0), + fEffBoundary(0), + fEff2Boundary(0), + fEff3Boundary(0), + fAddTRes(0), + fResCenter(0), + fResBoundary(0), + fResSlope(0), + fTimeWalkCenter(0), + fTimeWalkBoundary(0), + fTimeWalkSlope(0), + fTimeDelayFlag(-1), + fPulseHeightSlope(0), + fTimeDelaySlope(0), + fMinimumCharge(0), + fChargeSmearing(0), + fLogChargeSmearing(0), + fTimeSmearing(0), + fAverageTimeFlag(-1), + fAdcBin(0), + fAdcMean(0), + fAdcRms(0) +{ + // copy constructor + //this->fTOFGeometry=source.fTOFGeometry; - fEvent1 = 0; - fEvent2 = 0; - ftail = 0; - fSelectedSector = -1; - fSelectedPlate = -1; } //____________________________________________________________________________ -AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("TOFSDigitizer","") +AliTOFSDigitizer& AliTOFSDigitizer::operator=(const AliTOFSDigitizer &/*source*/) { - ftail = 0; - fSelectedSector=-1; // by default we sdigitize all sectors - fSelectedPlate =-1; // by default we sdigitize all plates in all sectors + // ass. op. + return *this; + +} + +//____________________________________________________________________________ +AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_t nEvents): + TTask("TOFSDigitizer",""), + fEvent1(-1), + fEvent2(-1), + ftail(0x0), + fHeadersFile(HeaderFile), // input filename (with hits) + fRunLoader(0x0), + fTOFLoader(0x0), + fSelectedSector(-1), // by default we sdigitize all sectors + fSelectedPlate(-1), // by default we sdigitize all plates in all sectors + fTimeResolution(0), + fpadefficiency(0), + fEdgeEffect(-1), + fEdgeTails(-1), + fHparameter(0), + fH2parameter(0), + fKparameter(0), + fK2parameter(0), + fEffCenter(0), + fEffBoundary(0), + fEff2Boundary(0), + fEff3Boundary(0), + fAddTRes(0), + fResCenter(0), + fResBoundary(0), + fResSlope(0), + fTimeWalkCenter(0), + fTimeWalkBoundary(0), + fTimeWalkSlope(0), + fTimeDelayFlag(-1), + fPulseHeightSlope(0), + fTimeDelaySlope(0), + fMinimumCharge(0), + fChargeSmearing(0), + fLogChargeSmearing(0), + fTimeSmearing(0), + fAverageTimeFlag(-1), + fAdcBin(0), + fAdcMean(0), + fAdcRms(0) +{ + //ctor, reading from input file - fHeadersFile = HeaderFile ; // input filename (with hits) TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data()); //File was not opened yet open file and get alirun object @@ -97,6 +216,24 @@ AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_ return; } + /* + fRunLoader->CdGAFile(); + TDirectory *savedir=gDirectory; + TFile *in=(TFile*)gFile; + + +// when fTOFGeometry was needed + if (!in->IsOpen()) { + AliWarning("Geometry file is not open default TOF geometry will be used"); + fTOFGeometry = new AliTOFGeometry(); + } + else { + in->cd(); + fTOFGeometry = (AliTOFGeometry*)in->Get("TOFgeometry"); + } + + savedir->cd(); + */ if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader(); if (evNumber1>=0) fEvent1 = evNumber1; @@ -130,6 +267,7 @@ AliTOFSDigitizer::~AliTOFSDigitizer() { // dtor fTOFLoader->CleanSDigitizer(); + } //____________________________________________________________________________ @@ -176,7 +314,7 @@ void AliTOFSDigitizer::InitParameters() } //__________________________________________________________________ -Double_t TimeWithTail(Double_t* x, Double_t* par) +Double_t TimeWithTail(const Double_t * const x, const Double_t * const par) { // sigma - par[0], alpha - par[1], part - par[2] // at xStart("TOFSDigitizer"); @@ -227,8 +364,8 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { fTOFLoader->LoadSDigits("recreate"); for (Int_t iEvent=fEvent1; iEventGetEvent(iEvent); @@ -262,6 +399,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { TClonesArray *tofHitArray = tof->Hits(); // create hit map + // AliTOFHitMap *hitMap = new AliTOFHitMap(tof->SDigits(), fTOFGeometry); AliTOFHitMap *hitMap = new AliTOFHitMap(tof->SDigits()); TBranch * tofHitsBranch = hitTree->GetBranch("TOF"); @@ -269,9 +407,12 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { Int_t ntracks = static_cast(hitTree->GetEntries()); for (Int_t track = 0; track < ntracks; track++) { - gAlice->ResetHits(); + gAlice->GetMCApp()->ResetHits(); tofHitsBranch->GetEvent(track); - particle = gAlice->GetMCApp()->Particle(track); + + AliMC *mcApplication = (AliMC*)gAlice->GetMCApp(); + + particle = mcApplication->Particle(track); Int_t nhits = tofHitArray->GetEntriesFast(); // cleaning all hits of the same track in the same pad volume // it is a rare event, however it happens @@ -285,7 +426,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { for (Int_t hit = 0; hit < nhits; hit++) { Int_t vol[5]; // location for a digit - Float_t digit[2]; // TOF digit variables + Int_t digit[2]; // TOF digit variables Int_t tracknum; Float_t dxPad; Float_t dzPad; @@ -293,7 +434,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { // fp: really sorry for this, it is a temporary trick to have // track length too - if(version!=6){ + if (version<6) { //(version!=6 && version!=7) AliTOFhit *tofHit = (AliTOFhit *) tofHitArray->UncheckedAt(hit); tracknum = tofHit->GetTrack(); vol[0] = tofHit->GetSector(); @@ -318,7 +459,13 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { } geantTime *= 1.e+09; // conversion from [s] to [ns] - + // TOF matching window (~200ns) control + if (geantTime>=AliTOFGeometry::MatchingWindow()*1E-3) { + AliDebug(2,Form("Time measurement (%f) greater than the matching window (%f)", + geantTime, AliTOFGeometry::MatchingWindow()*1E-3)); + continue; + } + // selection case for sdigitizing only hits in a given plate of a given sector if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){ @@ -356,8 +503,15 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { for(Int_t indexOfPad=0; indexOfPad=0.2) nlargeTofDiff++; + + // TOF matching window (~200ns) control + if (tofAfterSimul[indexOfPad]>=AliTOFGeometry::MatchingWindow()*1E-3) { + AliDebug(2,Form("Time measurement (%f) greater than the matching window (%f)", + tofAfterSimul[indexOfPad], AliTOFGeometry::MatchingWindow()*1E-3)); + continue; + } + + if(timediff>=0.2) nlargeTofDiff++; // greater than 200ps digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/AliTOFGeometry::TdcBinWidth()); // TDC bin number (each bin -> 24.4 ps) @@ -409,15 +563,14 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { if (tof->SDigits()) tof->ResetSDigits(); - if (strstr(verboseOption,"all")) { - AliInfo("----------------------------------------"); - AliInfo(" "); - AliInfo(Form("After sdigitizing %d hits in event %d", nselectedHitsinEv, iEvent)); + if (strstr(verboseOption,"all") || strstr(verboseOption,"partial")) { + AliDebug(2,"----------------------------------------"); + AliDebug(2,Form("After sdigitizing %d hits in event %d", nselectedHitsinEv, iEvent)); //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, " - AliInfo(Form("%d digits have been created", ntotalsdigitsinEv)); - AliInfo(Form("(%d due to signals and %d due to border effect)", nsignalsdigitsinEv, nnoisesdigitsinEv)); - AliInfo(Form("%d total updates of the hit map have been performed in current event", ntotalupdatesinEv)); - AliInfo("----------------------------------------"); + AliDebug(1,Form("%d sdigits have been created", ntotalsdigitsinEv)); + AliDebug(2,Form("(%d due to signals and %d due to border effect)", nsignalsdigitsinEv, nnoisesdigitsinEv)); + AliDebug(2,Form("%d total updates of the hit map have been performed in current event", ntotalupdatesinEv)); + AliDebug(2,"----------------------------------------"); } } //event loop on events @@ -434,19 +587,15 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { } nHitsFromSec=nselectedHits-nHitsFromPrim; - if(strstr(verboseOption,"all")){ - AliInfo("----------------------------------------"); - AliInfo("----------------------------------------"); - AliInfo("-----------SDigitization Summary--------"); - AliInfo(" "); - AliInfo(Form("After sdigitizing %d hits", nselectedHits)); - AliInfo(Form("in %d events", fEvent2-fEvent1)); -//" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, " - AliInfo(Form("%d sdigits have been created", ntotalsdigits)); - AliInfo(Form("(%d due to signals and " - "%d due to border effect)", nsignalsdigits, nnoisesdigits)); - AliInfo(Form("%d total updates of the hit map have been performed", ntotalupdates)); - AliInfo(Form("in %d cases the time of flight difference is greater than 200 ps", nlargeTofDiff)); + if (strstr(verboseOption,"all") || strstr(verboseOption,"partial")) { + AliDebug(2,"----------------------------------------"); + AliDebug(2,Form("After sdigitizing %d hits in %d events ", nselectedHits, fEvent2-fEvent1)); + //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, " + AliDebug(2,Form("%d sdigits have been created", ntotalsdigits)); + AliDebug(2,Form("(%d due to signals and %d due to border effect)", nsignalsdigits, nnoisesdigits)); + AliDebug(2,Form("%d total updates of the hit map have been performed", ntotalupdates)); + AliDebug(2,Form("in %d cases the time of flight difference is greater than 200 ps", nlargeTofDiff)); + AliDebug(2,"----------------------------------------"); } @@ -463,12 +612,13 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) { //__________________________________________________________________ void AliTOFSDigitizer::Print(Option_t* /*opt*/)const { - cout << "------------------- "<< GetName() << " ------------- \n"; + AliInfo(Form(" ------------------- %s ------------- ", GetName())); } //__________________________________________________________________ void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate) { + //Select sector and plate Bool_t isaWrongSelection=(sector < 0) || (sector >= AliTOFGeometry::NSectors()) || (plate < 0) || (plate >= AliTOFGeometry::NPlates()); if(isaWrongSelection){ AliError("You have selected an invalid value for sector or plate "); @@ -771,36 +921,36 @@ void AliTOFSDigitizer::PrintParameters()const // // Print parameters used for sdigitization // - cout << " ------------------- "<< GetName() << " -------------" << endl ; - cout << " Parameters used for TOF SDigitization " << endl ; + AliInfo(Form(" ------------------- %s -------------", GetName())); + AliInfo(" Parameters used for TOF SDigitization "); // Printing the parameters - cout << " Number of events: " << (fEvent2-fEvent1) << endl; - cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl; - cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl; - cout << " Edge Effect option: "<< fEdgeEffect<< endl; - - cout << " Boundary Effect Simulation Parameters " << endl; - cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl; - cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl; - cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl; - cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl; - cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl; - cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl; - cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl; - cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <