]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoQAEventCut.cxx
Fix Coverity report
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemtoUser / AliFemtoQAEventCut.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 //                                                                            //
3 // AliFemtoQAEventCut - the basic cut to check QA for event cuts.             //
4 // Only cuts on event multiplicity and z-vertex position                      //
5 //                                                                            //
6 ////////////////////////////////////////////////////////////////////////////////
7
8 #include "AliFemtoQAEventCut.h"
9 //#include <cstdio>
10
11 #ifdef __ROOT__
12 ClassImp(AliFemtoQAEventCut)
13 #endif
14
15 AliFemtoQAEventCut::AliFemtoQAEventCut() :
16   AliFemtoEventCut(),
17   fEventMult(),
18   fVertZPos(),
19   fAcceptBadVertex(false), 
20   fNEventsPassed(0), 
21   fNEventsFailed(0),
22   fHighOrLowSwitch(0), 
23   fEventMultQASwitch(kFALSE), 
24   fEventZPosQASwitch(kFALSE)
25 {
26   // Default constructor
27   fEventMult[0] = 0;
28   fEventMult[1] = 100000;
29   fVertZPos[0] = -100.0;
30   fVertZPos[1] = 100.0;
31   
32   fHighOrLowSwitch = 1;
33   fEventMultQASwitch = false;
34   fEventZPosQASwitch = false;
35   fEventMultQAExclusionZone[0] = 0;
36   fEventMultQAExclusionZone[1] = 100000;
37   fEventZPosQAExclusionZone[0] = -100.0;
38   fEventZPosQAExclusionZone[1] = 100.0;
39
40
41 //------------------------------
42 AliFemtoQAEventCut::~AliFemtoQAEventCut(){
43   // Default destructor
44 }
45 //------------------------------
46 bool AliFemtoQAEventCut::Pass(const AliFemtoEvent* event){
47   // Pass events if they fall within the multiplicity and z-vertex
48   // position range. If QA cutting on quantity, pass if outside 
49   // exclusion zone between low and high cut values. Fail otherwise.
50   int mult =  event->NumberOfTracks();
51   double vertexZPos = event->PrimVertPos().z();
52   cout << "AliFemtoQAEventCut:: mult:       " << fEventMult[0] << " < " << mult << " < " << fEventMult[1] << endl;
53   cout << "AliFemtoQAEventCut:: VertexZPos: " << fVertZPos[0] << " < " << vertexZPos << " < " << fVertZPos[1] << endl;
54   
55   bool goodEvent;
56   
57   if (fEventMultQASwitch) {
58     goodEvent =
59       ( (((mult < fEventMultQAExclusionZone[0]) && (fHighOrLowSwitch > 0))  ||
60          ((mult > fEventMultQAExclusionZone[1]) && (fHighOrLowSwitch < 0))) &&
61       (mult > fEventMult[0]) && 
62       (mult < fEventMult[1]) && 
63       (vertexZPos > fVertZPos[0]) &&
64       (vertexZPos < fVertZPos[1]) &&
65       (fAcceptBadVertex || (event->PrimVertCov()[4] > -1000.0)));
66   }
67   else if (fEventZPosQASwitch) {
68     goodEvent =
69       ((((vertexZPos < fEventZPosQAExclusionZone[0]) && (fHighOrLowSwitch > 0))  ||
70         ((vertexZPos > fEventZPosQAExclusionZone[1]) && (fHighOrLowSwitch < 0))) &&
71       (mult > fEventMult[0]) && 
72       (mult < fEventMult[1]) && 
73       (vertexZPos > fVertZPos[0]) &&
74       (vertexZPos < fVertZPos[1]) &&
75       (fAcceptBadVertex || (event->PrimVertCov()[4] > -1000.0)));
76   }
77   else {
78   goodEvent =
79     ((mult > fEventMult[0]) && 
80      (mult < fEventMult[1]) && 
81      (vertexZPos > fVertZPos[0]) &&
82      (vertexZPos < fVertZPos[1]) &&
83      (fAcceptBadVertex || (event->PrimVertCov()[4] > -1000.0)));
84   }
85   
86   if (goodEvent) fHighOrLowSwitch *= -1;
87   goodEvent ? fNEventsPassed++ : fNEventsFailed++ ;
88   //cout << "AliFemtoQAEventCut:: return : " << goodEvent << endl;
89   return (goodEvent);
90 }
91 //------------------------------
92 AliFemtoString AliFemtoQAEventCut::Report(){
93   // Prepare report
94   string stemp;
95   char ctemp[100];
96   snprintf(ctemp , 100, "\nMultiplicity:\t %d-%d",fEventMult[0],fEventMult[1]);
97   stemp = ctemp;
98   snprintf(ctemp , 100, "\nVertex Z-position:\t %E-%E",fVertZPos[0],fVertZPos[1]);
99   stemp += ctemp;
100   snprintf(ctemp , 100, "\nNumber of events which passed:\t%ld  Number which failed:\t%ld",fNEventsPassed,fNEventsFailed);
101   stemp += ctemp;
102   AliFemtoString returnThis = stemp;
103   return returnThis;
104 }
105 void AliFemtoQAEventCut::SetAcceptBadVertex(bool b)
106 {
107   fAcceptBadVertex = b;
108 }
109 bool AliFemtoQAEventCut::GetAcceptBadVertex()
110 {
111   return fAcceptBadVertex;
112 }