FillRawDigits.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \version
3 ////////////////////////////////////////////////////////////////////////
4 #include "FillRawDigits.h"
5 #include <vector>
6 #include <cmath>
7 #include "TH1.h"
8 #include "TH2.h"
9 #include "TH3.h"
10 #include "TSystem.h"
11 #include "Config/Config.h"
12 #include "Config/Param.h"
13 #include "EventDataModel/EventHandle.h"
14 #include "JobControl/Exception.h"
15 #include "JobControl/ModuleFactory.h"
16 #include "RawData/DAQHeader.h"
17 #include "RawData/RawDigit.h"
18 //#include "NOvAFMWK/Utilities/EDMUtils.h"
19 #include "Geometry/geo.h"
20 #include "Geometry/PlaneGeo.h"
21 //#include "CMap/CMap.h"
22 #include "Header/Header.h"
23 
24 #include "XMLInterface/xmli.h"
25 #include "Config/cfg.h"
26 #include "JobControl/jobc.h"
27 #include "EventDataModel/edm.h"
28 #include "Geometry/Geometry.h"
29 //#include "NOvAFMWK/Utilities/RandomHandler.h"
30 
31 #include "DAQDataFormats/RawEvent.h"
32 
33 //#include "DAQ2RawDigit/FlatDAQData/FlatDAQData.h"
34 #include "DAQDataFormats/BitFields.h"
35 
36 #include "IoModules/RWFactory.h"
37 #include <cstdlib>
38 #include <iostream>
39 
40 static int nevents = 0;
41 
42 using namespace rawp;
43 using namespace daqdataformats;
44 
45 
47 
48 
49 //......................................................................
50 
52  jobc::Module("rawp::FillRawDigits")
53 {
54 
55  this->SetCfgVersion(version);
56 
57 
58 }
59 
60 //......................................................................
61 
62 void FillRawDigits::Update(const cfg::Config& /*c*/) { }
63 
64 //......................................................................
65 
67 {
68 }
69 
70 //......................................................................
71 
72 jobc::Result FillRawDigits::Reco(edm::EventHandle& evt)
73 {
74 evt.Header().SetEvent(nevents);
75 
76  std::cout << "From FillRawDigits::Reco. run : " << evt.Header().Run()
77  << " subrun : " << evt.Header().Subrun()
78  << " event : " << evt.Header().Event() << std::endl;
79 
80 
81  std::cout<<"\nNeVents ="<<nevents<<"\n";
82 
83  ///setup the Header
84  //hdr::Header header;
85 
87  header.SetVersion ("MonteCarlo", "DAQsim");
88  header.SetRandomSeed ("DAQsim" , 0);
89  header.SetConfiguration("DAQsim" , "muons");
90  header.SetConfiguration("Geometry" , "ndos.gdml");
91  //lsheader.SetConfiguration("DAQsim" , nova_jobc::XMLConfiguration());
92 
93 
94  //Create vector of Digit Lists
95  std::vector<rawdata::RawDigit> rawdigitlist(0);
96 
97  //ev.print();
98 
99  rawdata::RawDigit digit;
100 
101 
102  //int fillrawdigit = 621;
103  int fillrawdigit = 0;
104  int rawdigitnumber = 0;
105 
106  for(int i=-1; i < nevents; ++i){
107 
108  //first 5 Blocks
109  for(uint32_t ihorizontal = 1; ihorizontal < 78; ++ihorizontal)
110  for(uint32_t icell = 0; icell < 96; ++icell)
111 
112  {
113  uint32_t plane = ihorizontal*2 - 1;
114  digit.SetChannel(this->getChannel(plane, icell));
115  digit.SetTDC(0,1000);
116  digit.SetADC(0,1000);
117  rawdigitnumber++;
118  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
119 
120  }
121 
122  //first 5 Blocks
123  for(uint32_t ivertical = 1; ivertical < 79; ++ivertical)
124  for(uint32_t icell = 0; icell < 64; ++icell)
125 
126  {
127  uint32_t plane = (ivertical - 1) * 2;
128  digit.SetChannel(this->getChannel(plane, icell));
129  digit.SetTDC(0,1000);
130  digit.SetADC(0,1000);
131  rawdigitnumber++;
132  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
133 
134  }
135 
136 
137  // 6-th block
138  for(uint32_t ivertical = 79; ivertical < 95; ++ivertical)
139  for(uint32_t icell = 0; icell < 64; ++icell)
140  {
141  uint32_t plane = 77 + 79 + (ivertical - 79)*2 -1;
142  digit.SetChannel(this->getChannel(plane, icell));
143  digit.SetTDC(0,1000);
144  digit.SetADC(0,1000);
145  rawdigitnumber++;
146  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
147 
148  }
149 
150  for(uint32_t ihorizontal = 78; ihorizontal < 93; ++ihorizontal)
151  for(uint32_t icell = 0; icell < 96; ++icell)
152 
153  {
154  uint32_t plane = 77 + 79 + (ihorizontal - 78)*2;
155  digit.SetChannel(this->getChannel(plane, icell));
156  digit.SetTDC(0,1000);
157  digit.SetADC(0,1000);
158  rawdigitnumber++;
159  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
160 
161  }
162 
163  // 7-th block
164  for(uint32_t ivertical = 95; ivertical < 101; ++ivertical)
165  for(uint32_t icell = 0; icell < 64; ++icell)
166  {
167  uint32_t plane = 93 + 95 + (ivertical - 95)*2 -1;
168  digit.SetChannel(this->getChannel(plane, icell));
169  digit.SetTDC(0,1000);
170  digit.SetADC(0,1000);
171  rawdigitnumber++;
172  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
173 
174  }
175 
176  for(uint32_t ihorizontal = 93; ihorizontal < 100; ++ihorizontal)
177  for(uint32_t icell = 0; icell < 96; ++icell)
178 
179  {
180  uint32_t plane = 93 + 94 + (ihorizontal - 93)*2 - 1;
181  digit.SetChannel(this->getChannel(plane, icell));
182  digit.SetTDC(0,1000);
183  digit.SetADC(0,1000);
184  rawdigitnumber++;
185  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
186 
187  }
188 
189 
190 
191 
192 
193 
194  /*
195  for(uint32_t plane = 0; plane < 186; ++plane){
196 
197  digit.SetChannel(this->getChannel(plane, 5));
198  digit.SetTDC(0,1000+i*10);
199  digit.SetADC(0,20+i*5);
200  rawdigitnumber++;
201  if(fillrawdigit == rawdigitnumber||fillrawdigit==0)rawdigitlist.push_back(digit);
202 
203  }//end of loop over planes
204 
205  */
206 
207 
208  }
209 
210 
211 
212 
213  ///clear the evt as it is the same handle for every spill
214 
215 
216  //if(!fIsHeaderPut){
217  evt.Clear();
218  std::cout<<"From FillRawDigits::Reco. Putting the header\n";
219  evt.DAQ().Put(header, ".");
220  std::cout<<"From FillRawDigits::Reco. End of Pitting the header\n";
221  //}
222 
223  // Write the raw digits into the event
224  if(evt.Raw().GetFolder(".") == 0)
225  evt.Raw().MakeFolder(".");
226 
227  for (unsigned int i=0; i<rawdigitlist.size(); ++i) {
228  evt.Raw().Put(rawdigitlist[i],".");
229  }
230 
231 
232  std::cout<<"End of job\n";
233 
234 
235  ++nevents;
236  return jobc::kPassed;
237 
238 }
239 
240 ////////////////////////////////////////////////////////////////////////
241 
242 
243 uint32_t FillRawDigits::getChannel(uint32_t plane, uint32_t cell){
244 
245  uint32_t chan = 0x0;
248 
249  return chan;
250 }
251 
jobc::Result Reco(edm::EventHandle &evt)
void SetTDC(int32_t iTDC)
Definition: RawDigit.cxx:116
static int nevents
A module to process the Flat files.
Definition: FillRawDigits.h:33
void SetChannel(uint32_t iChan)
Definition: RawDigit.h:99
std::string Header(std::string label)
void SetADC(uint32_t i, int16_t iADC)
Definition: RawDigit.cxx:108
void Update(const cfg::Config &c)
uint32_t getChannel(uint32_t plane, uint32_t cell)
Diblock ID, (6bit), valid range 1-15.
int evt
DCM ID, (6bit), valid range 1-384.
OStream cout
Definition: OStream.cxx:6
const XML_Char * version
Definition: expat.h:187
#define BITFIELDSET(block, data, mask, shift)
Definition: BitFields.h:24
Class to hold the data from the FEBs in correct formats.
FillRawDigits(const char *version)
Encapsulate the geometry of one entire detector (near, far, ndos)
MODULE_DECL(rawp::FillRawDigits)