Beispiel #1
0
//_________________________________________________________________________________________________
void Normalize(AliMergeableCollection& hc)
{
  TObjArray* a = hc.SortAllIdentifiers();
  TIter nextId(a);
  TObjString* sid;
  
  while ( ( sid = static_cast<TObjString*>(nextId()) ) )
  {
    std::cout << sid->String() << std::endl;
    
    if ( !sid->String().Contains("HITS") ) continue;
    
    TObjArray* parts = sid->String().Tokenize("/");
    TString npadsId("/");
    
    npadsId += static_cast<TObjString*>(parts->At(0))->String();
    npadsId += "/NPADS";
    
    delete parts;
    
    std::cout << npadsId << std::endl;
    
    TList* list = hc.CreateListOfObjectNames(sid->String().Data());
    TIter nextObject(list);
    TObjString* sobject;
    while ( ( sobject = static_cast<TObjString*>(nextObject())) )
    {
      std::cout << "     " << sobject->String() << std::endl;
    }
    
    delete list;
  }
  
  delete a;
}
void MergeFlowd() 
{
	TGrid *alien = TGrid::Connect("alien");
	if (alien->IsZombie())
	{
		delete alien;
		cout << "Fatal: Alien is a zombie!" << endl;
		return;
	}

  Int_t runlist[] = {                                                               // Counter
    /*170309, 170308, 170306, 170270, 170269, 170268, 170230, 170228,*/ 170204, 170203, // 10
    170193, 170163, 170159, 170155, 170081, 170027, 169859, 169858, 169855, 169846, // 20
    169838, 169837, 169835, 169417, 169415, 169411, 169238, 169167, 169160, 169156, // 30
    169148, 169145, 169144, 169138, 169094, 169091, 169035, 168992, 168988, 168826, // 40
    168777, 168514, 168512, 168511, 168467, 168464, 168460, 168458, 168362, 168361, // 50
    168342, 168341, 168325, 168322, 168311, 168310, 167988, 167987                  // 58
  };	

  TFileMerger merger;
  TString dataBaseDir = "/alice/cern.ch/user/m/mpuccio/Flowd_PbPb2011/output/000";
  merger.OutputFile("FileMerger.root");
  for (int iRun = 0; iRun < 1; ++iRun)
  {
  	TString runDir = Form("%s%i",dataBaseDir.Data(),runlist[iRun]);
  	TGridResult *res = alien->Command(Form("find %s */mpuccio_Flowd.root",runDir.Data()));
  	TIter iter(res);
  	TMap *map;
  	while ((map = (TMap*)iter())) 
  	{
  		TObjString *obj = dynamic_cast<TObjString*>(map->GetValue("turl"));
  		if (!obj || !obj->String().Length())
  		{
  			delete res;
  			break;
  		}

  		TFile *f = TFile::Open(obj->String().Data());
  		if (!f->IsOpen())
  		{
  			cout << "File " << obj->String().Data() << " has some problems..." << endl;
  			continue;
  		}
  		merger.AddFile(f);
  		merger.PartialMerge();
  		f->Close();
  	}
  }
  merger.Merge();
  merger.Write();
}
Beispiel #3
0
//_____________________________________________________________________________
void FitMacro( char* what ="pt",const char* printWhat = "", int debug =0 )
{

    AliLog::SetGlobalDebugLevel(debug);

    Bool_t rawcount = kFALSE;
    Bool_t clean = kFALSE;
    Bool_t print = kFALSE;

    TObjArray* sprint = TString(printWhat).Tokenize(",");
    
    //Set bool
    if(sprint->FindObject("rawcount")) rawcount =kTRUE;
    if(sprint->FindObject("clean")) clean       =kTRUE;
    if(sprint->FindObject("print")) print       =kTRUE;

   //General conf.
    TObjArray* whatArray= TString(what).Tokenize(",");
    TIter nextWhat(whatArray);
    TObjString* swhat;
    
    // main object
    AliAnalysisMuMu analysis(sfile,sasso,sasso2,beamYear);

    // Clean   
    if(clean) analysis.CleanAllSpectra();    

    //_____ Fit 
    while ( ( swhat = static_cast<TObjString*>(nextWhat()) ) )
    {
        if(swhat->String().Contains("integrated")) analysis.Jpsi(swhat->String().Data(),"",kFALSE,kFALSE);

        else analysis.Jpsi(swhat->String().Data(),"BENJ",kFALSE,kFALSE);
    }

    // analysis.PrintNofParticle("PSI","NofJPsi","YVSPT",kFALSE);
    // analysis.PrintNofParticle("PSI","NofJPsi","Y",kFALSE);
    if(print && what == "pt") analysis.PrintNofParticle("PSI","NofJPsi","PT",kFALSE);
    if(print && what == "y") analysis.PrintNofParticle("PSI","NofJPsi","Y",kFALSE);
    if(print && what == "integrated") analysis.PrintNofParticle("PSI","NofJPsi","INTEGRATED",kFALSE);
    if(print && what == "yvspt") analysis.PrintNofParticle("PSI","NofJPsi","YVSPT",kFALSE);

    if(rawcount){
        analysis.ComputeDimuonRawCount(2.8,3.4); 
        analysis.ComputeDimuonRawCount(2.1,2.8); 
    }

}
Beispiel #4
0
//___________________________________________________________
Bool_t FindDependentPackages(){
  // Find packages where aliroot depends on
  // Method is the following: the dependencies are on a webpage on alimonitor
  // we download file and try to find the aliroot expression in the file. The line
  // we read into a string. The we tokenize the string and look for the expression VO_ALICE@ROOT::
  // Then we have all information we need
  const char *wd = gSystem->pwd(); 
  gSystem->cd("/tmp");
  gSystem->Exec("wget http://alimonitor.cern.ch/packages");
  TString setting = gSystem->GetFromPipe(Form("cat index.html | grep VO_ALICE@AliRoot::%s", aliroot_version.Data()));
  gSystem->Exec("rm index.html");
  gSystem->cd(wd);
  if(!setting.Length()) return kFALSE;
  TObjArray *tokens = setting.Tokenize(";");
  TIter tokiter(tokens);
  TObjString *os = NULL;
  while((os = dynamic_cast<TObjString *>(tokiter()))){
    TString &mys = os->String();
    if(!mys.Contains("VO_ALICE@ROOT")) continue;
    mys.ReplaceAll("VO_ALICE@ROOT::", "");
    mys.ReplaceAll("&quot","");
    root_version = mys;
    break;
  }
  // print results:
  printf("Found Packages for Analysis:\n");
  printf("=====================================\n");
  printf("ALIROOT: %s\n", aliroot_version.Data());
  printf("ROOT:    %s\n", root_version.Data());
  printf("\n");
  return kTRUE;
}
Beispiel #5
0
TObjArray* findClassesForAlias(THashList &list, const char* aliasName)
{

    TObjArray* matchingTrClasses = new TObjArray(2);
    TIter iter(&list);
    TNamed *n = 0;
    iter.Reset();
    while((n = dynamic_cast<TNamed*>(iter.Next()))){
	TString aliasList(n->GetTitle());
	if(aliasList.Contains(aliasName)){
	    TObjArray* arrAliases = aliasList.Tokenize(',');
	    Int_t nAliases = arrAliases->GetEntries();
	    for(Int_t i=0; i<nAliases; i++){
		TObjString *alias = (TObjString*) arrAliases->At(i);
		alias->Print(0);
		if(alias->String()==TString(aliasName)){
		    TObjString *trClass = new TObjString(n->GetName());
		    matchingTrClasses->Add(trClass);
		}
	    }
	}
    }

    return matchingTrClasses;
}
Beispiel #6
0
void OccupancyAscii2OCDB(Int_t runNumber,
                         TObjArray& filenames,
                         const char* ocdbpath,
                         const char* comment)
{
    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
    AliCDBManager::Instance()->SetRun(runNumber);
    AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/OccupancyMap",ocdbpath);
    AliMpCDB::LoadAll();

    AliMUON2DMap occupancy(kTRUE);

    TObjString* str;
    TIter next(&filenames);
    while ( ( str = static_cast<TObjString*>(next()) ) )
    {
        TString data;
        ReadOccupancyFile(str->String().Data(),data);

        AliMUONTrackerIO::DecodeOccupancy(data.Data(),occupancy);
    }

    if (occupancy.GetSize())
    {
        AliCDBId id("MUON/Calib/OccupancyMap",runNumber,runNumber);

        AliCDBMetaData metaData;
        metaData.SetBeamPeriod(0);
        metaData.SetResponsible("MUON TRK");
        metaData.SetComment(comment);

        AliCDBManager::Instance()->Put(&occupancy,id,&metaData);
    }
}
Beispiel #7
0
//______________________________________________________________________________
void ReadIntegers(const char* filename, std::vector<int>& integers)
{
  /// Read integers from filename, where integers are either
  /// separated by "," or by return carriage
  ifstream in(gSystem->ExpandPathName(filename));
  int i;

  char line[10000];

  in.getline(line,10000,'\n');

  TString sline(line);

  if (sline.Contains(","))
  {
    TObjArray* a = sline.Tokenize(",");
    TIter next(a);
    TObjString* s;
    while ( ( s = static_cast<TObjString*>(next()) ) )
    {
      integers.push_back(s->String().Atoi());
    }
  }
  else
  {
    integers.push_back(sline.Atoi());

    while ( in >> i )
    {
      integers.push_back(i);
    }
  }

  std::sort(integers.begin(),integers.end());
}
Beispiel #8
0
//___________________________________________________
void KVClassFactory::WritePreProc(ofstream & file)
{
   //Write pre-processor directives in file
   //i.e. '#ifndef __TOTO_H' etc.
   //If this class has inheritance, we add '#include "base_class.h"' for each of the base classes.
   //and any other include files added using AddHeaderIncludeFile

   TString tmp = fClassName;
   tmp.ToUpper();
   tmp.Prepend("__");
   tmp.Append("_H");
   file << "#ifndef " << tmp.Data() << endl;
   file << "#define " << tmp.Data() << "\n" << endl;
   //base class(es) ?
   if (fHasBaseClass) {
		if(WithMultipleBaseClasses()){
			fBaseClassName.Begin(",");
			while( !fBaseClassName.End() )
				file << "#include \"" << fBaseClassName.Next(kTRUE) << ".h\"" << endl;
			file << endl;
		}
		else
	file << "#include \"" << fBaseClassName.Data() << ".h\"\n" << endl;
   }
   if( fHeadInc.GetSize() ){
      TIter next(&fHeadInc); TObjString* str;
      while( (str = (TObjString*)next()) ){
         file << "#include \"" << str->String().Data() << "\"\n" << endl;
      }
   }
}
Beispiel #9
0
TString RunDBInterface::Get(TString key){
  TObjString* val = (TObjString*)(GetMap()->GetValue(key.Data()));
  if (!val) {
    cout << "key not found: " << key.Data() << endl;
    return TString();
  }
  return val->String();
}
Beispiel #10
0
bool GetData(TObjArray &in, TString &out, int pos){
        //
        // Helper function reading data string
        //
        TObjString *entry = dynamic_cast<TObjString *>(in.At(pos));
        if(!entry){
                printf("Entry at pos %d not a string\n", pos);
                return false;
        }
        out = entry->String();
        return true;
}
void cacheGeometry( const Char_t *tag, const Char_t *addons )
{  
  TFile *file = new TFile(Form("%s.root",tag));
  if ( file->IsZombie() || nocache )
    {

      delete file;

      const Char_t *path  = ".:./StarVMC/Geometry/macros/:$STAR/StarVMC/Geometry/macros/";
      Char_t *file = gSystem->Which(path,"loadStarGeometry.C",kReadPermission);
      cout << "Loading macro: " << file << endl;
      gROOT -> ProcessLine(Form(".L %s",file));

      // Load development geometry
      //      loadDevStarGeometry(tag);
      loadStarGeometry(tag);

      TString    addOns = addons;
      TObjArray *array  = addOns.Tokenize(" ,;");
      
      for ( Int_t i = 0; i<array->GetEntries(); i++ )
	{
	  TObjString *str = (TObjString *)array->At(i);
	  cout << "Adding module " << str->String().Data() << endl;
	  addModule ( str->String() );
	}
      

      // Close the geometry
      gGeoManager->CloseGeometry();


      ColorScheme();
      gGeoManager->Export(Form("%s.root",tag));
    }
  delete file;
  // gROOT -> Reset();

}
Beispiel #12
0
void DecodeRunlist(const TString &val){
        //
        // Tokenize run list
        //
        TObjArray *runstrings = val.Tokenize(",");
        TObjString *os;
        TString runstr;
        TIter runIter(runstrings);
        g_runlist.Set(runstrings->GetEntries());
        int nruns(0);
        while((os = dynamic_cast<TObjString *>(runIter()))){
                runstr = os->String();
                g_runlist[nruns++] = runstr.Atoi();
        }
        delete runstrings;
}
Beispiel #13
0
//_____________________________________________________________________________
Int_t BdataLoc::CheckConfigureParams( const TObjArray* params, Int_t start )
{
  // Check given parameters of call to Configure for obvious errors.
  // Internal helper function.

  // Invalid call parameter?
  if( !params || start < 0 || start + GetNparams() > params->GetLast()+1 )
    return 1;

  // Invalid parameter array data?
  for( Int_t ip = start; ip < start + GetNparams(); ++ip ) {
    if( params->At(ip)->IsA() != TObjString::Class() )
      return 2;
    TObjString* os = static_cast<TObjString*>(params->At(ip));
    if( !os )
      return 3;
    if( os->String().IsNull() )
      return 4;
  }
  return 0;
}
Beispiel #14
0
//_____________________________________________________________________________
void FnormMacro(
              const char* filename="../LHC15g.MuMu.1.root",
              const char* associatedSimFileName="",
              const char* associatedSimFileName2="",
              const char* beamYear="PbPb2011",const int DebugLevel =0)
{


  // //_____ FNorm
    // analysis.ComputeIntFnormFromCounters("",kFALSE);
    // //_____ 


  AliAnalysisMuMu ana(filename,associatedSimFileName,associatedSimFileName2,beamYear);
  AliLog::SetGlobalDebugLevel(DebugLevel);


  if (!ana.OC() || !ana.CC())
  {
    AliError("No mergeable/counter collection. Consider Upgrade()");
    return ;
  }
  else
  {
    cout <<      " ================================================================ " << endl;
    cout <<      "                  Compute Mean Fnorm From Counters                " << endl;
    cout <<      " ================================================================ " << endl;
  }


  // Get configuration settings
  TObjArray* eventTypeArray   = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kEventSelectionList,IsSimulation());
  TObjArray* triggerMuonArray = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kDimuonTriggerList,IsSimulation());
  TObjArray* triggerMBArray   = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kMinbiasTriggerList,IsSimulation());
  TObjArray* centralityArray  = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kCentralitySelectionList, IsSimulation());

  // Iterator for loops
  TIter nextTriggerMuon(triggerMuonArray);
  TIter nextTriggerMB(triggerMBArray);
  TIter nextEventType(eventTypeArray);
  TIter nextCentrality(centralityArray);

  // Strings
  TObjString* striggerMuon;
  TObjString* striggerMB;
  TObjString* seventType;
  TObjString* scentrality;

  //Pointers on histo
  TH1*h(0x0);
  TH1*h1(0x0);
  TH1*h2(0x0);
  
  Double_t FNormOverStat(0.);
  Double_t FNormTotError(0.);
  Double_t FNormTotErrorInverse(0.);
  Double_t FNormTotErrorSys(0.);
  Double_t Norm(1.);

  Int_t n =0; //counter

  nextEventType.Reset();
  // Loop on each envenType (see MuMuConfig)
  //==============================================================================
  while ( ( seventType = static_cast<TObjString*>(nextEventType())) )
  {
    AliDebug(1,Form("EVENTTYPE %s",seventType->String().Data()));
    nextTriggerMuon.Reset();
    // Loop on each Muon trigger (see MuMuConfig)
    //==============================================================================
    while ( ( striggerMuon = static_cast<TObjString*>(nextTriggerMuon())) )
    {
      AliDebug(1,Form("-MUON TRIGGER %s",striggerMuon->String().Data()));
      nextTriggerMB.Reset();
      // Loop on each MB trigger (not the ones in MuMuConfig but the ones set)
      //==============================================================================
      while ( ( striggerMB = static_cast<TObjString*>(nextTriggerMB())) )
      {
        AliDebug(1,Form("-- MB PAIRCUT %s",striggerMB->String().Data()));
        nextCentrality.Reset();
        // Loop on each centrality
        //==============================================================================
        while ( ( scentrality = static_cast<TObjString*>(nextCentrality()) ) )
        {
          TString id(Form("/FNORM-%s/%s/%s/PbPb",striggerMuon->String().Data(),seventType->String().Data(),scentrality->String().Data())); // Path where are saved histos in the mergeable collection

          h = OC()->Histo(id.Data(),Form("hFNormIntVSrun_%s",striggerMB->String().Data()));
          if (!h)
          {
            AliDebug(1,Form("Can't get histo %s/hFNormIntVSrun_%s",id.Data(),striggerMB->String().Data()));
            continue;
          }

          h1 = OC()->Histo(id.Data(),Form("hFNormInt_%s",striggerMB->String().Data()));
          if (!h1)
          {
            AliDebug(1,Form("Can't get histo %s/hFNormInt_%s",id.Data(),striggerMB->String().Data()));
            continue;
          }

          h2 = OC()->Histo(id.Data(),Form("hFNormIntSys_%s",striggerMB->String().Data()));
          if (!h2)
          {
            AliDebug(1,Form("Can't get histo %s/hFNormIntSys_%s",id.Data(),striggerMB->String().Data()));
            continue;
          }

          cout << Form("Fnorm from %s/%s added",id.Data(),h1->GetName()) << endl;
          cout << Form("Fnorm from %s/%s added",id.Data(),h2->GetName()) << endl;

          // Normalise with respect to centrality
          if (scentrality->String().Contains("V0M_00.00_90.00"))
          {
            Norm = 1.;

            FNormOverStat        = FNormOverStat + (Norm*h1->GetBinContent(1)) /(TMath::Power(Norm *h1->GetBinError(1),2.));
            FNormTotError        = FNormTotError + 1./(TMath::Power(Norm*h1->GetBinError(1),2.));
            FNormTotErrorInverse = FNormTotErrorInverse + 1./(TMath::Power(Norm*h1->GetBinError(1),-2.));
            FNormTotErrorSys     = FNormTotErrorSys + 1./(TMath::Power(Norm*h2->GetBinContent(1),2.));

            cout <<"--- Quantities from histogram             :                " << endl;
            cout <<" - Norm                                   = " << Norm << endl;
            cout <<" - FNormHisto                             = " << h1->GetBinContent(1) << endl;
            cout <<" - FNormHistoError                        = " << h1->GetBinError(1) << endl;
            cout <<" - FNormHistoSys                          = " << h2->GetBinContent(1) << endl;
            cout <<"--- Quantities (normalized) from histogram:                " << endl;
            cout <<" - FNormHisto                             = " << Norm*h1->GetBinContent(1) << endl;
            cout <<" - FNormHistoError                        = " << Norm*h1->GetBinError(1) << endl;
            cout <<" - FNormHistoSys                          = " << Norm*h2->GetBinContent(1) << endl;
            cout <<"--- After addition                        :                 " << endl;
            cout <<" - FNormOverStat                          = " << FNormOverStat << endl;
            cout <<" - FNormTotError                          = " << FNormTotError << endl;
            cout <<" - FNormTotErrorInverse                   = " << FNormTotErrorInverse << endl;
            cout <<" - FNormTotErrorSys                       = " << FNormTotErrorSys << endl;
            }
          else if (scentrality->String().Contains("V0M_10.00_50.00"))
          {
            Norm = (1./0.4)*0.445*0.9;

            FNormOverStat        = FNormOverStat + (Norm*h1->GetBinContent(1)) /(TMath::Power(Norm *h1->GetBinError(1),2.));
            FNormTotError        = FNormTotError + 1./(TMath::Power(Norm*h1->GetBinError(1),2.));
            FNormTotErrorInverse = FNormTotErrorInverse + 1./(TMath::Power(Norm*h1->GetBinError(1),-2.));
            FNormTotErrorSys     = FNormTotErrorSys + 1./(TMath::Power(Norm*h2->GetBinContent(1),2.));

            cout <<"--- Quantities from histogram             :                " << endl;
            cout <<" - Norm                                   = " << Norm << endl;
            cout <<" - FNormHisto                             = " << h1->GetBinContent(1) << endl;
            cout <<" - FNormHistoError                        = " << h1->GetBinError(1) << endl;
            cout <<" - FNormHistoSys                          = " << h2->GetBinContent(1) << endl;
            cout <<"--- Quantities (normalized) from histogram:                " << endl;
            cout <<" - FNormHisto                             = " << Norm*h1->GetBinContent(1) << endl;
            cout <<" - FNormHistoError                        = " << Norm*h1->GetBinError(1) << endl;
            cout <<" - FNormHistoSys                          = " << Norm*h2->GetBinContent(1) << endl;
            cout <<"--- After addition                        :                 " << endl;
            cout <<" - FNormOverStat                          = " << FNormOverStat << endl;
            cout <<" - FNormTotError                          = " << FNormTotError << endl;
            cout <<" - FNormTotErrorInverse                   = " << FNormTotErrorInverse << endl;
            cout <<" - FNormTotErrorSys                       = " << FNormTotErrorSys << endl;

          }
          else if (scentrality->String().Contains("V0M_00.00_07.50"))
          {
            Norm = (1./0.075)*0.443*0.9;

            FNormOverStat        = FNormOverStat + (Norm*h1->GetBinContent(1)) /(TMath::Power(Norm *h1->GetBinError(1),2.));
            FNormTotError        = FNormTotError + 1./(TMath::Power(Norm*h1->GetBinError(1),2.));
            FNormTotErrorInverse = FNormTotErrorInverse + 1./(TMath::Power(Norm*h1->GetBinError(1),-2.));
            FNormTotErrorSys     = FNormTotErrorSys + 1./(TMath::Power(Norm*h2->GetBinContent(1),2.));

            cout <<"--- Quantities from histogram             :                " << endl;
            cout <<" - Norm                                   = " << Norm << endl;
            cout <<" - FNormHisto                             = " << h1->GetBinContent(1) << endl;
            cout <<" - FNormHistoError                        = " << h1->GetBinError(1) << endl;
            cout <<" - FNormHistoSys                          = " << h2->GetBinContent(1) << endl;
            cout <<"--- Quantities (normalized) from histogram:                " << endl;
            cout <<" - FNormHisto                             = " << Norm*h1->GetBinContent(1) << endl;
            cout <<" - FNormHistoError                        = " << Norm*h1->GetBinError(1) << endl;
            cout <<" - FNormHistoSys                          = " << Norm*h2->GetBinContent(1) << endl;
            cout <<"--- After addition                        :                 " << endl;
            cout <<" - FNormOverStat                          = " << FNormOverStat << endl;
            cout <<" - FNormTotError                          = " << FNormTotError << endl;
            cout <<" - FNormTotErrorInverse                   = " << FNormTotErrorInverse << endl;
            cout <<" - FNormTotErrorSys                       = " << FNormTotErrorSys << endl;

          }
          else
          {
            AliError("Check this method for centrality selection !");
            return;
          }

          n++;
        }
      }
    }
  }

