digibuilder.C

digibuilder macro - Ivan Muzalevsky, 08/14/2020 05:32 PM

Download (3.7 KB)

 
1
TString MakeConditionBeamID();
2
TString MakeConditionMWPCtime();
3

    
4
#include "/home/muzalevskii/work/macro/exp2001/beamCut.C"
5

    
6
void digibuilder(TString InFile, TString OutFile) {
7

    
8
  beamCut();
9

    
10
  TString inputdir = gSystem->Getenv("VMCWORKDIR");
11

    
12
  inputdir = "/home/muzalevskii/work/macro/h7_1904/parameters/";
13

    
14
  TString confFile = "/home/muzalevskii/work/macro/exp2001/digi/setupEXP2001.xml";
15

    
16
  TChain *ch = new TChain("stepRepackingxTree");
17
  ch->Add(InFile.Data());
18
  Int_t nEvents = ch->GetEntries();
19
  delete ch;
20
  cout << nEvents << " will be processed" << endl;
21
  std::cout << ">>> input file is " << InFile  << std::endl;
22
  std::cout << ">>> output file is " << OutFile << std::endl;
23

    
24
  // --- Source task
25
  ERDigibuilder* builder = new ERDigibuilder();
26
  builder->SetConfigurationFile(confFile);
27

    
28
  // UserCuts
29
  TString cut("");
30
  cut+=("DetEventCommon.trigger==1 && ");
31
  cut+=("Beam_detector_MWPC1.@fData.GetEntries()>0 && ");
32
  cut+=("Beam_detector_MWPC2.@fData.GetEntries()>0 && ");
33
  cut+=("Beam_detector_MWPC3.@fData.GetEntries()>0 && ");
34
  cut+=("Beam_detector_MWPC4.@fData.GetEntries()>0 && ");
35

    
36
  cut+=("Beam_detector_tMWPC.@fData.GetEntries()>0 && ");
37

    
38
  cut+=("Beam_detector_tF3.@fData.GetEntries()==4 && ");  
39
  cut+=("Beam_detector_tF5.@fData.GetEntries()==4 && ");   
40
  cut+=("Beam_detector_F3.@fData.GetEntries()==4 && ");
41
  cut+=("Beam_detector_F5.@fData.GetEntries()==4");
42

    
43
  cut.Append(" && " + (TString)cutF5_cal->GetName() + " && ");
44
  cut.Append((TString)cutF3_cal->GetName());
45
  cut.Append(" && " + MakeConditionMWPCtime());  
46

    
47

    
48
  cout << " Its my cut " << endl;
49
  cout << cut.Data() << endl;
50
  builder->SetUserCut(cut.Data(),kFALSE);
51

    
52
  builder->AddFile(InFile);
53

    
54
  ERBeamDetUnpack* beamDetUnpack = new ERBeamDetUnpack("Beam_detector");
55
  beamDetUnpack->SetToFCalibration(0.0625, 0., 0.0625, 0.); //aF3, bF3, aF5, bF5
56
  beamDetUnpack->SetMWPCCalibration(0.0625,0.);
57
  
58
  
59
  builder->AddUnpack(beamDetUnpack);
60

    
61
  // --- Run
62
  FairRunOnline *run = new FairRunOnline(builder);
63
  run->SetOutputFile(OutFile);
64

    
65
  ERBeamTimeEventHeader* header = new ERBeamTimeEventHeader();
66
  run->SetEventHeader(header);
67

    
68
  // -----   Logger settings --------------------------------------------
69
  FairLogger::GetLogger()->SetLogScreenLevel("INFO");
70

    
71
  // --- Start run
72
  TStopwatch timer;
73
  timer.Start();
74
  std::cout << ">>> Starting run..." << std::endl;
75
  run->Init();
76
  run->Run(0,nEvents);
77

    
78
  timer.Stop();
79
  
80
  // --- End-of-run info
81
  Double_t rtime = timer.RealTime();
82
  Double_t ctime = timer.CpuTime();
83
  std::cout << std::endl << std::endl;
84
  std::cout << ">>> Macro finished successfully." << std::endl;
85
  std::cout << ">>> Output file is " << OutFile << std::endl;
86
  std::cout << ">>> Real time " << rtime << " s, CPU time "
87
            << ctime << " s" << std::endl;
88
}
89

    
90

    
91
TString MakeConditionMWPCtime() {
92

    
93
  ////////////////////////////////////////////
94
  //time in MWPC
95
  ////////////////////////////////////////////
96

    
97
  TString timeF5 = "0.0625*0.25*(Beam_detector_tF5.fData.fValue[0]"
98
                "+Beam_detector_tF5.fData.fValue[1]"
99
                "+Beam_detector_tF5.fData.fValue[2]"
100
                "+Beam_detector_tF5.fData.fValue[3])";
101

    
102
  TString tMWPCX1 = "0.0625*Beam_detector_tMWPC.fData.fValue[0]";
103
  TString tMWPCY1 = "0.0625*Beam_detector_tMWPC.fData.fValue[1]";
104
  TString tMWPCX2 = "0.0625*Beam_detector_tMWPC.fData.fValue[2]";
105
  TString tMWPCY2 = "0.0625*Beam_detector_tMWPC.fData.fValue[3]";
106

    
107
  TString condition = "( ("+tMWPCX1+"-"+timeF5+")>55. && ("+tMWPCX1+"-"+timeF5+")<85."
108
          +" && ("+tMWPCY1+"-"+timeF5+")>55. && ("+tMWPCY1+"-"+timeF5+")<85."
109
          +" && ("+tMWPCX2+"-"+timeF5+")>55. && ("+tMWPCX2+"-"+timeF5+")<85."
110
          +" && ("+tMWPCY2+"-"+timeF5+")>55. && ("+tMWPCY2+"-"+timeF5+")<85.)";
111

    
112
  return condition;
113
}