Changeset 214 in Idarraga
- Timestamp:
- Jul 20, 2011, 1:28:03 AM (13 years ago)
- Location:
- EUTelraw2mdm
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EUTelraw2mdm/USBpixI4ConverterPlugin.cc
r202 r214 16 16 # include "IMPL/LCGenericObjectImpl.h" 17 17 # include "UTIL/CellIDEncoder.h" 18 19 #include "eudaq/write_mdm.h" 20 18 21 #endif 19 22 … … 30 33 31 34 namespace eudaq { 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 35 // The event type for which this converter plugin will be registered 36 // Modify this to match your actual event type (from the Producer) 37 static const std::string EVENT_TYPE = "USBPIXI4"; 38 39 static const unsigned int CHIP_MIN_COL = 1; 40 static const unsigned int CHIP_MAX_COL = 80; 41 static const unsigned int CHIP_MIN_ROW = 1; 42 static const unsigned int CHIP_MAX_ROW = 336; 43 static const unsigned int CHIP_MAX_ROW_NORM = CHIP_MAX_ROW - CHIP_MIN_ROW; // Maximum ROW normalized (starting with 0) 44 static const unsigned int CHIP_MAX_COL_NORM = CHIP_MAX_COL - CHIP_MIN_COL; 45 46 static int chip_id_offset = 20; 47 48 class USBpixI4ConverterBase { 49 private: 50 unsigned int count_boards; 48 51 std::vector<unsigned int> board_ids; 49 52 50 public: 51 unsigned int consecutive_lvl1; 53 public: 54 55 mdm * m_mdmhandler; 56 57 USBpixI4ConverterBase () { 58 59 // The constructor will be called on the first event since I need to know the number of DUT's 60 m_mdmhandler = new mdm(); 61 62 } 63 64 ~USBpixI4ConverterBase() { 65 int nDet = m_mdmhandler->getndet(); 66 for(int detItr = 0 ; detItr < nDet ; detItr++) { 67 WriteToNtuple::GetInstance("", "", nDet, m_mdmhandler->getDetIdToIndexArray()[detItr], m_mdmhandler->getDetIdToIndexArray())->closeNtuple(); 68 } 69 } 70 71 unsigned int consecutive_lvl1; 52 72 unsigned int tot_mode; 53 73 int first_sensor_id; 54 74 55 75 int getCountBoards() { 56 76 return count_boards; 57 77 } … … 66 86 } 67 87 68 88 void getBOREparameters (const Event & ev) { 69 89 count_boards = ev.GetTag ("boards", -1); 70 90 board_ids.clear(); … … 201 221 return plane; 202 222 } 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 }; 224 225 // Declare a new class that inherits from DataConverterPlugin 226 class USBPixI4ConverterPlugin : public DataConverterPlugin , public USBpixI4ConverterBase { 227 228 public: 229 230 // This is called once at the beginning of each run. 231 // You may extract information from the BORE and/or configuration 232 // and store it in member variables to use during the decoding later. 233 virtual void Initialize(const Event & bore, 234 const Configuration & cnf) { 235 (void)cnf; // just to suppress a warning about unused parameter cnf 236 getBOREparameters (bore); 237 } 238 239 // This should return the trigger ID (as provided by the TLU) 240 // if it was read out, otherwise it can either return (unsigned)-1, 241 // or be left undefined as there is already a default version. 242 virtual unsigned GetTriggerID(const Event & ev) const { 223 243 224 244 // Make sure the event is of class RawDataEvent … … 236 256 } 237 257 238 239 240 241 258 // Here, the data from the RawDataEvent is extracted into a StandardEvent. 259 // The return value indicates whether the conversion was successful. 260 // Again, this is just an example, adapted it for the actual data layout. 261 virtual bool GetStandardSubEvent(StandardEvent & sev, const Event & ev) const { 242 262 if (ev.IsBORE()) { 243 263 return true; … … 253 273 } 254 274 255 256 257 258 #if USE_LCIO && USE_EUTELESCOPE259 260 275 return true; 276 } 277 278 //i- #if USE_LCIO && USE_EUTELESCOPE 279 // This is where the conversion to LCIO is done 280 virtual lcio::LCEvent * GetLCIOEvent(const Event * /*ev*/) const { 261 281 return 0; 262 282 } 263 283 264 284 virtual bool GetLCIOSubEvent(lcio::LCEvent & lcioEvent, const Event & eudaqEvent) const { 265 //std::cout << "getlciosubevent (I4) event " << eudaqEvent.GetEventNumber() << " | " << GetTriggerID(eudaqEvent) << std::endl; 285 286 std::cout << "getlciosubevent (I4) event " << eudaqEvent.GetEventNumber() << " | " << GetTriggerID(eudaqEvent) << std::endl; 287 266 288 if (eudaqEvent.IsBORE()) { 267 289 // shouldn't happen … … 293 315 const RawDataEvent & ev_raw = dynamic_cast <const RawDataEvent &> (eudaqEvent); 294 316 317 // First time. Initialize the mdm handlers, number of DUTs won't change in a run. 318 if (!m_mdmhandler->isInitialized()) { 319 320 // find sensor ID's 321 std::vector<int> sIDs; 322 for (size_t chip = 0; chip < ev_raw.NumBlocks(); ++chip) { 323 // as calculated and stored later in zsDataEncoder["sensorID"] 324 sIDs.push_back(ev_raw.GetID(chip) + chip_id_offset + first_sensor_id); 325 } 326 327 // Initialize the Handler ! 328 m_mdmhandler->init(sIDs, EVENT_TYPE, CHIP_MAX_COL, CHIP_MAX_ROW); 329 330 } 331 295 332 std::vector< eutelescope::EUTelSetupDescription * > setupDescription; 296 333 … … 320 357 // a single TrackerData object (zsFrame) that will correspond to a single sensor in one event 321 358 std::auto_ptr< eutelescope::EUTelSparseDataImpl< eutelescope::EUTelAPIXSparsePixel > > 322 359 sparseFrame( new eutelescope::EUTelSparseDataImpl< eutelescope::EUTelAPIXSparsePixel > ( zsFrame.get() ) ); 323 360 324 361 unsigned int ToT = 0; … … 330 367 unsigned int Word = (((unsigned int)buffer[i + 3]) << 24) | (((unsigned int)buffer[i + 2]) << 16) | (((unsigned int)buffer[i + 1]) << 8) | (unsigned int)buffer[i]; 331 368 369 332 370 if (DATA_HEADER_MACRO(Word)) { 333 371 lvl1++; 334 372 } else { 373 335 374 // First Hit 336 375 if (getHitData(Word, false, Col, Row, ToT)) { … … 338 377 sparseFrame->addSparsePixel( thisHit ); 339 378 tmphits.push_back( thisHit ); 379 380 //std::cout << ".... f -> " << i << " : " << Col << "," << Row << "," << ToT << "," << lvl1-1 << std::endl; 381 // hit to mdm 382 m_mdmhandler->dofill(zsDataEncoder["sensorID"], Col, Row, ToT, lvl1-1); 340 383 } 341 384 // Second Hit … … 344 387 sparseFrame->addSparsePixel( thisHit ); 345 388 tmphits.push_back( thisHit ); 389 390 //std::cout << ".... s -> " << i << " : " << Col << "," << Row << "," << ToT << "," << lvl1-1 << std::endl; 391 // hit to mdm 392 m_mdmhandler->dofill(zsDataEncoder["sensorID"], Col, Row, ToT, lvl1-1); 346 393 } 347 394 } 348 395 } 349 396 397 // Write to mdm ! this member clears the matrix after filling 398 //std::cout << "chip : " << chip << std::endl; 399 m_mdmhandler->writetontuple(zsDataEncoder["sensorID"], lcioEvent.getEventNumber()); 400 350 401 // write TrackerData object that contains info from one sensor to LCIO collection 351 402 zsDataCollection->push_back( zsFrame.release() ); … … 353 404 // clean up 354 405 for( std::list<eutelescope::EUTelAPIXSparsePixel*>::iterator it = tmphits.begin(); it != tmphits.end(); it++ ){ 355 406 delete (*it); 356 407 } 357 408 } … … 380 431 return true; 381 432 382 } 383 #endif 384 385 private: 386 387 // The constructor can be private, only one static instance is created 388 // The DataConverterPlugin constructor must be passed the event type 389 // in order to register this converter for the corresponding conversions 390 // Member variables should also be initialized to default values here. 391 USBPixI4ConverterPlugin() 392 : DataConverterPlugin(EVENT_TYPE) 393 {} 394 395 // The single instance of this converter plugin 396 static USBPixI4ConverterPlugin m_instance; 397 }; 398 399 // Instantiate the converter plugin instance 400 USBPixI4ConverterPlugin USBPixI4ConverterPlugin::m_instance; 433 } 434 //#endif 435 436 private: 437 438 // The constructor can be private, only one static instance is created 439 // The DataConverterPlugin constructor must be passed the event type 440 // in order to register this converter for the corresponding conversions 441 // Member variables should also be initialized to default values here. 442 USBPixI4ConverterPlugin() 443 : DataConverterPlugin(EVENT_TYPE) 444 {} 445 446 // The single instance of this converter plugin 447 static USBPixI4ConverterPlugin m_instance; 448 }; 449 450 // Instantiate the converter plugin instance 451 USBPixI4ConverterPlugin USBPixI4ConverterPlugin::m_instance; 452 401 453 402 454 } // namespace eudaq
Note: See TracChangeset
for help on using the changeset viewer.