cout << "Mean FNorm  computed from " << n <<" results = " << FNormOverStat/FNormTotError << " +/- " <<
    TMath::Sqrt(FNormTotErrorInverse) << " (stat) +/-" << TMath::Sqrt(FNormTotErrorSys) << " (sys) " <<endl;

delete triggerMuonArray ;
delete triggerMBArray ;
delete eventTypeArray ;
delete centralityArray ;
}
Beispiel #15
0
void MultiHistoOverlap(TString namesandlabels, Int_t nOfFiles, const TString& outDir="./"){

  gROOT->Reset();
  gROOT->ProcessLine(".L tdrstyle.C"); 
  gROOT->ProcessLine("setTDRStyle()");
 
 //  gSystem->Load("libRooFit");
 //  using namespace RooFit;
 // preamble
  TPaveText *cmsprel = new TPaveText(0.19, 0.95, 0.95, 0.99, "NDC");
  cmsprel->SetTextSize(0.03);
  cmsprel->SetTextFont(42);
  cmsprel->SetFillColor(0);
  cmsprel->SetBorderSize(0);
  cmsprel->SetMargin(0.01);
  cmsprel->SetTextAlign(12); // align left
  TString text = "CMS Preliminary 2011";
  cmsprel->AddText(0.0, 0.5,text);  
  TString text2 = "#sqrt{s} = 7 TeV  |#eta_{#mu}|<2.4";             
  cmsprel->AddText(0.8, 0.5, text2);


  TList* FileList  = new TList();  
  TList* LabelList = new TList();    
  TObjArray *nameandlabelpairs = namesandlabels.Tokenize(",");  
  for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) {    
    TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("=");       
    if(aFileLegPair->GetEntries() == 2) {      
      FileList->Add( TFile::Open(aFileLegPair->At(0)->GetName())  ); 
      LabelList->Add( aFileLegPair->At(1) );    
    } else {      
      std::cout << "Please give file name and legend entry in the following form:\n" 		<< " filename1=legendentry1,filename2=legendentry2\n";          
    }  
  }
  

 Int_t NOfFiles =  FileList->GetSize();  
 if ( NOfFiles!=nOfFiles ){
   std::cout<<"&MSG-e: NOfFiles = "<<nOfFiles<<std::endl;  
   return;
 }  
 

 std::vector<TString> LegLabels;
 LegLabels.reserve(nOfFiles);    
 for(Int_t j=0; j < nOfFiles; j++) {       
   TObjString* legend = (TObjString*)LabelList->At(j);    
   LegLabels.push_back(legend->String());
   std::cout<<"LegLabels["<<j<<"]"<<LegLabels[j]<<std::endl;  
 }

 TLegend *leg=0; 

 TCanvas* c0 = new TCanvas("c0", "c0",50, 20, 800,600);
 TCanvas* c1 = new TCanvas("c1", "c1",50, 20, 800,600);
 TCanvas* c2 = new TCanvas("c2", "c2",50, 20, 800,600);
 TCanvas* c3 = new TCanvas("c3", "c3",50, 20, 800,600);
 TCanvas* c4 = new TCanvas("c4", "c4",50, 20, 800,600);
 TCanvas* c5 = new TCanvas("c5", "c5",50, 20, 1200,800);
 TCanvas* c6 = new TCanvas("c6", "c6",50, 20, 1200,800);

 TCanvas* c0s = new TCanvas("c0s", "c0s",50, 20, 800,600);
 TCanvas* c1s = new TCanvas("c1s", "c1s",50, 20, 800,600);
 TCanvas* c2s = new TCanvas("c2s", "c2s",50, 20, 800,600);
 TCanvas* c3s = new TCanvas("c3s", "c3s",50, 20, 800,600);

 TCanvas* cFit = new TCanvas("cFit", "cFit",50, 20, 1600, 800);


 //----------------- CANVAS C0 --------------//
 c0->SetFillColor(0);  
 c0->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);
 
// Mass VS muon phi plus -------------------------------
 TH1D *histoMassVsPhiPlus[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoMassVsPhiPlus[j] = (TH1D*)fin->Get("MassVsPhiPlus/allHistos/meanHisto"))){
     histoMassVsPhiPlus[j]->SetLineStyle(linestylelist[j]);
     histoMassVsPhiPlus[j]->SetMarkerColor(colorlist[j]);
     histoMassVsPhiPlus[j]->SetLineColor(colorlist[j]);
     histoMassVsPhiPlus[j]->SetMarkerStyle(markerstylelist[j]); 
     //     histoMassVsPhiPlus[j]->SetMarkerSize(0.75);
     if ( j == 0 ) {
       histoMassVsPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)");
       histoMassVsPhiPlus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)");
       //       histoMassVsPhiPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
       histoMassVsPhiPlus[j]->GetYaxis()->SetRangeUser(90.0,91.5);
       histoMassVsPhiPlus[j]->GetXaxis()->SetRangeUser(-3.14,3.14);
       histoMassVsPhiPlus[j]->Draw();
     } else {
       histoMassVsPhiPlus[j]->Draw("SAME");
     }
     leg->AddEntry(histoMassVsPhiPlus[j],LegLabels[j],"PL");  
   }
 }
 //cmsprel->Draw("same");
 leg->Draw("same");
 c0->SaveAs(outDir+"MassVsPhiPlus.png"); 


 //----------------- CANVAS C1 --------------//
 c1->SetFillColor(0);  
 c1->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);
 
// Mass VS muon eta plus -------------------------------
 TH1D *histoMassVsEtaPlus[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoMassVsEtaPlus[j] = (TH1D*)fin->Get("MassVsEtaPlus/allHistos/meanHisto"))){
     histoMassVsEtaPlus[j]->SetLineStyle(linestylelist[j]);
     histoMassVsEtaPlus[j]->SetMarkerColor(colorlist[j]);
     histoMassVsEtaPlus[j]->SetLineColor(colorlist[j]);
     histoMassVsEtaPlus[j]->SetMarkerStyle(markerstylelist[j]); 
     //     histoMassVsEtaPlus[j]->SetMarkerSize(0.75);
     if ( j == 0 ) {
       histoMassVsEtaPlus[j]->GetXaxis()->SetTitle("positive muon #eta");
       histoMassVsEtaPlus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)");
       //       histoMassVsEtaPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
       histoMassVsEtaPlus[j]->GetYaxis()->SetRangeUser(90.0,91.5);
       histoMassVsEtaPlus[j]->GetXaxis()->SetRangeUser(-2.41,2.41);
       histoMassVsEtaPlus[j]->Draw();
     } else {
       histoMassVsEtaPlus[j]->Draw("SAME");
     }
     leg->AddEntry(histoMassVsEtaPlus[j],LegLabels[j],"PL");  
   }
 }
 //cmsprel->Draw("same");
 leg->Draw("same");
 c1->SaveAs(outDir+"MassVsEtaPlus.png"); 


 //----------------- CANVAS C2 --------------//
 c2->SetFillColor(0);  
 c2->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);
 
// Mass VS muon eta plus - eta minus  -------------------------------
 TH1D *histoMassVsEtaPlusMinusDiff[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoMassVsEtaPlusMinusDiff[j] = (TH1D*)fin->Get("MassVsEtaPlusMinusDiff/allHistos/meanHisto"))){
     histoMassVsEtaPlusMinusDiff[j]->SetLineStyle(linestylelist[j]);
     histoMassVsEtaPlusMinusDiff[j]->SetMarkerColor(colorlist[j]);
     histoMassVsEtaPlusMinusDiff[j]->SetLineColor(colorlist[j]);
     histoMassVsEtaPlusMinusDiff[j]->SetMarkerStyle(markerstylelist[j]); 
     //     histoMassVsEtaPlusMinusDiff[j]->SetMarkerSize(0.75);
     if ( j == 0 ) {
       histoMassVsEtaPlusMinusDiff[j]->GetXaxis()->SetTitle("#eta pos. muon  #eta neg. muon");
       histoMassVsEtaPlusMinusDiff[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)");
       //       histoMassVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(88.0,96.0);
       histoMassVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(90.0,91.5);
       histoMassVsEtaPlusMinusDiff[j]->GetXaxis()->SetRangeUser(-3,3);
       histoMassVsEtaPlusMinusDiff[j]->Draw();
     } else {
       histoMassVsEtaPlusMinusDiff[j]->Draw("SAME");
     }
     leg->AddEntry(histoMassVsEtaPlusMinusDiff[j],LegLabels[j],"PL");  
   }
 }
 //cmsprel->Draw("same");
 leg->Draw("same");
 c2->SaveAs(outDir+"MassVsEtaPlusMinusDiff.png"); 

 //----------------- CANVAS C3 --------------//
 c3->SetFillColor(0);  
 c3->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);
 
