ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/AnaEvent.cc
Revision: 1.2
Committed: Tue Apr 23 09:27:55 2013 UTC (12 years ago) by konec
Content type: text/plain
Branch: MAIN
CVS Tags: Artur_11_07_2013_B, Artur_11_07_2013_A, Artur_11_07_2013, Artur_28_06_2013, HEAD
Changes since 1.1: +1 -1 lines
Error occurred while calculating annotation data.
Log Message:
*** empty log message ***

File Contents

# Content
1 #include "UserCode/L1RpcTriggerAnalysis/interface/AnaEvent.h"
2 #include "TObjArray.h"
3 #include "TH1D.h"
4 #include "TH2D.h"
5 #include "TGraphErrors.h"
6 #include "FWCore/ParameterSet/interface/ParameterSet.h"
7 #include "UserCode/L1RpcTriggerAnalysis/interface/EventObj.h"
8 #include "UserCode/L1RpcTriggerAnalysis/interface/EventObjBXExtra.h"
9 #include <sstream>
10 #include <fstream>
11 #include <iostream>
12 #include <cmath>
13
14 namespace {
15 TH1D *hEvent_BX, *hEvent_BX_val, *hEvent_BX_nm2, *hEvent_BX_np2;
16 }
17
18 AnaEvent::AnaEvent(const edm::ParameterSet& cfg)
19 : debug(false),
20 theUseValidBX_ONLY(false),
21 theUseValidBX_NoBxMinus2_ONLY(false),
22 theUseValidBX_NoBxPlus2_ONLY(false)
23 {
24
25 theSkipRuns = cfg.getParameter<std::vector<unsigned int> >("skipRuns");
26 std::sort(theSkipRuns.begin(), theSkipRuns.end());
27
28 if (cfg.exists("useValidBX_ONLY")) theUseValidBX_ONLY = cfg.getParameter<bool>("useValidBX_ONLY");
29 if (cfg.exists("useValidBX_NoBxMinus2_ONLY")) theUseValidBX_NoBxMinus2_ONLY = cfg.getParameter<bool>("useValidBX_NoBxMinus2_ONLY");
30 if (cfg.exists("useValidBX_NoBxPlus2_ONLY")) theUseValidBX_NoBxPlus2_ONLY = cfg.getParameter<bool>("useValidBX_NoBxPlus2_ONLY");
31
32 std::ifstream infile( cfg.getParameter<std::string>("validBXes") );
33 while (infile.good() && infile.peek() != EOF) {
34 char c = infile.peek();
35 if ( c=='#') infile.ignore(256,'\n'); //comment
36 else if ( c==',' || c==' ' || c=='\n') infile.ignore();
37 else if ( (c >= '0') && (c <= '9') ) {int bx; infile >>bx; theValidBX.set(bx);}
38 else { std::cout <<"Unexpected input file formatting, line is>>>"<<c<<"<<<"<<std::endl;infile.ignore(); }
39 }
40 infile.close();
41 }
42
43 bool AnaEvent::filter(EventObj* ev)
44
45 {
46 // skip if wrong run
47 if ( binary_search(theSkipRuns.begin(), theSkipRuns.end(), ev->run ) ) return false;
48 /*
49 if (ev->run == 200466) {
50 std::cout <<"RUN IS: "<< ev->run <<std::endl;
51 std::cout <<" result of search: "<< binary_search(theSkipRuns.begin(), theSkipRuns.end(), ev->run ) << std:endl;
52 std::cout <<"runs are: "; for
53 exit(7);
54 }
55 */
56
57 // skip if event duplication
58 if ( theRunEvent.find(std::make_pair(ev->run, ev->id) ) == theRunEvent.end()) theRunEvent[std::make_pair(ev->run, ev->id)] = ev->time;
59 else return false;
60
61 // filter BXes
62 bool validBXm2 = ( (int)ev->bx-2>=0 && theValidBX[ev->bx-2] );
63 bool validBXp2 = ( ev->bx+2<=3563 && theValidBX[ev->bx+2] );
64
65 //control histograms
66
67 if (theUseValidBX_ONLY && !theValidBX[ev->bx]) return false;
68 hEvent_BX->Fill(ev->bx);
69 if (theUseValidBX_NoBxMinus2_ONLY && validBXm2) return false;
70 if (theUseValidBX_NoBxPlus2_ONLY && validBXp2) return false;
71
72 if (theValidBX[ev->bx]) hEvent_BX_val->Fill(ev->bx);
73 if (!validBXm2) hEvent_BX_nm2->Fill(ev->bx);
74 if (!validBXp2) hEvent_BX_np2->Fill(ev->bx);
75
76 //fill eventExtra structure
77 if ( EventObjBXExtra* evbx = dynamic_cast<EventObjBXExtra*>(ev) ) {
78 evbx->hasValidBX = theValidBX[evbx->bx];
79 evbx->hasValidBX_Minus2 = validBXm2;
80 evbx->hasValidBX_Plus2 = validBXp2;
81 }
82
83 return true;
84 }
85
86 void AnaEvent::resume(TObjArray& histos)
87 {
88 }
89
90 void AnaEvent::init(TObjArray& histos)
91 {
92 hEvent_BX = new TH1D("hEvent_BX","hEvent_BX",3564,0., 3564.); histos.Add( hEvent_BX);
93 hEvent_BX_val = new TH1D("hEvent_BX_val","hEvent_BX_val",3564,0., 3564.); histos.Add( hEvent_BX_val);
94 hEvent_BX_nm2 = new TH1D("hEvent_BX_nm2","hEvent_BX_nm2",3564,0., 3564.); histos.Add( hEvent_BX_nm2);
95 hEvent_BX_np2 = new TH1D("hEvent_BX_np2","hEvent_BX_np2",3564,0., 3564.); histos.Add( hEvent_BX_np2);
96 }