X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FAliTOFT0.cxx;h=0e2f7b4a261eed2efd8ade6cfafe13fe8c2f62c5;hb=88213d75fbdd1e71bd08735e6e1198a2b5325463;hp=45edb28911291f4392543c179c7dcf319a8efae2;hpb=4c475d270bc4db4b33ee441ca06c5d5194788e8c;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/AliTOFT0.cxx b/TOF/AliTOFT0.cxx index 45edb289112..0e2f7b4a261 100644 --- a/TOF/AliTOFT0.cxx +++ b/TOF/AliTOFT0.cxx @@ -13,41 +13,56 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ +/* $Id$ */ + //_________________________________________________________________________ +// // This is a TTask that made the calculation of the Time zero using TOF. -// Description: The algorithm used to calculate the time zero of interaction -// using TOF detector is the following. -// We select in the MonteCarlo some primary particles - or tracks in the following - -// that strike the TOF detector (the larger part are pions, kaons or protons). -// We choose a set of 10 selected tracks, for each track You have the length -// of the track when the TOF is reached (a standard TOF hit does not contain this -// additional information, this is the reason why we implemented a new time zero -// dedicated TOF hit class AliTOFhitT0; in order to store this type of hit You -// have to use the AliTOFv4T0 as TOF class in Your Config.C. In AliTOFv4T0 the -// StepManager was modified in order to fill the TOF hit branch with this type -// of hits; in fact the AliTOF::AddT0Hit is called rather that the usual AliTOF::AddHit), -// the momentum at generation (from TreeK) and the time of flight -// given by the TOF detector. -// (Observe that the ctor of the AliTOF class, when the AliTOFv4T0 class is used, is called -// with the "tzero" option: it is in order create the fHits TClonesArray filled with -// AliTOFhitT0 objects, rather than with normal AliTOFhit) -// Then Momentum and time of flight for each track are smeared according to -// known experimental resolution (all sources of error have been token into account). -// Let consider now only one set of 10 tracks (the algorithm is the same for all sets). -// Assuming the (mass) hypothesis that each track can be AUT a pion, AUT a kaon, AUT a proton, -// we consider all the 3 at 10 possible cases. +// Description: The algorithm used to calculate the time zero of +// interaction using TOF detector is the following. +// We select in the MonteCarlo some primary particles - or tracks in +// the following - that strike the TOF detector (the larger part are +// pions, kaons or protons). +// We choose a set of 10 selected tracks, for each track You have the +// length of the track when the TOF is reached (a standard TOF hit +// does not contain this additional information, this is the reason +// why we implemented a new time zero dedicated TOF hit class +// AliTOFhitT0; in order to store this type of hit You have to use the +// AliTOFv4T0 as TOF class in Your Config.C. In AliTOFv4T0 the +// StepManager was modified in order to fill the TOF hit branch with +// this type of hits; in fact the AliTOF::AddT0Hit is called rather +// that the usual AliTOF::AddHit), the momentum at generation (from +// TreeK) and the time of flight given by the TOF detector. +// (Observe that the ctor of the AliTOF class, when the AliTOFv4T0 +// class is used, is called with the "tzero" option: it is in order +// create the fHits TClonesArray filled with AliTOFhitT0 objects, +// rather than with normal AliTOFhit) +// Then Momentum and time of flight for each track are smeared +// according to known experimental resolution (all sources of error +// have been token into account). +// Let consider now only one set of 10 tracks (the algorithm is the +// same for all sets). +// Assuming the (mass) hypothesis that each track can be AUT a pion, +// AUT a kaon, AUT a proton, we consider all the 3 at 10 possible +// cases. // For each track in each (mass) configuration -// (a configuration can be e.g. pion/pion/kaon/proton/pion/proton/kaon/kaon/pion/pion) -// we calculate the time zero (we know in fact the velocity of the track after -// the assumption about its mass, the time of flight given by the TOF, and the -// corresponding path travelled till the TOF detector). Then for each mass configuration we have -// 10 time zero and we can calculate the ChiSquare for the current configuration using the -// weighted mean over all 10 time zero. -// We call the best assignment the mass configuration that gives the minimum value of the ChiSquare. -// We plot the weighted mean over all 10 time zero for the best assignment, -// the ChiSquare for the best assignment and the corresponding confidence level. -// The strong assumption is the MC selection of primary particles. It will be introduced -// in the future also some more realistic simulation about this point. +// (a configuration can be +// e.g. pion/pion/kaon/proton/pion/proton/kaon/kaon/pion/pion) +// we calculate the time zero (we know in fact the velocity of the +// track after the assumption about its mass, the time of flight given +// by the TOF, and the corresponding path travelled till the TOF +// detector). Then for each mass configuration we have 10 time zero +// and we can calculate the ChiSquare for the current configuration +// using the weighted mean over all 10 time zero. +// We call the best assignment the mass configuration that gives the +// minimum value of the ChiSquare. +// We plot the weighted mean over all 10 time zero for the best +// assignment, the ChiSquare for the best assignment and the +// corresponding confidence level. +// The strong assumption is the MC selection of primary particles. It +// will be introduced in the future also some more realistic +// simulation about this point. +// // Use case: // root [0] AliTOFT0 * tzero = new AliTOFT0("galice.root") // Warning in : object already instantiated @@ -55,52 +70,76 @@ // root [2] tzero->ExecuteTask("tim") // // available parameters: // tim - print benchmarking information -// all - print usefull informations about the number of misidentified tracks -// and a comparison about the true configuration (known from MC) and the best +// all - print usefull informations about the number of +// misidentified tracks and a comparison about the +// true configuration (known from MC) and the best // assignment +// //-- Author: F. Pierella -////////////////////////////////////////////////////////////////////////////// +// +//_________________________________________________________________________ + +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AliMC.h" +#include "AliRun.h" -#include "AliTOFT0.h" #include "AliTOFhitT0.h" +#include "AliTOFT0.h" #include "AliTOF.h" -#include "AliTOFv4T0.h" -#include "AliRun.h" -#include "AliDetector.h" - -#include "TH1.h" -#include "TFile.h" -#include "TTask.h" -#include "TTree.h" -#include "TSystem.h" -#include "TCanvas.h" -#include "TFrame.h" -#include "TROOT.h" -#include "TFolder.h" -#include "TBenchmark.h" -#include "TParticle.h" -#include "TClonesArray.h" -#include -#include + +extern TROOT *gROOT; +extern TRandom *gRandom; +extern TBenchmark *gBenchmark; + +extern AliRun *gAlice; ClassImp(AliTOFT0) //____________________________________________________________________________ - AliTOFT0::AliTOFT0():TTask("AliTOFT0","") +AliTOFT0::AliTOFT0(): + TTask("AliTOFT0",""), + fNevents(0), + fTimeResolution(0), + fLowerMomBound(0), + fUpperMomBound(0), + fT0File(""), + fHeadersFile("") { // ctor - fNevents = 0 ; } //____________________________________________________________________________ - AliTOFT0::AliTOFT0(char* headerFile, Int_t nEvents):TTask("AliTOFT0","") +AliTOFT0::AliTOFT0(char* headerFile, Int_t nEvents): + TTask("AliTOFT0",""), + fNevents(nEvents), + fTimeResolution(1.2e-10), + fLowerMomBound(1.5), + fUpperMomBound(2.), + fT0File(""), + fHeadersFile(headerFile) { - fNevents=nEvents ; // Number of events for which calculate the T0, + // + // + // + + //fNevents=nEvents ; // Number of events for which calculate the T0, // default 0: it means all evens in current file - fLowerMomBound=1.5; // [GeV/c] default value - fUpperMomBound=2. ; // [GeV/c] default value - fTimeResolution = 1.2e-10; // 120 ps by default - fHeadersFile = headerFile ; + //fLowerMomBound=1.5; // [GeV/c] default value + //fUpperMomBound=2. ; // [GeV/c] default value + //fTimeResolution = 1.2e-10; // 120 ps by default + //fHeadersFile = headerFile ; TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ; @@ -118,6 +157,21 @@ ClassImp(AliTOFT0) roottasks->Add(this) ; } +//____________________________________________________________________________ +AliTOFT0::AliTOFT0(const AliTOFT0 & tzero): + TTask("AliTOFT0",""), + fNevents(0), + fTimeResolution(0), + fLowerMomBound(0), + fUpperMomBound(0), + fT0File(""), + fHeadersFile("") +{ + // copy ctr + +( (AliTOFT0 &)tzero ).Copy(*this); +} + //____________________________________________________________________________ AliTOFT0::~AliTOFT0() { @@ -206,57 +260,60 @@ void AliTOFT0::Exec(Option_t *option) Float_t chisquare=999.; Float_t tracktoflen[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; - AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF"); + AliTOF *detTOF = (AliTOF *) gAlice->GetDetector ("TOF"); - if (!TOF) { + if (!detTOF) { Error("AliTOFT0","TOF not found"); return; } if(strstr(option,"all")){ - cout << "Selecting primary tracks with momentum between " << fLowerMomBound << " GeV/c and " << fUpperMomBound << " GeV/c" << endl; - cout << "Memorandum: 0 means PION | 1 means KAON | 2 means PROTON" << endl; + AliInfo(Form("Selecting primary tracks with momentum between %f GeV/c and %f GeV/c", fLowerMomBound, fUpperMomBound)); + AliInfo("Memorandum: 0 means PION | 1 means KAON | 2 means PROTON") } - if (fNevents == 0) fNevents = (Int_t) gAlice->TreeE()->GetEntries(); + if (fNevents == 0) fNevents = (Int_t) AliRunLoader::Instance()->TreeE()->GetEntries(); for (Int_t ievent = 0; ievent < fNevents; ievent++) { gAlice->GetEvent(ievent); - TTree *TH = gAlice->TreeH (); - if (!TH) + TTree *hitTree = detTOF->GetLoader()->TreeH (); + if (!hitTree) return; TParticle* particle; AliTOFhitT0* tofHit; - TClonesArray* TOFhits = TOF->Hits(); + TClonesArray* tofHits = detTOF->Hits(); Int_t lasttrack=-1; Int_t nset=0; - TH->SetBranchStatus("*",0); // switch off all branches - TH->SetBranchStatus("TOF*",1); // switch on only TOF + hitTree->SetBranchStatus("*",0); // switch off all branches + hitTree->SetBranchStatus("TOF*",1); // switch on only TOF // Start loop on primary tracks in the hits containers - Int_t ntracks = static_cast(TH->GetEntries()); + Int_t ntracks = static_cast(hitTree->GetEntries()); for (Int_t track = 0; track < ntracks; track++) { if(nset>=5) break; // check on the number of set analyzed - gAlice->ResetHits(); - TH->GetEvent(track); - particle = gAlice->Particle(track); - Int_t nhits = TOFhits->GetEntriesFast(); + gAlice->GetMCApp()->ResetHits(); + hitTree->GetEvent(track); + + AliMC *mcApplication = (AliMC*)gAlice->GetMCApp(); + + particle = mcApplication->Particle(track); + Int_t nhits = tofHits->GetEntriesFast(); for (Int_t hit = 0; hit < nhits; hit++) { - tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit); + tofHit = (AliTOFhitT0 *) tofHits->UncheckedAt(hit); ipart = tofHit->GetTrack(); // check to discard the case when the same particle is selected more than one // time if (ipart != ipartold){ - particle = (TParticle*)gAlice->Particle(ipart); + particle = (TParticle*)gAlice->GetMCApp()->Particle(ipart); Float_t idealtime=tofHit->GetTof(); // Float_t time=idealtime; @@ -280,7 +337,7 @@ void AliTOFT0::Exec(Option_t *option) timeofflight[index]=time; tracktoflen[index]=toflen; momentum[index]=mom; - // cout << timeofflight[index] << " " << tracktoflen[index] << " " << momentum[index] << endl; + //AliInfo(Form(" %d %d %d ", timeofflight[index], tracktoflen[index], momentum[index])); switch (abspdg) { case 211: truparticle[index]=0; @@ -301,7 +358,7 @@ void AliTOFT0::Exec(Option_t *option) lasttrack=track; istop=0; selected=0; - //cout << "starting t0 calculation for current set" << endl; + //AliInfo("starting t0 calculation for current set"); for (Int_t i1=0; i1<3;i1++) { beta[0]=momentum[0]/sqrt(massarray[i1]*massarray[i1]+momentum[0]*momentum[0]); for (Int_t i2=0; i2<3;i2++) { @@ -387,10 +444,10 @@ void AliTOFT0::Exec(Option_t *option) hchibestconflevel->Fill(confLevel); itimes++; if(strstr(option,"all")){ - cout << "True Assignment " << truparticle[0] << truparticle[1] << truparticle[2] << truparticle[3] << truparticle[4] << truparticle[5] << truparticle[6] << truparticle[7] << truparticle[8] << truparticle[9] <Stop("TOFT0"); - cout << "AliTOFT0:" << endl ; + AliInfo("AliTOFT0:"); + /* cout << " took " << gBenchmark->GetCpuTime("TOFT0") << " seconds in order to calculate T0 " - << gBenchmark->GetCpuTime("TOFT0")/fNevents << " seconds per event " << endl ; - cout << endl ; + << gBenchmark->GetCpuTime("TOFT0")/fNevents << " seconds per event " << endl ; + */ + gBenchmark->Print("TOFT0"); } } //__________________________________________________________________ -void AliTOFT0::SetTZeroFile(char * file ){ - cout << "Destination file : " << file << endl ; +void AliTOFT0::SetTZeroFile(char * file ) +{ + // + // Set T0 file name + // + printf("Destination file : %s \n", file) ; fT0File=file; + } + //__________________________________________________________________ -void AliTOFT0::Print(Option_t* option)const +void AliTOFT0::Print(Option_t* /*option*/)const { - cout << "------------------- "<< GetName() << " -------------" << endl ; + // + // Print class content + // + printf("------------------- %s -------------\n", GetName()) ; if(!fT0File.IsNull()) - cout << " Writing T0 Distribution to file " << (char*) fT0File.Data() << endl ; + printf(" Writing T0 Distribution to file %s \n",(char*) fT0File.Data()); + } //__________________________________________________________________ Bool_t AliTOFT0::operator==( AliTOFT0 const &tzero )const { - // Equal operator. + // + // Equal operator // if( (fTimeResolution==tzero.fTimeResolution)&&(fLowerMomBound==tzero.fLowerMomBound)&&(fUpperMomBound==tzero.fUpperMomBound)) @@ -484,4 +554,3 @@ Bool_t AliTOFT0::operator==( AliTOFT0 const &tzero )const else return kFALSE ; } -