// Mass VS muon phi minus -------------------------------
 TH1D *histoMassVsPhiMinus[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoMassVsPhiMinus[j] = (TH1D*)fin->Get("MassVsPhiMinus/allHistos/meanHisto"))){
     histoMassVsPhiMinus[j]->SetLineStyle(linestylelist[j]);
     histoMassVsPhiMinus[j]->SetMarkerColor(colorlist[j]);
     histoMassVsPhiMinus[j]->SetLineColor(colorlist[j]);
     histoMassVsPhiMinus[j]->SetMarkerStyle(markerstylelist[j]); 
     //     histoMassVsPhiMinus[j]->SetMarkerSize(0.75);
     if ( j == 0 ) {
       histoMassVsPhiMinus[j]->GetXaxis()->SetTitle("negative muon #phi (rad)");
       histoMassVsPhiMinus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)");
       //       histoMassVsPhiMinus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
       histoMassVsPhiMinus[j]->GetYaxis()->SetRangeUser(90.0,91.5);
       histoMassVsPhiMinus[j]->GetXaxis()->SetRangeUser(-3.14,3.14);
       histoMassVsPhiMinus[j]->Draw();
     } else {
       histoMassVsPhiMinus[j]->Draw("SAME");
     }
     leg->AddEntry(histoMassVsPhiMinus[j],LegLabels[j],"PL");  
   }
 }
 //cmsprel->Draw("same");
 leg->Draw("same");
 c3->SaveAs(outDir+"MassVsPhiMinus.png"); 


 //----------------- CANVAS C4 --------------//
 c4->SetFillColor(0);  
 c4->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);
 
// Mass VS muon eta minus -------------------------------
 TH1D *histoMassVsEtaMinus[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoMassVsEtaMinus[j] = (TH1D*)fin->Get("MassVsEtaMinus/allHistos/meanHisto"))){
     histoMassVsEtaMinus[j]->SetLineStyle(linestylelist[j]);
     histoMassVsEtaMinus[j]->SetMarkerColor(colorlist[j]);
     histoMassVsEtaMinus[j]->SetLineColor(colorlist[j]);
     histoMassVsEtaMinus[j]->SetMarkerStyle(markerstylelist[j]); 
     //     histoMassVsEtaMinus[j]->SetMarkerSize(0.75);
     if ( j == 0 ) {
       histoMassVsEtaMinus[j]->GetXaxis()->SetTitle("negative muon #eta");
       histoMassVsEtaMinus[j]->GetYaxis()->SetTitle("M_{#mu#mu} (GeV)");
       //       histoMassVsEtaMinus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
       histoMassVsEtaMinus[j]->GetYaxis()->SetRangeUser(90.0,91.5);
       histoMassVsEtaMinus[j]->GetXaxis()->SetRangeUser(-2.41,2.41);
       histoMassVsEtaMinus[j]->Draw();
     } else {
       histoMassVsEtaMinus[j]->Draw("SAME");
     }
     leg->AddEntry(histoMassVsEtaMinus[j],LegLabels[j],"PL");  
   }
 }
 //cmsprel->Draw("same");
 leg->Draw("same");
 c4->SaveAs(outDir+"MassVsEtaMinus.png"); 

 //----------------- CANVAS C5 --------------//
 c5->SetFillColor(0);  
 c5->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);
 
 // Mass VS muon phi plus -------------------------------
 TH2D *histoMassVsEtaPhiPlus[nOfFiles];

 TStyle *newStyle;
 newStyle->SetPalette(1);
 // newStyle->SetOptTitle(1);

 Double_t zMin(82.);
 Double_t zMax(96.);
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoMassVsEtaPhiPlus[j] = (TH2D*)fin->Get("MassVsEtaPhiPlus/allHistos/meanHisto"))){
     if ( j == 0 ) {
       histoMassVsEtaPhiPlus[j]->SetTitle(LegLabels[j]);
       histoMassVsEtaPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)");
       histoMassVsEtaPhiPlus[j]->GetYaxis()->SetTitle("positive muon #eta");
       zMin = histoMassVsEtaPhiPlus[j]->GetMinimum();
       zMax = histoMassVsEtaPhiPlus[j]->GetMaximum();
       histoMassVsEtaPhiPlus[j]->Draw("COLZ");
       c5->SaveAs(outDir+"MassVsEtaPhiPlus_file0.png"); 
     } else {
       histoMassVsEtaPhiPlus[j]->SetTitle(LegLabels[j]);
       histoMassVsEtaPhiPlus[j]->SetMinimum(zMin);
       histoMassVsEtaPhiPlus[j]->SetMaximum(zMax);
       histoMassVsEtaPhiPlus[j]->Draw("COLZ");
       c5->SaveAs(outDir+"MassVsEtaPhiPlus_file"+(TString)Form("%d",(Int_t)j)+".png"); 
     }

   }
 }
 //cmsprel->Draw("same");

//  //----------------- CANVAS C6 --------------//
//  c6->SetFillColor(0);  
//  c6->cd();

//  leg = new TLegend(0.50,0.25,0.90,0.40);  
//  leg->SetBorderSize(1);
//  leg->SetFillColor(0);
//  leg->SetTextFont(42);
 
//  // Mass VS muon phi minus -------------------------------
//  TH2D *histoMassVsEtaPhiMinus[nOfFiles];

//  for(Int_t j=0; j < nOfFiles; j++) {     
   
//    TFile *fin = (TFile*)FileList->At(j);    
//    if (( histoMassVsEtaPhiMinus[j] = (TH2D*)fin->Get("MassVsEtaPhiMinus/allHistos/meanHisto"))){
//      if ( j == 0 ) {
//        histoMassVsEtaPhiMinus[j]->GetXaxis()->SetTitle("negative muon #phi (rad)");
//        histoMassVsEtaPhiMinus[j]->GetYaxis()->SetTitle("negative muon #eta");
//        zMin = histoMassVsEtaPhiMinus[j]->GetMinimum();
//        zMax = histoMassVsEtaPhiMinus[j]->GetMaximum();
//        histoMassVsEtaPhiMinus[j]->Draw();
//      } else {
//        histoMassVsEtaPhiMinus[j]->SetMinimum(zMin);
//        histoMassVsEtaPhiMinus[j]->SetMaximum(zMax);
//        histoMassVsEtaPhiMinus[j]->Draw("SAME");
//      }
//      leg->AddEntry(histoMassVsEtaPhiMinus[j],LegLabels[j],"PL");  
//    }
//  }
//  //cmsprel->Draw("same");
//  leg->Draw("same");
//  c6->SaveAs(outDir+"MassVsEtaPhiMinus.png"); 

// newStyle->SetOptTitle(0);

 const Color_t colorlist_resol[7]={kBlack,kGreen,kBlue,kMagenta,kCyan,kTeal,kRed};
 const Int_t linestylelist_resol[7]={1,1,1,1,1,1,1};
 const Int_t stylelist_resol[7]={1,1,1,1,1,1,1};
 const Style_t markerstylelist_resol[7]={kOpenCircle,kOpenTriangleUp,kOpenTriangleUp,kOpenCircle,kOpenTriangleUp,kOpenCircle,kOpenTriangleUp};


//  //----------------- CANVAS C0S --------------//
//  c0s->SetFillColor(0);  
//  c0s->cd();

//  leg = new TLegend(0.50,0.25,0.90,0.40);  
//  leg->SetBorderSize(1);
//  leg->SetFillColor(0);
//  leg->SetTextFont(42);

// // Sigma VS muon phi plus -------------------------------
//  TH1D *histoSigmaVsPhiPlus[nOfFiles];
//  for(Int_t j=0; j < nOfFiles; j++) {     
   
//    TFile *fin = (TFile*)FileList->At(j);    
//    if (( histoSigmaVsPhiPlus[j] = (TH1D*)fin->Get("MassVsPhiPlus/allHistos/sigmaHisto"))){
//      histoSigmaVsPhiPlus[j]->SetLineStyle(linestylelist_resol[j]);
//      histoSigmaVsPhiPlus[j]->SetMarkerColor(colorlist_resol[j]);
//      histoSigmaVsPhiPlus[j]->SetLineColor(colorlist_resol[j]);
//      histoSigmaVsPhiPlus[j]->SetMarkerStyle(markerstylelist_resol[j]); 
//      //     histoSigmaVsPhiPlus[j]->SetMarkerSize(0.75);
//      if ( j == 0 ) {
//        histoSigmaVsPhiPlus[j]->GetXaxis()->SetTitle("positive muon #phi (rad)");
//        histoSigmaVsPhiPlus[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)");
//        //       histoSigmaVsPhiPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
//        histoSigmaVsPhiPlus[j]->GetYaxis()->SetRangeUser(0.,3.);
//        histoSigmaVsPhiPlus[j]->GetXaxis()->SetRangeUser(-3.14,3.14);
//        histoSigmaVsPhiPlus[j]->Draw();
//      } else {
//        histoSigmaVsPhiPlus[j]->Draw("SAME");
//      }
//      leg->AddEntry(histoSigmaVsPhiPlus[j],LegLabels[j],"PL");  
//    }
//  }
//  //cmsprel->Draw("same");
//  leg->Draw("same");
//  c0s->SaveAs(outDir+"SigmaVsPhiPlus.png"); 


 //----------------- CANVAS C1S --------------//
 c1s->SetFillColor(0);  
 c1s->cd();

 leg = new TLegend(0.50,0.25,0.90,0.40);  
 leg->SetBorderSize(1);
 leg->SetFillColor(0);
 leg->SetTextFont(42);

 
// Sigma VS muon eta plus -------------------------------
 TH1D *histoSigmaVsEtaPlus[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoSigmaVsEtaPlus[j] = (TH1D*)fin->Get("MassVsEtaPlus/allHistos/sigmaHisto"))){
     histoSigmaVsEtaPlus[j]->SetLineStyle(linestylelist_resol[j]);
     histoSigmaVsEtaPlus[j]->SetMarkerColor(colorlist_resol[j]);
     histoSigmaVsEtaPlus[j]->SetLineColor(colorlist_resol[j]);
     histoSigmaVsEtaPlus[j]->SetMarkerStyle(markerstylelist_resol[j]); 
     //     histoSigmaVsEtaPlus[j]->SetMarkerSize(0.75);
     if ( j == 0 ) {
       histoSigmaVsEtaPlus[j]->GetXaxis()->SetTitle("positive muon #eta");
       histoSigmaVsEtaPlus[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)");
       //       histoSigmaVsEtaPlus[j]->GetYaxis()->SetRangeUser(88.5,93.5);
       histoSigmaVsEtaPlus[j]->GetYaxis()->SetRangeUser(0.,3.);
       histoSigmaVsEtaPlus[j]->GetXaxis()->SetRangeUser(-2.41,2.41);
       histoSigmaVsEtaPlus[j]->Draw();
     } else {
       histoSigmaVsEtaPlus[j]->Draw("SAME");
     }
     leg->AddEntry(histoSigmaVsEtaPlus[j],LegLabels[j],"PL");  
   }
 }
 //cmsprel->Draw("same");
 leg->Draw("same");
 c1s->SaveAs(outDir+"SigmaVsEtaPlus.png"); 


//  //----------------- CANVAS C2S --------------//
//  c2s->SetFillColor(0);  
//  c2s->cd();

//  leg = new TLegend(0.50,0.25,0.90,0.40);  
//  leg->SetBorderSize(1);
//  leg->SetFillColor(0);
//  leg->SetTextFont(42);

// // Sigma VS muon eta plus - eta minus  -------------------------------
//  TH1D *histoSigmaVsEtaPlusMinusDiff[nOfFiles];
//  for(Int_t j=0; j < nOfFiles; j++) {     
   
//    TFile *fin = (TFile*)FileList->At(j);    
//    if (( histoSigmaVsEtaPlusMinusDiff[j] = (TH1D*)fin->Get("MassVsEtaPlusMinusDiff/allHistos/sigmaHisto"))){
//      histoSigmaVsEtaPlusMinusDiff[j]->SetLineStyle(linestylelist_resol[j]);
//      histoSigmaVsEtaPlusMinusDiff[j]->SetMarkerColor(colorlist_resol[j]);
//      histoSigmaVsEtaPlusMinusDiff[j]->SetLineColor(colorlist_resol[j]);
//      histoSigmaVsEtaPlusMinusDiff[j]->SetMarkerStyle(markerstylelist_resol[j]); 
//      //     histoSigmaVsEtaPlusMinusDiff[j]->SetMarkerSize(0.75);
//      if ( j == 0 ) {
//        histoSigmaVsEtaPlusMinusDiff[j]->GetXaxis()->SetTitle("#eta pos. muon - #eta neg. muon");
//        histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)");
//        //       histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(88.0,96.0);
//        histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(0.,3.);
//        //histoSigmaVsEtaPlusMinusDiff[j]->GetYaxis()->SetRangeUser(90.60,90.75);
//        histoSigmaVsEtaPlusMinusDiff[j]->GetXaxis()->SetRangeUser(-3.2,3.2);
//        histoSigmaVsEtaPlusMinusDiff[j]->Draw();
//      } else {
//        histoSigmaVsEtaPlusMinusDiff[j]->Draw("SAME");
//      }
//      leg->AddEntry(histoSigmaVsEtaPlusMinusDiff[j],LegLabels[j],"PL");  
//    }
//  }
//  //cmsprel->Draw("same");
//  leg->Draw("same");
//  c2s->SaveAs(outDir+"SigmaVsEtaPlusMinusDiff.png"); 


//  //----------------- CANVAS C3S --------------//
//  c3s->SetFillColor(0);  
//  c3s->cd();

//  leg = new TLegend(0.35,0.15,0.55,0.35);  
//  leg->SetBorderSize(1);
//  leg->SetFillColor(0);
//  leg->SetTextFont(42);
 
// // Sigma VS muon pT  -------------------------------
//  TH1D *histoSigmaVsPt[nOfFiles];
//  for(Int_t j=0; j < nOfFiles; j++) {     
   
//    TFile *fin = (TFile*)FileList->At(j);    
//    if (( histoSigmaVsPt[j] = (TH1D*)fin->Get("MassVsPt/allHistos/sigmaHisto"))){
//      histoSigmaVsPt[j]->SetLineStyle(linestylelist_resol[j]);
//      histoSigmaVsPt[j]->SetMarkerColor(colorlist_resol[j]);
//      histoSigmaVsPt[j]->SetLineColor(colorlist_resol[j]);
//      histoSigmaVsPt[j]->SetMarkerStyle(markerstylelist_resol[j]); 
//      //     histoSigmaVsPt[j]->SetMarkerSize(0.75);
//      if ( j == 0 ) {
//        histoSigmaVsPt[j]->GetXaxis()->SetTitle("muon p_T (GeV)");
//        histoSigmaVsPt[j]->GetYaxis()->SetTitle("#sigma(M_{#mu#mu}) (GeV)");
//        //       histoSigmaVsPt[j]->GetYaxis()->SetRangeUser(88.0,96.0);
//        histoSigmaVsPt[j]->GetYaxis()->SetRangeUser(0.,3.);
//        //histoSigmaVsPt[j]->GetYaxis()->SetRangeUser(90.60,90.75);
//        histoSigmaVsPt[j]->GetXaxis()->SetRangeUser(15.,105.);
//        histoSigmaVsPt[j]->Draw();
//      } else {
//        histoSigmaVsPt[j]->Draw("SAME");
//      }
//      leg->AddEntry(histoSigmaVsPt[j],LegLabels[j],"PL");  
//    }
//  }
//  //cmsprel->Draw("same");
//  leg->Draw("same");
//  c3s->SaveAs(outDir+"SigmaVsPt.png"); 

 //----------------- CANVAS CFIT --------------//
 cFit->SetFillColor(0);  
 cFit->cd();
 Float_t nN = TMath::Sqrt(nOfFiles);
 Int_t nX = (Int_t)nN;
 if ( nN-nX > 0.5 ) nX++;
 Int_t nY = (Int_t)(nOfFiles/nX);
 std::cout << nX << " ," << nY << std::endl;
 cFit->Divide(nOfFiles,1);
 
