]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/JCORRAN/AliJRunTable.cxx
Fixing compilation issues after merging
[u/mrichter/AliRoot.git] / PWGCF / Correlations / JCORRAN / AliJRunTable.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // Comment describing what this class does needed!
17
18 #include "AliJRunTable.h"
19
20 #include <iostream>
21 #include <cstdlib>
22 #include <TSystem.h>
23 #include <TPRegexp.h>
24 using namespace std;
25
26 AliJRunTable::AliJRunTable() :
27   fCPeriod(0),
28   fCRunNumber(0),
29   fCPeriodMCName("undefined")
30 {
31   Init();
32 }
33
34 void AliJRunTable::Init(){
35   // comment needed
36     SetPeriodInformation( kUnknownPeriod, "UnknownPeriod", kPP, kRE, 0, -1, -1, "UnKnownPeriod" );
37     SetPeriodInformation( kLHC10b, "LHC10b", kPP, kRE, 7000, 114737, 117223, "LHC10d1" );
38     SetPeriodInformation( kLHC10c, "LHC10c", kPP, kRE, 7000, 118503, 121040, "LHC10d4" );
39     SetPeriodInformation( kLHC10d, "LHC10d", kPP, kRE, 7000, 122195, 126437, "LHC10f6a" );
40     SetPeriodInformation( kLHC10e, "LHC10e", kPP, kRE, 7000, 127712, 130850, "LHC10e20" );
41     SetPeriodInformation( kLHC10h, "LHC10h", kPbPb, kRE, 2760, 136851, 139517, "LHC11a10a_bis" );
42     SetPeriodInformation( kLHC11h, "LHC11h", kPbPb, kRE, 2760, 167813, 170309, "LHC12a17d_fix" );
43
44     //LHC11a
45     SetPeriodInformation(kLHC11a, "LHC11a", kPP, kRE, 2760, 144871, 146860, "LHC11b10a" );
46
47     // pp 7TeV LHC11bcde
48     SetPeriodInformation( kLHC11b, "LHC11b", kPP, kRE, 7000, 0, 0, "LHC12d2_plus" );
49     SetPeriodInformation( kLHC11c, "LHC11c", kPP, kRE, 7000, 153533, 154789, "LHC12d2_plus" );
50     SetPeriodInformation( kLHC11d, "LHC11d", kPP, kRE, 7000, 156620, 159580, "LHC12d2_plus" );
51     SetPeriodInformation( kLHC11e, "LHC11e", kPP, kRE, 7000, 0, 0, "LHC12d2_plus" );
52
53     // LHC12g - TODO
54     SetPeriodInformation( kLHC12g, "LHC12g",kPA, kRE, 5020, 188356,188503, "LHC13b2" );
55     SetPeriodInformation( kLHC12h, "LHC12h",kPA, kRE, 5020, 189122,192732, "LHC13b2" );
56     SetPeriodInformation( kLHC13b, "LHC13b",kPA, kRE, 5020, 195344,195483, "LHC13b2-efix_p1" );
57     SetPeriodInformation( kLHC13c, "LHC13c",kPA, kRE, 5020, 195529,195677, "LHC13b2-efix_p1" );
58     SetPeriodInformation( kLHC13d, "LHC13d",kPA, kRE, 5020, 195724,195872, "LHC13b2-efix_p1" );
59     SetPeriodInformation( kLHC13e, "LHC13e",kPA, kRE, 5020, 195955,196310, "LHC13b2-efix_p1" );
60     SetPeriodInformation( kLHC13g, "LHC13g",kPA, kRE, 5020, 197669,200000, "LHC13b2-efix_p1" );
61 }
62
63
64 TString AliJRunTable::GetPeriodName( int period ) const {
65     // TODO 
66     if( period < 0 ) period = fCPeriod;
67     return fPeriodName[period];
68 }
69
70 int AliJRunTable::GetRunNumberToPeriod( int runnumber ){
71   // comment needed
72     int period = -1;
73     for( int ip=0;ip<kJNPeriod;ip++ ){
74         if(fDataType[ip] == kMC ) continue;
75         if( runnumber >= fRunRange[ip][0] && runnumber <= fRunRange[ip][1] ){
76             cout<< fPeriodName[ip] <<"\t"<<fRunRange[ip][0]<<"~"<<fRunRange[ip][1]<<endl;
77             period = ip;
78             break;
79         }
80     }
81     if( period < 0 ){ 
82         cout<<"J_ERROR : no period for runnumber "<<runnumber<<endl;
83         gSystem->Exit(1);
84     }
85     return period;
86 }
87
88 void AliJRunTable::SetPeriodInformation(int period, TString name, int beamtype, int datatype, int energy, int run0, int run1, TString MCPeriod){
89   // comment needed
90     fPeriodName[period] = name;
91     fBeamType[period] = beamtype;
92     fDataType[period] = datatype;
93     fEnergy[period] = energy;
94     fRunRange[period][0] = run0;
95     fRunRange[period][1] = run1;
96     fMCPeriod[period] = MCPeriod;
97 }
98
99
100 int AliJRunTable::GetPeriodCode( TString perstr ) const{
101   // comment needed
102     int period = kUnknownPeriod;
103     for( int ip=0;ip<kJNPeriod;ip++ ){
104         if( perstr == GetPeriodName(ip) ){
105             period = ip;
106             break;
107         }
108     }
109     if( period <0 ){
110         cout<<"J_ERROR : no period for "<<perstr<<endl;
111     }
112     return period;
113
114 }
115
116 int AliJRunTable::GetRunNumberFromString(const char * tstr ){
117   // comment needed
118     TPMERegexp rexRunNumber( "1\\d{5}" );
119     rexRunNumber.Match(tstr);
120     return TString(rexRunNumber[0]).Atoi();
121 }
122
123 TString AliJRunTable::GetPeriodFromString(const char * tstr ) const{
124   // comment needed
125     TPMERegexp rexPeriod( "LHC1\\d[a-zA-Z]" );
126     rexPeriod.Match(tstr);
127     return rexPeriod[0];
128 }
129
130 TString AliJRunTable::GetMCPeriodFromString(const char * tstr ) const{
131   // comment needed
132     TPMERegexp rexPeriod( "LHC1\\d[a-zA-Z0-9]{2,}(\\w+)?" );
133     rexPeriod.Match(tstr);
134     return rexPeriod[0];
135 }
136
137 int AliJRunTable::GetPeriodFromMCPeriod( const char * tstr ){
138   // comment needed
139     int period = -1;
140     for( int ip=0;ip<kJNPeriod;ip++ ){
141         if(fDataType[ip] == kMC ) continue;
142         if( fMCPeriod[ip] == TString(tstr) ){
143             period = ip;
144             break;
145         }
146     }
147     if( period < 0 ){ 
148         cout<<"J_ERROR : no period for MCPeriod "<<tstr<<endl;
149         exit(1);
150     }
151     return period;
152 }
153
154 bool AliJRunTable::ParseString( const char * tstr ){
155   // comment needed
156     fCRunNumber = GetRunNumberFromString(tstr);
157     fCPeriodMCName = GetMCPeriodFromString(tstr);
158     if( fCRunNumber > 0 ){
159         fCPeriod = GetRunNumberToPeriod( fCRunNumber );
160     }else
161     if( fCPeriodMCName.Length() > 0 ){
162         fCPeriod = GetPeriodFromMCPeriod( fCPeriodMCName );
163     }else{
164         fCPeriod = kUnknownPeriod;
165     }
166     return true;
167 }
168
169 // GetBeamStr is never used anywhere. Should it be removed altogether?
170 const char * AliJRunTable::GetBeamStr( int ib ) const {
171   // comment needed
172     if( ib < 0 ) ib = fBeamType[fCPeriod]; 
173     switch (ib){
174         case kPP : return "pp";
175         case kPbPb: return "PbPb";
176         case kPA:   return "PA";
177     }
178     return NULL;
179 }
180
181 const char * AliJRunTable::GetDataStr( int ib ) const {
182   // comment needed
183     if( ib < 0 ) ib = fDataType[fCPeriod]; 
184     switch (ib){
185         case kRE: return "REAL";
186         case kMC: return "MC";
187     }
188     return NULL;
189 }
190 AliJRunTable& AliJRunTable::GetSpecialInstance(){
191   // comment needed
192     static AliJRunTable instance;
193     return instance;
194 }
195
196 // GetEnergyStr is never used anywhere. Should it be removed altogether?
197 const char * AliJRunTable::GetEnergyStr( int ib ) const {
198   // comment needed
199     if( ib < 0 ) ib = fEnergy[fCPeriod]; 
200     if( ib < 1000 ) return Form("%dGeV",ib);
201     if( ib == 2760 ) return "2.76TeV";
202     return Form("%dTeV",ib/1000);
203 }
204
205 const AliJRunTable& AliJRunTable::GetInstance(){
206   // comment needed
207     return GetSpecialInstance();
208 }