ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yangyong/zSelection/getGoodLS.cc
Revision: 1.1
Committed: Fri Sep 30 15:23:48 2011 UTC (13 years, 7 months ago) by yangyong
Content type: text/plain
Branch: MAIN
CVS Tags: V01-00-01, V01-00-00, HEAD
Log Message:
z selection code

File Contents

# User Rev Content
1 yangyong 1.1
2    
3    
4     vector<int> run_goodLS;
5    
6     map<int,vector<int> > map_runLS;
7    
8     vector<int> goodRunList;
9    
10     vector<int> crabRunList;
11    
12    
13    
14    
15     //get LS ranges
16     /// t3-susy [data/analysisMX] cat Cert_132440-142664_7TeV_StreamExpress_Collisions10_CMSSWConfig.txt | grep : | grep - | sed s/"-"/" "/g | sed s/":"/" "/g | sed s/"'"/""/g | sed s/","/""/g
17    
18    
19     ///this is from the offical JSON files of reReco or promptReco
20     ///not exactly the same as crabRunList.
21    
22     ///update for multiple Json file
23    
24     void getLSrangeofEachRuns(vector<string> certfiles){
25    
26     if(certfiles.size() <=0){
27     cout<<" getLSrangeofEachRuns No certfile " << endl;
28     exit(1);
29     }
30    
31    
32     int run;
33     int ls1;
34     int ls2;
35    
36     int prerun = 0;
37    
38     vector<int> lsbl;
39    
40     for(int n=0; n< int(certfiles.size()); n++){
41    
42     cout<<"certfile: "<< certfiles[n].c_str() <<endl;
43     ifstream txtin(certfiles[n].c_str(),ios::in);
44    
45     while( txtin.good()){
46    
47     txtin >> run >> ls1 >> run >> ls2;
48    
49     /// cout<<run<<" "<< ls1 <<" "<< ls2 <<endl;
50     bool newrun = false;
51     if(run != prerun){
52     newrun = true;
53    
54     }
55    
56     vector<int>::iterator it = find( goodRunList.begin(),goodRunList.end(),run);
57     if( it == goodRunList.end()){
58     goodRunList.push_back(run);
59     }
60    
61     /// cout<<"run: "<<prerun<<" "<<run <<endl;
62    
63    
64     if( newrun){
65    
66     if( int(lsbl.size()) >0){
67     //insert into map
68     map_runLS.insert( make_pair(prerun,lsbl));
69     }
70    
71     prerun = run;
72    
73     lsbl.clear();
74    
75    
76     }
77    
78     lsbl.push_back(ls1);
79     lsbl.push_back(ls2);
80    
81    
82     }
83     }
84    
85    
86     map_runLS.insert( make_pair(run,lsbl));
87    
88    
89     cout<<"total runs: "<< goodRunList.size()<<" "<< map_runLS.size()<<endl;
90    
91    
92     for(int n=0; n< int( goodRunList.size());n++){
93    
94     map<int,vector<int> > :: const_iterator iterMap = map_runLS.find(goodRunList[n]);
95    
96     if( iterMap != map_runLS.end()){
97    
98    
99     vector<int> tmp = iterMap->second;
100    
101     for(int j=0; j< int(tmp.size())/2; j++){
102     if( n<10 || n >int( goodRunList.size())-10 ) cout<< goodRunList[n]<<" "<< tmp[j*2] <<" "<< tmp[2*j+1]<<endl;
103     }
104    
105     }else{
106     cout<<"wrongcheckmaprunLS.."<<endl;
107     exit(1);
108     }
109     }
110    
111    
112     }
113    
114    
115    
116     bool checkLumiBlockofRun(){
117    
118    
119     if(dataOrMC==2) return true;
120    
121     bool goodLS = false;
122    
123     map<int,vector<int> > :: const_iterator iterMap = map_runLS.find(runNumber);
124    
125     if( iterMap != map_runLS.end()){
126     vector<int> tmp = iterMap->second;
127    
128     for(int j=0; j< int(tmp.size())/2; j++){
129     if( tmp[j*2] <= lumiBlock && lumiBlock <= tmp[2*j+1]){
130     goodLS = true;
131     break;
132     }
133     }
134    
135     }else{
136     cout<<"wrong.. no run found.." << runNumber <<endl;
137     //exit(1);
138     return false;
139     }
140    
141     return goodLS;
142    
143    
144     }