// Mass VS muon phi plus -------------------------------
 TFile *ZFitFile = new TFile("ZFitFile.root","RECREATE");
 RooPlot *histoLineShape[nOfFiles];
 for(Int_t j=0; j < nOfFiles; j++) {     
   
   TFile *fin = (TFile*)FileList->At(j);    
   if (( histoLineShape[j] = (RooPlot*)fin->Get("hRecBestResAllEvents_Mass_frame"))){
     std::cout<<"Writing fit histogrem file n. "<<j<<std::endl;
     histoLineShape[j]->Write();
     cFit->cd(j+1);
     histoLineShape[j]->SetTitle(LegLabels[j]);
     histoLineShape[j]->Draw();
     histoLineShape[j]->GetXaxis()->SetTitle("M_{#mu#mu} (GeV)");
//      TPaveText *cmsprel2 = new TPaveText(0.19, 0.95, 0.95, 0.99, "NDC");
//      cmsprel2->SetTextSize(0.03);
//      cmsprel2->SetTextFont(42);
//      cmsprel2->SetFillColor(0);
//      cmsprel2->SetBorderSize(0);
//      cmsprel2->SetMargin(0.01);
//      cmsprel2->SetTextAlign(12); // align left
//      cmsprel2->AddText(0.666666, 0.5, LegLabels[j]);

   }
 }
 ZFitFile->Close();
 // cmsprel2->Draw("same");
 cFit->SaveAs("ZFitFile.root");


 
 return; 
};
Beispiel #16
0
//___________________________________________________
void KVClassFactory::WriteClassWithTemplateImp()
{
   // Writes the implementation file for the class

   ofstream file_cpp;

   file_cpp.open( GetImpFileName() );

   WriteWhoWhen(file_cpp);

   file_cpp << "#include \"" << fClassName.Data() << ".h\"" << endl;
   if( fImpInc.GetSize() ){
      TIter next(&fImpInc); TObjString* str;
      while( (str = (TObjString*)next()) ){
         file_cpp << "#include \"" << str->String().Data() << "\"" << endl;
      }
   }
   file_cpp << endl << "ClassImp(" << fClassName.Data() << ")\n" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////"
       << endl;
   file_cpp << "// BEGIN_HTML <!--" << endl;
   file_cpp << "/* -->" << endl;
   file_cpp << "<h2>" << fClassName.Data() << "</h2>" << endl;
   file_cpp << "<h4>" << fClassDesc.Data() << "</h4>" << endl;
   file_cpp << "<!-- */" << endl;
   file_cpp << "// --> END_HTML" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////\n"
       << endl;

   TString cppFile;
   ifstream file_cpp_template;

   //open file whose full path was stored in fTemplateCPP
   if (!KVBase::
       SearchAndOpenKVFile(fTemplateCPP.Data(), file_cpp_template)) {
      //this should never happen!
      cout << "<KVClassFactory::WriteClassWithTemplateImp>: cannot open "
          << fTemplateCPP.Data() << endl;
      return;
   }

   cppFile.ReadFile(file_cpp_template);
   file_cpp_template.close();
   file_cpp << cppFile.ReplaceAll(fTemplateClassName.Data(),
                                  fClassName.Data());

   //write implementations of added methods
   if( fMethods.GetSize() ){
      KVString line;
      TIter next( &fMethods ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteImplementation(line);
         line.Prepend("\n//________________________________________________________________\n");
         file_cpp << line.Data();
      }
   }
   file_cpp.close();

   cout << "<KVClassFactory::WriteClassWithTemplateImp> : File " << GetImpFileName() << " generated." << endl;
}
Beispiel #17
0
void MakeLHCDataEntry(char* storageUri="local://$ALICE_ROOT/../AliRoot/OCDB", Int_t firstRun=0, Int_t lastRun=999999999)
{
  AliCDBManager *cdb = AliCDBManager::Instance();
  cdb->SetDefaultStorage(storageUri);

  // Get time start from the simulated LHCData file
  Double_t timeStart = 0.0;
  Double_t timeEnd = 1.0e+10;

  TString fileName(gSystem->ExpandPathName("$ALICE_ROOT/../AliRoot/GRP/ShuttleInput/testShuttle_GRP_run_number_testShuttle_data.txt"));
  Printf("Getting the file %s", fileName.Data());

  const Int_t fgknLHCDP = 9;   // number of dcs dps from LHC data
  const char* fgkLHCDataPoints[fgknLHCDP] = {
    "LHC_Beam_Energy",
    "LHC_MachineMode",
    "LHC_BeamMode",
    "LHC_Beams_Particle_Type",
    "BPTX_Phase_Shift_B1",
    "BPTX_Phase_Shift_B2",
    "LHC_Particle_Type_B1",
    "LHC_Particle_Type_B2",
    "LHC_Data_Quality_Flag"
  };

  AliGRPObject *grpobj = new AliGRPObject();
	// grpobj->SetBeamEnergyIsSqrtSHalfGeV(); // new format
  //
  //Getting the LHC Data from DCS FXS
  //
  AliLHCReader lhcReader;

  // Processing data to be put in AliGRPObject

		// Energy
		Printf("*************Energy ");
		TObjArray* energyArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[0]);
		if (energyArray){			
			Float_t energy = ProcessEnergy(energyArray,timeStart);
			if (energy != -1.) {
				grpobj->SetBeamEnergy(energy);
				grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE);
			}
			delete energyArray;
		}
		else {
			AliError("Energy not found in LHC Data file!!!");
		}	

  Double_t timeBeamModeEnd = timeEnd;        // max validity for Beam Mode 
  Double_t timeMachineModeEnd = timeEnd;     // max validity for Machine Mode
  Double_t timeBeamEnd = timeEnd;            // max validity for Beam Type
  Double_t timeBeamTypeEnd[2] = {timeEnd, timeEnd}; // max validity for Beam Type1,2
  Double_t timeBeamModeStart = -1;    // min validity for Beam Mode
  Double_t timeMachineModeStart = -1; // min validity for Machine Mode
  Double_t timeBeamStart = -1;        // min validity for Beam Type
  Double_t timeBeamTypeStart[2] = {-1,-1};        // min validity for Beam Type1,2
  Int_t indexBeamMode = -1;                  // index of measurement used to set Beam Mode
  Int_t indexMachineMode = -1;               // index of measurement used to set Machine Mode
  Int_t indexBeam = -1;                      // index of measurement used to set Beam Type
  Int_t indexBeamType[2] = {-1, -1};                      // index of measurement used to set Beam Type1,2
  Bool_t foundBeamModeStart = kFALSE;        // flag to be set in case an entry for the Beam Mode is found before (or at) SOR
  Bool_t foundMachineModeStart = kFALSE;     // flag to be set in case an entry for the Machine Mode is found before (or at) SOR
  Bool_t foundBeamStart = kFALSE;            // flag to be set in case an entry for the Beam Type is found before (or at) SOR
  Bool_t foundBeamTypeStart[2] = {kFALSE, kFALSE};            // flag to be set in case an entry for the Beam Type1,2 is found before (or at) SOR
  Bool_t flagBeamMode = kFALSE;  //flag set true if a changed occurred in BeamMode
  Bool_t flagMachineMode = kFALSE;  //flag set true if a changed occurred in MachineMode
  Bool_t flagBeam = kFALSE;  //flag set true if a changed occurred in BeamType
  Bool_t flagBeamType[2] = {kFALSE, kFALSE};  //flag set true if a changed occurred in BeamType1,2

  Double_t arrayTimes[5]={2.E9, 2.E9, 2.E9, 2.E9, 2.E9}; // array to keep track of the times of the possible changes of the LHC DPs; each entry set to Wed May 18 2033, 03:33:20 GMT (ALICE should not be running anymore...)
  // arrayTimes elements order correspond to the one used in the array of the strings fgkLHCDataPoints, i.e.:
  // arrayTimes[0] --> MachineMode
  // arrayTimes[1] --> BeamMode
  // arrayTimes[2] --> BeamType (when written together)
  // arrayTimes[3] --> BeamType1 (when written separate)
  // arrayTimes[4] --> BeamType2 (when written separate)

  // BeamMode
  Printf("*************BeamMode (LHCState) ");
  TObjArray* beamModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[2]);
  Int_t nBeamMode = -1;
  if (beamModeArray){	
    nBeamMode = beamModeArray->GetEntries();	
    if (nBeamMode==0){
      Printf("Found zero entries for the Beam Mode, leaving it empty");
    }
    else{
      for (Int_t iBeamMode = 0; iBeamMode<nBeamMode; iBeamMode++){
        AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(iBeamMode);
        if (beamMode){
          if (beamMode->GetTimeStamp()<=timeStart && beamMode->GetTimeStamp()>=timeBeamModeStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
            timeBeamModeStart = beamMode->GetTimeStamp();
            indexBeamMode = iBeamMode;
            foundBeamModeStart = kTRUE;
          }
          else {
            break;

          }
        }
      }
      if (!foundBeamModeStart){
        Printf("No value for the Beam Mode found before start of run, the Beam Mode will remain empty");
      }
      else {
        AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(indexBeamMode);
        TObjString* beamModeString = beamMode->GetStringArray(0);
        Printf(Form("LHC State (corresponding to BeamMode) = %s (set at %f)",(beamModeString->String()).Data(),beamMode->GetTimeStamp()));
        grpobj->SetLHCState(beamModeString->String());
        if (indexBeamMode < nBeamMode-1){
          AliDCSArray* beamMode1 = (AliDCSArray*)beamModeArray->At(indexBeamMode+1);
          if (beamMode1){
            if (beamMode1->GetTimeStamp()<=timeStart){
              Printf("ERROR: you did not choose the correct value! there is still something before (or at) SOR, but later than this!");
            }
            else if (beamMode1->GetTimeStamp()>timeStart && beamMode1->GetTimeStamp()<=timeEnd){
              timeBeamModeEnd = beamMode1->GetTimeStamp();
              TObjString* beamModeString1 = beamMode1->GetStringArray(0);
              TString bmString0 = beamModeString->String();
              TString bmString1 = beamModeString1->String();
              if (bmString0.CompareTo(bmString1.Data(),TString::kIgnoreCase) == -1){
                Printf("WARNING: The beam mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",bmString0.Data(), bmString1.Data(), timeBeamModeEnd, bmString0.Data());
                flagBeamMode = kTRUE;
                arrayTimes[1]=timeBeamModeEnd;

              }
            }
          }
          else {
            Printf("Invalid pointer for the first entry for Beam Mode after the first valid one, not considering anything after what has already been found");
          }
        }
      }
    }
    delete beamModeArray;
  }
  else{
    Printf("ERROR: Beam mode array not found in LHC Data file!!!");
  }
		
  // MachineMode
  Printf("*************MachineMode ");
  TObjArray* machineModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[1]);
  Int_t nMachineMode = -1;
  if (machineModeArray){
    nMachineMode = machineModeArray->GetEntries();
    if (nMachineMode==0){
      Printf("No Machine Mode found, leaving it empty");
    }
    else{
      for (Int_t iMachineMode = 0; iMachineMode<nMachineMode; iMachineMode++){
        AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(iMachineMode);
        if (machineMode){
          if (machineMode->GetTimeStamp()<=timeStart && machineMode->GetTimeStamp()>=timeMachineModeStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
            timeMachineModeStart = machineMode->GetTimeStamp();
            indexMachineMode = iMachineMode;
            foundMachineModeStart = kTRUE;
          }
          else{
            break;
          }
        }
      }
      if (!foundMachineModeStart){
        Printf("No value for the Machine Mode found before start of run, the Machine Mode will remain empty");
      }
      else {
        AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(indexMachineMode);
        TObjString* machineModeString = machineMode->GetStringArray(0);
        Printf(Form("MachineMode = %s (set at %f)",(machineModeString->String()).Data(),machineMode->GetTimeStamp()));
        grpobj->SetMachineMode(machineModeString->String());
        if (indexMachineMode < nMachineMode-1){
          AliDCSArray* machineMode1 = (AliDCSArray*)machineModeArray->At(indexMachineMode+1);
          if (machineMode1){
            if (machineMode1->GetTimeStamp()>timeStart && machineMode1->GetTimeStamp()<=timeEnd){
              timeMachineModeEnd = machineMode1->GetTimeStamp();
              TObjString* machineModeString1 = machineMode1->GetStringArray(0);
              TString mmString0 = machineModeString->String();
              TString mmString1 = machineModeString1->String();
              if (mmString0.CompareTo(mmString1.Data(),TString::kIgnoreCase) == -1){
                Printf("WARNING: The machine mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",mmString0.Data(),mmString1.Data(),timeMachineModeEnd,mmString0.Data());
                flagMachineMode = kTRUE;
                arrayTimes[0]=timeMachineModeEnd;
              }
            }
          }
          else {
            Printf("Invalid pointer for the first entry for Machine Mode after the first valid one, not considering anything after what has already been found");
          }
        }
      }
    }
    delete machineModeArray;
  }
  else{
    Printf("ERROR: Machine mode array not found in LHC Data file!!!");
  }

  // BeamType1 and BeamType2 - both put in the same string
  Printf("*************BeamType ");
  TObjArray* beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[3]);
  if (beamArray){			
    Int_t nBeam = beamArray->GetEntries();
    if (nBeam==0){
      Printf("No Beam Type found, leaving it empty");
    }
    else{
      for (Int_t iBeam = 0; iBeam<nBeam; iBeam++){
        AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
        if (beam){
          if (beam->GetTimeStamp()<=timeStart && beam->GetTimeStamp()>=timeBeamStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
            timeBeamStart = beam->GetTimeStamp();
            indexBeam = iBeam;
            foundBeamStart = kTRUE;
          }
          else{
            break;
          }
        }
      }
      if (!foundBeamStart){
        Printf("No value for the Beam Type found before start of run, the (common) Beam Type will remain empty");
      }
      else {
        AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
        TObjString* beamString = beam->GetStringArray(0);
        TString beamType = beamString->String();
        Printf(Form("Beam Type = %s",beamType.Data()));	
        if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
          Printf("Setting beam type to p-p");
          grpobj->SetBeamType("p-p");
        }
        else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
          Printf("Setting beam type to A-A");
          grpobj->SetBeamType("A-A");
        }
        /*
           else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
           Printf("Setting beam type to Pb-Pb");
           grpobj->SetBeamType("Pb-Pb");
           }
           else{
           Printf("ERROR: Beam Type not known, leaving it empty");
           }
           */
        if (indexBeam < nBeam-1){
          AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1);
          if (beam1){
            if (beam1->GetTimeStamp()>timeStart && beam1->GetTimeStamp()<=timeEnd){
              timeBeamEnd = beam1->GetTimeStamp();
              TObjString* beamString1 = beam1->GetStringArray(0);
              TString beamType1 = beamString1->String();
              if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){
                Printf("WARNING: The Beam Type changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data());
                flagBeam = kTRUE;
                arrayTimes[2] = timeBeamEnd;
              }
            }
          }
          else {
            Printf("Invalid pointer for the first entry for Beam Type after the first valid one, not considering anything after what has already been found");
          }
        }
      }
    }
    delete beamArray;
  }
  else{
    Printf("ERROR: Beam Type array not found in LHC Data file!!!");
  }		

  // BeamType1 and BeamType2 - in separete string
  Printf("*************BeamType, 1 and 2 ");
  Int_t indexBeamTypeString = 6;  // index of the string with the alias of BeanType1 in the array fgkLHCDataPoints
  TString combinedBeamType = "-";  // combined beam type, built from beam type 1 and beam type 2
  TString combinedBeamTypeFromLHC = "-";  // combined beam type, built from beam type 1 and beam type 2 AS SENT FROM LHC
  for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
    beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[indexBeamTypeString+ibeamType]);
    if (beamArray){			
      Int_t nBeam = beamArray->GetEntries();
      if (nBeam==0){
        Printf(Form("No Beam Type %s found, leaving it empty",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
      }
      else{
        for (Int_t iBeam = 0; iBeam<nBeam; iBeam++){
          AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
          if (beam){
            if (beam->GetTimeStamp()<=timeStart && beam->GetTimeStamp()>=timeBeamTypeStart[ibeamType]){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
              timeBeamTypeStart[ibeamType] = beam->GetTimeStamp();
              indexBeamType[ibeamType] = iBeam;
              foundBeamTypeStart[ibeamType] = kTRUE;
            }
            else{
              break;
            }
          }
        }
        if (!foundBeamTypeStart[ibeamType]){
          Printf(Form("No value for the Beam Type %s found before start of run, the Beam Type %d will remain empty", fgkLHCDataPoints[indexBeamTypeString+ibeamType], ibeamType));
        }
        else {
          AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
          TObjString* beamString = beam->GetStringArray(0);
          TString beamType = beamString->String();
          Printf(Form("Beam Type (for %s) = %s", fgkLHCDataPoints[indexBeamTypeString+ibeamType], beamType.Data()));
          TString singleBeam = ParseBeamTypeString(beamType,ibeamType);
          Printf(Form("Single Beam Type for beam %d set to %s", ibeamType, singleBeam.Data()));
          grpobj->SetSingleBeamType(ibeamType, singleBeam);
          if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
            Printf(Form("Setting beam %d for combined beam type to p", ibeamType));
            if (ibeamType == 0) combinedBeamType.Prepend("p"); 
            else combinedBeamType.Append("p");
          }
          else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
            Printf(Form("Setting beam %d for combined beam type to A",ibeamType));
            if (ibeamType == 0) combinedBeamType.Prepend("A");
            else combinedBeamType.Append("A");
          }
          if (ibeamType == 0) combinedBeamTypeFromLHC.Prepend(beamType); 
          else combinedBeamTypeFromLHC.Append(beamType);
          /*
             else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
             Printf("Setting beam type to Pb-Pb");
             grpobj->SetSingleBeamType(ibeamType, "Pb-Pb");
             }
             else{
             Printf("ERROR: Beam Type not known, leaving it empty");
             }
             */
          if (indexBeamType[ibeamType] < nBeam-1){
            AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1);
            if (beam1){
              if (beam1->GetTimeStamp()>timeStart && beam1->GetTimeStamp()<=timeEnd){
                timeBeamTypeEnd[ibeamType] = beam1->GetTimeStamp();
                TObjString* beamString1 = beam1->GetStringArray(0);
                TString beamType1 = beamString1->String();
                if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){
                  Printf("WARNING: The Beam Type for %s changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",fgkLHCDataPoints[indexBeamTypeString+ibeamType],beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data());
                  flagBeamType[ibeamType] = kTRUE;
                  arrayTimes[3+ibeamType] = timeBeamTypeEnd[ibeamType];
                }
              }
            }
            else {
              Printf(Form("Invalid pointer for the first entry for Beam Type %s after the first valid one, not considering anything after what has already been found",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
            }
          }
        }
      }
      delete beamArray;
    }
    else{
      AliError(Form("Beam Type %s array not found in LHC Data file!!!",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
    }		
  }
  Printf(Form("Setting combined beam type to %s",combinedBeamType.Data()));
  grpobj->SetBeamType(combinedBeamType);
  Printf(Form("Setting combined beam type form LHC to %s",combinedBeamTypeFromLHC.Data()));
  grpobj->SetBeamTypeFromLHC(combinedBeamTypeFromLHC);

  // Setting minTimeLHCValidity
  if (flagBeamMode == kTRUE || flagMachineMode == kTRUE || flagBeam == kTRUE || flagBeamType[0] == kTRUE || flagBeamType[1] == kTRUE){ 
    Double_t minTimeLHCValidity= TMath::MinElement(5,arrayTimes);
    Printf("WARNING: Setting MaxTimeLHCValidity to %f",minTimeLHCValidity);
    grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
  }
  /* 
  // Old way to determine the Maximum Time during which the LHC info is valid
  if (timeBeamModeEnd!=0 || timeMachineModeEnd!=0 || timeBeamEnd !=0){
  Double_t minTimeLHCValidity;
  if (flagBeamMode == kFALSE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam only true --> it is the only one that changed
  minTimeLHCValidity = timeBeamEnd;
  }
  else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode only true
  minTimeLHCValidity = timeMachineModeEnd;
  }
  else if (flagBeamMode == kTRUE && flagMachineMode == kFALSE && flagBeam == kFALSE){ // flagBeamMode only true
  minTimeLHCValidity = timeBeamModeEnd;
  }
  else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kTRUE){ // flagBeam and flagMachineMode only true
  minTimeLHCValidity= TMath::Min(timeBeamEnd,timeMachineModeEnd);
  }
  else if (flagBeamMode == kTRUE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam and flagBeamMode only true
  minTimeLHCValidity= TMath::Min(timeBeamEnd,timeBeamModeEnd);
  }
  else if (flagBeamMode == kTRUE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode and flagBeamMode only true
  minTimeLHCValidity= TMath::Min(timeMachineModeEnd,timeBeamModeEnd);
  }
  else {
  Double_t arrayTimes[3] = {timeBeamModeEnd,timeMachineModeEnd,timeBeamEnd};// flagMachineMode and flagBeamMode and flagBeam 
  minTimeLHCValidity= TMath::MinElement(3,arrayTimes);
  }
  Printf("WARNING: Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
  grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
  }
  */

  // Data Quality Flag --> storing start and end values of periods within the run during which the value was found to be FALSE
  Printf("*************Data Quality Flag ");
  TObjArray* dataQualityArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[8]);
  Int_t nDataQuality = -1;
  Double_t timeDataQualityStart = -1; // min validity for Data Quality Flag
  Int_t indexDataQuality = -1;               // index of first measurement used to set Data Quality Flag
  Bool_t foundDataQualityStart = kFALSE;     // flag to be set in case an entry for the Data Quality Flag is found before (or at) SOR

  if (dataQualityArray){
    nDataQuality = dataQualityArray->GetEntries();
    if (nDataQuality==0){
      Printf("No Data Quality Flag found, leaving it empty");
    }
    else{
      for (Int_t iDataQuality = 0; iDataQuality<nDataQuality; iDataQuality++){
        AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
        if (dataQuality){
          if (dataQuality->GetTimeStamp()<=timeStart && dataQuality->GetTimeStamp()>=timeDataQualityStart){// taking always the very last entry: if two measurements have the same timestamp, the last one is taken
            timeDataQualityStart = dataQuality->GetTimeStamp();
            indexDataQuality = iDataQuality;
            foundDataQualityStart = kTRUE;
          }
          else{
            // we suppose here that if the first measurement is not before SOR, then none will be (they MUST be in chronological order!!!) 
            break;
          }
        }
      }
      if (!foundDataQualityStart){
        // The Data Quality Flag should be found and TRUE at the start of the run. For the time being, if it is not found, don't do anything, but it means there is a problem..
        Printf("No value for the Data Quality Flag found before start of run, the Data Quality Flag will remain empty");
      }
      else {
        // counting how many FALSE values there are
        Bool_t foundEndOfFalse = kFALSE;
        Int_t nFalse = 0;
        for (Int_t iDataQuality = indexDataQuality; iDataQuality < nDataQuality; iDataQuality ++){
          AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
          Printf("dataQuality->GetTimeStamp() = %f, timeDataQualityStart = %f, timeEnd = %f", dataQuality->GetTimeStamp(), timeDataQualityStart, timeEnd );
          if (dataQuality->GetTimeStamp()>=timeDataQualityStart && dataQuality->GetTimeStamp()<=timeEnd){ // considering only values between the first valid and the end of the run
            Bool_t dataQualityFlag = dataQuality->GetBool(0);
            Printf("DataQuality = %d (set at %f)",(Int_t)dataQualityFlag,dataQuality->GetTimeStamp());
            if (dataQualityFlag != kTRUE){
              if (iDataQuality == indexDataQuality) {  // the first Data Quality value should be TRUE, but ignoring the problem now...
                Printf("ERROR: The first value for the Data Quality MUST be TRUE! Ignoring for now...");
              }
              nFalse++;
            }
          }
        }

        Printf(Form("Found %d FALSE values for the Data Quality Flag",nFalse));
        Double_t falses[nFalse*2];  // dimensioning this to the maximum possible, as if each false value was followed by a true one --> the false periods correspond to the number of falses

        Int_t iDataQuality = indexDataQuality;
        if (nFalse > 0){
          Int_t iFalse = 0;
          // filling the info about the periods when the flag was set to FALSE
          // starting, like for the other DPS, from the measurement closest to SOR (the index of which is iDataQuality)
          while (iDataQuality < nDataQuality){
            Printf("iDataQuality = %d",iDataQuality);
            AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
            if (dataQuality->GetTimeStamp()>=timeDataQualityStart && dataQuality->GetTimeStamp()<=timeEnd){ // considering only values between the first valid and the end of the run
              Bool_t dataQualityFlag = dataQuality->GetBool(0);
              Printf("DataQuality = %d (set at %f)",(Int_t)dataQualityFlag,dataQuality->GetTimeStamp());
              if (dataQualityFlag == kTRUE){
                // found TRUE value, continuing
                iDataQuality++;
                continue;
              }
              else{
                /*
                // the check was already done before
                if (iDataQuality == indexDataQuality) {  // the first Data Quality value should be TRUE, but ignoring the problem now...
                Printf("ERROR: The first value for the Data Quality MUST be TRUE! Ignoring for now...");
                }
                */
                falses[iFalse*2] = dataQuality->GetTimeStamp();
                foundEndOfFalse = kFALSE;
                Int_t iDataQualityNext = iDataQuality+1;
                while (iDataQualityNext < nDataQuality){
                  AliDCSArray* dataQualityNext = (AliDCSArray*)dataQualityArray->At(iDataQualityNext);
                  if (dataQualityNext->GetTimeStamp()>timeDataQualityStart && dataQualityNext->GetTimeStamp()<=timeEnd && dataQualityNext->GetTimeStamp() > dataQuality->GetTimeStamp()){ // considering only values between the first valid and the end of the run, and subsequent to the current value
                    Bool_t dataQualityFlagNext = dataQualityNext->GetBool(0);
                    Printf("DataQualityNext = %d (set at %f)",(Int_t)dataQualityFlagNext,dataQualityNext->GetTimeStamp());
                    if (dataQualityFlagNext == kTRUE){
                      // found TRUE value, first FALSE period completed
                      foundEndOfFalse = kTRUE;
                      falses[iFalse*2+1] = dataQualityNext->GetTimeStamp();
                      iFalse++;
                      break;
                    }
                    iDataQualityNext++;
                  }
                }
                if (!foundEndOfFalse) {
                  Printf("Please, note that the last FALSE value lasted until the end of the run");
                  falses[iFalse*2+1] = timeEnd;
                  iFalse++;
                  break;
                }
                iDataQuality = iDataQualityNext+1;
              }
            }
          }
          grpobj->SetNFalseDataQualityFlag(iFalse);
          grpobj->SetFalseDataQualityFlagPeriods(falses);
        }
      }
    }
    delete dataQualityArray;
  }
  else{
    Printf("ERROR: Data Quality Flag array not found in LHC Data file!!!");
  }

  // Processing data to go to AliLHCData object
  AliLHCData* dt = new AliLHCData(fileName.Data(),timeStart,timeEnd);
  // storing AliLHCData in OCDB
  if (dt){
    Printf(Form("Filled %d records to AliLHCData object",dt->GetData().GetEntriesFast()));
    AliCDBMetaData md;
    md.SetResponsible("Ruben Shahoyan");
    md.SetComment("LHC data from the GRP preprocessor.");
    Bool_t result = kTRUE;
    AliCDBId id("GRP/GRP/LHCData", 0, AliCDBRunRange::Infinity());
    result = cdb->Put(dt, id, &md); 
    delete dt;
    if (!result){
      Printf("Problems in storing LHC Data - but not going into Error");
    }
  }

  // processing LHC Phase

  TObjArray *beam1phase = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[4]);
  TObjArray *beam2phase = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[5]);
  if (beam1phase == 0x0 || beam2phase == 0x0){
    Printf(Form("Problems in retrieving LHC Clock data from LHC file"));
    return 4;
  }			
  AliLHCClockPhase *phaseObj = ProcessLHCClockPhase(beam1phase,beam2phase,timeEnd);
  delete beam1phase;
  delete beam2phase;
  if (phaseObj){
    Printf(Form("LHC Phase found"));
    AliCDBMetaData mdPhase;
    mdPhase.SetResponsible("Cvetan Cheshkov");
    mdPhase.SetComment("LHC Clock Phase");
    Bool_t result = kTRUE;
    AliCDBId id("GRP/Calib/LHCClockPhase", 0, AliCDBRunRange::Infinity());
    result = cdb->Put(phaseObj, id, &mdPhase); 
    delete phaseObj;
    if (!result) return 3;
  }
  else return 4;

  return 0;
}
Beispiel #18
0
KVList* KV_CCIN2P3_GE::GetListOfJobs()
{
   // Create and fill list with KVBatchJob objects describing current jobs
   // Delete list after use

   KVList* list_of_jobs = new KVList;

   // use qstat -r to get list of job ids and jobnames
   TString reply = gSystem->GetFromPipe("qstat -r");

   TObjArray* lines = reply.Tokenize("\n");
   Int_t nlines = lines->GetEntries();
   for (Int_t line_number = 0; line_number < nlines; line_number++) {
      TString thisLine = ((TObjString*)(*lines)[line_number])->String();
      if (thisLine.Contains("Full jobname:")) {
         // previous line contains job-id and status
         TString lastLine = ((TObjString*)(*lines)[line_number - 1])->String();
         TObjArray* bits = lastLine.Tokenize(" ");
         Int_t jobid = ((TObjString*)(*bits)[0])->String().Atoi();
         TString status = ((TObjString*)(*bits)[4])->String();
         // date & time jobs started (running job) or submitted (queued job)
         TString sdate = ((TObjString*)(*bits)[5])->String();// mm/dd/yyyy
         TString stime = ((TObjString*)(*bits)[6])->String();// hh:mm:ss
         Int_t dd, MM, yyyy, hh, mm, ss;
         sscanf(sdate.Data(), "%d/%d/%d", &MM, &dd, &yyyy);
         sscanf(stime.Data(), "%d:%d:%d", &hh, &mm, &ss);
         KVDatime submitted(yyyy, MM, dd, hh, mm, ss);
         delete bits;
         bits = thisLine.Tokenize(": ");
         TString jobname = ((TObjString*)(*bits)[2])->String();
         delete bits;

         KVGEBatchJob* job = new KVGEBatchJob();
         job->SetName(jobname);
         job->SetJobID(jobid);
         job->SetStatus(status);
         job->SetSubmitted(submitted);
         list_of_jobs->Add(job);
      }
   }
   delete lines;

   if (!list_of_jobs->GetEntries()) return list_of_jobs;

   // use qstat -j [jobid] to get cpu and memory used and also the resource requests
   TIter next_job(list_of_jobs);
   KVGEBatchJob* job;
   while ((job = (KVGEBatchJob*)next_job())) {

      // for running jobs, read in from [jobname].status file
      // the number of events read/to read, disk used
      if (!strcmp(job->GetStatus(), "r")) job->UpdateDiskUsedEventsRead();

      reply = gSystem->GetFromPipe(Form("qstat -j %d", job->GetJobID()));
      lines = reply.Tokenize("\n");
      nlines = lines->GetEntries();
      for (Int_t line_number = 0; line_number < nlines; line_number++) {
         TString thisLine = ((TObjString*)(*lines)[line_number])->String();
         if (thisLine.BeginsWith("usage")) {
            TObjArray* bits = thisLine.Tokenize("=,");
            TString stime = ((TObjString*)(*bits)[1])->String();// hh:mm:ss or d:hh:mm:ss
            Int_t dd, hh, mm, ss;
            TObjArray* tmp = stime.Tokenize(":");
            dd = 0;
            if (tmp->GetEntries() == 4) sscanf(stime.Data(), "%d:%2d:%2d:%2d", &dd, &hh, &mm, &ss);
            else sscanf(stime.Data(), "%2d:%2d:%2d", &hh, &mm, &ss);
            delete tmp;
            job->SetCPUusage((dd * 24 + hh) * 3600 + mm * 60 + ss);
            TString smem = ((TObjString*)(*bits)[7])->String();// xxx.xxxxM
            job->SetMemUsed(smem);
            delete bits;
         }
         else if (thisLine.BeginsWith("hard resource_list:")) {
            TObjArray* bits = thisLine.Tokenize(": ");
            TString res = ((TObjString*)(*bits)[2])->String();//os=sl5,xrootd=1,irods=1,s_vmem=1024M,s_fsize=50M,s_cpu=36000
            res.ReplaceAll("s_vmem", "vmem");
            res.ReplaceAll("s_fsize", "fsize");
            res.ReplaceAll("s_cpu", "ct");
            job->SetResources(res);
            TObjArray* bbits = res.Tokenize(",");
            TIter next_res(bbits);
            TObjString* ss;
            while ((ss = (TObjString*)next_res())) {
               TString g = ss->String();
               if (g.BeginsWith("ct=")) {
                  g.Remove(0, 3);
                  job->SetCPUmax(g.Atoi());
               }
               else if (g.BeginsWith("vmem=")) {
                  g.Remove(0, 5);
                  job->SetMemMax(g);
               }
               else if (g.BeginsWith("fsize=")) {
                  g.Remove(0, 6);
                  job->SetDiskMax(g);
               }
            }
            delete bits;
            delete bbits;
         }
      }
      delete lines;
      //}
   }

   return list_of_jobs;
}
Beispiel #19
0
//___________________________________________________
void KVClassFactory::WriteClassImp()
{
   //Write the class implementation file
   //This includes a class description in pure HTML

   ofstream file_cpp;

   file_cpp.open( GetImpFileName() );

   WriteWhoWhen(file_cpp);

   file_cpp << "#include \"" << fClassName.Data() << ".h\"" << endl;
   if( fImpInc.GetSize() ){
      TIter next(&fImpInc); TObjString* str;
      while( (str = (TObjString*)next()) ){
         file_cpp << "#include \"" << str->String().Data() << "\"" << endl;
      }
   }
   file_cpp << endl << "ClassImp(" << fClassName.Data() << ")\n" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////"
       << endl;
   file_cpp << "// BEGIN_HTML <!--" << endl;
   file_cpp << "/* -->" << endl;
   file_cpp << "<h2>" << fClassName.Data() << "</h2>" << endl;
   file_cpp << "<h4>" << fClassDesc.Data() << "</h4>" << endl;
   file_cpp << "<!-- */" << endl;
   file_cpp << "// --> END_HTML" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////\n"
       << endl;
   file_cpp << fClassName.Data() << "::" << fClassName.
       Data() << "()" << endl;
   file_cpp << "{\n   // Default constructor\n}\n" << endl;
	// any other ctors ?
   KVList* ctor = (KVList*)fMethods.GetSubListWithMethod("1", "IsConstructor");
	if( ctor->GetEntries() ){
      KVString line;
      TIter next( ctor ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteImplementation(line);
         line.Prepend("//________________________________________________________________\n\n");
         file_cpp << line.Data() << endl;
      }
	}
	delete ctor;

   file_cpp << fClassName.Data() << "::~" << fClassName.
       Data() << "()" << endl;
   file_cpp << "{\n   // Destructor\n}\n" << endl;

   //write implementations of added methods
   if( fMethods.GetSize() ){
      KVString line;
      TIter next( &fMethods ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
			if( !meth->IsConstructor() ){
         	meth->WriteImplementation(line);
         	line.Prepend("//________________________________________________________________\n\n");
         	file_cpp << line.Data() << endl;
			}
      }
   }

   file_cpp.close();

   cout << "<KVClassFactory::WriteClassImp> : File " << GetImpFileName() << " generated." << endl;
}
//*************************************************************
void AutoFitResiduals_forApproval(TString namesandlabels,bool stdres){
//*************************************************************

  gROOT->ProcessLine(".L TkAlStyle.cc+");
  TkAlStyle::set(PRELIMINARY);	// set publication status

  //Int_t colors[10]={kBlack,kRed,kBlue,kMagenta,kBlack,kRed,kBlue,kGreen};
  Int_t colors[8]={0,1,2,3,4,5,6,7};
  setStyle();

  TList *FileList  = new TList();
  TList *LabelList = new TList();
  
  TObjArray *nameandlabelpairs = namesandlabels.Tokenize(",");
  for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) {
    TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("=");
    
    if(aFileLegPair->GetEntries() == 2) {
      FileList->Add( TFile::Open(aFileLegPair->At(0)->GetName())  );  // 2
      LabelList->Add( aFileLegPair->At(1) );
    }
    else {
      std::cout << "Please give file name and legend entry in the following form:\n" 
		<< " filename1=legendentry1,filename2=legendentry2\n";
      
    }    
  }

  const Int_t nFiles_ = FileList->GetSize();
  TString LegLabels[10];  
  TFile *fins[nFiles_]; 

  for(Int_t j=0; j < nFiles_; j++) {
    
    // Retrieve files
    fins[j] = (TFile*)FileList->At(j);    
 
    // Retrieve labels
    TObjString* legend = (TObjString*)LabelList->At(j);
    LegLabels[j] = legend->String();
    cout<<"AutoFitResiduals_forApproval::AutoFitResiduals_forApproval(): label["<<j<<"]"<<LegLabels[j]<<endl;
    
  }

  const Int_t nBins_ =24;
  
  // dca absolute residuals
  TH1F* dxyPhiResiduals[nFiles_][nBins_];
  TH1F* dxyEtaResiduals[nFiles_][nBins_];
  				        
  TH1F* dzPhiResiduals[nFiles_][nBins_];
  TH1F* dzEtaResiduals[nFiles_][nBins_];

  // dca normalized residuals
  TH1F* dxyNormPhiResiduals[nFiles_][nBins_];
  TH1F* dxyNormEtaResiduals[nFiles_][nBins_];
  				        
  TH1F* dzNormPhiResiduals[nFiles_][nBins_];
  TH1F* dzNormEtaResiduals[nFiles_][nBins_];
  
  for(Int_t i=0;i<nFiles_;i++){
    for(Int_t j=0;j<nBins_;j++){
      
      if(stdres){
	// DCA absolute residuals
	dxyPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Phi_Residuals/histo_dxy_phi_plot%i",j));
	dxyEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Eta_Residuals/histo_dxy_eta_plot%i",j));
	dzPhiResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Phi_Residuals/histo_dz_phi_plot%i",j));
	dzEtaResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Eta_Residuals/histo_dz_eta_plot%i",j));
	
	// DCA normalized residuals
	dxyNormPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Phi_Residuals/histo_norm_dxy_phi_plot%i",j));
	dxyNormEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Eta_Residuals/histo_norm_dxy_eta_plot%i",j));
	dzNormPhiResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Phi_Residuals/histo_norm_dz_phi_plot%i",j));
	dzNormEtaResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Eta_Residuals/histo_norm_dz_eta_plot%i",j));

      } else {

	// DCA absolute residuals
	dxyPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Phi_Residuals/histo_IP2D_phi_plot%i",j));
	dxyEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Eta_Residuals/histo_IP2D_eta_plot%i",j));
	dzPhiResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Phi_Residuals/histo_resz_phi_plot%i",j));
	dzEtaResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Eta_Residuals/histo_resz_eta_plot%i",j));
	
	// DCA normalized residuals
	dxyNormPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Phi_Residuals/histo_norm_IP2D_phi_plot%i",j));
	dxyNormEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Eta_Residuals/histo_norm_IP2D_eta_plot%i",j));
	dzNormPhiResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Phi_Residuals/histo_norm_resz_phi_plot%i",j));
	dzNormEtaResiduals[i][j]  = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Eta_Residuals/histo_norm_resz_eta_plot%i",j));
      }
    }
  }
 
  Double_t highedge=nBins_-0.5;
  Double_t lowedge=-0.5;
  
  // DCA absolute

  TH1F* dxyPhiMeanTrend[nFiles_];  
  TH1F* dxyPhiWidthTrend[nFiles_]; 
  TH1F* dzPhiMeanTrend[nFiles_];   
  TH1F* dzPhiWidthTrend[nFiles_];  
  		       	 
  TH1F* dxyEtaMeanTrend[nFiles_];  
  TH1F* dxyEtaWidthTrend[nFiles_]; 
  TH1F* dzEtaMeanTrend[nFiles_];   
  TH1F* dzEtaWidthTrend[nFiles_];  

  // DCA normalized

  TH1F* dxyNormPhiMeanTrend[nFiles_];  
  TH1F* dxyNormPhiWidthTrend[nFiles_]; 
  TH1F* dzNormPhiMeanTrend[nFiles_];   
  TH1F* dzNormPhiWidthTrend[nFiles_];  
  		       	 
  TH1F* dxyNormEtaMeanTrend[nFiles_];  
  TH1F* dxyNormEtaWidthTrend[nFiles_]; 
  TH1F* dzNormEtaMeanTrend[nFiles_];   
  TH1F* dzNormEtaWidthTrend[nFiles_];  

  for(Int_t i=0;i<nFiles_;i++){

    // DCA trend plots

    dxyPhiMeanTrend[i]  = new TH1F(Form("means_dxy_phi_%i",i),"#LT d_{xy} #GT vs #phi sector;track #phi [rad];#LT d_{xy} #GT [#mum]",nBins_,lowedge,highedge); 
    dxyPhiWidthTrend[i] = new TH1F(Form("widths_dxy_phi_%i",i),"#sigma(d_{xy}) vs #phi sector;track #phi [rad];#sigma(d_{xy}) [#mum]",nBins_,lowedge,highedge);
    dzPhiMeanTrend[i]   = new TH1F(Form("means_dz_phi_%i",i),"#LT d_{z} #GT vs #phi sector;track #phi [rad];#LT d_{z} #GT [#mum]",nBins_,lowedge,highedge); 
    dzPhiWidthTrend[i]  = new TH1F(Form("widths_dz_phi_%i",i),"#sigma(d_{z}) vs #phi sector;track #phi [rad];#sigma(d_{z}) [#mum]",nBins_,lowedge,highedge);
    
    dxyEtaMeanTrend[i]  = new TH1F(Form("means_dxy_eta_%i",i),"#LT d_{xy} #GT vs #eta sector;track #eta;#LT d_{xy} #GT [#mum]",nBins_,lowedge,highedge);
    dxyEtaWidthTrend[i] = new TH1F(Form("widths_dxy_eta_%i",i),"#sigma(d_{xy}) vs #eta sector;track #eta;#sigma(d_{xy}) [#mum]",nBins_,lowedge,highedge);
    dzEtaMeanTrend[i]   = new TH1F(Form("means_dz_eta_%i",i),"#LT d_{z} #GT vs #eta sector;track #eta;#LT d_{z} #GT [#mum]",nBins_,lowedge,highedge); 
    dzEtaWidthTrend[i]  = new TH1F(Form("widths_dz_eta_%i",i),"#sigma(d_{xy}) vs #eta sector;track #eta;#sigma(d_{z}) [#mum]",nBins_,lowedge,highedge);

    dxyNormPhiMeanTrend[i] = new TH1F(Form("means_dxyNorm_phi_%i",i),"#LT d_{xy}/#sigma_{d_{xy}} #GT vs #phi sector;track #phi [rad];#LT d_{xy}/#sigma_{d_{xy}} #GT [#mum]",nBins_,lowedge,highedge); 
    dxyNormPhiWidthTrend[i]= new TH1F(Form("widths_dxyNorm_phi_%i",i),"#sigma(d_{xy}/#sigma_{d_{xy}}) vs #phi sector;track #phi [rad];#sigma(d_{xy}/#sigma_{d_{xy}}) [#mum]",nBins_,lowedge,highedge);
    dzNormPhiMeanTrend[i]  = new TH1F(Form("means_dzNorm_phi_%i",i),"#LT d_{z}/#sigma_{d_{z}} #GT vs #phi sector;track #phi [rad];#LT d_{z}/#sigma_{d_{z}} #GT [#mum]",nBins_,lowedge,highedge); 
    dzNormPhiWidthTrend[i] = new TH1F(Form("widths_dzNorm_phi_%i",i),"#sigma(d_{z}/#sigma_{d_{z}}) vs #phi sector;track #phi [rad];#sigma(d_{z}/#sigma_{d_{z}}) [#mum]",nBins_,lowedge,highedge);
    
    dxyNormEtaMeanTrend[i] = new TH1F(Form("means_dxyNorm_eta_%i",i),"#LT d_{xy}/#sigma_{d_{xy}} #GT vs #eta sector;track #eta;#LT d_{xy}/#sigma_{d_{xy}} #GT [#mum]",nBins_,lowedge,highedge);
    dxyNormEtaWidthTrend[i]= new TH1F(Form("widths_dxyNorm_eta_%i",i),"#sigma(d_{xy}/#sigma_{d_{xy}}) vs #eta sector;track #eta;#sigma(d_{xy}/#sigma_{d_{xy}}) [#mum]",nBins_,lowedge,highedge);
    dzNormEtaMeanTrend[i]  = new TH1F(Form("means_dzNorm_eta_%i",i),"#LT d_{z}/#sigma_{d_{z}} #GT vs #eta sector;track #eta;#LT d_{z}/#sigma_{d_{z}} #GT [#mum]",nBins_,lowedge,highedge); 
    dzNormEtaWidthTrend[i] = new TH1F(Form("widths_dzNorm_eta_%i",i),"#sigma(d_{z}/#sigma_{d_{z}}) vs #eta sector;track #eta;#sigma(d_{z}/#sigma_{d_{z}}) [#mum]",nBins_,lowedge,highedge);
   
    // DCA absolute

    FillTrendPlot(dxyPhiMeanTrend[i] ,dxyPhiResiduals[i],"mean","phi",nBins_);  
    FillTrendPlot(dxyPhiWidthTrend[i],dxyPhiResiduals[i],"width","phi",nBins_);
    FillTrendPlot(dzPhiMeanTrend[i]  ,dzPhiResiduals[i] ,"mean","phi",nBins_);   
    FillTrendPlot(dzPhiWidthTrend[i] ,dzPhiResiduals[i] ,"width","phi",nBins_);  
    
    FillTrendPlot(dxyEtaMeanTrend[i] ,dxyEtaResiduals[i],"mean","eta",nBins_); 
    FillTrendPlot(dxyEtaWidthTrend[i],dxyEtaResiduals[i],"width","eta",nBins_);
    FillTrendPlot(dzEtaMeanTrend[i]  ,dzEtaResiduals[i] ,"mean","eta",nBins_); 
    FillTrendPlot(dzEtaWidthTrend[i] ,dzEtaResiduals[i] ,"width","eta",nBins_);

    MakeNiceTrendPlotStyle(dxyPhiMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dxyPhiWidthTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzPhiMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzPhiWidthTrend[i],colors[i]);
  
    MakeNiceTrendPlotStyle(dxyEtaMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dxyEtaWidthTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzEtaMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzEtaWidthTrend[i],colors[i]);
    
    // DCA normalized

    FillTrendPlot(dxyNormPhiMeanTrend[i] ,dxyNormPhiResiduals[i],"mean","phi",nBins_);  
    FillTrendPlot(dxyNormPhiWidthTrend[i],dxyNormPhiResiduals[i],"width","phi",nBins_);
    FillTrendPlot(dzNormPhiMeanTrend[i]  ,dzNormPhiResiduals[i] ,"mean","phi",nBins_);   
    FillTrendPlot(dzNormPhiWidthTrend[i] ,dzNormPhiResiduals[i] ,"width","phi",nBins_);  
    
    FillTrendPlot(dxyNormEtaMeanTrend[i] ,dxyNormEtaResiduals[i],"mean","eta",nBins_); 
    FillTrendPlot(dxyNormEtaWidthTrend[i],dxyNormEtaResiduals[i],"width","eta",nBins_);
    FillTrendPlot(dzNormEtaMeanTrend[i]  ,dzNormEtaResiduals[i] ,"mean","eta",nBins_); 
    FillTrendPlot(dzNormEtaWidthTrend[i] ,dzNormEtaResiduals[i] ,"width","eta",nBins_);

    MakeNiceTrendPlotStyle(dxyNormPhiMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dxyNormPhiWidthTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzNormPhiMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzNormPhiWidthTrend[i],colors[i]);
  
    MakeNiceTrendPlotStyle(dxyNormEtaMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dxyNormEtaWidthTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzNormEtaMeanTrend[i],colors[i]);
    MakeNiceTrendPlotStyle(dzNormEtaWidthTrend[i],colors[i]);
    
  }
  
  // DCA absolute

  TCanvas *dxyPhiTrend = new TCanvas("dxyPhiTrend","dxyPhiTrend",1200,600);
  arrangeCanvas(dxyPhiTrend,dxyPhiMeanTrend,dxyPhiWidthTrend,nFiles_,LegLabels);

  dxyPhiTrend->SaveAs("dxyPhiTrend.pdf");
  dxyPhiTrend->SaveAs("dxyPhiTrend.png");

  TCanvas *dzPhiTrend = new TCanvas("dzPhiTrend","dzPhiTrend",1200,600);
  arrangeCanvas(dzPhiTrend,dzPhiMeanTrend,dzPhiWidthTrend,nFiles_,LegLabels);

  dzPhiTrend->SaveAs("dzPhiTrend.pdf");
  dzPhiTrend->SaveAs("dzPhiTrend.png");

  TCanvas *dxyEtaTrend = new TCanvas("dxyEtaTrend","dxyEtaTrend",1200,600);
  arrangeCanvas(dxyEtaTrend,dxyEtaMeanTrend,dxyEtaWidthTrend,nFiles_,LegLabels);

  dxyEtaTrend->SaveAs("dxyEtaTrend.pdf");
  dxyEtaTrend->SaveAs("dxyEtaTrend.png");

  TCanvas *dzEtaTrend = new TCanvas("dzEtaTrend","dzEtaTrend",1200,600);
  arrangeCanvas(dzEtaTrend,dzEtaMeanTrend,dzEtaWidthTrend,nFiles_,LegLabels);

  dzEtaTrend->SaveAs("dzEtaTrend.pdf");
  dzEtaTrend->SaveAs("dzEtaTrend.png");

  // DCA normalized

  TCanvas *dxyNormPhiTrend = new TCanvas("dxyNormPhiTrend","dxyNormPhiTrend",1200,600);
  arrangeCanvas(dxyNormPhiTrend,dxyNormPhiMeanTrend,dxyNormPhiWidthTrend,nFiles_,LegLabels);

  dxyNormPhiTrend->SaveAs("dxyPhiTrendNorm.pdf");
  dxyNormPhiTrend->SaveAs("dxyPhiTrendNorm.png");

  TCanvas *dzNormPhiTrend = new TCanvas("dzNormPhiTrend","dzNormPhiTrend",1200,600);
  arrangeCanvas(dzNormPhiTrend,dzNormPhiMeanTrend,dzNormPhiWidthTrend,nFiles_,LegLabels);

  dzNormPhiTrend->SaveAs("dzPhiTrendNorm.pdf");
  dzNormPhiTrend->SaveAs("dzPhiTrendNorm.png");

  TCanvas *dxyNormEtaTrend = new TCanvas("dxyNormEtaTrend","dxyNormEtaTrend",1200,600);
  arrangeCanvas(dxyNormEtaTrend,dxyNormEtaMeanTrend,dxyNormEtaWidthTrend,nFiles_,LegLabels);

  dxyNormEtaTrend->SaveAs("dxyEtaTrendNorm.pdf");
  dxyNormEtaTrend->SaveAs("dxyEtaTrendNorm.png");

  TCanvas *dzNormEtaTrend = new TCanvas("dzNormEtaTrend","dzNormEtaTrend",1200,600);
  arrangeCanvas(dzNormEtaTrend,dzNormEtaMeanTrend,dzNormEtaWidthTrend,nFiles_,LegLabels);

  dzNormEtaTrend->SaveAs("dzEtaTrendNorm.pdf");
  dzNormEtaTrend->SaveAs("dzEtaTrendNorm.png");

  // Bias plots

  TCanvas *BiasesCanvas = new TCanvas("BiasCanvas","BiasCanvas",1200,1200);
  arrangeBiasCanvas(BiasesCanvas,dxyPhiMeanTrend,dzPhiMeanTrend,dxyEtaMeanTrend,dzEtaMeanTrend,nFiles_,LegLabels);
  
  BiasesCanvas->SaveAs("BiasesCanvas.pdf");
  BiasesCanvas->SaveAs("BiasesCanvas.png");

  TCanvas *dxyPhiBiasCanvas = new TCanvas("dxyPhiBiasCanvas","dxyPhiBiasCanvas",600,600);
  TCanvas *dxyEtaBiasCanvas = new TCanvas("dxyEtaBiasCanvas","dxyEtaBiasCanvas",600,600);
  TCanvas *dzPhiBiasCanvas  = new TCanvas("dzPhiBiasCanvas","dzPhiBiasCanvas",600,600);
  TCanvas *dzEtaBiasCanvas  = new TCanvas("dzEtaBiasCanvas","dzEtaBiasCanvas",600,600);
  
  arrangeCanvas(dxyPhiBiasCanvas,dxyPhiMeanTrend,dxyPhiWidthTrend,nFiles_,LegLabels,true);
  arrangeCanvas(dzPhiBiasCanvas,dzPhiMeanTrend,dzPhiWidthTrend,nFiles_,LegLabels,true);
  arrangeCanvas(dxyEtaBiasCanvas,dxyEtaMeanTrend,dxyEtaWidthTrend,nFiles_,LegLabels,true);
  arrangeCanvas(dzEtaBiasCanvas,dzEtaMeanTrend,dzEtaWidthTrend,nFiles_,LegLabels,true);
  
  dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.pdf");
  dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.pdf");
  dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.pdf"); 
  dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.pdf"); 
  
  dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.png");
  dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.png");
  dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.png"); 
  dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.png"); 

  dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.eps");
  dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.eps");
  dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.eps"); 
  dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.eps"); 

  dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.root");
  dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.root");
  dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.root"); 
  dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.root"); 


}
Beispiel #21
0
void Config()
{
  // Libraries required by geant321
#if defined(__CINT__)
  gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_PHYSICS/include");
  gSystem->Load("libgeant321");
  LoadPhotos();
#endif

  
  new TGeant3TGeo("C++ Interface to Geant3");

  //=======================================================================
  //  Create the output file

   
  AliRunLoader* rl=0x0;

  cout<<"Config.C: Creating Run Loader ..."<<endl;
  rl = AliRunLoader::Open("galice.root",
			  AliConfig::GetDefaultEventFolderName(),
			  "recreate");
  if (rl == 0x0)
    {
      gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
      return;
    }
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(5000);
  gAlice->SetRunLoader(rl);
  
  if ( TString("VAR_TRIGGER_CONFIGURATION").Length() > 0 )
  {
    AliSimulation::Instance()->SetTriggerConfig("VAR_TRIGGER_CONFIGURATION");
    cout<<"Trigger configuration is set to VAR_TRIGGER_CONFIGURATION" << std::endl;
  }
  
  //
  //=======================================================================
  // ************* STEERING parameters FOR ALICE SIMULATION **************
  // --- Specify event type to be tracked through the ALICE setup
  // --- All positions are in cm, angles in degrees, and P and E in GeV


    gMC->SetProcess("DCAY",1);
    gMC->SetProcess("PAIR",1);
    gMC->SetProcess("COMP",1);
    gMC->SetProcess("PHOT",1);
    gMC->SetProcess("PFIS",0);
    gMC->SetProcess("DRAY",0);
    gMC->SetProcess("ANNI",1);
    gMC->SetProcess("BREM",1);
    gMC->SetProcess("MUNU",1);
    gMC->SetProcess("CKOV",1);
    gMC->SetProcess("HADR",1);
    gMC->SetProcess("LOSS",2);
    gMC->SetProcess("MULS",1);
    gMC->SetProcess("RAYL",1);

    Float_t cut = 1.e-3;        // 1MeV cut by default
    Float_t tofmax = 1.e10;

    gMC->SetCut("CUTGAM", cut);
    gMC->SetCut("CUTELE", cut);
    gMC->SetCut("CUTNEU", cut);
    gMC->SetCut("CUTHAD", cut);
    gMC->SetCut("CUTMUO", cut);
    gMC->SetCut("BCUTE",  cut); 
    gMC->SetCut("BCUTM",  cut); 
    gMC->SetCut("DCUTE",  cut); 
    gMC->SetCut("DCUTM",  cut); 
    gMC->SetCut("PPCUTM", cut);
    gMC->SetCut("TOFMAX", tofmax); 

  //======================//
  // Set External decayer //
  //======================//
  TVirtualMCDecayer* decayer = new AliDecayerPythia;
  
  /* FIXME: put back polarization switch ?
  if (polar == kNO_pol){
    decayer = new AliDecayerPythia();
  } else if (polar == kTH_pol){
    decayer = new AliDecayerPolarized(1.,AliDecayerPolarized::kHelicity,AliDecayerPolarized::kMuon);
  } else if (polar == kT_pol){
    decayer = new AliDecayerPolarized(1.,AliDecayerPolarized::kColSop,AliDecayerPolarized::kMuon);
  } else if (polar == kLH_pol){
    decayer = new AliDecayerPolarized(-1.,AliDecayerPolarized::kHelicity,AliDecayerPolarized::kMuon);
  } else if (polar == kL_pol){
    decayer = new AliDecayerPolarized(-1.,AliDecayerPolarized::kColSop,AliDecayerPolarized::kMuon);
  }
   */
  
  decayer->SetForceDecay(kAll);
  decayer->Init();
  gMC->SetExternalDecayer(decayer);

  //=========================//
  // Generator Configuration //
  //=========================//

  //AliGenerator* gener = CreateGenerator();

  std::cout << "VAR_GENERATOR settings " << std::endl;
  gROOT->LoadMacro("VAR_GENERATOR.C+");
  AliGenerator* gener = VAR_GENERATOR();
  
  TString slibs = gSystem->GetLibraries();
  TObjArray* olibs = slibs.Tokenize(" ");
  TObjString* s;
  TIter next(olibs);
  std::cout << "List of libraries=" << std::endl;
  while ( ( s = static_cast<TObjString*>(next())) )
  {
    std::cout << s->String().Data() << std::endl;
  }
  

  gener->SetOrigin(0., 0., 0.); // Taken from OCDB
  
  gener->SetSigma(VAR_VERTEX_SIGMA_X, VAR_VERTEX_SIGMA_Y, 0.);      // Sigma in (X,Y,Z) (cm) on IP position, sigmaz taken from OCDB
  gener->SetVertexSmear(kPerEvent);
  gener->Init();
  
  gener->Print();
    
  rl->CdGAFile();
  
  Int_t iABSO  = 1;
  Int_t iDIPO  = 1;
  Int_t iFMD   = 1;
  Int_t iFRAME = 1;
  Int_t iHALL  = 1;
  Int_t iITS   = 1;
  Int_t iMAG   = 1;
  Int_t iMUON  = 1;
  Int_t iPIPE  = 1;
  Int_t iSHIL  = 1;
  Int_t iT0    = 1;
  Int_t iVZERO = 1;
  Int_t iZDC   = 0;
  Int_t iAD    = 1;

    //=================== Alice BODY parameters =============================
    AliBODY *BODY = new AliBODY("BODY", "Alice envelop");

    if (iMAG)
    {
        //=================== MAG parameters ============================
        // --- Start with Magnet since detector layouts may be depending ---
        // --- on the selected Magnet dimensions ---
        AliMAG *MAG = new AliMAG("MAG", "Magnet");
    }

    if (iABSO)
    {
        //=================== ABSO parameters ============================
        AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
    }

    if (iDIPO)
    {
        //=================== DIPO parameters ============================

        AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");
    }

    if (iHALL)
    {
        //=================== HALL parameters ============================

        AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
    }

    if (iFRAME)
    {
        //=================== FRAME parameters ============================

        AliFRAMEv3 *FRAME = new AliFRAMEv3("FRAME", "Space Frame");
	FRAME->SetHoles(1);
    }

    if (iSHIL)
    {
        //=================== SHIL parameters ============================

        AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");
    }

    if (iPIPE)
    {
        //=================== PIPE parameters ============================

        AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
    }
 
    if (iITS)
    {
        //=================== ITS parameters ============================

	AliITS *ITS  = new AliITSv11("ITS","ITS v11");
    }

    if (iZDC)
    {
        //=================== ZDC parameters ============================
	
      AliZDC *ZDC = new AliZDCv4("ZDC", "normal ZDC");
      ZDC->SetLumiLength(0.);
      ZDC->SetVCollSideCAperture(2.8);
      ZDC->SetVCollSideCApertureNeg(2.8);
    }

    if (iFMD)
    {
        //=================== FMD parameters ============================

	AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
    }

    if (iMUON)
    {
        //=================== MUON parameters ===========================
        // New MUONv1 version (geometry defined via builders)
      AliMUON *MUON = new AliMUONv1("MUON", "default");
      MUON->SetTriggerEffCells(1);
      MUON->SetTriggerResponseV1(2);
    }

    if (iT0)
    {
        //=================== T0 parameters ============================
        AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
    }

    if (iVZERO)
    {
        //=================== ACORDE parameters ============================

        AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
    }

    if (iAD)
    {
        //=================== AD parameters ============================

        AliAD *AD = new AliADv1("AD", "normal AD");
    }

}
Beispiel #22
0
//___________________________________________________________
void DecodeDataString(const TString &datastring, TString &sample, TArrayI &listofruns){
  TObjArray *toks = datastring.Tokenize(":");
  sample = (dynamic_cast<TObjString *>(toks->At(0)))->String();
  TString &listrunstring = (dynamic_cast<TObjString *>(toks->At(1)))->String();
  TObjArray *runstrings = listrunstring.Tokenize(",");
  TIter runiter(runstrings);
  listofruns.Set(runstrings->GetEntriesFast());
  TObjString *myrunstring = NULL;
  Int_t counter = 0;
  while((myrunstring = dynamic_cast<TObjString *>(runiter()))) listofruns[counter++] = myrunstring->String().Atoi();  
  // Print summary:
  printf("Selected sample: %s\n", sample.Data());
  printf("========================================\n");
  for(Int_t irun = 0; irun < listofruns.GetSize(); irun++){
    printf("\trun %d\n", listofruns[irun]);
  }
  printf("\n");
  delete toks; delete runstrings;
}
Beispiel #23
0
  /** 
   * Analyse the reweighting option string and set options on task
   * appropriately.  The string is a comma or space separated list of
   * what to reweigh and how to do it. 
   *
   * What to reweigh can be specfied using one or more of the strings 
   *
   * - pt  Reweight in pT 
   * - pid Reweight particle abundance of pi, K, proton 
   * - str Reweight particles from strange weak decays 
   *
   * How to reweigh can be specifed as 
   *
   * - + or up   Increase weights (for pt < 0.05 by +30%)
   * - - or down Decrease weights (for pt < 0.05 by -30%)
   * - If none of these are given, then the weights are used as is. 
   * 
   * If pid rewighting is done and one of up or down are given, then
   * one can specify which particle type to reweigh
   *
   * - pi or pion    Reweight (up or down) pions 
   * - K  or kaon    Reweight (up or down) kaons
   * - p  or proton  Reweight (up or down) protons 
   *
   * Note, if PID, with explicit selection of pions, and strangeness
   * reweighting are specified, then the up/down flag applies to both
   * PID reweighting and the strangeness reweighting
   * 
   * @param task The task to modify 
   */
  void SetupReweighting(AliAnalysisTaskSE* task)
  {
    TString sel = fOptions.AsString("reweight");
    sel.ToLower();
    if (sel.IsNull() || sel.BeginsWith("no"))
      return;

    TList       files;
    Int_t       what = 0;
    Int_t       opt  = 0;
    TObjArray*  tokens = sel.Tokenize(", ");
    TIter       next(tokens);
    TObjString* ostr;
    // First find what should be done 
    while ((ostr = static_cast<TObjString*>(next()))) {
      const TString& token = ostr->String();
      
      if      (token.EqualTo("pt"))   {
	what |= 0x1;
	files.Add(new TObjString("REWEIGHTpt.root"));
	Printf("Will reweigh in pT");
      }
      else if (token.EqualTo("pid")) {
	what |= 0x2;
	Printf("Will reweigh particle species");
      }
      else if (token.EqualTo("str"))  {
	what |= 0x4;
	Printf("Will reweight particles from strange weak decays");
      }
    }
    if (what == 0x0) return;
    
    // Now figure out how to do it 
    next.Reset();
    TString part;
    while ((ostr = static_cast<TObjString*>(next()))) {
      const TString& token = ostr->String();
      Int_t aOpt = TMath::Abs(opt);
      if      (token.EqualTo("up")   || token.EqualTo("+")) 
	opt = (aOpt==0 ? +1 : +aOpt); 
      else if (token.EqualTo("down") || token.EqualTo("-"))
	opt = (aOpt==0 ? -1 : -aOpt);
      else if (token.EqualTo("pi")   || token.EqualTo("pion")){
	  opt = 1; part = "pi";
      }
      else if (token.EqualTo("k")    || token.EqualTo("kaon")) {
	opt = 2; part = "ka";
      }
      else if (token.EqualTo("p")    || token.EqualTo("proton")) {	  
	opt = 3; part = "pr";
      }
    }
    if (opt != 0)
      Printf("Will reweigh %s (%c30%% for pT<0.05)",
	     opt < 0 ? "down" : "up", opt < 0 ? '-' : '+');
    if (what & 0x2) {
      if (!part.IsNull()) {
	Printf("Will reweight %s in particular", part.Data());
	part.Prepend("_");
	part.Append(opt < 0 ? "-" : "+");
      }
      files.Add(new TObjString(Form("REWEIGHTpid%s.root", part.Data())));
    }
    if (what & 0x4)
      files.Add(new TObjString(Form("REWEIGHTstr%s.root",
				    opt == -1 ? "-" :
				    opt == +1 ? "+" : "")));
    delete tokens;

    Printf("Setting reweighing flag=0x%x with option=%d", what, opt);
    SetOnTask(task, "ReweightStack", what);
    SetOnTask(task, "ReweightFlag",  opt);

    TIter nextF(&files);
    while ((ostr = static_cast<TObjString*>(nextF()))) {
      Printf("Loading reweighting file %s", ostr->GetName());
      fRailway->LoadAux(ostr->GetName());
    }
  }
