New Calorimeter Calibration directory, now only PHOS
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
index 15f8bc7d742018f1e3e47675938981b8ed9e924a..bf298f0f0996ef253889ceb1a95fa8bed7dc5539 100755 (executable)
@@ -227,7 +227,7 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
        // store them in fOutputContainer
     
        TList * outputContainer = new TList() ; 
-       outputContainer->SetName("ExampleHistos") ; 
+       outputContainer->SetName("QAHistos") ; 
        
        Int_t nptbins  = GetHistoNPtBins();
        Int_t nphibins = GetHistoNPhiBins();
@@ -860,7 +860,13 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
        //Play with the MC stack if available
        AliStack * stack = 0x0;
        TParticle * primary = 0x0;
-       if(IsDataMC()) stack =  GetMCStack() ;
+       if(IsDataMC()) { 
+               stack =  GetMCStack() ;
+               if(!stack) {
+                       printf("Stack not available, have you switched on the MC data?\n");
+                       return;
+               }
+       }
        
        //Get List with clusters  
        TRefArray * partList = new TRefArray();
@@ -882,9 +888,9 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
        //Get vertex for photon momentum calculation
        Double_t v[3] ; //vertex ;
        GetReader()->GetVertex(v);
-       
+
        for(Int_t iclus = 0; iclus < partList->GetEntriesFast(); iclus++){
-               
+               //printf(" cluster %d\n",iclus);
                AliAODCaloCluster * calo =  (AliAODCaloCluster*) (partList->At(iclus));
                //if(calo->GetNCells() <= 2) continue;
                //Get cluster kinematics
@@ -905,7 +911,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                
                //matched cluster with tracks
                Int_t ntracksmatched = calo->GetNTracksMatched();
-               
+
                //Fill histograms only possible when simulation
                if(IsDataMC()){
                //Play with the MC stack if available
@@ -920,8 +926,10 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                                printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
                                continue ;
                }
-               //cout<<"LABEL > "<<label<<endl;
+                       
+               //cout<<"LABEL  "<<label<<endl;
                primary = GetMCStack()->Particle(label);
+
                    Int_t pdg = primary->GetPdgCode();
                    Float_t vx = primary->Vx();
                    Float_t vy = primary->Vy();
@@ -932,18 +940,16 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                                fhEMR      ->Fill(e,r);
                    }
                    
-                   //                  printf("reco e %f, pt %f, phi %f, eta %f \n", e, pt, phi, eta);
-                   //                  printf("prim e %f, pt %f, phi %f, eta %f \n", primary->Energy(),primary->Pt() ,primary->Phi() ,primary->Eta() );
-                   //                  printf("vertex: vx %f, vy %f, vz %f, r %f \n", vx, vy, vz, r);
+                   //printf("reco e %f, pt %f, phi %f, eta %f \n", e, pt, phi, eta);
+                   //printf("prim e %f, pt %f, phi %f, eta %f \n", primary->Energy(),primary->Pt() ,primary->Phi() ,primary->Eta() );
+                   //printf("vertex: vx %f, vy %f, vz %f, r %f \n", vx, vy, vz, r);
                    
                    //Get final particle, no conversion products
                    Int_t status =  primary->GetStatusCode();
                    Int_t mother= primary->GetFirstMother();
-                   Int_t finallabel = -1;
                    if(status == 0){
                                while(mother >= 0){
                                        primary = GetMCStack()->Particle(mother);
-                                       finallabel = mother;
                                        status = primary->GetStatusCode();
                                        mother= primary->GetFirstMother();
                                        if(status == 1) break;             
@@ -966,7 +972,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                        
                    //cout<<"Final Label "<<finallabel<<" mother "<<mother<<endl;
                    pdg = primary->GetPdgCode();
-                       Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
+                   Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
                        
                    if(pdg == 22){
                                //cout<<"pdg "<<pdg<<" status "<<status<<" "<<primary->GetStatusCode()<<endl;   
@@ -985,15 +991,21 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                                                while(mother >= 0){
                                                        pi0 = GetMCStack()->Particle(mother);
                                                        pdgpi0 = pi0->GetPdgCode();
-                                                       if(pdgpi0 == 111) break;
+                                                       if(pdgpi0 == 111) {
+                                                         //cout<<"pi0!!!"<<endl;
+                                                         break;
+                                                       }
                                                        mother= pi0->GetFirstMother();
                                                        //printf("mother %d\n",mother);
                                                }
                                        }
                                        else   pi0 = primary;
-                                       //cout<<"MOTHER PI0 LABEL "<<mother<<" pt" << pi0->Pt()<<endl;
+                               
+                                       if(!pi0 || mother < 0 ) continue ;
+                                       cout<<"pi0 pointer "<<pi0<<" pdg "<<pdgpi0<<" "<<pi0->GetPdgCode()<<endl;
+                                       cout<<"MOTHER PI0 LABEL "<<mother<<" pt" << pi0->Pt()<<" status "<<pi0->GetStatusCode()<<endl;
                                        if(pi0->GetNDaughters() == 2){
-                                               //  cout<<"pi0, 2 daughters "<<endl;
+                                         cout<<"pi0, 2 daughters "<<endl;
                                                Int_t id1 = pi0->GetFirstDaughter();
                                                Int_t id2 = pi0->GetFirstDaughter()+1;
                                                p1=GetMCStack()->Particle(id1);
@@ -1127,10 +1139,11 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                                if(trackIndex >= 0){
                                        AliESDtrack* track = (AliESDtrack*) esd->GetTrack(trackIndex);
                                        if (track && track->GetOuterParam() ) {
-                                               
+
                                                Double_t tphi = track->GetOuterParam()->Phi();
                                                Double_t teta = track->GetOuterParam()->Eta();
                                                Double_t tmom = track->GetOuterParam()->P();
+
                                                Double_t deta = teta - eta;
                                                Double_t dphi = tphi - phi;
                                                if(dphi > TMath::Pi()) dphi -= 2*TMath::Pi();
@@ -1144,9 +1157,11 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                                                
                                                fh1dR->Fill(dR);
                                                fh2MatchdEdx->Fill(track->P(),track->GetTPCsignal());
-                                           Int_t pdg = primary->GetPdgCode();
-                                               Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
+                                       
                                                if(IsDataMC() && primary){ 
+                                                        Int_t pdg = primary->GetPdgCode();
+                                                        Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
+                                                       
                                                        if(TMath::Abs(pdg) == 11){
                                                                fhMCEle1pOverE->Fill(pOverE);
                                                                fhMCEle1dR->Fill(dR);
@@ -1185,7 +1200,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                                                if ( (track->GetStatus() & status) == status) printf("ITS+TPC\n");
                                        }
                                        else {
-                                               Printf("ERROR: Could not receive track %d", trackIndex);
+                                               printf("ERROR: Could not receive track %d\n", trackIndex);
                                        }
                                }// non negative track index
                        }//do only if input are ESDs
@@ -1227,7 +1242,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
        fhNCells->Fill(ncells) ;
        
        for (Int_t iCell = 0; iCell < ncells; iCell++) {      
-               if(GetDebug() > 2)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
+               if(GetDebug() > 10)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
                fhAmplitude->Fill(cell->GetAmplitude(iCell));
        }
        
@@ -1290,6 +1305,10 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
                } //primary loop
        } //Is data MC
        
+       if(GetDebug() > 0)
+               printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - End \n");
+       
+       
 }
 
 //________________________________________________________________________