updates Francesco for warnings sprintf
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 2 Mar 2012 20:17:36 +0000 (20:17 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 2 Mar 2012 20:17:36 +0000 (20:17 +0000)
PWG/FLOW/Tasks/AliAnalysisTaskVnV0.cxx
PWG/FLOW/Tasks/AliFlowVZEROResults.cxx
PWGCF/FLOW/macros/AddTaskVZERO.C
PWGCF/FLOW/macros/extractFlowVZERO.C

index 885fe1c..b6b258c 100644 (file)
@@ -526,11 +526,12 @@ void AliAnalysisTaskVnV0::UserExec(Option_t *)
 
 
     //Get the MC object
-
-    AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
-    if (!mcHeader) {
-      AliError("Could not find MC Header in AOD");
-      return;
+    if(fIsMC){
+      AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
+      if (!mcHeader) {
+       AliError("Could not find MC Header in AOD");
+       return;
+      }
     }
 
     /*
@@ -1191,13 +1192,13 @@ void AliAnalysisTaskVnV0::OpenInfoCalbration(Int_t run){
            for(Int_t i=0;i  < nCentrBin;i++){
                char namecont[100];
                if(iside==0 && icoord==0)
-                   sprintf(namecont,"hQxc2_%i",i);
+                 snprintf(namecont,100,"hQxc2_%i",i);
                else if(iside==1 && icoord==0)
-                   sprintf(namecont,"hQxa2_%i",i);
+                 snprintf(namecont,100,"hQxa2_%i",i);
                else if(iside==0 && icoord==1)
-                   sprintf(namecont,"hQyc2_%i",i);
+                 snprintf(namecont,100,"hQyc2_%i",i);
                else if(iside==1 && icoord==1)
-                   sprintf(namecont,"hQya2_%i",i);
+                 snprintf(namecont,100,"hQya2_%i",i);
 
                cont = (AliOADBContainer*) foadb->Get(namecont);
                if(!cont){
@@ -1214,13 +1215,13 @@ void AliAnalysisTaskVnV0::OpenInfoCalbration(Int_t run){
 
                //for v3
                if(iside==0 && icoord==0)
-                   sprintf(namecont,"hQxc3_%i",i);
+                 snprintf(namecont,100,"hQxc3_%i",i);
                else if(iside==1 && icoord==0)
-                   sprintf(namecont,"hQxa3_%i",i);
+                 snprintf(namecont,100,"hQxa3_%i",i);
                else if(iside==0 && icoord==1)
-                   sprintf(namecont,"hQyc3_%i",i);
+                 snprintf(namecont,100,"hQyc3_%i",i);
                else if(iside==1 && icoord==1)
-                   sprintf(namecont,"hQya3_%i",i);
+                 snprintf(namecont,100,"hQya3_%i",i);
 
                cont = (AliOADBContainer*) foadb->Get(namecont);
                if(!cont){
index 7c25a0a..9223ad1 100644 (file)
@@ -157,14 +157,14 @@ void AliFlowVZEROResults::AddSpecies(const char *name,Int_t nXbin,const Double_t
   }
 
   char nameHisto[200];
-  char title[200];
+  char title[300];
   for(Int_t i=0; i < ncomb;i++){
-    sprintf(nameHisto,"%s_%s_%i",GetName(),name,i);
-    sprintf(title,"%s",name);
+    snprintf(nameHisto,200,"%s_%s_%i",GetName(),name,i);
+    snprintf(title,300,"%s",name);
     Int_t ncombTemp = i;
     for(Int_t j=0;j < GetNvar();j++){
       Int_t ibin = ncombTemp%(*fNbinVar)[j];
-      sprintf(title,"%s_%04.1f<%s<%04.1f",title,(*fXmin)[j] + ((*fXmax)[j]-(*fXmin)[j])/(*fNbinVar)[j]*ibin,fNameVar->At(j)->GetName(),(*fXmin)[j] + ((*fXmax)[j]-(*fXmin)[j])/(*fNbinVar)[j]*(ibin+1));
+      snprintf(title,300,"%s_%04.1f<%s<%04.1f",title,(*fXmin)[j] + ((*fXmax)[j]-(*fXmin)[j])/(*fNbinVar)[j]*ibin,fNameVar->At(j)->GetName(),(*fXmin)[j] + ((*fXmax)[j]-(*fXmin)[j])/(*fNbinVar)[j]*(ibin+1));
       ncombTemp /= (*fNbinVar)[j];
     }
 
@@ -237,7 +237,7 @@ TProfile *AliFlowVZEROResults::GetV2(Int_t species,Float_t x[]) const{
 
 TProfile *AliFlowVZEROResults::GetV2(Int_t species,Float_t xMin[],Float_t xMax[]) const{
   if(GetNvar()){
-    char title[200];
+    char title[300];
     Int_t ncomb = 1;
     for(Int_t i=0;i < GetNvar();i++){
       ncomb *= (*fNbinVar)[i];
@@ -247,7 +247,7 @@ TProfile *AliFlowVZEROResults::GetV2(Int_t species,Float_t xMin[],Float_t xMax[]
     TProfile *temp = new TProfile(*htemplate);
     temp->SetName("histo");
     temp->Reset();
-    sprintf(title,"%i_",species);
+    snprintf(title,300,"%i_",species);
     for(Int_t i=0;i < GetNvar();i++){
       Int_t imin = GetBin(i,xMin[i]);
       if(imin < 0) imin = 0;
@@ -255,7 +255,7 @@ TProfile *AliFlowVZEROResults::GetV2(Int_t species,Float_t xMin[],Float_t xMax[]
       Int_t imax = GetBin(i,xMax[i]);
       if(imax < imin) imax = imin;
       else if(imax >= (*fNbinVar)[i]) imax = (*fNbinVar)[i]-1;
-      sprintf(title,"%s_%04.1f<%s<%04.1f",title,
+      snprintf(title,300,"%s_%04.1f<%s<%04.1f",title,
                 (*fXmin)[i] + ((*fXmax)[i]-(*fXmin)[i])/(*fNbinVar)[i]*imin,
                 fNameVar->At(i)->GetName(),
                 (*fXmin)[i] + ((*fXmax)[i]-(*fXmin)[i])/(*fNbinVar)[i]*(imax+1));
index 4cbced9..efab56c 100644 (file)
@@ -1,12 +1,12 @@
 AliAnalysisTask *AddTaskVZERO(AliAnalysisManager *mgr,Bool_t ismc=kFALSE,Bool_t kV2=kTRUE,Bool_t kV3=kTRUE,Bool_t qa=kTRUE){
   char fileout[100];
-  sprintf(fileout,"outVZEROv2.root");
+  snprintf(fileout,100,"outVZEROv2.root");
   char fileout2[100];
-  sprintf(fileout2,"outVZEROv3.root");
+  snprintf(fileout2,100,"outVZEROv3.root");
   char fileout3[100];
-  sprintf(fileout3,"outVZEROmc.root");
+  snprintf(fileout3,100,"outVZEROmc.root");
   char fileout4[100];
-  sprintf(fileout4,"outVZEROqa.root");
+  snprintf(fileout4,100,"outVZEROqa.root");
 
   //get the current analysis manager
   //  AnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
@@ -22,7 +22,7 @@ AliAnalysisTask *AddTaskVZERO(AliAnalysisManager *mgr,Bool_t ismc=kFALSE,Bool_t
 
   //========= Add tender to the ANALYSIS manager and set default storage =====
   char mytaskName[100];
-  sprintf(mytaskName,"AliAnalysisTaskVnV0.cxx"); 
+  snprintf(mytaskName,100,"AliAnalysisTaskVnV0.cxx"); 
 
   AliAnalysisTaskVnV0 *task = new AliAnalysisTaskVnV0(mytaskName);
   task->SetV2(kV2);
@@ -57,4 +57,3 @@ AliAnalysisTask *AddTaskVZERO(AliAnalysisManager *mgr,Bool_t ismc=kFALSE,Bool_t
 
   return task;
 }
-
index 3257afd..747d283 100644 (file)
@@ -1,9 +1,9 @@
 extractFlowVZERO(Int_t icentr,Int_t spec,Int_t arm=2,Bool_t isMC=kFALSE){
   // NUA correction currently are missing
   char name[100];
-  sprintf(name,"outVZEROv%i.root",arm);
+  snprintf(name,100,"outVZEROv%i.root",arm);
   TFile *fo = new TFile(name);
-  sprintf(name,"contVZEROv%i",arm);
+  snprintf(name,100,"contVZEROv%i",arm);
   TList *cont = (TList *) fo->Get(name);
 
   Float_t xMin[5] = {icentr,-1,0,-10,0};
@@ -63,9 +63,9 @@ extractFlowVZERO(Int_t icentr,Int_t spec,Int_t arm=2,Bool_t isMC=kFALSE){
   pp2->Draw("SAME");
 
   if(arm == 2 && isMC){
-    sprintf(name,"outVZEROmc.root");
+    snprintf(name,100,"outVZEROmc.root");
     fo = new TFile(name);
-    sprintf(name,"contVZEROmc");
+    snprintf(name,100,"contVZEROmc");
     cont = (TList *) fo->Get(name);
     AliFlowVZEROResults *c = (AliFlowVZEROResults *) cont->At(0);
     c->GetV2(spec,xMin,xMax)->Draw("SAME");