StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BemcTwMask.cxx
1 #include <iostream>
2 #include <fstream>
3 #include <istream>
4 #include <sstream>
5 using namespace std;
6 
7 #include <TPad.h>
8 #include <TH2.h>
9 #include <TF1.h>
10 #include <TEnv.h>
11 
12 #include <TPaveStats.h>
13 #include <TStyle.h> // for gPad
14 #include <TROOT.h> // for gROOT
15 #include <TSystem.h>
16 #include <TMath.h>
17 
18 #include <StMessMgr.h>
19 
20 #include "BemcTwMask.h"
21 
22 //--------------------------------------
23 BemcTwMask::BemcTwMask()
24  : txtH(0)
25  , nMask(0)
26 {
27 }
28 
29 //--------------------------------------
30 BemcTwMask::~BemcTwMask()
31 {
32  if (txtH) delete txtH; txtH = 0;
33 }
34 
35 //--------------------------------------
36 void BemcTwMask::clear() {
37  for (int i = 0;i < nPl;i++) {
38  crG[i].Clear();
39  crG2[i].Clear();
40  }
41  nMask = 0;
42  memset(crCh, 0, sizeof(crCh));
43  if (txtH) txtH->Clear();
44 }
45 
46 //--------------------------------------
47 bool useBtowMask(const Char_t *fname, BemcTwMask *m) {
48  if (!(fname && fname[0] && m)) return false;
49 
50  LOG_INFO << "BEMCPlots::useTwMask(\"" << fname << "\") ..." << endm;
51 
52  string line;
53  Int_t softid, cr, seq, TWmask, HTmask ,TPmask, tp;
54  Int_t plot, channelinplot, nok=0;
55  Float_t ped;
56  Char_t name[1000];
57 
58  ifstream BemcStatusFile(fname);
59 
60  if (!BemcStatusFile) {
61  LOG_ERROR << "BemcTwMask:: useBTowMask Failed due to NO FILE" << endm;
62  m->clear();
63  return false;
64  }
65 
66  if (BemcStatusFile)
67  {
68  if (BemcStatusFile.is_open())
69  {
70  while (! BemcStatusFile.eof() )//loop until you get to the end of the file
71  {
72  std::getline(BemcStatusFile,line);//get next line in files
73  size_t comment=line.find("#",0); //check for # in line
74  size_t trigger=line.find("trigger",0);//check for "trigger" in line
75  if (comment!=string::npos) continue; //skip comment line
76  if (trigger!=string::npos) continue; //skip trigger mask line
77  istringstream iss; iss.str(line);//parse line for
78  iss>>name>>softid>>cr>>seq>>TWmask>>HTmask>>TPmask>>ped>>tp;
79  if (softid<1||softid>4800) return 0;//sanity check
80 
81  if (TWmask!=1){//if status !=good
82 
83  channelinplot=softid;
84 
85  if ((softid>0)&&(softid<=1220)) plot=0;
86  if ((softid>1220)&&(softid<=2400)) plot=1;
87  if ((softid>2400)&&(softid<=3540)) plot=2;
88  if ((softid>3540)&&(softid<=4800)) plot=3;
89 
90  int jj=m->crG[plot].GetN();
91  m->crG[plot].SetPoint(jj,channelinplot,-10);
92  m->crG[plot].SetPoint(jj+1,channelinplot,100000);
93  m->crG[plot].SetPoint(jj+2,channelinplot,-10);
94  //m->crG2[plot].SetPoint(jj,channelinplot,-10);
95  //m->crG2[plot].SetPoint(jj+1,channelinplot,100000);
96  //m->crG2[plot].SetPoint(jj+2,channelinplot,-10);
97 
98  nok++;
99  }
100  }
101  }
102  BemcStatusFile.close();
103  }
104 
105  m->nMask=nok;
106 
107  for(int i=0;i<m->nPl;i++){
108  m->crG[i].SetMarkerStyle(23);
109  m->crG[i].SetMarkerColor(kRed);
110  //m->crG2[i].SetMarkerStyle(1);
111  //m->crG2[i].SetLineColor(kRed);
112  }
113  return true;
114 }