eventAnalysis  7.0-49-g0ac7482
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TBeamSummaryDataModule.cxx
Go to the documentation of this file.
2 
3 #include <TFile.h>
4 #include <TSystem.h>
5 #include <TBeamDataSingleton.hxx>
6 
9 
10 
11 #include "../cvstags/TBeamSummaryDataModule.cxx"
12 
13 
15  const char* title) {
16  SetNameTitle(name, title);
17  // Enable this module by default:
18  fIsEnabled = kTRUE;
19  fDescription =
20  "Module incorporating Beam Summary Data as provided by the beamline "
21  "group";
23  fCVSID = CVSID;
25  new TClonesArray("ND::TBeamSummaryDataModule::TBeamSummaryData", 200);
26 
27  fTotalEvents = 0;
28  fEventsWithNoBSD = 0;
29 }
30 
32  ND280Log("TBeamSummaryDataModule summary; total events processed = "
33  << fTotalEvents
34  << "; total events with no BSD information = " << fEventsWithNoBSD);
35 }
36 
38 
40  // HEADER INFO
41  fOutputTree->Branch("BeamSummaryDataStatus", &fBeamSummaryDataStatus,
42  "BeamSummaryDataStatus/I", fBufferSize);
43  fOutputTree->Branch("ND280Spill", &fND280Spill, "ND280Spill/I", fBufferSize);
44  fOutputTree->Branch("BeamSummaryData", &fBeamSummaryData, fBufferSize,
45  fSplitLevel);
46  fOutputTree->GetBranch("BeamSummaryDataStatus")
47  ->SetTitle(
48  " Flag : Beam Summary Data is available or not in the spill. 1 = "
49  "BSD is available. 0 is not.");
50  fOutputTree->GetBranch("ND280Spill")
51  ->SetTitle(" ND280 Spill Number. 16 bit.");
52 }
53 
55 
56  if(fFilledConfigTree){
57  ND280NamedWarn("TBeamSummaryDataModule", "Module: " << this->GetName()
58  << " has already written the config tree this run.");
59  }
60  configTree->Branch("TotalEvents", &fTotalEvents);
61  configTree->Branch("EventsWithNoBSD", &fEventsWithNoBSD);
62 
64 }
65 
66 // finding spill and filling information //
67 bool ND::TBeamSummaryDataModule::FillTree(ND::TND280Event& event) {
68  fBeamSummaryDataStatus = 0;
69  fTotalEvents++;
70 
71  if (event.GetContext().IsMC()) return true;
72 
73  ND::TRawBeamData& fRawBeamData = ND::TBeamDataSingleton::Get();
74  fBeamSummaryData->Clear();
75 
76  Int_t spill = event.GetHeader().GetSpillNumber();
77  fND280Spill = spill;
78  Int_t mcmTime = event.GetHeader().GetMCMSecond();
79  Int_t trigger = event.GetHeader().GetTriggerBits();
80 
81  if (trigger != 1) {
82  return true;
83  }
84 
85  bool ret = fRawBeamData.GetSpill(spill, mcmTime, 1);
86 
87  if (ret == true && (mcmTime - fRawBeamData.GetTriggerTime(0)) >= 0) {
88  fBeamSummaryDataStatus = 1;
89  TBeamSummaryData* bsd = new ((*fBeamSummaryData)[0]) TBeamSummaryData;
90 
91  bsd->BeamRunNumber = fRawBeamData.GetBeamRunNumber();
92  bsd->SpillNumber = fRawBeamData.GetSpillNumber();
93  bsd->GPS1TriggerTime = fRawBeamData.GetTriggerTime(0);
94  bsd->GPS1TriggerTimeNanoSecond = fRawBeamData.GetTriggerTimeNanoSecond(0);
95  bsd->CT5ProtonsPerSpill = fRawBeamData.GetProtonsPerSpill(4);
96  bsd->GoodSpillFlag = fRawBeamData.GetGoodSpillFlag();
97  bsd->Horn1CurrentSum = fRawBeamData.GetHornCurrent(0);
98  bsd->Horn2CurrentSum = fRawBeamData.GetHornCurrent(1);
99  bsd->Horn3CurrentSum = fRawBeamData.GetHornCurrent(2);
100  bsd->BSDVersion = fRawBeamData.GetBSDVersion();
101 
102  // We have to think about numbering spills. //
103  for (int bunch_1 = 0; bunch_1 < 8; ++bunch_1) {
104  bsd->CT5ProtonsPerBunch[bunch_1] =
105  fRawBeamData.GetProtonsPerBunch(4, bunch_1 + 1);
106  bsd->CT5BeamBunchTiming[bunch_1] =
107  fRawBeamData.GetBeamBunchTiming(4, bunch_1 + 1);
108  bsd->CT5BeamBunchFlag[bunch_1] =
109  fRawBeamData.GetBeamBunchFlag(4, bunch_1 + 1);
110  }
111 
112  // Using calculating the official values for Protons per spill
113  // Also need to set this up for the proper variables. Will
114  // change to beamData variables once things are set up
115  // there. End user should use any variable with the name
116  // starting Official rather than CT5
117  int tmpct = -1;
119  fRawBeamData.GetCTPOT(0); // Using official POT for total POT per spill
120  for (int whichct = 0; whichct < 5;
121  ++whichct) { // loop to find official CT number
122  if (fRawBeamData.GetProtonsPerSpill(whichct) ==
123  fRawBeamData.GetCTPOT(0)) {
124  bsd->OfficialCTNumber = whichct + 1;
125  tmpct = whichct; // variable to make life in the next few lines easier
126  }
127  }
128  bsd->OfficialBeamFlag = fRawBeamData.GetBeamFlag(tmpct);
129  for (int bunch_1 = 0; bunch_1 < 8; ++bunch_1) {
130  bsd->OfficialProtonsPerBunch[bunch_1] =
131  fRawBeamData.GetCTPOT(bunch_1 + 1); // Get the official POT/bunch
132  bsd->OfficialBeamBunchTiming[bunch_1] =
133  fRawBeamData.GetBeamBunchTiming(tmpct, bunch_1 + 1);
134  bsd->OfficialBeamBunchFlag[bunch_1] =
135  fRawBeamData.GetBeamBunchFlag(tmpct, bunch_1 + 1);
136  }
137 
138  bsd->OtherData.SpillNumber = fRawBeamData.GetSpillNumber();
139  bsd->OtherData.MRRunNumber = fRawBeamData.GetMRRunNumber();
140  bsd->OtherData.BeamRunNumber = fRawBeamData.GetBeamRunNumber();
141  // bsd->OtherData.MRShotNumber = fRawBeamData.GetMRShotNumber();
142 
143  bsd->OtherData.SpillFlag = fRawBeamData.GetSpillFlag();
144  bsd->OtherData.TriggerFlag = fRawBeamData.GetTriggerFlag();
145  bsd->OtherData.GoodGPSFlag = fRawBeamData.GetGoodGPSFlag();
146  bsd->OtherData.GoodSpillFlag = fRawBeamData.GetGoodSpillFlag();
147 
148  bsd->OtherData.MagSetID = fRawBeamData.GetMagSetID();
149  bsd->OtherData.RunType = fRawBeamData.GetRunType();
150  // bsd->OtherData.MidasEvent = fRawBeamData.GetMidasEvent();
151 
152  for (int iGPS = 0; iGPS < 3; ++iGPS) {
153  bsd->OtherData.TriggerTime[iGPS] = fRawBeamData.GetTriggerTime(iGPS);
154  bsd->OtherData.TriggerTimeNanoSecond[iGPS] =
155  fRawBeamData.GetTriggerTimeNanoSecond(iGPS);
156  }
157  bsd->OtherData.GPSStatus[0] = fRawBeamData.GetGPSStatus(0);
158  bsd->OtherData.GPSStatus[1] = fRawBeamData.GetGPSStatus(1);
159 
160  for (int ct = 0; ct < 5; ++ct) {
161  bsd->OtherData.BeamTiming[ct] = fRawBeamData.GetBeamTiming(ct);
162  bsd->OtherData.BeamFlag[ct] = fRawBeamData.GetBeamFlag(ct);
163  bsd->OtherData.ProtonsPerSpill[ct] = fRawBeamData.GetProtonsPerSpill(ct);
164 
165  for (int bunch_2 = 0; bunch_2 < 9; ++bunch_2) {
166  bsd->OtherData.ProtonsPerBunch[ct][bunch_2] =
167  fRawBeamData.GetProtonsPerBunch(ct, bunch_2);
168  bsd->OtherData.BeamBunchTiming[ct][bunch_2] =
169  fRawBeamData.GetBeamBunchTiming(ct, bunch_2);
170  bsd->OtherData.BeamBunchFlag[ct][bunch_2] =
171  fRawBeamData.GetBeamBunchFlag(ct, bunch_2);
172  }
173  }
174 
175  for (int ihorn = 0; ihorn < 3; ++ihorn) {
176  bsd->OtherData.HornCurrent[ihorn] = fRawBeamData.GetHornCurrent(ihorn);
177 
178  for (int ch = 0; ch < 5; ++ch) {
179  bsd->OtherData.HornBusBarCurrent[ihorn][ch] =
180  fRawBeamData.GetHornBusBarCurrent(ihorn, ch);
181  }
182  }
183  for (int dir = 0; dir < 2; ++dir) {
184  bsd->OtherData.BeamDirectionOnTarget[dir] =
185  fRawBeamData.GetBeamDirectionOnTarget(dir);
186  bsd->OtherData.BeamSizeOnTarget[dir] =
187  fRawBeamData.GetBeamSizeOnTarget(dir);
188  }
189 
190  bsd->OtherData.MumonSiTotalQ = fRawBeamData.GetMumonSiTotalQ();
191  bsd->OtherData.MumonSiPeak = fRawBeamData.GetMumonSiPeak();
192  bsd->OtherData.MumonSiX = fRawBeamData.GetMumonSiX();
193  bsd->OtherData.MumonSiwX = fRawBeamData.GetMumonSiwX();
194  bsd->OtherData.MumonSiY = fRawBeamData.GetMumonSiY();
195  bsd->OtherData.MumonSiwY = fRawBeamData.GetMumonSiwY();
196 
197  bsd->OtherData.MumonICTotalQ = fRawBeamData.GetMumonICTotalQ();
198  bsd->OtherData.MumonICPeak = fRawBeamData.GetMumonICPeak();
199  bsd->OtherData.MumonICX = fRawBeamData.GetMumonICX();
200  bsd->OtherData.MumonICwX = fRawBeamData.GetMumonICwX();
201  bsd->OtherData.MumonICY = fRawBeamData.GetMumonICY();
202  bsd->OtherData.MumonICwY = fRawBeamData.GetMumonICwY();
203 
204  bsd->OtherData.OTRX = fRawBeamData.GetOTRX();
205  bsd->OtherData.OTRY = fRawBeamData.GetOTRY();
206  bsd->OtherData.OTRwX = fRawBeamData.GetOTRwX();
207  bsd->OtherData.OTRwY = fRawBeamData.GetOTRwY();
208  bsd->OtherData.OTRXError = fRawBeamData.GetOTRXError();
209  bsd->OtherData.OTRYError = fRawBeamData.GetOTRYError();
210  bsd->OtherData.OTRwXError = fRawBeamData.GetOTRwXError();
211  bsd->OtherData.OTRwYError = fRawBeamData.GetOTRwYError();
212  bsd->OtherData.OTRLightYield = fRawBeamData.GetOTRLightYield();
213  }
214 
215  if (fBeamSummaryDataStatus == 0) {
216  fBeamSummaryDataStatus = -1;
217  // throw ND::ENoBeamSummaryData(); // temporarily disable throwing
218  // exception; want to be able to process all data.
219  fEventsWithNoBSD++;
220  }
221  return true;
222 }
223 
225  return true;
226 }
227 
228 Bool_t ND::TBeamSummaryDataModule::Configure(std::string& option) {
229  SetEnabled(kFALSE);
230  /*
231  std::string filenameOrDirectory = option;
232 
233  void* dirp = gSystem->OpenDirectory(filenameOrDirectory.c_str());
234 
235  if(dirp) {
236  const char* fname = 0;
237  while((fname = gSystem->GetDirEntry(dirp))) {
238  std::string filePath = Form("%s/%s", filenameOrDirectory.c_str(), fname);
239  TFile *f = new TFile(filePath.c_str());
240  if(f && !f->IsZombie() && f->Get("bsd")) {
241  fBSDTree->Add(filePath.c_str());
242  }
243  delete f;
244  }
245  }
246  else {
247  TFile *f = new TFile(filenameOrDirectory.c_str());
248  if(f && !f->IsZombie() && f->Get("bsd")) {
249  fBSDTree->Add(filenameOrDirectory.c_str());;
250  }
251  delete f;
252  }
253  */
254  return true;
255 }
256 
void FillConfigTree(TTree *configTree)
#define CVSID
Double_t MumonSiwY
Beam Y Width on MUMON measured by the Sidetectors. [mm].
Int_t GPSStatus[2]
Status of GPS. [0] = GPS1, [1] = GPS2.
Double_t MumonICwY
Beam Y Width on MUMON measured by the ionizationchambers [mm].
virtual Bool_t ProcessFirstEvent(ND::TND280Event &)
Is meant to reference back to the original file [FIXME] The EventTRef does not currently work...
Int_t GoodSpillFlag
Good Spill Flag. Values &gt;=1 = Good Spill, with 1being at 250 kA, 2 at 200 kA, 100 at 0 kA...
virtual bool FillTree(ND::TND280Event &)
Fill all the stuff that goes in the output tree.
virtual void InitializeBranches()
Initialize Branches. Don&#39;t do anything else in this function.
Int_t OfficialBeamFlag
Flag describing that the Proton Beam isdetected or not for the official CT for a givenspill. 1 = extracted, 0 = not extracted.
ClassImp(ND::TBeamSummaryDataModule::TBeamSummaryData)
Double_t ProtonsPerSpill[5]
Number of Protons in the SPILL countedby CTs, [0] = CT1,..[4] = CT5.
Double_t BeamBunchFlag[5][9]
Flag describing that the Proton Beamis detected by CTs or not in the BUNCH(1st-8th). 1 = extracted, 0 = notextracted.
std::string fDescription
A longish descrition of the analysis.
Double_t OTRX
Beam X Position measured by the OTR. [mm].
Double_t HornCurrent[3]
Horn Current. [0-3] = Horn1 - Horn3. [kA].
Double_t MumonSiY
Beam Y Position on MUMON measured by the Sidetectors. [mm].
Int_t GoodSpillFlag
Status Flag of Spill. This Flag contains allinformation above and should be used to defindethe flag i...
Int_t BeamRunNumber
Beam Run Number in neutrino beamline.
Int_t TriggerFlag
Status Flag of Beam Trrigger. 1 = GOOD. 0 = BAD.
Double_t CT5BeamBunchTiming[8]
Timing of Proton beam BUNCH (1st-8th)measured by CT5, which is the mostdownstream charge transferer...
Double_t BeamTiming[5]
Timing of Proton beam measured by CTs. [0-4]= CT1-CT5. Time 0 is Trigger Time. [micro sec]...
TBeamSummaryDataModule(const char *name="BeamSummaryData", const char *title="Beam Summary Data")
Double_t CT5ProtonsPerBunch[8]
Number of Protons in the BUNCH(1st-8th) counted by CT5, which is themost downstream charge transferer...
Int_t BeamRunNumber
Beam Run Number in Neutrino beamline.
Int_t CT5BeamBunchFlag[8]
Flag describing that the Proton Beam isdetected by CT5 or not in the BUNCH(1st-8th). 1 = extracted, 0 = not extracted.
std::string fCVSID
Defined if an official tagged version.
Double_t MumonSiwX
Beam X Width on MUMON measured by the Sidetectors. [mm].
void SetNameTitle(char const *name, char const *title)
Double_t OTRwY
Beam Y Width measured by the OTR. [mm].
Int_t SpillFlag
Status Flag of Spill. 1 = GOOD. 0 = BAD.
TClonesArray * fBeamSummaryData
Data structure which contains beamsummary data information.
Double_t CT5ProtonsPerSpill
Number of Protons in the SPILL counted byCT5, which is the most downstream chargetransferer. [POT].
Double_t MumonICTotalQ
MUMON Total Charge measured by theionization chambers.
Int_t GoodGPSFlag
Status Flag of GPSs. 1 = GOOD. 0 = BAD.
Double_t BeamSizeOnTarget[2]
Beam Size on the target. [0..1] = [xand y]. [mm].
virtual void InitializeModule()
Initialize Module, override if necessary.
Double_t BeamDirectionOnTarget[2]
Beam Direction on the target.[0..1] = [x and y]. [mm].
Int_t TriggerTimeNanoSecond[3]
Trigger Time for sub-second (in nanosec), [0] = GPS1, [1] = GPS2, [2] = Rbclock system.
Double_t OTRwX
Beam X Width measured by the OTR. [mm].
Double_t BeamBunchTiming[5][9]
Timing of Proton beam BUNCH measuredby CTs. [0-4] = CT1-CT5, [0-8] = Wholeof bunches, 1st bunch, ... 8th bunch.Time 0 is Trigger Time. [micro sec].
Double_t OTRY
Beam Y Position measured by the OTR. [mm].
virtual Bool_t Configure(std::string &option)
A function that allows the module to be configured from an external class without any dependencies...
Double_t MumonSiX
Beam X Position on MUMON measured by the Sidetectors. [mm].
Double_t OfficialBeamBunchTiming[8]
Timing of Proton beam BUNCH(1st-8th) in the official analysis,usually CT5. Time 0 is TriggerTime...
Int_t GPS1TriggerTime
GPS1 Trigger Time (Unix Time in sec)
std::string fCVSTagName
Defined if an official tagged version.
#define CVSTAG
Double_t OfficialCTNumber
Gives the CT used for the POT calculation.Usually CT5.
Double_t MumonICY
Beam Y Position on MUMON measured by theionization chambers [mm].
Int_t OfficialBeamBunchFlag[8]
Flag describing that the Proton Beamis detected or not in the BUNCH(1st-8th) for the official CT for ...
Double_t MumonICPeak
MUMON Peak measured by the ionization chambers.
TString BSDVersion
BSD version information. Currently &quot;v01&quot; is thenewest.
Double_t HornBusBarCurrent[3][5]
Horn Current for each busbar.[0..3][] = Horn1..Horn3. [][0..4] =individual ch. [kA].
Double_t MumonSiTotalQ
MUMON Total Charge measured by the Si detectors.
Int_t TriggerTime[3]
Trigger Time (Unix Time in sec), [0] = GPS1,[1] = GPS2, [2] = Rb clock system.
Double_t MumonICX
Beam X Position on MUMON measured by theionization chambers [mm].
Double_t OfficialProtonsPerBunch[8]
Number of Protons in the BUNCH(1st-8th) counted in the officialanalysis, normally from CT5...
Int_t GPS1TriggerTimeNanoSecond
GPS1 Trigger Time for sub-second (innano sec)
Double_t MumonICwX
Beam X Width on MUMON measured by the ionizationchambers [mm].
Double_t OfficialProtonsPerSpill
Number of Protons in the SPILL forthe official analysis, normally CT5.[POT].
Double_t ProtonsPerBunch[5][9]
Number of Protons in the BUNCHcounted by CTs, [0-4] = CT1-CT5, [0-8]= Whole of bunches, 1st bunch, ... 8thbunch.
Double_t BeamFlag[5]
Flag describing that the Proton Beam isdetected by CTs or not. 1 = extracted, 0 = notextracted...
virtual void FillConfigTree(TTree *)

Package Summary
Package Name: eventAnalysis
Package Version: 7.0-49-g0ac7482
Package Manager:

Generated on Mon Mar 25 2024 14:43:58 for eventAnalysis by doxygen 1.8.5