Beispiel #24
0
void build(const char *filename,const char *lib = 0, const char *obj = 0) 
{
   if (obj!=0 && strlen(obj) ) {
      TString s = gSystem->GetMakeSharedLib();
      TString r(" $ObjectFiles ");
      r.Append(obj);
      s.ReplaceAll(" $ObjectFiles",r);
      //gDebug = 5;
      gSystem->SetMakeSharedLib(s);
   }
   if (lib && strlen(lib)) {
      TString liblist(lib);
      TObjArray *libs = liblist.Tokenize(" ");
      TIter iter(libs);
      TObjString *objstr;

      TString s = gSystem->GetMakeSharedLib();
      TString what("..nothing..");
      if (s.Contains("$DepLibs")) {
         what = " $DepLibs";
      } else {
         what = " $LinkedLibs";
      }
      TString libstolink(" ");
      while ( (objstr=(TObjString*)iter.Next()) ) {
         gSystem->Load(objstr->String());
         TString libfile( gSystem->GetLibraries(objstr->String(),"DSL",kFALSE));
         libstolink.Append(libfile);
         libstolink.Append(" ");
      }
      libstolink.Append(what);
      s.ReplaceAll(what,libstolink);
      gSystem->SetMakeSharedLib(s);
   }
#ifdef __CLING__
   TString r;
#ifdef  ClingWorkAroundCallfuncAndInline
   r.Append(" -DClingWorkAroundCallfuncAndInline ");
#endif
#ifdef  ClingWorkAroundCallfuncAndVirtual
   r.Append(" -DClingWorkAroundCallfuncAndVirtual ");
#endif
#ifdef ClingWorkAroundJITandInline
   r.Append(" -DClingWorkAroundJITandInline ");
#endif
#ifdef ClingWorkAroundCallfuncAndReturnByValue
   r.Append(" -DClingWorkAroundCallfuncAndReturnByValue ");
#endif
#ifdef ClingWorkAroundNoPrivateClassIO
   r.Append(" -DClingWorkAroundNoPrivateClassIO ");
#endif
   if (r.Length()) {
      r.Append(" $IncludePath");
      TString s = gSystem->GetMakeSharedLib();
      s.ReplaceAll(" $IncludePath",r);
      gSystem->SetMakeSharedLib(s);
   }
#endif
      
#if defined(_WIN32) && !defined(__CYGWIN__)
   TString fname(filename);
   if (filename[0]=='/') {
     // full path name we need to turn it into a windows path
     fname = gSystem->GetFromPipe(TString::Format("cygpath -w %s",filename));
   }
   fprintf(stderr,"from %s to %s\n",filename,fname.Data());
   int result = gSystem->CompileMacro(fname,"kc");
#else
   int result = gSystem->CompileMacro(filename,"kc");
#endif
   if (!result) gApplication->Terminate(1);
}
void MakeAllDETsFullMisAlignment(Char_t* CDBstorage = "local://$HOME/FullMisAlignment", Bool_t partialGeom=kFALSE){
   // Make full misalignment objects for all detectors
  // Pass different "CDBstorage" argument if needed (e.g. to fill
  // conditions' data base on alien) or set it to null string to have
  // the objects saved locally on file 
  // This macro defines the default name and place for the detector-macros
  // in charge of producing the full misalignment objects as 
  // $ALICE_ROOT/DET/MakeDETFullMisAlignment.C
  //
  const char* macroname="MakeAllDETsFullMisAlignment.C";

  TString strStorage(CDBstorage);
  if(strStorage.IsNull()){
    gSystem->Setenv("TOCDB","kFALSE");
  }else{  
    gSystem->Setenv("TOCDB","kTRUE");
    gSystem->Setenv("STORAGE",strStorage.Data());
    gSystem->Setenv("ARVERSION",ALIROOT_VERSION);
  }
  if(partialGeom){
    gSystem->Setenv("REALSETUP","kTRUE");
  }else{
    gSystem->Setenv("REALSETUP","kFALSE");
  }

  // Load geometry from CDB updating it if we are producing the
  // alignment objects for the CDB
  AliCDBManager* cdb = AliCDBManager::Instance();
  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  cdb->SetRun(0);
  
  if(strStorage.IsNull()){ //if we produce the objects into a file
    AliGeomManager::LoadGeometry(); //load geom from default CDB storage
  }else{ // if we produce the objects in a CDB storage
    // update geometry in it
    Info(macroname,"Updating geometry in CDB storage %s",strStorage.Data());
    gROOT->ProcessLine(".L $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C");
    if(partialGeom){
      UpdateCDBIdealGeom(strStorage.Data(),"$ALICE_ROOT/macros/Config_PDC06.C");
    }else{
      UpdateCDBIdealGeom(strStorage.Data(),"$ALICE_ROOT/macros/Config.C");
    }
    // load the same geometry from given CDB storage
    AliCDBPath path("GRP","Geometry","Data");
    AliCDBStorage* storage = cdb->GetStorage(strStorage.Data());
    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
    if(!entry) Fatal(macroname,"Couldn't load geometry data from CDB!");
    entry->SetOwner(0);
    TGeoManager* geom = (TGeoManager*) entry->GetObject();
    if (!geom) Fatal(macroname,"Couldn't find TGeoManager in the specified CDB entry!");
    AliGeomManager::SetGeometry(geom);
  }
   
  // run macro for non-sensitive modules
  // (presently generates only FRAME alignment objects)
  gSystem->Exec("aliroot -b -q $ALICE_ROOT/GRP/MakeSTRUCTFullMisAlignment.C");

  // run macros for sensitive modules
  TString sModules="ACORDE,EMCAL,FMD,HMPID,ITS,MUON,PMD,PHOS,T0,TRD,TPC,TOF,VZERO,ZDC";
  TObjArray *detArray = sModules.Tokenize(',');
  TIter iter(detArray);
  TObjString *ostr;
  TString exec_det_macro;

  while((ostr = (TObjString*) iter.Next())){
    TString str(ostr->String());
    exec_det_macro="aliroot -b -q $ALICE_ROOT/";
    exec_det_macro+=str;
    exec_det_macro+="/Make";
    exec_det_macro+=str;
    exec_det_macro+="FullMisAlignment.C";
    
    gSystem->Exec(exec_det_macro.Data());
  }

  return;
}
Beispiel #26
0
void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug=0) {
  // Loads libs and par files + custom task and classes

  // Custom stuff to be loaded
  //  listToLoad->Add(new TObjString("$ALICE_ROOT/ANALYSIS/AliCentralitySelectionTask.cxx+"));
  listToLoad->Add(new TObjString("/Users/mfloris/Work/AliSoft/AliRoot-trunk/PWGPP/background/AliHistoListWrapper.cxx+")); // FIXME
  listToLoad->Add(new TObjString("AliAnalysisMultPbTrackHistoManager.cxx+"));
  listToLoad->Add(new TObjString("AliAnalysisMultPbCentralitySelector.cxx+"));
  listToLoad->Add(new TObjString("AliAnalysisTaskMultPbTracks.cxx+"));
  // listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbTrackHistoManager.cxx+"));
  // listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbCentralitySelector.cxx+"));
  // listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskMultPbTracks.cxx+"));


  if (runMode == kMyRunModeCAF)
    {
      cout << "Init in CAF mode" << endl;
    
      gEnv->SetValue("XSec.GSI.DelegProxy", "2");
      //      TProof::Mgr("alice-caf.cern.ch")->SetROOTVersion("VO_ALICE@ROOT::v5-30-03-1");
      TProof::Mgr("alice-caf.cern.ch")->SetROOTVersion("current");
      TProof * p = TProof::Open("alice-caf.cern.ch", workers>0 ? Form("workers=%d",workers) : "1x");
      //      TProof * p = TProof::Open("skaf.saske.sk", workers>0 ? Form("workers=%d",workers) : "");    
      p->Exec("TObject *o = gEnv->GetTable()->FindObject(\"Proof.UseMergers\"); gEnv->GetTable()->Remove(o);", kTRUE);

      //      TProof::Mgr("alice-caf.cern.ch")->SetROOTVersion("VO_ALICE@ROOT::v5-28-00f");
      gProof->EnablePackage("VO_ALICE@AliRoot::v5-02-12-AN");
      gSystem->Load("libCore");
      gSystem->Load("libTree");
      gSystem->Load("libGeom");
      gSystem->Load("libVMC");
      gSystem->Load("libPhysics");
      gSystem->Load("libMinuit");
      gSystem->Load("libSTEERBase");
      gSystem->Load("libESD");
      gSystem->Load("libAOD");
      gSystem->Load("libANALYSIS");
      gSystem->Load("libOADB");
      gSystem->Load("libANALYSISalice");   

      // Enable the needed package
      // gProof->UploadPackage("$ALICE_ROOT/obj/STEERBase");
      // gProof->EnablePackage("$ALICE_ROOT/obj/STEERBase");
      // gProof->UploadPackage("$ALICE_ROOT/obj/ESD");
      // gProof->EnablePackage("$ALICE_ROOT/obj/ESD");
      // gProof->UploadPackage("$ALICE_ROOT/obj/AOD");
      // gProof->EnablePackage("$ALICE_ROOT/obj/AOD");
      // gProof->UploadPackage("$ALICE_ROOT/obj/ANALYSIS");
      // gProof->EnablePackage("$ALICE_ROOT/obj/ANALYSIS");
      // gProof->UploadPackage("$ALICE_ROOT/obj/OADB");
      // gProof->EnablePackage("$ALICE_ROOT/obj/OADB");
      // gProof->UploadPackage("$ALICE_ROOT/obj/ANALYSISalice");
      // gProof->EnablePackage("$ALICE_ROOT/obj/ANALYSISalice");
      // gProof->UploadPackage("$ALICE_ROOT/obj/PWG0base");
      // gProof->EnablePackage("$ALICE_ROOT/obj/PWG0base");
      // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/include"));
      // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb"));
      // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background"));
    }
  else if (runMode == kMyRunModeProofLite)
    {
      cout << "Init in CAF mode" << endl;
    
      gEnv->SetValue("XSec.GSI.DelegProxy", "2");
      TProof * p = TProof::Open("");
      //      TProof * p = TProof::Open("skaf.saske.sk", workers>0 ? Form("workers=%d",workers) : "");    
      //      p->Exec("TObject *o = gEnv->GetTable()->FindObject(\"Proof.UseMergers\"); gEnv->GetTable()->Remove(o);", kTRUE);

      //      TProof::Mgr("alice-caf.cern.ch")->SetROOTVersion("VO_ALICE@ROOT::v5-28-00f");
      //      TProof::Mgr("alice-caf.cern.ch")->SetROOTVersion("5.28/00f");
      gProof->UploadPackage("$ALICE_ROOT/ANALYSIS/macros/AliRootProofLite.par");
      gProof->EnablePackage("AliRootProofLite");

    }
  else
    {
      cout << "Init in Local or Grid mode" << endl;
      gSystem->Load("libCore");
      gSystem->Load("libTree");
      gSystem->Load("libGeom");
      gSystem->Load("libVMC");
      gSystem->Load("libPhysics");
      gSystem->Load("libMinuit");
      gSystem->Load("libSTEERBase");
      gSystem->Load("libESD");
      gSystem->Load("libAOD");
      gSystem->Load("libANALYSIS");
      gSystem->Load("libOADB");
      gSystem->Load("libANALYSISalice");   
      // Use AliRoot includes to compile our task
      gROOT->ProcessLine(".include $ALICE_ROOT/include");

      // gSystem->Load("libVMC");
      // gSystem->Load("libTree");
      // gSystem->Load("libSTEERBase");
      // gSystem->Load("libESD");
      // gSystem->Load("libAOD");
      // gSystem->Load("libANALYSIS");
      // gSystem->Load("libANALYSISalice");
      // gSystem->Load("libPWG0base");
    
      gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb"));
      gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWGPP/background"));
      //    gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWGPP/background/"));
    }
  // Load helper classes
  TIterator * iter = listToLoad->MakeIterator();
  TObjString * name = 0;
  while (name = (TObjString *)iter->Next()) {
    gSystem->ExpandPathName(name->String());
    cout << name->String().Data();
    if (runMode == kMyRunModeCAF || runMode == kMyRunModeProofLite) {
      gProof->Load(name->String()+(debug?"+g":""));   
    } else {
      gROOT->LoadMacro(name->String()+(debug?"+g":""));   
    }
  }

}