// analisi Bool_t CheckSingle(const char* esdFileName,Bool_t kGRID){ //inizializzo a zero ncluster (di tree T) //for (int ifc=0;ifc<10000;ifc++) ncluster[ifc]=0; // check the content of the ESD AliPIDResponse *pidr = new AliPIDResponse(); // open the ESD file TFile* esdFile = TFile::Open(esdFileName); if (!esdFile || !esdFile->IsOpen()){ Error("CheckESD", "opening ESD file %s failed", esdFileName); return kFALSE; } TString mctrkref(esdFileName); mctrkref.ReplaceAll("AliESDs.root","TrackRefs.root"); TString fgal(esdFileName); fgal.ReplaceAll("AliESDs.root","galice.root"); if(kGRID){ fgal.Insert(0,"alien://"); mctrkref.Insert(0,"alien://"); } TTree *trkref; printf("ESD = %s\n",esdFileName); TFile *ftrkref; if(isMC) ftrkref = TFile::Open(mctrkref.Data()); AliHeader *h = new AliHeader(); TFile *fgalice; if(isMC) fgalice = TFile::Open(fgal.Data()); TTree *tgalice; if(isMC){ tgalice = (TTree *) fgalice->Get("TE"); tgalice->SetBranchAddress("Header",&h); } AliRunLoader* runLoader = NULL; AliRun *gAlice; if(isMC) runLoader = AliRunLoader::Open(fgal.Data()); if(runLoader){ runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); if (!gAlice) { Error("CheckESD", "no galice object found"); return kFALSE; } runLoader->LoadKinematics(); runLoader->LoadHeader(); } AliESDEvent * esd = new AliESDEvent; // printf("esd object = %x\n",esd); TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree){ Error("CheckESD", "no ESD tree found"); return kFALSE; } esd->ReadFromTree(tree); // crea link tra esd e tree TClonesArray* tofcl; // array dinamico TClonesArray* tofhit; TClonesArray* tofmatch; Int_t nev = tree->GetEntries(); //ogni entries evento Float_t mag; printf("nev = %i\n",nev); //azzero il contatore delle tracce del TTree T //ntracks=0; AliStack* stack=NULL; Int_t trkassociation[1000000]; for(Int_t ie=0;ie < nev;ie++){ if(runLoader){ runLoader->GetEvent(ie); // select simulated primary particles, V0s and cascades stack = runLoader->Stack(); } if(isMC) trkref = (TTree *) ftrkref->Get(Form("Event%i/TreeTR",ie)); tree->GetEvent(ie); if(isMC) tgalice->GetEvent(ie); if(isMC) interactiontime = h->GenEventHeader()->InteractionTime()*1E+12; mag = esd->GetMagneticField(); AliTOFHeader *tofh = esd->GetTOFHeader(); ntofcl = tofh->GetNumberOfTOFclusters(); esd->ConnectTracks(); // Deve essere sempre chiamato dopo aver letto l'evento (non troverebbe l'ESDevent). Scrivo in tutte le tracce l origine dell evento così poi da arrivare ovunque(tipo al cluster e al tempo quindi). //Riempio variabile del tree "T" //nevento=ie; if(! esd->GetVertex()){ esd->ResetStdContent(); continue;// una volta fatto il connect manda un flag ; siccome qua c'era un continue(non si arriva in fondo al ciclo) bisogna resettarlo altrimenti lo trova già attivo. } tofcl = esd->GetESDTOFClusters(); // AliESDTOFCluster *cltof = tofcl->At(i); if(tofcl->GetEntries() == 0){ esd->ResetStdContent(); continue; } tofhit = esd->GetESDTOFHits(); // AliESDTOFHit *hittof = tofhit->At(i); tofmatch = esd->GetESDTOFMatches(); // AliESDTOFHit *mathctof = tofmatch->At(i); // loop over tracks pidr->SetTOFResponse(esd,AliPIDResponse::kTOF_T0); //per recuperare lo start time ("esd", "tipo start time"), tipo cioè o il TOF stesso o il T0 o il best, ovvero la combinazione dei 2 Int_t ntrk = esd->GetNumberOfTracks(); //printf("%i) TPC tracks = %i -- TOF cluster = %i - TOF hit = %i -- matchable info = %i\n",ie,ntrk,tofcl->GetEntries(),tofhit->GetEntries(),tofmatch->GetEntries()); Double_t time[AliPID::kSPECIESC]; if(isMC && stack){// create association trackref printf("nMC track = %i\n",stack->GetNtrack()); for(Int_t ist=0;ist < stack->GetNtrack();ist++){ trkassociation[ist]=-1; } for(Int_t iref=0;iref < trkref->GetEntries();iref++){ trkref->GetEvent(iref); Int_t trkreference = trkref->GetLeaf("TrackReferences.fTrack")->GetValue(); if(trkreference > -1 && trkreference < 1000000){ trkassociation[trkreference] = iref; } } } for (Int_t iTrack = 0; iTrack < ntrk; iTrack++){ AliESDtrack* track = esd->GetTrack(iTrack); // select tracks of selected particles if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;//almeno un hit nell ITS if (track->GetConstrainedChi2() > 4) continue; //se brutto X^2 if ((track->GetStatus() & AliESDtrack::kTOFout) == 0) continue; //se traccia matchata con tof if(track->GetNumberOfTPCClusters() < 70) continue; Float_t p =track->P(); itrig = 0; timetrig = 0; if(p > 0.9 && p < 1.1){ track->GetIntegratedTimes(time); itrig = iTrack; timetrig = track->GetTOFsignal() - time[2]; iTrack = ntrk; } } printf("real loop, ntrk = %i\n",ntrk); for (Int_t iTrack = 0; iTrack < ntrk; iTrack++){ AliESDtrack* track = esd->GetTrack(iTrack); // select tracks of selected particles if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;//almeno un hit nell ITS if (track->GetConstrainedChi2() > 4) continue; //se brutto X^2 //if ((track->GetStatus() & AliESDtrack::kTOFout) == 0) continue; //se traccia matchata con tof if(track->GetNumberOfTPCClusters() < 70) continue; TOFout = (track->GetStatus() & AliESDtrack::kTOFout) > 0; track->GetIntegratedTimes(time); Float_t dx = track->GetTOFsignalDx(); //leggo i residui tra traccia e canale tof acceso Float_t dz = track->GetTOFsignalDz(); mism = 0; dedx = track->GetTPCsignal(); Int_t label = TMath::Abs(track->GetLabel()); if(stack){ TParticle *part=stack->Particle(label); pdg = part->GetPdgCode(); } Int_t TOFlabel[3]; track->GetTOFLabel(TOFlabel); // printf("%i %i %i %i\n",label,TOFlabel[0],TOFlabel[1],TOFlabel[2]); ChannelTOF[0] = track->GetTOFCalChannel(); // printf("geant time = %f\n",gtime); //getchar(); // if(TMath::Abs(dx) > 1.25 || TMath::Abs(dz) > 1.75) continue; // is inside the pad //riempio il numro di cludter e impulso trasverso per traccia del TTree T ncluster=track->GetNTOFclusters(); impulso_trasv=track->Pt(); impulso=track->P(); StartTime = pidr->GetTOFResponse().GetStartTime(track->P()); StartTimeRes = pidr->GetTOFResponse().GetStartTimeRes(track->P()); if(track->Pt() > 0.9 && track->Pt() < 1.5){ //impulso non troppo alto per separazione tra particelle Float_t dt = track->GetTOFsignal() - time[2] - pidr->GetTOFResponse().GetStartTime(track->P());//tempo TOF(è lo stesso di Gettime, solo che lo prendo dale tracce)(già calibrato) -ip del PI (posizione 0 e, posizione 1 mu, pos 2 PI, pos 3 K,pos 4 p) -start time Float_t dtKa = track->GetTOFsignal() - time[3] - pidr->GetTOFResponse().GetStartTime(track->P()); Float_t dtPr = track->GetTOFsignal() - time[4] - pidr->GetTOFResponse().GetStartTime(track->P()); hdt->Fill(dt); hdtKa->Fill(dtKa); hdtPr->Fill(dtPr); } charge = track->Charge(); phi = track->Phi(); eta = track->Eta(); GetPositionAtTOF(track,mag,coord); phiExt = TMath::ATan2(coord[1],coord[0]); etaExt = -TMath::Log(TMath::Tan(0.5*TMath::ATan2(sqrt(coord[0]*coord[0]+coord[1]*coord[1]),coord[2]))); for (int i=0;i<(track->GetNTOFclusters());i++){ int idummy=track->GetTOFclusterArray()[i]; AliESDTOFCluster *cl = (AliESDTOFCluster *) tofcl->At(idummy); tempo[i]=cl->GetTime(); tot[i]=cl->GetTOT(); ChannelTOF[i]=cl->GetTOFchannel(); if(i==0){ GetResolutionAtTOF(track,mag,ChannelTOF[i],res); } for(int im=cl->GetNMatchableTracks();im--;){ //o così o da n-1 a 0 //for(int im=cl->GetNMatchableTracks();im>0;im--) non andava bene perchè non prendeva mai lo 0 // if(track->GetNTOFclusters()==2) printf("-- %i) %f %f\n",im,cl->GetLength(im),cl->GetIntegratedTime(2,im)); if(cl->GetTrackIndex(im) == track->GetID()){ exp_time_el[i] = cl->GetIntegratedTime(0,im); // pi = 2 exp_time_mu[i] = cl->GetIntegratedTime(1,im); // pi = 2 exp_time_pi[i] = cl->GetIntegratedTime(2,im); // pi = 2 exp_time_ka[i] = cl->GetIntegratedTime(3,im); // pi = 2 exp_time_pr[i] = cl->GetIntegratedTime(4,im); // pi = 2 L[i] = cl->GetLength(im); // if(track->GetNTOFclusters()==2)printf("%i) %f %f\n",i,L[i],exp_time_pi[i]); DeltaX[i]=cl->GetDx(im); // mettendolo dentro questo if dovrei prendere i residui di una stessa traccia DeltaZ[i]=cl->GetDz(im); } } } //ReMatch(); Int_t jref=0; if(isMC){ if(TOFlabel[0] > -1 && TOFlabel[0] < 1000000){ trkref->GetEvent(trkassociation[TOFlabel[0]]); if(TOFlabel[0] == trkref->GetLeaf("TrackReferences.fTrack")->GetValue()){ // printf("trk -> %i (%i)\n",trkref->GetLeaf("TrackReferences.fTrack")->GetValue(),trkref->GetLeaf("TrackReferences.fTrack")->GetValue(jref)); while(jref > -1 && trkref->GetLeaf("TrackReferences.fTrack")->GetValue(jref) != 0){ //printf("det = %i\n",trkref->GetLeaf("TrackReferences.fDetectorId")->GetValue(jref)); if(trkref->GetLeaf("TrackReferences.fDetectorId")->GetValue(jref) == 4){ gtime=trkref->GetLeaf("TrackReferences.fTime")->GetValue(jref)*1E+12; xgl = trkref->GetLeaf("TrackReferences.fX")->GetValue(jref); ygl = trkref->GetLeaf("TrackReferences.fY")->GetValue(jref); zgl = trkref->GetLeaf("TrackReferences.fZ")->GetValue(jref); MakeTrueRes(); jref = 100; } jref++; } } } } if(TMath::Abs(label) != TOFlabel[0] && stack){ mism=2; while(TOFlabel[0] != -1 && TOFlabel[0] != label){ TOFlabel[0] = stack->Particle(TOFlabel[0])->GetMother(0); } if(label == TOFlabel[0]) mism=1; } //AddDelay(); T->Fill(); //cout<<"riempio il tree "<<endl; //Riempio tree "T" //incremento il contatore delle tracce del TTree T matchate e che superano i tagli //ntracks++; }//end of for(tracks) esd->ResetStdContent(); } //end of for(events) if(runLoader){ runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; } esdFile->Close(); if(isMC) ftrkref->Close(); if(isMC) fgalice->Close(); }